2 * Direct3D state management
4 * Copyright 2006 Stefan Dösinger for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wined3d_private.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
30 #define GLINFO_LOCATION ((IWineD3DImpl *)(stateblock->wineD3DDevice->wineD3D))->gl_info
32 static void state_nogl(DWORD state, IWineD3DStateBlockImpl *stateblock) {
33 /* Used for states which are not mapped to a gl state as-is, but used somehow different,
34 * e.g as a parameter for drawing, or which are unimplemented in windows d3d
36 if(STATE_IS_RENDER(state)) {
37 WINED3DRENDERSTATETYPE RenderState = state - STATE_RENDER(0);
38 TRACE("(%s,%d) no direct mapping to gl\n", debug_d3drenderstate(RenderState), stateblock->renderState[RenderState]);
40 /* Shouldn't have an unknown type here */
41 FIXME("%d no direct mapping to gl of state with unknown type\n", state);
45 static void state_undefined(DWORD state, IWineD3DStateBlockImpl *stateblock) {
46 /* Print a WARN, this allows the stateblock code to loop over all states to generate a display
47 * list without causing confusing terminal output. Deliberately no special debug name here
48 * because its undefined.
50 WARN("undefined state %d\n", state);
53 static void state_fillmode(DWORD state, IWineD3DStateBlockImpl *stateblock) {
54 D3DFILLMODE Value = stateblock->renderState[WINED3DRS_FILLMODE];
58 glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
59 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_POINT)");
61 case D3DFILL_WIREFRAME:
62 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
63 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)");
66 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
67 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)");
70 FIXME("Unrecognized WINED3DRS_FILLMODE value %d\n", Value);
74 static void state_lighting(DWORD state, IWineD3DStateBlockImpl *stateblock) {
77 /* Lighting is only enabled if Vertex normals are passed by the application,
78 * but lighting does not affect the stream sources, so it is not grouped for performance reasons.
79 * This state reads the decoded vertex decl, so if it is dirty don't do anything. The
80 * vertex declaration appplying function calls this function for updating
83 if(isStateDirty(stateblock->wineD3DDevice, STATE_VDECL)) {
87 normals = stateblock->wineD3DDevice->strided_streams.u.s.normal.lpData != NULL ||
88 stateblock->wineD3DDevice->strided_streams.u.s.normal.VBO != 0;
90 if (stateblock->renderState[WINED3DRS_LIGHTING] && normals) {
91 glEnable(GL_LIGHTING);
92 checkGLcall("glEnable GL_LIGHTING");
94 glDisable(GL_LIGHTING);
95 checkGLcall("glDisable GL_LIGHTING");
99 static void state_zenable(DWORD state, IWineD3DStateBlockImpl *stateblock) {
100 switch ((WINED3DZBUFFERTYPE) stateblock->renderState[WINED3DRS_ZENABLE]) {
101 case WINED3DZB_FALSE:
102 glDisable(GL_DEPTH_TEST);
103 checkGLcall("glDisable GL_DEPTH_TEST");
106 glEnable(GL_DEPTH_TEST);
107 checkGLcall("glEnable GL_DEPTH_TEST");
110 glEnable(GL_DEPTH_TEST);
111 checkGLcall("glEnable GL_DEPTH_TEST");
112 FIXME("W buffer is not well handled\n");
115 FIXME("Unrecognized D3DZBUFFERTYPE value %d\n", stateblock->renderState[WINED3DRS_ZENABLE]);
119 static void state_cullmode(DWORD state, IWineD3DStateBlockImpl *stateblock) {
120 /* TODO: Put this into the offscreen / onscreen rendering block due to device->render_offscreen */
122 /* If we are culling "back faces with clockwise vertices" then
123 set front faces to be counter clockwise and enable culling
125 switch ((WINED3DCULL) stateblock->renderState[WINED3DRS_CULLMODE]) {
126 case WINED3DCULL_NONE:
127 glDisable(GL_CULL_FACE);
128 checkGLcall("glDisable GL_CULL_FACE");
131 glEnable(GL_CULL_FACE);
132 checkGLcall("glEnable GL_CULL_FACE");
133 if (stateblock->wineD3DDevice->render_offscreen) {
135 checkGLcall("glFrontFace GL_CW");
138 checkGLcall("glFrontFace GL_CCW");
142 case WINED3DCULL_CCW:
143 glEnable(GL_CULL_FACE);
144 checkGLcall("glEnable GL_CULL_FACE");
145 if (stateblock->wineD3DDevice->render_offscreen) {
147 checkGLcall("glFrontFace GL_CCW");
150 checkGLcall("glFrontFace GL_CW");
155 FIXME("Unrecognized/Unhandled WINED3DCULL value %d\n", stateblock->renderState[WINED3DRS_CULLMODE]);
159 static void state_shademode(DWORD state, IWineD3DStateBlockImpl *stateblock) {
160 switch ((WINED3DSHADEMODE) stateblock->renderState[WINED3DRS_SHADEMODE]) {
161 case WINED3DSHADE_FLAT:
162 glShadeModel(GL_FLAT);
163 checkGLcall("glShadeModel(GL_FLAT)");
165 case WINED3DSHADE_GOURAUD:
166 glShadeModel(GL_SMOOTH);
167 checkGLcall("glShadeModel(GL_SMOOTH)");
169 case WINED3DSHADE_PHONG:
170 FIXME("WINED3DSHADE_PHONG isn't supported\n");
173 FIXME("Unrecognized/Unhandled WINED3DSHADEMODE value %d\n", stateblock->renderState[WINED3DRS_SHADEMODE]);
177 static void state_ditherenable(DWORD state, IWineD3DStateBlockImpl *stateblock) {
178 if (stateblock->renderState[WINED3DRS_DITHERENABLE]) {
180 checkGLcall("glEnable GL_DITHER");
182 glDisable(GL_DITHER);
183 checkGLcall("glDisable GL_DITHER");
187 static void state_zwritenable(DWORD state, IWineD3DStateBlockImpl *stateblock) {
188 /* TODO: Test if in d3d z writing is enabled even if ZENABLE is off. If yes,
189 * this has to be merged with ZENABLE and ZFUNC
191 if (stateblock->renderState[WINED3DRS_ZWRITEENABLE]) {
193 checkGLcall("glDepthMask(1)");
196 checkGLcall("glDepthMask(0)");
200 static void state_zfunc(DWORD state, IWineD3DStateBlockImpl *stateblock) {
201 int glParm = CompareFunc(stateblock->renderState[WINED3DRS_ZFUNC]);
205 checkGLcall("glDepthFunc");
209 static void state_ambient(DWORD state, IWineD3DStateBlockImpl *stateblock) {
211 D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_AMBIENT], col);
213 TRACE("Setting ambient to (%f,%f,%f,%f)\n", col[0], col[1], col[2], col[3]);
214 glLightModelfv(GL_LIGHT_MODEL_AMBIENT, col);
215 checkGLcall("glLightModel for MODEL_AMBIENT");
218 static void state_blend(DWORD state, IWineD3DStateBlockImpl *stateblock) {
219 int srcBlend = GL_ZERO;
220 int dstBlend = GL_ZERO;
222 /* GL_LINE_SMOOTH needs GL_BLEND to work, according to the red book, and special blending params */
223 if (stateblock->renderState[WINED3DRS_ALPHABLENDENABLE] ||
224 stateblock->renderState[WINED3DRS_EDGEANTIALIAS] ||
225 stateblock->renderState[WINED3DRS_ANTIALIASEDLINEENABLE]) {
227 checkGLcall("glEnable GL_BLEND");
230 checkGLcall("glDisable GL_BLEND");
231 /* Nothing more to do - get out */
235 switch (stateblock->renderState[WINED3DRS_SRCBLEND]) {
236 case WINED3DBLEND_ZERO : srcBlend = GL_ZERO; break;
237 case WINED3DBLEND_ONE : srcBlend = GL_ONE; break;
238 case WINED3DBLEND_SRCCOLOR : srcBlend = GL_SRC_COLOR; break;
239 case WINED3DBLEND_INVSRCCOLOR : srcBlend = GL_ONE_MINUS_SRC_COLOR; break;
240 case WINED3DBLEND_SRCALPHA : srcBlend = GL_SRC_ALPHA; break;
241 case WINED3DBLEND_INVSRCALPHA : srcBlend = GL_ONE_MINUS_SRC_ALPHA; break;
242 case WINED3DBLEND_DESTALPHA : srcBlend = GL_DST_ALPHA; break;
243 case WINED3DBLEND_INVDESTALPHA : srcBlend = GL_ONE_MINUS_DST_ALPHA; break;
244 case WINED3DBLEND_DESTCOLOR : srcBlend = GL_DST_COLOR; break;
245 case WINED3DBLEND_INVDESTCOLOR : srcBlend = GL_ONE_MINUS_DST_COLOR; break;
246 case WINED3DBLEND_SRCALPHASAT : srcBlend = GL_SRC_ALPHA_SATURATE; break;
248 case WINED3DBLEND_BOTHSRCALPHA : srcBlend = GL_SRC_ALPHA;
249 dstBlend = GL_SRC_ALPHA;
252 case WINED3DBLEND_BOTHINVSRCALPHA : srcBlend = GL_ONE_MINUS_SRC_ALPHA;
253 dstBlend = GL_ONE_MINUS_SRC_ALPHA;
256 case WINED3DBLEND_BLENDFACTOR : srcBlend = GL_CONSTANT_COLOR; break;
257 case WINED3DBLEND_INVBLENDFACTOR : srcBlend = GL_ONE_MINUS_CONSTANT_COLOR; break;
259 FIXME("Unrecognized src blend value %d\n", stateblock->renderState[WINED3DRS_SRCBLEND]);
262 switch (stateblock->renderState[WINED3DRS_DESTBLEND]) {
263 case WINED3DBLEND_ZERO : dstBlend = GL_ZERO; break;
264 case WINED3DBLEND_ONE : dstBlend = GL_ONE; break;
265 case WINED3DBLEND_SRCCOLOR : dstBlend = GL_SRC_COLOR; break;
266 case WINED3DBLEND_INVSRCCOLOR : dstBlend = GL_ONE_MINUS_SRC_COLOR; break;
267 case WINED3DBLEND_SRCALPHA : dstBlend = GL_SRC_ALPHA; break;
268 case WINED3DBLEND_INVSRCALPHA : dstBlend = GL_ONE_MINUS_SRC_ALPHA; break;
269 case WINED3DBLEND_DESTALPHA : dstBlend = GL_DST_ALPHA; break;
270 case WINED3DBLEND_INVDESTALPHA : dstBlend = GL_ONE_MINUS_DST_ALPHA; break;
271 case WINED3DBLEND_DESTCOLOR : dstBlend = GL_DST_COLOR; break;
272 case WINED3DBLEND_INVDESTCOLOR : dstBlend = GL_ONE_MINUS_DST_COLOR; break;
273 case WINED3DBLEND_SRCALPHASAT : dstBlend = GL_SRC_ALPHA_SATURATE; break;
275 case WINED3DBLEND_BOTHSRCALPHA : dstBlend = GL_SRC_ALPHA;
276 srcBlend = GL_SRC_ALPHA;
279 case WINED3DBLEND_BOTHINVSRCALPHA : dstBlend = GL_ONE_MINUS_SRC_ALPHA;
280 srcBlend = GL_ONE_MINUS_SRC_ALPHA;
283 case D3DBLEND_BLENDFACTOR : dstBlend = GL_CONSTANT_COLOR; break;
284 case D3DBLEND_INVBLENDFACTOR : dstBlend = GL_ONE_MINUS_CONSTANT_COLOR; break;
286 FIXME("Unrecognized dst blend value %d\n", stateblock->renderState[WINED3DRS_DESTBLEND]);
289 if(stateblock->renderState[WINED3DRS_EDGEANTIALIAS] ||
290 stateblock->renderState[WINED3DRS_ANTIALIASEDLINEENABLE]) {
291 glEnable(GL_LINE_SMOOTH);
292 checkGLcall("glEnable(GL_LINE_SMOOTH)");
293 if(srcBlend != GL_SRC_ALPHA) {
294 FIXME("WINED3DRS_EDGEANTIALIAS enabled, but incompatible src blending param - what to do?\n");
295 srcBlend = GL_SRC_ALPHA;
297 if(dstBlend != GL_ONE_MINUS_SRC_ALPHA) {
298 FIXME("WINED3DRS_EDGEANTIALIAS enabled, but incompatible dst blending param - what to do?\n");
299 dstBlend = GL_ONE_MINUS_SRC_ALPHA;
302 glDisable(GL_LINE_SMOOTH);
303 checkGLcall("glDisable(GL_LINE_SMOOTH)");
306 TRACE("glBlendFunc src=%x, dst=%x\n", srcBlend, dstBlend);
307 glBlendFunc(srcBlend, dstBlend);
308 checkGLcall("glBlendFunc");
310 /* TODO: Remove when state management done */
311 stateblock->wineD3DDevice->dstBlend = dstBlend;
312 stateblock->wineD3DDevice->srcBlend = srcBlend;
315 static void state_blendfactor(DWORD state, IWineD3DStateBlockImpl *stateblock) {
318 TRACE("Setting BlendFactor to %d\n", stateblock->renderState[WINED3DRS_BLENDFACTOR]);
319 D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_BLENDFACTOR], col);
320 glBlendColor (col[0],col[1],col[2],col[3]);
321 checkGLcall("glBlendColor");
324 static void state_alpha(DWORD state, IWineD3DStateBlockImpl *stateblock) {
327 BOOL enable_ckey = FALSE;
329 IWineD3DSurfaceImpl *surf;
331 /* Find out if the texture on the first stage has a ckey set
332 * The alpha state func reads the texture settings, even though alpha and texture are not grouped
333 * together. This is to avoid making a huge alpha+texture+texture stage+ckey block due to the hardly
334 * used WINED3DRS_COLORKEYENABLE state(which is d3d <= 3 only). The texture function will call alpha
335 * in case it finds some texture+colorkeyenable combination which needs extra care.
337 if(stateblock->textures[0]) {
338 surf = (IWineD3DSurfaceImpl *) ((IWineD3DTextureImpl *)stateblock->textures[0])->surfaces[0];
339 if(surf->CKeyFlags & DDSD_CKSRCBLT) enable_ckey = TRUE;
342 if (stateblock->renderState[WINED3DRS_ALPHATESTENABLE] ||
343 (stateblock->renderState[WINED3DRS_COLORKEYENABLE] && enable_ckey)) {
344 glEnable(GL_ALPHA_TEST);
345 checkGLcall("glEnable GL_ALPHA_TEST");
347 glDisable(GL_ALPHA_TEST);
348 checkGLcall("glDisable GL_ALPHA_TEST");
349 /* Alpha test is disabled, don't bother setting the params - it will happen on the next
355 if(stateblock->renderState[WINED3DRS_COLORKEYENABLE] && enable_ckey) {
356 glParm = GL_NOTEQUAL;
359 ref = ((float) stateblock->renderState[WINED3DRS_ALPHAREF]) / 255.0f;
360 glParm = CompareFunc(stateblock->renderState[WINED3DRS_ALPHAFUNC]);
363 stateblock->wineD3DDevice->alphafunc = glParm; /* Remove when state management done */
364 glAlphaFunc(glParm, ref);
365 checkGLcall("glAlphaFunc");
367 /* TODO: Some texture blending operations seem to affect the alpha test */
370 static void state_clipping(DWORD state, IWineD3DStateBlockImpl *stateblock) {
371 DWORD enable = 0xFFFFFFFF;
372 DWORD disable = 0x00000000;
374 /* TODO: Keep track of previously enabled clipplanes to avoid unneccessary resetting
375 * of already set values
378 /* If enabling / disabling all
379 * TODO: Is this correct? Doesn't D3DRS_CLIPPING disable clipping on the viewport frustrum?
381 if (stateblock->renderState[WINED3DRS_CLIPPING]) {
382 enable = stateblock->renderState[WINED3DRS_CLIPPLANEENABLE];
383 disable = ~stateblock->renderState[WINED3DRS_CLIPPLANEENABLE];
385 disable = 0xffffffff;
389 if (enable & WINED3DCLIPPLANE0) { glEnable(GL_CLIP_PLANE0); checkGLcall("glEnable(clip plane 0)"); }
390 if (enable & WINED3DCLIPPLANE1) { glEnable(GL_CLIP_PLANE1); checkGLcall("glEnable(clip plane 1)"); }
391 if (enable & WINED3DCLIPPLANE2) { glEnable(GL_CLIP_PLANE2); checkGLcall("glEnable(clip plane 2)"); }
392 if (enable & WINED3DCLIPPLANE3) { glEnable(GL_CLIP_PLANE3); checkGLcall("glEnable(clip plane 3)"); }
393 if (enable & WINED3DCLIPPLANE4) { glEnable(GL_CLIP_PLANE4); checkGLcall("glEnable(clip plane 4)"); }
394 if (enable & WINED3DCLIPPLANE5) { glEnable(GL_CLIP_PLANE5); checkGLcall("glEnable(clip plane 5)"); }
396 if (disable & WINED3DCLIPPLANE0) { glDisable(GL_CLIP_PLANE0); checkGLcall("glDisable(clip plane 0)"); }
397 if (disable & WINED3DCLIPPLANE1) { glDisable(GL_CLIP_PLANE1); checkGLcall("glDisable(clip plane 1)"); }
398 if (disable & WINED3DCLIPPLANE2) { glDisable(GL_CLIP_PLANE2); checkGLcall("glDisable(clip plane 2)"); }
399 if (disable & WINED3DCLIPPLANE3) { glDisable(GL_CLIP_PLANE3); checkGLcall("glDisable(clip plane 3)"); }
400 if (disable & WINED3DCLIPPLANE4) { glDisable(GL_CLIP_PLANE4); checkGLcall("glDisable(clip plane 4)"); }
401 if (disable & WINED3DCLIPPLANE5) { glDisable(GL_CLIP_PLANE5); checkGLcall("glDisable(clip plane 5)"); }
403 /** update clipping status */
405 stateblock->clip_status.ClipUnion = 0;
406 stateblock->clip_status.ClipIntersection = 0xFFFFFFFF;
408 stateblock->clip_status.ClipUnion = 0;
409 stateblock->clip_status.ClipIntersection = 0;
413 static void state_blendop(DWORD state, IWineD3DStateBlockImpl *stateblock) {
414 int glParm = GL_FUNC_ADD;
416 if(!GL_SUPPORT(EXT_BLEND_MINMAX)) {
417 WARN("Unsupported in local OpenGL implementation: glBlendEquation\n");
421 switch ((WINED3DBLENDOP) stateblock->renderState[WINED3DRS_BLENDOP]) {
422 case WINED3DBLENDOP_ADD : glParm = GL_FUNC_ADD; break;
423 case WINED3DBLENDOP_SUBTRACT : glParm = GL_FUNC_SUBTRACT; break;
424 case WINED3DBLENDOP_REVSUBTRACT : glParm = GL_FUNC_REVERSE_SUBTRACT; break;
425 case WINED3DBLENDOP_MIN : glParm = GL_MIN; break;
426 case WINED3DBLENDOP_MAX : glParm = GL_MAX; break;
428 FIXME("Unrecognized/Unhandled D3DBLENDOP value %d\n", stateblock->renderState[WINED3DRS_BLENDOP]);
431 TRACE("glBlendEquation(%x)\n", glParm);
432 GL_EXTCALL(glBlendEquation(glParm));
433 checkGLcall("glBlendEquation");
437 state_specularenable(DWORD state, IWineD3DStateBlockImpl *stateblock) {
438 /* Originally this used glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR)
439 * and (GL_LIGHT_MODEL_COLOR_CONTROL,GL_SINGLE_COLOR) to swap between enabled/disabled
440 * specular color. This is wrong:
441 * Separate specular color means the specular colour is maintained separately, whereas
442 * single color means it is merged in. However in both cases they are being used to
444 * To disable specular color, set it explicitly to black and turn off GL_COLOR_SUM_EXT
445 * NOTE: If not supported don't give FIXMEs the impact is really minimal and very few people are
449 * If register combiners are enabled, enabling / disabling GL_COLOR_SUM has no effect.
450 * Instead, we need to setup the FinalCombiner properly.
452 * The default setup for the FinalCombiner is:
454 * <variable> <input> <mapping> <usage>
455 * GL_VARIABLE_A_NV GL_FOG, GL_UNSIGNED_IDENTITY_NV GL_ALPHA
456 * GL_VARIABLE_B_NV GL_SPARE0_PLUS_SECONDARY_COLOR_NV GL_UNSIGNED_IDENTITY_NV GL_RGB
457 * GL_VARIABLE_C_NV GL_FOG GL_UNSIGNED_IDENTITY_NV GL_RGB
458 * GL_VARIABLE_D_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
459 * GL_VARIABLE_E_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
460 * GL_VARIABLE_F_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
461 * GL_VARIABLE_G_NV GL_SPARE0_NV GL_UNSIGNED_IDENTITY_NV GL_ALPHA
463 * That's pretty much fine as it is, except for variable B, which needs to take
464 * either GL_SPARE0_PLUS_SECONDARY_COLOR_NV or GL_SPARE0_NV, depending on
465 * whether WINED3DRS_SPECULARENABLE is enabled or not.
468 TRACE("Setting specular enable state\n");
469 /* TODO: Add to the material setting functions */
470 if (stateblock->renderState[WINED3DRS_SPECULARENABLE]) {
471 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float*) &stateblock->material.Specular);
472 checkGLcall("glMaterialfv");
473 if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
474 glEnable(GL_COLOR_SUM_EXT);
476 TRACE("Specular colors cannot be enabled in this version of opengl\n");
478 checkGLcall("glEnable(GL_COLOR_SUM)");
480 if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
481 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_SPARE0_PLUS_SECONDARY_COLOR_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB));
482 checkGLcall("glFinalCombinerInputNV()");
485 float black[4] = {0.0f, 0.0f, 0.0f, 0.0f};
487 /* for the case of enabled lighting: */
488 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, &black[0]);
489 checkGLcall("glMaterialfv");
491 /* for the case of disabled lighting: */
492 if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
493 glDisable(GL_COLOR_SUM_EXT);
495 TRACE("Specular colors cannot be disabled in this version of opengl\n");
497 checkGLcall("glDisable(GL_COLOR_SUM)");
499 if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
500 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB));
501 checkGLcall("glFinalCombinerInputNV()");
506 static void state_texfactor(DWORD state, IWineD3DStateBlockImpl *stateblock) {
509 /* Note the texture color applies to all textures whereas
510 * GL_TEXTURE_ENV_COLOR applies to active only
513 D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_TEXTUREFACTOR], col);
515 if (!GL_SUPPORT(NV_REGISTER_COMBINERS)) {
516 /* And now the default texture color as well */
517 for (i = 0; i < GL_LIMITS(texture_stages); i++) {
518 /* Note the WINED3DRS value applies to all textures, but GL has one
519 * per texture, so apply it now ready to be used!
521 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
522 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + i));
523 checkGLcall("glActiveTextureARB");
525 FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
528 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &col[0]);
529 checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);");
532 GL_EXTCALL(glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV, &col[0]));
537 renderstate_stencil_twosided(IWineD3DStateBlockImpl *stateblock, GLint face, GLint func, GLint ref, GLuint mask, GLint stencilFail, GLint depthFail, GLint stencilPass ) {
538 #if 0 /* Don't use OpenGL 2.0 calls for now */
539 if(GL_EXTCALL(glStencilFuncSeparate) && GL_EXTCALL(glStencilOpSeparate)) {
540 GL_EXTCALL(glStencilFuncSeparate(face, func, ref, mask));
541 checkGLcall("glStencilFuncSeparate(...)");
542 GL_EXTCALL(glStencilOpSeparate(face, stencilFail, depthFail, stencilPass));
543 checkGLcall("glStencilOpSeparate(...)");
547 if(GL_SUPPORT(EXT_STENCIL_TWO_SIDE)) {
548 glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT);
549 checkGLcall("glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT)");
550 GL_EXTCALL(glActiveStencilFaceEXT(face));
551 checkGLcall("glActiveStencilFaceEXT(...)");
552 glStencilFunc(func, ref, mask);
553 checkGLcall("glStencilFunc(...)");
554 glStencilOp(stencilFail, depthFail, stencilPass);
555 checkGLcall("glStencilOp(...)");
556 } else if(GL_SUPPORT(ATI_SEPARATE_STENCIL)) {
557 GL_EXTCALL(glStencilFuncSeparateATI(face, func, ref, mask));
558 checkGLcall("glStencilFuncSeparateATI(...)");
559 GL_EXTCALL(glStencilOpSeparateATI(face, stencilFail, depthFail, stencilPass));
560 checkGLcall("glStencilOpSeparateATI(...)");
562 ERR("Separate (two sided) stencil not supported on this version of opengl. Caps weren't honored?\n");
567 state_stencil(DWORD state, IWineD3DStateBlockImpl *stateblock) {
568 DWORD onesided_enable = FALSE;
569 DWORD twosided_enable = FALSE;
570 GLint func = GL_ALWAYS;
571 GLint func_ccw = GL_ALWAYS;
574 GLint stencilFail = GL_KEEP;
575 GLint depthFail = GL_KEEP;
576 GLint stencilPass = GL_KEEP;
577 GLint stencilFail_ccw = GL_KEEP;
578 GLint depthFail_ccw = GL_KEEP;
579 GLint stencilPass_ccw = GL_KEEP;
581 if( stateblock->set.renderState[WINED3DRS_STENCILENABLE] )
582 onesided_enable = stateblock->renderState[WINED3DRS_STENCILENABLE];
583 if( stateblock->set.renderState[WINED3DRS_TWOSIDEDSTENCILMODE] )
584 twosided_enable = stateblock->renderState[WINED3DRS_TWOSIDEDSTENCILMODE];
585 if( stateblock->set.renderState[WINED3DRS_STENCILFUNC] )
586 if( !( func = CompareFunc(stateblock->renderState[WINED3DRS_STENCILFUNC]) ) )
588 if( stateblock->set.renderState[WINED3DRS_CCW_STENCILFUNC] )
589 if( !( func_ccw = CompareFunc(stateblock->renderState[WINED3DRS_CCW_STENCILFUNC]) ) )
591 if( stateblock->set.renderState[WINED3DRS_STENCILREF] )
592 ref = stateblock->renderState[WINED3DRS_STENCILREF];
593 if( stateblock->set.renderState[WINED3DRS_STENCILMASK] )
594 mask = stateblock->renderState[WINED3DRS_STENCILMASK];
595 if( stateblock->set.renderState[WINED3DRS_STENCILFAIL] )
596 stencilFail = StencilOp(stateblock->renderState[WINED3DRS_STENCILFAIL]);
597 if( stateblock->set.renderState[WINED3DRS_STENCILZFAIL] )
598 depthFail = StencilOp(stateblock->renderState[WINED3DRS_STENCILZFAIL]);
599 if( stateblock->set.renderState[WINED3DRS_STENCILPASS] )
600 stencilPass = StencilOp(stateblock->renderState[WINED3DRS_STENCILPASS]);
601 if( stateblock->set.renderState[WINED3DRS_CCW_STENCILFAIL] )
602 stencilFail_ccw = StencilOp(stateblock->renderState[WINED3DRS_CCW_STENCILFAIL]);
603 if( stateblock->set.renderState[WINED3DRS_CCW_STENCILZFAIL] )
604 depthFail_ccw = StencilOp(stateblock->renderState[WINED3DRS_CCW_STENCILZFAIL]);
605 if( stateblock->set.renderState[WINED3DRS_CCW_STENCILPASS] )
606 stencilPass_ccw = StencilOp(stateblock->renderState[WINED3DRS_CCW_STENCILPASS]);
608 TRACE("(onesided %d, twosided %d, ref %x, mask %x, \
609 GL_FRONT: func: %x, fail %x, zfail %x, zpass %x \
610 GL_BACK: func: %x, fail %x, zfail %x, zpass %x )\n",
611 onesided_enable, twosided_enable, ref, mask,
612 func, stencilFail, depthFail, stencilPass,
613 func_ccw, stencilFail_ccw, depthFail_ccw, stencilPass_ccw);
615 if (twosided_enable) {
616 renderstate_stencil_twosided(stateblock, GL_FRONT, func, ref, mask, stencilFail, depthFail, stencilPass);
617 renderstate_stencil_twosided(stateblock, GL_BACK, func_ccw, ref, mask, stencilFail_ccw, depthFail_ccw, stencilPass_ccw);
619 if (onesided_enable) {
620 glEnable(GL_STENCIL_TEST);
621 checkGLcall("glEnable GL_STENCIL_TEST");
622 glStencilFunc(func, ref, mask);
623 checkGLcall("glStencilFunc(...)");
624 glStencilOp(stencilFail, depthFail, stencilPass);
625 checkGLcall("glStencilOp(...)");
627 glDisable(GL_STENCIL_TEST);
628 checkGLcall("glDisable GL_STENCIL_TEST");
633 static void state_stencilwrite(DWORD state, IWineD3DStateBlockImpl *stateblock) {
634 glStencilMask(stateblock->renderState[WINED3DRS_STENCILWRITEMASK]);
635 checkGLcall("glStencilMask");
638 static void state_fog(DWORD state, IWineD3DStateBlockImpl *stateblock) {
639 /* TODO: Put this into the vertex type block once that is in the state table */
640 BOOL fogenable = stateblock->renderState[WINED3DRS_FOGENABLE];
641 float fogstart, fogend;
649 /* No fog? Disable it, and we're done :-) */
651 checkGLcall("glDisable GL_FOG");
654 tmpvalue.d = stateblock->renderState[WINED3DRS_FOGSTART];
655 fogstart = tmpvalue.f;
656 tmpvalue.d = stateblock->renderState[WINED3DRS_FOGEND];
659 /* Activate when vertex shaders are in the state table */
660 if(stateblock->vertexShader && ((IWineD3DVertexShaderImpl *)stateblock->vertexShader)->baseShader.function &&
661 ((IWineD3DVertexShaderImpl *)stateblock->vertexShader)->usesFog) {
662 glFogi(GL_FOG_MODE, GL_LINEAR);
663 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
666 stateblock->wineD3DDevice->last_was_foggy_shader = TRUE;
668 /* DX 7 sdk: "If both render states(vertex and table fog) are set to valid modes,
669 * the system will apply only pixel(=table) fog effects."
671 else if(stateblock->renderState[WINED3DRS_FOGTABLEMODE] == D3DFOG_NONE) {
672 glHint(GL_FOG_HINT, GL_FASTEST);
673 checkGLcall("glHint(GL_FOG_HINT, GL_FASTEST)");
674 stateblock->wineD3DDevice->last_was_foggy_shader = FALSE;
676 switch (stateblock->renderState[WINED3DRS_FOGVERTEXMODE]) {
677 /* Processed vertices have their fog factor stored in the specular value. Fall too the none case.
678 * If we are drawing untransformed vertices atm, d3ddevice_set_ortho will update the fog
681 if(!stateblock->wineD3DDevice->last_was_rhw) {
682 glFogi(GL_FOG_MODE, GL_EXP);
683 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP");
684 if(GL_SUPPORT(EXT_FOG_COORD)) {
685 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
686 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
692 if(!stateblock->wineD3DDevice->last_was_rhw) {
693 glFogi(GL_FOG_MODE, GL_EXP2);
694 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2");
695 if(GL_SUPPORT(EXT_FOG_COORD)) {
696 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
697 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
702 case D3DFOG_LINEAR: {
703 if(!stateblock->wineD3DDevice->last_was_rhw) {
704 glFogi(GL_FOG_MODE, GL_LINEAR);
705 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR");
706 if(GL_SUPPORT(EXT_FOG_COORD)) {
707 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
708 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
714 /* Both are none? According to msdn the alpha channel of the specular
715 * color contains a fog factor. Set it in drawStridedSlow.
716 * Same happens with Vertexfog on transformed vertices
718 if(GL_SUPPORT(EXT_FOG_COORD)) {
719 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);
720 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT)\n");
721 glFogi(GL_FOG_MODE, GL_LINEAR);
722 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
726 /* Disable GL fog, handle this in software in drawStridedSlow */
731 default: FIXME("Unexpected WINED3DRS_FOGVERTEXMODE %d\n", stateblock->renderState[WINED3DRS_FOGVERTEXMODE]);
734 glHint(GL_FOG_HINT, GL_NICEST);
735 checkGLcall("glHint(GL_FOG_HINT, GL_NICEST)");
736 stateblock->wineD3DDevice->last_was_foggy_shader = FALSE;
738 switch (stateblock->renderState[WINED3DRS_FOGTABLEMODE]) {
740 glFogi(GL_FOG_MODE, GL_EXP);
741 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP");
742 if(GL_SUPPORT(EXT_FOG_COORD)) {
743 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
744 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
749 glFogi(GL_FOG_MODE, GL_EXP2);
750 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2");
751 if(GL_SUPPORT(EXT_FOG_COORD)) {
752 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
753 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
758 glFogi(GL_FOG_MODE, GL_LINEAR);
759 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR");
760 if(GL_SUPPORT(EXT_FOG_COORD)) {
761 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
762 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
766 case D3DFOG_NONE: /* Won't happen */
768 FIXME("Unexpected WINED3DRS_FOGTABLEMODE %d\n", stateblock->renderState[WINED3DRS_FOGTABLEMODE]);
774 checkGLcall("glEnable GL_FOG");
776 glFogfv(GL_FOG_START, &fogstart);
777 checkGLcall("glFogf(GL_FOG_START, fogstart");
778 TRACE("Fog Start == %f\n", fogstart);
780 glFogfv(GL_FOG_END, &fogend);
781 checkGLcall("glFogf(GL_FOG_END, fogend");
782 TRACE("Fog End == %f\n", fogend);
785 checkGLcall("glDisable GL_FOG");
788 if (GL_SUPPORT(NV_FOG_DISTANCE)) {
789 glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_PLANE_ABSOLUTE_NV);
793 static void state_fogcolor(DWORD state, IWineD3DStateBlockImpl *stateblock) {
795 D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_FOGCOLOR], col);
796 /* Set the default alpha blend color */
797 glFogfv(GL_FOG_COLOR, &col[0]);
798 checkGLcall("glFog GL_FOG_COLOR");
801 static void state_fogdensity(DWORD state, IWineD3DStateBlockImpl *stateblock) {
806 tmpvalue.d = stateblock->renderState[WINED3DRS_FOGDENSITY];
807 glFogfv(GL_FOG_DENSITY, &tmpvalue.f);
808 checkGLcall("glFogf(GL_FOG_DENSITY, (float) Value)");
811 /* TODO: Merge with primitive type + init_materials()!! */
812 static void state_colormat(DWORD state, IWineD3DStateBlockImpl *stateblock) {
813 GLenum Parm = GL_AMBIENT_AND_DIFFUSE;
815 if (stateblock->renderState[WINED3DRS_COLORVERTEX]) {
816 TRACE("diff %d, amb %d, emis %d, spec %d\n",
817 stateblock->renderState[WINED3DRS_DIFFUSEMATERIALSOURCE],
818 stateblock->renderState[WINED3DRS_AMBIENTMATERIALSOURCE],
819 stateblock->renderState[WINED3DRS_EMISSIVEMATERIALSOURCE],
820 stateblock->renderState[WINED3DRS_SPECULARMATERIALSOURCE]);
822 if (stateblock->renderState[WINED3DRS_DIFFUSEMATERIALSOURCE] == D3DMCS_COLOR1) {
823 if (stateblock->renderState[WINED3DRS_AMBIENTMATERIALSOURCE] == D3DMCS_COLOR1) {
824 Parm = GL_AMBIENT_AND_DIFFUSE;
828 } else if (stateblock->renderState[WINED3DRS_AMBIENTMATERIALSOURCE] == D3DMCS_COLOR1) {
830 } else if (stateblock->renderState[WINED3DRS_EMISSIVEMATERIALSOURCE] == D3DMCS_COLOR1) {
832 } else if (stateblock->renderState[WINED3DRS_SPECULARMATERIALSOURCE] == D3DMCS_COLOR1) {
839 if (stateblock->wineD3DDevice->tracking_color != DISABLED_TRACKING) stateblock->wineD3DDevice->tracking_color = NEEDS_DISABLE;
841 stateblock->wineD3DDevice->tracking_color = NEEDS_TRACKING;
842 stateblock->wineD3DDevice->tracking_parm = Parm;
846 if (stateblock->wineD3DDevice->tracking_color != DISABLED_TRACKING) stateblock->wineD3DDevice->tracking_color = NEEDS_DISABLE;
850 static void state_linepattern(DWORD state, IWineD3DStateBlockImpl *stateblock) {
853 WINED3DLINEPATTERN lp;
855 tmppattern.d = stateblock->renderState[WINED3DRS_LINEPATTERN];
857 TRACE("Line pattern: repeat %d bits %x\n", tmppattern.lp.wRepeatFactor, tmppattern.lp.wLinePattern);
859 if (tmppattern.lp.wRepeatFactor) {
860 glLineStipple(tmppattern.lp.wRepeatFactor, tmppattern.lp.wLinePattern);
861 checkGLcall("glLineStipple(repeat, linepattern)");
862 glEnable(GL_LINE_STIPPLE);
863 checkGLcall("glEnable(GL_LINE_STIPPLE);");
865 glDisable(GL_LINE_STIPPLE);
866 checkGLcall("glDisable(GL_LINE_STIPPLE);");
870 static void state_zbias(DWORD state, IWineD3DStateBlockImpl *stateblock) {
876 if (stateblock->renderState[WINED3DRS_ZBIAS]) {
877 tmpvalue.d = stateblock->renderState[WINED3DRS_ZBIAS];
878 TRACE("ZBias value %f\n", tmpvalue.f);
879 glPolygonOffset(0, -tmpvalue.f);
880 checkGLcall("glPolygonOffset(0, -Value)");
881 glEnable(GL_POLYGON_OFFSET_FILL);
882 checkGLcall("glEnable(GL_POLYGON_OFFSET_FILL);");
883 glEnable(GL_POLYGON_OFFSET_LINE);
884 checkGLcall("glEnable(GL_POLYGON_OFFSET_LINE);");
885 glEnable(GL_POLYGON_OFFSET_POINT);
886 checkGLcall("glEnable(GL_POLYGON_OFFSET_POINT);");
888 glDisable(GL_POLYGON_OFFSET_FILL);
889 checkGLcall("glDisable(GL_POLYGON_OFFSET_FILL);");
890 glDisable(GL_POLYGON_OFFSET_LINE);
891 checkGLcall("glDisable(GL_POLYGON_OFFSET_LINE);");
892 glDisable(GL_POLYGON_OFFSET_POINT);
893 checkGLcall("glDisable(GL_POLYGON_OFFSET_POINT);");
898 static void state_normalize(DWORD state, IWineD3DStateBlockImpl *stateblock) {
899 if (stateblock->renderState[WINED3DRS_NORMALIZENORMALS]) {
900 glEnable(GL_NORMALIZE);
901 checkGLcall("glEnable(GL_NORMALIZE);");
903 glDisable(GL_NORMALIZE);
904 checkGLcall("glDisable(GL_NORMALIZE);");
908 static void state_psize(DWORD state, IWineD3DStateBlockImpl *stateblock) {
914 /* FIXME: check that pointSize isn't outside glGetFloatv( GL_POINT_SIZE_MAX_ARB, &maxSize ); or -ve */
915 tmpvalue.d = stateblock->renderState[WINED3DRS_POINTSIZE];
916 TRACE("Set point size to %f\n", tmpvalue.f);
917 glPointSize(tmpvalue.f);
918 checkGLcall("glPointSize(...);");
921 static void state_psizemin(DWORD state, IWineD3DStateBlockImpl *stateblock) {
927 if(GL_SUPPORT(ARB_POINT_PARAMETERS)) {
928 tmpvalue.d = stateblock->renderState[WINED3DRS_POINTSIZE_MIN];
929 GL_EXTCALL(glPointParameterfARB)(GL_POINT_SIZE_MIN_ARB, tmpvalue.f);
930 checkGLcall("glPointParameterfARB(...");
932 else if(GL_SUPPORT(EXT_POINT_PARAMETERS)) {
933 tmpvalue.d = stateblock->renderState[WINED3DRS_POINTSIZE_MIN];
934 GL_EXTCALL(glPointParameterfEXT)(GL_POINT_SIZE_MIN_EXT, tmpvalue.f);
935 checkGLcall("glPointParameterfEXT(...);");
937 FIXME("WINED3DRS_POINTSIZE_MIN not supported on this opengl\n");
941 static void state_psizemax(DWORD state, IWineD3DStateBlockImpl *stateblock) {
947 if(GL_SUPPORT(ARB_POINT_PARAMETERS)) {
948 tmpvalue.d = stateblock->renderState[WINED3DRS_POINTSIZE_MAX];
949 GL_EXTCALL(glPointParameterfARB)(GL_POINT_SIZE_MAX_ARB, tmpvalue.f);
950 checkGLcall("glPointParameterfARB(...");
952 else if(GL_SUPPORT(EXT_POINT_PARAMETERS)) {
953 tmpvalue.d = stateblock->renderState[WINED3DRS_POINTSIZE_MAX];
954 GL_EXTCALL(glPointParameterfEXT)(GL_POINT_SIZE_MAX_EXT, tmpvalue.f);
955 checkGLcall("glPointParameterfEXT(...);");
957 FIXME("WINED3DRS_POINTSIZE_MAX not supported on this opengl\n");
961 static void state_pscale(DWORD state, IWineD3DStateBlockImpl *stateblock) {
962 /* TODO: Group this with the viewport */
964 * POINTSCALEENABLE controls how point size value is treated. If set to
965 * true, the point size is scaled with respect to height of viewport.
966 * When set to false point size is in pixels.
968 * http://msdn.microsoft.com/library/en-us/directx9_c/point_sprites.asp
972 GLfloat att[3] = {1.0f, 0.0f, 0.0f};
975 * Minimum valid point size for OpenGL is 1.0f. For Direct3D it is 0.0f.
976 * This means that OpenGL will clamp really small point sizes to 1.0f.
977 * To correct for this we need to multiply by the scale factor when sizes
978 * are less than 1.0f. scale_factor = 1.0f / point_size.
980 GLfloat pointSize = *((float*)&stateblock->renderState[WINED3DRS_POINTSIZE]);
981 if(pointSize > 0.0f) {
984 if(pointSize < 1.0f) {
985 scaleFactor = pointSize * pointSize;
990 if(stateblock->renderState[WINED3DRS_POINTSCALEENABLE]) {
991 att[0] = *((float*)&stateblock->renderState[WINED3DRS_POINTSCALE_A]) /
992 (stateblock->viewport.Height * stateblock->viewport.Height * scaleFactor);
993 att[1] = *((float*)&stateblock->renderState[WINED3DRS_POINTSCALE_B]) /
994 (stateblock->viewport.Height * stateblock->viewport.Height * scaleFactor);
995 att[2] = *((float*)&stateblock->renderState[WINED3DRS_POINTSCALE_C]) /
996 (stateblock->viewport.Height * stateblock->viewport.Height * scaleFactor);
1000 if(GL_SUPPORT(ARB_POINT_PARAMETERS)) {
1001 GL_EXTCALL(glPointParameterfvARB)(GL_POINT_DISTANCE_ATTENUATION_ARB, att);
1002 checkGLcall("glPointParameterfvARB(GL_DISTANCE_ATTENUATION_ARB, ...");
1004 else if(GL_SUPPORT(EXT_POINT_PARAMETERS)) {
1005 GL_EXTCALL(glPointParameterfvEXT)(GL_DISTANCE_ATTENUATION_EXT, att);
1006 checkGLcall("glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, ...");
1008 TRACE("POINT_PARAMETERS not supported in this version of opengl\n");
1012 static void state_colorwrite(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1013 DWORD Value = stateblock->renderState[WINED3DRS_COLORWRITEENABLE];
1015 TRACE("Color mask: r(%d) g(%d) b(%d) a(%d)\n",
1016 Value & D3DCOLORWRITEENABLE_RED ? 1 : 0,
1017 Value & D3DCOLORWRITEENABLE_GREEN ? 1 : 0,
1018 Value & D3DCOLORWRITEENABLE_BLUE ? 1 : 0,
1019 Value & D3DCOLORWRITEENABLE_ALPHA ? 1 : 0);
1020 glColorMask(Value & D3DCOLORWRITEENABLE_RED ? GL_TRUE : GL_FALSE,
1021 Value & D3DCOLORWRITEENABLE_GREEN ? GL_TRUE : GL_FALSE,
1022 Value & D3DCOLORWRITEENABLE_BLUE ? GL_TRUE : GL_FALSE,
1023 Value & D3DCOLORWRITEENABLE_ALPHA ? GL_TRUE : GL_FALSE);
1024 checkGLcall("glColorMask(...)");
1026 /* depends on WINED3DRS_COLORWRITEENABLE. */
1027 if(stateblock->renderState[WINED3DRS_COLORWRITEENABLE1] != 0x0000000F ||
1028 stateblock->renderState[WINED3DRS_COLORWRITEENABLE2] != 0x0000000F ||
1029 stateblock->renderState[WINED3DRS_COLORWRITEENABLE3] != 0x0000000F ) {
1030 ERR("(WINED3DRS_COLORWRITEENABLE1/2/3,%d,%d,%d) not yet implemented. Missing of cap D3DPMISCCAPS_INDEPENDENTWRITEMASKS wasn't honored?\n",
1031 stateblock->renderState[WINED3DRS_COLORWRITEENABLE1],
1032 stateblock->renderState[WINED3DRS_COLORWRITEENABLE2],
1033 stateblock->renderState[WINED3DRS_COLORWRITEENABLE3]);
1037 static void state_localviewer(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1038 if(stateblock->renderState[WINED3DRS_LOCALVIEWER]) {
1039 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);
1040 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1)");
1042 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 0);
1043 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 0)");
1047 static void state_lastpixel(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1048 if(stateblock->renderState[WINED3DRS_LASTPIXEL]) {
1049 TRACE("Last Pixel Drawing Enabled\n");
1051 FIXME("Last Pixel Drawing Disabled, not handled yet\n");
1055 static void state_pointsprite(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1056 /* TODO: NV_POINT_SPRITE */
1057 if (!GL_SUPPORT(ARB_POINT_SPRITE)) {
1058 TRACE("Point sprites not supported\n");
1062 if (stateblock->renderState[WINED3DRS_POINTSPRITEENABLE]) {
1063 glEnable(GL_POINT_SPRITE_ARB);
1064 checkGLcall("glEnable(GL_POINT_SPRITE_ARB)");
1065 glTexEnvf(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, TRUE);
1066 checkGLcall("glTexEnvf(GL_POINT_SPRITE, GL_COORD_REPLACE, TRUE)");
1068 glDisable(GL_POINT_SPRITE_ARB);
1069 checkGLcall("glDisable(GL_POINT_SPRITE_ARB)");
1070 glTexEnvf(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, FALSE);
1071 checkGLcall("glTexEnvf(GL_POINT_SPRITE, GL_COORD_REPLACE, FALSE)");
1075 static void state_wrap(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1077 http://www.cosc.brocku.ca/Offerings/3P98/course/lectures/texture/
1078 http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/graphics/programmingguide/FixedFunction/Textures/texturewrapping.asp
1079 http://www.gamedev.net/reference/programming/features/rendererdll3/page2.asp
1080 Descussion that ways to turn on WRAPing to solve an opengl conversion problem.
1081 http://www.flipcode.org/cgi-bin/fcmsg.cgi?thread_show=10248
1083 so far as I can tell, wrapping and texture-coordinate generate go hand in hand,
1086 if(stateblock->renderState[WINED3DRS_WRAP0] ||
1087 stateblock->renderState[WINED3DRS_WRAP1] ||
1088 stateblock->renderState[WINED3DRS_WRAP2] ||
1089 stateblock->renderState[WINED3DRS_WRAP3] ||
1090 stateblock->renderState[WINED3DRS_WRAP4] ||
1091 stateblock->renderState[WINED3DRS_WRAP5] ||
1092 stateblock->renderState[WINED3DRS_WRAP6] ||
1093 stateblock->renderState[WINED3DRS_WRAP7] ||
1094 stateblock->renderState[WINED3DRS_WRAP8] ||
1095 stateblock->renderState[WINED3DRS_WRAP9] ||
1096 stateblock->renderState[WINED3DRS_WRAP10] ||
1097 stateblock->renderState[WINED3DRS_WRAP11] ||
1098 stateblock->renderState[WINED3DRS_WRAP12] ||
1099 stateblock->renderState[WINED3DRS_WRAP13] ||
1100 stateblock->renderState[WINED3DRS_WRAP14] ||
1101 stateblock->renderState[WINED3DRS_WRAP15] ) {
1102 ERR("(WINED3DRS_WRAP0) Texture wraping not yet supported\n");
1106 static void state_multisampleaa(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1107 if( GL_SUPPORT(ARB_MULTISAMPLE) ) {
1108 if(stateblock->renderState[WINED3DRS_MULTISAMPLEANTIALIAS]) {
1109 glEnable(GL_MULTISAMPLE_ARB);
1110 checkGLcall("glEnable(GL_MULTISAMPLE_ARB)");
1112 glDisable(GL_MULTISAMPLE_ARB);
1113 checkGLcall("glDisable(GL_MULTISAMPLE_ARB)");
1116 if(stateblock->renderState[WINED3DRS_MULTISAMPLEANTIALIAS]) {
1117 ERR("Multisample antialiasing not supported by gl\n");
1122 static void state_scissor(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1123 if(stateblock->renderState[WINED3DRS_SCISSORTESTENABLE]) {
1124 glEnable(GL_SCISSOR_TEST);
1125 checkGLcall("glEnable(GL_SCISSOR_TEST)");
1127 glDisable(GL_SCISSOR_TEST);
1128 checkGLcall("glDisable(GL_SCISSOR_TEST)");
1132 static void state_depthbias(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1138 if(stateblock->renderState[WINED3DRS_SLOPESCALEDEPTHBIAS] ||
1139 stateblock->renderState[WINED3DRS_DEPTHBIAS]) {
1140 tmpvalue.d = stateblock->renderState[WINED3DRS_SLOPESCALEDEPTHBIAS];
1141 glEnable(GL_POLYGON_OFFSET_FILL);
1142 checkGLcall("glEnable(GL_POLYGON_OFFSET_FILL)");
1143 glPolygonOffset(tmpvalue.f, *((float*)&stateblock->renderState[WINED3DRS_DEPTHBIAS]));
1144 checkGLcall("glPolygonOffset(...)");
1146 glDisable(GL_POLYGON_OFFSET_FILL);
1147 checkGLcall("glDisable(GL_POLYGON_OFFSET_FILL)");
1151 static void state_perspective(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1152 if (stateblock->renderState[WINED3DRS_TEXTUREPERSPECTIVE]) {
1153 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
1154 checkGLcall("glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)");
1156 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
1157 checkGLcall("glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST)");
1161 static void state_stippledalpha(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1163 if (stateblock->renderState[WINED3DRS_STIPPLEDALPHA])
1164 ERR(" Stippled Alpha not supported yet.\n");
1167 static void state_antialias(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1169 if (stateblock->renderState[WINED3DRS_ANTIALIAS])
1170 ERR(" Antialias not supported yet.\n");
1173 static void state_multisampmask(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1175 if (stateblock->renderState[WINED3DRS_MULTISAMPLEMASK] != 0xFFFFFFFF)
1176 ERR("(WINED3DRS_MULTISAMPLEMASK,%d) not yet implemented\n", stateblock->renderState[WINED3DRS_MULTISAMPLEMASK]);
1179 static void state_patchedgestyle(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1181 if (stateblock->renderState[WINED3DRS_PATCHEDGESTYLE] != D3DPATCHEDGE_DISCRETE)
1182 ERR("(WINED3DRS_PATCHEDGESTYLE,%d) not yet implemented\n", stateblock->renderState[WINED3DRS_PATCHEDGESTYLE]);
1185 static void state_patchsegments(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1193 if (stateblock->renderState[WINED3DRS_PATCHSEGMENTS] != tmpvalue.d)
1194 ERR("(WINED3DRS_PATCHSEGMENTS,%d) not yet implemented\n", tmpvalue.d);
1197 static void state_positiondegree(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1199 if (stateblock->renderState[WINED3DRS_POSITIONDEGREE] != D3DDEGREE_CUBIC)
1200 ERR("(WINED3DRS_POSITIONDEGREE,%d) not yet implemented\n", stateblock->renderState[WINED3DRS_POSITIONDEGREE]);
1203 static void state_normaldegree(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1205 if (stateblock->renderState[WINED3DRS_NORMALDEGREE] != D3DDEGREE_LINEAR)
1206 ERR("(WINED3DRS_NORMALDEGREE,%d) not yet implemented\n", stateblock->renderState[WINED3DRS_NORMALDEGREE]);
1209 static void state_tessellation(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1211 if(stateblock->renderState[WINED3DRS_ENABLEADAPTIVETESSELLATION])
1212 FIXME("(WINED3DRS_ENABLEADAPTIVETESSELLATION,%d) not yet implemented\n", stateblock->renderState[WINED3DRS_ENABLEADAPTIVETESSELLATION]);
1216 static void state_srgbwrite(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1217 if(stateblock->renderState[WINED3DRS_SRGBWRITEENABLE])
1218 ERR("Render state WINED3DRS_SRGBWRITEENABLE not yet implemented\n");
1221 static void state_seperateblend(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1223 if(stateblock->renderState[WINED3DRS_SEPARATEALPHABLENDENABLE])
1224 FIXME("(WINED3DRS_SEPARATEALPHABLENDENABLE,%d) not yet implemented\n", stateblock->renderState[WINED3DRS_SEPARATEALPHABLENDENABLE]);
1227 static void state_wrapu(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1228 if(stateblock->renderState[WINED3DRS_WRAPU]) {
1229 FIXME("Render state WINED3DRS_WRAPU not implemented yet\n");
1233 static void state_wrapv(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1234 if(stateblock->renderState[WINED3DRS_WRAPV]) {
1235 FIXME("Render state WINED3DRS_WRAPV not implemented yet\n");
1239 static void state_monoenable(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1240 if(stateblock->renderState[WINED3DRS_MONOENABLE]) {
1241 FIXME("Render state WINED3DRS_MONOENABLE not implemented yet\n");
1245 static void state_rop2(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1246 if(stateblock->renderState[WINED3DRS_ROP2]) {
1247 FIXME("Render state WINED3DRS_ROP2 not implemented yet\n");
1251 static void state_planemask(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1252 if(stateblock->renderState[WINED3DRS_PLANEMASK]) {
1253 FIXME("Render state WINED3DRS_PLANEMASK not implemented yet\n");
1257 static void state_subpixel(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1258 if(stateblock->renderState[WINED3DRS_SUBPIXEL]) {
1259 FIXME("Render state WINED3DRS_SUBPIXEL not implemented yet\n");
1263 static void state_subpixelx(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1264 if(stateblock->renderState[WINED3DRS_SUBPIXELX]) {
1265 FIXME("Render state WINED3DRS_SUBPIXELX not implemented yet\n");
1269 static void state_stippleenable(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1270 if(stateblock->renderState[WINED3DRS_STIPPLEENABLE]) {
1271 FIXME("Render state WINED3DRS_STIPPLEENABLE not implemented yet\n");
1275 static void state_bordercolor(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1276 if(stateblock->renderState[WINED3DRS_BORDERCOLOR]) {
1277 FIXME("Render state WINED3DRS_BORDERCOLOR not implemented yet\n");
1281 static void state_mipmaplodbias(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1282 if(stateblock->renderState[WINED3DRS_MIPMAPLODBIAS]) {
1283 FIXME("Render state WINED3DRS_MIPMAPLODBIAS not implemented yet\n");
1287 static void state_anisotropy(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1288 if(stateblock->renderState[WINED3DRS_ANISOTROPY]) {
1289 FIXME("Render state WINED3DRS_ANISOTROPY not implemented yet\n");
1293 static void state_flushbatch(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1294 if(stateblock->renderState[WINED3DRS_FLUSHBATCH]) {
1295 FIXME("Render state WINED3DRS_FLUSHBATCH not implemented yet\n");
1299 static void state_translucentsi(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1300 if(stateblock->renderState[WINED3DRS_TRANSLUCENTSORTINDEPENDENT]) {
1301 FIXME("Render state WINED3DRS_TRANSLUCENTSORTINDEPENDENT not implemented yet\n");
1305 static void state_extents(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1306 if(stateblock->renderState[WINED3DRS_EXTENTS]) {
1307 FIXME("Render state WINED3DRS_EXTENTS not implemented yet\n");
1311 static void state_ckeyblend(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1312 if(stateblock->renderState[WINED3DRS_COLORKEYBLENDENABLE]) {
1313 FIXME("Render state WINED3DRS_COLORKEYBLENDENABLE not implemented yet\n");
1317 /* Activates the texture dimension according to the bound D3D texture.
1318 * Does not care for the colorop or correct gl texture unit(when using nvrc)
1319 * Requires the caller to activate the correct unit before
1321 static void activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock) {
1322 if(stateblock->textures[stage]) {
1323 glDisable(GL_TEXTURE_1D);
1324 checkGLcall("glDisable(GL_TEXTURE_1D)");
1325 switch(stateblock->textureDimensions[stage]) {
1327 glDisable(GL_TEXTURE_3D);
1328 checkGLcall("glDisable(GL_TEXTURE_3D)");
1329 glDisable(GL_TEXTURE_CUBE_MAP_ARB);
1330 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
1331 glEnable(GL_TEXTURE_2D);
1332 checkGLcall("glEnable(GL_TEXTURE_2D)");
1335 glDisable(GL_TEXTURE_CUBE_MAP_ARB);
1336 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
1337 glDisable(GL_TEXTURE_2D);
1338 checkGLcall("glDisable(GL_TEXTURE_2D)");
1339 glEnable(GL_TEXTURE_3D);
1340 checkGLcall("glEnable(GL_TEXTURE_3D)");
1342 case GL_TEXTURE_CUBE_MAP_ARB:
1343 glDisable(GL_TEXTURE_2D);
1344 checkGLcall("glDisable(GL_TEXTURE_2D)");
1345 glDisable(GL_TEXTURE_3D);
1346 checkGLcall("glDisable(GL_TEXTURE_3D)");
1347 glEnable(GL_TEXTURE_CUBE_MAP_ARB);
1348 checkGLcall("glEnable(GL_TEXTURE_CUBE_MAP_ARB)");
1352 glDisable(GL_TEXTURE_2D);
1353 checkGLcall("glDisable(GL_TEXTURE_2D)");
1354 glDisable(GL_TEXTURE_3D);
1355 checkGLcall("glDisable(GL_TEXTURE_3D)");
1356 glDisable(GL_TEXTURE_CUBE_MAP_ARB);
1357 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
1358 glEnable(GL_TEXTURE_1D);
1359 checkGLcall("glEnable(GL_TEXTURE_1D)");
1360 /* Binding textures is done by samplers. A dummy texture will be bound */
1364 static void tex_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1365 DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE;
1366 DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[stage];
1368 TRACE("Setting color op for stage %d\n", stage);
1370 if (stateblock->pixelShader && stateblock->wineD3DDevice->ps_selected_mode != SHADER_NONE &&
1371 ((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.function) {
1372 /* Using a pixel shader? Don't care for anything here, the shader applying does it */
1376 if (stage != mapped_stage) WARN("Using non 1:1 mapping: %d -> %d!\n", stage, mapped_stage);
1378 if (mapped_stage != -1) {
1379 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
1380 if (mapped_stage >= GL_LIMITS(sampler_stages)) {
1381 if (stateblock->textureState[stage][WINED3DTSS_COLOROP] != WINED3DTOP_DISABLE &&
1382 stateblock->textureState[stage][WINED3DTSS_COLOROP] != 0) {
1383 FIXME("Attempt to enable unsupported stage!\n");
1387 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
1388 checkGLcall("glActiveTextureARB");
1389 } else if (stage > 0) {
1390 WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
1395 if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
1396 if(stateblock->lowest_disabled_stage > 0) {
1397 glEnable(GL_REGISTER_COMBINERS_NV);
1398 GL_EXTCALL(glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, stateblock->lowest_disabled_stage));
1400 glDisable(GL_REGISTER_COMBINERS_NV);
1403 if(stage >= stateblock->lowest_disabled_stage) {
1404 TRACE("Stage disabled\n");
1405 if (mapped_stage != -1) {
1406 /* Disable everything here */
1407 glDisable(GL_TEXTURE_1D);
1408 checkGLcall("glDisable(GL_TEXTURE_1D)");
1409 glDisable(GL_TEXTURE_2D);
1410 checkGLcall("glDisable(GL_TEXTURE_2D)");
1411 glDisable(GL_TEXTURE_3D);
1412 checkGLcall("glDisable(GL_TEXTURE_3D)");
1413 glDisable(GL_TEXTURE_CUBE_MAP_ARB);
1414 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
1420 if (mapped_stage != -1) activate_dimensions(stage, stateblock);
1422 /* Set the texture combiners */
1423 if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
1424 set_tex_op_nvrc((IWineD3DDevice *)stateblock->wineD3DDevice, FALSE, stage,
1425 stateblock->textureState[stage][WINED3DTSS_COLOROP],
1426 stateblock->textureState[stage][WINED3DTSS_COLORARG1],
1427 stateblock->textureState[stage][WINED3DTSS_COLORARG2],
1428 stateblock->textureState[stage][WINED3DTSS_COLORARG0],
1431 set_tex_op((IWineD3DDevice *)stateblock->wineD3DDevice, FALSE, stage,
1432 stateblock->textureState[stage][WINED3DTSS_COLOROP],
1433 stateblock->textureState[stage][WINED3DTSS_COLORARG1],
1434 stateblock->textureState[stage][WINED3DTSS_COLORARG2],
1435 stateblock->textureState[stage][WINED3DTSS_COLORARG0]);
1439 static void tex_alphaop(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1440 DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE;
1441 DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[stage];
1443 TRACE("Setting alpha op for stage %d\n", stage);
1444 /* Do not care for enabled / disabled stages, just assign the settigns. colorop disables / enables required stuff */
1445 if (mapped_stage != -1) {
1446 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
1447 if (stage >= GL_LIMITS(sampler_stages)) {
1448 if (stateblock->textureState[stage][WINED3DTSS_COLOROP] != WINED3DTOP_DISABLE &&
1449 stateblock->textureState[stage][WINED3DTSS_COLOROP] != 0) {
1450 FIXME("Attempt to enable unsupported stage!\n");
1454 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
1455 checkGLcall("glActiveTextureARB");
1456 } else if (stage > 0) {
1457 /* We can't do anything here */
1458 WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
1463 TRACE("Setting alpha op for stage %d\n", stage);
1464 if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
1465 set_tex_op_nvrc((IWineD3DDevice *)stateblock->wineD3DDevice, TRUE, stage,
1466 stateblock->textureState[stage][WINED3DTSS_ALPHAOP],
1467 stateblock->textureState[stage][WINED3DTSS_ALPHAARG1],
1468 stateblock->textureState[stage][WINED3DTSS_ALPHAARG2],
1469 stateblock->textureState[stage][WINED3DTSS_ALPHAARG0],
1472 set_tex_op((IWineD3DDevice *)stateblock->wineD3DDevice, TRUE, stage, stateblock->textureState[stage][WINED3DTSS_ALPHAOP],
1473 stateblock->textureState[stage][WINED3DTSS_ALPHAARG1],
1474 stateblock->textureState[stage][WINED3DTSS_ALPHAARG2],
1475 stateblock->textureState[stage][WINED3DTSS_ALPHAARG0]);
1479 static void transform_texture(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1480 DWORD texUnit = state - STATE_TRANSFORM(WINED3DTS_TEXTURE0);
1482 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
1483 if(texUnit >= GL_LIMITS(sampler_stages)) {
1486 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + stateblock->wineD3DDevice->texUnitMap[texUnit]));
1487 checkGLcall("glActiveTextureARB");
1488 } else if (texUnit > 0) {
1489 /* We can't do anything here */
1490 WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
1494 set_texture_matrix((float *)&stateblock->transforms[WINED3DTS_TEXTURE0 + texUnit].u.m[0][0],
1495 stateblock->textureState[texUnit][WINED3DTSS_TEXTURETRANSFORMFLAGS],
1496 (stateblock->textureState[texUnit][WINED3DTSS_TEXCOORDINDEX] & 0xFFFF0000) != WINED3DTSS_TCI_PASSTHRU);
1500 static void tex_coordindex(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1501 DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE;
1502 DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[stage];
1504 if (mapped_stage == -1) {
1505 TRACE("No texture unit mapped to stage %d. Skipping texture coordinates.\n", stage);
1509 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
1510 if(stage >= GL_LIMITS(sampler_stages)) {
1513 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
1514 checkGLcall("glActiveTextureARB");
1515 } else if (stage > 0) {
1516 /* We can't do anything here */
1517 WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
1521 /* Values 0-7 are indexes into the FVF tex coords - See comments in DrawPrimitive
1523 * FIXME: From MSDN: The WINED3DTSS_TCI_* flags are mutually exclusive. If you include
1524 * one flag, you can still specify an index value, which the system uses to
1525 * determine the texture wrapping mode.
1526 * eg. SetTextureStageState( 0, WINED3DTSS_TEXCOORDINDEX, WINED3DTSS_TCI_CAMERASPACEPOSITION | 1 );
1527 * means use the vertex position (camera-space) as the input texture coordinates
1528 * for this texture stage, and the wrap mode set in the WINED3DRS_WRAP1 render
1529 * state. We do not (yet) support the WINED3DRENDERSTATE_WRAPx values, nor tie them up
1530 * to the TEXCOORDINDEX value
1534 * Be careful the value of the mask 0xF0000 come from d3d8types.h infos
1536 switch (stateblock->textureState[stage][WINED3DTSS_TEXCOORDINDEX] & 0xFFFF0000) {
1537 case WINED3DTSS_TCI_PASSTHRU:
1538 /*Use the specified texture coordinates contained within the vertex format. This value resolves to zero.*/
1539 glDisable(GL_TEXTURE_GEN_S);
1540 glDisable(GL_TEXTURE_GEN_T);
1541 glDisable(GL_TEXTURE_GEN_R);
1542 glDisable(GL_TEXTURE_GEN_Q);
1543 checkGLcall("glDisable(GL_TEXTURE_GEN_S,T,R,Q)");
1546 case WINED3DTSS_TCI_CAMERASPACEPOSITION:
1547 /* CameraSpacePosition means use the vertex position, transformed to camera space,
1548 * as the input texture coordinates for this stage's texture transformation. This
1549 * equates roughly to EYE_LINEAR
1552 float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
1553 float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
1554 float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
1555 float q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
1556 TRACE("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set eye plane\n");
1558 glMatrixMode(GL_MODELVIEW);
1561 glTexGenfv(GL_S, GL_EYE_PLANE, s_plane);
1562 glTexGenfv(GL_T, GL_EYE_PLANE, t_plane);
1563 glTexGenfv(GL_R, GL_EYE_PLANE, r_plane);
1564 glTexGenfv(GL_Q, GL_EYE_PLANE, q_plane);
1567 TRACE("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set GL_TEXTURE_GEN_x and GL_x, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR\n");
1568 glEnable(GL_TEXTURE_GEN_S);
1569 checkGLcall("glEnable(GL_TEXTURE_GEN_S);");
1570 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
1571 checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)");
1572 glEnable(GL_TEXTURE_GEN_T);
1573 checkGLcall("glEnable(GL_TEXTURE_GEN_T);");
1574 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
1575 checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)");
1576 glEnable(GL_TEXTURE_GEN_R);
1577 checkGLcall("glEnable(GL_TEXTURE_GEN_R);");
1578 glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
1579 checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)");
1583 case WINED3DTSS_TCI_CAMERASPACENORMAL:
1585 if (GL_SUPPORT(NV_TEXGEN_REFLECTION)) {
1586 float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
1587 float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
1588 float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
1589 float q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
1590 TRACE("WINED3DTSS_TCI_CAMERASPACENORMAL - Set eye plane\n");
1592 glMatrixMode(GL_MODELVIEW);
1595 glTexGenfv(GL_S, GL_EYE_PLANE, s_plane);
1596 glTexGenfv(GL_T, GL_EYE_PLANE, t_plane);
1597 glTexGenfv(GL_R, GL_EYE_PLANE, r_plane);
1598 glTexGenfv(GL_Q, GL_EYE_PLANE, q_plane);
1601 glEnable(GL_TEXTURE_GEN_S);
1602 checkGLcall("glEnable(GL_TEXTURE_GEN_S);");
1603 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV);
1604 checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV)");
1605 glEnable(GL_TEXTURE_GEN_T);
1606 checkGLcall("glEnable(GL_TEXTURE_GEN_T);");
1607 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV);
1608 checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV)");
1609 glEnable(GL_TEXTURE_GEN_R);
1610 checkGLcall("glEnable(GL_TEXTURE_GEN_R);");
1611 glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV);
1612 checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV)");
1617 case WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR:
1619 if (GL_SUPPORT(NV_TEXGEN_REFLECTION)) {
1620 float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
1621 float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
1622 float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
1623 float q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
1624 TRACE("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Set eye plane\n");
1626 glMatrixMode(GL_MODELVIEW);
1629 glTexGenfv(GL_S, GL_EYE_PLANE, s_plane);
1630 glTexGenfv(GL_T, GL_EYE_PLANE, t_plane);
1631 glTexGenfv(GL_R, GL_EYE_PLANE, r_plane);
1632 glTexGenfv(GL_Q, GL_EYE_PLANE, q_plane);
1635 glEnable(GL_TEXTURE_GEN_S);
1636 checkGLcall("glEnable(GL_TEXTURE_GEN_S);");
1637 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV);
1638 checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV)");
1639 glEnable(GL_TEXTURE_GEN_T);
1640 checkGLcall("glEnable(GL_TEXTURE_GEN_T);");
1641 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV);
1642 checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV)");
1643 glEnable(GL_TEXTURE_GEN_R);
1644 checkGLcall("glEnable(GL_TEXTURE_GEN_R);");
1645 glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV);
1646 checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV)");
1651 /* Unhandled types: */
1654 /* ? disable GL_TEXTURE_GEN_n ? */
1655 glDisable(GL_TEXTURE_GEN_S);
1656 glDisable(GL_TEXTURE_GEN_T);
1657 glDisable(GL_TEXTURE_GEN_R);
1658 glDisable(GL_TEXTURE_GEN_Q);
1659 FIXME("Unhandled WINED3DTSS_TEXCOORDINDEX %x\n", stateblock->textureState[stage][WINED3DTSS_TEXCOORDINDEX]);
1663 /* Update the texture matrix */
1664 if(!isStateDirty(stateblock->wineD3DDevice, STATE_TRANSFORM(WINED3DTS_TEXTURE0 + stage))) {
1665 transform_texture(STATE_TRANSFORM(WINED3DTS_TEXTURE0 + stage), stateblock);
1669 static void tex_bumpenvlscale(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1670 DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE;
1676 tmpvalue.d = stateblock->textureState[stage][WINED3DTSS_BUMPENVLSCALE];
1677 if(tmpvalue.f != 0.0) {
1678 ERR("WINED3DTSS_BUMPENVLSCALE not supported yet\n");
1682 static void tex_bumpenvloffset(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1683 DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE;
1689 tmpvalue.d = stateblock->textureState[stage][WINED3DTSS_BUMPENVLOFFSET];
1690 if(tmpvalue.f != 0.0) {
1691 ERR("WINED3DTSS_BUMPENVLOFFSET not supported yet\n");
1695 static void tex_resultarg(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1696 DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE;
1698 if(stateblock->textureState[stage][WINED3DTSS_RESULTARG] != D3DTA_CURRENT) {
1699 ERR("WINED3DTSS_RESULTARG not supported yet\n");
1703 static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1704 DWORD sampler = state - STATE_SAMPLER(0);
1710 TRACE("Sampler: %d\n", sampler);
1711 /* Enabling and disabling texture dimensions is done by texture stage state / pixel shader setup, this function
1712 * only has to bind textures and set the per texture states
1714 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
1715 /* TODO: register combiners! */
1716 if(sampler >= GL_LIMITS(sampler_stages)) {
1719 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + stateblock->wineD3DDevice->texUnitMap[sampler]));
1720 checkGLcall("glActiveTextureARB");
1721 } else if (sampler > 0) {
1722 /* We can't do anything here */
1723 WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
1727 if(stateblock->textures[sampler]) {
1729 /* NP2 textures need the texture matrix set properly for the stage */
1730 if(wined3d_settings.nonpower2_mode == NP2_NATIVE && sampler < MAX_TEXTURES - 1 &&
1731 stateblock->textureDimensions[sampler] == GL_TEXTURE_2D &&
1732 (((IWineD3DTextureImpl *) stateblock->textures[sampler])->pow2scalingFactorX != 1.0 ||
1733 ((IWineD3DTextureImpl *) stateblock->textures[sampler])->pow2scalingFactorY != 1.0 ) ) {
1734 transform_texture(STATE_TRANSFORM(WINED3DTS_TEXTURE0 + stateblock->wineD3DDevice->texUnitMap[sampler]), stateblock);
1737 IWineD3DBaseTexture_PreLoad((IWineD3DBaseTexture *) stateblock->textures[sampler]);
1738 IWineD3DBaseTexture_ApplyStateChanges(stateblock->textures[sampler], stateblock->textureState[sampler], stateblock->samplerState[sampler]);
1740 if (GL_SUPPORT(EXT_TEXTURE_LOD_BIAS)) {
1741 tmpvalue.d = stateblock->samplerState[sampler][WINED3DSAMP_MIPMAPLODBIAS];
1742 glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT,
1743 GL_TEXTURE_LOD_BIAS_EXT,
1745 checkGLcall("glTexEnvi GL_TEXTURE_LOD_BIAS_EXT ...");
1748 if (stateblock->wineD3DDevice->ps_selected_mode != SHADER_NONE && stateblock->pixelShader &&
1749 ((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.function) {
1750 /* Using a pixel shader? Verify the sampler types */
1752 /* Make sure that the texture dimensions are enabled. I don't have to disable the other
1753 * dimensions because the shader knows from which texture type to sample from. For the sake of
1754 * debugging all dimensions could be enabled and a texture with some ugly pink bound to the unused
1755 * dimensions. This should make wrong sampling sources visible :-)
1757 glEnable(stateblock->textureDimensions[sampler]);
1758 checkGLcall("glEnable(stateblock->textureDimensions[sampler])");
1759 } else if(sampler < stateblock->lowest_disabled_stage) {
1760 activate_dimensions(sampler, stateblock);
1762 if(stateblock->renderState[WINED3DRS_COLORKEYENABLE] && sampler == 0) {
1763 /* If color keying is enabled update the alpha test, it depends on the existence
1764 * of a color key in stage 0
1766 state_alpha(WINED3DRS_COLORKEYENABLE, stateblock);
1769 } else if(sampler < GL_LIMITS(texture_stages)) {
1770 if(sampler < stateblock->lowest_disabled_stage) {
1771 /* TODO: Check if the colorop is dirty to do that job
1772 * TODO: What should I do with pixel shaders here ???
1774 activate_dimensions(sampler, stateblock);
1775 } /* Otherwise tex_colorop disables the stage */
1776 glBindTexture(GL_TEXTURE_1D, stateblock->wineD3DDevice->dummyTextureName[sampler]);
1777 checkGLcall("glBindTexture(GL_TEXTURE_1D, stateblock->wineD3DDevice->dummyTextureName[sampler])");
1781 static void pixelshader(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1784 if(stateblock->pixelShader && ((IWineD3DPixelShaderImpl *) stateblock->pixelShader)->baseShader.function != NULL) {
1785 if(!stateblock->wineD3DDevice->last_was_pshader) {
1786 /* Former draw without a pixel shader, some samplers
1787 * may be disabled because of WINED3DTSS_COLOROP = WINED3DTOP_DISABLE
1788 * make sure to enable them
1790 for(i=0; i < MAX_SAMPLERS; i++) {
1791 if(!isStateDirty(stateblock->wineD3DDevice, STATE_SAMPLER(i))) {
1792 sampler(STATE_SAMPLER(i), stateblock);
1796 /* Otherwise all samplers were activated by the code above in earlier draws, or by sampler()
1797 * if a different texture was bound. I don't have to do anything.
1801 /* Compile and bind the shader */
1802 IWineD3DPixelShader_CompileShader(stateblock->pixelShader);
1805 /* Can't do that here right now, because glsl shaders depend on having both pixel and vertex shader
1806 * setup at the same time. The shader_select call will be done by drawprim until vertex shaders are
1807 * moved to the state table too
1809 stateblock->wineD3DDevice->shader_backend->shader_select(
1810 (IWineD3DDevice *) stateblock->wineD3DDevice,
1812 !stateblock->vertexShader ? FALSE : ((IWineD3DVertexShaderImpl *) stateblock->vertexShader)->baseShader.function != NULL);
1814 stateblock->wineD3DDevice->last_was_pshader = TRUE;
1816 /* Disabled the pixel shader - color ops weren't applied
1817 * while it was enabled, so re-apply them.
1819 for(i=0; i < MAX_TEXTURES; i++) {
1820 if(!isStateDirty(stateblock->wineD3DDevice, STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP))) {
1821 tex_colorop(STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP), stateblock);
1824 stateblock->wineD3DDevice->last_was_pshader = FALSE;
1827 stateblock->wineD3DDevice->shader_backend->shader_select(
1828 (IWineD3DDevice *) stateblock->wineD3DDevice,
1830 !stateblock->vertexShader ? FALSE : ((IWineD3DVertexShaderImpl *) stateblock->vertexShader)->baseShader.function != NULL);
1835 static void transform_world(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1836 /* This function is called by transform_view below if the view matrix was changed too
1838 * Deliberately no check if the vertex declaration is dirty because the vdecl state
1839 * does not always update the world matrix, only on a switch between transformed
1840 * and untrannsformed draws. It *may* happen that the world matrix is set 2 times during one
1841 * draw, but that should be rather rare and cheaper in total.
1843 glMatrixMode(GL_MODELVIEW);
1844 checkGLcall("glMatrixMode");
1846 if(stateblock->wineD3DDevice->last_was_rhw) {
1848 checkGLcall("glLoadIdentity()");
1850 /* In the general case, the view matrix is the identity matrix */
1851 if (stateblock->wineD3DDevice->view_ident) {
1852 glLoadMatrixf((float *) &stateblock->transforms[WINED3DTS_WORLDMATRIX(0)].u.m[0][0]);
1853 checkGLcall("glLoadMatrixf");
1855 glLoadMatrixf((float *) &stateblock->transforms[WINED3DTS_VIEW].u.m[0][0]);
1856 checkGLcall("glLoadMatrixf");
1857 glMultMatrixf((float *) &stateblock->transforms[WINED3DTS_WORLDMATRIX(0)].u.m[0][0]);
1858 checkGLcall("glMultMatrixf");
1863 static void transform_view(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1866 /* If we are changing the View matrix, reset the light and clipping planes to the new view
1867 * NOTE: We have to reset the positions even if the light/plane is not currently
1868 * enabled, since the call to enable it will not reset the position.
1869 * NOTE2: Apparently texture transforms do NOT need reapplying
1872 PLIGHTINFOEL *lightChain = NULL;
1874 glMatrixMode(GL_MODELVIEW);
1875 checkGLcall("glMatrixMode(GL_MODELVIEW)");
1876 glLoadMatrixf((float *)(float *) &stateblock->transforms[WINED3DTS_VIEW].u.m[0][0]);
1877 checkGLcall("glLoadMatrixf(...)");
1879 /* Reset lights. TODO: Call light apply func */
1880 lightChain = stateblock->lights;
1881 while (lightChain && lightChain->glIndex != -1) {
1882 glLightfv(GL_LIGHT0 + lightChain->glIndex, GL_POSITION, lightChain->lightPosn);
1883 checkGLcall("glLightfv posn");
1884 glLightfv(GL_LIGHT0 + lightChain->glIndex, GL_SPOT_DIRECTION, lightChain->lightDirn);
1885 checkGLcall("glLightfv dirn");
1886 lightChain = lightChain->next;
1889 /* Reset Clipping Planes if clipping is enabled. TODO: Call clipplane apply func */
1890 for (k = 0; k < GL_LIMITS(clipplanes); k++) {
1891 glClipPlane(GL_CLIP_PLANE0 + k, stateblock->clipplane[k]);
1892 checkGLcall("glClipPlane");
1895 if(stateblock->wineD3DDevice->last_was_rhw) {
1897 checkGLcall("glLoadIdentity()");
1898 /* No need to update the world matrix, the identity is fine */
1902 /* Call the world matrix state, this will apply the combined WORLD + VIEW matrix
1903 * No need to do it here if the state is scheduled for update.
1905 if(!isStateDirty(stateblock->wineD3DDevice, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)))) {
1906 transform_world(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), stateblock);
1910 static void transform_worldex(DWORD state, IWineD3DStateBlockImpl *stateBlock) {
1911 WARN("World matrix 1 - 255 not supported yet\n");
1914 static const GLfloat invymat[16] = {
1915 1.0f, 0.0f, 0.0f, 0.0f,
1916 0.0f, -1.0f, 0.0f, 0.0f,
1917 0.0f, 0.0f, 1.0f, 0.0f,
1918 0.0f, 0.0f, 0.0f, 1.0f};
1920 static void transform_projection(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1921 glMatrixMode(GL_PROJECTION);
1922 checkGLcall("glMatrixMode(GL_PROJECTION)");
1924 checkGLcall("glLoadIdentity");
1926 if(stateblock->wineD3DDevice->last_was_rhw) {
1927 double X, Y, height, width, minZ, maxZ;
1929 X = stateblock->viewport.X;
1930 Y = stateblock->viewport.Y;
1931 height = stateblock->viewport.Height;
1932 width = stateblock->viewport.Width;
1933 minZ = stateblock->viewport.MinZ;
1934 maxZ = stateblock->viewport.MaxZ;
1936 if(!stateblock->wineD3DDevice->untransformed) {
1937 /* Transformed vertices are supposed to bypass the whole transform pipeline including
1938 * frustum clipping. This can't be done in opengl, so this code adjusts the Z range to
1939 * suppress depth clipping. This can be done because it is an orthogonal projection and
1940 * the Z coordinate does not affect the size of the primitives
1942 TRACE("Calling glOrtho with %f, %f, %f, %f\n", width, height, -minZ, -maxZ);
1943 glOrtho(X, X + width, Y + height, Y, -minZ, -maxZ);
1945 /* If the app mixes transformed and untransformed primitives we can't use the coordinate system
1946 * trick above because this would mess up transformed and untransformed Z order. Pass the z position
1947 * unmodified to opengl.
1949 * If the app depends on mixed types and disabled clipping we're out of luck without a pipeline
1950 * replacement shader.
1952 TRACE("Calling glOrtho with %f, %f, %f, %f\n", width, height, 1.0, -1.0);
1953 glOrtho(X, X + width, Y + height, Y, 1.0, -1.0);
1955 checkGLcall("glOrtho");
1957 /* Window Coord 0 is the middle of the first pixel, so translate by 3/8 pixels */
1958 glTranslatef(0.375, 0.375, 0);
1959 checkGLcall("glTranslatef(0.375, 0.375, 0)");
1960 /* D3D texture coordinates are flipped compared to OpenGL ones, so
1961 * render everything upside down when rendering offscreen. */
1962 if (stateblock->wineD3DDevice->render_offscreen) {
1963 glMultMatrixf(invymat);
1964 checkGLcall("glMultMatrixf(invymat)");
1967 /* The rule is that the window coordinate 0 does not correspond to the
1968 beginning of the first pixel, but the center of the first pixel.
1969 As a consequence if you want to correctly draw one line exactly from
1970 the left to the right end of the viewport (with all matrices set to
1971 be identity), the x coords of both ends of the line would be not
1972 -1 and 1 respectively but (-1-1/viewport_widh) and (1-1/viewport_width)
1974 glTranslatef(0.9 / stateblock->viewport.Width, -0.9 / stateblock->viewport.Height, 0);
1975 checkGLcall("glTranslatef (0.9 / width, -0.9 / height, 0)");
1977 /* D3D texture coordinates are flipped compared to OpenGL ones, so
1978 * render everything upside down when rendering offscreen. */
1979 if (stateblock->wineD3DDevice->render_offscreen) {
1980 glMultMatrixf(invymat);
1981 checkGLcall("glMultMatrixf(invymat)");
1983 glMultMatrixf((float *) &stateblock->transforms[WINED3DTS_PROJECTION].u.m[0][0]);
1984 checkGLcall("glLoadMatrixf");
1988 /* Helper for vertexdeclaration() */
1989 static inline void handleStreams(IWineD3DStateBlockImpl *stateblock, BOOL useVertexShaderFunction) {
1990 IWineD3DDeviceImpl *device = stateblock->wineD3DDevice;
1992 if(device->up_strided) {
1993 /* Note: this is a ddraw fixed-function code path */
1994 TRACE("================ Strided Input ===================\n");
1995 memcpy(&device->strided_streams, device->up_strided, sizeof(device->strided_streams));
1996 } else if (stateblock->vertexDecl || stateblock->vertexShader) {
1997 /* Note: This is a fixed function or shader codepath.
1998 * This means it must handle both types of strided data.
1999 * Shaders must go through here to zero the strided data, even if they
2000 * don't set any declaration at all
2002 TRACE("================ Vertex Declaration ===================\n");
2003 memset(&device->strided_streams, 0, sizeof(device->strided_streams));
2005 if (stateblock->vertexDecl != NULL ||
2006 ((IWineD3DVertexShaderImpl *)stateblock->vertexShader)->vertexDeclaration != NULL) {
2008 primitiveDeclarationConvertToStridedData((IWineD3DDevice *) device, useVertexShaderFunction,
2009 &device->strided_streams, &device->streamFixedUp);
2012 /* Note: This codepath is not reachable from d3d9 (see fvf->decl9 conversion)
2013 * It is reachable through d3d8, but only for fixed-function.
2014 * It will not work properly for shaders.
2016 TRACE("================ FVF ===================\n");
2017 memset(&device->strided_streams, 0, sizeof(device->strided_streams));
2018 primitiveConvertToStridedData((IWineD3DDevice *) device, &device->strided_streams,
2019 &device->streamFixedUp);
2023 static void vertexdeclaration(DWORD state, IWineD3DStateBlockImpl *stateblock) {
2024 BOOL useVertexShaderFunction = FALSE, updateFog = FALSE;
2026 /* Some stuff is in the device until we have per context tracking */
2027 IWineD3DDeviceImpl *device = stateblock->wineD3DDevice;
2028 BOOL wasrhw = device->last_was_rhw;
2030 device->streamFixedUp = FALSE;
2032 /* Shaders can be implemented using ARB_PROGRAM, GLSL, or software -
2033 * here simply check whether a shader was set, or the user disabled shaders
2035 if (device->vs_selected_mode != SHADER_NONE && stateblock->vertexShader &&
2036 ((IWineD3DVertexShaderImpl *)stateblock->vertexShader)->baseShader.function != NULL) {
2037 useVertexShaderFunction = TRUE;
2039 if(((IWineD3DVertexShaderImpl *)stateblock->vertexShader)->usesFog != device->last_was_foggy_shader) {
2042 } else if(device->last_was_foggy_shader) {
2046 handleStreams(stateblock, useVertexShaderFunction);
2048 /* Do I have to use ? TRUE : FALSE ? Or can I rely on 15==15 beeing equal to TRUE(=1)? */
2049 transformed = ((device->strided_streams.u.s.position.lpData != NULL ||
2050 device->strided_streams.u.s.position.VBO != 0) &&
2051 device->strided_streams.u.s.position_transformed) ? TRUE : FALSE;
2053 if(transformed != device->last_was_rhw && !useVertexShaderFunction) {
2057 /* Reapply lighting if it is not sheduled for reapplication already */
2058 if(!isStateDirty(device, STATE_RENDER(WINED3DRS_LIGHTING))) {
2059 state_lighting(STATE_RENDER(WINED3DRS_LIGHTING), stateblock);
2062 if (!useVertexShaderFunction && transformed) {
2063 stateblock->wineD3DDevice->last_was_rhw = TRUE;
2066 /* Untransformed, so relies on the view and projection matrices */
2067 device->last_was_rhw = FALSE;
2068 /* This turns off the Z scale trick to 'disable' viewport frustum clipping in rhw mode*/
2069 device->untransformed = TRUE;
2071 /* Todo for sw shaders: Vertex Shader output is already transformed, so set up identity matrices
2072 * Not needed as long as only hw shaders are supported
2075 /* This sets the shader output position correction constants.
2076 * TODO: Move to the viewport state
2078 if (useVertexShaderFunction) {
2079 device->posFixup[1] = device->render_offscreen ? -1.0 : 1.0;
2083 /* Don't have to apply the matrices when vertex shaders are used. When vshaders are turned
2084 * off this function will be called again anyway to make sure they're properly set
2086 if(!useVertexShaderFunction) {
2087 /* TODO: Move this mainly to the viewport state and only apply when the vp has changed
2088 * or transformed / untransformed was switched
2090 if(wasrhw != device->last_was_rhw &&
2091 !isStateDirty(stateblock->wineD3DDevice, STATE_TRANSFORM(WINED3DTS_PROJECTION)) &&
2092 !isStateDirty(stateblock->wineD3DDevice, STATE_VIEWPORT)) {
2093 transform_projection(STATE_TRANSFORM(WINED3DTS_PROJECTION), stateblock);
2095 /* World matrix needs reapplication here only if we're switching between rhw and non-rhw
2098 * If a vertex shader is used, the world matrix changed and then vertex shader unbound
2099 * this check will fail and the matrix not applied again. This is OK because a simple
2100 * world matrix change reapplies the matrix - These checks here are only to satisfy the
2101 * needs of the vertex declaration.
2103 * World and view matrix go into the same gl matrix, so only apply them when neither is
2106 if(transformed != wasrhw &&
2107 !isStateDirty(stateblock->wineD3DDevice, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0))) &&
2108 !isStateDirty(stateblock->wineD3DDevice, STATE_TRANSFORM(WINED3DTS_VIEW))) {
2109 transform_world(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), stateblock);
2114 state_fog(STATE_RENDER(WINED3DRS_FOGENABLE), stateblock);
2118 static void viewport(DWORD state, IWineD3DStateBlockImpl *stateblock) {
2119 glDepthRange(stateblock->viewport.MinZ, stateblock->viewport.MaxZ);
2120 checkGLcall("glDepthRange");
2121 /* Note: GL requires lower left, DirectX supplies upper left */
2122 /* TODO: replace usage of renderTarget with context management */
2123 glViewport(stateblock->viewport.X,
2124 (((IWineD3DSurfaceImpl *)stateblock->wineD3DDevice->render_targets[0])->currentDesc.Height - (stateblock->viewport.Y + stateblock->viewport.Height)),
2125 stateblock->viewport.Width, stateblock->viewport.Height);
2127 checkGLcall("glViewport");
2129 stateblock->wineD3DDevice->posFixup[2] = 0.9 / stateblock->viewport.Width;
2130 stateblock->wineD3DDevice->posFixup[3] = -0.9 / stateblock->viewport.Height;
2131 if(!isStateDirty(stateblock->wineD3DDevice, STATE_TRANSFORM(D3DTS_PROJECTION))) {
2132 transform_projection(STATE_TRANSFORM(D3DTS_PROJECTION), stateblock);
2137 const struct StateEntry StateTable[] =
2139 /* State name representative, apply function */
2140 { /* 0, Undefined */ 0, state_undefined },
2141 { /* 1, WINED3DRS_TEXTUREHANDLE */ 0 /* Handled in ddraw */, state_undefined },
2142 { /* 2, WINED3DRS_ANTIALIAS */ STATE_RENDER(WINED3DRS_ANTIALIAS), state_antialias },
2143 { /* 3, WINED3DRS_TEXTUREADDRESS */ 0 /* Handled in ddraw */, state_undefined },
2144 { /* 4, WINED3DRS_TEXTUREPERSPECTIVE */ STATE_RENDER(WINED3DRS_TEXTUREPERSPECTIVE), state_perspective },
2145 { /* 5, WINED3DRS_WRAPU */ STATE_RENDER(WINED3DRS_WRAPU), state_wrapu },
2146 { /* 6, WINED3DRS_WRAPV */ STATE_RENDER(WINED3DRS_WRAPV), state_wrapv },
2147 { /* 7, WINED3DRS_ZENABLE */ STATE_RENDER(WINED3DRS_ZENABLE), state_zenable },
2148 { /* 8, WINED3DRS_FILLMODE */ STATE_RENDER(WINED3DRS_FILLMODE), state_fillmode },
2149 { /* 9, WINED3DRS_SHADEMODE */ STATE_RENDER(WINED3DRS_SHADEMODE), state_shademode },
2150 { /* 10, WINED3DRS_LINEPATTERN */ STATE_RENDER(WINED3DRS_LINEPATTERN), state_linepattern },
2151 { /* 11, WINED3DRS_MONOENABLE */ STATE_RENDER(WINED3DRS_MONOENABLE), state_monoenable },
2152 { /* 12, WINED3DRS_ROP2 */ STATE_RENDER(WINED3DRS_ROP2), state_rop2 },
2153 { /* 13, WINED3DRS_PLANEMASK */ STATE_RENDER(WINED3DRS_PLANEMASK), state_planemask },
2154 { /* 14, WINED3DRS_ZWRITEENABLE */ STATE_RENDER(WINED3DRS_ZWRITEENABLE), state_zwritenable },
2155 { /* 15, WINED3DRS_ALPHATESTENABLE */ STATE_RENDER(WINED3DRS_ALPHATESTENABLE), state_alpha },
2156 { /* 16, WINED3DRS_LASTPIXEL */ STATE_RENDER(WINED3DRS_LASTPIXEL), state_lastpixel },
2157 { /* 17, WINED3DRS_TEXTUREMAG */ 0 /* Handled in ddraw */, state_undefined },
2158 { /* 18, WINED3DRS_TEXTUREMIN */ 0 /* Handled in ddraw */, state_undefined },
2159 { /* 19, WINED3DRS_SRCBLEND */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), state_blend },
2160 { /* 20, WINED3DRS_DESTBLEND */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), state_blend },
2161 { /* 21, WINED3DRS_TEXTUREMAPBLEND */ 0 /* Handled in ddraw */, state_undefined },
2162 { /* 22, WINED3DRS_CULLMODE */ STATE_RENDER(WINED3DRS_CULLMODE), state_cullmode },
2163 { /* 23, WINED3DRS_ZFUNC */ STATE_RENDER(WINED3DRS_ZFUNC), state_zfunc },
2164 { /* 24, WINED3DRS_ALPHAREF */ STATE_RENDER(WINED3DRS_ALPHATESTENABLE), state_alpha },
2165 { /* 25, WINED3DRS_ALPHAFUNC */ STATE_RENDER(WINED3DRS_ALPHATESTENABLE), state_alpha },
2166 { /* 26, WINED3DRS_DITHERENABLE */ STATE_RENDER(WINED3DRS_DITHERENABLE), state_ditherenable },
2167 { /* 27, WINED3DRS_ALPHABLENDENABLE */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), state_blend },
2168 { /* 28, WINED3DRS_FOGENABLE */ STATE_RENDER(WINED3DRS_FOGENABLE), state_fog },
2169 { /* 29, WINED3DRS_SPECULARENABLE */ STATE_RENDER(WINED3DRS_SPECULARENABLE), state_specularenable},
2170 { /* 30, WINED3DRS_ZVISIBLE */ 0 /* Not supported according to the msdn */, state_nogl },
2171 { /* 31, WINED3DRS_SUBPIXEL */ STATE_RENDER(WINED3DRS_SUBPIXEL), state_subpixel },
2172 { /* 32, WINED3DRS_SUBPIXELX */ STATE_RENDER(WINED3DRS_SUBPIXELX), state_subpixelx },
2173 { /* 33, WINED3DRS_STIPPLEDALPHA */ STATE_RENDER(WINED3DRS_STIPPLEDALPHA), state_stippledalpha },
2174 { /* 34, WINED3DRS_FOGCOLOR */ STATE_RENDER(WINED3DRS_FOGCOLOR), state_fogcolor },
2175 { /* 35, WINED3DRS_FOGTABLEMODE */ STATE_RENDER(WINED3DRS_FOGENABLE), state_fog },
2176 { /* 36, WINED3DRS_FOGSTART */ STATE_RENDER(WINED3DRS_FOGENABLE), state_fog },
2177 { /* 37, WINED3DRS_FOGEND */ STATE_RENDER(WINED3DRS_FOGENABLE), state_fog },
2178 { /* 38, WINED3DRS_FOGDENSITY */ STATE_RENDER(WINED3DRS_FOGDENSITY), state_fogdensity },
2179 { /* 39, WINED3DRS_STIPPLEENABLE */ STATE_RENDER(WINED3DRS_STIPPLEENABLE), state_stippleenable },
2180 { /* 40, WINED3DRS_EDGEANTIALIAS */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), state_blend },
2181 { /* 41, WINED3DRS_COLORKEYENABLE */ STATE_RENDER(WINED3DRS_ALPHATESTENABLE), state_alpha },
2182 { /* 42, undefined */ 0, state_undefined },
2183 { /* 43, WINED3DRS_BORDERCOLOR */ STATE_RENDER(WINED3DRS_BORDERCOLOR), state_bordercolor },
2184 { /* 44, WINED3DRS_TEXTUREADDRESSU */ 0, /* Handled in ddraw */ state_undefined },
2185 { /* 45, WINED3DRS_TEXTUREADDRESSV */ 0, /* Handled in ddraw */ state_undefined },
2186 { /* 46, WINED3DRS_MIPMAPLODBIAS */ STATE_RENDER(WINED3DRS_MIPMAPLODBIAS), state_mipmaplodbias },
2187 { /* 47, WINED3DRS_ZBIAS */ STATE_RENDER(WINED3DRS_ZBIAS), state_zbias },
2188 { /* 48, WINED3DRS_RANGEFOGENABLE */ 0, state_nogl },
2189 { /* 49, WINED3DRS_ANISOTROPY */ STATE_RENDER(WINED3DRS_ANISOTROPY), state_anisotropy },
2190 { /* 50, WINED3DRS_FLUSHBATCH */ STATE_RENDER(WINED3DRS_FLUSHBATCH), state_flushbatch },
2191 { /* 51, WINED3DRS_TRANSLUCENTSORTINDEPENDENT */ STATE_RENDER(WINED3DRS_TRANSLUCENTSORTINDEPENDENT), state_translucentsi },
2192 { /* 52, WINED3DRS_STENCILENABLE */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2193 { /* 53, WINED3DRS_STENCILFAIL */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2194 { /* 54, WINED3DRS_STENCILZFAIL */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2195 { /* 55, WINED3DRS_STENCILPASS */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2196 { /* 56, WINED3DRS_STENCILFUNC */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2197 { /* 57, WINED3DRS_STENCILREF */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2198 { /* 58, WINED3DRS_STENCILMASK */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2199 { /* 59, WINED3DRS_STENCILWRITEMASK */ STATE_RENDER(WINED3DRS_STENCILWRITEMASK), state_stencilwrite },
2200 { /* 60, WINED3DRS_TEXTUREFACTOR */ STATE_RENDER(WINED3DRS_TEXTUREFACTOR), state_texfactor },
2201 { /* 61, Undefined */ 0, state_undefined },
2202 { /* 62, Undefined */ 0, state_undefined },
2203 { /* 63, Undefined */ 0, state_undefined },
2204 { /* 64, WINED3DRS_STIPPLEPATTERN00 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2205 { /* 65, WINED3DRS_STIPPLEPATTERN01 */ 0 /* Obsolete, should he handled by ddraw */, state_undefined },
2206 { /* 66, WINED3DRS_STIPPLEPATTERN02 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2207 { /* 67, WINED3DRS_STIPPLEPATTERN03 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2208 { /* 68, WINED3DRS_STIPPLEPATTERN04 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2209 { /* 69, WINED3DRS_STIPPLEPATTERN05 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2210 { /* 70, WINED3DRS_STIPPLEPATTERN06 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2211 { /* 71, WINED3DRS_STIPPLEPATTERN07 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2212 { /* 72, WINED3DRS_STIPPLEPATTERN08 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2213 { /* 73, WINED3DRS_STIPPLEPATTERN09 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2214 { /* 74, WINED3DRS_STIPPLEPATTERN10 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2215 { /* 75, WINED3DRS_STIPPLEPATTERN11 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2216 { /* 76, WINED3DRS_STIPPLEPATTERN12 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2217 { /* 77, WINED3DRS_STIPPLEPATTERN13 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2218 { /* 78, WINED3DRS_STIPPLEPATTERN14 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2219 { /* 79, WINED3DRS_STIPPLEPATTERN15 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2220 { /* 80, WINED3DRS_STIPPLEPATTERN16 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2221 { /* 81, WINED3DRS_STIPPLEPATTERN17 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2222 { /* 82, WINED3DRS_STIPPLEPATTERN18 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2223 { /* 83, WINED3DRS_STIPPLEPATTERN19 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2224 { /* 84, WINED3DRS_STIPPLEPATTERN20 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2225 { /* 85, WINED3DRS_STIPPLEPATTERN21 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2226 { /* 86, WINED3DRS_STIPPLEPATTERN22 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2227 { /* 87, WINED3DRS_STIPPLEPATTERN23 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2228 { /* 88, WINED3DRS_STIPPLEPATTERN24 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2229 { /* 89, WINED3DRS_STIPPLEPATTERN25 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2230 { /* 90, WINED3DRS_STIPPLEPATTERN26 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2231 { /* 91, WINED3DRS_STIPPLEPATTERN27 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2232 { /* 92, WINED3DRS_STIPPLEPATTERN28 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2233 { /* 93, WINED3DRS_STIPPLEPATTERN29 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2234 { /* 94, WINED3DRS_STIPPLEPATTERN30 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2235 { /* 95, WINED3DRS_STIPPLEPATTERN31 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2236 { /* 96, Undefined */ 0, state_undefined },
2237 { /* 97, Undefined */ 0, state_undefined },
2238 { /* 98, Undefined */ 0, state_undefined },
2239 { /* 99, Undefined */ 0, state_undefined },
2240 { /*100, Undefined */ 0, state_undefined },
2241 { /*101, Undefined */ 0, state_undefined },
2242 { /*102, Undefined */ 0, state_undefined },
2243 { /*103, Undefined */ 0, state_undefined },
2244 { /*104, Undefined */ 0, state_undefined },
2245 { /*105, Undefined */ 0, state_undefined },
2246 { /*106, Undefined */ 0, state_undefined },
2247 { /*107, Undefined */ 0, state_undefined },
2248 { /*108, Undefined */ 0, state_undefined },
2249 { /*109, Undefined */ 0, state_undefined },
2250 { /*110, Undefined */ 0, state_undefined },
2251 { /*111, Undefined */ 0, state_undefined },
2252 { /*112, Undefined */ 0, state_undefined },
2253 { /*113, Undefined */ 0, state_undefined },
2254 { /*114, Undefined */ 0, state_undefined },
2255 { /*115, Undefined */ 0, state_undefined },
2256 { /*116, Undefined */ 0, state_undefined },
2257 { /*117, Undefined */ 0, state_undefined },
2258 { /*118, Undefined */ 0, state_undefined },
2259 { /*119, Undefined */ 0, state_undefined },
2260 { /*120, Undefined */ 0, state_undefined },
2261 { /*121, Undefined */ 0, state_undefined },
2262 { /*122, Undefined */ 0, state_undefined },
2263 { /*123, Undefined */ 0, state_undefined },
2264 { /*124, Undefined */ 0, state_undefined },
2265 { /*125, Undefined */ 0, state_undefined },
2266 { /*126, Undefined */ 0, state_undefined },
2267 { /*127, Undefined */ 0, state_undefined },
2269 { /*128, WINED3DRS_WRAP0 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2270 { /*129, WINED3DRS_WRAP1 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2271 { /*130, WINED3DRS_WRAP2 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2272 { /*131, WINED3DRS_WRAP3 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2273 { /*132, WINED3DRS_WRAP4 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2274 { /*133, WINED3DRS_WRAP5 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2275 { /*134, WINED3DRS_WRAP6 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2276 { /*135, WINED3DRS_WRAP7 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2277 { /*136, WINED3DRS_CLIPPING */ STATE_RENDER(WINED3DRS_CLIPPING), state_clipping },
2278 { /*137, WINED3DRS_LIGHTING */ STATE_RENDER(WINED3DRS_LIGHTING), state_lighting },
2279 { /*138, WINED3DRS_EXTENTS */ STATE_RENDER(WINED3DRS_EXTENTS), state_extents },
2280 { /*139, WINED3DRS_AMBIENT */ STATE_RENDER(WINED3DRS_AMBIENT), state_ambient },
2281 { /*140, WINED3DRS_FOGVERTEXMODE */ STATE_RENDER(WINED3DRS_FOGENABLE), state_fog },
2282 { /*141, WINED3DRS_COLORVERTEX */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat },
2283 { /*142, WINED3DRS_LOCALVIEWER */ STATE_RENDER(WINED3DRS_LOCALVIEWER), state_localviewer },
2284 { /*143, WINED3DRS_NORMALIZENORMALS */ STATE_RENDER(WINED3DRS_NORMALIZENORMALS), state_normalize },
2285 { /*144, WINED3DRS_COLORKEYBLENDENABLE */ STATE_RENDER(WINED3DRS_COLORKEYBLENDENABLE), state_ckeyblend },
2286 { /*145, WINED3DRS_DIFFUSEMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat },
2287 { /*146, WINED3DRS_SPECULARMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat },
2288 { /*147, WINED3DRS_AMBIENTMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat },
2289 { /*148, WINED3DRS_EMISSIVEMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat },
2290 { /*149, Undefined */ 0, state_undefined },
2291 { /*150, Undefined */ 0, state_undefined },
2292 { /*151, WINED3DRS_VERTEXBLEND */ 0, state_nogl },
2293 { /*152, WINED3DRS_CLIPPLANEENABLE */ STATE_RENDER(WINED3DRS_CLIPPING), state_clipping },
2294 { /*153, WINED3DRS_SOFTWAREVERTEXPROCESSING */ 0, state_nogl },
2295 { /*154, WINED3DRS_POINTSIZE */ STATE_RENDER(WINED3DRS_POINTSIZE), state_psize },
2296 { /*155, WINED3DRS_POINTSIZE_MIN */ STATE_RENDER(WINED3DRS_POINTSIZE_MIN), state_psizemin },
2297 { /*156, WINED3DRS_POINTSPRITEENABLE */ STATE_RENDER(WINED3DRS_POINTSPRITEENABLE), state_pointsprite },
2298 { /*157, WINED3DRS_POINTSCALEENABLE */ STATE_RENDER(WINED3DRS_POINTSCALEENABLE), state_pscale },
2299 { /*158, WINED3DRS_POINTSCALE_A */ STATE_RENDER(WINED3DRS_POINTSCALEENABLE), state_pscale },
2300 { /*159, WINED3DRS_POINTSCALE_B */ STATE_RENDER(WINED3DRS_POINTSCALEENABLE), state_pscale },
2301 { /*160, WINED3DRS_POINTSCALE_C */ STATE_RENDER(WINED3DRS_POINTSCALEENABLE), state_pscale },
2302 { /*161, WINED3DRS_MULTISAMPLEANTIALIAS */ STATE_RENDER(WINED3DRS_MULTISAMPLEANTIALIAS), state_multisampleaa },
2303 { /*162, WINED3DRS_MULTISAMPLEMASK */ STATE_RENDER(WINED3DRS_MULTISAMPLEMASK), state_multisampmask },
2304 { /*163, WINED3DRS_PATCHEDGESTYLE */ STATE_RENDER(WINED3DRS_PATCHEDGESTYLE), state_patchedgestyle},
2305 { /*164, WINED3DRS_PATCHSEGMENTS */ STATE_RENDER(WINED3DRS_PATCHSEGMENTS), state_patchsegments },
2306 { /*165, WINED3DRS_DEBUGMONITORTOKEN */ STATE_RENDER(WINED3DRS_DEBUGMONITORTOKEN), state_nogl },
2307 { /*166, WINED3DRS_POINTSIZE_MAX */ STATE_RENDER(WINED3DRS_POINTSIZE_MAX), state_psizemax },
2308 { /*167, WINED3DRS_INDEXEDVERTEXBLENDENABLE */ 0, state_nogl },
2309 { /*168, WINED3DRS_COLORWRITEENABLE */ STATE_RENDER(WINED3DRS_COLORWRITEENABLE), state_colorwrite },
2310 { /*169, Undefined */ 0, state_undefined },
2311 { /*170, WINED3DRS_TWEENFACTOR */ 0, state_nogl },
2312 { /*171, WINED3DRS_BLENDOP */ STATE_RENDER(WINED3DRS_BLENDOP), state_blendop },
2313 { /*172, WINED3DRS_POSITIONDEGREE */ STATE_RENDER(WINED3DRS_POSITIONDEGREE), state_positiondegree},
2314 { /*173, WINED3DRS_NORMALDEGREE */ STATE_RENDER(WINED3DRS_NORMALDEGREE), state_normaldegree },
2315 /*172, WINED3DRS_POSITIONORDER */ /* Value assigned to 2 state names */
2316 /*173, WINED3DRS_NORMALORDER */ /* Value assigned to 2 state names */
2317 { /*174, WINED3DRS_SCISSORTESTENABLE */ STATE_RENDER(WINED3DRS_SCISSORTESTENABLE), state_scissor },
2318 { /*175, WINED3DRS_SLOPESCALEDEPTHBIAS */ STATE_RENDER(WINED3DRS_DEPTHBIAS), state_depthbias },
2319 { /*176, WINED3DRS_ANTIALIASEDLINEENABLE */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), state_blend },
2320 { /*177, undefined */ 0, state_undefined },
2321 { /*178, WINED3DRS_MINTESSELLATIONLEVEL */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation },
2322 { /*179, WINED3DRS_MAXTESSELLATIONLEVEL */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation },
2323 { /*180, WINED3DRS_ADAPTIVETESS_X */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation },
2324 { /*181, WINED3DRS_ADAPTIVETESS_Y */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation },
2325 { /*182, WINED3DRS_ADAPTIVETESS_Z */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation },
2326 { /*183, WINED3DRS_ADAPTIVETESS_W */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation },
2327 { /*184, WINED3DRS_ENABLEADAPTIVETESSELLATION */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation },
2328 { /*185, WINED3DRS_TWOSIDEDSTENCILMODE */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2329 { /*186, WINED3DRS_CCW_STENCILFAIL */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2330 { /*187, WINED3DRS_CCW_STENCILZFAIL */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2331 { /*188, WINED3DRS_CCW_STENCILPASS */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2332 { /*189, WINED3DRS_CCW_STENCILFUNC */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2333 { /*190, WINED3DRS_COLORWRITEENABLE1 */ STATE_RENDER(WINED3DRS_COLORWRITEENABLE), state_colorwrite },
2334 { /*191, WINED3DRS_COLORWRITEENABLE2 */ STATE_RENDER(WINED3DRS_COLORWRITEENABLE), state_colorwrite },
2335 { /*192, WINED3DRS_COLORWRITEENABLE3 */ STATE_RENDER(WINED3DRS_COLORWRITEENABLE), state_colorwrite },
2336 { /*193, WINED3DRS_BLENDFACTOR */ STATE_RENDER(WINED3DRS_BLENDFACTOR), state_blendfactor },
2337 { /*194, WINED3DRS_SRGBWRITEENABLE */ STATE_RENDER(WINED3DRS_SRGBWRITEENABLE), state_srgbwrite },
2338 { /*195, WINED3DRS_DEPTHBIAS */ STATE_RENDER(WINED3DRS_DEPTHBIAS), state_depthbias },
2339 { /*196, undefined */ 0, state_undefined },
2340 { /*197, undefined */ 0, state_undefined },
2341 { /*198, WINED3DRS_WRAP8 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2342 { /*199, WINED3DRS_WRAP9 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2343 { /*200, WINED3DRS_WRAP10 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2344 { /*201, WINED3DRS_WRAP11 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2345 { /*202, WINED3DRS_WRAP12 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2346 { /*203, WINED3DRS_WRAP13 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2347 { /*204, WINED3DRS_WRAP14 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2348 { /*205, WINED3DRS_WRAP15 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2349 { /*206, WINED3DRS_SEPARATEALPHABLENDENABLE */ STATE_RENDER(WINED3DRS_SEPARATEALPHABLENDENABLE), state_seperateblend },
2350 { /*207, WINED3DRS_SRCBLENDALPHA */ STATE_RENDER(WINED3DRS_SEPARATEALPHABLENDENABLE), state_seperateblend },
2351 { /*208, WINED3DRS_DESTBLENDALPHA */ STATE_RENDER(WINED3DRS_SEPARATEALPHABLENDENABLE), state_seperateblend },
2352 { /*209, WINED3DRS_BLENDOPALPHA */ STATE_RENDER(WINED3DRS_SEPARATEALPHABLENDENABLE), state_seperateblend },
2353 /* Texture stage states */
2354 { /*0, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop },
2355 { /*0, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop },
2356 { /*0, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop },
2357 { /*0, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), tex_alphaop },
2358 { /*0, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), tex_alphaop },
2359 { /*0, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), tex_alphaop },
2360 { /*0, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop },
2361 { /*0, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop },
2362 { /*0, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop },
2363 { /*0, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop },
2364 { /*0, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(0, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
2365 { /*0, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2366 { /*0, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2367 { /*0, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2368 { /*0, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2369 { /*0, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2370 { /*0, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2371 { /*0, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2372 { /*0, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2373 { /*0, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2374 { /*0, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2375 { /*0, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
2376 { /*0, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
2377 { /*0, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE0), transform_texture },
2378 { /*0, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2379 { /*0, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop },
2380 { /*0, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), tex_alphaop },
2381 { /*0, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(0, WINED3DTSS_RESULTARG), tex_resultarg },
2382 { /*0, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2383 { /*0, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2384 { /*0, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2385 { /*0, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
2387 { /*1, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), tex_colorop },
2388 { /*1, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), tex_colorop },
2389 { /*1, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), tex_colorop },
2390 { /*1, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP), tex_alphaop },
2391 { /*1, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP), tex_alphaop },
2392 { /*1, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP), tex_alphaop },
2393 { /*1, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), tex_colorop },
2394 { /*1, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), tex_colorop },
2395 { /*1, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), tex_colorop },
2396 { /*1, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), tex_colorop },
2397 { /*1, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(1, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
2398 { /*1, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2399 { /*1, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2400 { /*1, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2401 { /*1, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2402 { /*1, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2403 { /*1, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2404 { /*1, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2405 { /*1, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2406 { /*1, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2407 { /*1, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2408 { /*1, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
2409 { /*1, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
2410 { /*1, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE1), transform_texture },
2411 { /*1, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2412 { /*1, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), tex_colorop },
2413 { /*1, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP), tex_alphaop },
2414 { /*1, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(1, WINED3DTSS_RESULTARG), tex_resultarg },
2415 { /*1, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2416 { /*1, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2417 { /*1, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2418 { /*1, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
2420 { /*2, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), tex_colorop },
2421 { /*2, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), tex_colorop },
2422 { /*2, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), tex_colorop },
2423 { /*2, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP), tex_alphaop },
2424 { /*2, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP), tex_alphaop },
2425 { /*2, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP), tex_alphaop },
2426 { /*2, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), tex_colorop },
2427 { /*2, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), tex_colorop },
2428 { /*2, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), tex_colorop },
2429 { /*2, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), tex_colorop },
2430 { /*2, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(2, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
2431 { /*2, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2432 { /*2, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2433 { /*2, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2434 { /*2, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2435 { /*2, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2436 { /*2, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2437 { /*2, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2438 { /*2, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2439 { /*2, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2440 { /*2, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2441 { /*2, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
2442 { /*2, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
2443 { /*2, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE2), transform_texture },
2444 { /*2, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2445 { /*2, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), tex_colorop },
2446 { /*2, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP), tex_alphaop },
2447 { /*2, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(2, WINED3DTSS_RESULTARG), tex_resultarg },
2448 { /*2, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2449 { /*2, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2450 { /*2, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2451 { /*2, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
2453 { /*3, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), tex_colorop },
2454 { /*3, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), tex_colorop },
2455 { /*3, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), tex_colorop },
2456 { /*3, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP), tex_alphaop },
2457 { /*3, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP), tex_alphaop },
2458 { /*3, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP), tex_alphaop },
2459 { /*3, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), tex_colorop },
2460 { /*3, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), tex_colorop },
2461 { /*3, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), tex_colorop },
2462 { /*3, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), tex_colorop },
2463 { /*3, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(3, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
2464 { /*3, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2465 { /*3, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2466 { /*3, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2467 { /*3, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2468 { /*3, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2469 { /*3, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2470 { /*3, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2471 { /*3, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2472 { /*3, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2473 { /*3, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2474 { /*3, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
2475 { /*3, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
2476 { /*3, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE3), transform_texture },
2477 { /*3, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2478 { /*3, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), tex_colorop },
2479 { /*3, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP), tex_alphaop },
2480 { /*3, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(3, WINED3DTSS_RESULTARG), tex_resultarg },
2481 { /*3, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2482 { /*3, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2483 { /*3, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2484 { /*3, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
2486 { /*4, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), tex_colorop },
2487 { /*4, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), tex_colorop },
2488 { /*4, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), tex_colorop },
2489 { /*4, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP), tex_alphaop },
2490 { /*4, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP), tex_alphaop },
2491 { /*4, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP), tex_alphaop },
2492 { /*4, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), state_undefined },
2493 { /*4, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), state_undefined },
2494 { /*4, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), state_undefined },
2495 { /*4, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), state_undefined },
2496 { /*4, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(4, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
2497 { /*4, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2498 { /*4, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2499 { /*4, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2500 { /*4, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2501 { /*4, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2502 { /*4, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2503 { /*4, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2504 { /*4, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2505 { /*4, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2506 { /*4, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2507 { /*4, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
2508 { /*4, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
2509 { /*4, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE4), transform_texture },
2510 { /*4, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2511 { /*4, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), tex_colorop },
2512 { /*4, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP), tex_alphaop },
2513 { /*4, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(4, WINED3DTSS_RESULTARG), tex_resultarg },
2514 { /*4, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2515 { /*4, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2516 { /*4, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2517 { /*4, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
2519 { /*5, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), tex_colorop },
2520 { /*5, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), tex_colorop },
2521 { /*5, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), tex_colorop },
2522 { /*5, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP), tex_alphaop },
2523 { /*5, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP), tex_alphaop },
2524 { /*5, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP), tex_alphaop },
2525 { /*5, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), tex_colorop },
2526 { /*5, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), tex_colorop },
2527 { /*5, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), tex_colorop },
2528 { /*5, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), tex_colorop },
2529 { /*5, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(5, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
2530 { /*5, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2531 { /*5, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2532 { /*5, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2533 { /*5, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2534 { /*5, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2535 { /*5, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2536 { /*5, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2537 { /*5, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2538 { /*5, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2539 { /*5, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2540 { /*5, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
2541 { /*5, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
2542 { /*5, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE5), transform_texture },
2543 { /*5, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2544 { /*5, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), tex_colorop },
2545 { /*5, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP), tex_alphaop },
2546 { /*5, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(5, WINED3DTSS_RESULTARG), tex_resultarg },
2547 { /*5, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2548 { /*5, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2549 { /*5, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2550 { /*5, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
2552 { /*6, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), tex_colorop },
2553 { /*6, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), tex_colorop },
2554 { /*6, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), tex_colorop },
2555 { /*6, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP), tex_alphaop },
2556 { /*6, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP), tex_alphaop },
2557 { /*6, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP), tex_alphaop },
2558 { /*6, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), tex_colorop },
2559 { /*6, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), tex_colorop },
2560 { /*6, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), tex_colorop },
2561 { /*6, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), tex_colorop },
2562 { /*6, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(6, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
2563 { /*6, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2564 { /*6, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2565 { /*6, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2566 { /*6, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2567 { /*6, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2568 { /*6, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2569 { /*6, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2570 { /*6, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2571 { /*6, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2572 { /*6, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2573 { /*6, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
2574 { /*6, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
2575 { /*6, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE6), transform_texture },
2576 { /*6, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2577 { /*6, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), tex_colorop },
2578 { /*6, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP), tex_alphaop },
2579 { /*6, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(6, WINED3DTSS_RESULTARG), tex_resultarg },
2580 { /*6, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2581 { /*6, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2582 { /*6, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2583 { /*6, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
2585 { /*7, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), tex_colorop },
2586 { /*7, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), tex_colorop },
2587 { /*7, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), tex_colorop },
2588 { /*7, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP), tex_alphaop },
2589 { /*7, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP), tex_alphaop },
2590 { /*7, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP), tex_alphaop },
2591 { /*7, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), tex_colorop },
2592 { /*7, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), tex_colorop },
2593 { /*7, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), tex_colorop },
2594 { /*7, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), tex_colorop },
2595 { /*7, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(7, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
2596 { /*7, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2597 { /*7, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2598 { /*7, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2599 { /*7, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2600 { /*7, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2601 { /*7, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2602 { /*7, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2603 { /*7, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2604 { /*7, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2605 { /*7, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2606 { /*7, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
2607 { /*7, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
2608 { /*7, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE7), transform_texture },
2609 { /*7, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2610 { /*7, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), tex_colorop },
2611 { /*7, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP), tex_alphaop },
2612 { /*7, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(7, WINED3DTSS_RESULTARG), tex_resultarg },
2613 { /*7, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2614 { /*7, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2615 { /*7, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2616 { /*7, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
2617 /* Sampler states */
2618 { /* 0, Sampler 0 */ STATE_SAMPLER(0), sampler },
2619 { /* 1, Sampler 1 */ STATE_SAMPLER(1), sampler },
2620 { /* 2, Sampler 2 */ STATE_SAMPLER(2), sampler },
2621 { /* 3, Sampler 3 */ STATE_SAMPLER(3), sampler },
2622 { /* 4, Sampler 3 */ STATE_SAMPLER(4), sampler },
2623 { /* 5, Sampler 5 */ STATE_SAMPLER(5), sampler },
2624 { /* 6, Sampler 6 */ STATE_SAMPLER(6), sampler },
2625 { /* 7, Sampler 7 */ STATE_SAMPLER(7), sampler },
2626 { /* 8, Sampler 8 */ STATE_SAMPLER(8), sampler },
2627 { /* 9, Sampler 9 */ STATE_SAMPLER(9), sampler },
2628 { /*10, Sampler 10 */ STATE_SAMPLER(10), sampler },
2629 { /*11, Sampler 11 */ STATE_SAMPLER(11), sampler },
2630 { /*12, Sampler 12 */ STATE_SAMPLER(12), sampler },
2631 { /*13, Sampler 13 */ STATE_SAMPLER(13), sampler },
2632 { /*14, Sampler 14 */ STATE_SAMPLER(14), sampler },
2633 { /*15, Sampler 15 */ STATE_SAMPLER(15), sampler },
2635 { /* , Pixel Shader */ STATE_PIXELSHADER, pixelshader },
2636 /* Transform states follow */
2637 { /* 1, undefined */ 0, state_undefined },
2638 { /* 2, WINED3DTS_VIEW */ STATE_TRANSFORM(WINED3DTS_VIEW), transform_view },
2639 { /* 3, WINED3DTS_PROJECTION */ STATE_TRANSFORM(WINED3DTS_PROJECTION), transform_projection},
2640 { /* 4, undefined */ 0, state_undefined },
2641 { /* 5, undefined */ 0, state_undefined },
2642 { /* 6, undefined */ 0, state_undefined },
2643 { /* 7, undefined */ 0, state_undefined },
2644 { /* 8, undefined */ 0, state_undefined },
2645 { /* 9, undefined */ 0, state_undefined },
2646 { /* 10, undefined */ 0, state_undefined },
2647 { /* 11, undefined */ 0, state_undefined },
2648 { /* 12, undefined */ 0, state_undefined },
2649 { /* 13, undefined */ 0, state_undefined },
2650 { /* 14, undefined */ 0, state_undefined },
2651 { /* 15, undefined */ 0, state_undefined },
2652 { /* 16, WINED3DTS_TEXTURE0 */ STATE_TRANSFORM(WINED3DTS_TEXTURE0), transform_texture },
2653 { /* 17, WINED3DTS_TEXTURE1 */ STATE_TRANSFORM(WINED3DTS_TEXTURE1), transform_texture },
2654 { /* 18, WINED3DTS_TEXTURE2 */ STATE_TRANSFORM(WINED3DTS_TEXTURE2), transform_texture },
2655 { /* 19, WINED3DTS_TEXTURE3 */ STATE_TRANSFORM(WINED3DTS_TEXTURE3), transform_texture },
2656 { /* 20, WINED3DTS_TEXTURE4 */ STATE_TRANSFORM(WINED3DTS_TEXTURE4), transform_texture },
2657 { /* 21, WINED3DTS_TEXTURE5 */ STATE_TRANSFORM(WINED3DTS_TEXTURE5), transform_texture },
2658 { /* 22, WINED3DTS_TEXTURE6 */ STATE_TRANSFORM(WINED3DTS_TEXTURE6), transform_texture },
2659 { /* 23, WINED3DTS_TEXTURE7 */ STATE_TRANSFORM(WINED3DTS_TEXTURE7), transform_texture },
2660 /* A huge gap between TEXTURE7 and WORLDMATRIX(0) :-( But entries are needed to catch then if a broken app sets them */
2661 { /* 24, undefined */ 0, state_undefined },
2662 { /* 25, undefined */ 0, state_undefined },
2663 { /* 26, undefined */ 0, state_undefined },
2664 { /* 27, undefined */ 0, state_undefined },
2665 { /* 28, undefined */ 0, state_undefined },
2666 { /* 29, undefined */ 0, state_undefined },
2667 { /* 30, undefined */ 0, state_undefined },
2668 { /* 31, undefined */ 0, state_undefined },
2669 { /* 32, undefined */ 0, state_undefined },
2670 { /* 33, undefined */ 0, state_undefined },
2671 { /* 34, undefined */ 0, state_undefined },
2672 { /* 35, undefined */ 0, state_undefined },
2673 { /* 36, undefined */ 0, state_undefined },
2674 { /* 37, undefined */ 0, state_undefined },
2675 { /* 38, undefined */ 0, state_undefined },
2676 { /* 39, undefined */ 0, state_undefined },
2677 { /* 40, undefined */ 0, state_undefined },
2678 { /* 41, undefined */ 0, state_undefined },
2679 { /* 42, undefined */ 0, state_undefined },
2680 { /* 43, undefined */ 0, state_undefined },
2681 { /* 44, undefined */ 0, state_undefined },
2682 { /* 45, undefined */ 0, state_undefined },
2683 { /* 46, undefined */ 0, state_undefined },
2684 { /* 47, undefined */ 0, state_undefined },
2685 { /* 48, undefined */ 0, state_undefined },
2686 { /* 49, undefined */ 0, state_undefined },
2687 { /* 50, undefined */ 0, state_undefined },
2688 { /* 51, undefined */ 0, state_undefined },
2689 { /* 52, undefined */ 0, state_undefined },
2690 { /* 53, undefined */ 0, state_undefined },
2691 { /* 54, undefined */ 0, state_undefined },
2692 { /* 55, undefined */ 0, state_undefined },
2693 { /* 56, undefined */ 0, state_undefined },
2694 { /* 57, undefined */ 0, state_undefined },
2695 { /* 58, undefined */ 0, state_undefined },
2696 { /* 59, undefined */ 0, state_undefined },
2697 { /* 60, undefined */ 0, state_undefined },
2698 { /* 61, undefined */ 0, state_undefined },
2699 { /* 62, undefined */ 0, state_undefined },
2700 { /* 63, undefined */ 0, state_undefined },
2701 { /* 64, undefined */ 0, state_undefined },
2702 { /* 65, undefined */ 0, state_undefined },
2703 { /* 66, undefined */ 0, state_undefined },
2704 { /* 67, undefined */ 0, state_undefined },
2705 { /* 68, undefined */ 0, state_undefined },
2706 { /* 69, undefined */ 0, state_undefined },
2707 { /* 70, undefined */ 0, state_undefined },
2708 { /* 71, undefined */ 0, state_undefined },
2709 { /* 72, undefined */ 0, state_undefined },
2710 { /* 73, undefined */ 0, state_undefined },
2711 { /* 74, undefined */ 0, state_undefined },
2712 { /* 75, undefined */ 0, state_undefined },
2713 { /* 76, undefined */ 0, state_undefined },
2714 { /* 77, undefined */ 0, state_undefined },
2715 { /* 78, undefined */ 0, state_undefined },
2716 { /* 79, undefined */ 0, state_undefined },
2717 { /* 80, undefined */ 0, state_undefined },
2718 { /* 81, undefined */ 0, state_undefined },
2719 { /* 82, undefined */ 0, state_undefined },
2720 { /* 83, undefined */ 0, state_undefined },
2721 { /* 84, undefined */ 0, state_undefined },
2722 { /* 85, undefined */ 0, state_undefined },
2723 { /* 86, undefined */ 0, state_undefined },
2724 { /* 87, undefined */ 0, state_undefined },
2725 { /* 88, undefined */ 0, state_undefined },
2726 { /* 89, undefined */ 0, state_undefined },
2727 { /* 90, undefined */ 0, state_undefined },
2728 { /* 91, undefined */ 0, state_undefined },
2729 { /* 92, undefined */ 0, state_undefined },
2730 { /* 93, undefined */ 0, state_undefined },
2731 { /* 94, undefined */ 0, state_undefined },
2732 { /* 95, undefined */ 0, state_undefined },
2733 { /* 96, undefined */ 0, state_undefined },
2734 { /* 97, undefined */ 0, state_undefined },
2735 { /* 98, undefined */ 0, state_undefined },
2736 { /* 99, undefined */ 0, state_undefined },
2737 { /*100, undefined */ 0, state_undefined },
2738 { /*101, undefined */ 0, state_undefined },
2739 { /*102, undefined */ 0, state_undefined },
2740 { /*103, undefined */ 0, state_undefined },
2741 { /*104, undefined */ 0, state_undefined },
2742 { /*105, undefined */ 0, state_undefined },
2743 { /*106, undefined */ 0, state_undefined },
2744 { /*107, undefined */ 0, state_undefined },
2745 { /*108, undefined */ 0, state_undefined },
2746 { /*109, undefined */ 0, state_undefined },
2747 { /*110, undefined */ 0, state_undefined },
2748 { /*111, undefined */ 0, state_undefined },
2749 { /*112, undefined */ 0, state_undefined },
2750 { /*113, undefined */ 0, state_undefined },
2751 { /*114, undefined */ 0, state_undefined },
2752 { /*115, undefined */ 0, state_undefined },
2753 { /*116, undefined */ 0, state_undefined },
2754 { /*117, undefined */ 0, state_undefined },
2755 { /*118, undefined */ 0, state_undefined },
2756 { /*119, undefined */ 0, state_undefined },
2757 { /*120, undefined */ 0, state_undefined },
2758 { /*121, undefined */ 0, state_undefined },
2759 { /*122, undefined */ 0, state_undefined },
2760 { /*123, undefined */ 0, state_undefined },
2761 { /*124, undefined */ 0, state_undefined },
2762 { /*125, undefined */ 0, state_undefined },
2763 { /*126, undefined */ 0, state_undefined },
2764 { /*127, undefined */ 0, state_undefined },
2765 { /*128, undefined */ 0, state_undefined },
2766 { /*129, undefined */ 0, state_undefined },
2767 { /*130, undefined */ 0, state_undefined },
2768 { /*131, undefined */ 0, state_undefined },
2769 { /*132, undefined */ 0, state_undefined },
2770 { /*133, undefined */ 0, state_undefined },
2771 { /*134, undefined */ 0, state_undefined },
2772 { /*135, undefined */ 0, state_undefined },
2773 { /*136, undefined */ 0, state_undefined },
2774 { /*137, undefined */ 0, state_undefined },
2775 { /*138, undefined */ 0, state_undefined },
2776 { /*139, undefined */ 0, state_undefined },
2777 { /*140, undefined */ 0, state_undefined },
2778 { /*141, undefined */ 0, state_undefined },
2779 { /*142, undefined */ 0, state_undefined },
2780 { /*143, undefined */ 0, state_undefined },
2781 { /*144, undefined */ 0, state_undefined },
2782 { /*145, undefined */ 0, state_undefined },
2783 { /*146, undefined */ 0, state_undefined },
2784 { /*147, undefined */ 0, state_undefined },
2785 { /*148, undefined */ 0, state_undefined },
2786 { /*149, undefined */ 0, state_undefined },
2787 { /*150, undefined */ 0, state_undefined },
2788 { /*151, undefined */ 0, state_undefined },
2789 { /*152, undefined */ 0, state_undefined },
2790 { /*153, undefined */ 0, state_undefined },
2791 { /*154, undefined */ 0, state_undefined },
2792 { /*155, undefined */ 0, state_undefined },
2793 { /*156, undefined */ 0, state_undefined },
2794 { /*157, undefined */ 0, state_undefined },
2795 { /*158, undefined */ 0, state_undefined },
2796 { /*159, undefined */ 0, state_undefined },
2797 { /*160, undefined */ 0, state_undefined },
2798 { /*161, undefined */ 0, state_undefined },
2799 { /*162, undefined */ 0, state_undefined },
2800 { /*163, undefined */ 0, state_undefined },
2801 { /*164, undefined */ 0, state_undefined },
2802 { /*165, undefined */ 0, state_undefined },
2803 { /*166, undefined */ 0, state_undefined },
2804 { /*167, undefined */ 0, state_undefined },
2805 { /*168, undefined */ 0, state_undefined },
2806 { /*169, undefined */ 0, state_undefined },
2807 { /*170, undefined */ 0, state_undefined },
2808 { /*171, undefined */ 0, state_undefined },
2809 { /*172, undefined */ 0, state_undefined },
2810 { /*173, undefined */ 0, state_undefined },
2811 { /*174, undefined */ 0, state_undefined },
2812 { /*175, undefined */ 0, state_undefined },
2813 { /*176, undefined */ 0, state_undefined },
2814 { /*177, undefined */ 0, state_undefined },
2815 { /*178, undefined */ 0, state_undefined },
2816 { /*179, undefined */ 0, state_undefined },
2817 { /*180, undefined */ 0, state_undefined },
2818 { /*181, undefined */ 0, state_undefined },
2819 { /*182, undefined */ 0, state_undefined },
2820 { /*183, undefined */ 0, state_undefined },
2821 { /*184, undefined */ 0, state_undefined },
2822 { /*185, undefined */ 0, state_undefined },
2823 { /*186, undefined */ 0, state_undefined },
2824 { /*187, undefined */ 0, state_undefined },
2825 { /*188, undefined */ 0, state_undefined },
2826 { /*189, undefined */ 0, state_undefined },
2827 { /*190, undefined */ 0, state_undefined },
2828 { /*191, undefined */ 0, state_undefined },
2829 { /*192, undefined */ 0, state_undefined },
2830 { /*193, undefined */ 0, state_undefined },
2831 { /*194, undefined */ 0, state_undefined },
2832 { /*195, undefined */ 0, state_undefined },
2833 { /*196, undefined */ 0, state_undefined },
2834 { /*197, undefined */ 0, state_undefined },
2835 { /*198, undefined */ 0, state_undefined },
2836 { /*199, undefined */ 0, state_undefined },
2837 { /*200, undefined */ 0, state_undefined },
2838 { /*201, undefined */ 0, state_undefined },
2839 { /*202, undefined */ 0, state_undefined },
2840 { /*203, undefined */ 0, state_undefined },
2841 { /*204, undefined */ 0, state_undefined },
2842 { /*205, undefined */ 0, state_undefined },
2843 { /*206, undefined */ 0, state_undefined },
2844 { /*207, undefined */ 0, state_undefined },
2845 { /*208, undefined */ 0, state_undefined },
2846 { /*209, undefined */ 0, state_undefined },
2847 { /*210, undefined */ 0, state_undefined },
2848 { /*211, undefined */ 0, state_undefined },
2849 { /*212, undefined */ 0, state_undefined },
2850 { /*213, undefined */ 0, state_undefined },
2851 { /*214, undefined */ 0, state_undefined },
2852 { /*215, undefined */ 0, state_undefined },
2853 { /*216, undefined */ 0, state_undefined },
2854 { /*217, undefined */ 0, state_undefined },
2855 { /*218, undefined */ 0, state_undefined },
2856 { /*219, undefined */ 0, state_undefined },
2857 { /*220, undefined */ 0, state_undefined },
2858 { /*221, undefined */ 0, state_undefined },
2859 { /*222, undefined */ 0, state_undefined },
2860 { /*223, undefined */ 0, state_undefined },
2861 { /*224, undefined */ 0, state_undefined },
2862 { /*225, undefined */ 0, state_undefined },
2863 { /*226, undefined */ 0, state_undefined },
2864 { /*227, undefined */ 0, state_undefined },
2865 { /*228, undefined */ 0, state_undefined },
2866 { /*229, undefined */ 0, state_undefined },
2867 { /*230, undefined */ 0, state_undefined },
2868 { /*231, undefined */ 0, state_undefined },
2869 { /*232, undefined */ 0, state_undefined },
2870 { /*233, undefined */ 0, state_undefined },
2871 { /*234, undefined */ 0, state_undefined },
2872 { /*235, undefined */ 0, state_undefined },
2873 { /*236, undefined */ 0, state_undefined },
2874 { /*237, undefined */ 0, state_undefined },
2875 { /*238, undefined */ 0, state_undefined },
2876 { /*239, undefined */ 0, state_undefined },
2877 { /*240, undefined */ 0, state_undefined },
2878 { /*241, undefined */ 0, state_undefined },
2879 { /*242, undefined */ 0, state_undefined },
2880 { /*243, undefined */ 0, state_undefined },
2881 { /*244, undefined */ 0, state_undefined },
2882 { /*245, undefined */ 0, state_undefined },
2883 { /*246, undefined */ 0, state_undefined },
2884 { /*247, undefined */ 0, state_undefined },
2885 { /*248, undefined */ 0, state_undefined },
2886 { /*249, undefined */ 0, state_undefined },
2887 { /*250, undefined */ 0, state_undefined },
2888 { /*251, undefined */ 0, state_undefined },
2889 { /*252, undefined */ 0, state_undefined },
2890 { /*253, undefined */ 0, state_undefined },
2891 { /*254, undefined */ 0, state_undefined },
2892 { /*255, undefined */ 0, state_undefined },
2894 { /*256, WINED3DTS_WORLDMATRIX(0) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), transform_world },
2895 { /*257, WINED3DTS_WORLDMATRIX(1) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(1)), transform_worldex },
2896 { /*258, WINED3DTS_WORLDMATRIX(2) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(2)), transform_worldex },
2897 { /*259, WINED3DTS_WORLDMATRIX(3) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(3)), transform_worldex },
2898 { /*260, WINED3DTS_WORLDMATRIX(4) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(4)), transform_worldex },
2899 { /*261, WINED3DTS_WORLDMATRIX(5) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(5)), transform_worldex },
2900 { /*262, WINED3DTS_WORLDMATRIX(6) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(6)), transform_worldex },
2901 { /*263, WINED3DTS_WORLDMATRIX(7) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(7)), transform_worldex },
2902 { /*264, WINED3DTS_WORLDMATRIX(8) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(8)), transform_worldex },
2903 { /*265, WINED3DTS_WORLDMATRIX(9) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(9)), transform_worldex },
2904 { /*266, WINED3DTS_WORLDMATRIX(10) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(10)), transform_worldex },
2905 { /*267, WINED3DTS_WORLDMATRIX(11) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(11)), transform_worldex },
2906 { /*268, WINED3DTS_WORLDMATRIX(12) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(12)), transform_worldex },
2907 { /*269, WINED3DTS_WORLDMATRIX(13) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(13)), transform_worldex },
2908 { /*270, WINED3DTS_WORLDMATRIX(14) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(14)), transform_worldex },
2909 { /*271, WINED3DTS_WORLDMATRIX(15) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(15)), transform_worldex },
2910 { /*272, WINED3DTS_WORLDMATRIX(16) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(16)), transform_worldex },
2911 { /*273, WINED3DTS_WORLDMATRIX(17) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(17)), transform_worldex },
2912 { /*274, WINED3DTS_WORLDMATRIX(18) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(18)), transform_worldex },
2913 { /*275, WINED3DTS_WORLDMATRIX(19) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(19)), transform_worldex },
2914 { /*276, WINED3DTS_WORLDMATRIX(20) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(20)), transform_worldex },
2915 { /*277, WINED3DTS_WORLDMATRIX(21) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(21)), transform_worldex },
2916 { /*278, WINED3DTS_WORLDMATRIX(22) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(22)), transform_worldex },
2917 { /*279, WINED3DTS_WORLDMATRIX(23) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(23)), transform_worldex },
2918 { /*280, WINED3DTS_WORLDMATRIX(24) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(24)), transform_worldex },
2919 { /*281, WINED3DTS_WORLDMATRIX(25) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(25)), transform_worldex },
2920 { /*282, WINED3DTS_WORLDMATRIX(26) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(26)), transform_worldex },
2921 { /*283, WINED3DTS_WORLDMATRIX(27) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(27)), transform_worldex },
2922 { /*284, WINED3DTS_WORLDMATRIX(28) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(28)), transform_worldex },
2923 { /*285, WINED3DTS_WORLDMATRIX(29) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(29)), transform_worldex },
2924 { /*286, WINED3DTS_WORLDMATRIX(30) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(30)), transform_worldex },
2925 { /*287, WINED3DTS_WORLDMATRIX(31) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(31)), transform_worldex },
2926 { /*288, WINED3DTS_WORLDMATRIX(32) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(32)), transform_worldex },
2927 { /*289, WINED3DTS_WORLDMATRIX(33) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(33)), transform_worldex },
2928 { /*290, WINED3DTS_WORLDMATRIX(34) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(34)), transform_worldex },
2929 { /*291, WINED3DTS_WORLDMATRIX(35) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(35)), transform_worldex },
2930 { /*292, WINED3DTS_WORLDMATRIX(36) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(36)), transform_worldex },
2931 { /*293, WINED3DTS_WORLDMATRIX(37) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(37)), transform_worldex },
2932 { /*294, WINED3DTS_WORLDMATRIX(38) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(38)), transform_worldex },
2933 { /*295, WINED3DTS_WORLDMATRIX(39) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(39)), transform_worldex },
2934 { /*296, WINED3DTS_WORLDMATRIX(40) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(40)), transform_worldex },
2935 { /*297, WINED3DTS_WORLDMATRIX(41) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(41)), transform_worldex },
2936 { /*298, WINED3DTS_WORLDMATRIX(42) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(42)), transform_worldex },
2937 { /*299, WINED3DTS_WORLDMATRIX(43) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(43)), transform_worldex },
2938 { /*300, WINED3DTS_WORLDMATRIX(44) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(44)), transform_worldex },
2939 { /*301, WINED3DTS_WORLDMATRIX(45) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(45)), transform_worldex },
2940 { /*302, WINED3DTS_WORLDMATRIX(46) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(46)), transform_worldex },
2941 { /*303, WINED3DTS_WORLDMATRIX(47) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(47)), transform_worldex },
2942 { /*304, WINED3DTS_WORLDMATRIX(48) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(48)), transform_worldex },
2943 { /*305, WINED3DTS_WORLDMATRIX(49) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(49)), transform_worldex },
2944 { /*306, WINED3DTS_WORLDMATRIX(50) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(50)), transform_worldex },
2945 { /*307, WINED3DTS_WORLDMATRIX(51) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(51)), transform_worldex },
2946 { /*308, WINED3DTS_WORLDMATRIX(52) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(52)), transform_worldex },
2947 { /*309, WINED3DTS_WORLDMATRIX(53) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(53)), transform_worldex },
2948 { /*310, WINED3DTS_WORLDMATRIX(54) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(54)), transform_worldex },
2949 { /*311, WINED3DTS_WORLDMATRIX(55) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(55)), transform_worldex },
2950 { /*312, WINED3DTS_WORLDMATRIX(56) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(56)), transform_worldex },
2951 { /*313, WINED3DTS_WORLDMATRIX(57) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(57)), transform_worldex },
2952 { /*314, WINED3DTS_WORLDMATRIX(58) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(58)), transform_worldex },
2953 { /*315, WINED3DTS_WORLDMATRIX(59) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(59)), transform_worldex },
2954 { /*316, WINED3DTS_WORLDMATRIX(60) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(60)), transform_worldex },
2955 { /*317, WINED3DTS_WORLDMATRIX(61) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(61)), transform_worldex },
2956 { /*318, WINED3DTS_WORLDMATRIX(62) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(62)), transform_worldex },
2957 { /*319, WINED3DTS_WORLDMATRIX(63) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(63)), transform_worldex },
2958 { /*320, WINED3DTS_WORLDMATRIX(64) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(64)), transform_worldex },
2959 { /*321, WINED3DTS_WORLDMATRIX(65) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(65)), transform_worldex },
2960 { /*322, WINED3DTS_WORLDMATRIX(66) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(66)), transform_worldex },
2961 { /*323, WINED3DTS_WORLDMATRIX(67) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(67)), transform_worldex },
2962 { /*324, WINED3DTS_WORLDMATRIX(68) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(68)), transform_worldex },
2963 { /*325, WINED3DTS_WORLDMATRIX(68) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(69)), transform_worldex },
2964 { /*326, WINED3DTS_WORLDMATRIX(70) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(70)), transform_worldex },
2965 { /*327, WINED3DTS_WORLDMATRIX(71) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(71)), transform_worldex },
2966 { /*328, WINED3DTS_WORLDMATRIX(72) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(72)), transform_worldex },
2967 { /*329, WINED3DTS_WORLDMATRIX(73) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(73)), transform_worldex },
2968 { /*330, WINED3DTS_WORLDMATRIX(74) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(74)), transform_worldex },
2969 { /*331, WINED3DTS_WORLDMATRIX(75) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(75)), transform_worldex },
2970 { /*332, WINED3DTS_WORLDMATRIX(76) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(76)), transform_worldex },
2971 { /*333, WINED3DTS_WORLDMATRIX(77) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(77)), transform_worldex },
2972 { /*334, WINED3DTS_WORLDMATRIX(78) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(78)), transform_worldex },
2973 { /*335, WINED3DTS_WORLDMATRIX(79) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(79)), transform_worldex },
2974 { /*336, WINED3DTS_WORLDMATRIX(80) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(80)), transform_worldex },
2975 { /*337, WINED3DTS_WORLDMATRIX(81) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(81)), transform_worldex },
2976 { /*338, WINED3DTS_WORLDMATRIX(82) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(82)), transform_worldex },
2977 { /*339, WINED3DTS_WORLDMATRIX(83) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(83)), transform_worldex },
2978 { /*340, WINED3DTS_WORLDMATRIX(84) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(84)), transform_worldex },
2979 { /*341, WINED3DTS_WORLDMATRIX(85) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(85)), transform_worldex },
2980 { /*341, WINED3DTS_WORLDMATRIX(86) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(86)), transform_worldex },
2981 { /*343, WINED3DTS_WORLDMATRIX(87) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(87)), transform_worldex },
2982 { /*344, WINED3DTS_WORLDMATRIX(88) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(88)), transform_worldex },
2983 { /*345, WINED3DTS_WORLDMATRIX(89) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(89)), transform_worldex },
2984 { /*346, WINED3DTS_WORLDMATRIX(90) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(90)), transform_worldex },
2985 { /*347, WINED3DTS_WORLDMATRIX(91) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(91)), transform_worldex },
2986 { /*348, WINED3DTS_WORLDMATRIX(92) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(92)), transform_worldex },
2987 { /*349, WINED3DTS_WORLDMATRIX(93) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(93)), transform_worldex },
2988 { /*350, WINED3DTS_WORLDMATRIX(94) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(94)), transform_worldex },
2989 { /*351, WINED3DTS_WORLDMATRIX(95) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(95)), transform_worldex },
2990 { /*352, WINED3DTS_WORLDMATRIX(96) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(96)), transform_worldex },
2991 { /*353, WINED3DTS_WORLDMATRIX(97) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(97)), transform_worldex },
2992 { /*354, WINED3DTS_WORLDMATRIX(98) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(98)), transform_worldex },
2993 { /*355, WINED3DTS_WORLDMATRIX(99) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(99)), transform_worldex },
2994 { /*356, WINED3DTS_WORLDMATRIX(100) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(100)), transform_worldex },
2995 { /*357, WINED3DTS_WORLDMATRIX(101) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(101)), transform_worldex },
2996 { /*358, WINED3DTS_WORLDMATRIX(102) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(102)), transform_worldex },
2997 { /*359, WINED3DTS_WORLDMATRIX(103) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(103)), transform_worldex },
2998 { /*360, WINED3DTS_WORLDMATRIX(104) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(104)), transform_worldex },
2999 { /*361, WINED3DTS_WORLDMATRIX(105) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(105)), transform_worldex },
3000 { /*362, WINED3DTS_WORLDMATRIX(106) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(106)), transform_worldex },
3001 { /*363, WINED3DTS_WORLDMATRIX(107) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(107)), transform_worldex },
3002 { /*364, WINED3DTS_WORLDMATRIX(108) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(108)), transform_worldex },
3003 { /*365, WINED3DTS_WORLDMATRIX(109) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(109)), transform_worldex },
3004 { /*366, WINED3DTS_WORLDMATRIX(110) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(110)), transform_worldex },
3005 { /*367, WINED3DTS_WORLDMATRIX(111) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(111)), transform_worldex },
3006 { /*368, WINED3DTS_WORLDMATRIX(112) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(112)), transform_worldex },
3007 { /*369, WINED3DTS_WORLDMATRIX(113) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(113)), transform_worldex },
3008 { /*370, WINED3DTS_WORLDMATRIX(114) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(114)), transform_worldex },
3009 { /*371, WINED3DTS_WORLDMATRIX(115) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(115)), transform_worldex },
3010 { /*372, WINED3DTS_WORLDMATRIX(116) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(116)), transform_worldex },
3011 { /*373, WINED3DTS_WORLDMATRIX(117) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(117)), transform_worldex },
3012 { /*374, WINED3DTS_WORLDMATRIX(118) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(118)), transform_worldex },
3013 { /*375, WINED3DTS_WORLDMATRIX(119) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(119)), transform_worldex },
3014 { /*376, WINED3DTS_WORLDMATRIX(120) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(120)), transform_worldex },
3015 { /*377, WINED3DTS_WORLDMATRIX(121) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(121)), transform_worldex },
3016 { /*378, WINED3DTS_WORLDMATRIX(122) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(122)), transform_worldex },
3017 { /*379, WINED3DTS_WORLDMATRIX(123) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(123)), transform_worldex },
3018 { /*380, WINED3DTS_WORLDMATRIX(124) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(124)), transform_worldex },
3019 { /*381, WINED3DTS_WORLDMATRIX(125) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(125)), transform_worldex },
3020 { /*382, WINED3DTS_WORLDMATRIX(126) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(126)), transform_worldex },
3021 { /*383, WINED3DTS_WORLDMATRIX(127) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(127)), transform_worldex },
3022 { /*384, WINED3DTS_WORLDMATRIX(128) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(128)), transform_worldex },
3023 { /*385, WINED3DTS_WORLDMATRIX(129) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(129)), transform_worldex },
3024 { /*386, WINED3DTS_WORLDMATRIX(130) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(130)), transform_worldex },
3025 { /*387, WINED3DTS_WORLDMATRIX(131) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(131)), transform_worldex },
3026 { /*388, WINED3DTS_WORLDMATRIX(132) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(132)), transform_worldex },
3027 { /*389, WINED3DTS_WORLDMATRIX(133) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(133)), transform_worldex },
3028 { /*390, WINED3DTS_WORLDMATRIX(134) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(134)), transform_worldex },
3029 { /*391, WINED3DTS_WORLDMATRIX(135) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(135)), transform_worldex },
3030 { /*392, WINED3DTS_WORLDMATRIX(136) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(136)), transform_worldex },
3031 { /*393, WINED3DTS_WORLDMATRIX(137) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(137)), transform_worldex },
3032 { /*394, WINED3DTS_WORLDMATRIX(138) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(138)), transform_worldex },
3033 { /*395, WINED3DTS_WORLDMATRIX(139) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(139)), transform_worldex },
3034 { /*396, WINED3DTS_WORLDMATRIX(140) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(140)), transform_worldex },
3035 { /*397, WINED3DTS_WORLDMATRIX(141) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(141)), transform_worldex },
3036 { /*398, WINED3DTS_WORLDMATRIX(142) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(142)), transform_worldex },
3037 { /*399, WINED3DTS_WORLDMATRIX(143) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(143)), transform_worldex },
3038 { /*400, WINED3DTS_WORLDMATRIX(144) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(144)), transform_worldex },
3039 { /*401, WINED3DTS_WORLDMATRIX(145) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(145)), transform_worldex },
3040 { /*402, WINED3DTS_WORLDMATRIX(146) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(146)), transform_worldex },
3041 { /*403, WINED3DTS_WORLDMATRIX(147) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(147)), transform_worldex },
3042 { /*404, WINED3DTS_WORLDMATRIX(148) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(148)), transform_worldex },
3043 { /*405, WINED3DTS_WORLDMATRIX(149) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(149)), transform_worldex },
3044 { /*406, WINED3DTS_WORLDMATRIX(150) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(150)), transform_worldex },
3045 { /*407, WINED3DTS_WORLDMATRIX(151) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(151)), transform_worldex },
3046 { /*408, WINED3DTS_WORLDMATRIX(152) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(152)), transform_worldex },
3047 { /*409, WINED3DTS_WORLDMATRIX(153) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(153)), transform_worldex },
3048 { /*410, WINED3DTS_WORLDMATRIX(154) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(154)), transform_worldex },
3049 { /*411, WINED3DTS_WORLDMATRIX(155) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(155)), transform_worldex },
3050 { /*412, WINED3DTS_WORLDMATRIX(156) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(156)), transform_worldex },
3051 { /*413, WINED3DTS_WORLDMATRIX(157) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(157)), transform_worldex },
3052 { /*414, WINED3DTS_WORLDMATRIX(158) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(158)), transform_worldex },
3053 { /*415, WINED3DTS_WORLDMATRIX(159) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(159)), transform_worldex },
3054 { /*416, WINED3DTS_WORLDMATRIX(160) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(160)), transform_worldex },
3055 { /*417, WINED3DTS_WORLDMATRIX(161) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(161)), transform_worldex },
3056 { /*418, WINED3DTS_WORLDMATRIX(162) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(162)), transform_worldex },
3057 { /*419, WINED3DTS_WORLDMATRIX(163) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(163)), transform_worldex },
3058 { /*420, WINED3DTS_WORLDMATRIX(164) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(164)), transform_worldex },
3059 { /*421, WINED3DTS_WORLDMATRIX(165) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(165)), transform_worldex },
3060 { /*422, WINED3DTS_WORLDMATRIX(166) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(166)), transform_worldex },
3061 { /*423, WINED3DTS_WORLDMATRIX(167) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(167)), transform_worldex },
3062 { /*424, WINED3DTS_WORLDMATRIX(168) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(168)), transform_worldex },
3063 { /*425, WINED3DTS_WORLDMATRIX(168) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(169)), transform_worldex },
3064 { /*426, WINED3DTS_WORLDMATRIX(170) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(170)), transform_worldex },
3065 { /*427, WINED3DTS_WORLDMATRIX(171) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(171)), transform_worldex },
3066 { /*428, WINED3DTS_WORLDMATRIX(172) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(172)), transform_worldex },
3067 { /*429, WINED3DTS_WORLDMATRIX(173) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(173)), transform_worldex },
3068 { /*430, WINED3DTS_WORLDMATRIX(174) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(174)), transform_worldex },
3069 { /*431, WINED3DTS_WORLDMATRIX(175) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(175)), transform_worldex },
3070 { /*432, WINED3DTS_WORLDMATRIX(176) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(176)), transform_worldex },
3071 { /*433, WINED3DTS_WORLDMATRIX(177) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(177)), transform_worldex },
3072 { /*434, WINED3DTS_WORLDMATRIX(178) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(178)), transform_worldex },
3073 { /*435, WINED3DTS_WORLDMATRIX(179) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(179)), transform_worldex },
3074 { /*436, WINED3DTS_WORLDMATRIX(180) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(180)), transform_worldex },
3075 { /*437, WINED3DTS_WORLDMATRIX(181) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(181)), transform_worldex },
3076 { /*438, WINED3DTS_WORLDMATRIX(182) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(182)), transform_worldex },
3077 { /*439, WINED3DTS_WORLDMATRIX(183) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(183)), transform_worldex },
3078 { /*440, WINED3DTS_WORLDMATRIX(184) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(184)), transform_worldex },
3079 { /*441, WINED3DTS_WORLDMATRIX(185) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(185)), transform_worldex },
3080 { /*441, WINED3DTS_WORLDMATRIX(186) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(186)), transform_worldex },
3081 { /*443, WINED3DTS_WORLDMATRIX(187) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(187)), transform_worldex },
3082 { /*444, WINED3DTS_WORLDMATRIX(188) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(188)), transform_worldex },
3083 { /*445, WINED3DTS_WORLDMATRIX(189) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(189)), transform_worldex },
3084 { /*446, WINED3DTS_WORLDMATRIX(190) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(190)), transform_worldex },
3085 { /*447, WINED3DTS_WORLDMATRIX(191) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(191)), transform_worldex },
3086 { /*448, WINED3DTS_WORLDMATRIX(192) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(192)), transform_worldex },
3087 { /*449, WINED3DTS_WORLDMATRIX(193) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(193)), transform_worldex },
3088 { /*450, WINED3DTS_WORLDMATRIX(194) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(194)), transform_worldex },
3089 { /*451, WINED3DTS_WORLDMATRIX(195) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(195)), transform_worldex },
3090 { /*452, WINED3DTS_WORLDMATRIX(196) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(196)), transform_worldex },
3091 { /*453, WINED3DTS_WORLDMATRIX(197) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(197)), transform_worldex },
3092 { /*454, WINED3DTS_WORLDMATRIX(198) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(198)), transform_worldex },
3093 { /*455, WINED3DTS_WORLDMATRIX(199) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(199)), transform_worldex },
3094 { /*356, WINED3DTS_WORLDMATRIX(200) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(200)), transform_worldex },
3095 { /*457, WINED3DTS_WORLDMATRIX(201) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(201)), transform_worldex },
3096 { /*458, WINED3DTS_WORLDMATRIX(202) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(202)), transform_worldex },
3097 { /*459, WINED3DTS_WORLDMATRIX(203) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(203)), transform_worldex },
3098 { /*460, WINED3DTS_WORLDMATRIX(204) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(204)), transform_worldex },
3099 { /*461, WINED3DTS_WORLDMATRIX(205) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(205)), transform_worldex },
3100 { /*462, WINED3DTS_WORLDMATRIX(206) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(206)), transform_worldex },
3101 { /*463, WINED3DTS_WORLDMATRIX(207) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(207)), transform_worldex },
3102 { /*464, WINED3DTS_WORLDMATRIX(208) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(208)), transform_worldex },
3103 { /*465, WINED3DTS_WORLDMATRIX(209) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(209)), transform_worldex },
3104 { /*466, WINED3DTS_WORLDMATRIX(210) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(210)), transform_worldex },
3105 { /*467, WINED3DTS_WORLDMATRIX(211) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(211)), transform_worldex },
3106 { /*468, WINED3DTS_WORLDMATRIX(212) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(212)), transform_worldex },
3107 { /*469, WINED3DTS_WORLDMATRIX(213) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(213)), transform_worldex },
3108 { /*470, WINED3DTS_WORLDMATRIX(214) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(214)), transform_worldex },
3109 { /*471, WINED3DTS_WORLDMATRIX(215) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(215)), transform_worldex },
3110 { /*472, WINED3DTS_WORLDMATRIX(216) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(216)), transform_worldex },
3111 { /*473, WINED3DTS_WORLDMATRIX(217) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(217)), transform_worldex },
3112 { /*474, WINED3DTS_WORLDMATRIX(218) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(218)), transform_worldex },
3113 { /*475, WINED3DTS_WORLDMATRIX(219) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(219)), transform_worldex },
3114 { /*476, WINED3DTS_WORLDMATRIX(220) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(220)), transform_worldex },
3115 { /*477, WINED3DTS_WORLDMATRIX(221) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(221)), transform_worldex },
3116 { /*478, WINED3DTS_WORLDMATRIX(222) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(222)), transform_worldex },
3117 { /*479, WINED3DTS_WORLDMATRIX(223) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(223)), transform_worldex },
3118 { /*480, WINED3DTS_WORLDMATRIX(224) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(224)), transform_worldex },
3119 { /*481, WINED3DTS_WORLDMATRIX(225) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(225)), transform_worldex },
3120 { /*482, WINED3DTS_WORLDMATRIX(226) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(226)), transform_worldex },
3121 { /*483, WINED3DTS_WORLDMATRIX(227) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(227)), transform_worldex },
3122 { /*484, WINED3DTS_WORLDMATRIX(228) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(228)), transform_worldex },
3123 { /*485, WINED3DTS_WORLDMATRIX(229) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(229)), transform_worldex },
3124 { /*486, WINED3DTS_WORLDMATRIX(230) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(230)), transform_worldex },
3125 { /*487, WINED3DTS_WORLDMATRIX(231) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(231)), transform_worldex },
3126 { /*488, WINED3DTS_WORLDMATRIX(232) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(232)), transform_worldex },
3127 { /*489, WINED3DTS_WORLDMATRIX(233) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(233)), transform_worldex },
3128 { /*490, WINED3DTS_WORLDMATRIX(234) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(234)), transform_worldex },
3129 { /*491, WINED3DTS_WORLDMATRIX(235) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(235)), transform_worldex },
3130 { /*492, WINED3DTS_WORLDMATRIX(236) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(236)), transform_worldex },
3131 { /*493, WINED3DTS_WORLDMATRIX(237) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(237)), transform_worldex },
3132 { /*494, WINED3DTS_WORLDMATRIX(238) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(238)), transform_worldex },
3133 { /*495, WINED3DTS_WORLDMATRIX(239) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(239)), transform_worldex },
3134 { /*496, WINED3DTS_WORLDMATRIX(240) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(240)), transform_worldex },
3135 { /*497, WINED3DTS_WORLDMATRIX(241) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(241)), transform_worldex },
3136 { /*498, WINED3DTS_WORLDMATRIX(242) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(242)), transform_worldex },
3137 { /*499, WINED3DTS_WORLDMATRIX(243) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(243)), transform_worldex },
3138 { /*500, WINED3DTS_WORLDMATRIX(244) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(244)), transform_worldex },
3139 { /*501, WINED3DTS_WORLDMATRIX(245) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(245)), transform_worldex },
3140 { /*502, WINED3DTS_WORLDMATRIX(246) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(246)), transform_worldex },
3141 { /*503, WINED3DTS_WORLDMATRIX(247) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(247)), transform_worldex },
3142 { /*504, WINED3DTS_WORLDMATRIX(248) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(248)), transform_worldex },
3143 { /*505, WINED3DTS_WORLDMATRIX(249) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(249)), transform_worldex },
3144 { /*506, WINED3DTS_WORLDMATRIX(250) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(250)), transform_worldex },
3145 { /*507, WINED3DTS_WORLDMATRIX(251) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(251)), transform_worldex },
3146 { /*508, WINED3DTS_WORLDMATRIX(252) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(252)), transform_worldex },
3147 { /*509, WINED3DTS_WORLDMATRIX(253) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(253)), transform_worldex },
3148 { /*510, WINED3DTS_WORLDMATRIX(254) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(254)), transform_worldex },
3149 { /*511, WINED3DTS_WORLDMATRIX(255) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(255)), transform_worldex },
3150 /* Various Vertex states follow */
3151 { /* , STATE_STREAMSRC */ STATE_VDECL, vertexdeclaration },
3152 { /* , STATE_VDECL */ STATE_VDECL, vertexdeclaration },
3153 { /* , STATE_VSHADER */ STATE_VDECL, vertexdeclaration },
3154 { /* , STATE_VIEWPORT */ STATE_VIEWPORT, viewport },