2 * Direct3D state management
4 * Copyright 2002 Lionel Ulmer
5 * Copyright 2002-2005 Jason Edmeades
6 * Copyright 2003-2004 Raphael Junqueira
7 * Copyright 2004 Christian Costa
8 * Copyright 2005 Oliver Stieber
9 * Copyright 2006 Henri Verbeet
10 * Copyright 2006-2007 Stefan Dösinger for CodeWeavers
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
32 #include "wined3d_private.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(d3d
);
35 WINE_DECLARE_DEBUG_CHANNEL(d3d_shader
);
37 #define GLINFO_LOCATION stateblock->wineD3DDevice->adapter->gl_info
39 static void state_blendop(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
);
41 static void state_nogl(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
42 /* Used for states which are not mapped to a gl state as-is, but used somehow different,
43 * e.g as a parameter for drawing, or which are unimplemented in windows d3d
45 if(STATE_IS_RENDER(state
)) {
46 WINED3DRENDERSTATETYPE RenderState
= state
- STATE_RENDER(0);
47 TRACE("(%s,%d) no direct mapping to gl\n", debug_d3drenderstate(RenderState
), stateblock
->renderState
[RenderState
]);
49 /* Shouldn't have an unknown type here */
50 FIXME("%d no direct mapping to gl of state with unknown type\n", state
);
54 static void state_undefined(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
55 /* Print a WARN, this allows the stateblock code to loop over all states to generate a display
56 * list without causing confusing terminal output. Deliberately no special debug name here
57 * because its undefined.
59 WARN("undefined state %d\n", state
);
62 static void state_fillmode(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
63 WINED3DFILLMODE Value
= stateblock
->renderState
[WINED3DRS_FILLMODE
];
66 case WINED3DFILL_POINT
:
67 glPolygonMode(GL_FRONT_AND_BACK
, GL_POINT
);
68 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_POINT)");
70 case WINED3DFILL_WIREFRAME
:
71 glPolygonMode(GL_FRONT_AND_BACK
, GL_LINE
);
72 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)");
74 case WINED3DFILL_SOLID
:
75 glPolygonMode(GL_FRONT_AND_BACK
, GL_FILL
);
76 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)");
79 FIXME("Unrecognized WINED3DRS_FILLMODE value %d\n", Value
);
83 static void state_lighting(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
86 /* Lighting is not enabled if transformed vertices are drawn
87 * but lighting does not affect the stream sources, so it is not grouped for performance reasons.
88 * This state reads the decoded vertex declaration, so if it is dirty don't do anything. The
89 * vertex declaration applying function calls this function for updating
92 if(isStateDirty(context
, STATE_VDECL
)) {
96 transformed
= ((stateblock
->wineD3DDevice
->strided_streams
.u
.s
.position
.lpData
!= NULL
||
97 stateblock
->wineD3DDevice
->strided_streams
.u
.s
.position
.VBO
!= 0) &&
98 stateblock
->wineD3DDevice
->strided_streams
.u
.s
.position_transformed
) ? TRUE
: FALSE
;
100 if (stateblock
->renderState
[WINED3DRS_LIGHTING
] && !transformed
) {
101 glEnable(GL_LIGHTING
);
102 checkGLcall("glEnable GL_LIGHTING");
104 glDisable(GL_LIGHTING
);
105 checkGLcall("glDisable GL_LIGHTING");
109 static void state_zenable(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
110 /* No z test without depth stencil buffers */
111 if(stateblock
->wineD3DDevice
->stencilBufferTarget
== NULL
) {
112 TRACE("No Z buffer - disabling depth test\n");
113 glDisable(GL_DEPTH_TEST
); /* This also disables z writing in gl */
114 checkGLcall("glDisable GL_DEPTH_TEST");
118 switch ((WINED3DZBUFFERTYPE
) stateblock
->renderState
[WINED3DRS_ZENABLE
]) {
119 case WINED3DZB_FALSE
:
120 glDisable(GL_DEPTH_TEST
);
121 checkGLcall("glDisable GL_DEPTH_TEST");
124 glEnable(GL_DEPTH_TEST
);
125 checkGLcall("glEnable GL_DEPTH_TEST");
128 glEnable(GL_DEPTH_TEST
);
129 checkGLcall("glEnable GL_DEPTH_TEST");
130 FIXME("W buffer is not well handled\n");
133 FIXME("Unrecognized D3DZBUFFERTYPE value %d\n", stateblock
->renderState
[WINED3DRS_ZENABLE
]);
137 static void state_cullmode(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
138 /* glFrontFace() is set in context.c at context init and on an offscreen / onscreen rendering
141 switch ((WINED3DCULL
) stateblock
->renderState
[WINED3DRS_CULLMODE
]) {
142 case WINED3DCULL_NONE
:
143 glDisable(GL_CULL_FACE
);
144 checkGLcall("glDisable GL_CULL_FACE");
147 glEnable(GL_CULL_FACE
);
148 checkGLcall("glEnable GL_CULL_FACE");
149 glCullFace(GL_FRONT
);
150 checkGLcall("glCullFace(GL_FRONT)");
152 case WINED3DCULL_CCW
:
153 glEnable(GL_CULL_FACE
);
154 checkGLcall("glEnable GL_CULL_FACE");
156 checkGLcall("glCullFace(GL_BACK)");
159 FIXME("Unrecognized/Unhandled WINED3DCULL value %d\n", stateblock
->renderState
[WINED3DRS_CULLMODE
]);
163 static void state_shademode(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
164 switch ((WINED3DSHADEMODE
) stateblock
->renderState
[WINED3DRS_SHADEMODE
]) {
165 case WINED3DSHADE_FLAT
:
166 glShadeModel(GL_FLAT
);
167 checkGLcall("glShadeModel(GL_FLAT)");
169 case WINED3DSHADE_GOURAUD
:
170 glShadeModel(GL_SMOOTH
);
171 checkGLcall("glShadeModel(GL_SMOOTH)");
173 case WINED3DSHADE_PHONG
:
174 FIXME("WINED3DSHADE_PHONG isn't supported\n");
177 FIXME("Unrecognized/Unhandled WINED3DSHADEMODE value %d\n", stateblock
->renderState
[WINED3DRS_SHADEMODE
]);
181 static void state_ditherenable(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
182 if (stateblock
->renderState
[WINED3DRS_DITHERENABLE
]) {
184 checkGLcall("glEnable GL_DITHER");
186 glDisable(GL_DITHER
);
187 checkGLcall("glDisable GL_DITHER");
191 static void state_zwritenable(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
192 /* TODO: Test if in d3d z writing is enabled even if ZENABLE is off. If yes,
193 * this has to be merged with ZENABLE and ZFUNC
195 if (stateblock
->renderState
[WINED3DRS_ZWRITEENABLE
]) {
197 checkGLcall("glDepthMask(1)");
200 checkGLcall("glDepthMask(0)");
204 static void state_zfunc(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
205 int glParm
= CompareFunc(stateblock
->renderState
[WINED3DRS_ZFUNC
]);
208 if(glParm
== GL_EQUAL
|| glParm
== GL_NOTEQUAL
) {
209 static BOOL once
= FALSE
;
210 /* There are a few issues with this: First, our inability to
211 * select a proper Z depth, most of the time we're stuck with
212 * D24S8, even if the app selects D32 or D16. There seem to be
213 * some other precision problems which have to be debugged to
214 * make NOTEQUAL and EQUAL work properly
218 FIXME("D3DCMP_NOTEQUAL and D3DCMP_EQUAL do not work correctly yet\n");
223 checkGLcall("glDepthFunc");
227 static void state_ambient(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
229 D3DCOLORTOGLFLOAT4(stateblock
->renderState
[WINED3DRS_AMBIENT
], col
);
231 TRACE("Setting ambient to (%f,%f,%f,%f)\n", col
[0], col
[1], col
[2], col
[3]);
232 glLightModelfv(GL_LIGHT_MODEL_AMBIENT
, col
);
233 checkGLcall("glLightModel for MODEL_AMBIENT");
236 static void state_blend(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
237 int srcBlend
= GL_ZERO
;
238 int dstBlend
= GL_ZERO
;
239 const StaticPixelFormatDesc
*rtFormat
;
240 IWineD3DSurfaceImpl
*target
= (IWineD3DSurfaceImpl
*) stateblock
->wineD3DDevice
->render_targets
[0];
242 /* GL_LINE_SMOOTH needs GL_BLEND to work, according to the red book, and special blending params */
243 if (stateblock
->renderState
[WINED3DRS_ALPHABLENDENABLE
] ||
244 stateblock
->renderState
[WINED3DRS_EDGEANTIALIAS
] ||
245 stateblock
->renderState
[WINED3DRS_ANTIALIASEDLINEENABLE
]) {
247 checkGLcall("glEnable GL_BLEND");
250 checkGLcall("glDisable GL_BLEND");
251 /* Nothing more to do - get out */
255 switch (stateblock
->renderState
[WINED3DRS_DESTBLEND
]) {
256 case WINED3DBLEND_ZERO
: dstBlend
= GL_ZERO
; break;
257 case WINED3DBLEND_ONE
: dstBlend
= GL_ONE
; break;
258 case WINED3DBLEND_SRCCOLOR
: dstBlend
= GL_SRC_COLOR
; break;
259 case WINED3DBLEND_INVSRCCOLOR
: dstBlend
= GL_ONE_MINUS_SRC_COLOR
; break;
260 case WINED3DBLEND_SRCALPHA
: dstBlend
= GL_SRC_ALPHA
; break;
261 case WINED3DBLEND_INVSRCALPHA
: dstBlend
= GL_ONE_MINUS_SRC_ALPHA
; break;
262 case WINED3DBLEND_DESTCOLOR
: dstBlend
= GL_DST_COLOR
; break;
263 case WINED3DBLEND_INVDESTCOLOR
: dstBlend
= GL_ONE_MINUS_DST_COLOR
; break;
265 /* To compensate the lack of format switching with backbuffer offscreen rendering,
266 * and with onscreen rendering, we modify the alpha test parameters for (INV)DESTALPHA
267 * if the render target doesn't support alpha blending. A nonexistent alpha channel
268 * returns 1.0, so D3DBLEND_DESTALPHA is GL_ONE, and D3DBLEND_INVDESTALPHA is GL_ZERO
270 case WINED3DBLEND_DESTALPHA
:
271 rtFormat
= getFormatDescEntry(target
->resource
.format
, NULL
, NULL
);
272 dstBlend
= rtFormat
->alphaMask
? GL_DST_ALPHA
: GL_ONE
;
274 case WINED3DBLEND_INVDESTALPHA
:
275 rtFormat
= getFormatDescEntry(target
->resource
.format
, NULL
, NULL
);
276 dstBlend
= rtFormat
->alphaMask
? GL_ONE_MINUS_DST_ALPHA
: GL_ZERO
;
279 case WINED3DBLEND_SRCALPHASAT
:
280 dstBlend
= GL_SRC_ALPHA_SATURATE
;
281 WARN("Application uses SRCALPHASAT as dest blend factor, expect problems\n");
284 /* WINED3DBLEND_BOTHSRCALPHA and WINED3DBLEND_BOTHINVSRCALPHA are legacy source blending
285 * values which are still valid up to d3d9. They should not occur as dest blend values
287 case WINED3DBLEND_BOTHSRCALPHA
: dstBlend
= GL_SRC_ALPHA
;
288 srcBlend
= GL_SRC_ALPHA
;
289 FIXME("WINED3DRS_DESTBLEND = WINED3DBLEND_BOTHSRCALPHA, what to do?\n");
292 case WINED3DBLEND_BOTHINVSRCALPHA
: dstBlend
= GL_ONE_MINUS_SRC_ALPHA
;
293 srcBlend
= GL_ONE_MINUS_SRC_ALPHA
;
294 FIXME("WINED3DRS_DESTBLEND = WINED3DBLEND_BOTHINVSRCALPHA, what to do?\n");
297 case WINED3DBLEND_BLENDFACTOR
: dstBlend
= GL_CONSTANT_COLOR
; break;
298 case WINED3DBLEND_INVBLENDFACTOR
: dstBlend
= GL_ONE_MINUS_CONSTANT_COLOR
; break;
300 FIXME("Unrecognized dst blend value %d\n", stateblock
->renderState
[WINED3DRS_DESTBLEND
]);
303 switch (stateblock
->renderState
[WINED3DRS_SRCBLEND
]) {
304 case WINED3DBLEND_ZERO
: srcBlend
= GL_ZERO
; break;
305 case WINED3DBLEND_ONE
: srcBlend
= GL_ONE
; break;
306 case WINED3DBLEND_SRCCOLOR
: srcBlend
= GL_SRC_COLOR
; break;
307 case WINED3DBLEND_INVSRCCOLOR
: srcBlend
= GL_ONE_MINUS_SRC_COLOR
; break;
308 case WINED3DBLEND_SRCALPHA
: srcBlend
= GL_SRC_ALPHA
; break;
309 case WINED3DBLEND_INVSRCALPHA
: srcBlend
= GL_ONE_MINUS_SRC_ALPHA
; break;
310 case WINED3DBLEND_DESTCOLOR
: srcBlend
= GL_DST_COLOR
; break;
311 case WINED3DBLEND_INVDESTCOLOR
: srcBlend
= GL_ONE_MINUS_DST_COLOR
; break;
312 case WINED3DBLEND_SRCALPHASAT
: srcBlend
= GL_SRC_ALPHA_SATURATE
; break;
314 case WINED3DBLEND_DESTALPHA
:
315 rtFormat
= getFormatDescEntry(target
->resource
.format
, NULL
, NULL
);
316 srcBlend
= rtFormat
->alphaMask
? GL_DST_ALPHA
: GL_ONE
;
318 case WINED3DBLEND_INVDESTALPHA
:
319 rtFormat
= getFormatDescEntry(target
->resource
.format
, NULL
, NULL
);
320 srcBlend
= rtFormat
->alphaMask
? GL_ONE_MINUS_DST_ALPHA
: GL_ZERO
;
323 case WINED3DBLEND_BOTHSRCALPHA
: srcBlend
= GL_SRC_ALPHA
;
324 dstBlend
= GL_ONE_MINUS_SRC_ALPHA
;
327 case WINED3DBLEND_BOTHINVSRCALPHA
: srcBlend
= GL_ONE_MINUS_SRC_ALPHA
;
328 dstBlend
= GL_SRC_ALPHA
;
331 case WINED3DBLEND_BLENDFACTOR
: srcBlend
= GL_CONSTANT_COLOR
; break;
332 case WINED3DBLEND_INVBLENDFACTOR
: srcBlend
= GL_ONE_MINUS_CONSTANT_COLOR
; break;
334 FIXME("Unrecognized src blend value %d\n", stateblock
->renderState
[WINED3DRS_SRCBLEND
]);
337 if(stateblock
->renderState
[WINED3DRS_EDGEANTIALIAS
] ||
338 stateblock
->renderState
[WINED3DRS_ANTIALIASEDLINEENABLE
]) {
339 glEnable(GL_LINE_SMOOTH
);
340 checkGLcall("glEnable(GL_LINE_SMOOTH)");
341 if(srcBlend
!= GL_SRC_ALPHA
) {
342 WARN("WINED3DRS_EDGEANTIALIAS enabled, but unexpected src blending param\n");
344 if(dstBlend
!= GL_ONE_MINUS_SRC_ALPHA
&& dstBlend
!= GL_ONE
) {
345 WARN("WINED3DRS_EDGEANTIALIAS enabled, but unexpected dst blending param\n");
348 glDisable(GL_LINE_SMOOTH
);
349 checkGLcall("glDisable(GL_LINE_SMOOTH)");
352 /* Re-apply BLENDOP(ALPHA) because of a possible SEPARATEALPHABLENDENABLE change */
353 if(!isStateDirty(context
, STATE_RENDER(WINED3DRS_BLENDOP
))) {
354 state_blendop(STATE_RENDER(WINED3DRS_BLENDOPALPHA
), stateblock
, context
);
357 if(stateblock
->renderState
[WINED3DRS_SEPARATEALPHABLENDENABLE
]) {
358 int srcBlendAlpha
= GL_ZERO
;
359 int dstBlendAlpha
= GL_ZERO
;
361 /* Separate alpha blending requires GL_EXT_blend_function_separate, so make sure it is around */
362 if(!GL_SUPPORT(EXT_BLEND_FUNC_SEPARATE
)) {
363 WARN("Unsupported in local OpenGL implementation: glBlendFuncSeparateEXT\n");
367 switch (stateblock
->renderState
[WINED3DRS_DESTBLENDALPHA
]) {
368 case WINED3DBLEND_ZERO
: dstBlendAlpha
= GL_ZERO
; break;
369 case WINED3DBLEND_ONE
: dstBlendAlpha
= GL_ONE
; break;
370 case WINED3DBLEND_SRCCOLOR
: dstBlendAlpha
= GL_SRC_COLOR
; break;
371 case WINED3DBLEND_INVSRCCOLOR
: dstBlendAlpha
= GL_ONE_MINUS_SRC_COLOR
; break;
372 case WINED3DBLEND_SRCALPHA
: dstBlendAlpha
= GL_SRC_ALPHA
; break;
373 case WINED3DBLEND_INVSRCALPHA
: dstBlendAlpha
= GL_ONE_MINUS_SRC_ALPHA
; break;
374 case WINED3DBLEND_DESTCOLOR
: dstBlendAlpha
= GL_DST_COLOR
; break;
375 case WINED3DBLEND_INVDESTCOLOR
: dstBlendAlpha
= GL_ONE_MINUS_DST_COLOR
; break;
376 case WINED3DBLEND_DESTALPHA
: dstBlendAlpha
= GL_DST_ALPHA
; break;
377 case WINED3DBLEND_INVDESTALPHA
: dstBlendAlpha
= GL_DST_ALPHA
; break;
378 case WINED3DBLEND_SRCALPHASAT
:
379 dstBlend
= GL_SRC_ALPHA_SATURATE
;
380 WARN("Application uses SRCALPHASAT as dest blend factor, expect problems\n");
382 /* WINED3DBLEND_BOTHSRCALPHA and WINED3DBLEND_BOTHINVSRCALPHA are legacy source blending
383 * values which are still valid up to d3d9. They should not occur as dest blend values
385 case WINED3DBLEND_BOTHSRCALPHA
:
386 dstBlendAlpha
= GL_SRC_ALPHA
;
387 srcBlendAlpha
= GL_SRC_ALPHA
;
388 FIXME("WINED3DRS_DESTBLENDALPHA = WINED3DBLEND_BOTHSRCALPHA, what to do?\n");
390 case WINED3DBLEND_BOTHINVSRCALPHA
:
391 dstBlendAlpha
= GL_ONE_MINUS_SRC_ALPHA
;
392 srcBlendAlpha
= GL_ONE_MINUS_SRC_ALPHA
;
393 FIXME("WINED3DRS_DESTBLENDALPHA = WINED3DBLEND_BOTHINVSRCALPHA, what to do?\n");
395 case WINED3DBLEND_BLENDFACTOR
: dstBlendAlpha
= GL_CONSTANT_COLOR
; break;
396 case WINED3DBLEND_INVBLENDFACTOR
: dstBlendAlpha
= GL_ONE_MINUS_CONSTANT_COLOR
; break;
398 FIXME("Unrecognized dst blend alpha value %d\n", stateblock
->renderState
[WINED3DRS_DESTBLENDALPHA
]);
401 switch (stateblock
->renderState
[WINED3DRS_SRCBLENDALPHA
]) {
402 case WINED3DBLEND_ZERO
: srcBlendAlpha
= GL_ZERO
; break;
403 case WINED3DBLEND_ONE
: srcBlendAlpha
= GL_ONE
; break;
404 case WINED3DBLEND_SRCCOLOR
: srcBlendAlpha
= GL_SRC_COLOR
; break;
405 case WINED3DBLEND_INVSRCCOLOR
: srcBlendAlpha
= GL_ONE_MINUS_SRC_COLOR
; break;
406 case WINED3DBLEND_SRCALPHA
: srcBlendAlpha
= GL_SRC_ALPHA
; break;
407 case WINED3DBLEND_INVSRCALPHA
: srcBlendAlpha
= GL_ONE_MINUS_SRC_ALPHA
; break;
408 case WINED3DBLEND_DESTCOLOR
: srcBlendAlpha
= GL_DST_COLOR
; break;
409 case WINED3DBLEND_INVDESTCOLOR
: srcBlendAlpha
= GL_ONE_MINUS_DST_COLOR
; break;
410 case WINED3DBLEND_SRCALPHASAT
: srcBlendAlpha
= GL_SRC_ALPHA_SATURATE
; break;
411 case WINED3DBLEND_DESTALPHA
: srcBlendAlpha
= GL_DST_ALPHA
; break;
412 case WINED3DBLEND_INVDESTALPHA
: srcBlendAlpha
= GL_DST_ALPHA
; break;
413 case WINED3DBLEND_BOTHSRCALPHA
:
414 srcBlendAlpha
= GL_SRC_ALPHA
;
415 dstBlendAlpha
= GL_ONE_MINUS_SRC_ALPHA
;
417 case WINED3DBLEND_BOTHINVSRCALPHA
:
418 srcBlendAlpha
= GL_ONE_MINUS_SRC_ALPHA
;
419 dstBlendAlpha
= GL_SRC_ALPHA
;
421 case WINED3DBLEND_BLENDFACTOR
: srcBlendAlpha
= GL_CONSTANT_COLOR
; break;
422 case WINED3DBLEND_INVBLENDFACTOR
: srcBlendAlpha
= GL_ONE_MINUS_CONSTANT_COLOR
; break;
424 FIXME("Unrecognized src blend alpha value %d\n", stateblock
->renderState
[WINED3DRS_SRCBLENDALPHA
]);
427 GL_EXTCALL(glBlendFuncSeparateEXT(srcBlend
, dstBlend
, srcBlendAlpha
, dstBlendAlpha
));
428 checkGLcall("glBlendFuncSeparateEXT");
430 TRACE("glBlendFunc src=%x, dst=%x\n", srcBlend
, dstBlend
);
431 glBlendFunc(srcBlend
, dstBlend
);
432 checkGLcall("glBlendFunc");
435 /* colorkey fixup for stage 0 alphaop depends on WINED3DRS_ALPHABLENDENABLE state,
436 so it may need updating */
437 if (stateblock
->renderState
[WINED3DRS_COLORKEYENABLE
]) {
438 StateTable
[STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
)].apply(STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), stateblock
, context
);
442 static void state_blendfactor(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
445 if(!GL_SUPPORT(EXT_BLEND_COLOR
)) {
446 WARN("Unsupported in local OpenGL implementation: glBlendColorEXT\n");
450 TRACE("Setting BlendFactor to %d\n", stateblock
->renderState
[WINED3DRS_BLENDFACTOR
]);
451 D3DCOLORTOGLFLOAT4(stateblock
->renderState
[WINED3DRS_BLENDFACTOR
], col
);
452 GL_EXTCALL(glBlendColorEXT (col
[0],col
[1],col
[2],col
[3]));
453 checkGLcall("glBlendColor");
456 static void state_alpha(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
459 BOOL enable_ckey
= FALSE
;
461 IWineD3DSurfaceImpl
*surf
;
463 /* Find out if the texture on the first stage has a ckey set
464 * The alpha state func reads the texture settings, even though alpha and texture are not grouped
465 * together. This is to avoid making a huge alpha+texture+texture stage+ckey block due to the hardly
466 * used WINED3DRS_COLORKEYENABLE state(which is d3d <= 3 only). The texture function will call alpha
467 * in case it finds some texture+colorkeyenable combination which needs extra care.
469 if(stateblock
->textures
[0] && (
470 stateblock
->textureDimensions
[0] == GL_TEXTURE_2D
||
471 stateblock
->textureDimensions
[0] == GL_TEXTURE_RECTANGLE_ARB
)) {
472 surf
= (IWineD3DSurfaceImpl
*) ((IWineD3DTextureImpl
*)stateblock
->textures
[0])->surfaces
[0];
474 if(surf
->CKeyFlags
& WINEDDSD_CKSRCBLT
) {
475 const StaticPixelFormatDesc
*fmt
= getFormatDescEntry(surf
->resource
.format
, NULL
, NULL
);
476 /* The surface conversion does not do color keying conversion for surfaces that have an alpha
477 * channel on their own. Likewise, the alpha test shouldn't be set up for color keying if the
478 * surface has alpha bits
480 if(fmt
->alphaMask
== 0x00000000) {
486 if(enable_ckey
|| context
->last_was_ckey
) {
487 StateTable
[STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
)].apply(STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), stateblock
, context
);
489 context
->last_was_ckey
= enable_ckey
;
491 if (stateblock
->renderState
[WINED3DRS_ALPHATESTENABLE
] ||
492 (stateblock
->renderState
[WINED3DRS_COLORKEYENABLE
] && enable_ckey
)) {
493 glEnable(GL_ALPHA_TEST
);
494 checkGLcall("glEnable GL_ALPHA_TEST");
496 glDisable(GL_ALPHA_TEST
);
497 checkGLcall("glDisable GL_ALPHA_TEST");
498 /* Alpha test is disabled, don't bother setting the params - it will happen on the next
504 if(stateblock
->renderState
[WINED3DRS_COLORKEYENABLE
] && enable_ckey
) {
505 glParm
= GL_NOTEQUAL
;
508 ref
= ((float) stateblock
->renderState
[WINED3DRS_ALPHAREF
]) / 255.0f
;
509 glParm
= CompareFunc(stateblock
->renderState
[WINED3DRS_ALPHAFUNC
]);
512 glAlphaFunc(glParm
, ref
);
513 checkGLcall("glAlphaFunc");
517 static void state_clipping(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
518 DWORD enable
= 0xFFFFFFFF;
519 DWORD disable
= 0x00000000;
521 if (use_vs(stateblock
->wineD3DDevice
)) {
522 /* The spec says that opengl clipping planes are disabled when using shaders. Direct3D planes aren't,
523 * so that is an issue. The MacOS ATI driver keeps clipping planes activated with shaders in some
524 * conditions I got sick of tracking down. The shader state handler disables all clip planes because
525 * of that - don't do anything here and keep them disabled
527 if(stateblock
->renderState
[WINED3DRS_CLIPPLANEENABLE
]) {
528 static BOOL warned
= FALSE
;
530 FIXME("Clipping not supported with vertex shaders\n");
537 /* TODO: Keep track of previously enabled clipplanes to avoid unnecessary resetting
538 * of already set values
541 /* If enabling / disabling all
542 * TODO: Is this correct? Doesn't D3DRS_CLIPPING disable clipping on the viewport frustrum?
544 if (stateblock
->renderState
[WINED3DRS_CLIPPING
]) {
545 enable
= stateblock
->renderState
[WINED3DRS_CLIPPLANEENABLE
];
546 disable
= ~stateblock
->renderState
[WINED3DRS_CLIPPLANEENABLE
];
547 if(GL_SUPPORT(NV_DEPTH_CLAMP
)) {
548 glDisable(GL_DEPTH_CLAMP_NV
);
549 checkGLcall("glDisable(GL_DEPTH_CLAMP_NV)");
552 disable
= 0xffffffff;
554 if(GL_SUPPORT(NV_DEPTH_CLAMP
)) {
555 glEnable(GL_DEPTH_CLAMP_NV
);
556 checkGLcall("glEnable(GL_DEPTH_CLAMP_NV)");
560 if (enable
& WINED3DCLIPPLANE0
) { glEnable(GL_CLIP_PLANE0
); checkGLcall("glEnable(clip plane 0)"); }
561 if (enable
& WINED3DCLIPPLANE1
) { glEnable(GL_CLIP_PLANE1
); checkGLcall("glEnable(clip plane 1)"); }
562 if (enable
& WINED3DCLIPPLANE2
) { glEnable(GL_CLIP_PLANE2
); checkGLcall("glEnable(clip plane 2)"); }
563 if (enable
& WINED3DCLIPPLANE3
) { glEnable(GL_CLIP_PLANE3
); checkGLcall("glEnable(clip plane 3)"); }
564 if (enable
& WINED3DCLIPPLANE4
) { glEnable(GL_CLIP_PLANE4
); checkGLcall("glEnable(clip plane 4)"); }
565 if (enable
& WINED3DCLIPPLANE5
) { glEnable(GL_CLIP_PLANE5
); checkGLcall("glEnable(clip plane 5)"); }
567 if (disable
& WINED3DCLIPPLANE0
) { glDisable(GL_CLIP_PLANE0
); checkGLcall("glDisable(clip plane 0)"); }
568 if (disable
& WINED3DCLIPPLANE1
) { glDisable(GL_CLIP_PLANE1
); checkGLcall("glDisable(clip plane 1)"); }
569 if (disable
& WINED3DCLIPPLANE2
) { glDisable(GL_CLIP_PLANE2
); checkGLcall("glDisable(clip plane 2)"); }
570 if (disable
& WINED3DCLIPPLANE3
) { glDisable(GL_CLIP_PLANE3
); checkGLcall("glDisable(clip plane 3)"); }
571 if (disable
& WINED3DCLIPPLANE4
) { glDisable(GL_CLIP_PLANE4
); checkGLcall("glDisable(clip plane 4)"); }
572 if (disable
& WINED3DCLIPPLANE5
) { glDisable(GL_CLIP_PLANE5
); checkGLcall("glDisable(clip plane 5)"); }
574 /** update clipping status */
576 stateblock
->clip_status
.ClipUnion
= 0;
577 stateblock
->clip_status
.ClipIntersection
= 0xFFFFFFFF;
579 stateblock
->clip_status
.ClipUnion
= 0;
580 stateblock
->clip_status
.ClipIntersection
= 0;
584 static void state_blendop(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
585 int blendEquation
= GL_FUNC_ADD
;
586 int blendEquationAlpha
= GL_FUNC_ADD
;
588 if(!GL_SUPPORT(EXT_BLEND_MINMAX
)) {
589 WARN("Unsupported in local OpenGL implementation: glBlendEquation\n");
593 /* BLENDOPALPHA requires GL_EXT_blend_equation_separate, so make sure it is around */
594 if(stateblock
->renderState
[WINED3DRS_BLENDOPALPHA
] && !GL_SUPPORT(EXT_BLEND_EQUATION_SEPARATE
)) {
595 WARN("Unsupported in local OpenGL implementation: glBlendEquationSeparateEXT\n");
599 switch ((WINED3DBLENDOP
) stateblock
->renderState
[WINED3DRS_BLENDOP
]) {
600 case WINED3DBLENDOP_ADD
: blendEquation
= GL_FUNC_ADD
; break;
601 case WINED3DBLENDOP_SUBTRACT
: blendEquation
= GL_FUNC_SUBTRACT
; break;
602 case WINED3DBLENDOP_REVSUBTRACT
: blendEquation
= GL_FUNC_REVERSE_SUBTRACT
; break;
603 case WINED3DBLENDOP_MIN
: blendEquation
= GL_MIN
; break;
604 case WINED3DBLENDOP_MAX
: blendEquation
= GL_MAX
; break;
606 FIXME("Unrecognized/Unhandled D3DBLENDOP value %d\n", stateblock
->renderState
[WINED3DRS_BLENDOP
]);
609 switch ((WINED3DBLENDOP
) stateblock
->renderState
[WINED3DRS_BLENDOPALPHA
]) {
610 case WINED3DBLENDOP_ADD
: blendEquationAlpha
= GL_FUNC_ADD
; break;
611 case WINED3DBLENDOP_SUBTRACT
: blendEquationAlpha
= GL_FUNC_SUBTRACT
; break;
612 case WINED3DBLENDOP_REVSUBTRACT
: blendEquationAlpha
= GL_FUNC_REVERSE_SUBTRACT
; break;
613 case WINED3DBLENDOP_MIN
: blendEquationAlpha
= GL_MIN
; break;
614 case WINED3DBLENDOP_MAX
: blendEquationAlpha
= GL_MAX
; break;
616 FIXME("Unrecognized/Unhandled D3DBLENDOP value %d\n", stateblock
->renderState
[WINED3DRS_BLENDOPALPHA
]);
619 if(stateblock
->renderState
[WINED3DRS_SEPARATEALPHABLENDENABLE
]) {
620 TRACE("glBlendEquationSeparateEXT(%x, %x)\n", blendEquation
, blendEquationAlpha
);
621 GL_EXTCALL(glBlendEquationSeparateEXT(blendEquation
, blendEquationAlpha
));
622 checkGLcall("glBlendEquationSeparateEXT");
624 TRACE("glBlendEquation(%x)\n", blendEquation
);
625 GL_EXTCALL(glBlendEquationEXT(blendEquation
));
626 checkGLcall("glBlendEquation");
631 state_specularenable(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
632 /* Originally this used glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR)
633 * and (GL_LIGHT_MODEL_COLOR_CONTROL,GL_SINGLE_COLOR) to swap between enabled/disabled
634 * specular color. This is wrong:
635 * Separate specular color means the specular colour is maintained separately, whereas
636 * single color means it is merged in. However in both cases they are being used to
638 * To disable specular color, set it explicitly to black and turn off GL_COLOR_SUM_EXT
639 * NOTE: If not supported don't give FIXMEs the impact is really minimal and very few people are
643 * If register combiners are enabled, enabling / disabling GL_COLOR_SUM has no effect.
644 * Instead, we need to setup the FinalCombiner properly.
646 * The default setup for the FinalCombiner is:
648 * <variable> <input> <mapping> <usage>
649 * GL_VARIABLE_A_NV GL_FOG, GL_UNSIGNED_IDENTITY_NV GL_ALPHA
650 * GL_VARIABLE_B_NV GL_SPARE0_PLUS_SECONDARY_COLOR_NV GL_UNSIGNED_IDENTITY_NV GL_RGB
651 * GL_VARIABLE_C_NV GL_FOG GL_UNSIGNED_IDENTITY_NV GL_RGB
652 * GL_VARIABLE_D_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
653 * GL_VARIABLE_E_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
654 * GL_VARIABLE_F_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
655 * GL_VARIABLE_G_NV GL_SPARE0_NV GL_UNSIGNED_IDENTITY_NV GL_ALPHA
657 * That's pretty much fine as it is, except for variable B, which needs to take
658 * either GL_SPARE0_PLUS_SECONDARY_COLOR_NV or GL_SPARE0_NV, depending on
659 * whether WINED3DRS_SPECULARENABLE is enabled or not.
662 TRACE("Setting specular enable state and materials\n");
663 if (stateblock
->renderState
[WINED3DRS_SPECULARENABLE
]) {
664 glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, (float*) &stateblock
->material
.Specular
);
665 checkGLcall("glMaterialfv");
667 if(stateblock
->material
.Power
> GL_LIMITS(shininess
)) {
668 /* glMaterialf man page says that the material says that GL_SHININESS must be between 0.0
669 * and 128.0, although in d3d neither -1 nor 129 produce an error. GL_NV_max_light_exponent
670 * allows bigger values. If the extension is supported, GL_LIMITS(shininess) contains the
671 * value reported by the extension, otherwise 128. For values > GL_LIMITS(shininess) clamp
672 * them, it should be safe to do so without major visual dissortions.
674 WARN("Material power = %f, limit %f\n", stateblock
->material
.Power
, GL_LIMITS(shininess
));
675 glMaterialf(GL_FRONT_AND_BACK
, GL_SHININESS
, GL_LIMITS(shininess
));
677 glMaterialf(GL_FRONT_AND_BACK
, GL_SHININESS
, stateblock
->material
.Power
);
679 checkGLcall("glMaterialf(GL_SHININESS)");
681 if (GL_SUPPORT(EXT_SECONDARY_COLOR
)) {
682 glEnable(GL_COLOR_SUM_EXT
);
684 TRACE("Specular colors cannot be enabled in this version of opengl\n");
686 checkGLcall("glEnable(GL_COLOR_SUM)");
688 if (GL_SUPPORT(NV_REGISTER_COMBINERS
)) {
689 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV
, GL_SPARE0_PLUS_SECONDARY_COLOR_NV
, GL_UNSIGNED_IDENTITY_NV
, GL_RGB
));
690 checkGLcall("glFinalCombinerInputNV()");
693 float black
[4] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
695 /* for the case of enabled lighting: */
696 glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, &black
[0]);
697 checkGLcall("glMaterialfv");
699 /* for the case of disabled lighting: */
700 if (GL_SUPPORT(EXT_SECONDARY_COLOR
)) {
701 glDisable(GL_COLOR_SUM_EXT
);
703 TRACE("Specular colors cannot be disabled in this version of opengl\n");
705 checkGLcall("glDisable(GL_COLOR_SUM)");
707 if (GL_SUPPORT(NV_REGISTER_COMBINERS
)) {
708 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV
, GL_SPARE0_NV
, GL_UNSIGNED_IDENTITY_NV
, GL_RGB
));
709 checkGLcall("glFinalCombinerInputNV()");
713 TRACE("(%p) : Diffuse (%f,%f,%f,%f)\n", stateblock
->wineD3DDevice
, stateblock
->material
.Diffuse
.r
, stateblock
->material
.Diffuse
.g
,
714 stateblock
->material
.Diffuse
.b
, stateblock
->material
.Diffuse
.a
);
715 TRACE("(%p) : Ambient (%f,%f,%f,%f)\n", stateblock
->wineD3DDevice
, stateblock
->material
.Ambient
.r
, stateblock
->material
.Ambient
.g
,
716 stateblock
->material
.Ambient
.b
, stateblock
->material
.Ambient
.a
);
717 TRACE("(%p) : Specular (%f,%f,%f,%f)\n", stateblock
->wineD3DDevice
, stateblock
->material
.Specular
.r
, stateblock
->material
.Specular
.g
,
718 stateblock
->material
.Specular
.b
, stateblock
->material
.Specular
.a
);
719 TRACE("(%p) : Emissive (%f,%f,%f,%f)\n", stateblock
->wineD3DDevice
, stateblock
->material
.Emissive
.r
, stateblock
->material
.Emissive
.g
,
720 stateblock
->material
.Emissive
.b
, stateblock
->material
.Emissive
.a
);
722 glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float*) &stateblock
->material
.Ambient
);
723 checkGLcall("glMaterialfv(GL_AMBIENT)");
724 glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float*) &stateblock
->material
.Diffuse
);
725 checkGLcall("glMaterialfv(GL_DIFFUSE)");
726 glMaterialfv(GL_FRONT_AND_BACK
, GL_EMISSION
, (float*) &stateblock
->material
.Emissive
);
727 checkGLcall("glMaterialfv(GL_EMISSION)");
730 static void state_texfactor(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
733 /* Note the texture color applies to all textures whereas
734 * GL_TEXTURE_ENV_COLOR applies to active only
737 D3DCOLORTOGLFLOAT4(stateblock
->renderState
[WINED3DRS_TEXTUREFACTOR
], col
);
739 if (!GL_SUPPORT(NV_REGISTER_COMBINERS
)) {
740 /* And now the default texture color as well */
741 for (i
= 0; i
< GL_LIMITS(texture_stages
); i
++) {
742 /* Note the WINED3DRS value applies to all textures, but GL has one
743 * per texture, so apply it now ready to be used!
745 if (GL_SUPPORT(ARB_MULTITEXTURE
)) {
746 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB
+ i
));
747 checkGLcall("glActiveTextureARB");
749 FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
752 glTexEnvfv(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_COLOR
, &col
[0]);
753 checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);");
756 GL_EXTCALL(glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV
, &col
[0]));
761 renderstate_stencil_twosided(IWineD3DStateBlockImpl
*stateblock
, GLint face
, GLint func
, GLint ref
, GLuint mask
, GLint stencilFail
, GLint depthFail
, GLint stencilPass
) {
762 #if 0 /* Don't use OpenGL 2.0 calls for now */
763 if(GL_EXTCALL(glStencilFuncSeparate
) && GL_EXTCALL(glStencilOpSeparate
)) {
764 GL_EXTCALL(glStencilFuncSeparate(face
, func
, ref
, mask
));
765 checkGLcall("glStencilFuncSeparate(...)");
766 GL_EXTCALL(glStencilOpSeparate(face
, stencilFail
, depthFail
, stencilPass
));
767 checkGLcall("glStencilOpSeparate(...)");
771 if(GL_SUPPORT(EXT_STENCIL_TWO_SIDE
)) {
772 glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT
);
773 checkGLcall("glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT)");
774 GL_EXTCALL(glActiveStencilFaceEXT(face
));
775 checkGLcall("glActiveStencilFaceEXT(...)");
776 glStencilFunc(func
, ref
, mask
);
777 checkGLcall("glStencilFunc(...)");
778 glStencilOp(stencilFail
, depthFail
, stencilPass
);
779 checkGLcall("glStencilOp(...)");
780 } else if(GL_SUPPORT(ATI_SEPARATE_STENCIL
)) {
781 GL_EXTCALL(glStencilFuncSeparateATI(face
, func
, ref
, mask
));
782 checkGLcall("glStencilFuncSeparateATI(...)");
783 GL_EXTCALL(glStencilOpSeparateATI(face
, stencilFail
, depthFail
, stencilPass
));
784 checkGLcall("glStencilOpSeparateATI(...)");
786 ERR("Separate (two sided) stencil not supported on this version of opengl. Caps weren't honored?\n");
791 state_stencil(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
792 DWORD onesided_enable
= FALSE
;
793 DWORD twosided_enable
= FALSE
;
794 GLint func
= GL_ALWAYS
;
795 GLint func_ccw
= GL_ALWAYS
;
798 GLint stencilFail
= GL_KEEP
;
799 GLint depthFail
= GL_KEEP
;
800 GLint stencilPass
= GL_KEEP
;
801 GLint stencilFail_ccw
= GL_KEEP
;
802 GLint depthFail_ccw
= GL_KEEP
;
803 GLint stencilPass_ccw
= GL_KEEP
;
805 /* No stencil test without a stencil buffer */
806 if(stateblock
->wineD3DDevice
->stencilBufferTarget
== NULL
) {
807 glDisable(GL_STENCIL_TEST
);
808 checkGLcall("glDisable GL_STENCIL_TEST");
812 onesided_enable
= stateblock
->renderState
[WINED3DRS_STENCILENABLE
];
813 twosided_enable
= stateblock
->renderState
[WINED3DRS_TWOSIDEDSTENCILMODE
];
814 if( !( func
= CompareFunc(stateblock
->renderState
[WINED3DRS_STENCILFUNC
]) ) )
816 if( !( func_ccw
= CompareFunc(stateblock
->renderState
[WINED3DRS_CCW_STENCILFUNC
]) ) )
817 func_ccw
= GL_ALWAYS
;
818 ref
= stateblock
->renderState
[WINED3DRS_STENCILREF
];
819 mask
= stateblock
->renderState
[WINED3DRS_STENCILMASK
];
820 stencilFail
= StencilOp(stateblock
->renderState
[WINED3DRS_STENCILFAIL
]);
821 depthFail
= StencilOp(stateblock
->renderState
[WINED3DRS_STENCILZFAIL
]);
822 stencilPass
= StencilOp(stateblock
->renderState
[WINED3DRS_STENCILPASS
]);
823 stencilFail_ccw
= StencilOp(stateblock
->renderState
[WINED3DRS_CCW_STENCILFAIL
]);
824 depthFail_ccw
= StencilOp(stateblock
->renderState
[WINED3DRS_CCW_STENCILZFAIL
]);
825 stencilPass_ccw
= StencilOp(stateblock
->renderState
[WINED3DRS_CCW_STENCILPASS
]);
827 TRACE("(onesided %d, twosided %d, ref %x, mask %x, "
828 "GL_FRONT: func: %x, fail %x, zfail %x, zpass %x "
829 "GL_BACK: func: %x, fail %x, zfail %x, zpass %x )\n",
830 onesided_enable
, twosided_enable
, ref
, mask
,
831 func
, stencilFail
, depthFail
, stencilPass
,
832 func_ccw
, stencilFail_ccw
, depthFail_ccw
, stencilPass_ccw
);
834 if (twosided_enable
&& onesided_enable
) {
835 glEnable(GL_STENCIL_TEST
);
836 checkGLcall("glEnable GL_STENCIL_TEST");
838 /* Apply back first, then front. This function calls glActiveStencilFaceEXT,
839 * which has an effect on the code below too. If we apply the front face
840 * afterwards, we are sure that the active stencil face is set to front,
841 * and other stencil functions which do not use two sided stencil do not have
844 renderstate_stencil_twosided(stateblock
, GL_BACK
, func_ccw
, ref
, mask
, stencilFail_ccw
, depthFail_ccw
, stencilPass_ccw
);
845 renderstate_stencil_twosided(stateblock
, GL_FRONT
, func
, ref
, mask
, stencilFail
, depthFail
, stencilPass
);
846 } else if(onesided_enable
) {
847 if(GL_SUPPORT(EXT_STENCIL_TWO_SIDE
)) {
848 glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT
);
849 checkGLcall("glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT)");
852 glEnable(GL_STENCIL_TEST
);
853 checkGLcall("glEnable GL_STENCIL_TEST");
854 glStencilFunc(func
, ref
, mask
);
855 checkGLcall("glStencilFunc(...)");
856 glStencilOp(stencilFail
, depthFail
, stencilPass
);
857 checkGLcall("glStencilOp(...)");
859 glDisable(GL_STENCIL_TEST
);
860 checkGLcall("glDisable GL_STENCIL_TEST");
864 static void state_stencilwrite(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
867 if(stateblock
->wineD3DDevice
->stencilBufferTarget
) {
868 mask
= stateblock
->renderState
[WINED3DRS_STENCILWRITEMASK
];
873 if(GL_SUPPORT(EXT_STENCIL_TWO_SIDE
)) {
874 GL_EXTCALL(glActiveStencilFaceEXT(GL_BACK
));
875 checkGLcall("glActiveStencilFaceEXT(GL_BACK)");
877 checkGLcall("glStencilMask");
878 GL_EXTCALL(glActiveStencilFaceEXT(GL_FRONT
));
879 checkGLcall("glActiveStencilFaceEXT(GL_FRONT)");
884 checkGLcall("glStencilMask");
887 static void state_fog(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
888 /* TODO: Put this into the vertex type block once that is in the state table */
889 BOOL fogenable
= stateblock
->renderState
[WINED3DRS_FOGENABLE
];
890 BOOL is_ps3
= use_ps(stateblock
->wineD3DDevice
)
891 && ((IWineD3DPixelShaderImpl
*)stateblock
->pixelShader
)->baseShader
.hex_version
>= WINED3DPS_VERSION(3,0);
892 float fogstart
, fogend
;
900 /* No fog? Disable it, and we're done :-) */
902 checkGLcall("glDisable GL_FOG");
903 if( use_ps(stateblock
->wineD3DDevice
)
904 && ((IWineD3DPixelShaderImpl
*)stateblock
->pixelShader
)->baseShader
.hex_version
< WINED3DPS_VERSION(3,0) ) {
905 /* disable fog in the pixel shader
906 * NOTE: For pixel shader, GL_FOG_START and GL_FOG_END don't hold fog start s and end e but
907 * -1/(e-s) and e/(e-s) respectively.
909 glFogf(GL_FOG_START
, 0.0f
);
910 checkGLcall("glFogf(GL_FOG_START, fogstart)");
911 glFogf(GL_FOG_END
, 1.0f
);
912 checkGLcall("glFogf(GL_FOG_END, fogend)");
917 tmpvalue
.d
= stateblock
->renderState
[WINED3DRS_FOGSTART
];
918 fogstart
= tmpvalue
.f
;
919 tmpvalue
.d
= stateblock
->renderState
[WINED3DRS_FOGEND
];
924 * With fixed function vertex processing, Direct3D knows 2 different fog input sources.
925 * It can use the Z value of the vertex, or the alpha component of the specular color.
926 * This depends on the fog vertex, fog table and the vertex declaration. If the Z value
927 * is used, fogstart, fogend and the equation type are used, otherwise linear fog with
928 * start = 255, end = 0 is used. Obviously the msdn is not very clear on that.
930 * FOGTABLEMODE != NONE:
931 * The Z value is used, with the equation specified, no matter what vertex type.
933 * FOGTABLEMODE == NONE, FOGVERTEXMODE != NONE, untransformed:
934 * Per vertex fog is calculated using the specified fog equation and the parameters
936 * FOGTABLEMODE == NONE, FOGVERTEXMODE != NONE, transformed, OR
937 * FOGTABLEMODE == NONE, FOGVERTEXMODE == NONE, untransformed:
938 * Linear fog with start = 255.0, end = 0.0, input comes from the specular color
941 * Rules for vertex fog with shaders:
943 * When mixing fixed function functionality with the programmable pipeline, D3D expects
944 * the fog computation to happen during transformation while openGL expects it to happen
945 * during rasterization. Also, prior to pixel shader 3.0 D3D handles fog blending after
946 * the pixel shader while openGL always expects the pixel shader to handle the blending.
947 * To solve this problem, WineD3D does:
948 * 1) implement a linear fog equation and fog blending at the end of every pre 3.0 pixel
950 * and 2) disables the fog computation (in either the fixed function or programmable
951 * rasterizer) if using a vertex program.
954 * If a fogtablemode and a fogvertexmode are specified, table fog is applied (with or
959 if( !use_vs(stateblock
->wineD3DDevice
)
960 && stateblock
->renderState
[WINED3DRS_FOGTABLEMODE
] == WINED3DFOG_NONE
) {
961 FIXME("Implement vertex fog for pixel shader >= 3.0 and fixed function pipeline\n");
965 if (use_vs(stateblock
->wineD3DDevice
)
966 && ((IWineD3DVertexShaderImpl
*)stateblock
->vertexShader
)->baseShader
.reg_maps
.fog
) {
967 if( stateblock
->renderState
[WINED3DRS_FOGTABLEMODE
] != WINED3DFOG_NONE
) {
968 if(!is_ps3
) FIXME("Implement table fog for foggy vertex shader\n");
972 /* Set fog computation in the rasterizer to pass through the value (just blend it) */
973 glFogi(GL_FOG_MODE
, GL_LINEAR
);
974 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
979 if(GL_SUPPORT(EXT_FOG_COORD
) && context
->fog_coord
) {
980 glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FRAGMENT_DEPTH_EXT
);
981 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT)");
982 context
->fog_coord
= FALSE
;
984 context
->last_was_foggy_shader
= TRUE
;
986 else if( use_ps(stateblock
->wineD3DDevice
) ) {
987 /* NOTE: For pixel shader, GL_FOG_START and GL_FOG_END don't hold fog start s and end e but
988 * -1/(e-s) and e/(e-s) respectively to simplify fog computation in the shader.
991 context
->last_was_foggy_shader
= FALSE
;
993 /* If both fogmodes are set use the table fog mode */
994 if(stateblock
->renderState
[WINED3DRS_FOGTABLEMODE
] == WINED3DFOG_NONE
)
995 mode
= stateblock
->renderState
[WINED3DRS_FOGVERTEXMODE
];
997 mode
= stateblock
->renderState
[WINED3DRS_FOGTABLEMODE
];
1000 case WINED3DFOG_EXP
:
1001 case WINED3DFOG_EXP2
:
1002 if(!is_ps3
) FIXME("Implement non linear fog for pixel shader < 3.0\n");
1007 case WINED3DFOG_LINEAR
:
1008 fogstart
= -1.0f
/(fogend
-fogstart
);
1009 fogend
*= -fogstart
;
1012 case WINED3DFOG_NONE
:
1013 if(!is_ps3
) FIXME("Implement software vertex fog for pixel shader < 3.0\n");
1017 default: FIXME("Unexpected WINED3DRS_FOGVERTEXMODE %d\n", stateblock
->renderState
[WINED3DRS_FOGVERTEXMODE
]);
1020 if(GL_SUPPORT(EXT_FOG_COORD
) && context
->fog_coord
) {
1021 glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FRAGMENT_DEPTH_EXT
);
1022 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT)");
1023 context
->fog_coord
= FALSE
;
1026 /* DX 7 sdk: "If both render states(vertex and table fog) are set to valid modes,
1027 * the system will apply only pixel(=table) fog effects."
1029 else if(stateblock
->renderState
[WINED3DRS_FOGTABLEMODE
] == WINED3DFOG_NONE
) {
1030 glHint(GL_FOG_HINT
, GL_FASTEST
);
1031 checkGLcall("glHint(GL_FOG_HINT, GL_FASTEST)");
1032 context
->last_was_foggy_shader
= FALSE
;
1034 switch (stateblock
->renderState
[WINED3DRS_FOGVERTEXMODE
]) {
1035 /* If processed vertices are used, fall through to the NONE case */
1036 case WINED3DFOG_EXP
: {
1037 if(!context
->last_was_rhw
) {
1038 glFogi(GL_FOG_MODE
, GL_EXP
);
1039 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP)");
1040 if(GL_SUPPORT(EXT_FOG_COORD
) && context
->fog_coord
) {
1041 glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FRAGMENT_DEPTH_EXT
);
1042 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT)");
1043 context
->fog_coord
= FALSE
;
1048 case WINED3DFOG_EXP2
: {
1049 if(!context
->last_was_rhw
) {
1050 glFogi(GL_FOG_MODE
, GL_EXP2
);
1051 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2)");
1052 if(GL_SUPPORT(EXT_FOG_COORD
) && context
->fog_coord
) {
1053 glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FRAGMENT_DEPTH_EXT
);
1054 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT)");
1055 context
->fog_coord
= FALSE
;
1060 case WINED3DFOG_LINEAR
: {
1061 if(!context
->last_was_rhw
) {
1062 glFogi(GL_FOG_MODE
, GL_LINEAR
);
1063 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1064 if(GL_SUPPORT(EXT_FOG_COORD
) && context
->fog_coord
) {
1065 glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FRAGMENT_DEPTH_EXT
);
1066 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT)");
1067 context
->fog_coord
= FALSE
;
1072 case WINED3DFOG_NONE
: {
1073 /* Both are none? According to msdn the alpha channel of the specular
1074 * color contains a fog factor. Set it in drawStridedSlow.
1075 * Same happens with Vertexfog on transformed vertices
1077 if(GL_SUPPORT(EXT_FOG_COORD
)) {
1078 if(context
->fog_coord
== FALSE
) {
1079 glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FOG_COORDINATE_EXT
);
1080 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT)");
1081 context
->fog_coord
= TRUE
;
1083 glFogi(GL_FOG_MODE
, GL_LINEAR
);
1084 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1088 /* Disable GL fog, handle this in software in drawStridedSlow */
1093 default: FIXME("Unexpected WINED3DRS_FOGVERTEXMODE %d\n", stateblock
->renderState
[WINED3DRS_FOGVERTEXMODE
]);
1096 glHint(GL_FOG_HINT
, GL_NICEST
);
1097 checkGLcall("glHint(GL_FOG_HINT, GL_NICEST)");
1098 context
->last_was_foggy_shader
= FALSE
;
1100 switch (stateblock
->renderState
[WINED3DRS_FOGTABLEMODE
]) {
1101 case WINED3DFOG_EXP
:
1102 glFogi(GL_FOG_MODE
, GL_EXP
);
1103 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP)");
1104 if(GL_SUPPORT(EXT_FOG_COORD
) && context
->fog_coord
) {
1105 glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FRAGMENT_DEPTH_EXT
);
1106 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT)");
1107 context
->fog_coord
= FALSE
;
1111 case WINED3DFOG_EXP2
:
1112 glFogi(GL_FOG_MODE
, GL_EXP2
);
1113 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2)");
1114 if(GL_SUPPORT(EXT_FOG_COORD
) && context
->fog_coord
) {
1115 glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FRAGMENT_DEPTH_EXT
);
1116 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT)");
1117 context
->fog_coord
= FALSE
;
1121 case WINED3DFOG_LINEAR
:
1122 glFogi(GL_FOG_MODE
, GL_LINEAR
);
1123 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1124 if(GL_SUPPORT(EXT_FOG_COORD
) && context
->fog_coord
) {
1125 glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FRAGMENT_DEPTH_EXT
);
1126 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT)");
1127 context
->fog_coord
= FALSE
;
1131 case WINED3DFOG_NONE
: /* Won't happen */
1133 FIXME("Unexpected WINED3DRS_FOGTABLEMODE %d\n", stateblock
->renderState
[WINED3DRS_FOGTABLEMODE
]);
1139 checkGLcall("glEnable GL_FOG");
1141 if(fogstart
!= fogend
)
1143 glFogfv(GL_FOG_START
, &fogstart
);
1144 checkGLcall("glFogf(GL_FOG_START, fogstart)");
1145 TRACE("Fog Start == %f\n", fogstart
);
1147 glFogfv(GL_FOG_END
, &fogend
);
1148 checkGLcall("glFogf(GL_FOG_END, fogend)");
1149 TRACE("Fog End == %f\n", fogend
);
1153 glFogf(GL_FOG_START
, -1.0 / 0.0);
1154 checkGLcall("glFogf(GL_FOG_START, fogstart)");
1155 TRACE("Fog Start == %f\n", fogstart
);
1157 glFogf(GL_FOG_END
, 0.0);
1158 checkGLcall("glFogf(GL_FOG_END, fogend)");
1159 TRACE("Fog End == %f\n", fogend
);
1163 checkGLcall("glDisable GL_FOG");
1164 if( use_ps(stateblock
->wineD3DDevice
) ) {
1165 /* disable fog in the pixel shader
1166 * NOTE: For pixel shader, GL_FOG_START and GL_FOG_END don't hold fog start s and end e but
1167 * -1/(e-s) and e/(e-s) respectively.
1169 glFogf(GL_FOG_START
, 0.0f
);
1170 checkGLcall("glFogf(GL_FOG_START, fogstart)");
1171 glFogf(GL_FOG_END
, 1.0f
);
1172 checkGLcall("glFogf(GL_FOG_END, fogend)");
1177 static void state_rangefog(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1178 if(stateblock
->renderState
[WINED3DRS_RANGEFOGENABLE
]) {
1179 if (GL_SUPPORT(NV_FOG_DISTANCE
)) {
1180 glFogi(GL_FOG_DISTANCE_MODE_NV
, GL_EYE_RADIAL_NV
);
1181 checkGLcall("glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_RADIAL_NV)");
1183 WARN("Range fog enabled, but not supported by this opengl implementation\n");
1186 if (GL_SUPPORT(NV_FOG_DISTANCE
)) {
1187 glFogi(GL_FOG_DISTANCE_MODE_NV
, GL_EYE_PLANE_ABSOLUTE_NV
);
1188 checkGLcall("glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_PLANE_ABSOLUTE_NV)");
1193 static void state_fogcolor(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1195 D3DCOLORTOGLFLOAT4(stateblock
->renderState
[WINED3DRS_FOGCOLOR
], col
);
1196 glFogfv(GL_FOG_COLOR
, &col
[0]);
1197 checkGLcall("glFog GL_FOG_COLOR");
1200 static void state_fogdensity(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1205 tmpvalue
.d
= stateblock
->renderState
[WINED3DRS_FOGDENSITY
];
1206 glFogfv(GL_FOG_DENSITY
, &tmpvalue
.f
);
1207 checkGLcall("glFogf(GL_FOG_DENSITY, (float) Value)");
1210 /* TODO: Merge with primitive type + init_materials()!! */
1211 static void state_colormat(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1212 IWineD3DDeviceImpl
*device
= stateblock
->wineD3DDevice
;
1214 WineDirect3DStridedData
*diffuse
= &device
->strided_streams
.u
.s
.diffuse
;
1215 BOOL isDiffuseSupplied
;
1217 /* Depends on the decoded vertex declaration to read the existence of diffuse data.
1218 * The vertex declaration will call this function if the fixed function pipeline is used.
1221 if(isStateDirty(context
, STATE_VDECL
)) {
1225 isDiffuseSupplied
= diffuse
->lpData
|| diffuse
->VBO
;
1227 context
->num_untracked_materials
= 0;
1228 if (isDiffuseSupplied
&& stateblock
->renderState
[WINED3DRS_COLORVERTEX
]) {
1229 TRACE("diff %d, amb %d, emis %d, spec %d\n",
1230 stateblock
->renderState
[WINED3DRS_DIFFUSEMATERIALSOURCE
],
1231 stateblock
->renderState
[WINED3DRS_AMBIENTMATERIALSOURCE
],
1232 stateblock
->renderState
[WINED3DRS_EMISSIVEMATERIALSOURCE
],
1233 stateblock
->renderState
[WINED3DRS_SPECULARMATERIALSOURCE
]);
1235 if (stateblock
->renderState
[WINED3DRS_DIFFUSEMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1236 if (stateblock
->renderState
[WINED3DRS_AMBIENTMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1237 Parm
= GL_AMBIENT_AND_DIFFUSE
;
1241 if(stateblock
->renderState
[WINED3DRS_EMISSIVEMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1242 context
->untracked_materials
[context
->num_untracked_materials
] = GL_EMISSION
;
1243 context
->num_untracked_materials
++;
1245 if(stateblock
->renderState
[WINED3DRS_SPECULARMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1246 context
->untracked_materials
[context
->num_untracked_materials
] = GL_SPECULAR
;
1247 context
->num_untracked_materials
++;
1249 } else if (stateblock
->renderState
[WINED3DRS_AMBIENTMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1251 if(stateblock
->renderState
[WINED3DRS_EMISSIVEMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1252 context
->untracked_materials
[context
->num_untracked_materials
] = GL_EMISSION
;
1253 context
->num_untracked_materials
++;
1255 if(stateblock
->renderState
[WINED3DRS_SPECULARMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1256 context
->untracked_materials
[context
->num_untracked_materials
] = GL_SPECULAR
;
1257 context
->num_untracked_materials
++;
1259 } else if (stateblock
->renderState
[WINED3DRS_EMISSIVEMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1261 if(stateblock
->renderState
[WINED3DRS_SPECULARMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1262 context
->untracked_materials
[context
->num_untracked_materials
] = GL_SPECULAR
;
1263 context
->num_untracked_materials
++;
1265 } else if (stateblock
->renderState
[WINED3DRS_SPECULARMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1270 /* Nothing changed, return. */
1271 if (Parm
== context
->tracking_parm
) return;
1274 glDisable(GL_COLOR_MATERIAL
);
1275 checkGLcall("glDisable GL_COLOR_MATERIAL");
1277 glColorMaterial(GL_FRONT_AND_BACK
, Parm
);
1278 checkGLcall("glColorMaterial(GL_FRONT_AND_BACK, Parm)");
1279 glEnable(GL_COLOR_MATERIAL
);
1280 checkGLcall("glEnable(GL_COLOR_MATERIAL)");
1283 /* Apparently calls to glMaterialfv are ignored for properties we're
1284 * tracking with glColorMaterial, so apply those here. */
1285 switch (context
->tracking_parm
) {
1286 case GL_AMBIENT_AND_DIFFUSE
:
1287 glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float*)&device
->updateStateBlock
->material
.Ambient
);
1288 glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float*)&device
->updateStateBlock
->material
.Diffuse
);
1289 checkGLcall("glMaterialfv");
1293 glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float*)&device
->updateStateBlock
->material
.Diffuse
);
1294 checkGLcall("glMaterialfv");
1298 glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float*)&device
->updateStateBlock
->material
.Ambient
);
1299 checkGLcall("glMaterialfv");
1303 glMaterialfv(GL_FRONT_AND_BACK
, GL_EMISSION
, (float*)&device
->updateStateBlock
->material
.Emissive
);
1304 checkGLcall("glMaterialfv");
1308 /* Only change material color if specular is enabled, otherwise it is set to black */
1309 if (device
->stateBlock
->renderState
[WINED3DRS_SPECULARENABLE
]) {
1310 glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, (float*)&device
->updateStateBlock
->material
.Specular
);
1311 checkGLcall("glMaterialfv");
1313 float black
[4] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
1314 glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, &black
[0]);
1315 checkGLcall("glMaterialfv");
1320 context
->tracking_parm
= Parm
;
1323 static void state_linepattern(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1326 WINED3DLINEPATTERN lp
;
1328 tmppattern
.d
= stateblock
->renderState
[WINED3DRS_LINEPATTERN
];
1330 TRACE("Line pattern: repeat %d bits %x\n", tmppattern
.lp
.wRepeatFactor
, tmppattern
.lp
.wLinePattern
);
1332 if (tmppattern
.lp
.wRepeatFactor
) {
1333 glLineStipple(tmppattern
.lp
.wRepeatFactor
, tmppattern
.lp
.wLinePattern
);
1334 checkGLcall("glLineStipple(repeat, linepattern)");
1335 glEnable(GL_LINE_STIPPLE
);
1336 checkGLcall("glEnable(GL_LINE_STIPPLE);");
1338 glDisable(GL_LINE_STIPPLE
);
1339 checkGLcall("glDisable(GL_LINE_STIPPLE);");
1343 static void state_zbias(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1349 if (stateblock
->renderState
[WINED3DRS_ZBIAS
]) {
1350 tmpvalue
.d
= stateblock
->renderState
[WINED3DRS_ZBIAS
];
1351 TRACE("ZBias value %f\n", tmpvalue
.f
);
1352 glPolygonOffset(0, -tmpvalue
.f
);
1353 checkGLcall("glPolygonOffset(0, -Value)");
1354 glEnable(GL_POLYGON_OFFSET_FILL
);
1355 checkGLcall("glEnable(GL_POLYGON_OFFSET_FILL);");
1356 glEnable(GL_POLYGON_OFFSET_LINE
);
1357 checkGLcall("glEnable(GL_POLYGON_OFFSET_LINE);");
1358 glEnable(GL_POLYGON_OFFSET_POINT
);
1359 checkGLcall("glEnable(GL_POLYGON_OFFSET_POINT);");
1361 glDisable(GL_POLYGON_OFFSET_FILL
);
1362 checkGLcall("glDisable(GL_POLYGON_OFFSET_FILL);");
1363 glDisable(GL_POLYGON_OFFSET_LINE
);
1364 checkGLcall("glDisable(GL_POLYGON_OFFSET_LINE);");
1365 glDisable(GL_POLYGON_OFFSET_POINT
);
1366 checkGLcall("glDisable(GL_POLYGON_OFFSET_POINT);");
1371 static void state_normalize(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1372 if(isStateDirty(context
, STATE_VDECL
)) {
1375 /* Without vertex normals, we set the current normal to 0/0/0 to remove the diffuse factor
1376 * from the opengl lighting equation, as d3d does. Normalization of 0/0/0 can lead to a division
1377 * by zero and is not properly defined in opengl, so avoid it
1379 if (stateblock
->renderState
[WINED3DRS_NORMALIZENORMALS
] && (
1380 stateblock
->wineD3DDevice
->strided_streams
.u
.s
.normal
.lpData
||
1381 stateblock
->wineD3DDevice
->strided_streams
.u
.s
.normal
.VBO
)) {
1382 glEnable(GL_NORMALIZE
);
1383 checkGLcall("glEnable(GL_NORMALIZE);");
1385 glDisable(GL_NORMALIZE
);
1386 checkGLcall("glDisable(GL_NORMALIZE);");
1390 static void state_psizemin(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1396 tmpvalue
.d
= stateblock
->renderState
[WINED3DRS_POINTSIZE_MIN
];
1397 if(GL_SUPPORT(ARB_POINT_PARAMETERS
)) {
1398 GL_EXTCALL(glPointParameterfARB
)(GL_POINT_SIZE_MIN_ARB
, tmpvalue
.f
);
1399 checkGLcall("glPointParameterfARB(...)");
1401 else if(GL_SUPPORT(EXT_POINT_PARAMETERS
)) {
1402 GL_EXTCALL(glPointParameterfEXT
)(GL_POINT_SIZE_MIN_EXT
, tmpvalue
.f
);
1403 checkGLcall("glPointParameterfEXT(...)");
1404 } else if(tmpvalue
.f
!= 1.0) {
1405 FIXME("WINED3DRS_POINTSIZE_MIN not supported on this opengl, value is %f\n", tmpvalue
.f
);
1409 static void state_psizemax(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1415 tmpvalue
.d
= stateblock
->renderState
[WINED3DRS_POINTSIZE_MAX
];
1416 if(GL_SUPPORT(ARB_POINT_PARAMETERS
)) {
1417 GL_EXTCALL(glPointParameterfARB
)(GL_POINT_SIZE_MAX_ARB
, tmpvalue
.f
);
1418 checkGLcall("glPointParameterfARB(...)");
1420 else if(GL_SUPPORT(EXT_POINT_PARAMETERS
)) {
1421 GL_EXTCALL(glPointParameterfEXT
)(GL_POINT_SIZE_MAX_EXT
, tmpvalue
.f
);
1422 checkGLcall("glPointParameterfEXT(...)");
1423 } else if(tmpvalue
.f
!= 64.0) {
1424 FIXME("WINED3DRS_POINTSIZE_MAX not supported on this opengl, value is %f\n", tmpvalue
.f
);
1428 static void state_pscale(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1429 /* TODO: Group this with the viewport */
1431 * POINTSCALEENABLE controls how point size value is treated. If set to
1432 * true, the point size is scaled with respect to height of viewport.
1433 * When set to false point size is in pixels.
1436 /* Default values */
1437 GLfloat att
[3] = {1.0f
, 0.0f
, 0.0f
};
1441 } pointSize
, A
, B
, C
;
1443 pointSize
.d
= stateblock
->renderState
[WINED3DRS_POINTSIZE
];
1444 A
.d
= stateblock
->renderState
[WINED3DRS_POINTSCALE_A
];
1445 B
.d
= stateblock
->renderState
[WINED3DRS_POINTSCALE_B
];
1446 C
.d
= stateblock
->renderState
[WINED3DRS_POINTSCALE_C
];
1448 if(stateblock
->renderState
[WINED3DRS_POINTSCALEENABLE
]) {
1449 GLfloat scaleFactor
;
1450 float h
= stateblock
->viewport
.Height
;
1452 if(pointSize
.f
< GL_LIMITS(pointsizemin
)) {
1454 * Minimum valid point size for OpenGL is driver specific. For Direct3D it is
1455 * 0.0f. This means that OpenGL will clamp really small point sizes to the
1456 * driver minimum. To correct for this we need to multiply by the scale factor when sizes
1457 * are less than 1.0f. scale_factor = 1.0f / point_size.
1459 scaleFactor
= pointSize
.f
/ GL_LIMITS(pointsizemin
);
1460 /* Clamp the point size, don't rely on the driver to do it. MacOS says min point size
1461 * is 1.0, but then accepts points below that and draws too small points
1463 pointSize
.f
= GL_LIMITS(pointsizemin
);
1464 } else if(pointSize
.f
> GL_LIMITS(pointsize
)) {
1465 /* gl already scales the input to glPointSize,
1466 * d3d scales the result after the point size scale.
1467 * If the point size is bigger than the max size, use the
1468 * scaling to scale it bigger, and set the gl point size to max
1470 scaleFactor
= pointSize
.f
/ GL_LIMITS(pointsize
);
1471 TRACE("scale: %f\n", scaleFactor
);
1472 pointSize
.f
= GL_LIMITS(pointsize
);
1476 scaleFactor
= pow(h
* scaleFactor
, 2);
1478 att
[0] = A
.f
/ scaleFactor
;
1479 att
[1] = B
.f
/ scaleFactor
;
1480 att
[2] = C
.f
/ scaleFactor
;
1483 if(GL_SUPPORT(ARB_POINT_PARAMETERS
)) {
1484 GL_EXTCALL(glPointParameterfvARB
)(GL_POINT_DISTANCE_ATTENUATION_ARB
, att
);
1485 checkGLcall("glPointParameterfvARB(GL_DISTANCE_ATTENUATION_ARB, ...)");
1487 else if(GL_SUPPORT(EXT_POINT_PARAMETERS
)) {
1488 GL_EXTCALL(glPointParameterfvEXT
)(GL_DISTANCE_ATTENUATION_EXT
, att
);
1489 checkGLcall("glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, ...)");
1490 } else if(stateblock
->renderState
[WINED3DRS_POINTSCALEENABLE
]) {
1491 WARN("POINT_PARAMETERS not supported in this version of opengl\n");
1494 glPointSize(pointSize
.f
);
1495 checkGLcall("glPointSize(...);");
1498 static void state_colorwrite(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1499 DWORD Value
= stateblock
->renderState
[WINED3DRS_COLORWRITEENABLE
];
1501 TRACE("Color mask: r(%d) g(%d) b(%d) a(%d)\n",
1502 Value
& WINED3DCOLORWRITEENABLE_RED
? 1 : 0,
1503 Value
& WINED3DCOLORWRITEENABLE_GREEN
? 1 : 0,
1504 Value
& WINED3DCOLORWRITEENABLE_BLUE
? 1 : 0,
1505 Value
& WINED3DCOLORWRITEENABLE_ALPHA
? 1 : 0);
1506 glColorMask(Value
& WINED3DCOLORWRITEENABLE_RED
? GL_TRUE
: GL_FALSE
,
1507 Value
& WINED3DCOLORWRITEENABLE_GREEN
? GL_TRUE
: GL_FALSE
,
1508 Value
& WINED3DCOLORWRITEENABLE_BLUE
? GL_TRUE
: GL_FALSE
,
1509 Value
& WINED3DCOLORWRITEENABLE_ALPHA
? GL_TRUE
: GL_FALSE
);
1510 checkGLcall("glColorMask(...)");
1512 /* depends on WINED3DRS_COLORWRITEENABLE. */
1513 if(stateblock
->renderState
[WINED3DRS_COLORWRITEENABLE1
] != 0x0000000F ||
1514 stateblock
->renderState
[WINED3DRS_COLORWRITEENABLE2
] != 0x0000000F ||
1515 stateblock
->renderState
[WINED3DRS_COLORWRITEENABLE3
] != 0x0000000F ) {
1516 ERR("(WINED3DRS_COLORWRITEENABLE1/2/3,%d,%d,%d) not yet implemented. Missing of cap D3DPMISCCAPS_INDEPENDENTWRITEMASKS wasn't honored?\n",
1517 stateblock
->renderState
[WINED3DRS_COLORWRITEENABLE1
],
1518 stateblock
->renderState
[WINED3DRS_COLORWRITEENABLE2
],
1519 stateblock
->renderState
[WINED3DRS_COLORWRITEENABLE3
]);
1523 static void state_localviewer(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1524 if(stateblock
->renderState
[WINED3DRS_LOCALVIEWER
]) {
1525 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER
, 1);
1526 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1)");
1528 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER
, 0);
1529 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 0)");
1533 static void state_lastpixel(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1534 if(stateblock
->renderState
[WINED3DRS_LASTPIXEL
]) {
1535 TRACE("Last Pixel Drawing Enabled\n");
1537 static BOOL first
= TRUE
;
1539 FIXME("Last Pixel Drawing Disabled, not handled yet\n");
1542 TRACE("Last Pixel Drawing Disabled, not handled yet\n");
1547 static void state_pointsprite(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1548 /* TODO: NV_POINT_SPRITE */
1549 if (!GL_SUPPORT(ARB_POINT_SPRITE
)) {
1550 TRACE("Point sprites not supported\n");
1554 if (stateblock
->renderState
[WINED3DRS_POINTSPRITEENABLE
]) {
1555 glEnable(GL_POINT_SPRITE_ARB
);
1556 checkGLcall("glEnable(GL_POINT_SPRITE_ARB)");
1558 glDisable(GL_POINT_SPRITE_ARB
);
1559 checkGLcall("glDisable(GL_POINT_SPRITE_ARB)");
1563 static void state_wrap(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1565 http://www.cosc.brocku.ca/Offerings/3P98/course/lectures/texture/
1566 http://www.gamedev.net/reference/programming/features/rendererdll3/page2.asp
1567 Discussion on the ways to turn on WRAPing to solve an OpenGL conversion problem.
1568 http://www.flipcode.org/cgi-bin/fcmsg.cgi?thread_show=10248
1570 so far as I can tell, wrapping and texture-coordinate generate go hand in hand,
1573 if(stateblock
->renderState
[WINED3DRS_WRAP0
] ||
1574 stateblock
->renderState
[WINED3DRS_WRAP1
] ||
1575 stateblock
->renderState
[WINED3DRS_WRAP2
] ||
1576 stateblock
->renderState
[WINED3DRS_WRAP3
] ||
1577 stateblock
->renderState
[WINED3DRS_WRAP4
] ||
1578 stateblock
->renderState
[WINED3DRS_WRAP5
] ||
1579 stateblock
->renderState
[WINED3DRS_WRAP6
] ||
1580 stateblock
->renderState
[WINED3DRS_WRAP7
] ||
1581 stateblock
->renderState
[WINED3DRS_WRAP8
] ||
1582 stateblock
->renderState
[WINED3DRS_WRAP9
] ||
1583 stateblock
->renderState
[WINED3DRS_WRAP10
] ||
1584 stateblock
->renderState
[WINED3DRS_WRAP11
] ||
1585 stateblock
->renderState
[WINED3DRS_WRAP12
] ||
1586 stateblock
->renderState
[WINED3DRS_WRAP13
] ||
1587 stateblock
->renderState
[WINED3DRS_WRAP14
] ||
1588 stateblock
->renderState
[WINED3DRS_WRAP15
] ) {
1589 FIXME("(WINED3DRS_WRAP0) Texture wraping not yet supported\n");
1593 static void state_multisampleaa(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1594 if( GL_SUPPORT(ARB_MULTISAMPLE
) ) {
1595 if(stateblock
->renderState
[WINED3DRS_MULTISAMPLEANTIALIAS
]) {
1596 glEnable(GL_MULTISAMPLE_ARB
);
1597 checkGLcall("glEnable(GL_MULTISAMPLE_ARB)");
1599 glDisable(GL_MULTISAMPLE_ARB
);
1600 checkGLcall("glDisable(GL_MULTISAMPLE_ARB)");
1603 if(stateblock
->renderState
[WINED3DRS_MULTISAMPLEANTIALIAS
]) {
1604 WARN("Multisample antialiasing not supported by gl\n");
1609 static void state_scissor(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1610 if(stateblock
->renderState
[WINED3DRS_SCISSORTESTENABLE
]) {
1611 glEnable(GL_SCISSOR_TEST
);
1612 checkGLcall("glEnable(GL_SCISSOR_TEST)");
1614 glDisable(GL_SCISSOR_TEST
);
1615 checkGLcall("glDisable(GL_SCISSOR_TEST)");
1619 static void state_depthbias(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1625 if(stateblock
->renderState
[WINED3DRS_SLOPESCALEDEPTHBIAS
] ||
1626 stateblock
->renderState
[WINED3DRS_DEPTHBIAS
]) {
1627 tmpvalue
.d
= stateblock
->renderState
[WINED3DRS_SLOPESCALEDEPTHBIAS
];
1628 glEnable(GL_POLYGON_OFFSET_FILL
);
1629 checkGLcall("glEnable(GL_POLYGON_OFFSET_FILL)");
1630 glPolygonOffset(tmpvalue
.f
, *((float*)&stateblock
->renderState
[WINED3DRS_DEPTHBIAS
]));
1631 checkGLcall("glPolygonOffset(...)");
1633 glDisable(GL_POLYGON_OFFSET_FILL
);
1634 checkGLcall("glDisable(GL_POLYGON_OFFSET_FILL)");
1638 static void state_perspective(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1639 if (stateblock
->renderState
[WINED3DRS_TEXTUREPERSPECTIVE
]) {
1640 glHint(GL_PERSPECTIVE_CORRECTION_HINT
, GL_NICEST
);
1641 checkGLcall("glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)");
1643 glHint(GL_PERSPECTIVE_CORRECTION_HINT
, GL_FASTEST
);
1644 checkGLcall("glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST)");
1648 static void state_stippledalpha(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1650 if (stateblock
->renderState
[WINED3DRS_STIPPLEDALPHA
])
1651 FIXME(" Stippled Alpha not supported yet.\n");
1654 static void state_antialias(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1656 if (stateblock
->renderState
[WINED3DRS_ANTIALIAS
])
1657 FIXME(" Antialias not supported yet.\n");
1660 static void state_multisampmask(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1662 if (stateblock
->renderState
[WINED3DRS_MULTISAMPLEMASK
] != 0xFFFFFFFF)
1663 FIXME("(WINED3DRS_MULTISAMPLEMASK,%d) not yet implemented\n", stateblock
->renderState
[WINED3DRS_MULTISAMPLEMASK
]);
1666 static void state_patchedgestyle(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1668 if (stateblock
->renderState
[WINED3DRS_PATCHEDGESTYLE
] != WINED3DPATCHEDGE_DISCRETE
)
1669 FIXME("(WINED3DRS_PATCHEDGESTYLE,%d) not yet implemented\n", stateblock
->renderState
[WINED3DRS_PATCHEDGESTYLE
]);
1672 static void state_patchsegments(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1680 if (stateblock
->renderState
[WINED3DRS_PATCHSEGMENTS
] != tmpvalue
.d
)
1682 static BOOL displayed
= FALSE
;
1684 tmpvalue
.d
= stateblock
->renderState
[WINED3DRS_PATCHSEGMENTS
];
1686 FIXME("(WINED3DRS_PATCHSEGMENTS,%f) not yet implemented\n", tmpvalue
.f
);
1692 static void state_positiondegree(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1694 if (stateblock
->renderState
[WINED3DRS_POSITIONDEGREE
] != WINED3DDEGREE_CUBIC
)
1695 FIXME("(WINED3DRS_POSITIONDEGREE,%d) not yet implemented\n", stateblock
->renderState
[WINED3DRS_POSITIONDEGREE
]);
1698 static void state_normaldegree(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1700 if (stateblock
->renderState
[WINED3DRS_NORMALDEGREE
] != WINED3DDEGREE_LINEAR
)
1701 FIXME("(WINED3DRS_NORMALDEGREE,%d) not yet implemented\n", stateblock
->renderState
[WINED3DRS_NORMALDEGREE
]);
1704 static void state_tessellation(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1706 if(stateblock
->renderState
[WINED3DRS_ENABLEADAPTIVETESSELLATION
])
1707 FIXME("(WINED3DRS_ENABLEADAPTIVETESSELLATION,%d) not yet implemented\n", stateblock
->renderState
[WINED3DRS_ENABLEADAPTIVETESSELLATION
]);
1710 static void state_wrapu(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1711 if(stateblock
->renderState
[WINED3DRS_WRAPU
]) {
1712 FIXME("Render state WINED3DRS_WRAPU not implemented yet\n");
1716 static void state_wrapv(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1717 if(stateblock
->renderState
[WINED3DRS_WRAPV
]) {
1718 FIXME("Render state WINED3DRS_WRAPV not implemented yet\n");
1722 static void state_monoenable(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1723 if(stateblock
->renderState
[WINED3DRS_MONOENABLE
]) {
1724 FIXME("Render state WINED3DRS_MONOENABLE not implemented yet\n");
1728 static void state_rop2(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1729 if(stateblock
->renderState
[WINED3DRS_ROP2
]) {
1730 FIXME("Render state WINED3DRS_ROP2 not implemented yet\n");
1734 static void state_planemask(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1735 if(stateblock
->renderState
[WINED3DRS_PLANEMASK
]) {
1736 FIXME("Render state WINED3DRS_PLANEMASK not implemented yet\n");
1740 static void state_subpixel(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1741 if(stateblock
->renderState
[WINED3DRS_SUBPIXEL
]) {
1742 FIXME("Render state WINED3DRS_SUBPIXEL not implemented yet\n");
1746 static void state_subpixelx(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1747 if(stateblock
->renderState
[WINED3DRS_SUBPIXELX
]) {
1748 FIXME("Render state WINED3DRS_SUBPIXELX not implemented yet\n");
1752 static void state_stippleenable(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1753 if(stateblock
->renderState
[WINED3DRS_STIPPLEENABLE
]) {
1754 FIXME("Render state WINED3DRS_STIPPLEENABLE not implemented yet\n");
1758 static void state_bordercolor(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1759 if(stateblock
->renderState
[WINED3DRS_BORDERCOLOR
]) {
1760 FIXME("Render state WINED3DRS_BORDERCOLOR not implemented yet\n");
1764 static void state_mipmaplodbias(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1765 if(stateblock
->renderState
[WINED3DRS_MIPMAPLODBIAS
]) {
1766 FIXME("Render state WINED3DRS_MIPMAPLODBIAS not implemented yet\n");
1770 static void state_anisotropy(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1771 if(stateblock
->renderState
[WINED3DRS_ANISOTROPY
]) {
1772 FIXME("Render state WINED3DRS_ANISOTROPY not implemented yet\n");
1776 static void state_flushbatch(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1777 if(stateblock
->renderState
[WINED3DRS_FLUSHBATCH
]) {
1778 FIXME("Render state WINED3DRS_FLUSHBATCH not implemented yet\n");
1782 static void state_translucentsi(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1783 if(stateblock
->renderState
[WINED3DRS_TRANSLUCENTSORTINDEPENDENT
]) {
1784 FIXME("Render state WINED3DRS_TRANSLUCENTSORTINDEPENDENT not implemented yet\n");
1788 static void state_extents(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1789 if(stateblock
->renderState
[WINED3DRS_EXTENTS
]) {
1790 FIXME("Render state WINED3DRS_EXTENTS not implemented yet\n");
1794 static void state_ckeyblend(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1795 if(stateblock
->renderState
[WINED3DRS_COLORKEYBLENDENABLE
]) {
1796 FIXME("Render state WINED3DRS_COLORKEYBLENDENABLE not implemented yet\n");
1800 /* Activates the texture dimension according to the bound D3D texture.
1801 * Does not care for the colorop or correct gl texture unit(when using nvrc)
1802 * Requires the caller to activate the correct unit before
1804 static void activate_dimensions(DWORD stage
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1805 BOOL bumpmap
= FALSE
;
1807 if(stage
> 0 && (stateblock
->textureState
[stage
- 1][WINED3DTSS_COLOROP
] == WINED3DTOP_BUMPENVMAPLUMINANCE
||
1808 stateblock
->textureState
[stage
- 1][WINED3DTSS_COLOROP
] == WINED3DTOP_BUMPENVMAP
)) {
1810 context
->texShaderBumpMap
|= (1 << stage
);
1812 context
->texShaderBumpMap
&= ~(1 << stage
);
1815 if(stateblock
->textures
[stage
]) {
1816 switch(stateblock
->textureDimensions
[stage
]) {
1818 if(GL_SUPPORT(NV_TEXTURE_SHADER2
)) {
1819 glTexEnvi(GL_TEXTURE_SHADER_NV
, GL_SHADER_OPERATION_NV
, bumpmap
? GL_OFFSET_TEXTURE_2D_NV
: GL_TEXTURE_2D
);
1820 checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, ...)");
1822 glDisable(GL_TEXTURE_3D
);
1823 checkGLcall("glDisable(GL_TEXTURE_3D)");
1824 if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP
)) {
1825 glDisable(GL_TEXTURE_CUBE_MAP_ARB
);
1826 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
1828 if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE
)) {
1829 glDisable(GL_TEXTURE_RECTANGLE_ARB
);
1830 checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)");
1832 glEnable(GL_TEXTURE_2D
);
1833 checkGLcall("glEnable(GL_TEXTURE_2D)");
1836 case GL_TEXTURE_RECTANGLE_ARB
:
1837 if(GL_SUPPORT(NV_TEXTURE_SHADER2
)) {
1838 glTexEnvi(GL_TEXTURE_SHADER_NV
, GL_SHADER_OPERATION_NV
, bumpmap
? GL_OFFSET_TEXTURE_2D_NV
: GL_TEXTURE_RECTANGLE_ARB
);
1839 checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, ...)");
1841 glDisable(GL_TEXTURE_2D
);
1842 checkGLcall("glDisable(GL_TEXTURE_2D)");
1843 glDisable(GL_TEXTURE_3D
);
1844 checkGLcall("glDisable(GL_TEXTURE_3D)");
1845 if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP
)) {
1846 glDisable(GL_TEXTURE_CUBE_MAP_ARB
);
1847 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
1849 glEnable(GL_TEXTURE_RECTANGLE_ARB
);
1850 checkGLcall("glEnable(GL_TEXTURE_RECTANGLE_ARB)");
1854 if(GL_SUPPORT(NV_TEXTURE_SHADER2
)) {
1855 glTexEnvi(GL_TEXTURE_SHADER_NV
, GL_SHADER_OPERATION_NV
, GL_TEXTURE_3D
);
1856 checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_3D)");
1858 if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP
)) {
1859 glDisable(GL_TEXTURE_CUBE_MAP_ARB
);
1860 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
1862 if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE
)) {
1863 glDisable(GL_TEXTURE_RECTANGLE_ARB
);
1864 checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)");
1866 glDisable(GL_TEXTURE_2D
);
1867 checkGLcall("glDisable(GL_TEXTURE_2D)");
1868 glEnable(GL_TEXTURE_3D
);
1869 checkGLcall("glEnable(GL_TEXTURE_3D)");
1872 case GL_TEXTURE_CUBE_MAP_ARB
:
1873 if(GL_SUPPORT(NV_TEXTURE_SHADER2
)) {
1874 glTexEnvi(GL_TEXTURE_SHADER_NV
, GL_SHADER_OPERATION_NV
, GL_TEXTURE_CUBE_MAP_ARB
);
1875 checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_CUBE_MAP_ARB)");
1877 glDisable(GL_TEXTURE_2D
);
1878 checkGLcall("glDisable(GL_TEXTURE_2D)");
1879 glDisable(GL_TEXTURE_3D
);
1880 checkGLcall("glDisable(GL_TEXTURE_3D)");
1881 if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE
)) {
1882 glDisable(GL_TEXTURE_RECTANGLE_ARB
);
1883 checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)");
1885 glEnable(GL_TEXTURE_CUBE_MAP_ARB
);
1886 checkGLcall("glEnable(GL_TEXTURE_CUBE_MAP_ARB)");
1891 if(GL_SUPPORT(NV_TEXTURE_SHADER2
)) {
1892 glTexEnvi(GL_TEXTURE_SHADER_NV
, GL_SHADER_OPERATION_NV
, GL_NONE
);
1893 checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_NONE)");
1895 glEnable(GL_TEXTURE_2D
);
1896 checkGLcall("glEnable(GL_TEXTURE_2D)");
1897 glDisable(GL_TEXTURE_3D
);
1898 checkGLcall("glDisable(GL_TEXTURE_3D)");
1899 if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP
)) {
1900 glDisable(GL_TEXTURE_CUBE_MAP_ARB
);
1901 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
1903 if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE
)) {
1904 glDisable(GL_TEXTURE_RECTANGLE_ARB
);
1905 checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)");
1907 /* Binding textures is done by samplers. A dummy texture will be bound */
1912 static void tex_colorop(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1913 DWORD stage
= (state
- STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE
;
1914 DWORD mapped_stage
= stateblock
->wineD3DDevice
->texUnitMap
[stage
];
1915 BOOL tex_used
= stateblock
->wineD3DDevice
->fixed_function_usage_map
[stage
];
1917 TRACE("Setting color op for stage %d\n", stage
);
1919 if (stateblock
->pixelShader
&& stateblock
->wineD3DDevice
->ps_selected_mode
!= SHADER_NONE
&&
1920 ((IWineD3DPixelShaderImpl
*)stateblock
->pixelShader
)->baseShader
.function
) {
1921 /* Using a pixel shader? Don't care for anything here, the shader applying does it */
1925 if (stage
!= mapped_stage
) WARN("Using non 1:1 mapping: %d -> %d!\n", stage
, mapped_stage
);
1927 if (mapped_stage
!= -1) {
1928 if (GL_SUPPORT(ARB_MULTITEXTURE
)) {
1929 if (tex_used
&& mapped_stage
>= GL_LIMITS(textures
)) {
1930 FIXME("Attempt to enable unsupported stage!\n");
1933 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
1934 checkGLcall("glActiveTextureARB");
1935 } else if (stage
> 0) {
1936 WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
1941 if (GL_SUPPORT(NV_REGISTER_COMBINERS
)) {
1942 if(stateblock
->lowest_disabled_stage
> 0) {
1943 glEnable(GL_REGISTER_COMBINERS_NV
);
1944 GL_EXTCALL(glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV
, stateblock
->lowest_disabled_stage
));
1946 glDisable(GL_REGISTER_COMBINERS_NV
);
1949 if(stage
>= stateblock
->lowest_disabled_stage
) {
1950 TRACE("Stage disabled\n");
1951 if (mapped_stage
!= -1) {
1952 /* Disable everything here */
1953 glDisable(GL_TEXTURE_2D
);
1954 checkGLcall("glDisable(GL_TEXTURE_2D)");
1955 glDisable(GL_TEXTURE_3D
);
1956 checkGLcall("glDisable(GL_TEXTURE_3D)");
1957 if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP
)) {
1958 glDisable(GL_TEXTURE_CUBE_MAP_ARB
);
1959 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
1961 if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE
)) {
1962 glDisable(GL_TEXTURE_RECTANGLE_ARB
);
1963 checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)");
1965 if(GL_SUPPORT(NV_TEXTURE_SHADER2
) && mapped_stage
< GL_LIMITS(textures
)) {
1966 glTexEnvi(GL_TEXTURE_SHADER_NV
, GL_SHADER_OPERATION_NV
, GL_NONE
);
1973 /* The sampler will also activate the correct texture dimensions, so no need to do it here
1974 * if the sampler for this stage is dirty
1976 if(!isStateDirty(context
, STATE_SAMPLER(stage
))) {
1977 if (tex_used
) activate_dimensions(stage
, stateblock
, context
);
1980 /* Set the texture combiners */
1981 if (GL_SUPPORT(NV_REGISTER_COMBINERS
)) {
1982 set_tex_op_nvrc((IWineD3DDevice
*)stateblock
->wineD3DDevice
, FALSE
, stage
,
1983 stateblock
->textureState
[stage
][WINED3DTSS_COLOROP
],
1984 stateblock
->textureState
[stage
][WINED3DTSS_COLORARG1
],
1985 stateblock
->textureState
[stage
][WINED3DTSS_COLORARG2
],
1986 stateblock
->textureState
[stage
][WINED3DTSS_COLORARG0
],
1989 /* In register combiners bump mapping is done in the stage AFTER the one that has the bump map operation set,
1990 * thus the texture shader may have to be updated
1992 if(GL_SUPPORT(NV_TEXTURE_SHADER2
)) {
1993 BOOL usesBump
= (stateblock
->textureState
[stage
][WINED3DTSS_COLOROP
] == WINED3DTOP_BUMPENVMAPLUMINANCE
||
1994 stateblock
->textureState
[stage
][WINED3DTSS_COLOROP
] == WINED3DTOP_BUMPENVMAP
) ? TRUE
: FALSE
;
1995 BOOL usedBump
= (context
->texShaderBumpMap
& 1 << (stage
+ 1)) ? TRUE
: FALSE
;
1996 if(usesBump
!= usedBump
) {
1997 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
+ 1));
1998 checkGLcall("glActiveTextureARB");
1999 activate_dimensions(stage
+ 1, stateblock
, context
);
2000 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
2001 checkGLcall("glActiveTextureARB");
2005 set_tex_op((IWineD3DDevice
*)stateblock
->wineD3DDevice
, FALSE
, stage
,
2006 stateblock
->textureState
[stage
][WINED3DTSS_COLOROP
],
2007 stateblock
->textureState
[stage
][WINED3DTSS_COLORARG1
],
2008 stateblock
->textureState
[stage
][WINED3DTSS_COLORARG2
],
2009 stateblock
->textureState
[stage
][WINED3DTSS_COLORARG0
]);
2013 static void tex_alphaop(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
2014 DWORD stage
= (state
- STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE
;
2015 DWORD mapped_stage
= stateblock
->wineD3DDevice
->texUnitMap
[stage
];
2016 BOOL tex_used
= stateblock
->wineD3DDevice
->fixed_function_usage_map
[stage
];
2017 DWORD op
, arg1
, arg2
, arg0
;
2019 TRACE("Setting alpha op for stage %d\n", stage
);
2020 /* Do not care for enabled / disabled stages, just assign the settings. colorop disables / enables required stuff */
2021 if (mapped_stage
!= -1) {
2022 if (GL_SUPPORT(ARB_MULTITEXTURE
)) {
2023 if (tex_used
&& mapped_stage
>= GL_LIMITS(textures
)) {
2024 FIXME("Attempt to enable unsupported stage!\n");
2027 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
2028 checkGLcall("glActiveTextureARB");
2029 } else if (stage
> 0) {
2030 /* We can't do anything here */
2031 WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
2036 op
= stateblock
->textureState
[stage
][WINED3DTSS_ALPHAOP
];
2037 arg1
= stateblock
->textureState
[stage
][WINED3DTSS_ALPHAARG1
];
2038 arg2
= stateblock
->textureState
[stage
][WINED3DTSS_ALPHAARG2
];
2039 arg0
= stateblock
->textureState
[stage
][WINED3DTSS_ALPHAARG0
];
2041 if(stateblock
->renderState
[WINED3DRS_COLORKEYENABLE
] && stage
== 0 &&
2042 stateblock
->textures
[0] &&
2043 (stateblock
->textureDimensions
[0] == GL_TEXTURE_2D
|| stateblock
->textureDimensions
[0] == GL_TEXTURE_RECTANGLE_ARB
)) {
2044 IWineD3DSurfaceImpl
*surf
= (IWineD3DSurfaceImpl
*) ((IWineD3DTextureImpl
*) stateblock
->textures
[0])->surfaces
[0];
2046 if(surf
->CKeyFlags
& WINEDDSD_CKSRCBLT
&&
2047 getFormatDescEntry(surf
->resource
.format
, NULL
, NULL
)->alphaMask
== 0x00000000) {
2049 /* Color keying needs to pass alpha values from the texture through to have the alpha test work properly.
2050 * On the other hand applications can still use texture combiners apparently. This code takes care that apps
2051 * cannot remove the texture's alpha channel entirely.
2053 * The fixup is required for Prince of Persia 3D(prison bars), while Moto racer 2 requires D3DTOP_MODULATE to work
2054 * on color keyed surfaces. Aliens vs Predator 1 uses color keyed textures and alpha component of diffuse color to
2055 * draw things like translucent text and perform other blending effects.
2057 * Aliens vs Predator 1 relies on diffuse alpha having an effect, so it cannot be ignored. To provide the
2058 * behavior expected by the game, while emulating the colorkey, diffuse alpha must be modulated with texture alpha.
2059 * OTOH, Moto racer 2 at some points sets alphaop/alphaarg to SELECTARG/CURRENT, yet puts garbage in diffuse alpha
2060 * (zeroes). This works on native, because the game disables alpha test and alpha blending. Alpha test is overwritten by
2061 * wine's for purposes of color-keying though, so this will lead to missing geometry if texture alpha is modulated
2062 * (pixels fail alpha test). To get around this, ALPHABLENDENABLE state is checked: if the app enables alpha blending,
2063 * it can be expected to provide meaningful values in diffuse alpha, so it should be modulated with texture alpha;
2064 * otherwise, selecting diffuse alpha is ignored in favour of texture alpha.
2066 * What to do with multitexturing? So far no app has been found that uses color keying with multitexturing
2068 if(op
== WINED3DTOP_DISABLE
) {
2069 arg1
= WINED3DTA_TEXTURE
;
2070 op
= WINED3DTOP_SELECTARG1
;
2072 else if(op
== WINED3DTOP_SELECTARG1
&& arg1
!= WINED3DTA_TEXTURE
) {
2073 if (stateblock
->renderState
[WINED3DRS_ALPHABLENDENABLE
]) {
2074 arg2
= WINED3DTA_TEXTURE
;
2075 op
= WINED3DTOP_MODULATE
;
2077 else arg1
= WINED3DTA_TEXTURE
;
2079 else if(op
== WINED3DTOP_SELECTARG2
&& arg2
!= WINED3DTA_TEXTURE
) {
2080 if (stateblock
->renderState
[WINED3DRS_ALPHABLENDENABLE
]) {
2081 arg1
= WINED3DTA_TEXTURE
;
2082 op
= WINED3DTOP_MODULATE
;
2084 else arg2
= WINED3DTA_TEXTURE
;
2089 TRACE("Setting alpha op for stage %d\n", stage
);
2090 if (GL_SUPPORT(NV_REGISTER_COMBINERS
)) {
2091 set_tex_op_nvrc((IWineD3DDevice
*)stateblock
->wineD3DDevice
, TRUE
, stage
,
2092 op
, arg1
, arg2
, arg0
,
2095 set_tex_op((IWineD3DDevice
*)stateblock
->wineD3DDevice
, TRUE
, stage
,
2096 op
, arg1
, arg2
, arg0
);
2100 static void transform_texture(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
2101 DWORD texUnit
= state
- STATE_TRANSFORM(WINED3DTS_TEXTURE0
);
2102 DWORD mapped_stage
= stateblock
->wineD3DDevice
->texUnitMap
[texUnit
];
2105 /* Ignore this when a vertex shader is used, or if the streams aren't sorted out yet */
2106 if(use_vs(stateblock
->wineD3DDevice
) ||
2107 isStateDirty(context
, STATE_VDECL
)) {
2108 TRACE("Using a vertex shader, or stream sources not sorted out yet, skipping\n");
2112 if (mapped_stage
== -1) return;
2114 if (GL_SUPPORT(ARB_MULTITEXTURE
)) {
2115 if(mapped_stage
>= GL_LIMITS(textures
)) {
2118 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
2119 checkGLcall("glActiveTextureARB");
2120 } else if (mapped_stage
> 0) {
2121 /* We can't do anything here */
2122 WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
2125 generated
= (stateblock
->textureState
[texUnit
][WINED3DTSS_TEXCOORDINDEX
] & 0xFFFF0000) != WINED3DTSS_TCI_PASSTHRU
;
2127 set_texture_matrix(&stateblock
->transforms
[WINED3DTS_TEXTURE0
+ texUnit
].u
.m
[0][0],
2128 stateblock
->textureState
[texUnit
][WINED3DTSS_TEXTURETRANSFORMFLAGS
],
2130 context
->last_was_rhw
,
2131 stateblock
->wineD3DDevice
->strided_streams
.u
.s
.texCoords
[texUnit
].dwStride
?
2132 stateblock
->wineD3DDevice
->strided_streams
.u
.s
.texCoords
[texUnit
].dwType
:
2133 WINED3DDECLTYPE_UNUSED
);
2135 /* The sampler applying function calls us if this changes */
2136 if(context
->lastWasPow2Texture
[texUnit
] && stateblock
->textures
[texUnit
]) {
2138 FIXME("Non-power2 texture being used with generated texture coords\n");
2140 TRACE("Non power two matrix multiply fixup\n");
2141 glMultMatrixf(((IWineD3DTextureImpl
*) stateblock
->textures
[texUnit
])->baseTexture
.pow2Matrix
);
2145 static void unloadTexCoords(IWineD3DStateBlockImpl
*stateblock
) {
2148 for (texture_idx
= 0; texture_idx
< GL_LIMITS(texture_stages
); ++texture_idx
) {
2149 GL_EXTCALL(glClientActiveTextureARB(GL_TEXTURE0_ARB
+ texture_idx
));
2150 glDisableClientState(GL_TEXTURE_COORD_ARRAY
);
2154 static void loadTexCoords(IWineD3DStateBlockImpl
*stateblock
, WineDirect3DVertexStridedData
*sd
, GLint
*curVBO
) {
2155 UINT
*offset
= stateblock
->streamOffset
;
2156 unsigned int mapped_stage
= 0;
2157 unsigned int textureNo
= 0;
2159 /* The code below uses glClientActiveTexture and glMultiTexCoord* which are all part of the GL_ARB_multitexture extension. */
2160 /* Abort if we don't support the extension. */
2161 if (!GL_SUPPORT(ARB_MULTITEXTURE
)) {
2162 FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
2166 for (textureNo
= 0; textureNo
< GL_LIMITS(texture_stages
); ++textureNo
) {
2167 int coordIdx
= stateblock
->textureState
[textureNo
][WINED3DTSS_TEXCOORDINDEX
];
2169 mapped_stage
= stateblock
->wineD3DDevice
->texUnitMap
[textureNo
];
2170 if (mapped_stage
== -1) continue;
2172 if (coordIdx
< MAX_TEXTURES
&& (sd
->u
.s
.texCoords
[coordIdx
].lpData
|| sd
->u
.s
.texCoords
[coordIdx
].VBO
)) {
2173 TRACE("Setting up texture %u, idx %d, cordindx %u, data %p\n",
2174 textureNo
, mapped_stage
, coordIdx
, sd
->u
.s
.texCoords
[coordIdx
].lpData
);
2176 if (*curVBO
!= sd
->u
.s
.texCoords
[coordIdx
].VBO
) {
2177 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, sd
->u
.s
.texCoords
[coordIdx
].VBO
));
2178 checkGLcall("glBindBufferARB");
2179 *curVBO
= sd
->u
.s
.texCoords
[coordIdx
].VBO
;
2182 GL_EXTCALL(glClientActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
2183 checkGLcall("glClientActiveTextureARB");
2185 /* The coords to supply depend completely on the fvf / vertex shader */
2187 WINED3D_ATR_SIZE(sd
->u
.s
.texCoords
[coordIdx
].dwType
),
2188 WINED3D_ATR_GLTYPE(sd
->u
.s
.texCoords
[coordIdx
].dwType
),
2189 sd
->u
.s
.texCoords
[coordIdx
].dwStride
,
2190 sd
->u
.s
.texCoords
[coordIdx
].lpData
+ stateblock
->loadBaseVertexIndex
* sd
->u
.s
.texCoords
[coordIdx
].dwStride
+ offset
[sd
->u
.s
.texCoords
[coordIdx
].streamNo
]);
2191 glEnableClientState(GL_TEXTURE_COORD_ARRAY
);
2193 GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB
+ mapped_stage
, 0, 0, 0, 1));
2196 if (GL_SUPPORT(NV_REGISTER_COMBINERS
)) {
2197 /* The number of the mapped stages increases monotonically, so it's fine to use the last used one */
2198 for (textureNo
= mapped_stage
+ 1; textureNo
< GL_LIMITS(textures
); ++textureNo
) {
2199 GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB
+ textureNo
, 0, 0, 0, 1));
2204 static void tex_coordindex(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
2205 DWORD stage
= (state
- STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE
;
2206 DWORD mapped_stage
= stateblock
->wineD3DDevice
->texUnitMap
[stage
];
2208 if (mapped_stage
== -1) {
2209 TRACE("No texture unit mapped to stage %d. Skipping texture coordinates.\n", stage
);
2213 if (GL_SUPPORT(ARB_MULTITEXTURE
)) {
2214 if(mapped_stage
>= GL_LIMITS(fragment_samplers
)) {
2217 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
2218 checkGLcall("glActiveTextureARB");
2219 } else if (stage
> 0) {
2220 /* We can't do anything here */
2221 WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
2225 /* Values 0-7 are indexes into the FVF tex coords - See comments in DrawPrimitive
2227 * FIXME: From MSDN: The WINED3DTSS_TCI_* flags are mutually exclusive. If you include
2228 * one flag, you can still specify an index value, which the system uses to
2229 * determine the texture wrapping mode.
2230 * eg. SetTextureStageState( 0, WINED3DTSS_TEXCOORDINDEX, WINED3DTSS_TCI_CAMERASPACEPOSITION | 1 );
2231 * means use the vertex position (camera-space) as the input texture coordinates
2232 * for this texture stage, and the wrap mode set in the WINED3DRS_WRAP1 render
2233 * state. We do not (yet) support the WINED3DRENDERSTATE_WRAPx values, nor tie them up
2234 * to the TEXCOORDINDEX value
2238 * Be careful the value of the mask 0xF0000 come from d3d8types.h infos
2240 switch (stateblock
->textureState
[stage
][WINED3DTSS_TEXCOORDINDEX
] & 0xFFFF0000) {
2241 case WINED3DTSS_TCI_PASSTHRU
:
2242 /*Use the specified texture coordinates contained within the vertex format. This value resolves to zero.*/
2243 glDisable(GL_TEXTURE_GEN_S
);
2244 glDisable(GL_TEXTURE_GEN_T
);
2245 glDisable(GL_TEXTURE_GEN_R
);
2246 glDisable(GL_TEXTURE_GEN_Q
);
2247 checkGLcall("glDisable(GL_TEXTURE_GEN_S,T,R,Q)");
2250 case WINED3DTSS_TCI_CAMERASPACEPOSITION
:
2251 /* CameraSpacePosition means use the vertex position, transformed to camera space,
2252 * as the input texture coordinates for this stage's texture transformation. This
2253 * equates roughly to EYE_LINEAR
2256 float s_plane
[] = { 1.0, 0.0, 0.0, 0.0 };
2257 float t_plane
[] = { 0.0, 1.0, 0.0, 0.0 };
2258 float r_plane
[] = { 0.0, 0.0, 1.0, 0.0 };
2259 float q_plane
[] = { 0.0, 0.0, 0.0, 1.0 };
2260 TRACE("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set eye plane\n");
2262 glMatrixMode(GL_MODELVIEW
);
2265 glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
2266 glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
2267 glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
2268 glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
2271 TRACE("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set GL_TEXTURE_GEN_x and GL_x, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR\n");
2272 glEnable(GL_TEXTURE_GEN_S
);
2273 checkGLcall("glEnable(GL_TEXTURE_GEN_S)");
2274 glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
2275 checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)");
2276 glEnable(GL_TEXTURE_GEN_T
);
2277 checkGLcall("glEnable(GL_TEXTURE_GEN_T)");
2278 glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
2279 checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)");
2280 glEnable(GL_TEXTURE_GEN_R
);
2281 checkGLcall("glEnable(GL_TEXTURE_GEN_R)");
2282 glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
2283 checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)");
2287 case WINED3DTSS_TCI_CAMERASPACENORMAL
:
2289 if (GL_SUPPORT(NV_TEXGEN_REFLECTION
)) {
2290 float s_plane
[] = { 1.0, 0.0, 0.0, 0.0 };
2291 float t_plane
[] = { 0.0, 1.0, 0.0, 0.0 };
2292 float r_plane
[] = { 0.0, 0.0, 1.0, 0.0 };
2293 float q_plane
[] = { 0.0, 0.0, 0.0, 1.0 };
2294 TRACE("WINED3DTSS_TCI_CAMERASPACENORMAL - Set eye plane\n");
2296 glMatrixMode(GL_MODELVIEW
);
2299 glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
2300 glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
2301 glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
2302 glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
2305 glEnable(GL_TEXTURE_GEN_S
);
2306 checkGLcall("glEnable(GL_TEXTURE_GEN_S)");
2307 glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
2308 checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV)");
2309 glEnable(GL_TEXTURE_GEN_T
);
2310 checkGLcall("glEnable(GL_TEXTURE_GEN_T)");
2311 glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
2312 checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV)");
2313 glEnable(GL_TEXTURE_GEN_R
);
2314 checkGLcall("glEnable(GL_TEXTURE_GEN_R)");
2315 glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
2316 checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV)");
2321 case WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR
:
2323 if (GL_SUPPORT(NV_TEXGEN_REFLECTION
)) {
2324 float s_plane
[] = { 1.0, 0.0, 0.0, 0.0 };
2325 float t_plane
[] = { 0.0, 1.0, 0.0, 0.0 };
2326 float r_plane
[] = { 0.0, 0.0, 1.0, 0.0 };
2327 float q_plane
[] = { 0.0, 0.0, 0.0, 1.0 };
2328 TRACE("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Set eye plane\n");
2330 glMatrixMode(GL_MODELVIEW
);
2333 glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
2334 glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
2335 glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
2336 glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
2339 glEnable(GL_TEXTURE_GEN_S
);
2340 checkGLcall("glEnable(GL_TEXTURE_GEN_S)");
2341 glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
2342 checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV)");
2343 glEnable(GL_TEXTURE_GEN_T
);
2344 checkGLcall("glEnable(GL_TEXTURE_GEN_T)");
2345 glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
2346 checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV)");
2347 glEnable(GL_TEXTURE_GEN_R
);
2348 checkGLcall("glEnable(GL_TEXTURE_GEN_R)");
2349 glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
2350 checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV)");
2355 /* Unhandled types: */
2358 /* ? disable GL_TEXTURE_GEN_n ? */
2359 glDisable(GL_TEXTURE_GEN_S
);
2360 glDisable(GL_TEXTURE_GEN_T
);
2361 glDisable(GL_TEXTURE_GEN_R
);
2362 glDisable(GL_TEXTURE_GEN_Q
);
2363 FIXME("Unhandled WINED3DTSS_TEXCOORDINDEX %x\n", stateblock
->textureState
[stage
][WINED3DTSS_TEXCOORDINDEX
]);
2367 /* Update the texture matrix */
2368 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_TEXTURE0
+ stage
))) {
2369 transform_texture(STATE_TRANSFORM(WINED3DTS_TEXTURE0
+ stage
), stateblock
, context
);
2372 if(!isStateDirty(context
, STATE_VDECL
) && context
->namedArraysLoaded
) {
2373 /* Reload the arrays if we are using fixed function arrays to reflect the selected coord input
2374 * source. Call loadTexCoords directly because there is no need to reparse the vertex declaration
2375 * and do all the things linked to it
2376 * TODO: Tidy that up to reload only the arrays of the changed unit
2378 GLint curVBO
= GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT
) ? -1 : 0;
2380 unloadTexCoords(stateblock
);
2381 loadTexCoords(stateblock
, &stateblock
->wineD3DDevice
->strided_streams
, &curVBO
);
2385 static void shaderconstant(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
2386 IWineD3DDeviceImpl
*device
= stateblock
->wineD3DDevice
;
2388 /* Vertex and pixel shader states will call a shader upload, don't do anything as long one of them
2389 * has an update pending
2391 if(isStateDirty(context
, STATE_VDECL
) ||
2392 isStateDirty(context
, STATE_PIXELSHADER
)) {
2396 device
->shader_backend
->shader_load_constants((IWineD3DDevice
*) device
, use_ps(device
), use_vs(device
));
2399 static void tex_bumpenvlscale(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
2400 DWORD stage
= (state
- STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE
;
2406 if(stateblock
->pixelShader
&& stage
!= 0 &&
2407 ((IWineD3DPixelShaderImpl
*) stateblock
->pixelShader
)->baseShader
.reg_maps
.luminanceparams
[stage
]) {
2408 /* The pixel shader has to know the luminance scale. Do a constants update if it
2409 * isn't scheduled anyway
2411 if(!isStateDirty(context
, STATE_PIXELSHADERCONSTANT
) &&
2412 !isStateDirty(context
, STATE_PIXELSHADER
)) {
2413 shaderconstant(STATE_PIXELSHADERCONSTANT
, stateblock
, context
);
2417 tmpvalue
.d
= stateblock
->textureState
[stage
][WINED3DTSS_BUMPENVLSCALE
];
2418 if(tmpvalue
.f
!= 0.0) {
2419 FIXME("WINED3DTSS_BUMPENVLSCALE not supported yet\n");
2423 static void tex_bumpenvloffset(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
2424 DWORD stage
= (state
- STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE
;
2430 if(stateblock
->pixelShader
&& stage
!= 0 &&
2431 ((IWineD3DPixelShaderImpl
*) stateblock
->pixelShader
)->baseShader
.reg_maps
.luminanceparams
[stage
]) {
2432 /* The pixel shader has to know the luminance offset. Do a constants update if it
2433 * isn't scheduled anyway
2435 if(!isStateDirty(context
, STATE_PIXELSHADERCONSTANT
) &&
2436 !isStateDirty(context
, STATE_PIXELSHADER
)) {
2437 shaderconstant(STATE_PIXELSHADERCONSTANT
, stateblock
, context
);
2441 tmpvalue
.d
= stateblock
->textureState
[stage
][WINED3DTSS_BUMPENVLOFFSET
];
2442 if(tmpvalue
.f
!= 0.0) {
2443 FIXME("WINED3DTSS_BUMPENVLOFFSET not supported yet\n");
2447 static void tex_resultarg(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
2448 DWORD stage
= (state
- STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE
;
2450 if(stage
>= GL_LIMITS(texture_stages
)) {
2454 if(stateblock
->textureState
[stage
][WINED3DTSS_RESULTARG
] != WINED3DTA_CURRENT
) {
2455 FIXME("WINED3DTSS_RESULTARG not supported yet\n");
2459 static void sampler(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
2460 DWORD sampler
= state
- STATE_SAMPLER(0);
2461 DWORD mapped_stage
= stateblock
->wineD3DDevice
->texUnitMap
[sampler
];
2467 TRACE("Sampler: %d\n", sampler
);
2468 /* Enabling and disabling texture dimensions is done by texture stage state / pixel shader setup, this function
2469 * only has to bind textures and set the per texture states
2472 if (mapped_stage
== -1) {
2473 TRACE("No sampler mapped to stage %d. Returning.\n", sampler
);
2477 if (GL_SUPPORT(ARB_MULTITEXTURE
)) {
2478 if (mapped_stage
>= GL_LIMITS(combined_samplers
)) {
2481 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
2482 checkGLcall("glActiveTextureARB");
2483 } else if (sampler
> 0) {
2484 /* We can't do anything here */
2485 WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
2489 if(stateblock
->textures
[sampler
]) {
2490 BOOL texIsPow2
= FALSE
;
2492 /* The fixed function np2 texture emulation uses the texture matrix to fix up the coordinates
2493 * IWineD3DBaseTexture::ApplyStateChanges multiplies the set matrix with a fixup matrix. Before the
2494 * scaling is reapplied or removed, the texture matrix has to be reapplied
2496 if(!GL_SUPPORT(ARB_TEXTURE_NON_POWER_OF_TWO
) && sampler
< MAX_TEXTURES
) {
2497 if(stateblock
->textureDimensions
[sampler
] == GL_TEXTURE_2D
||
2498 stateblock
->textureDimensions
[sampler
] == GL_TEXTURE_RECTANGLE_ARB
) {
2499 if(((IWineD3DTextureImpl
*) stateblock
->textures
[sampler
])->baseTexture
.pow2Matrix
[0] != 1.0 ||
2500 ((IWineD3DTextureImpl
*) stateblock
->textures
[sampler
])->baseTexture
.pow2Matrix
[5] != 1.0 ) {
2503 } else if(stateblock
->textureDimensions
[sampler
] == GL_TEXTURE_CUBE_MAP_ARB
) {
2504 if(((IWineD3DCubeTextureImpl
*) stateblock
->textures
[sampler
])->baseTexture
.pow2Matrix
[0] != 1.0) {
2509 if(texIsPow2
|| context
->lastWasPow2Texture
[sampler
]) {
2510 context
->lastWasPow2Texture
[sampler
] = texIsPow2
;
2511 transform_texture(STATE_TRANSFORM(WINED3DTS_TEXTURE0
+ stateblock
->wineD3DDevice
->texUnitMap
[sampler
]), stateblock
, context
);
2515 IWineD3DBaseTexture_PreLoad(stateblock
->textures
[sampler
]);
2516 IWineD3DBaseTexture_ApplyStateChanges(stateblock
->textures
[sampler
], stateblock
->textureState
[sampler
], stateblock
->samplerState
[sampler
]);
2518 if (GL_SUPPORT(EXT_TEXTURE_LOD_BIAS
)) {
2519 tmpvalue
.d
= stateblock
->samplerState
[sampler
][WINED3DSAMP_MIPMAPLODBIAS
];
2520 glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT
,
2521 GL_TEXTURE_LOD_BIAS_EXT
,
2523 checkGLcall("glTexEnvi(GL_TEXTURE_LOD_BIAS_EXT, ...)");
2526 if (stateblock
->wineD3DDevice
->ps_selected_mode
!= SHADER_NONE
&& stateblock
->pixelShader
&&
2527 ((IWineD3DPixelShaderImpl
*)stateblock
->pixelShader
)->baseShader
.function
) {
2528 /* Using a pixel shader? Verify the sampler types */
2530 /* Make sure that the texture dimensions are enabled. I don't have to disable the other
2531 * dimensions because the shader knows from which texture type to sample from. For the sake of
2532 * debugging all dimensions could be enabled and a texture with some ugly pink bound to the unused
2533 * dimensions. This should make wrong sampling sources visible :-)
2535 glEnable(stateblock
->textureDimensions
[sampler
]);
2536 checkGLcall("glEnable(stateblock->textureDimensions[sampler])");
2537 } else if(sampler
< stateblock
->lowest_disabled_stage
) {
2538 if(!isStateDirty(context
, STATE_TEXTURESTAGE(sampler
, WINED3DTSS_COLOROP
))) {
2539 activate_dimensions(sampler
, stateblock
, context
);
2542 if(stateblock
->renderState
[WINED3DRS_COLORKEYENABLE
] && sampler
== 0) {
2543 /* If color keying is enabled update the alpha test, it depends on the existence
2544 * of a color key in stage 0
2546 state_alpha(WINED3DRS_COLORKEYENABLE
, stateblock
, context
);
2549 } else if(mapped_stage
< GL_LIMITS(textures
)) {
2550 if(sampler
< stateblock
->lowest_disabled_stage
) {
2551 /* TODO: What should I do with pixel shaders here ??? */
2552 if(!isStateDirty(context
, STATE_TEXTURESTAGE(sampler
, WINED3DTSS_COLOROP
))) {
2553 activate_dimensions(sampler
, stateblock
, context
);
2556 if(stateblock
->renderState
[WINED3DRS_COLORKEYENABLE
] && sampler
== 0) {
2557 /* If color keying is enabled update the alpha test, it depends on the existence
2558 * of a color key in stage 0
2560 state_alpha(WINED3DRS_COLORKEYENABLE
, stateblock
, context
);
2562 } /* Otherwise tex_colorop disables the stage */
2563 glBindTexture(GL_TEXTURE_2D
, stateblock
->wineD3DDevice
->dummyTextureName
[sampler
]);
2564 checkGLcall("glBindTexture(GL_TEXTURE_2D, stateblock->wineD3DDevice->dummyTextureName[sampler])");
2568 static void pixelshader(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
2569 IWineD3DDeviceImpl
*device
= stateblock
->wineD3DDevice
;
2570 BOOL use_pshader
= use_ps(device
);
2571 BOOL use_vshader
= use_vs(device
);
2572 BOOL update_fog
= FALSE
;
2576 if(!context
->last_was_pshader
) {
2577 /* Former draw without a pixel shader, some samplers
2578 * may be disabled because of WINED3DTSS_COLOROP = WINED3DTOP_DISABLE
2579 * make sure to enable them
2581 for(i
=0; i
< MAX_FRAGMENT_SAMPLERS
; i
++) {
2582 if(!isStateDirty(context
, STATE_SAMPLER(i
))) {
2583 sampler(STATE_SAMPLER(i
), stateblock
, context
);
2588 /* Otherwise all samplers were activated by the code above in earlier draws, or by sampler()
2589 * if a different texture was bound. I don't have to do anything.
2593 /* Compile and bind the shader */
2594 IWineD3DPixelShader_CompileShader(stateblock
->pixelShader
);
2596 /* Disabled the pixel shader - color ops weren't applied
2597 * while it was enabled, so re-apply them.
2599 for(i
=0; i
< MAX_TEXTURES
; i
++) {
2600 if(!isStateDirty(context
, STATE_TEXTURESTAGE(i
, WINED3DTSS_COLOROP
))) {
2601 tex_colorop(STATE_TEXTURESTAGE(i
, WINED3DTSS_COLOROP
), stateblock
, context
);
2604 if(context
->last_was_pshader
)
2608 if(!isStateDirty(context
, StateTable
[STATE_VSHADER
].representative
)) {
2609 device
->shader_backend
->shader_select((IWineD3DDevice
*)stateblock
->wineD3DDevice
, use_pshader
, use_vshader
);
2611 if (!isStateDirty(context
, STATE_VERTEXSHADERCONSTANT
) && (use_vshader
|| use_pshader
)) {
2612 shaderconstant(STATE_VERTEXSHADERCONSTANT
, stateblock
, context
);
2617 state_fog(state
, stateblock
, context
);
2619 context
->last_was_pshader
= use_pshader
;
2622 static void tex_bumpenvmat(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
2623 DWORD stage
= (state
- STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE
;
2625 if(stateblock
->pixelShader
&& stage
!= 0 &&
2626 ((IWineD3DPixelShaderImpl
*) stateblock
->pixelShader
)->baseShader
.reg_maps
.bumpmat
[stage
]) {
2627 /* The pixel shader has to know the bump env matrix. Do a constants update if it isn't scheduled
2630 if(!isStateDirty(context
, STATE_PIXELSHADERCONSTANT
) &&
2631 !isStateDirty(context
, STATE_PIXELSHADER
)) {
2632 shaderconstant(STATE_PIXELSHADERCONSTANT
, stateblock
, context
);
2636 if(GL_SUPPORT(ATI_ENVMAP_BUMPMAP
)) {
2637 if(stage
>= GL_LIMITS(texture_stages
)) {
2638 WARN("Bump env matrix of unsupported stage set\n");
2639 } else if(GL_SUPPORT(ARB_MULTITEXTURE
)) {
2640 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB
+ stage
));
2641 checkGLcall("GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + stage))");
2643 mat
[0][0] = *((float *) &stateblock
->textureState
[stage
][WINED3DTSS_BUMPENVMAT00
]);
2644 mat
[1][0] = *((float *) &stateblock
->textureState
[stage
][WINED3DTSS_BUMPENVMAT01
]);
2645 mat
[0][1] = *((float *) &stateblock
->textureState
[stage
][WINED3DTSS_BUMPENVMAT10
]);
2646 mat
[1][1] = *((float *) &stateblock
->textureState
[stage
][WINED3DTSS_BUMPENVMAT11
]);
2647 GL_EXTCALL(glTexBumpParameterfvATI(GL_BUMP_ROT_MATRIX_ATI
, (float *) mat
));
2648 checkGLcall("glTexBumpParameterfvATI");
2649 } else if(GL_SUPPORT(NV_TEXTURE_SHADER2
)) {
2650 /* Direct3D sets the matrix in the stage reading the perturbation map. The result is used to
2651 * offset the destination stage(always stage + 1 in d3d). In GL_NV_texture_shader, the bump
2652 * map offseting is done in the stage reading the bump mapped texture, and the perturbation
2653 * map is read from a specified source stage(always stage - 1 for d3d). Thus set the matrix
2654 * for stage + 1. Keep the nvrc tex unit mapping in mind too
2656 DWORD mapped_stage
= stateblock
->wineD3DDevice
->texUnitMap
[stage
+ 1];
2658 if(mapped_stage
< GL_LIMITS(textures
)) {
2659 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
2660 checkGLcall("GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage))");
2662 /* We can't just pass a pointer to the stateblock to GL due to the different matrix
2663 * format(column major vs row major)
2665 mat
[0][0] = *((float *) &stateblock
->textureState
[stage
][WINED3DTSS_BUMPENVMAT00
]);
2666 mat
[1][0] = *((float *) &stateblock
->textureState
[stage
][WINED3DTSS_BUMPENVMAT01
]);
2667 mat
[0][1] = *((float *) &stateblock
->textureState
[stage
][WINED3DTSS_BUMPENVMAT10
]);
2668 mat
[1][1] = *((float *) &stateblock
->textureState
[stage
][WINED3DTSS_BUMPENVMAT11
]);
2669 glTexEnvfv(GL_TEXTURE_SHADER_NV
, GL_OFFSET_TEXTURE_MATRIX_NV
, (float *) mat
);
2670 checkGLcall("glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, mat)");
2675 static void transform_world(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
2676 /* This function is called by transform_view below if the view matrix was changed too
2678 * Deliberately no check if the vertex declaration is dirty because the vdecl state
2679 * does not always update the world matrix, only on a switch between transformed
2680 * and untransformed draws. It *may* happen that the world matrix is set 2 times during one
2681 * draw, but that should be rather rare and cheaper in total.
2683 glMatrixMode(GL_MODELVIEW
);
2684 checkGLcall("glMatrixMode");
2686 if(context
->last_was_rhw
) {
2688 checkGLcall("glLoadIdentity()");
2690 /* In the general case, the view matrix is the identity matrix */
2691 if (stateblock
->wineD3DDevice
->view_ident
) {
2692 glLoadMatrixf(&stateblock
->transforms
[WINED3DTS_WORLDMATRIX(0)].u
.m
[0][0]);
2693 checkGLcall("glLoadMatrixf");
2695 glLoadMatrixf(&stateblock
->transforms
[WINED3DTS_VIEW
].u
.m
[0][0]);
2696 checkGLcall("glLoadMatrixf");
2697 glMultMatrixf(&stateblock
->transforms
[WINED3DTS_WORLDMATRIX(0)].u
.m
[0][0]);
2698 checkGLcall("glMultMatrixf");
2703 static void clipplane(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
2704 UINT index
= state
- STATE_CLIPPLANE(0);
2706 if(isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_VIEW
)) || index
>= GL_LIMITS(clipplanes
)) {
2710 /* Clip Plane settings are affected by the model view in OpenGL, the View transform in direct3d */
2711 glMatrixMode(GL_MODELVIEW
);
2713 glLoadMatrixf(&stateblock
->transforms
[WINED3DTS_VIEW
].u
.m
[0][0]);
2715 TRACE("Clipplane [%f,%f,%f,%f]\n",
2716 stateblock
->clipplane
[index
][0],
2717 stateblock
->clipplane
[index
][1],
2718 stateblock
->clipplane
[index
][2],
2719 stateblock
->clipplane
[index
][3]);
2720 glClipPlane(GL_CLIP_PLANE0
+ index
, stateblock
->clipplane
[index
]);
2721 checkGLcall("glClipPlane");
2726 static void transform_worldex(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
2727 UINT matrix
= state
- STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0));
2729 TRACE("Setting world matrix %d\n", matrix
);
2731 if(matrix
>= GL_LIMITS(blends
)) {
2732 WARN("Unsupported blend matrix set\n");
2734 } else if(isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_VIEW
))) {
2738 /* GL_MODELVIEW0_ARB: 0x1700
2739 * GL_MODELVIEW1_ARB: 0x0x850a
2740 * GL_MODELVIEW2_ARB: 0x8722
2741 * GL_MODELVIEW3_ARB: 0x8723
2743 * GL_MODELVIEW31_ARB: 0x873F
2745 if(matrix
== 1) glMat
= GL_MODELVIEW1_ARB
;
2746 else glMat
= GL_MODELVIEW2_ARB
- 2 + matrix
;
2748 glMatrixMode(glMat
);
2749 checkGLcall("glMatrixMode(glMat)");
2751 /* World matrix 0 is multiplied with the view matrix because d3d uses 3 matrices while gl uses only 2. To avoid
2752 * weighting the view matrix incorrectly it has to be multiplied into every gl modelview matrix
2754 if(stateblock
->wineD3DDevice
->view_ident
) {
2755 glLoadMatrixf(&stateblock
->transforms
[WINED3DTS_WORLDMATRIX(matrix
)].u
.m
[0][0]);
2756 checkGLcall("glLoadMatrixf")
2758 glLoadMatrixf(&stateblock
->transforms
[WINED3DTS_VIEW
].u
.m
[0][0]);
2759 checkGLcall("glLoadMatrixf")
2760 glMultMatrixf(&stateblock
->transforms
[WINED3DTS_WORLDMATRIX(matrix
)].u
.m
[0][0]);
2761 checkGLcall("glMultMatrixf")
2765 static void state_vertexblend(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
2766 WINED3DVERTEXBLENDFLAGS val
= stateblock
->renderState
[WINED3DRS_VERTEXBLEND
];
2769 case WINED3DVBF_1WEIGHTS
:
2770 case WINED3DVBF_2WEIGHTS
:
2771 case WINED3DVBF_3WEIGHTS
:
2772 if(GL_SUPPORT(ARB_VERTEX_BLEND
)) {
2773 glEnable(GL_VERTEX_BLEND_ARB
);
2774 checkGLcall("glEnable(GL_VERTEX_BLEND_ARB)");
2776 /* D3D adds one more matrix which has weight (1 - sum(weights)). This is enabled at context
2777 * creation with enabling GL_WEIGHT_SUM_UNITY_ARB.
2779 GL_EXTCALL(glVertexBlendARB(stateblock
->renderState
[WINED3DRS_VERTEXBLEND
] + 1));
2781 if(!stateblock
->wineD3DDevice
->vertexBlendUsed
) {
2783 for(i
= 1; i
< GL_LIMITS(blends
); i
++) {
2784 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(i
)))) {
2785 transform_worldex(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(i
)), stateblock
, context
);
2788 stateblock
->wineD3DDevice
->vertexBlendUsed
= TRUE
;
2791 static BOOL once
= FALSE
;
2794 /* TODO: Implement vertex blending in drawStridedSlow */
2795 FIXME("Vertex blending enabled, but not supported by hardware\n");
2800 case WINED3DVBF_DISABLE
:
2801 case WINED3DVBF_0WEIGHTS
: /* for Indexed vertex blending - not supported */
2802 if(GL_SUPPORT(ARB_VERTEX_BLEND
)) {
2803 glDisable(GL_VERTEX_BLEND_ARB
);
2804 checkGLcall("glDisable(GL_VERTEX_BLEND_ARB)");
2806 TRACE("Vertex blending disabled\n");
2810 case WINED3DVBF_TWEENING
:
2811 /* Just set the vertex weight for weight 0, enable vertex blending and hope the app doesn't have
2812 * vertex weights in the vertices?
2813 * For now we don't report that as supported, so a warn should suffice
2815 WARN("Tweening not supported yet\n");
2820 static void transform_view(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
2823 /* If we are changing the View matrix, reset the light and clipping planes to the new view
2824 * NOTE: We have to reset the positions even if the light/plane is not currently
2825 * enabled, since the call to enable it will not reset the position.
2826 * NOTE2: Apparently texture transforms do NOT need reapplying
2829 PLIGHTINFOEL
*light
= NULL
;
2831 glMatrixMode(GL_MODELVIEW
);
2832 checkGLcall("glMatrixMode(GL_MODELVIEW)");
2833 glLoadMatrixf(&stateblock
->transforms
[WINED3DTS_VIEW
].u
.m
[0][0]);
2834 checkGLcall("glLoadMatrixf(...)");
2836 /* Reset lights. TODO: Call light apply func */
2837 for(k
= 0; k
< stateblock
->wineD3DDevice
->maxConcurrentLights
; k
++) {
2838 light
= stateblock
->activeLights
[k
];
2839 if(!light
) continue;
2840 glLightfv(GL_LIGHT0
+ light
->glIndex
, GL_POSITION
, light
->lightPosn
);
2841 checkGLcall("glLightfv posn");
2842 glLightfv(GL_LIGHT0
+ light
->glIndex
, GL_SPOT_DIRECTION
, light
->lightDirn
);
2843 checkGLcall("glLightfv dirn");
2846 /* Reset Clipping Planes */
2847 for (k
= 0; k
< GL_LIMITS(clipplanes
); k
++) {
2848 if(!isStateDirty(context
, STATE_CLIPPLANE(k
))) {
2849 clipplane(STATE_CLIPPLANE(k
), stateblock
, context
);
2853 if(context
->last_was_rhw
) {
2855 checkGLcall("glLoadIdentity()");
2856 /* No need to update the world matrix, the identity is fine */
2860 /* Call the world matrix state, this will apply the combined WORLD + VIEW matrix
2861 * No need to do it here if the state is scheduled for update.
2863 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)))) {
2864 transform_world(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), stateblock
, context
);
2867 /* Avoid looping over a number of matrices if the app never used the functionality */
2868 if(stateblock
->wineD3DDevice
->vertexBlendUsed
) {
2869 for(k
= 1; k
< GL_LIMITS(blends
); k
++) {
2870 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(k
)))) {
2871 transform_worldex(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(k
)), stateblock
, context
);
2877 static void transform_projection(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
2878 glMatrixMode(GL_PROJECTION
);
2879 checkGLcall("glMatrixMode(GL_PROJECTION)");
2881 checkGLcall("glLoadIdentity");
2883 if(context
->last_was_rhw
) {
2884 double X
, Y
, height
, width
, minZ
, maxZ
;
2886 X
= stateblock
->viewport
.X
;
2887 Y
= stateblock
->viewport
.Y
;
2888 height
= stateblock
->viewport
.Height
;
2889 width
= stateblock
->viewport
.Width
;
2890 minZ
= stateblock
->viewport
.MinZ
;
2891 maxZ
= stateblock
->viewport
.MaxZ
;
2893 if(!stateblock
->wineD3DDevice
->untransformed
) {
2894 /* Transformed vertices are supposed to bypass the whole transform pipeline including
2895 * frustum clipping. This can't be done in opengl, so this code adjusts the Z range to
2896 * suppress depth clipping. This can be done because it is an orthogonal projection and
2897 * the Z coordinate does not affect the size of the primitives. Half Life 1 and Prince of
2898 * Persia 3D need this.
2900 * Note that using minZ and maxZ here doesn't entirely fix the problem, since view frustum
2901 * clipping is still enabled, but it seems to fix it for all apps tested so far. A minor
2902 * problem can be witnessed in half-life 1 engine based games, the weapon is clipped close
2905 * Also note that this breaks z comparison against z values filled in with clear,
2906 * but no app depending on that and disabled clipping has been found yet. Comparing
2907 * primitives against themselves works, so the Z buffer is still intact for normal hidden
2910 * We could disable clipping entirely by setting the near to infinity and far to -infinity,
2911 * but this would break Z buffer operation. Raising the range to something less than
2912 * infinity would help a bit at the cost of Z precision, but it wouldn't eliminate the
2915 TRACE("Calling glOrtho with %f, %f, %f, %f\n", width
, height
, -minZ
, -maxZ
);
2916 if(stateblock
->wineD3DDevice
->render_offscreen
) {
2917 glOrtho(X
, X
+ width
, -Y
, -Y
- height
, -minZ
, -maxZ
);
2919 glOrtho(X
, X
+ width
, Y
+ height
, Y
, -minZ
, -maxZ
);
2922 /* If the app mixes transformed and untransformed primitives we can't use the coordinate system
2923 * trick above because this would mess up transformed and untransformed Z order. Pass the z position
2924 * unmodified to opengl.
2926 * If the app depends on mixed types and disabled clipping we're out of luck without a pipeline
2927 * replacement shader.
2929 TRACE("Calling glOrtho with %f, %f, %f, %f\n", width
, height
, 1.0, -1.0);
2930 if(stateblock
->wineD3DDevice
->render_offscreen
) {
2931 glOrtho(X
, X
+ width
, -Y
, -Y
- height
, 0.0, -1.0);
2933 glOrtho(X
, X
+ width
, Y
+ height
, Y
, 0.0, -1.0);
2936 checkGLcall("glOrtho");
2938 /* Window Coord 0 is the middle of the first pixel, so translate by 1/2 pixels */
2939 glTranslatef(0.5, 0.5, 0);
2940 checkGLcall("glTranslatef(0.5, 0.5, 0)");
2941 /* D3D texture coordinates are flipped compared to OpenGL ones, so
2942 * render everything upside down when rendering offscreen. */
2943 if (stateblock
->wineD3DDevice
->render_offscreen
) {
2944 glScalef(1.0, -1.0, 1.0);
2945 checkGLcall("glScalef");
2948 /* The rule is that the window coordinate 0 does not correspond to the
2949 beginning of the first pixel, but the center of the first pixel.
2950 As a consequence if you want to correctly draw one line exactly from
2951 the left to the right end of the viewport (with all matrices set to
2952 be identity), the x coords of both ends of the line would be not
2953 -1 and 1 respectively but (-1-1/viewport_widh) and (1-1/viewport_width)
2956 1.0 / Width is used because the coord range goes from -1.0 to 1.0, then we
2957 divide by the Width/Height, so we need the half range(1.0) to translate by
2960 The other fun is that d3d's output z range after the transformation is [0;1],
2961 but opengl's is [-1;1]. Since the z buffer is in range [0;1] for both, gl
2962 scales [-1;1] to [0;1]. This would mean that we end up in [0.5;1] and loose a lot
2963 of Z buffer precision and the clear values do not match in the z test. Thus scale
2964 [0;1] to [-1;1], so when gl undoes that we utilize the full z range
2966 glTranslatef(1.0 / stateblock
->viewport
.Width
, -1.0/ stateblock
->viewport
.Height
, -1.0);
2967 checkGLcall("glTranslatef (1.0 / width, -1.0 / height, -1.0)");
2968 if (stateblock
->wineD3DDevice
->render_offscreen
) {
2969 /* D3D texture coordinates are flipped compared to OpenGL ones, so
2970 * render everything upside down when rendering offscreen. */
2971 glScalef(1.0, -1.0, 2.0);
2973 glScalef(1.0, 1.0, 2.0);
2975 checkGLcall("glScalef");
2977 glMultMatrixf(&stateblock
->transforms
[WINED3DTS_PROJECTION
].u
.m
[0][0]);
2978 checkGLcall("glLoadMatrixf");
2982 /* This should match any arrays loaded in loadVertexData.
2983 * stateblock impl is required for GL_SUPPORT
2984 * TODO: Only load / unload arrays if we have to.
2986 static inline void unloadVertexData(IWineD3DStateBlockImpl
*stateblock
) {
2987 glDisableClientState(GL_VERTEX_ARRAY
);
2988 glDisableClientState(GL_NORMAL_ARRAY
);
2989 glDisableClientState(GL_COLOR_ARRAY
);
2990 if (GL_SUPPORT(EXT_SECONDARY_COLOR
)) {
2991 glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT
);
2993 if (GL_SUPPORT(ARB_VERTEX_BLEND
)) {
2994 glDisableClientState(GL_WEIGHT_ARRAY_ARB
);
2995 } else if (GL_SUPPORT(EXT_VERTEX_WEIGHTING
)) {
2996 glDisableClientState(GL_VERTEX_WEIGHT_ARRAY_EXT
);
2998 unloadTexCoords(stateblock
);
3001 /* This should match any arrays loaded in loadNumberedArrays
3002 * TODO: Only load / unload arrays if we have to.
3004 static inline void unloadNumberedArrays(IWineD3DStateBlockImpl
*stateblock
) {
3005 /* disable any attribs (this is the same for both GLSL and ARB modes) */
3009 /* Leave all the attribs disabled */
3010 glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB
, &maxAttribs
);
3011 /* MESA does not support it right not */
3012 if (glGetError() != GL_NO_ERROR
)
3014 for (i
= 0; i
< maxAttribs
; ++i
) {
3015 GL_EXTCALL(glDisableVertexAttribArrayARB(i
));
3016 checkGLcall("glDisableVertexAttribArrayARB(reg)");
3020 static inline void loadNumberedArrays(IWineD3DStateBlockImpl
*stateblock
, WineDirect3DVertexStridedData
*strided
) {
3021 GLint curVBO
= GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT
) ? -1 : 0;
3023 UINT
*offset
= stateblock
->streamOffset
;
3024 IWineD3DVertexBufferImpl
*vb
;
3025 DWORD_PTR shift_index
;
3027 /* Default to no instancing */
3028 stateblock
->wineD3DDevice
->instancedDraw
= FALSE
;
3030 for (i
= 0; i
< MAX_ATTRIBS
; i
++) {
3032 if (!strided
->u
.input
[i
].lpData
&& !strided
->u
.input
[i
].VBO
)
3035 /* Do not load instance data. It will be specified using glTexCoord by drawprim */
3036 if(stateblock
->streamFlags
[strided
->u
.input
[i
].streamNo
] & WINED3DSTREAMSOURCE_INSTANCEDATA
) {
3037 GL_EXTCALL(glDisableVertexAttribArrayARB(i
));
3038 stateblock
->wineD3DDevice
->instancedDraw
= TRUE
;
3042 TRACE_(d3d_shader
)("Loading array %u [VBO=%u]\n", i
, strided
->u
.input
[i
].VBO
);
3044 if(strided
->u
.input
[i
].dwStride
) {
3045 if(curVBO
!= strided
->u
.input
[i
].VBO
) {
3046 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, strided
->u
.input
[i
].VBO
));
3047 checkGLcall("glBindBufferARB");
3048 curVBO
= strided
->u
.input
[i
].VBO
;
3050 vb
= (IWineD3DVertexBufferImpl
*) stateblock
->streamSource
[strided
->u
.input
[i
].streamNo
];
3051 /* Use the VBO to find out if a vertex buffer exists, not the vb pointer. vb can point to a
3052 * user pointer data blob. In that case curVBO will be 0. If there is a vertex buffer but no
3053 * vbo we won't be load converted attributes anyway
3055 if(curVBO
&& vb
->conv_shift
) {
3056 TRACE("Loading attribute from shifted buffer\n");
3057 TRACE("Attrib %d has original stride %d, new stride %d\n", i
, strided
->u
.input
[i
].dwStride
, vb
->conv_stride
);
3058 TRACE("Original offset %p, additional offset 0x%08x\n",strided
->u
.input
[i
].lpData
, vb
->conv_shift
[(DWORD_PTR
) strided
->u
.input
[i
].lpData
]);
3059 TRACE("Opengl type %x\n", WINED3D_ATR_GLTYPE(strided
->u
.input
[i
].dwType
));
3060 shift_index
= ((DWORD_PTR
) strided
->u
.input
[i
].lpData
+ offset
[strided
->u
.input
[i
].streamNo
]);
3061 shift_index
= shift_index
% strided
->u
.input
[i
].dwStride
;
3062 GL_EXTCALL(glVertexAttribPointerARB(i
,
3063 WINED3D_ATR_SIZE(strided
->u
.input
[i
].dwType
),
3064 WINED3D_ATR_GLTYPE(strided
->u
.input
[i
].dwType
),
3065 WINED3D_ATR_NORMALIZED(strided
->u
.input
[i
].dwType
),
3068 strided
->u
.input
[i
].lpData
+ vb
->conv_shift
[shift_index
] +
3069 stateblock
->loadBaseVertexIndex
* strided
->u
.input
[i
].dwStride
+
3070 offset
[strided
->u
.input
[i
].streamNo
]));
3073 GL_EXTCALL(glVertexAttribPointerARB(i
,
3074 WINED3D_ATR_SIZE(strided
->u
.input
[i
].dwType
),
3075 WINED3D_ATR_GLTYPE(strided
->u
.input
[i
].dwType
),
3076 WINED3D_ATR_NORMALIZED(strided
->u
.input
[i
].dwType
),
3077 strided
->u
.input
[i
].dwStride
,
3079 strided
->u
.input
[i
].lpData
+
3080 stateblock
->loadBaseVertexIndex
* strided
->u
.input
[i
].dwStride
+
3081 offset
[strided
->u
.input
[i
].streamNo
]) );
3083 GL_EXTCALL(glEnableVertexAttribArrayARB(i
));
3085 /* Stride = 0 means always the same values. glVertexAttribPointerARB doesn't do that. Instead disable the pointer and
3086 * set up the attribute statically. But we have to figure out the system memory address.
3088 BYTE
*ptr
= strided
->u
.input
[i
].lpData
+ offset
[strided
->u
.input
[i
].streamNo
];
3089 if(strided
->u
.input
[i
].VBO
) {
3090 vb
= (IWineD3DVertexBufferImpl
*) stateblock
->streamSource
[strided
->u
.input
[i
].streamNo
];
3091 ptr
+= (long) vb
->resource
.allocatedMemory
;
3093 GL_EXTCALL(glDisableVertexAttribArrayARB(i
));
3095 switch(strided
->u
.input
[i
].dwType
) {
3096 case WINED3DDECLTYPE_FLOAT1
:
3097 GL_EXTCALL(glVertexAttrib1fvARB(i
, (float *) ptr
));
3099 case WINED3DDECLTYPE_FLOAT2
:
3100 GL_EXTCALL(glVertexAttrib2fvARB(i
, (float *) ptr
));
3102 case WINED3DDECLTYPE_FLOAT3
:
3103 GL_EXTCALL(glVertexAttrib3fvARB(i
, (float *) ptr
));
3105 case WINED3DDECLTYPE_FLOAT4
:
3106 GL_EXTCALL(glVertexAttrib4fvARB(i
, (float *) ptr
));
3109 case WINED3DDECLTYPE_UBYTE4
:
3110 GL_EXTCALL(glVertexAttrib4NubvARB(i
, ptr
));
3112 case WINED3DDECLTYPE_UBYTE4N
:
3113 case WINED3DDECLTYPE_D3DCOLOR
:
3114 GL_EXTCALL(glVertexAttrib4NubvARB(i
, ptr
));
3117 case WINED3DDECLTYPE_SHORT2
:
3118 GL_EXTCALL(glVertexAttrib4svARB(i
, (GLshort
*) ptr
));
3120 case WINED3DDECLTYPE_SHORT4
:
3121 GL_EXTCALL(glVertexAttrib4svARB(i
, (GLshort
*) ptr
));
3124 case WINED3DDECLTYPE_SHORT2N
:
3126 GLshort s
[4] = {((short *) ptr
)[0], ((short *) ptr
)[1], 0, 1};
3127 GL_EXTCALL(glVertexAttrib4NsvARB(i
, s
));
3130 case WINED3DDECLTYPE_USHORT2N
:
3132 GLushort s
[4] = {((unsigned short *) ptr
)[0], ((unsigned short *) ptr
)[1], 0, 1};
3133 GL_EXTCALL(glVertexAttrib4NusvARB(i
, s
));
3136 case WINED3DDECLTYPE_SHORT4N
:
3137 GL_EXTCALL(glVertexAttrib4NsvARB(i
, (GLshort
*) ptr
));
3139 case WINED3DDECLTYPE_USHORT4N
:
3140 GL_EXTCALL(glVertexAttrib4NusvARB(i
, (GLushort
*) ptr
));
3143 case WINED3DDECLTYPE_UDEC3
:
3144 FIXME("Unsure about WINED3DDECLTYPE_UDEC3\n");
3145 /*glVertexAttrib3usvARB(i, (GLushort *) ptr); Does not exist */
3147 case WINED3DDECLTYPE_DEC3N
:
3148 FIXME("Unsure about WINED3DDECLTYPE_DEC3N\n");
3149 /*glVertexAttrib3NusvARB(i, (GLushort *) ptr); Does not exist */
3152 case WINED3DDECLTYPE_FLOAT16_2
:
3153 /* Are those 16 bit floats. C doesn't have a 16 bit float type. I could read the single bits and calculate a 4
3154 * byte float according to the IEEE standard
3156 FIXME("Unsupported WINED3DDECLTYPE_FLOAT16_2\n");
3158 case WINED3DDECLTYPE_FLOAT16_4
:
3159 FIXME("Unsupported WINED3DDECLTYPE_FLOAT16_4\n");
3162 case WINED3DDECLTYPE_UNUSED
:
3164 ERR("Unexpected declaration in stride 0 attributes\n");
3170 checkGLcall("Loading numbered arrays");
3173 /* Used from 2 different functions, and too big to justify making it inlined */
3174 static void loadVertexData(IWineD3DStateBlockImpl
*stateblock
, WineDirect3DVertexStridedData
*sd
) {
3175 UINT
*offset
= stateblock
->streamOffset
;
3176 GLint curVBO
= GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT
) ? -1 : 0;
3178 TRACE("Using fast vertex array code\n");
3180 /* This is fixed function pipeline only, and the fixed function pipeline doesn't do instancing */
3181 stateblock
->wineD3DDevice
->instancedDraw
= FALSE
;
3183 /* Blend Data ---------------------------------------------- */
3184 if( (sd
->u
.s
.blendWeights
.lpData
) || (sd
->u
.s
.blendWeights
.VBO
) ||
3185 (sd
->u
.s
.blendMatrixIndices
.lpData
) || (sd
->u
.s
.blendMatrixIndices
.VBO
) ) {
3187 if (GL_SUPPORT(ARB_VERTEX_BLEND
)) {
3188 TRACE("Blend %d %p %d\n", WINED3D_ATR_SIZE(sd
->u
.s
.blendWeights
.dwType
),
3189 sd
->u
.s
.blendWeights
.lpData
+ stateblock
->loadBaseVertexIndex
* sd
->u
.s
.blendWeights
.dwStride
, sd
->u
.s
.blendWeights
.dwStride
+ offset
[sd
->u
.s
.blendWeights
.streamNo
]);
3191 glEnableClientState(GL_WEIGHT_ARRAY_ARB
);
3192 checkGLcall("glEnableClientState(GL_WEIGHT_ARRAY_ARB)");
3194 GL_EXTCALL(glVertexBlendARB(WINED3D_ATR_SIZE(sd
->u
.s
.blendWeights
.dwType
) + 1));
3196 VTRACE(("glWeightPointerARB(%d, GL_FLOAT, %d, %p)\n",
3197 WINED3D_ATR_SIZE(sd
->u
.s
.blendWeights
.dwType
) ,
3198 sd
->u
.s
.blendWeights
.dwStride
,
3199 sd
->u
.s
.blendWeights
.lpData
+ stateblock
->loadBaseVertexIndex
* sd
->u
.s
.blendWeights
.dwStride
+ offset
[sd
->u
.s
.blendWeights
.streamNo
]));
3201 if(curVBO
!= sd
->u
.s
.blendWeights
.VBO
) {
3202 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, sd
->u
.s
.blendWeights
.VBO
));
3203 checkGLcall("glBindBufferARB");
3204 curVBO
= sd
->u
.s
.blendWeights
.VBO
;
3207 GL_EXTCALL(glWeightPointerARB
)(
3208 WINED3D_ATR_SIZE(sd
->u
.s
.blendWeights
.dwType
),
3209 WINED3D_ATR_GLTYPE(sd
->u
.s
.blendWeights
.dwType
),
3210 sd
->u
.s
.blendWeights
.dwStride
,
3211 sd
->u
.s
.blendWeights
.lpData
+ stateblock
->loadBaseVertexIndex
* sd
->u
.s
.blendWeights
.dwStride
+ offset
[sd
->u
.s
.blendWeights
.streamNo
]);
3213 checkGLcall("glWeightPointerARB");
3215 if((sd
->u
.s
.blendMatrixIndices
.lpData
) || (sd
->u
.s
.blendMatrixIndices
.VBO
)){
3216 static BOOL showfixme
= TRUE
;
3218 FIXME("blendMatrixIndices support\n");
3222 } else if (GL_SUPPORT(EXT_VERTEX_WEIGHTING
)) {
3223 /* FIXME("TODO\n");*/
3226 GL_EXTCALL(glVertexWeightPointerEXT
)(
3227 WINED3D_ATR_SIZE(sd
->u
.s
.blendWeights
.dwType
),
3228 WINED3D_ATR_GLTYPE(sd
->u
.s
.blendWeights
.dwType
),
3229 sd
->u
.s
.blendWeights
.dwStride
,
3230 sd
->u
.s
.blendWeights
.lpData
+ stateblock
->loadBaseVertexIndex
* sd
->u
.s
.blendWeights
.dwStride
);
3231 checkGLcall("glVertexWeightPointerEXT(numBlends, ...)");
3232 glEnableClientState(GL_VERTEX_WEIGHT_ARRAY_EXT
);
3233 checkGLcall("glEnableClientState(GL_VERTEX_WEIGHT_ARRAY_EXT)");
3237 /* TODO: support blends in drawStridedSlow
3238 * No need to write a FIXME here, this is done after the general vertex decl decoding
3240 WARN("unsupported blending in openGl\n");
3243 if (GL_SUPPORT(ARB_VERTEX_BLEND
)) {
3244 static const GLbyte one
= 1;
3245 GL_EXTCALL(glWeightbvARB(1, &one
));
3246 checkGLcall("glWeightivARB(GL_LIMITS(blends), weights)");
3250 #if 0 /* FOG ----------------------------------------------*/
3251 if (sd
->u
.s
.fog
.lpData
|| sd
->u
.s
.fog
.VBO
) {
3253 if (GL_SUPPORT(EXT_FOG_COORD
) {
3254 glEnableClientState(GL_FOG_COORDINATE_EXT
);
3255 (GL_EXTCALL
)(FogCoordPointerEXT
)(
3256 WINED3D_ATR_GLTYPE(sd
->u
.s
.fog
.dwType
),
3257 sd
->u
.s
.fog
.dwStride
,
3258 sd
->u
.s
.fog
.lpData
+ stateblock
->loadBaseVertexIndex
* sd
->u
.s
.fog
.dwStride
);
3260 /* don't bother falling back to 'slow' as we don't support software FOG yet. */
3261 /* FIXME: fixme once */
3262 TRACE("Hardware support for FOG is not avaiable, FOG disabled.\n");
3265 if (GL_SUPPRT(EXT_FOR_COORD
) {
3266 /* make sure fog is disabled */
3267 glDisableClientState(GL_FOG_COORDINATE_EXT
);
3272 #if 0 /* tangents ----------------------------------------------*/
3273 if (sd
->u
.s
.tangent
.lpData
|| sd
->u
.s
.tangent
.VBO
||
3274 sd
->u
.s
.binormal
.lpData
|| sd
->u
.s
.binormal
.VBO
) {
3276 if (GL_SUPPORT(EXT_COORDINATE_FRAME
) {
3277 if (sd
->u
.s
.tangent
.lpData
|| sd
->u
.s
.tangent
.VBO
) {
3278 glEnable(GL_TANGENT_ARRAY_EXT
);
3279 (GL_EXTCALL
)(TangentPointerEXT
)(
3280 WINED3D_ATR_GLTYPE(sd
->u
.s
.tangent
.dwType
),
3281 sd
->u
.s
.tangent
.dwStride
,
3282 sd
->u
.s
.tangent
.lpData
+ stateblock
->loadBaseVertexIndex
* sd
->u
.s
.tangent
.dwStride
);
3284 glDisable(GL_TANGENT_ARRAY_EXT
);
3286 if (sd
->u
.s
.binormal
.lpData
|| sd
->u
.s
.binormal
.VBO
) {
3287 glEnable(GL_BINORMAL_ARRAY_EXT
);
3288 (GL_EXTCALL
)(BinormalPointerEXT
)(
3289 WINED3D_ATR_GLTYPE(sd
->u
.s
.binormal
.dwType
),
3290 sd
->u
.s
.binormal
.dwStride
,
3291 sd
->u
.s
.binormal
.lpData
+ stateblock
->loadBaseVertexIndex
* sd
->u
.s
.binormal
.dwStride
);
3293 glDisable(GL_BINORMAL_ARRAY_EXT
);
3297 /* don't bother falling back to 'slow' as we don't support software tangents and binormals yet . */
3298 /* FIXME: fixme once */
3299 TRACE("Hardware support for tangents and binormals is not avaiable, tangents and binormals disabled.\n");
3302 if (GL_SUPPORT(EXT_COORDINATE_FRAME
) {
3303 /* make sure fog is disabled */
3304 glDisable(GL_TANGENT_ARRAY_EXT
);
3305 glDisable(GL_BINORMAL_ARRAY_EXT
);
3310 /* Point Size ----------------------------------------------*/
3311 if (sd
->u
.s
.pSize
.lpData
|| sd
->u
.s
.pSize
.VBO
) {
3313 /* no such functionality in the fixed function GL pipeline */
3314 TRACE("Cannot change ptSize here in openGl\n");
3315 /* TODO: Implement this function in using shaders if they are available */
3319 /* Vertex Pointers -----------------------------------------*/
3320 if (sd
->u
.s
.position
.lpData
!= NULL
|| sd
->u
.s
.position
.VBO
!= 0) {
3321 /* Note dwType == float3 or float4 == 2 or 3 */
3322 VTRACE(("glVertexPointer(%d, GL_FLOAT, %d, %p)\n",
3323 sd
->u
.s
.position
.dwStride
,
3324 sd
->u
.s
.position
.dwType
+ 1,
3325 sd
->u
.s
.position
.lpData
));
3327 if(curVBO
!= sd
->u
.s
.position
.VBO
) {
3328 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, sd
->u
.s
.position
.VBO
));
3329 checkGLcall("glBindBufferARB");
3330 curVBO
= sd
->u
.s
.position
.VBO
;
3333 /* min(WINED3D_ATR_SIZE(position),3) to Disable RHW mode as 'w' coord
3334 handling for rhw mode should not impact screen position whereas in GL it does.
3335 This may result in very slightly distorted textures in rhw mode.
3336 There's always the other option of fixing the view matrix to
3337 prevent w from having any effect.
3339 This only applies to user pointer sources, in VBOs the vertices are fixed up
3341 if(sd
->u
.s
.position
.VBO
== 0) {
3342 glVertexPointer(3 /* min(WINED3D_ATR_SIZE(sd->u.s.position.dwType),3) */,
3343 WINED3D_ATR_GLTYPE(sd
->u
.s
.position
.dwType
),
3344 sd
->u
.s
.position
.dwStride
, sd
->u
.s
.position
.lpData
+ stateblock
->loadBaseVertexIndex
* sd
->u
.s
.position
.dwStride
+ offset
[sd
->u
.s
.position
.streamNo
]);
3347 WINED3D_ATR_SIZE(sd
->u
.s
.position
.dwType
),
3348 WINED3D_ATR_GLTYPE(sd
->u
.s
.position
.dwType
),
3349 sd
->u
.s
.position
.dwStride
, sd
->u
.s
.position
.lpData
+ stateblock
->loadBaseVertexIndex
* sd
->u
.s
.position
.dwStride
+ offset
[sd
->u
.s
.position
.streamNo
]);
3351 checkGLcall("glVertexPointer(...)");
3352 glEnableClientState(GL_VERTEX_ARRAY
);
3353 checkGLcall("glEnableClientState(GL_VERTEX_ARRAY)");
3356 /* Normals -------------------------------------------------*/
3357 if (sd
->u
.s
.normal
.lpData
|| sd
->u
.s
.normal
.VBO
) {
3358 /* Note dwType == float3 or float4 == 2 or 3 */
3359 VTRACE(("glNormalPointer(GL_FLOAT, %d, %p)\n",
3360 sd
->u
.s
.normal
.dwStride
,
3361 sd
->u
.s
.normal
.lpData
));
3362 if(curVBO
!= sd
->u
.s
.normal
.VBO
) {
3363 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, sd
->u
.s
.normal
.VBO
));
3364 checkGLcall("glBindBufferARB");
3365 curVBO
= sd
->u
.s
.normal
.VBO
;
3368 WINED3D_ATR_GLTYPE(sd
->u
.s
.normal
.dwType
),
3369 sd
->u
.s
.normal
.dwStride
,
3370 sd
->u
.s
.normal
.lpData
+ stateblock
->loadBaseVertexIndex
* sd
->u
.s
.normal
.dwStride
+ offset
[sd
->u
.s
.normal
.streamNo
]);
3371 checkGLcall("glNormalPointer(...)");
3372 glEnableClientState(GL_NORMAL_ARRAY
);
3373 checkGLcall("glEnableClientState(GL_NORMAL_ARRAY)");
3376 glNormal3f(0, 0, 0);
3377 checkGLcall("glNormal3f(0, 0, 0)");
3380 /* Diffuse Colour --------------------------------------------*/
3381 /* WARNING: Data here MUST be in RGBA format, so cannot */
3382 /* go directly into fast mode from app pgm, because */
3383 /* directx requires data in BGRA format. */
3384 /* currently fixupVertices swizzles the format, but this isn't*/
3385 /* very practical when using VBOS */
3386 /* NOTE: Unless we write a vertex shader to swizzle the colour*/
3387 /* , or the user doesn't care and wants the speed advantage */
3389 if (sd
->u
.s
.diffuse
.lpData
|| sd
->u
.s
.diffuse
.VBO
) {
3390 /* Note dwType == float3 or float4 == 2 or 3 */
3391 VTRACE(("glColorPointer(4, GL_UNSIGNED_BYTE, %d, %p)\n",
3392 sd
->u
.s
.diffuse
.dwStride
,
3393 sd
->u
.s
.diffuse
.lpData
));
3395 if(curVBO
!= sd
->u
.s
.diffuse
.VBO
) {
3396 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, sd
->u
.s
.diffuse
.VBO
));
3397 checkGLcall("glBindBufferARB");
3398 curVBO
= sd
->u
.s
.diffuse
.VBO
;
3401 glColorPointer(WINED3D_ATR_SIZE(sd
->u
.s
.diffuse
.dwType
),
3402 WINED3D_ATR_GLTYPE(sd
->u
.s
.diffuse
.dwType
),
3403 sd
->u
.s
.diffuse
.dwStride
,
3404 sd
->u
.s
.diffuse
.lpData
+ stateblock
->loadBaseVertexIndex
* sd
->u
.s
.diffuse
.dwStride
+ offset
[sd
->u
.s
.diffuse
.streamNo
]);
3405 checkGLcall("glColorPointer(4, GL_UNSIGNED_BYTE, ...)");
3406 glEnableClientState(GL_COLOR_ARRAY
);
3407 checkGLcall("glEnableClientState(GL_COLOR_ARRAY)");
3410 glColor4f(1.0f
, 1.0f
, 1.0f
, 1.0f
);
3411 checkGLcall("glColor4f(1, 1, 1, 1)");
3414 /* Specular Colour ------------------------------------------*/
3415 if (sd
->u
.s
.specular
.lpData
|| sd
->u
.s
.specular
.VBO
) {
3416 TRACE("setting specular colour\n");
3417 /* Note dwType == float3 or float4 == 2 or 3 */
3418 VTRACE(("glSecondaryColorPointer(4, GL_UNSIGNED_BYTE, %d, %p)\n",
3419 sd
->u
.s
.specular
.dwStride
,
3420 sd
->u
.s
.specular
.lpData
));
3421 if (GL_SUPPORT(EXT_SECONDARY_COLOR
)) {
3422 if(curVBO
!= sd
->u
.s
.specular
.VBO
) {
3423 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, sd
->u
.s
.specular
.VBO
));
3424 checkGLcall("glBindBufferARB");
3425 curVBO
= sd
->u
.s
.specular
.VBO
;
3427 GL_EXTCALL(glSecondaryColorPointerEXT
)(WINED3D_ATR_SIZE(sd
->u
.s
.specular
.dwType
),
3428 WINED3D_ATR_GLTYPE(sd
->u
.s
.specular
.dwType
),
3429 sd
->u
.s
.specular
.dwStride
,
3430 sd
->u
.s
.specular
.lpData
+ stateblock
->loadBaseVertexIndex
* sd
->u
.s
.specular
.dwStride
+ offset
[sd
->u
.s
.specular
.streamNo
]);
3431 vcheckGLcall("glSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, ...)");
3432 glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT
);
3433 vcheckGLcall("glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
3436 /* Missing specular color is not critical, no warnings */
3437 VTRACE(("Specular colour is not supported in this GL implementation\n"));
3441 if (GL_SUPPORT(EXT_SECONDARY_COLOR
)) {
3442 GL_EXTCALL(glSecondaryColor3fEXT
)(0, 0, 0);
3443 checkGLcall("glSecondaryColor3fEXT(0, 0, 0)");
3446 /* Missing specular color is not critical, no warnings */
3447 VTRACE(("Specular colour is not supported in this GL implementation\n"));
3451 /* Texture coords -------------------------------------------*/
3452 loadTexCoords(stateblock
, sd
, &curVBO
);
3455 static inline void drawPrimitiveTraceDataLocations(
3456 WineDirect3DVertexStridedData
*dataLocations
) {
3458 /* Dump out what parts we have supplied */
3459 TRACE("Strided Data:\n");
3460 TRACE_STRIDED((dataLocations
), position
);
3461 TRACE_STRIDED((dataLocations
), blendWeights
);
3462 TRACE_STRIDED((dataLocations
), blendMatrixIndices
);
3463 TRACE_STRIDED((dataLocations
), normal
);
3464 TRACE_STRIDED((dataLocations
), pSize
);
3465 TRACE_STRIDED((dataLocations
), diffuse
);
3466 TRACE_STRIDED((dataLocations
), specular
);
3467 TRACE_STRIDED((dataLocations
), texCoords
[0]);
3468 TRACE_STRIDED((dataLocations
), texCoords
[1]);
3469 TRACE_STRIDED((dataLocations
), texCoords
[2]);
3470 TRACE_STRIDED((dataLocations
), texCoords
[3]);
3471 TRACE_STRIDED((dataLocations
), texCoords
[4]);
3472 TRACE_STRIDED((dataLocations
), texCoords
[5]);
3473 TRACE_STRIDED((dataLocations
), texCoords
[6]);
3474 TRACE_STRIDED((dataLocations
), texCoords
[7]);
3475 TRACE_STRIDED((dataLocations
), position2
);
3476 TRACE_STRIDED((dataLocations
), normal2
);
3477 TRACE_STRIDED((dataLocations
), tangent
);
3478 TRACE_STRIDED((dataLocations
), binormal
);
3479 TRACE_STRIDED((dataLocations
), tessFactor
);
3480 TRACE_STRIDED((dataLocations
), fog
);
3481 TRACE_STRIDED((dataLocations
), depth
);
3482 TRACE_STRIDED((dataLocations
), sample
);
3487 /* Helper for vertexdeclaration() */
3488 static inline void handleStreams(IWineD3DStateBlockImpl
*stateblock
, BOOL useVertexShaderFunction
, WineD3DContext
*context
) {
3489 IWineD3DDeviceImpl
*device
= stateblock
->wineD3DDevice
;
3491 WineDirect3DVertexStridedData
*dataLocations
= &device
->strided_streams
;
3493 if(device
->up_strided
) {
3494 /* Note: this is a ddraw fixed-function code path */
3495 TRACE("================ Strided Input ===================\n");
3496 memcpy(dataLocations
, device
->up_strided
, sizeof(*dataLocations
));
3499 drawPrimitiveTraceDataLocations(dataLocations
);
3502 /* Note: This is a fixed function or shader codepath.
3503 * This means it must handle both types of strided data.
3504 * Shaders must go through here to zero the strided data, even if they
3505 * don't set any declaration at all
3507 TRACE("================ Vertex Declaration ===================\n");
3508 memset(dataLocations
, 0, sizeof(*dataLocations
));
3509 primitiveDeclarationConvertToStridedData((IWineD3DDevice
*) device
,
3510 useVertexShaderFunction
, dataLocations
, &fixup
);
3513 if (dataLocations
->u
.s
.position_transformed
) {
3514 useVertexShaderFunction
= FALSE
;
3517 /* Unload the old arrays before loading the new ones to get old junk out */
3518 if(context
->numberedArraysLoaded
) {
3519 unloadNumberedArrays(stateblock
);
3520 context
->numberedArraysLoaded
= FALSE
;
3522 if(context
->namedArraysLoaded
) {
3523 unloadVertexData(stateblock
);
3524 context
->namedArraysLoaded
= FALSE
;
3527 if(useVertexShaderFunction
) {
3528 if(((IWineD3DVertexDeclarationImpl
*) stateblock
->vertexDecl
)->half_float_conv_needed
&& !fixup
) {
3529 TRACE("Using drawStridedSlow with vertex shaders for FLOAT16 conversion\n");
3530 device
->useDrawStridedSlow
= TRUE
;
3531 context
->numberedArraysLoaded
= FALSE
;
3533 TRACE("Loading numbered arrays\n");
3534 loadNumberedArrays(stateblock
, dataLocations
);
3535 device
->useDrawStridedSlow
= FALSE
;
3536 context
->numberedArraysLoaded
= TRUE
;
3539 (dataLocations
->u
.s
.pSize
.lpData
== NULL
&&
3540 dataLocations
->u
.s
.diffuse
.lpData
== NULL
&&
3541 dataLocations
->u
.s
.specular
.lpData
== NULL
)) {
3542 /* Load the vertex data using named arrays */
3543 TRACE("Loading vertex data\n");
3544 loadVertexData(stateblock
, dataLocations
);
3545 device
->useDrawStridedSlow
= FALSE
;
3546 context
->namedArraysLoaded
= TRUE
;
3548 TRACE("Not loading vertex data\n");
3549 device
->useDrawStridedSlow
= TRUE
;
3552 /* Generate some fixme's if unsupported functionality is being used */
3553 #define BUFFER_OR_DATA(_attribute) dataLocations->u.s._attribute.lpData
3554 /* TODO: Either support missing functionality in fixupVertices or by creating a shader to replace the pipeline. */
3555 if (!useVertexShaderFunction
&& (BUFFER_OR_DATA(position2
) || BUFFER_OR_DATA(normal2
))) {
3556 FIXME("Tweening is only valid with vertex shaders\n");
3558 if (!useVertexShaderFunction
&& (BUFFER_OR_DATA(tangent
) || BUFFER_OR_DATA(binormal
))) {
3559 FIXME("Tangent and binormal bump mapping is only valid with vertex shaders\n");
3561 if (!useVertexShaderFunction
&& (BUFFER_OR_DATA(tessFactor
) || BUFFER_OR_DATA(fog
) || BUFFER_OR_DATA(depth
) || BUFFER_OR_DATA(sample
))) {
3562 FIXME("Extended attributes are only valid with vertex shaders\n");
3564 #undef BUFFER_OR_DATA
3567 static void vertexdeclaration(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
3568 BOOL useVertexShaderFunction
= FALSE
, updateFog
= FALSE
;
3569 BOOL usePixelShaderFunction
= stateblock
->wineD3DDevice
->ps_selected_mode
!= SHADER_NONE
&& stateblock
->pixelShader
3570 && ((IWineD3DPixelShaderImpl
*)stateblock
->pixelShader
)->baseShader
.function
;
3572 /* Some stuff is in the device until we have per context tracking */
3573 IWineD3DDeviceImpl
*device
= stateblock
->wineD3DDevice
;
3574 BOOL wasrhw
= context
->last_was_rhw
;
3576 /* Shaders can be implemented using ARB_PROGRAM, GLSL, or software -
3577 * here simply check whether a shader was set, or the user disabled shaders
3579 if (device
->vs_selected_mode
!= SHADER_NONE
&& stateblock
->vertexShader
&&
3580 ((IWineD3DVertexShaderImpl
*)stateblock
->vertexShader
)->baseShader
.function
!= NULL
) {
3581 useVertexShaderFunction
= TRUE
;
3583 if(((IWineD3DVertexShaderImpl
*)stateblock
->vertexShader
)->baseShader
.reg_maps
.fog
!= context
->last_was_foggy_shader
) {
3586 } else if(context
->last_was_foggy_shader
) {
3590 handleStreams(stateblock
, useVertexShaderFunction
, context
);
3592 transformed
= device
->strided_streams
.u
.s
.position_transformed
;
3593 if (transformed
) useVertexShaderFunction
= FALSE
;
3595 if(transformed
!= context
->last_was_rhw
&& !useVertexShaderFunction
) {
3599 /* Reapply lighting if it is not scheduled for reapplication already */
3600 if(!isStateDirty(context
, STATE_RENDER(WINED3DRS_LIGHTING
))) {
3601 state_lighting(STATE_RENDER(WINED3DRS_LIGHTING
), stateblock
, context
);
3605 context
->last_was_rhw
= TRUE
;
3608 /* Untransformed, so relies on the view and projection matrices */
3609 context
->last_was_rhw
= FALSE
;
3610 /* This turns off the Z scale trick to 'disable' viewport frustum clipping in rhw mode*/
3611 device
->untransformed
= TRUE
;
3613 /* Todo for sw shaders: Vertex Shader output is already transformed, so set up identity matrices
3614 * Not needed as long as only hw shaders are supported
3617 /* This sets the shader output position correction constants.
3618 * TODO: Move to the viewport state
3620 if (useVertexShaderFunction
) {
3621 device
->posFixup
[1] = device
->render_offscreen
? -1.0 : 1.0;
3622 device
->posFixup
[3] = -device
->posFixup
[1] / stateblock
->viewport
.Height
;
3626 /* Don't have to apply the matrices when vertex shaders are used. When vshaders are turned
3627 * off this function will be called again anyway to make sure they're properly set
3629 if(!useVertexShaderFunction
) {
3630 /* TODO: Move this mainly to the viewport state and only apply when the vp has changed
3631 * or transformed / untransformed was switched
3633 if(wasrhw
!= context
->last_was_rhw
&&
3634 !isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_PROJECTION
)) &&
3635 !isStateDirty(context
, STATE_VIEWPORT
)) {
3636 transform_projection(STATE_TRANSFORM(WINED3DTS_PROJECTION
), stateblock
, context
);
3638 /* World matrix needs reapplication here only if we're switching between rhw and non-rhw
3641 * If a vertex shader is used, the world matrix changed and then vertex shader unbound
3642 * this check will fail and the matrix not applied again. This is OK because a simple
3643 * world matrix change reapplies the matrix - These checks here are only to satisfy the
3644 * needs of the vertex declaration.
3646 * World and view matrix go into the same gl matrix, so only apply them when neither is
3649 if(transformed
!= wasrhw
&&
3650 !isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0))) &&
3651 !isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_VIEW
))) {
3652 transform_world(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), stateblock
, context
);
3655 if(!isStateDirty(context
, STATE_RENDER(WINED3DRS_COLORVERTEX
))) {
3656 state_colormat(STATE_RENDER(WINED3DRS_COLORVERTEX
), stateblock
, context
);
3659 if(context
->last_was_vshader
&& !isStateDirty(context
, STATE_RENDER(WINED3DRS_CLIPPLANEENABLE
))) {
3660 state_clipping(STATE_RENDER(WINED3DRS_CLIPPLANEENABLE
), stateblock
, context
);
3662 if(!isStateDirty(context
, STATE_RENDER(WINED3DRS_NORMALIZENORMALS
))) {
3663 state_normalize(STATE_RENDER(WINED3DRS_NORMALIZENORMALS
), stateblock
, context
);
3666 /* We compile the shader here because we need the vertex declaration
3667 * in order to determine if we need to do any swizzling for D3DCOLOR
3668 * registers. If the shader is already compiled this call will do nothing. */
3669 IWineD3DVertexShader_CompileShader(stateblock
->vertexShader
);
3671 if(!context
->last_was_vshader
) {
3673 static BOOL warned
= FALSE
;
3674 /* Disable all clip planes to get defined results on all drivers. See comment in the
3675 * state_clipping state handler
3677 for(i
= 0; i
< GL_LIMITS(clipplanes
); i
++) {
3678 glDisable(GL_CLIP_PLANE0
+ i
);
3679 checkGLcall("glDisable(GL_CLIP_PLANE0 + i)");
3682 if(!warned
&& stateblock
->renderState
[WINED3DRS_CLIPPLANEENABLE
]) {
3683 FIXME("Clipping not supported with vertex shaders\n");
3687 /* Apply the transform matrices when switching from rhw drawing to vertex shaders. Vertex
3688 * shaders themselves do not need it, but the matrices are not reapplied automatically when
3689 * switching back from vertex shaders to fixed function processing. So make sure we leave the
3690 * fixed function vertex processing states back in a sane state before switching to shaders
3692 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_PROJECTION
))) {
3693 transform_projection(STATE_TRANSFORM(WINED3DTS_PROJECTION
), stateblock
, context
);
3695 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)))) {
3696 transform_world(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), stateblock
, context
);
3702 /* Vertex and pixel shaders are applied together for now, so let the last dirty state do the
3705 if (!isStateDirty(context
, STATE_PIXELSHADER
)) {
3706 device
->shader_backend
->shader_select((IWineD3DDevice
*)device
, usePixelShaderFunction
, useVertexShaderFunction
);
3708 if (!isStateDirty(context
, STATE_VERTEXSHADERCONSTANT
) && (useVertexShaderFunction
|| usePixelShaderFunction
)) {
3709 shaderconstant(STATE_VERTEXSHADERCONSTANT
, stateblock
, context
);
3713 context
->last_was_vshader
= useVertexShaderFunction
;
3716 state_fog(STATE_RENDER(WINED3DRS_FOGENABLE
), stateblock
, context
);
3718 if(!useVertexShaderFunction
) {
3720 for(i
= 0; i
< MAX_TEXTURES
; i
++) {
3721 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_TEXTURE0
+ i
))) {
3722 transform_texture(STATE_TRANSFORM(WINED3DTS_TEXTURE0
+ i
), stateblock
, context
);
3728 static void viewport(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
3730 IWineD3DSurfaceImpl
*target
;
3732 glDepthRange(stateblock
->viewport
.MinZ
, stateblock
->viewport
.MaxZ
);
3733 checkGLcall("glDepthRange");
3734 /* Note: GL requires lower left, DirectX supplies upper left. This is reversed when using offscreen rendering
3736 if(stateblock
->wineD3DDevice
->render_offscreen
) {
3737 glViewport(stateblock
->viewport
.X
,
3738 stateblock
->viewport
.Y
,
3739 stateblock
->viewport
.Width
, stateblock
->viewport
.Height
);
3741 target
= (IWineD3DSurfaceImpl
*) stateblock
->wineD3DDevice
->render_targets
[0];
3742 target
->get_drawable_size(target
, &width
, &height
);
3744 glViewport(stateblock
->viewport
.X
,
3745 (height
- (stateblock
->viewport
.Y
+ stateblock
->viewport
.Height
)),
3746 stateblock
->viewport
.Width
, stateblock
->viewport
.Height
);
3749 checkGLcall("glViewport");
3751 stateblock
->wineD3DDevice
->posFixup
[2] = 1.0 / stateblock
->viewport
.Width
;
3752 stateblock
->wineD3DDevice
->posFixup
[3] = -stateblock
->wineD3DDevice
->posFixup
[1] / stateblock
->viewport
.Height
;
3753 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_PROJECTION
))) {
3754 transform_projection(STATE_TRANSFORM(WINED3DTS_PROJECTION
), stateblock
, context
);
3756 if(!isStateDirty(context
, STATE_RENDER(WINED3DRS_POINTSCALEENABLE
))) {
3757 state_pscale(STATE_RENDER(WINED3DRS_POINTSCALEENABLE
), stateblock
, context
);
3761 static void light(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
3762 UINT Index
= state
- STATE_ACTIVELIGHT(0);
3763 PLIGHTINFOEL
*lightInfo
= stateblock
->activeLights
[Index
];
3766 glDisable(GL_LIGHT0
+ Index
);
3767 checkGLcall("glDisable(GL_LIGHT0 + Index)");
3770 float colRGBA
[] = {0.0, 0.0, 0.0, 0.0};
3772 /* Light settings are affected by the model view in OpenGL, the View transform in direct3d*/
3773 glMatrixMode(GL_MODELVIEW
);
3775 glLoadMatrixf(&stateblock
->transforms
[WINED3DTS_VIEW
].u
.m
[0][0]);
3778 colRGBA
[0] = lightInfo
->OriginalParms
.Diffuse
.r
;
3779 colRGBA
[1] = lightInfo
->OriginalParms
.Diffuse
.g
;
3780 colRGBA
[2] = lightInfo
->OriginalParms
.Diffuse
.b
;
3781 colRGBA
[3] = lightInfo
->OriginalParms
.Diffuse
.a
;
3782 glLightfv(GL_LIGHT0
+ Index
, GL_DIFFUSE
, colRGBA
);
3783 checkGLcall("glLightfv");
3786 colRGBA
[0] = lightInfo
->OriginalParms
.Specular
.r
;
3787 colRGBA
[1] = lightInfo
->OriginalParms
.Specular
.g
;
3788 colRGBA
[2] = lightInfo
->OriginalParms
.Specular
.b
;
3789 colRGBA
[3] = lightInfo
->OriginalParms
.Specular
.a
;
3790 glLightfv(GL_LIGHT0
+ Index
, GL_SPECULAR
, colRGBA
);
3791 checkGLcall("glLightfv");
3794 colRGBA
[0] = lightInfo
->OriginalParms
.Ambient
.r
;
3795 colRGBA
[1] = lightInfo
->OriginalParms
.Ambient
.g
;
3796 colRGBA
[2] = lightInfo
->OriginalParms
.Ambient
.b
;
3797 colRGBA
[3] = lightInfo
->OriginalParms
.Ambient
.a
;
3798 glLightfv(GL_LIGHT0
+ Index
, GL_AMBIENT
, colRGBA
);
3799 checkGLcall("glLightfv");
3801 if ((lightInfo
->OriginalParms
.Range
*lightInfo
->OriginalParms
.Range
) >= FLT_MIN
) {
3802 quad_att
= 1.4/(lightInfo
->OriginalParms
.Range
*lightInfo
->OriginalParms
.Range
);
3804 quad_att
= 0; /* 0 or MAX? (0 seems to be ok) */
3807 /* Do not assign attenuation values for lights that do not use them. D3D apps are free to pass any junk,
3808 * but gl drivers use them and may crash due to bad Attenuation values. Need for Speed most wanted sets
3809 * Attenuation0 to NaN and crashes in the gl lib
3812 switch (lightInfo
->OriginalParms
.Type
) {
3813 case WINED3DLIGHT_POINT
:
3815 glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->lightPosn
[0]);
3816 checkGLcall("glLightfv");
3817 glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
3818 checkGLcall("glLightf");
3819 /* Attenuation - Are these right? guessing... */
3820 glLightf(GL_LIGHT0
+ Index
, GL_CONSTANT_ATTENUATION
, lightInfo
->OriginalParms
.Attenuation0
);
3821 checkGLcall("glLightf");
3822 glLightf(GL_LIGHT0
+ Index
, GL_LINEAR_ATTENUATION
, lightInfo
->OriginalParms
.Attenuation1
);
3823 checkGLcall("glLightf");
3824 if (quad_att
< lightInfo
->OriginalParms
.Attenuation2
) quad_att
= lightInfo
->OriginalParms
.Attenuation2
;
3825 glLightf(GL_LIGHT0
+ Index
, GL_QUADRATIC_ATTENUATION
, quad_att
);
3826 checkGLcall("glLightf");
3830 case WINED3DLIGHT_SPOT
:
3832 glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->lightPosn
[0]);
3833 checkGLcall("glLightfv");
3835 glLightfv(GL_LIGHT0
+ Index
, GL_SPOT_DIRECTION
, &lightInfo
->lightDirn
[0]);
3836 checkGLcall("glLightfv");
3837 glLightf(GL_LIGHT0
+ Index
, GL_SPOT_EXPONENT
, lightInfo
->exponent
);
3838 checkGLcall("glLightf");
3839 glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
3840 checkGLcall("glLightf");
3841 /* Attenuation - Are these right? guessing... */
3842 glLightf(GL_LIGHT0
+ Index
, GL_CONSTANT_ATTENUATION
, lightInfo
->OriginalParms
.Attenuation0
);
3843 checkGLcall("glLightf");
3844 glLightf(GL_LIGHT0
+ Index
, GL_LINEAR_ATTENUATION
, lightInfo
->OriginalParms
.Attenuation1
);
3845 checkGLcall("glLightf");
3846 if (quad_att
< lightInfo
->OriginalParms
.Attenuation2
) quad_att
= lightInfo
->OriginalParms
.Attenuation2
;
3847 glLightf(GL_LIGHT0
+ Index
, GL_QUADRATIC_ATTENUATION
, quad_att
);
3848 checkGLcall("glLightf");
3852 case WINED3DLIGHT_DIRECTIONAL
:
3854 glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->lightPosn
[0]); /* Note gl uses w position of 0 for direction! */
3855 checkGLcall("glLightfv");
3856 glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
3857 checkGLcall("glLightf");
3858 glLightf(GL_LIGHT0
+ Index
, GL_SPOT_EXPONENT
, 0.0f
);
3859 checkGLcall("glLightf");
3863 FIXME("Unrecognized light type %d\n", lightInfo
->OriginalParms
.Type
);
3866 /* Restore the modelview matrix */
3869 glEnable(GL_LIGHT0
+ Index
);
3870 checkGLcall("glEnable(GL_LIGHT0 + Index)");
3876 static void scissorrect(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
3877 RECT
*pRect
= &stateblock
->scissorRect
;
3880 IWineD3DSurfaceImpl
*target
= (IWineD3DSurfaceImpl
*) stateblock
->wineD3DDevice
->render_targets
[0];
3882 target
->get_drawable_size(target
, &width
, &height
);
3883 /* Warning: glScissor uses window coordinates, not viewport coordinates, so our viewport correction does not apply
3884 * Warning2: Even in windowed mode the coords are relative to the window, not the screen
3886 TRACE("(%p) Setting new Scissor Rect to %d:%d-%d:%d\n", stateblock
->wineD3DDevice
, pRect
->left
, pRect
->bottom
- height
,
3887 pRect
->right
- pRect
->left
, pRect
->bottom
- pRect
->top
);
3889 if (stateblock
->wineD3DDevice
->render_offscreen
) {
3890 glScissor(pRect
->left
, pRect
->top
, pRect
->right
- pRect
->left
, pRect
->bottom
- pRect
->top
);
3892 glScissor(pRect
->left
, height
- pRect
->bottom
, pRect
->right
- pRect
->left
, pRect
->bottom
- pRect
->top
);
3894 checkGLcall("glScissor");
3897 static void indexbuffer(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
3898 if(GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT
)) {
3899 if(stateblock
->streamIsUP
|| stateblock
->pIndexData
== NULL
) {
3900 GL_EXTCALL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB
, 0));
3902 IWineD3DIndexBufferImpl
*ib
= (IWineD3DIndexBufferImpl
*) stateblock
->pIndexData
;
3903 GL_EXTCALL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB
, ib
->vbo
));
3908 static void frontface(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
3909 if(stateblock
->wineD3DDevice
->render_offscreen
) {
3910 glFrontFace(GL_CCW
);
3911 checkGLcall("glFrontFace(GL_CCW)");
3914 checkGLcall("glFrontFace(GL_CW)");
3918 const struct StateEntry StateTable
[] =
3920 /* State name representative, apply function */
3921 { /* 0, Undefined */ 0, state_undefined
},
3922 { /* 1, WINED3DRS_TEXTUREHANDLE */ 0 /* Handled in ddraw */, state_undefined
},
3923 { /* 2, WINED3DRS_ANTIALIAS */ STATE_RENDER(WINED3DRS_ANTIALIAS
), state_antialias
},
3924 { /* 3, WINED3DRS_TEXTUREADDRESS */ 0 /* Handled in ddraw */, state_undefined
},
3925 { /* 4, WINED3DRS_TEXTUREPERSPECTIVE */ STATE_RENDER(WINED3DRS_TEXTUREPERSPECTIVE
), state_perspective
},
3926 { /* 5, WINED3DRS_WRAPU */ STATE_RENDER(WINED3DRS_WRAPU
), state_wrapu
},
3927 { /* 6, WINED3DRS_WRAPV */ STATE_RENDER(WINED3DRS_WRAPV
), state_wrapv
},
3928 { /* 7, WINED3DRS_ZENABLE */ STATE_RENDER(WINED3DRS_ZENABLE
), state_zenable
},
3929 { /* 8, WINED3DRS_FILLMODE */ STATE_RENDER(WINED3DRS_FILLMODE
), state_fillmode
},
3930 { /* 9, WINED3DRS_SHADEMODE */ STATE_RENDER(WINED3DRS_SHADEMODE
), state_shademode
},
3931 { /* 10, WINED3DRS_LINEPATTERN */ STATE_RENDER(WINED3DRS_LINEPATTERN
), state_linepattern
},
3932 { /* 11, WINED3DRS_MONOENABLE */ STATE_RENDER(WINED3DRS_MONOENABLE
), state_monoenable
},
3933 { /* 12, WINED3DRS_ROP2 */ STATE_RENDER(WINED3DRS_ROP2
), state_rop2
},
3934 { /* 13, WINED3DRS_PLANEMASK */ STATE_RENDER(WINED3DRS_PLANEMASK
), state_planemask
},
3935 { /* 14, WINED3DRS_ZWRITEENABLE */ STATE_RENDER(WINED3DRS_ZWRITEENABLE
), state_zwritenable
},
3936 { /* 15, WINED3DRS_ALPHATESTENABLE */ STATE_RENDER(WINED3DRS_ALPHATESTENABLE
), state_alpha
},
3937 { /* 16, WINED3DRS_LASTPIXEL */ STATE_RENDER(WINED3DRS_LASTPIXEL
), state_lastpixel
},
3938 { /* 17, WINED3DRS_TEXTUREMAG */ 0 /* Handled in ddraw */, state_undefined
},
3939 { /* 18, WINED3DRS_TEXTUREMIN */ 0 /* Handled in ddraw */, state_undefined
},
3940 { /* 19, WINED3DRS_SRCBLEND */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
},
3941 { /* 20, WINED3DRS_DESTBLEND */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
},
3942 { /* 21, WINED3DRS_TEXTUREMAPBLEND */ 0 /* Handled in ddraw */, state_undefined
},
3943 { /* 22, WINED3DRS_CULLMODE */ STATE_RENDER(WINED3DRS_CULLMODE
), state_cullmode
},
3944 { /* 23, WINED3DRS_ZFUNC */ STATE_RENDER(WINED3DRS_ZFUNC
), state_zfunc
},
3945 { /* 24, WINED3DRS_ALPHAREF */ STATE_RENDER(WINED3DRS_ALPHATESTENABLE
), state_alpha
},
3946 { /* 25, WINED3DRS_ALPHAFUNC */ STATE_RENDER(WINED3DRS_ALPHATESTENABLE
), state_alpha
},
3947 { /* 26, WINED3DRS_DITHERENABLE */ STATE_RENDER(WINED3DRS_DITHERENABLE
), state_ditherenable
},
3948 { /* 27, WINED3DRS_ALPHABLENDENABLE */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
},
3949 { /* 28, WINED3DRS_FOGENABLE */ STATE_RENDER(WINED3DRS_FOGENABLE
), state_fog
},
3950 { /* 29, WINED3DRS_SPECULARENABLE */ STATE_RENDER(WINED3DRS_SPECULARENABLE
), state_specularenable
},
3951 { /* 30, WINED3DRS_ZVISIBLE */ 0 /* Not supported according to the msdn */, state_nogl
},
3952 { /* 31, WINED3DRS_SUBPIXEL */ STATE_RENDER(WINED3DRS_SUBPIXEL
), state_subpixel
},
3953 { /* 32, WINED3DRS_SUBPIXELX */ STATE_RENDER(WINED3DRS_SUBPIXELX
), state_subpixelx
},
3954 { /* 33, WINED3DRS_STIPPLEDALPHA */ STATE_RENDER(WINED3DRS_STIPPLEDALPHA
), state_stippledalpha
},
3955 { /* 34, WINED3DRS_FOGCOLOR */ STATE_RENDER(WINED3DRS_FOGCOLOR
), state_fogcolor
},
3956 { /* 35, WINED3DRS_FOGTABLEMODE */ STATE_RENDER(WINED3DRS_FOGENABLE
), state_fog
},
3957 { /* 36, WINED3DRS_FOGSTART */ STATE_RENDER(WINED3DRS_FOGENABLE
), state_fog
},
3958 { /* 37, WINED3DRS_FOGEND */ STATE_RENDER(WINED3DRS_FOGENABLE
), state_fog
},
3959 { /* 38, WINED3DRS_FOGDENSITY */ STATE_RENDER(WINED3DRS_FOGDENSITY
), state_fogdensity
},
3960 { /* 39, WINED3DRS_STIPPLEENABLE */ STATE_RENDER(WINED3DRS_STIPPLEENABLE
), state_stippleenable
},
3961 { /* 40, WINED3DRS_EDGEANTIALIAS */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
},
3962 { /* 41, WINED3DRS_COLORKEYENABLE */ STATE_RENDER(WINED3DRS_ALPHATESTENABLE
), state_alpha
},
3963 { /* 42, undefined */ 0, state_undefined
},
3964 { /* 43, WINED3DRS_BORDERCOLOR */ STATE_RENDER(WINED3DRS_BORDERCOLOR
), state_bordercolor
},
3965 { /* 44, WINED3DRS_TEXTUREADDRESSU */ 0, /* Handled in ddraw */ state_undefined
},
3966 { /* 45, WINED3DRS_TEXTUREADDRESSV */ 0, /* Handled in ddraw */ state_undefined
},
3967 { /* 46, WINED3DRS_MIPMAPLODBIAS */ STATE_RENDER(WINED3DRS_MIPMAPLODBIAS
), state_mipmaplodbias
},
3968 { /* 47, WINED3DRS_ZBIAS */ STATE_RENDER(WINED3DRS_ZBIAS
), state_zbias
},
3969 { /* 48, WINED3DRS_RANGEFOGENABLE */ STATE_RENDER(WINED3DRS_RANGEFOGENABLE
), state_rangefog
},
3970 { /* 49, WINED3DRS_ANISOTROPY */ STATE_RENDER(WINED3DRS_ANISOTROPY
), state_anisotropy
},
3971 { /* 50, WINED3DRS_FLUSHBATCH */ STATE_RENDER(WINED3DRS_FLUSHBATCH
), state_flushbatch
},
3972 { /* 51, WINED3DRS_TRANSLUCENTSORTINDEPENDENT */ STATE_RENDER(WINED3DRS_TRANSLUCENTSORTINDEPENDENT
), state_translucentsi
},
3973 { /* 52, WINED3DRS_STENCILENABLE */ STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
},
3974 { /* 53, WINED3DRS_STENCILFAIL */ STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
},
3975 { /* 54, WINED3DRS_STENCILZFAIL */ STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
},
3976 { /* 55, WINED3DRS_STENCILPASS */ STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
},
3977 { /* 56, WINED3DRS_STENCILFUNC */ STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
},
3978 { /* 57, WINED3DRS_STENCILREF */ STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
},
3979 { /* 58, WINED3DRS_STENCILMASK */ STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
},
3980 { /* 59, WINED3DRS_STENCILWRITEMASK */ STATE_RENDER(WINED3DRS_STENCILWRITEMASK
), state_stencilwrite
},
3981 { /* 60, WINED3DRS_TEXTUREFACTOR */ STATE_RENDER(WINED3DRS_TEXTUREFACTOR
), state_texfactor
},
3982 { /* 61, Undefined */ 0, state_undefined
},
3983 { /* 62, Undefined */ 0, state_undefined
},
3984 { /* 63, Undefined */ 0, state_undefined
},
3985 { /* 64, WINED3DRS_STIPPLEPATTERN00 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
3986 { /* 65, WINED3DRS_STIPPLEPATTERN01 */ 0 /* Obsolete, should he handled by ddraw */, state_undefined
},
3987 { /* 66, WINED3DRS_STIPPLEPATTERN02 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
3988 { /* 67, WINED3DRS_STIPPLEPATTERN03 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
3989 { /* 68, WINED3DRS_STIPPLEPATTERN04 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
3990 { /* 69, WINED3DRS_STIPPLEPATTERN05 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
3991 { /* 70, WINED3DRS_STIPPLEPATTERN06 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
3992 { /* 71, WINED3DRS_STIPPLEPATTERN07 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
3993 { /* 72, WINED3DRS_STIPPLEPATTERN08 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
3994 { /* 73, WINED3DRS_STIPPLEPATTERN09 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
3995 { /* 74, WINED3DRS_STIPPLEPATTERN10 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
3996 { /* 75, WINED3DRS_STIPPLEPATTERN11 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
3997 { /* 76, WINED3DRS_STIPPLEPATTERN12 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
3998 { /* 77, WINED3DRS_STIPPLEPATTERN13 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
3999 { /* 78, WINED3DRS_STIPPLEPATTERN14 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
4000 { /* 79, WINED3DRS_STIPPLEPATTERN15 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
4001 { /* 80, WINED3DRS_STIPPLEPATTERN16 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
4002 { /* 81, WINED3DRS_STIPPLEPATTERN17 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
4003 { /* 82, WINED3DRS_STIPPLEPATTERN18 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
4004 { /* 83, WINED3DRS_STIPPLEPATTERN19 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
4005 { /* 84, WINED3DRS_STIPPLEPATTERN20 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
4006 { /* 85, WINED3DRS_STIPPLEPATTERN21 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
4007 { /* 86, WINED3DRS_STIPPLEPATTERN22 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
4008 { /* 87, WINED3DRS_STIPPLEPATTERN23 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
4009 { /* 88, WINED3DRS_STIPPLEPATTERN24 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
4010 { /* 89, WINED3DRS_STIPPLEPATTERN25 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
4011 { /* 90, WINED3DRS_STIPPLEPATTERN26 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
4012 { /* 91, WINED3DRS_STIPPLEPATTERN27 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
4013 { /* 92, WINED3DRS_STIPPLEPATTERN28 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
4014 { /* 93, WINED3DRS_STIPPLEPATTERN29 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
4015 { /* 94, WINED3DRS_STIPPLEPATTERN30 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
4016 { /* 95, WINED3DRS_STIPPLEPATTERN31 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined
},
4017 { /* 96, Undefined */ 0, state_undefined
},
4018 { /* 97, Undefined */ 0, state_undefined
},
4019 { /* 98, Undefined */ 0, state_undefined
},
4020 { /* 99, Undefined */ 0, state_undefined
},
4021 { /*100, Undefined */ 0, state_undefined
},
4022 { /*101, Undefined */ 0, state_undefined
},
4023 { /*102, Undefined */ 0, state_undefined
},
4024 { /*103, Undefined */ 0, state_undefined
},
4025 { /*104, Undefined */ 0, state_undefined
},
4026 { /*105, Undefined */ 0, state_undefined
},
4027 { /*106, Undefined */ 0, state_undefined
},
4028 { /*107, Undefined */ 0, state_undefined
},
4029 { /*108, Undefined */ 0, state_undefined
},
4030 { /*109, Undefined */ 0, state_undefined
},
4031 { /*110, Undefined */ 0, state_undefined
},
4032 { /*111, Undefined */ 0, state_undefined
},
4033 { /*112, Undefined */ 0, state_undefined
},
4034 { /*113, Undefined */ 0, state_undefined
},
4035 { /*114, Undefined */ 0, state_undefined
},
4036 { /*115, Undefined */ 0, state_undefined
},
4037 { /*116, Undefined */ 0, state_undefined
},
4038 { /*117, Undefined */ 0, state_undefined
},
4039 { /*118, Undefined */ 0, state_undefined
},
4040 { /*119, Undefined */ 0, state_undefined
},
4041 { /*120, Undefined */ 0, state_undefined
},
4042 { /*121, Undefined */ 0, state_undefined
},
4043 { /*122, Undefined */ 0, state_undefined
},
4044 { /*123, Undefined */ 0, state_undefined
},
4045 { /*124, Undefined */ 0, state_undefined
},
4046 { /*125, Undefined */ 0, state_undefined
},
4047 { /*126, Undefined */ 0, state_undefined
},
4048 { /*127, Undefined */ 0, state_undefined
},
4050 { /*128, WINED3DRS_WRAP0 */ STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
},
4051 { /*129, WINED3DRS_WRAP1 */ STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
},
4052 { /*130, WINED3DRS_WRAP2 */ STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
},
4053 { /*131, WINED3DRS_WRAP3 */ STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
},
4054 { /*132, WINED3DRS_WRAP4 */ STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
},
4055 { /*133, WINED3DRS_WRAP5 */ STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
},
4056 { /*134, WINED3DRS_WRAP6 */ STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
},
4057 { /*135, WINED3DRS_WRAP7 */ STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
},
4058 { /*136, WINED3DRS_CLIPPING */ STATE_RENDER(WINED3DRS_CLIPPING
), state_clipping
},
4059 { /*137, WINED3DRS_LIGHTING */ STATE_RENDER(WINED3DRS_LIGHTING
), state_lighting
},
4060 { /*138, WINED3DRS_EXTENTS */ STATE_RENDER(WINED3DRS_EXTENTS
), state_extents
},
4061 { /*139, WINED3DRS_AMBIENT */ STATE_RENDER(WINED3DRS_AMBIENT
), state_ambient
},
4062 { /*140, WINED3DRS_FOGVERTEXMODE */ STATE_RENDER(WINED3DRS_FOGENABLE
), state_fog
},
4063 { /*141, WINED3DRS_COLORVERTEX */ STATE_RENDER(WINED3DRS_COLORVERTEX
), state_colormat
},
4064 { /*142, WINED3DRS_LOCALVIEWER */ STATE_RENDER(WINED3DRS_LOCALVIEWER
), state_localviewer
},
4065 { /*143, WINED3DRS_NORMALIZENORMALS */ STATE_RENDER(WINED3DRS_NORMALIZENORMALS
), state_normalize
},
4066 { /*144, WINED3DRS_COLORKEYBLENDENABLE */ STATE_RENDER(WINED3DRS_COLORKEYBLENDENABLE
), state_ckeyblend
},
4067 { /*145, WINED3DRS_DIFFUSEMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX
), state_colormat
},
4068 { /*146, WINED3DRS_SPECULARMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX
), state_colormat
},
4069 { /*147, WINED3DRS_AMBIENTMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX
), state_colormat
},
4070 { /*148, WINED3DRS_EMISSIVEMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX
), state_colormat
},
4071 { /*149, Undefined */ 0, state_undefined
},
4072 { /*150, Undefined */ 0, state_undefined
},
4073 { /*151, WINED3DRS_VERTEXBLEND */ STATE_RENDER(WINED3DRS_VERTEXBLEND
), state_vertexblend
},
4074 { /*152, WINED3DRS_CLIPPLANEENABLE */ STATE_RENDER(WINED3DRS_CLIPPING
), state_clipping
},
4075 { /*153, WINED3DRS_SOFTWAREVERTEXPROCESSING */ 0, state_nogl
},
4076 { /*154, WINED3DRS_POINTSIZE */ STATE_RENDER(WINED3DRS_POINTSCALEENABLE
), state_pscale
},
4077 { /*155, WINED3DRS_POINTSIZE_MIN */ STATE_RENDER(WINED3DRS_POINTSIZE_MIN
), state_psizemin
},
4078 { /*156, WINED3DRS_POINTSPRITEENABLE */ STATE_RENDER(WINED3DRS_POINTSPRITEENABLE
), state_pointsprite
},
4079 { /*157, WINED3DRS_POINTSCALEENABLE */ STATE_RENDER(WINED3DRS_POINTSCALEENABLE
), state_pscale
},
4080 { /*158, WINED3DRS_POINTSCALE_A */ STATE_RENDER(WINED3DRS_POINTSCALEENABLE
), state_pscale
},
4081 { /*159, WINED3DRS_POINTSCALE_B */ STATE_RENDER(WINED3DRS_POINTSCALEENABLE
), state_pscale
},
4082 { /*160, WINED3DRS_POINTSCALE_C */ STATE_RENDER(WINED3DRS_POINTSCALEENABLE
), state_pscale
},
4083 { /*161, WINED3DRS_MULTISAMPLEANTIALIAS */ STATE_RENDER(WINED3DRS_MULTISAMPLEANTIALIAS
), state_multisampleaa
},
4084 { /*162, WINED3DRS_MULTISAMPLEMASK */ STATE_RENDER(WINED3DRS_MULTISAMPLEMASK
), state_multisampmask
},
4085 { /*163, WINED3DRS_PATCHEDGESTYLE */ STATE_RENDER(WINED3DRS_PATCHEDGESTYLE
), state_patchedgestyle
},
4086 { /*164, WINED3DRS_PATCHSEGMENTS */ STATE_RENDER(WINED3DRS_PATCHSEGMENTS
), state_patchsegments
},
4087 { /*165, WINED3DRS_DEBUGMONITORTOKEN */ STATE_RENDER(WINED3DRS_DEBUGMONITORTOKEN
), state_nogl
},
4088 { /*166, WINED3DRS_POINTSIZE_MAX */ STATE_RENDER(WINED3DRS_POINTSIZE_MAX
), state_psizemax
},
4089 { /*167, WINED3DRS_INDEXEDVERTEXBLENDENABLE */ 0, state_nogl
},
4090 { /*168, WINED3DRS_COLORWRITEENABLE */ STATE_RENDER(WINED3DRS_COLORWRITEENABLE
), state_colorwrite
},
4091 { /*169, Undefined */ 0, state_undefined
},
4092 { /*170, WINED3DRS_TWEENFACTOR */ 0, state_nogl
},
4093 { /*171, WINED3DRS_BLENDOP */ STATE_RENDER(WINED3DRS_BLENDOP
), state_blendop
},
4094 { /*172, WINED3DRS_POSITIONDEGREE */ STATE_RENDER(WINED3DRS_POSITIONDEGREE
), state_positiondegree
},
4095 { /*173, WINED3DRS_NORMALDEGREE */ STATE_RENDER(WINED3DRS_NORMALDEGREE
), state_normaldegree
},
4096 /*172, WINED3DRS_POSITIONORDER */ /* Value assigned to 2 state names */
4097 /*173, WINED3DRS_NORMALORDER */ /* Value assigned to 2 state names */
4098 { /*174, WINED3DRS_SCISSORTESTENABLE */ STATE_RENDER(WINED3DRS_SCISSORTESTENABLE
), state_scissor
},
4099 { /*175, WINED3DRS_SLOPESCALEDEPTHBIAS */ STATE_RENDER(WINED3DRS_DEPTHBIAS
), state_depthbias
},
4100 { /*176, WINED3DRS_ANTIALIASEDLINEENABLE */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
},
4101 { /*177, undefined */ 0, state_undefined
},
4102 { /*178, WINED3DRS_MINTESSELLATIONLEVEL */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), state_tessellation
},
4103 { /*179, WINED3DRS_MAXTESSELLATIONLEVEL */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), state_tessellation
},
4104 { /*180, WINED3DRS_ADAPTIVETESS_X */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), state_tessellation
},
4105 { /*181, WINED3DRS_ADAPTIVETESS_Y */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), state_tessellation
},
4106 { /*182, WINED3DRS_ADAPTIVETESS_Z */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), state_tessellation
},
4107 { /*183, WINED3DRS_ADAPTIVETESS_W */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), state_tessellation
},
4108 { /*184, WINED3DRS_ENABLEADAPTIVETESSELLATION */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), state_tessellation
},
4109 { /*185, WINED3DRS_TWOSIDEDSTENCILMODE */ STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
},
4110 { /*186, WINED3DRS_CCW_STENCILFAIL */ STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
},
4111 { /*187, WINED3DRS_CCW_STENCILZFAIL */ STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
},
4112 { /*188, WINED3DRS_CCW_STENCILPASS */ STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
},
4113 { /*189, WINED3DRS_CCW_STENCILFUNC */ STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
},
4114 { /*190, WINED3DRS_COLORWRITEENABLE1 */ STATE_RENDER(WINED3DRS_COLORWRITEENABLE
), state_colorwrite
},
4115 { /*191, WINED3DRS_COLORWRITEENABLE2 */ STATE_RENDER(WINED3DRS_COLORWRITEENABLE
), state_colorwrite
},
4116 { /*192, WINED3DRS_COLORWRITEENABLE3 */ STATE_RENDER(WINED3DRS_COLORWRITEENABLE
), state_colorwrite
},
4117 { /*193, WINED3DRS_BLENDFACTOR */ STATE_RENDER(WINED3DRS_BLENDFACTOR
), state_blendfactor
},
4118 { /*194, WINED3DRS_SRGBWRITEENABLE */ STATE_PIXELSHADER
, pixelshader
},
4119 { /*195, WINED3DRS_DEPTHBIAS */ STATE_RENDER(WINED3DRS_DEPTHBIAS
), state_depthbias
},
4120 { /*196, undefined */ 0, state_undefined
},
4121 { /*197, undefined */ 0, state_undefined
},
4122 { /*198, WINED3DRS_WRAP8 */ STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
},
4123 { /*199, WINED3DRS_WRAP9 */ STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
},
4124 { /*200, WINED3DRS_WRAP10 */ STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
},
4125 { /*201, WINED3DRS_WRAP11 */ STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
},
4126 { /*202, WINED3DRS_WRAP12 */ STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
},
4127 { /*203, WINED3DRS_WRAP13 */ STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
},
4128 { /*204, WINED3DRS_WRAP14 */ STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
},
4129 { /*205, WINED3DRS_WRAP15 */ STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
},
4130 { /*206, WINED3DRS_SEPARATEALPHABLENDENABLE */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
},
4131 { /*207, WINED3DRS_SRCBLENDALPHA */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
},
4132 { /*208, WINED3DRS_DESTBLENDALPHA */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
},
4133 { /*209, WINED3DRS_BLENDOPALPHA */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blendop
},
4134 /* Texture stage states */
4135 { /*0, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP
), tex_colorop
},
4136 { /*0, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP
), tex_colorop
},
4137 { /*0, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP
), tex_colorop
},
4138 { /*0, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4139 { /*0, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4140 { /*0, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4141 { /*0, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4142 { /*0, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4143 { /*0, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4144 { /*0, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4145 { /*0, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(0, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
},
4146 { /*0, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4147 { /*0, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4148 { /*0, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4149 { /*0, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4150 { /*0, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4151 { /*0, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4152 { /*0, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4153 { /*0, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4154 { /*0, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4155 { /*0, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4156 { /*0, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
},
4157 { /*0, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLOFFSET
), tex_bumpenvloffset
},
4158 { /*0, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE0
), transform_texture
},
4159 { /*0, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4160 { /*0, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP
), tex_colorop
},
4161 { /*0, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4162 { /*0, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(0, WINED3DTSS_RESULTARG
), tex_resultarg
},
4163 { /*0, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4164 { /*0, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4165 { /*0, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4166 { /*0, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl
},
4168 { /*1, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP
), tex_colorop
},
4169 { /*1, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP
), tex_colorop
},
4170 { /*1, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP
), tex_colorop
},
4171 { /*1, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4172 { /*1, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4173 { /*1, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4174 { /*1, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4175 { /*1, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4176 { /*1, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4177 { /*1, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4178 { /*1, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(1, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
},
4179 { /*1, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4180 { /*1, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4181 { /*1, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4182 { /*1, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4183 { /*1, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4184 { /*1, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4185 { /*1, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4186 { /*1, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4187 { /*1, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4188 { /*1, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4189 { /*1, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
},
4190 { /*1, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLOFFSET
), tex_bumpenvloffset
},
4191 { /*1, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE1
), transform_texture
},
4192 { /*1, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4193 { /*1, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP
), tex_colorop
},
4194 { /*1, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4195 { /*1, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(1, WINED3DTSS_RESULTARG
), tex_resultarg
},
4196 { /*1, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4197 { /*1, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4198 { /*1, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4199 { /*1, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl
},
4201 { /*2, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP
), tex_colorop
},
4202 { /*2, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP
), tex_colorop
},
4203 { /*2, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP
), tex_colorop
},
4204 { /*2, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4205 { /*2, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4206 { /*2, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4207 { /*2, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4208 { /*2, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4209 { /*2, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4210 { /*2, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4211 { /*2, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(2, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
},
4212 { /*2, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4213 { /*2, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4214 { /*2, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4215 { /*2, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4216 { /*2, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4217 { /*2, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4218 { /*2, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4219 { /*2, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4220 { /*2, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4221 { /*2, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4222 { /*2, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
},
4223 { /*2, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLOFFSET
), tex_bumpenvloffset
},
4224 { /*2, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE2
), transform_texture
},
4225 { /*2, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4226 { /*2, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP
), tex_colorop
},
4227 { /*2, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4228 { /*2, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(2, WINED3DTSS_RESULTARG
), tex_resultarg
},
4229 { /*2, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4230 { /*2, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4231 { /*2, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4232 { /*2, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl
},
4234 { /*3, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP
), tex_colorop
},
4235 { /*3, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP
), tex_colorop
},
4236 { /*3, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP
), tex_colorop
},
4237 { /*3, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4238 { /*3, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4239 { /*3, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4240 { /*3, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4241 { /*3, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4242 { /*3, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4243 { /*3, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4244 { /*3, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(3, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
},
4245 { /*3, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4246 { /*3, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4247 { /*3, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4248 { /*3, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4249 { /*3, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4250 { /*3, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4251 { /*3, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4252 { /*3, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4253 { /*3, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4254 { /*3, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4255 { /*3, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
},
4256 { /*3, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLOFFSET
), tex_bumpenvloffset
},
4257 { /*3, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE3
), transform_texture
},
4258 { /*3, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4259 { /*3, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP
), tex_colorop
},
4260 { /*3, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4261 { /*3, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(3, WINED3DTSS_RESULTARG
), tex_resultarg
},
4262 { /*3, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4263 { /*3, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4264 { /*3, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4265 { /*3, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl
},
4267 { /*4, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP
), tex_colorop
},
4268 { /*4, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP
), tex_colorop
},
4269 { /*4, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP
), tex_colorop
},
4270 { /*4, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4271 { /*4, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4272 { /*4, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4273 { /*4, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4274 { /*4, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4275 { /*4, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4276 { /*4, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4277 { /*4, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(4, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
},
4278 { /*4, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4279 { /*4, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4280 { /*4, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4281 { /*4, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4282 { /*4, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4283 { /*4, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4284 { /*4, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4285 { /*4, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4286 { /*4, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4287 { /*4, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4288 { /*4, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
},
4289 { /*4, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLOFFSET
), tex_bumpenvloffset
},
4290 { /*4, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE4
), transform_texture
},
4291 { /*4, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4292 { /*4, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP
), tex_colorop
},
4293 { /*4, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4294 { /*4, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(4, WINED3DTSS_RESULTARG
), tex_resultarg
},
4295 { /*4, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4296 { /*4, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4297 { /*4, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4298 { /*4, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl
},
4300 { /*5, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP
), tex_colorop
},
4301 { /*5, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP
), tex_colorop
},
4302 { /*5, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP
), tex_colorop
},
4303 { /*5, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4304 { /*5, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4305 { /*5, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4306 { /*5, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4307 { /*5, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4308 { /*5, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4309 { /*5, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4310 { /*5, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(5, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
},
4311 { /*5, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4312 { /*5, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4313 { /*5, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4314 { /*5, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4315 { /*5, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4316 { /*5, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4317 { /*5, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4318 { /*5, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4319 { /*5, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4320 { /*5, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4321 { /*5, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
},
4322 { /*5, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLOFFSET
), tex_bumpenvloffset
},
4323 { /*5, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE5
), transform_texture
},
4324 { /*5, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4325 { /*5, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP
), tex_colorop
},
4326 { /*5, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4327 { /*5, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(5, WINED3DTSS_RESULTARG
), tex_resultarg
},
4328 { /*5, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4329 { /*5, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4330 { /*5, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4331 { /*5, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl
},
4333 { /*6, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP
), tex_colorop
},
4334 { /*6, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP
), tex_colorop
},
4335 { /*6, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP
), tex_colorop
},
4336 { /*6, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4337 { /*6, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4338 { /*6, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4339 { /*6, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4340 { /*6, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4341 { /*6, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4342 { /*6, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4343 { /*6, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(6, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
},
4344 { /*6, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4345 { /*6, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4346 { /*6, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4347 { /*6, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4348 { /*6, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4349 { /*6, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4350 { /*6, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4351 { /*6, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4352 { /*6, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4353 { /*6, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4354 { /*6, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
},
4355 { /*6, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLOFFSET
), tex_bumpenvloffset
},
4356 { /*6, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE6
), transform_texture
},
4357 { /*6, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4358 { /*6, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP
), tex_colorop
},
4359 { /*6, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4360 { /*6, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(6, WINED3DTSS_RESULTARG
), tex_resultarg
},
4361 { /*6, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4362 { /*6, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4363 { /*6, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4364 { /*6, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl
},
4366 { /*7, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP
), tex_colorop
},
4367 { /*7, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP
), tex_colorop
},
4368 { /*7, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP
), tex_colorop
},
4369 { /*7, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4370 { /*7, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4371 { /*7, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4372 { /*7, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4373 { /*7, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4374 { /*7, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4375 { /*7, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00
), tex_bumpenvmat
},
4376 { /*7, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(7, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
},
4377 { /*7, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4378 { /*7, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4379 { /*7, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4380 { /*7, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4381 { /*7, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4382 { /*7, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4383 { /*7, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4384 { /*7, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4385 { /*7, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4386 { /*7, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4387 { /*7, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
},
4388 { /*7, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLOFFSET
), tex_bumpenvloffset
},
4389 { /*7, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE7
), transform_texture
},
4390 { /*7, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4391 { /*7, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP
), tex_colorop
},
4392 { /*7, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP
), tex_alphaop
},
4393 { /*7, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(7, WINED3DTSS_RESULTARG
), tex_resultarg
},
4394 { /*7, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4395 { /*7, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4396 { /*7, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined
},
4397 { /*7, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl
},
4398 /* Sampler states */
4399 { /* 0, Sampler 0 */ STATE_SAMPLER(0), sampler
},
4400 { /* 1, Sampler 1 */ STATE_SAMPLER(1), sampler
},
4401 { /* 2, Sampler 2 */ STATE_SAMPLER(2), sampler
},
4402 { /* 3, Sampler 3 */ STATE_SAMPLER(3), sampler
},
4403 { /* 4, Sampler 3 */ STATE_SAMPLER(4), sampler
},
4404 { /* 5, Sampler 5 */ STATE_SAMPLER(5), sampler
},
4405 { /* 6, Sampler 6 */ STATE_SAMPLER(6), sampler
},
4406 { /* 7, Sampler 7 */ STATE_SAMPLER(7), sampler
},
4407 { /* 8, Sampler 8 */ STATE_SAMPLER(8), sampler
},
4408 { /* 9, Sampler 9 */ STATE_SAMPLER(9), sampler
},
4409 { /*10, Sampler 10 */ STATE_SAMPLER(10), sampler
},
4410 { /*11, Sampler 11 */ STATE_SAMPLER(11), sampler
},
4411 { /*12, Sampler 12 */ STATE_SAMPLER(12), sampler
},
4412 { /*13, Sampler 13 */ STATE_SAMPLER(13), sampler
},
4413 { /*14, Sampler 14 */ STATE_SAMPLER(14), sampler
},
4414 { /*15, Sampler 15 */ STATE_SAMPLER(15), sampler
},
4415 { /*16, Vertex sampler 0 */ STATE_SAMPLER(16), sampler
},
4416 { /*17, Vertex sampler 1 */ STATE_SAMPLER(17), sampler
},
4417 { /*18, Vertex sampler 2 */ STATE_SAMPLER(18), sampler
},
4418 { /*19, Vertex sampler 3 */ STATE_SAMPLER(19), sampler
},
4420 { /* , Pixel Shader */ STATE_PIXELSHADER
, pixelshader
},
4421 /* Transform states follow */
4422 { /* 1, undefined */ 0, state_undefined
},
4423 { /* 2, WINED3DTS_VIEW */ STATE_TRANSFORM(WINED3DTS_VIEW
), transform_view
},
4424 { /* 3, WINED3DTS_PROJECTION */ STATE_TRANSFORM(WINED3DTS_PROJECTION
), transform_projection
},
4425 { /* 4, undefined */ 0, state_undefined
},
4426 { /* 5, undefined */ 0, state_undefined
},
4427 { /* 6, undefined */ 0, state_undefined
},
4428 { /* 7, undefined */ 0, state_undefined
},
4429 { /* 8, undefined */ 0, state_undefined
},
4430 { /* 9, undefined */ 0, state_undefined
},
4431 { /* 10, undefined */ 0, state_undefined
},
4432 { /* 11, undefined */ 0, state_undefined
},
4433 { /* 12, undefined */ 0, state_undefined
},
4434 { /* 13, undefined */ 0, state_undefined
},
4435 { /* 14, undefined */ 0, state_undefined
},
4436 { /* 15, undefined */ 0, state_undefined
},
4437 { /* 16, WINED3DTS_TEXTURE0 */ STATE_TRANSFORM(WINED3DTS_TEXTURE0
), transform_texture
},
4438 { /* 17, WINED3DTS_TEXTURE1 */ STATE_TRANSFORM(WINED3DTS_TEXTURE1
), transform_texture
},
4439 { /* 18, WINED3DTS_TEXTURE2 */ STATE_TRANSFORM(WINED3DTS_TEXTURE2
), transform_texture
},
4440 { /* 19, WINED3DTS_TEXTURE3 */ STATE_TRANSFORM(WINED3DTS_TEXTURE3
), transform_texture
},
4441 { /* 20, WINED3DTS_TEXTURE4 */ STATE_TRANSFORM(WINED3DTS_TEXTURE4
), transform_texture
},
4442 { /* 21, WINED3DTS_TEXTURE5 */ STATE_TRANSFORM(WINED3DTS_TEXTURE5
), transform_texture
},
4443 { /* 22, WINED3DTS_TEXTURE6 */ STATE_TRANSFORM(WINED3DTS_TEXTURE6
), transform_texture
},
4444 { /* 23, WINED3DTS_TEXTURE7 */ STATE_TRANSFORM(WINED3DTS_TEXTURE7
), transform_texture
},
4445 /* A huge gap between TEXTURE7 and WORLDMATRIX(0) :-( But entries are needed to catch then if a broken app sets them */
4446 { /* 24, undefined */ 0, state_undefined
},
4447 { /* 25, undefined */ 0, state_undefined
},
4448 { /* 26, undefined */ 0, state_undefined
},
4449 { /* 27, undefined */ 0, state_undefined
},
4450 { /* 28, undefined */ 0, state_undefined
},
4451 { /* 29, undefined */ 0, state_undefined
},
4452 { /* 30, undefined */ 0, state_undefined
},
4453 { /* 31, undefined */ 0, state_undefined
},
4454 { /* 32, undefined */ 0, state_undefined
},
4455 { /* 33, undefined */ 0, state_undefined
},
4456 { /* 34, undefined */ 0, state_undefined
},
4457 { /* 35, undefined */ 0, state_undefined
},
4458 { /* 36, undefined */ 0, state_undefined
},
4459 { /* 37, undefined */ 0, state_undefined
},
4460 { /* 38, undefined */ 0, state_undefined
},
4461 { /* 39, undefined */ 0, state_undefined
},
4462 { /* 40, undefined */ 0, state_undefined
},
4463 { /* 41, undefined */ 0, state_undefined
},
4464 { /* 42, undefined */ 0, state_undefined
},
4465 { /* 43, undefined */ 0, state_undefined
},
4466 { /* 44, undefined */ 0, state_undefined
},
4467 { /* 45, undefined */ 0, state_undefined
},
4468 { /* 46, undefined */ 0, state_undefined
},
4469 { /* 47, undefined */ 0, state_undefined
},
4470 { /* 48, undefined */ 0, state_undefined
},
4471 { /* 49, undefined */ 0, state_undefined
},
4472 { /* 50, undefined */ 0, state_undefined
},
4473 { /* 51, undefined */ 0, state_undefined
},
4474 { /* 52, undefined */ 0, state_undefined
},
4475 { /* 53, undefined */ 0, state_undefined
},
4476 { /* 54, undefined */ 0, state_undefined
},
4477 { /* 55, undefined */ 0, state_undefined
},
4478 { /* 56, undefined */ 0, state_undefined
},
4479 { /* 57, undefined */ 0, state_undefined
},
4480 { /* 58, undefined */ 0, state_undefined
},
4481 { /* 59, undefined */ 0, state_undefined
},
4482 { /* 60, undefined */ 0, state_undefined
},
4483 { /* 61, undefined */ 0, state_undefined
},
4484 { /* 62, undefined */ 0, state_undefined
},
4485 { /* 63, undefined */ 0, state_undefined
},
4486 { /* 64, undefined */ 0, state_undefined
},
4487 { /* 65, undefined */ 0, state_undefined
},
4488 { /* 66, undefined */ 0, state_undefined
},
4489 { /* 67, undefined */ 0, state_undefined
},
4490 { /* 68, undefined */ 0, state_undefined
},
4491 { /* 69, undefined */ 0, state_undefined
},
4492 { /* 70, undefined */ 0, state_undefined
},
4493 { /* 71, undefined */ 0, state_undefined
},
4494 { /* 72, undefined */ 0, state_undefined
},
4495 { /* 73, undefined */ 0, state_undefined
},
4496 { /* 74, undefined */ 0, state_undefined
},
4497 { /* 75, undefined */ 0, state_undefined
},
4498 { /* 76, undefined */ 0, state_undefined
},
4499 { /* 77, undefined */ 0, state_undefined
},
4500 { /* 78, undefined */ 0, state_undefined
},
4501 { /* 79, undefined */ 0, state_undefined
},
4502 { /* 80, undefined */ 0, state_undefined
},
4503 { /* 81, undefined */ 0, state_undefined
},
4504 { /* 82, undefined */ 0, state_undefined
},
4505 { /* 83, undefined */ 0, state_undefined
},
4506 { /* 84, undefined */ 0, state_undefined
},
4507 { /* 85, undefined */ 0, state_undefined
},
4508 { /* 86, undefined */ 0, state_undefined
},
4509 { /* 87, undefined */ 0, state_undefined
},
4510 { /* 88, undefined */ 0, state_undefined
},
4511 { /* 89, undefined */ 0, state_undefined
},
4512 { /* 90, undefined */ 0, state_undefined
},
4513 { /* 91, undefined */ 0, state_undefined
},
4514 { /* 92, undefined */ 0, state_undefined
},
4515 { /* 93, undefined */ 0, state_undefined
},
4516 { /* 94, undefined */ 0, state_undefined
},
4517 { /* 95, undefined */ 0, state_undefined
},
4518 { /* 96, undefined */ 0, state_undefined
},
4519 { /* 97, undefined */ 0, state_undefined
},
4520 { /* 98, undefined */ 0, state_undefined
},
4521 { /* 99, undefined */ 0, state_undefined
},
4522 { /*100, undefined */ 0, state_undefined
},
4523 { /*101, undefined */ 0, state_undefined
},
4524 { /*102, undefined */ 0, state_undefined
},
4525 { /*103, undefined */ 0, state_undefined
},
4526 { /*104, undefined */ 0, state_undefined
},
4527 { /*105, undefined */ 0, state_undefined
},
4528 { /*106, undefined */ 0, state_undefined
},
4529 { /*107, undefined */ 0, state_undefined
},
4530 { /*108, undefined */ 0, state_undefined
},
4531 { /*109, undefined */ 0, state_undefined
},
4532 { /*110, undefined */ 0, state_undefined
},
4533 { /*111, undefined */ 0, state_undefined
},
4534 { /*112, undefined */ 0, state_undefined
},
4535 { /*113, undefined */ 0, state_undefined
},
4536 { /*114, undefined */ 0, state_undefined
},
4537 { /*115, undefined */ 0, state_undefined
},
4538 { /*116, undefined */ 0, state_undefined
},
4539 { /*117, undefined */ 0, state_undefined
},
4540 { /*118, undefined */ 0, state_undefined
},
4541 { /*119, undefined */ 0, state_undefined
},
4542 { /*120, undefined */ 0, state_undefined
},
4543 { /*121, undefined */ 0, state_undefined
},
4544 { /*122, undefined */ 0, state_undefined
},
4545 { /*123, undefined */ 0, state_undefined
},
4546 { /*124, undefined */ 0, state_undefined
},
4547 { /*125, undefined */ 0, state_undefined
},
4548 { /*126, undefined */ 0, state_undefined
},
4549 { /*127, undefined */ 0, state_undefined
},
4550 { /*128, undefined */ 0, state_undefined
},
4551 { /*129, undefined */ 0, state_undefined
},
4552 { /*130, undefined */ 0, state_undefined
},
4553 { /*131, undefined */ 0, state_undefined
},
4554 { /*132, undefined */ 0, state_undefined
},
4555 { /*133, undefined */ 0, state_undefined
},
4556 { /*134, undefined */ 0, state_undefined
},
4557 { /*135, undefined */ 0, state_undefined
},
4558 { /*136, undefined */ 0, state_undefined
},
4559 { /*137, undefined */ 0, state_undefined
},
4560 { /*138, undefined */ 0, state_undefined
},
4561 { /*139, undefined */ 0, state_undefined
},
4562 { /*140, undefined */ 0, state_undefined
},
4563 { /*141, undefined */ 0, state_undefined
},
4564 { /*142, undefined */ 0, state_undefined
},
4565 { /*143, undefined */ 0, state_undefined
},
4566 { /*144, undefined */ 0, state_undefined
},
4567 { /*145, undefined */ 0, state_undefined
},
4568 { /*146, undefined */ 0, state_undefined
},
4569 { /*147, undefined */ 0, state_undefined
},
4570 { /*148, undefined */ 0, state_undefined
},
4571 { /*149, undefined */ 0, state_undefined
},
4572 { /*150, undefined */ 0, state_undefined
},
4573 { /*151, undefined */ 0, state_undefined
},
4574 { /*152, undefined */ 0, state_undefined
},
4575 { /*153, undefined */ 0, state_undefined
},
4576 { /*154, undefined */ 0, state_undefined
},
4577 { /*155, undefined */ 0, state_undefined
},
4578 { /*156, undefined */ 0, state_undefined
},
4579 { /*157, undefined */ 0, state_undefined
},
4580 { /*158, undefined */ 0, state_undefined
},
4581 { /*159, undefined */ 0, state_undefined
},
4582 { /*160, undefined */ 0, state_undefined
},
4583 { /*161, undefined */ 0, state_undefined
},
4584 { /*162, undefined */ 0, state_undefined
},
4585 { /*163, undefined */ 0, state_undefined
},
4586 { /*164, undefined */ 0, state_undefined
},
4587 { /*165, undefined */ 0, state_undefined
},
4588 { /*166, undefined */ 0, state_undefined
},
4589 { /*167, undefined */ 0, state_undefined
},
4590 { /*168, undefined */ 0, state_undefined
},
4591 { /*169, undefined */ 0, state_undefined
},
4592 { /*170, undefined */ 0, state_undefined
},
4593 { /*171, undefined */ 0, state_undefined
},
4594 { /*172, undefined */ 0, state_undefined
},
4595 { /*173, undefined */ 0, state_undefined
},
4596 { /*174, undefined */ 0, state_undefined
},
4597 { /*175, undefined */ 0, state_undefined
},
4598 { /*176, undefined */ 0, state_undefined
},
4599 { /*177, undefined */ 0, state_undefined
},
4600 { /*178, undefined */ 0, state_undefined
},
4601 { /*179, undefined */ 0, state_undefined
},
4602 { /*180, undefined */ 0, state_undefined
},
4603 { /*181, undefined */ 0, state_undefined
},
4604 { /*182, undefined */ 0, state_undefined
},
4605 { /*183, undefined */ 0, state_undefined
},
4606 { /*184, undefined */ 0, state_undefined
},
4607 { /*185, undefined */ 0, state_undefined
},
4608 { /*186, undefined */ 0, state_undefined
},
4609 { /*187, undefined */ 0, state_undefined
},
4610 { /*188, undefined */ 0, state_undefined
},
4611 { /*189, undefined */ 0, state_undefined
},
4612 { /*190, undefined */ 0, state_undefined
},
4613 { /*191, undefined */ 0, state_undefined
},
4614 { /*192, undefined */ 0, state_undefined
},
4615 { /*193, undefined */ 0, state_undefined
},
4616 { /*194, undefined */ 0, state_undefined
},
4617 { /*195, undefined */ 0, state_undefined
},
4618 { /*196, undefined */ 0, state_undefined
},
4619 { /*197, undefined */ 0, state_undefined
},
4620 { /*198, undefined */ 0, state_undefined
},
4621 { /*199, undefined */ 0, state_undefined
},
4622 { /*200, undefined */ 0, state_undefined
},
4623 { /*201, undefined */ 0, state_undefined
},
4624 { /*202, undefined */ 0, state_undefined
},
4625 { /*203, undefined */ 0, state_undefined
},
4626 { /*204, undefined */ 0, state_undefined
},
4627 { /*205, undefined */ 0, state_undefined
},
4628 { /*206, undefined */ 0, state_undefined
},
4629 { /*207, undefined */ 0, state_undefined
},
4630 { /*208, undefined */ 0, state_undefined
},
4631 { /*209, undefined */ 0, state_undefined
},
4632 { /*210, undefined */ 0, state_undefined
},
4633 { /*211, undefined */ 0, state_undefined
},
4634 { /*212, undefined */ 0, state_undefined
},
4635 { /*213, undefined */ 0, state_undefined
},
4636 { /*214, undefined */ 0, state_undefined
},
4637 { /*215, undefined */ 0, state_undefined
},
4638 { /*216, undefined */ 0, state_undefined
},
4639 { /*217, undefined */ 0, state_undefined
},
4640 { /*218, undefined */ 0, state_undefined
},
4641 { /*219, undefined */ 0, state_undefined
},
4642 { /*220, undefined */ 0, state_undefined
},
4643 { /*221, undefined */ 0, state_undefined
},
4644 { /*222, undefined */ 0, state_undefined
},
4645 { /*223, undefined */ 0, state_undefined
},
4646 { /*224, undefined */ 0, state_undefined
},
4647 { /*225, undefined */ 0, state_undefined
},
4648 { /*226, undefined */ 0, state_undefined
},
4649 { /*227, undefined */ 0, state_undefined
},
4650 { /*228, undefined */ 0, state_undefined
},
4651 { /*229, undefined */ 0, state_undefined
},
4652 { /*230, undefined */ 0, state_undefined
},
4653 { /*231, undefined */ 0, state_undefined
},
4654 { /*232, undefined */ 0, state_undefined
},
4655 { /*233, undefined */ 0, state_undefined
},
4656 { /*234, undefined */ 0, state_undefined
},
4657 { /*235, undefined */ 0, state_undefined
},
4658 { /*236, undefined */ 0, state_undefined
},
4659 { /*237, undefined */ 0, state_undefined
},
4660 { /*238, undefined */ 0, state_undefined
},
4661 { /*239, undefined */ 0, state_undefined
},
4662 { /*240, undefined */ 0, state_undefined
},
4663 { /*241, undefined */ 0, state_undefined
},
4664 { /*242, undefined */ 0, state_undefined
},
4665 { /*243, undefined */ 0, state_undefined
},
4666 { /*244, undefined */ 0, state_undefined
},
4667 { /*245, undefined */ 0, state_undefined
},
4668 { /*246, undefined */ 0, state_undefined
},
4669 { /*247, undefined */ 0, state_undefined
},
4670 { /*248, undefined */ 0, state_undefined
},
4671 { /*249, undefined */ 0, state_undefined
},
4672 { /*250, undefined */ 0, state_undefined
},
4673 { /*251, undefined */ 0, state_undefined
},
4674 { /*252, undefined */ 0, state_undefined
},
4675 { /*253, undefined */ 0, state_undefined
},
4676 { /*254, undefined */ 0, state_undefined
},
4677 { /*255, undefined */ 0, state_undefined
},
4679 { /*256, WINED3DTS_WORLDMATRIX(0) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), transform_world
},
4680 { /*257, WINED3DTS_WORLDMATRIX(1) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(1)), transform_worldex
},
4681 { /*258, WINED3DTS_WORLDMATRIX(2) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(2)), transform_worldex
},
4682 { /*259, WINED3DTS_WORLDMATRIX(3) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(3)), transform_worldex
},
4683 { /*260, WINED3DTS_WORLDMATRIX(4) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(4)), transform_worldex
},
4684 { /*261, WINED3DTS_WORLDMATRIX(5) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(5)), transform_worldex
},
4685 { /*262, WINED3DTS_WORLDMATRIX(6) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(6)), transform_worldex
},
4686 { /*263, WINED3DTS_WORLDMATRIX(7) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(7)), transform_worldex
},
4687 { /*264, WINED3DTS_WORLDMATRIX(8) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(8)), transform_worldex
},
4688 { /*265, WINED3DTS_WORLDMATRIX(9) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(9)), transform_worldex
},
4689 { /*266, WINED3DTS_WORLDMATRIX(10) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(10)), transform_worldex
},
4690 { /*267, WINED3DTS_WORLDMATRIX(11) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(11)), transform_worldex
},
4691 { /*268, WINED3DTS_WORLDMATRIX(12) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(12)), transform_worldex
},
4692 { /*269, WINED3DTS_WORLDMATRIX(13) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(13)), transform_worldex
},
4693 { /*270, WINED3DTS_WORLDMATRIX(14) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(14)), transform_worldex
},
4694 { /*271, WINED3DTS_WORLDMATRIX(15) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(15)), transform_worldex
},
4695 { /*272, WINED3DTS_WORLDMATRIX(16) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(16)), transform_worldex
},
4696 { /*273, WINED3DTS_WORLDMATRIX(17) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(17)), transform_worldex
},
4697 { /*274, WINED3DTS_WORLDMATRIX(18) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(18)), transform_worldex
},
4698 { /*275, WINED3DTS_WORLDMATRIX(19) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(19)), transform_worldex
},
4699 { /*276, WINED3DTS_WORLDMATRIX(20) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(20)), transform_worldex
},
4700 { /*277, WINED3DTS_WORLDMATRIX(21) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(21)), transform_worldex
},
4701 { /*278, WINED3DTS_WORLDMATRIX(22) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(22)), transform_worldex
},
4702 { /*279, WINED3DTS_WORLDMATRIX(23) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(23)), transform_worldex
},
4703 { /*280, WINED3DTS_WORLDMATRIX(24) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(24)), transform_worldex
},
4704 { /*281, WINED3DTS_WORLDMATRIX(25) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(25)), transform_worldex
},
4705 { /*282, WINED3DTS_WORLDMATRIX(26) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(26)), transform_worldex
},
4706 { /*283, WINED3DTS_WORLDMATRIX(27) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(27)), transform_worldex
},
4707 { /*284, WINED3DTS_WORLDMATRIX(28) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(28)), transform_worldex
},
4708 { /*285, WINED3DTS_WORLDMATRIX(29) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(29)), transform_worldex
},
4709 { /*286, WINED3DTS_WORLDMATRIX(30) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(30)), transform_worldex
},
4710 { /*287, WINED3DTS_WORLDMATRIX(31) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(31)), transform_worldex
},
4711 { /*288, WINED3DTS_WORLDMATRIX(32) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(32)), transform_worldex
},
4712 { /*289, WINED3DTS_WORLDMATRIX(33) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(33)), transform_worldex
},
4713 { /*290, WINED3DTS_WORLDMATRIX(34) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(34)), transform_worldex
},
4714 { /*291, WINED3DTS_WORLDMATRIX(35) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(35)), transform_worldex
},
4715 { /*292, WINED3DTS_WORLDMATRIX(36) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(36)), transform_worldex
},
4716 { /*293, WINED3DTS_WORLDMATRIX(37) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(37)), transform_worldex
},
4717 { /*294, WINED3DTS_WORLDMATRIX(38) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(38)), transform_worldex
},
4718 { /*295, WINED3DTS_WORLDMATRIX(39) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(39)), transform_worldex
},
4719 { /*296, WINED3DTS_WORLDMATRIX(40) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(40)), transform_worldex
},
4720 { /*297, WINED3DTS_WORLDMATRIX(41) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(41)), transform_worldex
},
4721 { /*298, WINED3DTS_WORLDMATRIX(42) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(42)), transform_worldex
},
4722 { /*299, WINED3DTS_WORLDMATRIX(43) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(43)), transform_worldex
},
4723 { /*300, WINED3DTS_WORLDMATRIX(44) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(44)), transform_worldex
},
4724 { /*301, WINED3DTS_WORLDMATRIX(45) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(45)), transform_worldex
},
4725 { /*302, WINED3DTS_WORLDMATRIX(46) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(46)), transform_worldex
},
4726 { /*303, WINED3DTS_WORLDMATRIX(47) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(47)), transform_worldex
},
4727 { /*304, WINED3DTS_WORLDMATRIX(48) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(48)), transform_worldex
},
4728 { /*305, WINED3DTS_WORLDMATRIX(49) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(49)), transform_worldex
},
4729 { /*306, WINED3DTS_WORLDMATRIX(50) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(50)), transform_worldex
},
4730 { /*307, WINED3DTS_WORLDMATRIX(51) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(51)), transform_worldex
},
4731 { /*308, WINED3DTS_WORLDMATRIX(52) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(52)), transform_worldex
},
4732 { /*309, WINED3DTS_WORLDMATRIX(53) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(53)), transform_worldex
},
4733 { /*310, WINED3DTS_WORLDMATRIX(54) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(54)), transform_worldex
},
4734 { /*311, WINED3DTS_WORLDMATRIX(55) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(55)), transform_worldex
},
4735 { /*312, WINED3DTS_WORLDMATRIX(56) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(56)), transform_worldex
},
4736 { /*313, WINED3DTS_WORLDMATRIX(57) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(57)), transform_worldex
},
4737 { /*314, WINED3DTS_WORLDMATRIX(58) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(58)), transform_worldex
},
4738 { /*315, WINED3DTS_WORLDMATRIX(59) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(59)), transform_worldex
},
4739 { /*316, WINED3DTS_WORLDMATRIX(60) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(60)), transform_worldex
},
4740 { /*317, WINED3DTS_WORLDMATRIX(61) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(61)), transform_worldex
},
4741 { /*318, WINED3DTS_WORLDMATRIX(62) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(62)), transform_worldex
},
4742 { /*319, WINED3DTS_WORLDMATRIX(63) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(63)), transform_worldex
},
4743 { /*320, WINED3DTS_WORLDMATRIX(64) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(64)), transform_worldex
},
4744 { /*321, WINED3DTS_WORLDMATRIX(65) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(65)), transform_worldex
},
4745 { /*322, WINED3DTS_WORLDMATRIX(66) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(66)), transform_worldex
},
4746 { /*323, WINED3DTS_WORLDMATRIX(67) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(67)), transform_worldex
},
4747 { /*324, WINED3DTS_WORLDMATRIX(68) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(68)), transform_worldex
},
4748 { /*325, WINED3DTS_WORLDMATRIX(68) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(69)), transform_worldex
},
4749 { /*326, WINED3DTS_WORLDMATRIX(70) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(70)), transform_worldex
},
4750 { /*327, WINED3DTS_WORLDMATRIX(71) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(71)), transform_worldex
},
4751 { /*328, WINED3DTS_WORLDMATRIX(72) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(72)), transform_worldex
},
4752 { /*329, WINED3DTS_WORLDMATRIX(73) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(73)), transform_worldex
},
4753 { /*330, WINED3DTS_WORLDMATRIX(74) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(74)), transform_worldex
},
4754 { /*331, WINED3DTS_WORLDMATRIX(75) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(75)), transform_worldex
},
4755 { /*332, WINED3DTS_WORLDMATRIX(76) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(76)), transform_worldex
},
4756 { /*333, WINED3DTS_WORLDMATRIX(77) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(77)), transform_worldex
},
4757 { /*334, WINED3DTS_WORLDMATRIX(78) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(78)), transform_worldex
},
4758 { /*335, WINED3DTS_WORLDMATRIX(79) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(79)), transform_worldex
},
4759 { /*336, WINED3DTS_WORLDMATRIX(80) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(80)), transform_worldex
},
4760 { /*337, WINED3DTS_WORLDMATRIX(81) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(81)), transform_worldex
},
4761 { /*338, WINED3DTS_WORLDMATRIX(82) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(82)), transform_worldex
},
4762 { /*339, WINED3DTS_WORLDMATRIX(83) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(83)), transform_worldex
},
4763 { /*340, WINED3DTS_WORLDMATRIX(84) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(84)), transform_worldex
},
4764 { /*341, WINED3DTS_WORLDMATRIX(85) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(85)), transform_worldex
},
4765 { /*341, WINED3DTS_WORLDMATRIX(86) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(86)), transform_worldex
},
4766 { /*343, WINED3DTS_WORLDMATRIX(87) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(87)), transform_worldex
},
4767 { /*344, WINED3DTS_WORLDMATRIX(88) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(88)), transform_worldex
},
4768 { /*345, WINED3DTS_WORLDMATRIX(89) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(89)), transform_worldex
},
4769 { /*346, WINED3DTS_WORLDMATRIX(90) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(90)), transform_worldex
},
4770 { /*347, WINED3DTS_WORLDMATRIX(91) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(91)), transform_worldex
},
4771 { /*348, WINED3DTS_WORLDMATRIX(92) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(92)), transform_worldex
},
4772 { /*349, WINED3DTS_WORLDMATRIX(93) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(93)), transform_worldex
},
4773 { /*350, WINED3DTS_WORLDMATRIX(94) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(94)), transform_worldex
},
4774 { /*351, WINED3DTS_WORLDMATRIX(95) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(95)), transform_worldex
},
4775 { /*352, WINED3DTS_WORLDMATRIX(96) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(96)), transform_worldex
},
4776 { /*353, WINED3DTS_WORLDMATRIX(97) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(97)), transform_worldex
},
4777 { /*354, WINED3DTS_WORLDMATRIX(98) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(98)), transform_worldex
},
4778 { /*355, WINED3DTS_WORLDMATRIX(99) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(99)), transform_worldex
},
4779 { /*356, WINED3DTS_WORLDMATRIX(100) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(100)), transform_worldex
},
4780 { /*357, WINED3DTS_WORLDMATRIX(101) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(101)), transform_worldex
},
4781 { /*358, WINED3DTS_WORLDMATRIX(102) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(102)), transform_worldex
},
4782 { /*359, WINED3DTS_WORLDMATRIX(103) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(103)), transform_worldex
},
4783 { /*360, WINED3DTS_WORLDMATRIX(104) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(104)), transform_worldex
},
4784 { /*361, WINED3DTS_WORLDMATRIX(105) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(105)), transform_worldex
},
4785 { /*362, WINED3DTS_WORLDMATRIX(106) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(106)), transform_worldex
},
4786 { /*363, WINED3DTS_WORLDMATRIX(107) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(107)), transform_worldex
},
4787 { /*364, WINED3DTS_WORLDMATRIX(108) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(108)), transform_worldex
},
4788 { /*365, WINED3DTS_WORLDMATRIX(109) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(109)), transform_worldex
},
4789 { /*366, WINED3DTS_WORLDMATRIX(110) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(110)), transform_worldex
},
4790 { /*367, WINED3DTS_WORLDMATRIX(111) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(111)), transform_worldex
},
4791 { /*368, WINED3DTS_WORLDMATRIX(112) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(112)), transform_worldex
},
4792 { /*369, WINED3DTS_WORLDMATRIX(113) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(113)), transform_worldex
},
4793 { /*370, WINED3DTS_WORLDMATRIX(114) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(114)), transform_worldex
},
4794 { /*371, WINED3DTS_WORLDMATRIX(115) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(115)), transform_worldex
},
4795 { /*372, WINED3DTS_WORLDMATRIX(116) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(116)), transform_worldex
},
4796 { /*373, WINED3DTS_WORLDMATRIX(117) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(117)), transform_worldex
},
4797 { /*374, WINED3DTS_WORLDMATRIX(118) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(118)), transform_worldex
},
4798 { /*375, WINED3DTS_WORLDMATRIX(119) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(119)), transform_worldex
},
4799 { /*376, WINED3DTS_WORLDMATRIX(120) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(120)), transform_worldex
},
4800 { /*377, WINED3DTS_WORLDMATRIX(121) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(121)), transform_worldex
},
4801 { /*378, WINED3DTS_WORLDMATRIX(122) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(122)), transform_worldex
},
4802 { /*379, WINED3DTS_WORLDMATRIX(123) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(123)), transform_worldex
},
4803 { /*380, WINED3DTS_WORLDMATRIX(124) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(124)), transform_worldex
},
4804 { /*381, WINED3DTS_WORLDMATRIX(125) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(125)), transform_worldex
},
4805 { /*382, WINED3DTS_WORLDMATRIX(126) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(126)), transform_worldex
},
4806 { /*383, WINED3DTS_WORLDMATRIX(127) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(127)), transform_worldex
},
4807 { /*384, WINED3DTS_WORLDMATRIX(128) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(128)), transform_worldex
},
4808 { /*385, WINED3DTS_WORLDMATRIX(129) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(129)), transform_worldex
},
4809 { /*386, WINED3DTS_WORLDMATRIX(130) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(130)), transform_worldex
},
4810 { /*387, WINED3DTS_WORLDMATRIX(131) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(131)), transform_worldex
},
4811 { /*388, WINED3DTS_WORLDMATRIX(132) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(132)), transform_worldex
},
4812 { /*389, WINED3DTS_WORLDMATRIX(133) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(133)), transform_worldex
},
4813 { /*390, WINED3DTS_WORLDMATRIX(134) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(134)), transform_worldex
},
4814 { /*391, WINED3DTS_WORLDMATRIX(135) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(135)), transform_worldex
},
4815 { /*392, WINED3DTS_WORLDMATRIX(136) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(136)), transform_worldex
},
4816 { /*393, WINED3DTS_WORLDMATRIX(137) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(137)), transform_worldex
},
4817 { /*394, WINED3DTS_WORLDMATRIX(138) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(138)), transform_worldex
},
4818 { /*395, WINED3DTS_WORLDMATRIX(139) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(139)), transform_worldex
},
4819 { /*396, WINED3DTS_WORLDMATRIX(140) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(140)), transform_worldex
},
4820 { /*397, WINED3DTS_WORLDMATRIX(141) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(141)), transform_worldex
},
4821 { /*398, WINED3DTS_WORLDMATRIX(142) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(142)), transform_worldex
},
4822 { /*399, WINED3DTS_WORLDMATRIX(143) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(143)), transform_worldex
},
4823 { /*400, WINED3DTS_WORLDMATRIX(144) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(144)), transform_worldex
},
4824 { /*401, WINED3DTS_WORLDMATRIX(145) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(145)), transform_worldex
},
4825 { /*402, WINED3DTS_WORLDMATRIX(146) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(146)), transform_worldex
},
4826 { /*403, WINED3DTS_WORLDMATRIX(147) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(147)), transform_worldex
},
4827 { /*404, WINED3DTS_WORLDMATRIX(148) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(148)), transform_worldex
},
4828 { /*405, WINED3DTS_WORLDMATRIX(149) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(149)), transform_worldex
},
4829 { /*406, WINED3DTS_WORLDMATRIX(150) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(150)), transform_worldex
},
4830 { /*407, WINED3DTS_WORLDMATRIX(151) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(151)), transform_worldex
},
4831 { /*408, WINED3DTS_WORLDMATRIX(152) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(152)), transform_worldex
},
4832 { /*409, WINED3DTS_WORLDMATRIX(153) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(153)), transform_worldex
},
4833 { /*410, WINED3DTS_WORLDMATRIX(154) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(154)), transform_worldex
},
4834 { /*411, WINED3DTS_WORLDMATRIX(155) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(155)), transform_worldex
},
4835 { /*412, WINED3DTS_WORLDMATRIX(156) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(156)), transform_worldex
},
4836 { /*413, WINED3DTS_WORLDMATRIX(157) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(157)), transform_worldex
},
4837 { /*414, WINED3DTS_WORLDMATRIX(158) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(158)), transform_worldex
},
4838 { /*415, WINED3DTS_WORLDMATRIX(159) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(159)), transform_worldex
},
4839 { /*416, WINED3DTS_WORLDMATRIX(160) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(160)), transform_worldex
},
4840 { /*417, WINED3DTS_WORLDMATRIX(161) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(161)), transform_worldex
},
4841 { /*418, WINED3DTS_WORLDMATRIX(162) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(162)), transform_worldex
},
4842 { /*419, WINED3DTS_WORLDMATRIX(163) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(163)), transform_worldex
},
4843 { /*420, WINED3DTS_WORLDMATRIX(164) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(164)), transform_worldex
},
4844 { /*421, WINED3DTS_WORLDMATRIX(165) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(165)), transform_worldex
},
4845 { /*422, WINED3DTS_WORLDMATRIX(166) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(166)), transform_worldex
},
4846 { /*423, WINED3DTS_WORLDMATRIX(167) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(167)), transform_worldex
},
4847 { /*424, WINED3DTS_WORLDMATRIX(168) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(168)), transform_worldex
},
4848 { /*425, WINED3DTS_WORLDMATRIX(168) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(169)), transform_worldex
},
4849 { /*426, WINED3DTS_WORLDMATRIX(170) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(170)), transform_worldex
},
4850 { /*427, WINED3DTS_WORLDMATRIX(171) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(171)), transform_worldex
},
4851 { /*428, WINED3DTS_WORLDMATRIX(172) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(172)), transform_worldex
},
4852 { /*429, WINED3DTS_WORLDMATRIX(173) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(173)), transform_worldex
},
4853 { /*430, WINED3DTS_WORLDMATRIX(174) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(174)), transform_worldex
},
4854 { /*431, WINED3DTS_WORLDMATRIX(175) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(175)), transform_worldex
},
4855 { /*432, WINED3DTS_WORLDMATRIX(176) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(176)), transform_worldex
},
4856 { /*433, WINED3DTS_WORLDMATRIX(177) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(177)), transform_worldex
},
4857 { /*434, WINED3DTS_WORLDMATRIX(178) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(178)), transform_worldex
},
4858 { /*435, WINED3DTS_WORLDMATRIX(179) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(179)), transform_worldex
},
4859 { /*436, WINED3DTS_WORLDMATRIX(180) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(180)), transform_worldex
},
4860 { /*437, WINED3DTS_WORLDMATRIX(181) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(181)), transform_worldex
},
4861 { /*438, WINED3DTS_WORLDMATRIX(182) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(182)), transform_worldex
},
4862 { /*439, WINED3DTS_WORLDMATRIX(183) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(183)), transform_worldex
},
4863 { /*440, WINED3DTS_WORLDMATRIX(184) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(184)), transform_worldex
},
4864 { /*441, WINED3DTS_WORLDMATRIX(185) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(185)), transform_worldex
},
4865 { /*441, WINED3DTS_WORLDMATRIX(186) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(186)), transform_worldex
},
4866 { /*443, WINED3DTS_WORLDMATRIX(187) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(187)), transform_worldex
},
4867 { /*444, WINED3DTS_WORLDMATRIX(188) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(188)), transform_worldex
},
4868 { /*445, WINED3DTS_WORLDMATRIX(189) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(189)), transform_worldex
},
4869 { /*446, WINED3DTS_WORLDMATRIX(190) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(190)), transform_worldex
},
4870 { /*447, WINED3DTS_WORLDMATRIX(191) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(191)), transform_worldex
},
4871 { /*448, WINED3DTS_WORLDMATRIX(192) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(192)), transform_worldex
},
4872 { /*449, WINED3DTS_WORLDMATRIX(193) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(193)), transform_worldex
},
4873 { /*450, WINED3DTS_WORLDMATRIX(194) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(194)), transform_worldex
},
4874 { /*451, WINED3DTS_WORLDMATRIX(195) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(195)), transform_worldex
},
4875 { /*452, WINED3DTS_WORLDMATRIX(196) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(196)), transform_worldex
},
4876 { /*453, WINED3DTS_WORLDMATRIX(197) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(197)), transform_worldex
},
4877 { /*454, WINED3DTS_WORLDMATRIX(198) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(198)), transform_worldex
},
4878 { /*455, WINED3DTS_WORLDMATRIX(199) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(199)), transform_worldex
},
4879 { /*356, WINED3DTS_WORLDMATRIX(200) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(200)), transform_worldex
},
4880 { /*457, WINED3DTS_WORLDMATRIX(201) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(201)), transform_worldex
},
4881 { /*458, WINED3DTS_WORLDMATRIX(202) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(202)), transform_worldex
},
4882 { /*459, WINED3DTS_WORLDMATRIX(203) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(203)), transform_worldex
},
4883 { /*460, WINED3DTS_WORLDMATRIX(204) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(204)), transform_worldex
},
4884 { /*461, WINED3DTS_WORLDMATRIX(205) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(205)), transform_worldex
},
4885 { /*462, WINED3DTS_WORLDMATRIX(206) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(206)), transform_worldex
},
4886 { /*463, WINED3DTS_WORLDMATRIX(207) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(207)), transform_worldex
},
4887 { /*464, WINED3DTS_WORLDMATRIX(208) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(208)), transform_worldex
},
4888 { /*465, WINED3DTS_WORLDMATRIX(209) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(209)), transform_worldex
},
4889 { /*466, WINED3DTS_WORLDMATRIX(210) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(210)), transform_worldex
},
4890 { /*467, WINED3DTS_WORLDMATRIX(211) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(211)), transform_worldex
},
4891 { /*468, WINED3DTS_WORLDMATRIX(212) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(212)), transform_worldex
},
4892 { /*469, WINED3DTS_WORLDMATRIX(213) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(213)), transform_worldex
},
4893 { /*470, WINED3DTS_WORLDMATRIX(214) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(214)), transform_worldex
},
4894 { /*471, WINED3DTS_WORLDMATRIX(215) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(215)), transform_worldex
},
4895 { /*472, WINED3DTS_WORLDMATRIX(216) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(216)), transform_worldex
},
4896 { /*473, WINED3DTS_WORLDMATRIX(217) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(217)), transform_worldex
},
4897 { /*474, WINED3DTS_WORLDMATRIX(218) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(218)), transform_worldex
},
4898 { /*475, WINED3DTS_WORLDMATRIX(219) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(219)), transform_worldex
},
4899 { /*476, WINED3DTS_WORLDMATRIX(220) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(220)), transform_worldex
},
4900 { /*477, WINED3DTS_WORLDMATRIX(221) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(221)), transform_worldex
},
4901 { /*478, WINED3DTS_WORLDMATRIX(222) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(222)), transform_worldex
},
4902 { /*479, WINED3DTS_WORLDMATRIX(223) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(223)), transform_worldex
},
4903 { /*480, WINED3DTS_WORLDMATRIX(224) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(224)), transform_worldex
},
4904 { /*481, WINED3DTS_WORLDMATRIX(225) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(225)), transform_worldex
},
4905 { /*482, WINED3DTS_WORLDMATRIX(226) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(226)), transform_worldex
},
4906 { /*483, WINED3DTS_WORLDMATRIX(227) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(227)), transform_worldex
},
4907 { /*484, WINED3DTS_WORLDMATRIX(228) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(228)), transform_worldex
},
4908 { /*485, WINED3DTS_WORLDMATRIX(229) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(229)), transform_worldex
},
4909 { /*486, WINED3DTS_WORLDMATRIX(230) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(230)), transform_worldex
},
4910 { /*487, WINED3DTS_WORLDMATRIX(231) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(231)), transform_worldex
},
4911 { /*488, WINED3DTS_WORLDMATRIX(232) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(232)), transform_worldex
},
4912 { /*489, WINED3DTS_WORLDMATRIX(233) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(233)), transform_worldex
},
4913 { /*490, WINED3DTS_WORLDMATRIX(234) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(234)), transform_worldex
},
4914 { /*491, WINED3DTS_WORLDMATRIX(235) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(235)), transform_worldex
},
4915 { /*492, WINED3DTS_WORLDMATRIX(236) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(236)), transform_worldex
},
4916 { /*493, WINED3DTS_WORLDMATRIX(237) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(237)), transform_worldex
},
4917 { /*494, WINED3DTS_WORLDMATRIX(238) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(238)), transform_worldex
},
4918 { /*495, WINED3DTS_WORLDMATRIX(239) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(239)), transform_worldex
},
4919 { /*496, WINED3DTS_WORLDMATRIX(240) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(240)), transform_worldex
},
4920 { /*497, WINED3DTS_WORLDMATRIX(241) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(241)), transform_worldex
},
4921 { /*498, WINED3DTS_WORLDMATRIX(242) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(242)), transform_worldex
},
4922 { /*499, WINED3DTS_WORLDMATRIX(243) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(243)), transform_worldex
},
4923 { /*500, WINED3DTS_WORLDMATRIX(244) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(244)), transform_worldex
},
4924 { /*501, WINED3DTS_WORLDMATRIX(245) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(245)), transform_worldex
},
4925 { /*502, WINED3DTS_WORLDMATRIX(246) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(246)), transform_worldex
},
4926 { /*503, WINED3DTS_WORLDMATRIX(247) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(247)), transform_worldex
},
4927 { /*504, WINED3DTS_WORLDMATRIX(248) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(248)), transform_worldex
},
4928 { /*505, WINED3DTS_WORLDMATRIX(249) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(249)), transform_worldex
},
4929 { /*506, WINED3DTS_WORLDMATRIX(250) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(250)), transform_worldex
},
4930 { /*507, WINED3DTS_WORLDMATRIX(251) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(251)), transform_worldex
},
4931 { /*508, WINED3DTS_WORLDMATRIX(252) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(252)), transform_worldex
},
4932 { /*509, WINED3DTS_WORLDMATRIX(253) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(253)), transform_worldex
},
4933 { /*510, WINED3DTS_WORLDMATRIX(254) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(254)), transform_worldex
},
4934 { /*511, WINED3DTS_WORLDMATRIX(255) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(255)), transform_worldex
},
4935 /* Various Vertex states follow */
4936 { /* , STATE_STREAMSRC */ STATE_VDECL
, vertexdeclaration
},
4937 { /* , STATE_INDEXBUFFER */ STATE_INDEXBUFFER
, indexbuffer
},
4938 { /* , STATE_VDECL */ STATE_VDECL
, vertexdeclaration
},
4939 { /* , STATE_VSHADER */ STATE_VDECL
, vertexdeclaration
},
4940 { /* , STATE_VIEWPORT */ STATE_VIEWPORT
, viewport
},
4941 { /* , STATE_VERTEXSHADERCONSTANT */ STATE_VERTEXSHADERCONSTANT
, shaderconstant
},
4942 { /* , STATE_PIXELSHADERCONSTANT */ STATE_VERTEXSHADERCONSTANT
, shaderconstant
},
4944 { /* , STATE_ACTIVELIGHT(0) */ STATE_ACTIVELIGHT(0), light
},
4945 { /* , STATE_ACTIVELIGHT(1) */ STATE_ACTIVELIGHT(1), light
},
4946 { /* , STATE_ACTIVELIGHT(2) */ STATE_ACTIVELIGHT(2), light
},
4947 { /* , STATE_ACTIVELIGHT(3) */ STATE_ACTIVELIGHT(3), light
},
4948 { /* , STATE_ACTIVELIGHT(4) */ STATE_ACTIVELIGHT(4), light
},
4949 { /* , STATE_ACTIVELIGHT(5) */ STATE_ACTIVELIGHT(5), light
},
4950 { /* , STATE_ACTIVELIGHT(6) */ STATE_ACTIVELIGHT(6), light
},
4951 { /* , STATE_ACTIVELIGHT(7) */ STATE_ACTIVELIGHT(7), light
},
4953 { /* Scissor rect */ STATE_SCISSORRECT
, scissorrect
},
4955 { /* STATE_CLIPPLANE(0) */ STATE_CLIPPLANE(0), clipplane
},
4956 { /* STATE_CLIPPLANE(1) */ STATE_CLIPPLANE(1), clipplane
},
4957 { /* STATE_CLIPPLANE(2) */ STATE_CLIPPLANE(2), clipplane
},
4958 { /* STATE_CLIPPLANE(3) */ STATE_CLIPPLANE(3), clipplane
},
4959 { /* STATE_CLIPPLANE(4) */ STATE_CLIPPLANE(4), clipplane
},
4960 { /* STATE_CLIPPLANE(5) */ STATE_CLIPPLANE(5), clipplane
},
4961 { /* STATE_CLIPPLANE(6) */ STATE_CLIPPLANE(6), clipplane
},
4962 { /* STATE_CLIPPLANE(7) */ STATE_CLIPPLANE(7), clipplane
},
4963 { /* STATE_CLIPPLANE(8) */ STATE_CLIPPLANE(8), clipplane
},
4964 { /* STATE_CLIPPLANE(9) */ STATE_CLIPPLANE(9), clipplane
},
4965 { /* STATE_CLIPPLANE(10) */ STATE_CLIPPLANE(10), clipplane
},
4966 { /* STATE_CLIPPLANE(11) */ STATE_CLIPPLANE(11), clipplane
},
4967 { /* STATE_CLIPPLANE(12) */ STATE_CLIPPLANE(12), clipplane
},
4968 { /* STATE_CLIPPLANE(13) */ STATE_CLIPPLANE(13), clipplane
},
4969 { /* STATE_CLIPPLANE(14) */ STATE_CLIPPLANE(14), clipplane
},
4970 { /* STATE_CLIPPLANE(15) */ STATE_CLIPPLANE(15), clipplane
},
4971 { /* STATE_CLIPPLANE(16) */ STATE_CLIPPLANE(16), clipplane
},
4972 { /* STATE_CLIPPLANE(17) */ STATE_CLIPPLANE(17), clipplane
},
4973 { /* STATE_CLIPPLANE(18) */ STATE_CLIPPLANE(18), clipplane
},
4974 { /* STATE_CLIPPLANE(19) */ STATE_CLIPPLANE(19), clipplane
},
4975 { /* STATE_CLIPPLANE(20) */ STATE_CLIPPLANE(20), clipplane
},
4976 { /* STATE_CLIPPLANE(21) */ STATE_CLIPPLANE(21), clipplane
},
4977 { /* STATE_CLIPPLANE(22) */ STATE_CLIPPLANE(22), clipplane
},
4978 { /* STATE_CLIPPLANE(23) */ STATE_CLIPPLANE(23), clipplane
},
4979 { /* STATE_CLIPPLANE(24) */ STATE_CLIPPLANE(24), clipplane
},
4980 { /* STATE_CLIPPLANE(25) */ STATE_CLIPPLANE(25), clipplane
},
4981 { /* STATE_CLIPPLANE(26) */ STATE_CLIPPLANE(26), clipplane
},
4982 { /* STATE_CLIPPLANE(27) */ STATE_CLIPPLANE(27), clipplane
},
4983 { /* STATE_CLIPPLANE(28) */ STATE_CLIPPLANE(28), clipplane
},
4984 { /* STATE_CLIPPLANE(29) */ STATE_CLIPPLANE(29), clipplane
},
4985 { /* STATE_CLIPPLANE(30) */ STATE_CLIPPLANE(30), clipplane
},
4986 { /* STATE_CLIPPLANE(31) */ STATE_CLIPPLANE(31), clipplane
},
4988 { /* STATE_MATERIAL */ STATE_RENDER(WINED3DRS_SPECULARENABLE
), state_specularenable
},
4989 { /* STATE_FRONTFACE */ STATE_FRONTFACE
, frontface
},