wined3d: Add a viewport state to the state table.
[wine/multimedia.git] / dlls / wined3d / state.c
blob3eed45ef78aabc45bbe327b0e3d34627dcb57f7f
1 /*
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
21 #include "config.h"
22 #include <stdio.h>
23 #ifdef HAVE_FLOAT_H
24 # include <float.h>
25 #endif
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]);
39 } else {
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];
56 switch(Value) {
57 case D3DFILL_POINT:
58 glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
59 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_POINT)");
60 break;
61 case D3DFILL_WIREFRAME:
62 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
63 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)");
64 break;
65 case D3DFILL_SOLID:
66 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
67 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)");
68 break;
69 default:
70 FIXME("Unrecognized WINED3DRS_FILLMODE value %d\n", Value);
74 static void state_lighting(DWORD state, IWineD3DStateBlockImpl *stateblock) {
76 /* TODO: Lighting is only enabled if Vertex normals are passed by the application,
77 * so merge the lighting render state with the vertex declaration once it is available
80 if (stateblock->renderState[WINED3DRS_LIGHTING]) {
81 glEnable(GL_LIGHTING);
82 checkGLcall("glEnable GL_LIGHTING");
83 } else {
84 glDisable(GL_LIGHTING);
85 checkGLcall("glDisable GL_LIGHTING");
89 static void state_zenable(DWORD state, IWineD3DStateBlockImpl *stateblock) {
90 switch ((WINED3DZBUFFERTYPE) stateblock->renderState[WINED3DRS_ZENABLE]) {
91 case WINED3DZB_FALSE:
92 glDisable(GL_DEPTH_TEST);
93 checkGLcall("glDisable GL_DEPTH_TEST");
94 break;
95 case WINED3DZB_TRUE:
96 glEnable(GL_DEPTH_TEST);
97 checkGLcall("glEnable GL_DEPTH_TEST");
98 break;
99 case WINED3DZB_USEW:
100 glEnable(GL_DEPTH_TEST);
101 checkGLcall("glEnable GL_DEPTH_TEST");
102 FIXME("W buffer is not well handled\n");
103 break;
104 default:
105 FIXME("Unrecognized D3DZBUFFERTYPE value %d\n", stateblock->renderState[WINED3DRS_ZENABLE]);
109 static void state_cullmode(DWORD state, IWineD3DStateBlockImpl *stateblock) {
110 /* TODO: Put this into the offscreen / onscreen rendering block due to device->render_offscreen */
112 /* If we are culling "back faces with clockwise vertices" then
113 set front faces to be counter clockwise and enable culling
114 of back faces */
115 switch ((WINED3DCULL) stateblock->renderState[WINED3DRS_CULLMODE]) {
116 case WINED3DCULL_NONE:
117 glDisable(GL_CULL_FACE);
118 checkGLcall("glDisable GL_CULL_FACE");
119 break;
120 case WINED3DCULL_CW:
121 glEnable(GL_CULL_FACE);
122 checkGLcall("glEnable GL_CULL_FACE");
123 if (stateblock->wineD3DDevice->render_offscreen) {
124 glFrontFace(GL_CW);
125 checkGLcall("glFrontFace GL_CW");
126 } else {
127 glFrontFace(GL_CCW);
128 checkGLcall("glFrontFace GL_CCW");
130 glCullFace(GL_BACK);
131 break;
132 case WINED3DCULL_CCW:
133 glEnable(GL_CULL_FACE);
134 checkGLcall("glEnable GL_CULL_FACE");
135 if (stateblock->wineD3DDevice->render_offscreen) {
136 glFrontFace(GL_CCW);
137 checkGLcall("glFrontFace GL_CCW");
138 } else {
139 glFrontFace(GL_CW);
140 checkGLcall("glFrontFace GL_CW");
142 glCullFace(GL_BACK);
143 break;
144 default:
145 FIXME("Unrecognized/Unhandled WINED3DCULL value %d\n", stateblock->renderState[WINED3DRS_CULLMODE]);
149 static void state_shademode(DWORD state, IWineD3DStateBlockImpl *stateblock) {
150 switch ((WINED3DSHADEMODE) stateblock->renderState[WINED3DRS_SHADEMODE]) {
151 case WINED3DSHADE_FLAT:
152 glShadeModel(GL_FLAT);
153 checkGLcall("glShadeModel(GL_FLAT)");
154 break;
155 case WINED3DSHADE_GOURAUD:
156 glShadeModel(GL_SMOOTH);
157 checkGLcall("glShadeModel(GL_SMOOTH)");
158 break;
159 case WINED3DSHADE_PHONG:
160 FIXME("WINED3DSHADE_PHONG isn't supported\n");
161 break;
162 default:
163 FIXME("Unrecognized/Unhandled WINED3DSHADEMODE value %d\n", stateblock->renderState[WINED3DRS_SHADEMODE]);
167 static void state_ditherenable(DWORD state, IWineD3DStateBlockImpl *stateblock) {
168 if (stateblock->renderState[WINED3DRS_DITHERENABLE]) {
169 glEnable(GL_DITHER);
170 checkGLcall("glEnable GL_DITHER");
171 } else {
172 glDisable(GL_DITHER);
173 checkGLcall("glDisable GL_DITHER");
177 static void state_zwritenable(DWORD state, IWineD3DStateBlockImpl *stateblock) {
178 /* TODO: Test if in d3d z writing is enabled even if ZENABLE is off. If yes,
179 * this has to be merged with ZENABLE and ZFUNC
181 if (stateblock->renderState[WINED3DRS_ZWRITEENABLE]) {
182 glDepthMask(1);
183 checkGLcall("glDepthMask(1)");
184 } else {
185 glDepthMask(0);
186 checkGLcall("glDepthMask(0)");
190 static void state_zfunc(DWORD state, IWineD3DStateBlockImpl *stateblock) {
191 int glParm = CompareFunc(stateblock->renderState[WINED3DRS_ZFUNC]);
193 if(glParm) {
194 glDepthFunc(glParm);
195 checkGLcall("glDepthFunc");
199 static void state_ambient(DWORD state, IWineD3DStateBlockImpl *stateblock) {
200 float col[4];
201 D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_AMBIENT], col);
203 TRACE("Setting ambient to (%f,%f,%f,%f)\n", col[0], col[1], col[2], col[3]);
204 glLightModelfv(GL_LIGHT_MODEL_AMBIENT, col);
205 checkGLcall("glLightModel for MODEL_AMBIENT");
208 static void state_blend(DWORD state, IWineD3DStateBlockImpl *stateblock) {
209 int srcBlend = GL_ZERO;
210 int dstBlend = GL_ZERO;
212 /* GL_LINE_SMOOTH needs GL_BLEND to work, according to the red book, and special blending params */
213 if (stateblock->renderState[WINED3DRS_ALPHABLENDENABLE] ||
214 stateblock->renderState[WINED3DRS_EDGEANTIALIAS] ||
215 stateblock->renderState[WINED3DRS_ANTIALIASEDLINEENABLE]) {
216 glEnable(GL_BLEND);
217 checkGLcall("glEnable GL_BLEND");
218 } else {
219 glDisable(GL_BLEND);
220 checkGLcall("glDisable GL_BLEND");
221 /* Nothing more to do - get out */
222 return;
225 switch (stateblock->renderState[WINED3DRS_SRCBLEND]) {
226 case WINED3DBLEND_ZERO : srcBlend = GL_ZERO; break;
227 case WINED3DBLEND_ONE : srcBlend = GL_ONE; break;
228 case WINED3DBLEND_SRCCOLOR : srcBlend = GL_SRC_COLOR; break;
229 case WINED3DBLEND_INVSRCCOLOR : srcBlend = GL_ONE_MINUS_SRC_COLOR; break;
230 case WINED3DBLEND_SRCALPHA : srcBlend = GL_SRC_ALPHA; break;
231 case WINED3DBLEND_INVSRCALPHA : srcBlend = GL_ONE_MINUS_SRC_ALPHA; break;
232 case WINED3DBLEND_DESTALPHA : srcBlend = GL_DST_ALPHA; break;
233 case WINED3DBLEND_INVDESTALPHA : srcBlend = GL_ONE_MINUS_DST_ALPHA; break;
234 case WINED3DBLEND_DESTCOLOR : srcBlend = GL_DST_COLOR; break;
235 case WINED3DBLEND_INVDESTCOLOR : srcBlend = GL_ONE_MINUS_DST_COLOR; break;
236 case WINED3DBLEND_SRCALPHASAT : srcBlend = GL_SRC_ALPHA_SATURATE; break;
238 case WINED3DBLEND_BOTHSRCALPHA : srcBlend = GL_SRC_ALPHA;
239 dstBlend = GL_SRC_ALPHA;
240 break;
242 case WINED3DBLEND_BOTHINVSRCALPHA : srcBlend = GL_ONE_MINUS_SRC_ALPHA;
243 dstBlend = GL_ONE_MINUS_SRC_ALPHA;
244 break;
246 case WINED3DBLEND_BLENDFACTOR : srcBlend = GL_CONSTANT_COLOR; break;
247 case WINED3DBLEND_INVBLENDFACTOR : srcBlend = GL_ONE_MINUS_CONSTANT_COLOR; break;
248 default:
249 FIXME("Unrecognized src blend value %d\n", stateblock->renderState[WINED3DRS_SRCBLEND]);
252 switch (stateblock->renderState[WINED3DRS_DESTBLEND]) {
253 case WINED3DBLEND_ZERO : dstBlend = GL_ZERO; break;
254 case WINED3DBLEND_ONE : dstBlend = GL_ONE; break;
255 case WINED3DBLEND_SRCCOLOR : dstBlend = GL_SRC_COLOR; break;
256 case WINED3DBLEND_INVSRCCOLOR : dstBlend = GL_ONE_MINUS_SRC_COLOR; break;
257 case WINED3DBLEND_SRCALPHA : dstBlend = GL_SRC_ALPHA; break;
258 case WINED3DBLEND_INVSRCALPHA : dstBlend = GL_ONE_MINUS_SRC_ALPHA; break;
259 case WINED3DBLEND_DESTALPHA : dstBlend = GL_DST_ALPHA; break;
260 case WINED3DBLEND_INVDESTALPHA : dstBlend = GL_ONE_MINUS_DST_ALPHA; break;
261 case WINED3DBLEND_DESTCOLOR : dstBlend = GL_DST_COLOR; break;
262 case WINED3DBLEND_INVDESTCOLOR : dstBlend = GL_ONE_MINUS_DST_COLOR; break;
263 case WINED3DBLEND_SRCALPHASAT : dstBlend = GL_SRC_ALPHA_SATURATE; break;
265 case WINED3DBLEND_BOTHSRCALPHA : dstBlend = GL_SRC_ALPHA;
266 srcBlend = GL_SRC_ALPHA;
267 break;
269 case WINED3DBLEND_BOTHINVSRCALPHA : dstBlend = GL_ONE_MINUS_SRC_ALPHA;
270 srcBlend = GL_ONE_MINUS_SRC_ALPHA;
271 break;
273 case D3DBLEND_BLENDFACTOR : dstBlend = GL_CONSTANT_COLOR; break;
274 case D3DBLEND_INVBLENDFACTOR : dstBlend = GL_ONE_MINUS_CONSTANT_COLOR; break;
275 default:
276 FIXME("Unrecognized dst blend value %d\n", stateblock->renderState[WINED3DRS_DESTBLEND]);
279 if(stateblock->renderState[WINED3DRS_EDGEANTIALIAS] ||
280 stateblock->renderState[WINED3DRS_ANTIALIASEDLINEENABLE]) {
281 glEnable(GL_LINE_SMOOTH);
282 checkGLcall("glEnable(GL_LINE_SMOOTH)");
283 if(srcBlend != GL_SRC_ALPHA) {
284 FIXME("WINED3DRS_EDGEANTIALIAS enabled, but incompatible src blending param - what to do?\n");
285 srcBlend = GL_SRC_ALPHA;
287 if(dstBlend != GL_ONE_MINUS_SRC_ALPHA) {
288 FIXME("WINED3DRS_EDGEANTIALIAS enabled, but incompatible dst blending param - what to do?\n");
289 dstBlend = GL_ONE_MINUS_SRC_ALPHA;
291 } else {
292 glDisable(GL_LINE_SMOOTH);
293 checkGLcall("glDisable(GL_LINE_SMOOTH)");
296 TRACE("glBlendFunc src=%x, dst=%x\n", srcBlend, dstBlend);
297 glBlendFunc(srcBlend, dstBlend);
298 checkGLcall("glBlendFunc");
300 /* TODO: Remove when state management done */
301 stateblock->wineD3DDevice->dstBlend = dstBlend;
302 stateblock->wineD3DDevice->srcBlend = srcBlend;
305 static void state_blendfactor(DWORD state, IWineD3DStateBlockImpl *stateblock) {
306 float col[4];
308 TRACE("Setting BlendFactor to %d\n", stateblock->renderState[WINED3DRS_BLENDFACTOR]);
309 D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_BLENDFACTOR], col);
310 glBlendColor (col[0],col[1],col[2],col[3]);
311 checkGLcall("glBlendColor");
314 static void state_alpha(DWORD state, IWineD3DStateBlockImpl *stateblock) {
315 int glParm = 0;
316 float ref;
317 BOOL enable_ckey = FALSE;
319 IWineD3DSurfaceImpl *surf;
321 /* Find out if the texture on the first stage has a ckey set
322 * The alpha state func reads the texture settings, even though alpha and texture are not grouped
323 * together. This is to avoid making a huge alpha+texture+texture stage+ckey block due to the hardly
324 * used WINED3DRS_COLORKEYENABLE state(which is d3d <= 3 only). The texture function will call alpha
325 * in case it finds some texture+colorkeyenable combination which needs extra care.
327 if(stateblock->textures[0]) {
328 surf = (IWineD3DSurfaceImpl *) ((IWineD3DTextureImpl *)stateblock->textures[0])->surfaces[0];
329 if(surf->CKeyFlags & DDSD_CKSRCBLT) enable_ckey = TRUE;
332 if (stateblock->renderState[WINED3DRS_ALPHATESTENABLE] ||
333 (stateblock->renderState[WINED3DRS_COLORKEYENABLE] && enable_ckey)) {
334 glEnable(GL_ALPHA_TEST);
335 checkGLcall("glEnable GL_ALPHA_TEST");
336 } else {
337 glDisable(GL_ALPHA_TEST);
338 checkGLcall("glDisable GL_ALPHA_TEST");
339 /* Alpha test is disabled, don't bother setting the params - it will happen on the next
340 * enable call
342 return;
345 if(stateblock->renderState[WINED3DRS_COLORKEYENABLE] && enable_ckey) {
346 glParm = GL_NOTEQUAL;
347 ref = 0.0;
348 } else {
349 ref = ((float) stateblock->renderState[WINED3DRS_ALPHAREF]) / 255.0f;
350 glParm = CompareFunc(stateblock->renderState[WINED3DRS_ALPHAFUNC]);
352 if(glParm) {
353 stateblock->wineD3DDevice->alphafunc = glParm; /* Remove when state management done */
354 glAlphaFunc(glParm, ref);
355 checkGLcall("glAlphaFunc");
357 /* TODO: Some texture blending operations seem to affect the alpha test */
360 static void state_clipping(DWORD state, IWineD3DStateBlockImpl *stateblock) {
361 DWORD enable = 0xFFFFFFFF;
362 DWORD disable = 0x00000000;
364 /* TODO: Keep track of previously enabled clipplanes to avoid unneccessary resetting
365 * of already set values
368 /* If enabling / disabling all
369 * TODO: Is this correct? Doesn't D3DRS_CLIPPING disable clipping on the viewport frustrum?
371 if (stateblock->renderState[WINED3DRS_CLIPPING]) {
372 enable = stateblock->renderState[WINED3DRS_CLIPPLANEENABLE];
373 disable = ~stateblock->renderState[WINED3DRS_CLIPPLANEENABLE];
374 } else {
375 disable = 0xffffffff;
376 enable = 0x00;
379 if (enable & WINED3DCLIPPLANE0) { glEnable(GL_CLIP_PLANE0); checkGLcall("glEnable(clip plane 0)"); }
380 if (enable & WINED3DCLIPPLANE1) { glEnable(GL_CLIP_PLANE1); checkGLcall("glEnable(clip plane 1)"); }
381 if (enable & WINED3DCLIPPLANE2) { glEnable(GL_CLIP_PLANE2); checkGLcall("glEnable(clip plane 2)"); }
382 if (enable & WINED3DCLIPPLANE3) { glEnable(GL_CLIP_PLANE3); checkGLcall("glEnable(clip plane 3)"); }
383 if (enable & WINED3DCLIPPLANE4) { glEnable(GL_CLIP_PLANE4); checkGLcall("glEnable(clip plane 4)"); }
384 if (enable & WINED3DCLIPPLANE5) { glEnable(GL_CLIP_PLANE5); checkGLcall("glEnable(clip plane 5)"); }
386 if (disable & WINED3DCLIPPLANE0) { glDisable(GL_CLIP_PLANE0); checkGLcall("glDisable(clip plane 0)"); }
387 if (disable & WINED3DCLIPPLANE1) { glDisable(GL_CLIP_PLANE1); checkGLcall("glDisable(clip plane 1)"); }
388 if (disable & WINED3DCLIPPLANE2) { glDisable(GL_CLIP_PLANE2); checkGLcall("glDisable(clip plane 2)"); }
389 if (disable & WINED3DCLIPPLANE3) { glDisable(GL_CLIP_PLANE3); checkGLcall("glDisable(clip plane 3)"); }
390 if (disable & WINED3DCLIPPLANE4) { glDisable(GL_CLIP_PLANE4); checkGLcall("glDisable(clip plane 4)"); }
391 if (disable & WINED3DCLIPPLANE5) { glDisable(GL_CLIP_PLANE5); checkGLcall("glDisable(clip plane 5)"); }
393 /** update clipping status */
394 if (enable) {
395 stateblock->clip_status.ClipUnion = 0;
396 stateblock->clip_status.ClipIntersection = 0xFFFFFFFF;
397 } else {
398 stateblock->clip_status.ClipUnion = 0;
399 stateblock->clip_status.ClipIntersection = 0;
403 static void state_blendop(DWORD state, IWineD3DStateBlockImpl *stateblock) {
404 int glParm = GL_FUNC_ADD;
406 if(!GL_SUPPORT(EXT_BLEND_MINMAX)) {
407 WARN("Unsupported in local OpenGL implementation: glBlendEquation\n");
408 return;
411 switch ((WINED3DBLENDOP) stateblock->renderState[WINED3DRS_BLENDOP]) {
412 case WINED3DBLENDOP_ADD : glParm = GL_FUNC_ADD; break;
413 case WINED3DBLENDOP_SUBTRACT : glParm = GL_FUNC_SUBTRACT; break;
414 case WINED3DBLENDOP_REVSUBTRACT : glParm = GL_FUNC_REVERSE_SUBTRACT; break;
415 case WINED3DBLENDOP_MIN : glParm = GL_MIN; break;
416 case WINED3DBLENDOP_MAX : glParm = GL_MAX; break;
417 default:
418 FIXME("Unrecognized/Unhandled D3DBLENDOP value %d\n", stateblock->renderState[WINED3DRS_BLENDOP]);
421 TRACE("glBlendEquation(%x)\n", glParm);
422 GL_EXTCALL(glBlendEquation(glParm));
423 checkGLcall("glBlendEquation");
426 static void
427 state_specularenable(DWORD state, IWineD3DStateBlockImpl *stateblock) {
428 /* Originally this used glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR)
429 * and (GL_LIGHT_MODEL_COLOR_CONTROL,GL_SINGLE_COLOR) to swap between enabled/disabled
430 * specular color. This is wrong:
431 * Separate specular color means the specular colour is maintained separately, whereas
432 * single color means it is merged in. However in both cases they are being used to
433 * some extent.
434 * To disable specular color, set it explicitly to black and turn off GL_COLOR_SUM_EXT
435 * NOTE: If not supported don't give FIXMEs the impact is really minimal and very few people are
436 * running 1.4 yet!
439 * If register combiners are enabled, enabling / disabling GL_COLOR_SUM has no effect.
440 * Instead, we need to setup the FinalCombiner properly.
442 * The default setup for the FinalCombiner is:
444 * <variable> <input> <mapping> <usage>
445 * GL_VARIABLE_A_NV GL_FOG, GL_UNSIGNED_IDENTITY_NV GL_ALPHA
446 * GL_VARIABLE_B_NV GL_SPARE0_PLUS_SECONDARY_COLOR_NV GL_UNSIGNED_IDENTITY_NV GL_RGB
447 * GL_VARIABLE_C_NV GL_FOG GL_UNSIGNED_IDENTITY_NV GL_RGB
448 * GL_VARIABLE_D_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
449 * GL_VARIABLE_E_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
450 * GL_VARIABLE_F_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
451 * GL_VARIABLE_G_NV GL_SPARE0_NV GL_UNSIGNED_IDENTITY_NV GL_ALPHA
453 * That's pretty much fine as it is, except for variable B, which needs to take
454 * either GL_SPARE0_PLUS_SECONDARY_COLOR_NV or GL_SPARE0_NV, depending on
455 * whether WINED3DRS_SPECULARENABLE is enabled or not.
458 TRACE("Setting specular enable state\n");
459 /* TODO: Add to the material setting functions */
460 if (stateblock->renderState[WINED3DRS_SPECULARENABLE]) {
461 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float*) &stateblock->material.Specular);
462 checkGLcall("glMaterialfv");
463 if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
464 glEnable(GL_COLOR_SUM_EXT);
465 } else {
466 TRACE("Specular colors cannot be enabled in this version of opengl\n");
468 checkGLcall("glEnable(GL_COLOR_SUM)");
470 if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
471 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_SPARE0_PLUS_SECONDARY_COLOR_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB));
472 checkGLcall("glFinalCombinerInputNV()");
474 } else {
475 float black[4] = {0.0f, 0.0f, 0.0f, 0.0f};
477 /* for the case of enabled lighting: */
478 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, &black[0]);
479 checkGLcall("glMaterialfv");
481 /* for the case of disabled lighting: */
482 if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
483 glDisable(GL_COLOR_SUM_EXT);
484 } else {
485 TRACE("Specular colors cannot be disabled in this version of opengl\n");
487 checkGLcall("glDisable(GL_COLOR_SUM)");
489 if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
490 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB));
491 checkGLcall("glFinalCombinerInputNV()");
496 static void state_texfactor(DWORD state, IWineD3DStateBlockImpl *stateblock) {
497 unsigned int i;
499 /* Note the texture color applies to all textures whereas
500 * GL_TEXTURE_ENV_COLOR applies to active only
502 float col[4];
503 D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_TEXTUREFACTOR], col);
505 if (!GL_SUPPORT(NV_REGISTER_COMBINERS)) {
506 /* And now the default texture color as well */
507 for (i = 0; i < GL_LIMITS(texture_stages); i++) {
508 /* Note the WINED3DRS value applies to all textures, but GL has one
509 * per texture, so apply it now ready to be used!
511 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
512 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + i));
513 checkGLcall("glActiveTextureARB");
514 } else if (i>0) {
515 FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
518 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &col[0]);
519 checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);");
521 } else {
522 GL_EXTCALL(glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV, &col[0]));
526 static void
527 renderstate_stencil_twosided(IWineD3DStateBlockImpl *stateblock, GLint face, GLint func, GLint ref, GLuint mask, GLint stencilFail, GLint depthFail, GLint stencilPass ) {
528 #if 0 /* Don't use OpenGL 2.0 calls for now */
529 if(GL_EXTCALL(glStencilFuncSeparate) && GL_EXTCALL(glStencilOpSeparate)) {
530 GL_EXTCALL(glStencilFuncSeparate(face, func, ref, mask));
531 checkGLcall("glStencilFuncSeparate(...)");
532 GL_EXTCALL(glStencilOpSeparate(face, stencilFail, depthFail, stencilPass));
533 checkGLcall("glStencilOpSeparate(...)");
535 else
536 #endif
537 if(GL_SUPPORT(EXT_STENCIL_TWO_SIDE)) {
538 glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT);
539 checkGLcall("glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT)");
540 GL_EXTCALL(glActiveStencilFaceEXT(face));
541 checkGLcall("glActiveStencilFaceEXT(...)");
542 glStencilFunc(func, ref, mask);
543 checkGLcall("glStencilFunc(...)");
544 glStencilOp(stencilFail, depthFail, stencilPass);
545 checkGLcall("glStencilOp(...)");
546 } else if(GL_SUPPORT(ATI_SEPARATE_STENCIL)) {
547 GL_EXTCALL(glStencilFuncSeparateATI(face, func, ref, mask));
548 checkGLcall("glStencilFuncSeparateATI(...)");
549 GL_EXTCALL(glStencilOpSeparateATI(face, stencilFail, depthFail, stencilPass));
550 checkGLcall("glStencilOpSeparateATI(...)");
551 } else {
552 ERR("Separate (two sided) stencil not supported on this version of opengl. Caps weren't honored?\n");
556 static void
557 state_stencil(DWORD state, IWineD3DStateBlockImpl *stateblock) {
558 DWORD onesided_enable = FALSE;
559 DWORD twosided_enable = FALSE;
560 GLint func = GL_ALWAYS;
561 GLint func_ccw = GL_ALWAYS;
562 GLint ref = 0;
563 GLuint mask = 0;
564 GLint stencilFail = GL_KEEP;
565 GLint depthFail = GL_KEEP;
566 GLint stencilPass = GL_KEEP;
567 GLint stencilFail_ccw = GL_KEEP;
568 GLint depthFail_ccw = GL_KEEP;
569 GLint stencilPass_ccw = GL_KEEP;
571 if( stateblock->set.renderState[WINED3DRS_STENCILENABLE] )
572 onesided_enable = stateblock->renderState[WINED3DRS_STENCILENABLE];
573 if( stateblock->set.renderState[WINED3DRS_TWOSIDEDSTENCILMODE] )
574 twosided_enable = stateblock->renderState[WINED3DRS_TWOSIDEDSTENCILMODE];
575 if( stateblock->set.renderState[WINED3DRS_STENCILFUNC] )
576 if( !( func = CompareFunc(stateblock->renderState[WINED3DRS_STENCILFUNC]) ) )
577 func = GL_ALWAYS;
578 if( stateblock->set.renderState[WINED3DRS_CCW_STENCILFUNC] )
579 if( !( func_ccw = CompareFunc(stateblock->renderState[WINED3DRS_CCW_STENCILFUNC]) ) )
580 func = GL_ALWAYS;
581 if( stateblock->set.renderState[WINED3DRS_STENCILREF] )
582 ref = stateblock->renderState[WINED3DRS_STENCILREF];
583 if( stateblock->set.renderState[WINED3DRS_STENCILMASK] )
584 mask = stateblock->renderState[WINED3DRS_STENCILMASK];
585 if( stateblock->set.renderState[WINED3DRS_STENCILFAIL] )
586 stencilFail = StencilOp(stateblock->renderState[WINED3DRS_STENCILFAIL]);
587 if( stateblock->set.renderState[WINED3DRS_STENCILZFAIL] )
588 depthFail = StencilOp(stateblock->renderState[WINED3DRS_STENCILZFAIL]);
589 if( stateblock->set.renderState[WINED3DRS_STENCILPASS] )
590 stencilPass = StencilOp(stateblock->renderState[WINED3DRS_STENCILPASS]);
591 if( stateblock->set.renderState[WINED3DRS_CCW_STENCILFAIL] )
592 stencilFail_ccw = StencilOp(stateblock->renderState[WINED3DRS_CCW_STENCILFAIL]);
593 if( stateblock->set.renderState[WINED3DRS_CCW_STENCILZFAIL] )
594 depthFail_ccw = StencilOp(stateblock->renderState[WINED3DRS_CCW_STENCILZFAIL]);
595 if( stateblock->set.renderState[WINED3DRS_CCW_STENCILPASS] )
596 stencilPass_ccw = StencilOp(stateblock->renderState[WINED3DRS_CCW_STENCILPASS]);
598 TRACE("(onesided %d, twosided %d, ref %x, mask %x, \
599 GL_FRONT: func: %x, fail %x, zfail %x, zpass %x \
600 GL_BACK: func: %x, fail %x, zfail %x, zpass %x )\n",
601 onesided_enable, twosided_enable, ref, mask,
602 func, stencilFail, depthFail, stencilPass,
603 func_ccw, stencilFail_ccw, depthFail_ccw, stencilPass_ccw);
605 if (twosided_enable) {
606 renderstate_stencil_twosided(stateblock, GL_FRONT, func, ref, mask, stencilFail, depthFail, stencilPass);
607 renderstate_stencil_twosided(stateblock, GL_BACK, func_ccw, ref, mask, stencilFail_ccw, depthFail_ccw, stencilPass_ccw);
608 } else {
609 if (onesided_enable) {
610 glEnable(GL_STENCIL_TEST);
611 checkGLcall("glEnable GL_STENCIL_TEST");
612 glStencilFunc(func, ref, mask);
613 checkGLcall("glStencilFunc(...)");
614 glStencilOp(stencilFail, depthFail, stencilPass);
615 checkGLcall("glStencilOp(...)");
616 } else {
617 glDisable(GL_STENCIL_TEST);
618 checkGLcall("glDisable GL_STENCIL_TEST");
623 static void state_stencilwrite(DWORD state, IWineD3DStateBlockImpl *stateblock) {
624 glStencilMask(stateblock->renderState[WINED3DRS_STENCILWRITEMASK]);
625 checkGLcall("glStencilMask");
628 static void state_fog(DWORD state, IWineD3DStateBlockImpl *stateblock) {
629 /* TODO: Put this into the vertex type block once that is in the state table */
630 BOOL fogenable = stateblock->renderState[WINED3DRS_FOGENABLE];
631 float fogstart, fogend;
633 union {
634 DWORD d;
635 float f;
636 } tmpvalue;
638 if (!fogenable) {
639 /* No fog? Disable it, and we're done :-) */
640 glDisable(GL_FOG);
641 checkGLcall("glDisable GL_FOG");
644 tmpvalue.d = stateblock->renderState[WINED3DRS_FOGSTART];
645 fogstart = tmpvalue.f;
646 tmpvalue.d = stateblock->renderState[WINED3DRS_FOGEND];
647 fogend = tmpvalue.f;
649 #if 0
650 /* Activate when vertex shaders are in the state table */
651 if(stateblock->vertexShader && ((IWineD3DVertexShaderImpl *)stateblock->vertexShader)->baseShader.function &&
652 ((IWineD3DVertexShaderImpl *)stateblock->vertexShader)->usesFog) {
653 glFogi(GL_FOG_MODE, GL_LINEAR);
654 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
655 fogstart = 1.0;
656 fogend = 0.0;
657 stateblock->wineD3DDevice->last_was_foggy_shader = TRUE;
659 #endif
661 /* DX 7 sdk: "If both render states(vertex and table fog) are set to valid modes,
662 * the system will apply only pixel(=table) fog effects."
664 /* else */ if(stateblock->renderState[WINED3DRS_FOGTABLEMODE] == D3DFOG_NONE) {
665 glHint(GL_FOG_HINT, GL_FASTEST);
666 checkGLcall("glHint(GL_FOG_HINT, GL_FASTEST)");
667 #if 0
668 stateblock->wineD3DDevice->last_was_foggy_shader = FALSE;
669 #endif
670 switch (stateblock->renderState[WINED3DRS_FOGVERTEXMODE]) {
671 /* Processed vertices have their fog factor stored in the specular value. Fall too the none case.
672 * If we are drawing untransformed vertices atm, d3ddevice_set_ortho will update the fog
674 case D3DFOG_EXP: {
675 if(!stateblock->wineD3DDevice->last_was_rhw) {
676 glFogi(GL_FOG_MODE, GL_EXP);
677 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP");
678 if(GL_SUPPORT(EXT_FOG_COORD)) {
679 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
680 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
682 break;
685 case D3DFOG_EXP2: {
686 if(!stateblock->wineD3DDevice->last_was_rhw) {
687 glFogi(GL_FOG_MODE, GL_EXP2);
688 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2");
689 if(GL_SUPPORT(EXT_FOG_COORD)) {
690 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
691 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
693 break;
696 case D3DFOG_LINEAR: {
697 if(!stateblock->wineD3DDevice->last_was_rhw) {
698 glFogi(GL_FOG_MODE, GL_LINEAR);
699 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR");
700 if(GL_SUPPORT(EXT_FOG_COORD)) {
701 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
702 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
704 break;
707 case D3DFOG_NONE: {
708 /* Both are none? According to msdn the alpha channel of the specular
709 * color contains a fog factor. Set it in drawStridedSlow.
710 * Same happens with Vertexfog on transformed vertices
712 if(GL_SUPPORT(EXT_FOG_COORD)) {
713 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);
714 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT)\n");
715 glFogi(GL_FOG_MODE, GL_LINEAR);
716 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
717 fogstart = 0xff;
718 fogend = 0x0;
719 } else {
720 /* Disable GL fog, handle this in software in drawStridedSlow */
721 fogenable = FALSE;
723 break;
725 default: FIXME("Unexpected WINED3DRS_FOGVERTEXMODE %d\n", stateblock->renderState[WINED3DRS_FOGVERTEXMODE]);
727 } else {
728 glHint(GL_FOG_HINT, GL_NICEST);
729 checkGLcall("glHint(GL_FOG_HINT, GL_NICEST)");
730 #if 0
731 stateblock->wineD3DDevice->last_was_foggy_shader = FALSE;
732 #endif
733 switch (stateblock->renderState[WINED3DRS_FOGTABLEMODE]) {
734 case D3DFOG_EXP:
735 glFogi(GL_FOG_MODE, GL_EXP);
736 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP");
737 if(GL_SUPPORT(EXT_FOG_COORD)) {
738 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
739 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
741 break;
743 case D3DFOG_EXP2:
744 glFogi(GL_FOG_MODE, GL_EXP2);
745 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2");
746 if(GL_SUPPORT(EXT_FOG_COORD)) {
747 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
748 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
750 break;
752 case D3DFOG_LINEAR:
753 glFogi(GL_FOG_MODE, GL_LINEAR);
754 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR");
755 if(GL_SUPPORT(EXT_FOG_COORD)) {
756 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
757 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
759 break;
761 case D3DFOG_NONE: /* Won't happen */
762 default:
763 FIXME("Unexpected WINED3DRS_FOGTABLEMODE %d\n", stateblock->renderState[WINED3DRS_FOGTABLEMODE]);
767 if(fogenable) {
768 glEnable(GL_FOG);
769 checkGLcall("glEnable GL_FOG");
771 glFogfv(GL_FOG_START, &fogstart);
772 checkGLcall("glFogf(GL_FOG_START, fogstart");
773 TRACE("Fog Start == %f\n", fogstart);
775 glFogfv(GL_FOG_END, &fogend);
776 checkGLcall("glFogf(GL_FOG_END, fogend");
777 TRACE("Fog End == %f\n", fogend);
778 } else {
779 glDisable(GL_FOG);
780 checkGLcall("glDisable GL_FOG");
783 if (GL_SUPPORT(NV_FOG_DISTANCE)) {
784 glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_PLANE_ABSOLUTE_NV);
788 static void state_fogcolor(DWORD state, IWineD3DStateBlockImpl *stateblock) {
789 float col[4];
790 D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_FOGCOLOR], col);
791 /* Set the default alpha blend color */
792 glFogfv(GL_FOG_COLOR, &col[0]);
793 checkGLcall("glFog GL_FOG_COLOR");
796 static void state_fogdensity(DWORD state, IWineD3DStateBlockImpl *stateblock) {
797 union {
798 DWORD d;
799 float f;
800 } tmpvalue;
801 tmpvalue.d = stateblock->renderState[WINED3DRS_FOGDENSITY];
802 glFogfv(GL_FOG_DENSITY, &tmpvalue.f);
803 checkGLcall("glFogf(GL_FOG_DENSITY, (float) Value)");
806 /* TODO: Merge with primitive type + init_materials()!! */
807 static void state_colormat(DWORD state, IWineD3DStateBlockImpl *stateblock) {
808 GLenum Parm = GL_AMBIENT_AND_DIFFUSE;
810 if (stateblock->renderState[WINED3DRS_COLORVERTEX]) {
811 TRACE("diff %d, amb %d, emis %d, spec %d\n",
812 stateblock->renderState[WINED3DRS_DIFFUSEMATERIALSOURCE],
813 stateblock->renderState[WINED3DRS_AMBIENTMATERIALSOURCE],
814 stateblock->renderState[WINED3DRS_EMISSIVEMATERIALSOURCE],
815 stateblock->renderState[WINED3DRS_SPECULARMATERIALSOURCE]);
817 if (stateblock->renderState[WINED3DRS_DIFFUSEMATERIALSOURCE] == D3DMCS_COLOR1) {
818 if (stateblock->renderState[WINED3DRS_AMBIENTMATERIALSOURCE] == D3DMCS_COLOR1) {
819 Parm = GL_AMBIENT_AND_DIFFUSE;
820 } else {
821 Parm = GL_DIFFUSE;
823 } else if (stateblock->renderState[WINED3DRS_AMBIENTMATERIALSOURCE] == D3DMCS_COLOR1) {
824 Parm = GL_AMBIENT;
825 } else if (stateblock->renderState[WINED3DRS_EMISSIVEMATERIALSOURCE] == D3DMCS_COLOR1) {
826 Parm = GL_EMISSION;
827 } else if (stateblock->renderState[WINED3DRS_SPECULARMATERIALSOURCE] == D3DMCS_COLOR1) {
828 Parm = GL_SPECULAR;
829 } else {
830 Parm = -1;
833 if (Parm == -1) {
834 if (stateblock->wineD3DDevice->tracking_color != DISABLED_TRACKING) stateblock->wineD3DDevice->tracking_color = NEEDS_DISABLE;
835 } else {
836 stateblock->wineD3DDevice->tracking_color = NEEDS_TRACKING;
837 stateblock->wineD3DDevice->tracking_parm = Parm;
840 } else {
841 if (stateblock->wineD3DDevice->tracking_color != DISABLED_TRACKING) stateblock->wineD3DDevice->tracking_color = NEEDS_DISABLE;
845 static void state_linepattern(DWORD state, IWineD3DStateBlockImpl *stateblock) {
846 union {
847 DWORD d;
848 WINED3DLINEPATTERN lp;
849 } tmppattern;
850 tmppattern.d = stateblock->renderState[WINED3DRS_LINEPATTERN];
852 TRACE("Line pattern: repeat %d bits %x\n", tmppattern.lp.wRepeatFactor, tmppattern.lp.wLinePattern);
854 if (tmppattern.lp.wRepeatFactor) {
855 glLineStipple(tmppattern.lp.wRepeatFactor, tmppattern.lp.wLinePattern);
856 checkGLcall("glLineStipple(repeat, linepattern)");
857 glEnable(GL_LINE_STIPPLE);
858 checkGLcall("glEnable(GL_LINE_STIPPLE);");
859 } else {
860 glDisable(GL_LINE_STIPPLE);
861 checkGLcall("glDisable(GL_LINE_STIPPLE);");
865 static void state_zbias(DWORD state, IWineD3DStateBlockImpl *stateblock) {
866 union {
867 DWORD d;
868 float f;
869 } tmpvalue;
871 if (stateblock->renderState[WINED3DRS_ZBIAS]) {
872 tmpvalue.d = stateblock->renderState[WINED3DRS_ZBIAS];
873 TRACE("ZBias value %f\n", tmpvalue.f);
874 glPolygonOffset(0, -tmpvalue.f);
875 checkGLcall("glPolygonOffset(0, -Value)");
876 glEnable(GL_POLYGON_OFFSET_FILL);
877 checkGLcall("glEnable(GL_POLYGON_OFFSET_FILL);");
878 glEnable(GL_POLYGON_OFFSET_LINE);
879 checkGLcall("glEnable(GL_POLYGON_OFFSET_LINE);");
880 glEnable(GL_POLYGON_OFFSET_POINT);
881 checkGLcall("glEnable(GL_POLYGON_OFFSET_POINT);");
882 } else {
883 glDisable(GL_POLYGON_OFFSET_FILL);
884 checkGLcall("glDisable(GL_POLYGON_OFFSET_FILL);");
885 glDisable(GL_POLYGON_OFFSET_LINE);
886 checkGLcall("glDisable(GL_POLYGON_OFFSET_LINE);");
887 glDisable(GL_POLYGON_OFFSET_POINT);
888 checkGLcall("glDisable(GL_POLYGON_OFFSET_POINT);");
893 static void state_normalize(DWORD state, IWineD3DStateBlockImpl *stateblock) {
894 if (stateblock->renderState[WINED3DRS_NORMALIZENORMALS]) {
895 glEnable(GL_NORMALIZE);
896 checkGLcall("glEnable(GL_NORMALIZE);");
897 } else {
898 glDisable(GL_NORMALIZE);
899 checkGLcall("glDisable(GL_NORMALIZE);");
903 static void state_psize(DWORD state, IWineD3DStateBlockImpl *stateblock) {
904 union {
905 DWORD d;
906 float f;
907 } tmpvalue;
909 /* FIXME: check that pointSize isn't outside glGetFloatv( GL_POINT_SIZE_MAX_ARB, &maxSize ); or -ve */
910 tmpvalue.d = stateblock->renderState[WINED3DRS_POINTSIZE];
911 TRACE("Set point size to %f\n", tmpvalue.f);
912 glPointSize(tmpvalue.f);
913 checkGLcall("glPointSize(...);");
916 static void state_psizemin(DWORD state, IWineD3DStateBlockImpl *stateblock) {
917 union {
918 DWORD d;
919 float f;
920 } tmpvalue;
922 if(GL_SUPPORT(ARB_POINT_PARAMETERS)) {
923 tmpvalue.d = stateblock->renderState[WINED3DRS_POINTSIZE_MIN];
924 GL_EXTCALL(glPointParameterfARB)(GL_POINT_SIZE_MIN_ARB, tmpvalue.f);
925 checkGLcall("glPointParameterfARB(...");
927 else if(GL_SUPPORT(EXT_POINT_PARAMETERS)) {
928 tmpvalue.d = stateblock->renderState[WINED3DRS_POINTSIZE_MIN];
929 GL_EXTCALL(glPointParameterfEXT)(GL_POINT_SIZE_MIN_EXT, tmpvalue.f);
930 checkGLcall("glPointParameterfEXT(...);");
931 } else {
932 FIXME("WINED3DRS_POINTSIZE_MIN not supported on this opengl\n");
936 static void state_psizemax(DWORD state, IWineD3DStateBlockImpl *stateblock) {
937 union {
938 DWORD d;
939 float f;
940 } tmpvalue;
942 if(GL_SUPPORT(ARB_POINT_PARAMETERS)) {
943 tmpvalue.d = stateblock->renderState[WINED3DRS_POINTSIZE_MAX];
944 GL_EXTCALL(glPointParameterfARB)(GL_POINT_SIZE_MAX_ARB, tmpvalue.f);
945 checkGLcall("glPointParameterfARB(...");
947 else if(GL_SUPPORT(EXT_POINT_PARAMETERS)) {
948 tmpvalue.d = stateblock->renderState[WINED3DRS_POINTSIZE_MAX];
949 GL_EXTCALL(glPointParameterfEXT)(GL_POINT_SIZE_MAX_EXT, tmpvalue.f);
950 checkGLcall("glPointParameterfEXT(...);");
951 } else {
952 FIXME("WINED3DRS_POINTSIZE_MAX not supported on this opengl\n");
956 static void state_pscale(DWORD state, IWineD3DStateBlockImpl *stateblock) {
957 /* TODO: Group this with the viewport */
959 * POINTSCALEENABLE controls how point size value is treated. If set to
960 * true, the point size is scaled with respect to height of viewport.
961 * When set to false point size is in pixels.
963 * http://msdn.microsoft.com/library/en-us/directx9_c/point_sprites.asp
966 /* Default values */
967 GLfloat att[3] = {1.0f, 0.0f, 0.0f};
970 * Minimum valid point size for OpenGL is 1.0f. For Direct3D it is 0.0f.
971 * This means that OpenGL will clamp really small point sizes to 1.0f.
972 * To correct for this we need to multiply by the scale factor when sizes
973 * are less than 1.0f. scale_factor = 1.0f / point_size.
975 GLfloat pointSize = *((float*)&stateblock->renderState[WINED3DRS_POINTSIZE]);
976 if(pointSize > 0.0f) {
977 GLfloat scaleFactor;
979 if(pointSize < 1.0f) {
980 scaleFactor = pointSize * pointSize;
981 } else {
982 scaleFactor = 1.0f;
985 if(stateblock->renderState[WINED3DRS_POINTSCALEENABLE]) {
986 att[0] = *((float*)&stateblock->renderState[WINED3DRS_POINTSCALE_A]) /
987 (stateblock->viewport.Height * stateblock->viewport.Height * scaleFactor);
988 att[1] = *((float*)&stateblock->renderState[WINED3DRS_POINTSCALE_B]) /
989 (stateblock->viewport.Height * stateblock->viewport.Height * scaleFactor);
990 att[2] = *((float*)&stateblock->renderState[WINED3DRS_POINTSCALE_C]) /
991 (stateblock->viewport.Height * stateblock->viewport.Height * scaleFactor);
995 if(GL_SUPPORT(ARB_POINT_PARAMETERS)) {
996 GL_EXTCALL(glPointParameterfvARB)(GL_POINT_DISTANCE_ATTENUATION_ARB, att);
997 checkGLcall("glPointParameterfvARB(GL_DISTANCE_ATTENUATION_ARB, ...");
999 else if(GL_SUPPORT(EXT_POINT_PARAMETERS)) {
1000 GL_EXTCALL(glPointParameterfvEXT)(GL_DISTANCE_ATTENUATION_EXT, att);
1001 checkGLcall("glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, ...");
1002 } else {
1003 TRACE("POINT_PARAMETERS not supported in this version of opengl\n");
1007 static void state_colorwrite(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1008 DWORD Value = stateblock->renderState[WINED3DRS_COLORWRITEENABLE];
1010 TRACE("Color mask: r(%d) g(%d) b(%d) a(%d)\n",
1011 Value & D3DCOLORWRITEENABLE_RED ? 1 : 0,
1012 Value & D3DCOLORWRITEENABLE_GREEN ? 1 : 0,
1013 Value & D3DCOLORWRITEENABLE_BLUE ? 1 : 0,
1014 Value & D3DCOLORWRITEENABLE_ALPHA ? 1 : 0);
1015 glColorMask(Value & D3DCOLORWRITEENABLE_RED ? GL_TRUE : GL_FALSE,
1016 Value & D3DCOLORWRITEENABLE_GREEN ? GL_TRUE : GL_FALSE,
1017 Value & D3DCOLORWRITEENABLE_BLUE ? GL_TRUE : GL_FALSE,
1018 Value & D3DCOLORWRITEENABLE_ALPHA ? GL_TRUE : GL_FALSE);
1019 checkGLcall("glColorMask(...)");
1021 /* depends on WINED3DRS_COLORWRITEENABLE. */
1022 if(stateblock->renderState[WINED3DRS_COLORWRITEENABLE1] != 0x0000000F ||
1023 stateblock->renderState[WINED3DRS_COLORWRITEENABLE2] != 0x0000000F ||
1024 stateblock->renderState[WINED3DRS_COLORWRITEENABLE3] != 0x0000000F ) {
1025 ERR("(WINED3DRS_COLORWRITEENABLE1/2/3,%d,%d,%d) not yet implemented. Missing of cap D3DPMISCCAPS_INDEPENDENTWRITEMASKS wasn't honored?\n",
1026 stateblock->renderState[WINED3DRS_COLORWRITEENABLE1],
1027 stateblock->renderState[WINED3DRS_COLORWRITEENABLE2],
1028 stateblock->renderState[WINED3DRS_COLORWRITEENABLE3]);
1032 static void state_localviewer(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1033 if(stateblock->renderState[WINED3DRS_LOCALVIEWER]) {
1034 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);
1035 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1)");
1036 } else {
1037 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 0);
1038 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 0)");
1042 static void state_lastpixel(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1043 if(stateblock->renderState[WINED3DRS_LASTPIXEL]) {
1044 TRACE("Last Pixel Drawing Enabled\n");
1045 } else {
1046 FIXME("Last Pixel Drawing Disabled, not handled yet\n");
1050 static void state_pointsprite(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1051 /* TODO: NV_POINT_SPRITE */
1052 if (!GL_SUPPORT(ARB_POINT_SPRITE)) {
1053 TRACE("Point sprites not supported\n");
1054 return;
1057 if (stateblock->renderState[WINED3DRS_POINTSPRITEENABLE]) {
1058 glEnable(GL_POINT_SPRITE_ARB);
1059 checkGLcall("glEnable(GL_POINT_SPRITE_ARB)");
1060 glTexEnvf(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, TRUE);
1061 checkGLcall("glTexEnvf(GL_POINT_SPRITE, GL_COORD_REPLACE, TRUE)");
1062 } else {
1063 glDisable(GL_POINT_SPRITE_ARB);
1064 checkGLcall("glDisable(GL_POINT_SPRITE_ARB)");
1065 glTexEnvf(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, FALSE);
1066 checkGLcall("glTexEnvf(GL_POINT_SPRITE, GL_COORD_REPLACE, FALSE)");
1070 static void state_wrap(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1072 http://www.cosc.brocku.ca/Offerings/3P98/course/lectures/texture/
1073 http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/graphics/programmingguide/FixedFunction/Textures/texturewrapping.asp
1074 http://www.gamedev.net/reference/programming/features/rendererdll3/page2.asp
1075 Descussion that ways to turn on WRAPing to solve an opengl conversion problem.
1076 http://www.flipcode.org/cgi-bin/fcmsg.cgi?thread_show=10248
1078 so far as I can tell, wrapping and texture-coordinate generate go hand in hand,
1080 TRACE("Stub\n");
1081 if(stateblock->renderState[WINED3DRS_WRAP0] ||
1082 stateblock->renderState[WINED3DRS_WRAP1] ||
1083 stateblock->renderState[WINED3DRS_WRAP2] ||
1084 stateblock->renderState[WINED3DRS_WRAP3] ||
1085 stateblock->renderState[WINED3DRS_WRAP4] ||
1086 stateblock->renderState[WINED3DRS_WRAP5] ||
1087 stateblock->renderState[WINED3DRS_WRAP6] ||
1088 stateblock->renderState[WINED3DRS_WRAP7] ||
1089 stateblock->renderState[WINED3DRS_WRAP8] ||
1090 stateblock->renderState[WINED3DRS_WRAP9] ||
1091 stateblock->renderState[WINED3DRS_WRAP10] ||
1092 stateblock->renderState[WINED3DRS_WRAP11] ||
1093 stateblock->renderState[WINED3DRS_WRAP12] ||
1094 stateblock->renderState[WINED3DRS_WRAP13] ||
1095 stateblock->renderState[WINED3DRS_WRAP14] ||
1096 stateblock->renderState[WINED3DRS_WRAP15] ) {
1097 ERR("(WINED3DRS_WRAP0) Texture wraping not yet supported\n");
1101 static void state_multisampleaa(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1102 if( GL_SUPPORT(ARB_MULTISAMPLE) ) {
1103 if(stateblock->renderState[WINED3DRS_MULTISAMPLEANTIALIAS]) {
1104 glEnable(GL_MULTISAMPLE_ARB);
1105 checkGLcall("glEnable(GL_MULTISAMPLE_ARB)");
1106 } else {
1107 glDisable(GL_MULTISAMPLE_ARB);
1108 checkGLcall("glDisable(GL_MULTISAMPLE_ARB)");
1110 } else {
1111 if(stateblock->renderState[WINED3DRS_MULTISAMPLEANTIALIAS]) {
1112 ERR("Multisample antialiasing not supported by gl\n");
1117 static void state_scissor(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1118 if(stateblock->renderState[WINED3DRS_SCISSORTESTENABLE]) {
1119 glEnable(GL_SCISSOR_TEST);
1120 checkGLcall("glEnable(GL_SCISSOR_TEST)");
1121 } else {
1122 glDisable(GL_SCISSOR_TEST);
1123 checkGLcall("glDisable(GL_SCISSOR_TEST)");
1127 static void state_depthbias(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1128 union {
1129 DWORD d;
1130 float f;
1131 } tmpvalue;
1133 if(stateblock->renderState[WINED3DRS_SLOPESCALEDEPTHBIAS] ||
1134 stateblock->renderState[WINED3DRS_DEPTHBIAS]) {
1135 tmpvalue.d = stateblock->renderState[WINED3DRS_SLOPESCALEDEPTHBIAS];
1136 glEnable(GL_POLYGON_OFFSET_FILL);
1137 checkGLcall("glEnable(GL_POLYGON_OFFSET_FILL)");
1138 glPolygonOffset(tmpvalue.f, *((float*)&stateblock->renderState[WINED3DRS_DEPTHBIAS]));
1139 checkGLcall("glPolygonOffset(...)");
1140 } else {
1141 glDisable(GL_POLYGON_OFFSET_FILL);
1142 checkGLcall("glDisable(GL_POLYGON_OFFSET_FILL)");
1146 static void state_perspective(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1147 if (stateblock->renderState[WINED3DRS_TEXTUREPERSPECTIVE]) {
1148 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
1149 checkGLcall("glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)");
1150 } else {
1151 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
1152 checkGLcall("glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST)");
1156 static void state_stippledalpha(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1157 TRACE("Stub\n");
1158 if (stateblock->renderState[WINED3DRS_STIPPLEDALPHA])
1159 ERR(" Stippled Alpha not supported yet.\n");
1162 static void state_antialias(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1163 TRACE("Stub\n");
1164 if (stateblock->renderState[WINED3DRS_ANTIALIAS])
1165 ERR(" Antialias not supported yet.\n");
1168 static void state_multisampmask(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1169 TRACE("Stub\n");
1170 if (stateblock->renderState[WINED3DRS_MULTISAMPLEMASK] != 0xFFFFFFFF)
1171 ERR("(WINED3DRS_MULTISAMPLEMASK,%d) not yet implemented\n", stateblock->renderState[WINED3DRS_MULTISAMPLEMASK]);
1174 static void state_patchedgestyle(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1175 TRACE("Stub\n");
1176 if (stateblock->renderState[WINED3DRS_PATCHEDGESTYLE] != D3DPATCHEDGE_DISCRETE)
1177 ERR("(WINED3DRS_PATCHEDGESTYLE,%d) not yet implemented\n", stateblock->renderState[WINED3DRS_PATCHEDGESTYLE]);
1180 static void state_patchsegments(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1181 union {
1182 DWORD d;
1183 float f;
1184 } tmpvalue;
1185 tmpvalue.f = 1.0f;
1187 TRACE("Stub\n");
1188 if (stateblock->renderState[WINED3DRS_PATCHSEGMENTS] != tmpvalue.d)
1189 ERR("(WINED3DRS_PATCHSEGMENTS,%d) not yet implemented\n", tmpvalue.d);
1192 static void state_positiondegree(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1193 TRACE("Stub\n");
1194 if (stateblock->renderState[WINED3DRS_POSITIONDEGREE] != D3DDEGREE_CUBIC)
1195 ERR("(WINED3DRS_POSITIONDEGREE,%d) not yet implemented\n", stateblock->renderState[WINED3DRS_POSITIONDEGREE]);
1198 static void state_normaldegree(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1199 TRACE("Stub\n");
1200 if (stateblock->renderState[WINED3DRS_NORMALDEGREE] != D3DDEGREE_LINEAR)
1201 ERR("(WINED3DRS_NORMALDEGREE,%d) not yet implemented\n", stateblock->renderState[WINED3DRS_NORMALDEGREE]);
1204 static void state_tessellation(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1205 TRACE("Stub\n");
1206 if(stateblock->renderState[WINED3DRS_ENABLEADAPTIVETESSELLATION])
1207 FIXME("(WINED3DRS_ENABLEADAPTIVETESSELLATION,%d) not yet implemented\n", stateblock->renderState[WINED3DRS_ENABLEADAPTIVETESSELLATION]);
1211 static void state_srgbwrite(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1212 if(stateblock->renderState[WINED3DRS_SRGBWRITEENABLE])
1213 ERR("Render state WINED3DRS_SRGBWRITEENABLE not yet implemented\n");
1216 static void state_seperateblend(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1217 TRACE("Stub\n");
1218 if(stateblock->renderState[WINED3DRS_SEPARATEALPHABLENDENABLE])
1219 FIXME("(WINED3DRS_SEPARATEALPHABLENDENABLE,%d) not yet implemented\n", stateblock->renderState[WINED3DRS_SEPARATEALPHABLENDENABLE]);
1222 static void state_wrapu(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1223 if(stateblock->renderState[WINED3DRS_WRAPU]) {
1224 FIXME("Render state WINED3DRS_WRAPU not implemented yet\n");
1228 static void state_wrapv(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1229 if(stateblock->renderState[WINED3DRS_WRAPV]) {
1230 FIXME("Render state WINED3DRS_WRAPV not implemented yet\n");
1234 static void state_monoenable(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1235 if(stateblock->renderState[WINED3DRS_MONOENABLE]) {
1236 FIXME("Render state WINED3DRS_MONOENABLE not implemented yet\n");
1240 static void state_rop2(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1241 if(stateblock->renderState[WINED3DRS_ROP2]) {
1242 FIXME("Render state WINED3DRS_ROP2 not implemented yet\n");
1246 static void state_planemask(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1247 if(stateblock->renderState[WINED3DRS_PLANEMASK]) {
1248 FIXME("Render state WINED3DRS_PLANEMASK not implemented yet\n");
1252 static void state_subpixel(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1253 if(stateblock->renderState[WINED3DRS_SUBPIXEL]) {
1254 FIXME("Render state WINED3DRS_SUBPIXEL not implemented yet\n");
1258 static void state_subpixelx(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1259 if(stateblock->renderState[WINED3DRS_SUBPIXELX]) {
1260 FIXME("Render state WINED3DRS_SUBPIXELX not implemented yet\n");
1264 static void state_stippleenable(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1265 if(stateblock->renderState[WINED3DRS_STIPPLEENABLE]) {
1266 FIXME("Render state WINED3DRS_STIPPLEENABLE not implemented yet\n");
1270 static void state_bordercolor(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1271 if(stateblock->renderState[WINED3DRS_BORDERCOLOR]) {
1272 FIXME("Render state WINED3DRS_BORDERCOLOR not implemented yet\n");
1276 static void state_mipmaplodbias(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1277 if(stateblock->renderState[WINED3DRS_MIPMAPLODBIAS]) {
1278 FIXME("Render state WINED3DRS_MIPMAPLODBIAS not implemented yet\n");
1282 static void state_anisotropy(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1283 if(stateblock->renderState[WINED3DRS_ANISOTROPY]) {
1284 FIXME("Render state WINED3DRS_ANISOTROPY not implemented yet\n");
1288 static void state_flushbatch(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1289 if(stateblock->renderState[WINED3DRS_FLUSHBATCH]) {
1290 FIXME("Render state WINED3DRS_FLUSHBATCH not implemented yet\n");
1294 static void state_translucentsi(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1295 if(stateblock->renderState[WINED3DRS_TRANSLUCENTSORTINDEPENDENT]) {
1296 FIXME("Render state WINED3DRS_TRANSLUCENTSORTINDEPENDENT not implemented yet\n");
1300 static void state_extents(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1301 if(stateblock->renderState[WINED3DRS_EXTENTS]) {
1302 FIXME("Render state WINED3DRS_EXTENTS not implemented yet\n");
1306 static void state_ckeyblend(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1307 if(stateblock->renderState[WINED3DRS_COLORKEYBLENDENABLE]) {
1308 FIXME("Render state WINED3DRS_COLORKEYBLENDENABLE not implemented yet\n");
1312 /* Activates the texture dimension according to the bound D3D texture.
1313 * Does not care for the colorop or correct gl texture unit(when using nvrc)
1314 * Requires the caller to activate the correct unit before
1316 static void activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock) {
1317 if(stateblock->textures[stage]) {
1318 glDisable(GL_TEXTURE_1D);
1319 checkGLcall("glDisable(GL_TEXTURE_1D)");
1320 switch(stateblock->textureDimensions[stage]) {
1321 case GL_TEXTURE_2D:
1322 glDisable(GL_TEXTURE_3D);
1323 checkGLcall("glDisable(GL_TEXTURE_3D)");
1324 glDisable(GL_TEXTURE_CUBE_MAP_ARB);
1325 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
1326 glEnable(GL_TEXTURE_2D);
1327 checkGLcall("glEnable(GL_TEXTURE_2D)");
1328 break;
1329 case GL_TEXTURE_3D:
1330 glDisable(GL_TEXTURE_CUBE_MAP_ARB);
1331 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
1332 glDisable(GL_TEXTURE_2D);
1333 checkGLcall("glDisable(GL_TEXTURE_2D)");
1334 glEnable(GL_TEXTURE_3D);
1335 checkGLcall("glEnable(GL_TEXTURE_3D)");
1336 break;
1337 case GL_TEXTURE_CUBE_MAP_ARB:
1338 glDisable(GL_TEXTURE_2D);
1339 checkGLcall("glDisable(GL_TEXTURE_2D)");
1340 glDisable(GL_TEXTURE_3D);
1341 checkGLcall("glDisable(GL_TEXTURE_3D)");
1342 glEnable(GL_TEXTURE_CUBE_MAP_ARB);
1343 checkGLcall("glEnable(GL_TEXTURE_CUBE_MAP_ARB)");
1344 break;
1346 } else {
1347 glDisable(GL_TEXTURE_2D);
1348 checkGLcall("glDisable(GL_TEXTURE_2D)");
1349 glDisable(GL_TEXTURE_3D);
1350 checkGLcall("glDisable(GL_TEXTURE_3D)");
1351 glDisable(GL_TEXTURE_CUBE_MAP_ARB);
1352 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
1353 glEnable(GL_TEXTURE_1D);
1354 checkGLcall("glEnable(GL_TEXTURE_1D)");
1355 /* Binding textures is done by samplers. A dummy texture will be bound */
1359 static void tex_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1360 DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE;
1362 TRACE("Setting color op for stage %d\n", stage);
1364 if (stateblock->pixelShader && stateblock->wineD3DDevice->ps_selected_mode != SHADER_NONE &&
1365 ((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.function) {
1366 /* Using a pixel shader? Don't care for anything here, the shader applying does it */
1367 return;
1370 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
1371 /* TODO: register combiners! */
1372 if(stage != stateblock->wineD3DDevice->texUnitMap[stage]) ERR("Foo: %d is %d!\n", stage, stateblock->wineD3DDevice->texUnitMap[stage]);
1373 if(stateblock->wineD3DDevice->texUnitMap[stage] >= GL_LIMITS(sampler_stages)) {
1374 if(stateblock->textureState[stage][WINED3DTSS_COLOROP] != WINED3DTOP_DISABLE &&
1375 stateblock->textureState[stage][WINED3DTSS_COLOROP] != 0) {
1376 FIXME("Attempt to enable unsupported stage!\n");
1378 return;
1380 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + stateblock->wineD3DDevice->texUnitMap[stage]));
1381 checkGLcall("glActiveTextureARB");
1382 } else if (stage > 0) {
1383 WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
1384 return;
1387 if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
1388 if(stateblock->lowest_disabled_stage > 0) {
1389 glEnable(GL_REGISTER_COMBINERS_NV);
1390 GL_EXTCALL(glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, stateblock->lowest_disabled_stage));
1391 } else {
1392 glDisable(GL_REGISTER_COMBINERS_NV);
1395 if(stage >= stateblock->lowest_disabled_stage) {
1396 TRACE("Stage disabled\n");
1397 /* Disable everything here */
1398 glDisable(GL_TEXTURE_1D);
1399 checkGLcall("glDisable(GL_TEXTURE_1D)");
1400 glDisable(GL_TEXTURE_2D);
1401 checkGLcall("glDisable(GL_TEXTURE_2D)");
1402 glDisable(GL_TEXTURE_3D);
1403 checkGLcall("glDisable(GL_TEXTURE_3D)");
1404 glDisable(GL_TEXTURE_CUBE_MAP_ARB);
1405 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
1406 /* All done */
1407 return;
1410 activate_dimensions(stage, stateblock);
1412 /* Set the texture combiners */
1413 if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
1414 set_tex_op_nvrc((IWineD3DDevice *)stateblock->wineD3DDevice, FALSE, stage,
1415 stateblock->textureState[stage][WINED3DTSS_COLOROP],
1416 stateblock->textureState[stage][WINED3DTSS_COLORARG1],
1417 stateblock->textureState[stage][WINED3DTSS_COLORARG2],
1418 stateblock->textureState[stage][WINED3DTSS_COLORARG0],
1419 stateblock->wineD3DDevice->texUnitMap[stage]);
1420 } else {
1421 set_tex_op((IWineD3DDevice *)stateblock->wineD3DDevice, FALSE, stage,
1422 stateblock->textureState[stage][WINED3DTSS_COLOROP],
1423 stateblock->textureState[stage][WINED3DTSS_COLORARG1],
1424 stateblock->textureState[stage][WINED3DTSS_COLORARG2],
1425 stateblock->textureState[stage][WINED3DTSS_COLORARG0]);
1429 static void tex_alphaop(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1430 DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE;
1432 TRACE("Setting alpha op for stage %d\n", stage);
1433 /* Do not care for enabled / disabled stages, just assign the settigns. colorop disables / enables required stuff */
1434 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
1435 /* TODO: register combiners! */
1436 if(stage >= GL_LIMITS(sampler_stages)) {
1437 if(stateblock->textureState[stage][WINED3DTSS_COLOROP] != WINED3DTOP_DISABLE &&
1438 stateblock->textureState[stage][WINED3DTSS_COLOROP] != 0) {
1439 FIXME("Attempt to enable unsupported stage!\n");
1441 return;
1443 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + stateblock->wineD3DDevice->texUnitMap[stage]));
1444 checkGLcall("glActiveTextureARB");
1445 } else if (stage > 0) {
1446 /* We can't do anything here */
1447 WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
1448 return;
1451 TRACE("Setting alpha op for stage %d\n", stage);
1452 if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
1453 set_tex_op_nvrc((IWineD3DDevice *)stateblock->wineD3DDevice, TRUE, stage,
1454 stateblock->textureState[stage][WINED3DTSS_ALPHAOP],
1455 stateblock->textureState[stage][WINED3DTSS_ALPHAARG1],
1456 stateblock->textureState[stage][WINED3DTSS_ALPHAARG2],
1457 stateblock->textureState[stage][WINED3DTSS_ALPHAARG0],
1458 stateblock->wineD3DDevice->texUnitMap[stage]);
1459 } else {
1460 set_tex_op((IWineD3DDevice *)stateblock->wineD3DDevice, TRUE, stage, stateblock->textureState[stage][WINED3DTSS_ALPHAOP],
1461 stateblock->textureState[stage][WINED3DTSS_ALPHAARG1],
1462 stateblock->textureState[stage][WINED3DTSS_ALPHAARG2],
1463 stateblock->textureState[stage][WINED3DTSS_ALPHAARG0]);
1467 static void transform_texture(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1468 DWORD texUnit = state - STATE_TRANSFORM(WINED3DTS_TEXTURE0);
1470 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
1471 if(texUnit >= GL_LIMITS(sampler_stages)) {
1472 return;
1474 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + stateblock->wineD3DDevice->texUnitMap[texUnit]));
1475 checkGLcall("glActiveTextureARB");
1476 } else if (texUnit > 0) {
1477 /* We can't do anything here */
1478 WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
1479 return;
1482 set_texture_matrix((float *)&stateblock->transforms[WINED3DTS_TEXTURE0 + texUnit].u.m[0][0],
1483 stateblock->textureState[texUnit][WINED3DTSS_TEXTURETRANSFORMFLAGS],
1484 (stateblock->textureState[texUnit][WINED3DTSS_TEXCOORDINDEX] & 0xFFFF0000) != WINED3DTSS_TCI_PASSTHRU);
1488 static void tex_coordindex(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1489 DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE;
1491 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
1492 /* TODO: register combiners! */
1493 if(stage >= GL_LIMITS(sampler_stages)) {
1494 return;
1496 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + stateblock->wineD3DDevice->texUnitMap[stage]));
1497 checkGLcall("glActiveTextureARB");
1498 } else if (stage > 0) {
1499 /* We can't do anything here */
1500 WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
1501 return;
1504 /* Values 0-7 are indexes into the FVF tex coords - See comments in DrawPrimitive
1506 * FIXME: From MSDN: The WINED3DTSS_TCI_* flags are mutually exclusive. If you include
1507 * one flag, you can still specify an index value, which the system uses to
1508 * determine the texture wrapping mode.
1509 * eg. SetTextureStageState( 0, WINED3DTSS_TEXCOORDINDEX, WINED3DTSS_TCI_CAMERASPACEPOSITION | 1 );
1510 * means use the vertex position (camera-space) as the input texture coordinates
1511 * for this texture stage, and the wrap mode set in the WINED3DRS_WRAP1 render
1512 * state. We do not (yet) support the WINED3DRENDERSTATE_WRAPx values, nor tie them up
1513 * to the TEXCOORDINDEX value
1517 * Be careful the value of the mask 0xF0000 come from d3d8types.h infos
1519 switch (stateblock->textureState[stage][WINED3DTSS_TEXCOORDINDEX] & 0xFFFF0000) {
1520 case WINED3DTSS_TCI_PASSTHRU:
1521 /*Use the specified texture coordinates contained within the vertex format. This value resolves to zero.*/
1522 glDisable(GL_TEXTURE_GEN_S);
1523 glDisable(GL_TEXTURE_GEN_T);
1524 glDisable(GL_TEXTURE_GEN_R);
1525 glDisable(GL_TEXTURE_GEN_Q);
1526 checkGLcall("glDisable(GL_TEXTURE_GEN_S,T,R,Q)");
1527 break;
1529 case WINED3DTSS_TCI_CAMERASPACEPOSITION:
1530 /* CameraSpacePosition means use the vertex position, transformed to camera space,
1531 * as the input texture coordinates for this stage's texture transformation. This
1532 * equates roughly to EYE_LINEAR
1535 float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
1536 float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
1537 float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
1538 float q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
1539 TRACE("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set eye plane\n");
1541 glMatrixMode(GL_MODELVIEW);
1542 glPushMatrix();
1543 glLoadIdentity();
1544 glTexGenfv(GL_S, GL_EYE_PLANE, s_plane);
1545 glTexGenfv(GL_T, GL_EYE_PLANE, t_plane);
1546 glTexGenfv(GL_R, GL_EYE_PLANE, r_plane);
1547 glTexGenfv(GL_Q, GL_EYE_PLANE, q_plane);
1548 glPopMatrix();
1550 TRACE("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set GL_TEXTURE_GEN_x and GL_x, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR\n");
1551 glEnable(GL_TEXTURE_GEN_S);
1552 checkGLcall("glEnable(GL_TEXTURE_GEN_S);");
1553 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
1554 checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)");
1555 glEnable(GL_TEXTURE_GEN_T);
1556 checkGLcall("glEnable(GL_TEXTURE_GEN_T);");
1557 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
1558 checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)");
1559 glEnable(GL_TEXTURE_GEN_R);
1560 checkGLcall("glEnable(GL_TEXTURE_GEN_R);");
1561 glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
1562 checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)");
1564 break;
1566 case WINED3DTSS_TCI_CAMERASPACENORMAL:
1568 if (GL_SUPPORT(NV_TEXGEN_REFLECTION)) {
1569 float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
1570 float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
1571 float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
1572 float q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
1573 TRACE("WINED3DTSS_TCI_CAMERASPACENORMAL - Set eye plane\n");
1575 glMatrixMode(GL_MODELVIEW);
1576 glPushMatrix();
1577 glLoadIdentity();
1578 glTexGenfv(GL_S, GL_EYE_PLANE, s_plane);
1579 glTexGenfv(GL_T, GL_EYE_PLANE, t_plane);
1580 glTexGenfv(GL_R, GL_EYE_PLANE, r_plane);
1581 glTexGenfv(GL_Q, GL_EYE_PLANE, q_plane);
1582 glPopMatrix();
1584 glEnable(GL_TEXTURE_GEN_S);
1585 checkGLcall("glEnable(GL_TEXTURE_GEN_S);");
1586 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV);
1587 checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV)");
1588 glEnable(GL_TEXTURE_GEN_T);
1589 checkGLcall("glEnable(GL_TEXTURE_GEN_T);");
1590 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV);
1591 checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV)");
1592 glEnable(GL_TEXTURE_GEN_R);
1593 checkGLcall("glEnable(GL_TEXTURE_GEN_R);");
1594 glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV);
1595 checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV)");
1598 break;
1600 case WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR:
1602 if (GL_SUPPORT(NV_TEXGEN_REFLECTION)) {
1603 float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
1604 float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
1605 float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
1606 float q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
1607 TRACE("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Set eye plane\n");
1609 glMatrixMode(GL_MODELVIEW);
1610 glPushMatrix();
1611 glLoadIdentity();
1612 glTexGenfv(GL_S, GL_EYE_PLANE, s_plane);
1613 glTexGenfv(GL_T, GL_EYE_PLANE, t_plane);
1614 glTexGenfv(GL_R, GL_EYE_PLANE, r_plane);
1615 glTexGenfv(GL_Q, GL_EYE_PLANE, q_plane);
1616 glPopMatrix();
1618 glEnable(GL_TEXTURE_GEN_S);
1619 checkGLcall("glEnable(GL_TEXTURE_GEN_S);");
1620 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV);
1621 checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV)");
1622 glEnable(GL_TEXTURE_GEN_T);
1623 checkGLcall("glEnable(GL_TEXTURE_GEN_T);");
1624 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV);
1625 checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV)");
1626 glEnable(GL_TEXTURE_GEN_R);
1627 checkGLcall("glEnable(GL_TEXTURE_GEN_R);");
1628 glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV);
1629 checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV)");
1632 break;
1634 /* Unhandled types: */
1635 default:
1636 /* Todo: */
1637 /* ? disable GL_TEXTURE_GEN_n ? */
1638 glDisable(GL_TEXTURE_GEN_S);
1639 glDisable(GL_TEXTURE_GEN_T);
1640 glDisable(GL_TEXTURE_GEN_R);
1641 glDisable(GL_TEXTURE_GEN_Q);
1642 FIXME("Unhandled WINED3DTSS_TEXCOORDINDEX %x\n", stateblock->textureState[stage][WINED3DTSS_TEXCOORDINDEX]);
1643 break;
1646 /* Update the texture matrix */
1647 if(!isStateDirty(stateblock->wineD3DDevice, STATE_TRANSFORM(WINED3DTS_TEXTURE0 + stage))) {
1648 transform_texture(STATE_TRANSFORM(WINED3DTS_TEXTURE0 + stage), stateblock);
1652 static void tex_bumpenvlscale(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1653 DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE;
1654 union {
1655 DWORD d;
1656 float f;
1657 } tmpvalue;
1659 tmpvalue.d = stateblock->textureState[stage][WINED3DTSS_BUMPENVLSCALE];
1660 if(tmpvalue.f != 0.0) {
1661 ERR("WINED3DTSS_BUMPENVLSCALE not supported yet\n");
1665 static void tex_bumpenvloffset(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1666 DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE;
1667 union {
1668 DWORD d;
1669 float f;
1670 } tmpvalue;
1672 tmpvalue.d = stateblock->textureState[stage][WINED3DTSS_BUMPENVLOFFSET];
1673 if(tmpvalue.f != 0.0) {
1674 ERR("WINED3DTSS_BUMPENVLOFFSET not supported yet\n");
1678 static void tex_resultarg(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1679 DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE;
1681 if(stateblock->textureState[stage][WINED3DTSS_RESULTARG] != D3DTA_CURRENT) {
1682 ERR("WINED3DTSS_RESULTARG not supported yet\n");
1686 static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1687 DWORD sampler = state - STATE_SAMPLER(0);
1688 union {
1689 float f;
1690 DWORD d;
1691 } tmpvalue;
1693 TRACE("Sampler: %d\n", sampler);
1694 /* Enabling and disabling texture dimensions is done by texture stage state / pixel shader setup, this function
1695 * only has to bind textures and set the per texture states
1697 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
1698 /* TODO: register combiners! */
1699 if(sampler >= GL_LIMITS(sampler_stages)) {
1700 return;
1702 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + stateblock->wineD3DDevice->texUnitMap[sampler]));
1703 checkGLcall("glActiveTextureARB");
1704 } else if (sampler > 0) {
1705 /* We can't do anything here */
1706 WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
1707 return;
1710 if(stateblock->textures[sampler]) {
1712 /* NP2 textures need the texture matrix set properly for the stage */
1713 if(wined3d_settings.nonpower2_mode == NP2_NATIVE && sampler < MAX_TEXTURES - 1 &&
1714 stateblock->textureDimensions[sampler] == GL_TEXTURE_2D &&
1715 (((IWineD3DTextureImpl *) stateblock->textures[sampler])->pow2scalingFactorX != 1.0 ||
1716 ((IWineD3DTextureImpl *) stateblock->textures[sampler])->pow2scalingFactorY != 1.0 ) ) {
1717 transform_texture(STATE_TRANSFORM(WINED3DTS_TEXTURE0 + stateblock->wineD3DDevice->texUnitMap[sampler]), stateblock);
1720 IWineD3DBaseTexture_PreLoad((IWineD3DBaseTexture *) stateblock->textures[sampler]);
1721 IWineD3DBaseTexture_ApplyStateChanges(stateblock->textures[sampler], stateblock->textureState[sampler], stateblock->samplerState[sampler]);
1723 if (GL_SUPPORT(EXT_TEXTURE_LOD_BIAS)) {
1724 tmpvalue.d = stateblock->samplerState[sampler][WINED3DSAMP_MIPMAPLODBIAS];
1725 glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT,
1726 GL_TEXTURE_LOD_BIAS_EXT,
1727 tmpvalue.f);
1728 checkGLcall("glTexEnvi GL_TEXTURE_LOD_BIAS_EXT ...");
1731 if (stateblock->wineD3DDevice->ps_selected_mode != SHADER_NONE && stateblock->pixelShader &&
1732 ((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.function) {
1733 /* Using a pixel shader? Verify the sampler types */
1735 /* Make sure that the texture dimensions are enabled. I don't have to disable the other
1736 * dimensions because the shader knows from which texture type to sample from. For the sake of
1737 * debugging all dimensions could be enabled and a texture with some ugly pink bound to the unused
1738 * dimensions. This should make wrong sampling sources visible :-)
1740 glEnable(stateblock->textureDimensions[sampler]);
1741 checkGLcall("glEnable(stateblock->textureDimensions[sampler])");
1742 } else if(sampler < stateblock->lowest_disabled_stage) {
1743 activate_dimensions(sampler, stateblock);
1745 if(stateblock->renderState[WINED3DRS_COLORKEYENABLE] && sampler == 0) {
1746 /* If color keying is enabled update the alpha test, it depends on the existance
1747 * of a color key in stage 0
1749 state_alpha(WINED3DRS_COLORKEYENABLE, stateblock);
1752 } else if(sampler < GL_LIMITS(texture_stages)) {
1753 if(sampler < stateblock->lowest_disabled_stage) {
1754 /* TODO: Check if the colorop is dirty to do that job
1755 * TODO: What should I do with pixel shaders here ???
1757 activate_dimensions(sampler, stateblock);
1758 } /* Otherwise tex_colorop disables the stage */
1759 glBindTexture(GL_TEXTURE_1D, stateblock->wineD3DDevice->dummyTextureName[sampler]);
1760 checkGLcall("glBindTexture(GL_TEXTURE_1D, stateblock->wineD3DDevice->dummyTextureName[sampler])");
1764 static void pixelshader(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1765 int i;
1767 if(stateblock->pixelShader && ((IWineD3DPixelShaderImpl *) stateblock->pixelShader)->baseShader.function != NULL) {
1768 if(!stateblock->wineD3DDevice->last_was_pshader) {
1769 /* Former draw without a pixel shader, some samplers
1770 * may be disabled because of WINED3DTSS_COLOROP = WINED3DTOP_DISABLE
1771 * make sure to enable them
1773 for(i=0; i < MAX_SAMPLERS; i++) {
1774 if(!isStateDirty(stateblock->wineD3DDevice, STATE_SAMPLER(i))) {
1775 sampler(STATE_SAMPLER(i), stateblock);
1778 } else {
1779 /* Otherwise all samplers were activated by the code above in earlier draws, or by sampler()
1780 * if a different texture was bound. I don't have to do anything.
1784 /* Compile and bind the shader */
1785 IWineD3DPixelShader_CompileShader(stateblock->pixelShader);
1787 #if 0
1788 /* Can't do that here right now, because glsl shaders depend on having both pixel and vertex shader
1789 * setup at the same time. The shader_select call will be done by drawprim until vertex shaders are
1790 * moved to the state table too
1792 stateblock->wineD3DDevice->shader_backend->shader_select(
1793 (IWineD3DDevice *) stateblock->wineD3DDevice,
1794 TRUE,
1795 !stateblock->vertexShader ? FALSE : ((IWineD3DVertexShaderImpl *) stateblock->vertexShader)->baseShader.function != NULL);
1796 #endif
1797 stateblock->wineD3DDevice->last_was_pshader = TRUE;
1798 } else {
1799 /* Disabled the pixel shader - color ops weren't applied
1800 * while it was enabled, so re-apply them.
1802 for(i=0; i < MAX_TEXTURES; i++) {
1803 if(!isStateDirty(stateblock->wineD3DDevice, STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP))) {
1804 tex_colorop(STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP), stateblock);
1807 stateblock->wineD3DDevice->last_was_pshader = FALSE;
1809 #if 0
1810 stateblock->wineD3DDevice->shader_backend->shader_select(
1811 (IWineD3DDevice *) stateblock->wineD3DDevice,
1812 FALSE,
1813 !stateblock->vertexShader ? FALSE : ((IWineD3DVertexShaderImpl *) stateblock->vertexShader)->baseShader.function != NULL);
1814 #endif
1818 static void transform_view(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1819 unsigned int k;
1821 /* If we are changing the View matrix, reset the light and clipping planes to the new view
1822 * NOTE: We have to reset the positions even if the light/plane is not currently
1823 * enabled, since the call to enable it will not reset the position.
1824 * NOTE2: Apparently texture transforms do NOT need reapplying
1827 PLIGHTINFOEL *lightChain = NULL;
1828 stateblock->wineD3DDevice->modelview_valid = FALSE;
1830 glMatrixMode(GL_MODELVIEW);
1831 checkGLcall("glMatrixMode(GL_MODELVIEW)");
1832 glPushMatrix();
1833 checkGLcall("glPushMatrix()");
1834 glLoadMatrixf((float *)(float *) &stateblock->transforms[WINED3DTS_VIEW].u.m[0][0]);
1835 checkGLcall("glLoadMatrixf(...)");
1837 /* Reset lights. TODO: Call light apply func */
1838 lightChain = stateblock->lights;
1839 while (lightChain && lightChain->glIndex != -1) {
1840 glLightfv(GL_LIGHT0 + lightChain->glIndex, GL_POSITION, lightChain->lightPosn);
1841 checkGLcall("glLightfv posn");
1842 glLightfv(GL_LIGHT0 + lightChain->glIndex, GL_SPOT_DIRECTION, lightChain->lightDirn);
1843 checkGLcall("glLightfv dirn");
1844 lightChain = lightChain->next;
1847 /* Reset Clipping Planes if clipping is enabled. TODO: Call clipplane apply func */
1848 for (k = 0; k < GL_LIMITS(clipplanes); k++) {
1849 glClipPlane(GL_CLIP_PLANE0 + k, stateblock->clipplane[k]);
1850 checkGLcall("glClipPlane");
1852 glPopMatrix();
1853 checkGLcall("glPopMatrix()");
1856 static void transform_worldex(DWORD state, IWineD3DStateBlockImpl *stateBlock) {
1857 WARN("World matrix 1 - 255 not supported yet\n");
1860 static void vertexdeclaration(DWORD state, IWineD3DStateBlockImpl *stateblock) {
1861 BOOL useVertexShaderFunction = FALSE;
1862 stateblock->wineD3DDevice->streamFixedUp = FALSE;
1864 /* Shaders can be implemented using ARB_PROGRAM, GLSL, or software -
1865 * here simply check whether a shader was set, or the user disabled shaders
1867 if (stateblock->wineD3DDevice->vs_selected_mode != SHADER_NONE && stateblock->vertexShader &&
1868 ((IWineD3DVertexShaderImpl *)stateblock->vertexShader)->baseShader.function != NULL)
1869 useVertexShaderFunction = TRUE;
1871 if(stateblock->wineD3DDevice->up_strided) {
1873 /* Note: this is a ddraw fixed-function code path */
1874 TRACE("================ Strided Input ===================\n");
1875 memcpy(&stateblock->wineD3DDevice->strided_streams, stateblock->wineD3DDevice->up_strided, sizeof(stateblock->wineD3DDevice->strided_streams));
1876 stateblock->wineD3DDevice->streamFixedUp = FALSE;
1878 else if (stateblock->vertexDecl || stateblock->vertexShader) {
1879 /* Note: This is a fixed function or shader codepath.
1880 * This means it must handle both types of strided data.
1881 * Shaders must go through here to zero the strided data, even if they
1882 * don't set any declaration at all
1884 TRACE("================ Vertex Declaration ===================\n");
1885 memset(&stateblock->wineD3DDevice->strided_streams, 0, sizeof(stateblock->wineD3DDevice->strided_streams));
1887 if (stateblock->vertexDecl != NULL ||
1888 ((IWineD3DVertexShaderImpl *)stateblock->vertexShader)->vertexDeclaration != NULL) {
1890 primitiveDeclarationConvertToStridedData((IWineD3DDevice *) stateblock->wineD3DDevice, useVertexShaderFunction,
1891 &stateblock->wineD3DDevice->strided_streams, &stateblock->wineD3DDevice->streamFixedUp);
1893 } else {
1894 /* Note: This codepath is not reachable from d3d9 (see fvf->decl9 conversion)
1895 * It is reachable through d3d8, but only for fixed-function.
1896 * It will not work properly for shaders.
1898 TRACE("================ FVF ===================\n");
1899 memset(&stateblock->wineD3DDevice->strided_streams, 0, sizeof(stateblock->wineD3DDevice->strided_streams));
1900 primitiveConvertToStridedData((IWineD3DDevice *) stateblock->wineD3DDevice, &stateblock->wineD3DDevice->strided_streams,
1901 &stateblock->wineD3DDevice->streamFixedUp);
1905 const struct StateEntry StateTable[] =
1907 /* State name representative, apply function */
1908 { /* 0, Undefined */ 0, state_undefined },
1909 { /* 1, WINED3DRS_TEXTUREHANDLE */ 0 /* Handled in ddraw */, state_undefined },
1910 { /* 2, WINED3DRS_ANTIALIAS */ STATE_RENDER(WINED3DRS_ANTIALIAS), state_antialias },
1911 { /* 3, WINED3DRS_TEXTUREADDRESS */ 0 /* Handled in ddraw */, state_undefined },
1912 { /* 4, WINED3DRS_TEXTUREPERSPECTIVE */ STATE_RENDER(WINED3DRS_TEXTUREPERSPECTIVE), state_perspective },
1913 { /* 5, WINED3DRS_WRAPU */ STATE_RENDER(WINED3DRS_WRAPU), state_wrapu },
1914 { /* 6, WINED3DRS_WRAPV */ STATE_RENDER(WINED3DRS_WRAPV), state_wrapv },
1915 { /* 7, WINED3DRS_ZENABLE */ STATE_RENDER(WINED3DRS_ZENABLE), state_zenable },
1916 { /* 8, WINED3DRS_FILLMODE */ STATE_RENDER(WINED3DRS_FILLMODE), state_fillmode },
1917 { /* 9, WINED3DRS_SHADEMODE */ STATE_RENDER(WINED3DRS_SHADEMODE), state_shademode },
1918 { /* 10, WINED3DRS_LINEPATTERN */ STATE_RENDER(WINED3DRS_LINEPATTERN), state_linepattern },
1919 { /* 11, WINED3DRS_MONOENABLE */ STATE_RENDER(WINED3DRS_MONOENABLE), state_monoenable },
1920 { /* 12, WINED3DRS_ROP2 */ STATE_RENDER(WINED3DRS_ROP2), state_rop2 },
1921 { /* 13, WINED3DRS_PLANEMASK */ STATE_RENDER(WINED3DRS_PLANEMASK), state_planemask },
1922 { /* 14, WINED3DRS_ZWRITEENABLE */ STATE_RENDER(WINED3DRS_ZWRITEENABLE), state_zwritenable },
1923 { /* 15, WINED3DRS_ALPHATESTENABLE */ STATE_RENDER(WINED3DRS_ALPHATESTENABLE), state_alpha },
1924 { /* 16, WINED3DRS_LASTPIXEL */ STATE_RENDER(WINED3DRS_LASTPIXEL), state_lastpixel },
1925 { /* 17, WINED3DRS_TEXTUREMAG */ 0 /* Handled in ddraw */, state_undefined },
1926 { /* 18, WINED3DRS_TEXTUREMIN */ 0 /* Handled in ddraw */, state_undefined },
1927 { /* 19, WINED3DRS_SRCBLEND */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), state_blend },
1928 { /* 20, WINED3DRS_DESTBLEND */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), state_blend },
1929 { /* 21, WINED3DRS_TEXTUREMAPBLEND */ 0 /* Handled in ddraw */, state_undefined },
1930 { /* 22, WINED3DRS_CULLMODE */ STATE_RENDER(WINED3DRS_CULLMODE), state_cullmode },
1931 { /* 23, WINED3DRS_ZFUNC */ STATE_RENDER(WINED3DRS_ZFUNC), state_zfunc },
1932 { /* 24, WINED3DRS_ALPHAREF */ STATE_RENDER(WINED3DRS_ALPHATESTENABLE), state_alpha },
1933 { /* 25, WINED3DRS_ALPHAFUNC */ STATE_RENDER(WINED3DRS_ALPHATESTENABLE), state_alpha },
1934 { /* 26, WINED3DRS_DITHERENABLE */ STATE_RENDER(WINED3DRS_DITHERENABLE), state_ditherenable },
1935 { /* 27, WINED3DRS_ALPHABLENDENABLE */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), state_blend },
1936 { /* 28, WINED3DRS_FOGENABLE */ STATE_RENDER(WINED3DRS_FOGENABLE), state_fog },
1937 { /* 29, WINED3DRS_SPECULARENABLE */ STATE_RENDER(WINED3DRS_SPECULARENABLE), state_specularenable},
1938 { /* 30, WINED3DRS_ZVISIBLE */ 0 /* Not supported according to the msdn */, state_nogl },
1939 { /* 31, WINED3DRS_SUBPIXEL */ STATE_RENDER(WINED3DRS_SUBPIXEL), state_subpixel },
1940 { /* 32, WINED3DRS_SUBPIXELX */ STATE_RENDER(WINED3DRS_SUBPIXELX), state_subpixelx },
1941 { /* 33, WINED3DRS_STIPPLEDALPHA */ STATE_RENDER(WINED3DRS_STIPPLEDALPHA), state_stippledalpha },
1942 { /* 34, WINED3DRS_FOGCOLOR */ STATE_RENDER(WINED3DRS_FOGCOLOR), state_fogcolor },
1943 { /* 35, WINED3DRS_FOGTABLEMODE */ STATE_RENDER(WINED3DRS_FOGENABLE), state_fog },
1944 { /* 36, WINED3DRS_FOGSTART */ STATE_RENDER(WINED3DRS_FOGENABLE), state_fog },
1945 { /* 37, WINED3DRS_FOGEND */ STATE_RENDER(WINED3DRS_FOGENABLE), state_fog },
1946 { /* 38, WINED3DRS_FOGDENSITY */ STATE_RENDER(WINED3DRS_FOGDENSITY), state_fogdensity },
1947 { /* 39, WINED3DRS_STIPPLEENABLE */ STATE_RENDER(WINED3DRS_STIPPLEENABLE), state_stippleenable },
1948 { /* 40, WINED3DRS_EDGEANTIALIAS */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), state_blend },
1949 { /* 41, WINED3DRS_COLORKEYENABLE */ STATE_RENDER(WINED3DRS_ALPHATESTENABLE), state_alpha },
1950 { /* 42, undefined */ 0, state_undefined },
1951 { /* 43, WINED3DRS_BORDERCOLOR */ STATE_RENDER(WINED3DRS_BORDERCOLOR), state_bordercolor },
1952 { /* 44, WINED3DRS_TEXTUREADDRESSU */ 0, /* Handled in ddraw */ state_undefined },
1953 { /* 45, WINED3DRS_TEXTUREADDRESSV */ 0, /* Handled in ddraw */ state_undefined },
1954 { /* 46, WINED3DRS_MIPMAPLODBIAS */ STATE_RENDER(WINED3DRS_MIPMAPLODBIAS), state_mipmaplodbias },
1955 { /* 47, WINED3DRS_ZBIAS */ STATE_RENDER(WINED3DRS_ZBIAS), state_zbias },
1956 { /* 48, WINED3DRS_RANGEFOGENABLE */ 0, state_nogl },
1957 { /* 49, WINED3DRS_ANISOTROPY */ STATE_RENDER(WINED3DRS_ANISOTROPY), state_anisotropy },
1958 { /* 50, WINED3DRS_FLUSHBATCH */ STATE_RENDER(WINED3DRS_FLUSHBATCH), state_flushbatch },
1959 { /* 51, WINED3DRS_TRANSLUCENTSORTINDEPENDENT */ STATE_RENDER(WINED3DRS_TRANSLUCENTSORTINDEPENDENT), state_translucentsi },
1960 { /* 52, WINED3DRS_STENCILENABLE */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
1961 { /* 53, WINED3DRS_STENCILFAIL */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
1962 { /* 54, WINED3DRS_STENCILZFAIL */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
1963 { /* 55, WINED3DRS_STENCILPASS */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
1964 { /* 56, WINED3DRS_STENCILFUNC */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
1965 { /* 57, WINED3DRS_STENCILREF */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
1966 { /* 58, WINED3DRS_STENCILMASK */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
1967 { /* 59, WINED3DRS_STENCILWRITEMASK */ STATE_RENDER(WINED3DRS_STENCILWRITEMASK), state_stencilwrite },
1968 { /* 60, WINED3DRS_TEXTUREFACTOR */ STATE_RENDER(WINED3DRS_TEXTUREFACTOR), state_texfactor },
1969 { /* 61, Undefined */ 0, state_undefined },
1970 { /* 62, Undefined */ 0, state_undefined },
1971 { /* 63, Undefined */ 0, state_undefined },
1972 { /* 64, WINED3DRS_STIPPLEPATTERN00 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
1973 { /* 65, WINED3DRS_STIPPLEPATTERN01 */ 0 /* Obsolete, should he handled by ddraw */, state_undefined },
1974 { /* 66, WINED3DRS_STIPPLEPATTERN02 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
1975 { /* 67, WINED3DRS_STIPPLEPATTERN03 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
1976 { /* 68, WINED3DRS_STIPPLEPATTERN04 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
1977 { /* 69, WINED3DRS_STIPPLEPATTERN05 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
1978 { /* 70, WINED3DRS_STIPPLEPATTERN06 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
1979 { /* 71, WINED3DRS_STIPPLEPATTERN07 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
1980 { /* 72, WINED3DRS_STIPPLEPATTERN08 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
1981 { /* 73, WINED3DRS_STIPPLEPATTERN09 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
1982 { /* 74, WINED3DRS_STIPPLEPATTERN10 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
1983 { /* 75, WINED3DRS_STIPPLEPATTERN11 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
1984 { /* 76, WINED3DRS_STIPPLEPATTERN12 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
1985 { /* 77, WINED3DRS_STIPPLEPATTERN13 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
1986 { /* 78, WINED3DRS_STIPPLEPATTERN14 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
1987 { /* 79, WINED3DRS_STIPPLEPATTERN15 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
1988 { /* 80, WINED3DRS_STIPPLEPATTERN16 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
1989 { /* 81, WINED3DRS_STIPPLEPATTERN17 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
1990 { /* 82, WINED3DRS_STIPPLEPATTERN18 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
1991 { /* 83, WINED3DRS_STIPPLEPATTERN19 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
1992 { /* 84, WINED3DRS_STIPPLEPATTERN20 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
1993 { /* 85, WINED3DRS_STIPPLEPATTERN21 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
1994 { /* 86, WINED3DRS_STIPPLEPATTERN22 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
1995 { /* 87, WINED3DRS_STIPPLEPATTERN23 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
1996 { /* 88, WINED3DRS_STIPPLEPATTERN24 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
1997 { /* 89, WINED3DRS_STIPPLEPATTERN25 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
1998 { /* 90, WINED3DRS_STIPPLEPATTERN26 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
1999 { /* 91, WINED3DRS_STIPPLEPATTERN27 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2000 { /* 92, WINED3DRS_STIPPLEPATTERN28 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2001 { /* 93, WINED3DRS_STIPPLEPATTERN29 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2002 { /* 94, WINED3DRS_STIPPLEPATTERN30 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2003 { /* 95, WINED3DRS_STIPPLEPATTERN31 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2004 { /* 96, Undefined */ 0, state_undefined },
2005 { /* 97, Undefined */ 0, state_undefined },
2006 { /* 98, Undefined */ 0, state_undefined },
2007 { /* 99, Undefined */ 0, state_undefined },
2008 { /*100, Undefined */ 0, state_undefined },
2009 { /*101, Undefined */ 0, state_undefined },
2010 { /*102, Undefined */ 0, state_undefined },
2011 { /*103, Undefined */ 0, state_undefined },
2012 { /*104, Undefined */ 0, state_undefined },
2013 { /*105, Undefined */ 0, state_undefined },
2014 { /*106, Undefined */ 0, state_undefined },
2015 { /*107, Undefined */ 0, state_undefined },
2016 { /*108, Undefined */ 0, state_undefined },
2017 { /*109, Undefined */ 0, state_undefined },
2018 { /*110, Undefined */ 0, state_undefined },
2019 { /*111, Undefined */ 0, state_undefined },
2020 { /*112, Undefined */ 0, state_undefined },
2021 { /*113, Undefined */ 0, state_undefined },
2022 { /*114, Undefined */ 0, state_undefined },
2023 { /*115, Undefined */ 0, state_undefined },
2024 { /*116, Undefined */ 0, state_undefined },
2025 { /*117, Undefined */ 0, state_undefined },
2026 { /*118, Undefined */ 0, state_undefined },
2027 { /*119, Undefined */ 0, state_undefined },
2028 { /*120, Undefined */ 0, state_undefined },
2029 { /*121, Undefined */ 0, state_undefined },
2030 { /*122, Undefined */ 0, state_undefined },
2031 { /*123, Undefined */ 0, state_undefined },
2032 { /*124, Undefined */ 0, state_undefined },
2033 { /*125, Undefined */ 0, state_undefined },
2034 { /*126, Undefined */ 0, state_undefined },
2035 { /*127, Undefined */ 0, state_undefined },
2036 /* Big hole ends */
2037 { /*128, WINED3DRS_WRAP0 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2038 { /*129, WINED3DRS_WRAP1 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2039 { /*130, WINED3DRS_WRAP2 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2040 { /*131, WINED3DRS_WRAP3 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2041 { /*132, WINED3DRS_WRAP4 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2042 { /*133, WINED3DRS_WRAP5 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2043 { /*134, WINED3DRS_WRAP6 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2044 { /*135, WINED3DRS_WRAP7 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2045 { /*136, WINED3DRS_CLIPPING */ STATE_RENDER(WINED3DRS_CLIPPING), state_clipping },
2046 { /*137, WINED3DRS_LIGHTING */ STATE_RENDER(WINED3DRS_LIGHTING) /* Vertex decl! */,state_lighting },
2047 { /*138, WINED3DRS_EXTENTS */ STATE_RENDER(WINED3DRS_EXTENTS), state_extents },
2048 { /*139, WINED3DRS_AMBIENT */ STATE_RENDER(WINED3DRS_AMBIENT), state_ambient },
2049 { /*140, WINED3DRS_FOGVERTEXMODE */ STATE_RENDER(WINED3DRS_FOGENABLE), state_fog },
2050 { /*141, WINED3DRS_COLORVERTEX */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat },
2051 { /*142, WINED3DRS_LOCALVIEWER */ STATE_RENDER(WINED3DRS_LOCALVIEWER), state_localviewer },
2052 { /*143, WINED3DRS_NORMALIZENORMALS */ STATE_RENDER(WINED3DRS_NORMALIZENORMALS), state_normalize },
2053 { /*144, WINED3DRS_COLORKEYBLENDENABLE */ STATE_RENDER(WINED3DRS_COLORKEYBLENDENABLE), state_ckeyblend },
2054 { /*145, WINED3DRS_DIFFUSEMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat },
2055 { /*146, WINED3DRS_SPECULARMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat },
2056 { /*147, WINED3DRS_AMBIENTMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat },
2057 { /*148, WINED3DRS_EMISSIVEMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat },
2058 { /*149, Undefined */ 0, state_undefined },
2059 { /*150, Undefined */ 0, state_undefined },
2060 { /*151, WINED3DRS_VERTEXBLEND */ 0, state_nogl },
2061 { /*152, WINED3DRS_CLIPPLANEENABLE */ STATE_RENDER(WINED3DRS_CLIPPING), state_clipping },
2062 { /*153, WINED3DRS_SOFTWAREVERTEXPROCESSING */ 0, state_nogl },
2063 { /*154, WINED3DRS_POINTSIZE */ STATE_RENDER(WINED3DRS_POINTSIZE), state_psize },
2064 { /*155, WINED3DRS_POINTSIZE_MIN */ STATE_RENDER(WINED3DRS_POINTSIZE_MIN), state_psizemin },
2065 { /*156, WINED3DRS_POINTSPRITEENABLE */ STATE_RENDER(WINED3DRS_POINTSPRITEENABLE), state_pointsprite },
2066 { /*157, WINED3DRS_POINTSCALEENABLE */ STATE_RENDER(WINED3DRS_POINTSCALEENABLE), state_pscale },
2067 { /*158, WINED3DRS_POINTSCALE_A */ STATE_RENDER(WINED3DRS_POINTSCALEENABLE), state_pscale },
2068 { /*159, WINED3DRS_POINTSCALE_B */ STATE_RENDER(WINED3DRS_POINTSCALEENABLE), state_pscale },
2069 { /*160, WINED3DRS_POINTSCALE_C */ STATE_RENDER(WINED3DRS_POINTSCALEENABLE), state_pscale },
2070 { /*161, WINED3DRS_MULTISAMPLEANTIALIAS */ STATE_RENDER(WINED3DRS_MULTISAMPLEANTIALIAS), state_multisampleaa },
2071 { /*162, WINED3DRS_MULTISAMPLEMASK */ STATE_RENDER(WINED3DRS_MULTISAMPLEMASK), state_multisampmask },
2072 { /*163, WINED3DRS_PATCHEDGESTYLE */ STATE_RENDER(WINED3DRS_PATCHEDGESTYLE), state_patchedgestyle},
2073 { /*164, WINED3DRS_PATCHSEGMENTS */ STATE_RENDER(WINED3DRS_PATCHSEGMENTS), state_patchsegments },
2074 { /*165, WINED3DRS_DEBUGMONITORTOKEN */ STATE_RENDER(WINED3DRS_DEBUGMONITORTOKEN), state_nogl },
2075 { /*166, WINED3DRS_POINTSIZE_MAX */ STATE_RENDER(WINED3DRS_POINTSIZE_MAX), state_psizemax },
2076 { /*167, WINED3DRS_INDEXEDVERTEXBLENDENABLE */ 0, state_nogl },
2077 { /*168, WINED3DRS_COLORWRITEENABLE */ STATE_RENDER(WINED3DRS_COLORWRITEENABLE), state_colorwrite },
2078 { /*169, Undefined */ 0, state_undefined },
2079 { /*170, WINED3DRS_TWEENFACTOR */ 0, state_nogl },
2080 { /*171, WINED3DRS_BLENDOP */ STATE_RENDER(WINED3DRS_BLENDOP), state_blendop },
2081 { /*172, WINED3DRS_POSITIONDEGREE */ STATE_RENDER(WINED3DRS_POSITIONDEGREE), state_positiondegree},
2082 { /*173, WINED3DRS_NORMALDEGREE */ STATE_RENDER(WINED3DRS_NORMALDEGREE), state_normaldegree },
2083 /*172, WINED3DRS_POSITIONORDER */ /* Value assigned to 2 state names */
2084 /*173, WINED3DRS_NORMALORDER */ /* Value assigned to 2 state names */
2085 { /*174, WINED3DRS_SCISSORTESTENABLE */ STATE_RENDER(WINED3DRS_SCISSORTESTENABLE), state_scissor },
2086 { /*175, WINED3DRS_SLOPESCALEDEPTHBIAS */ STATE_RENDER(WINED3DRS_DEPTHBIAS), state_depthbias },
2087 { /*176, WINED3DRS_ANTIALIASEDLINEENABLE */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), state_blend },
2088 { /*177, undefined */ 0, state_undefined },
2089 { /*178, WINED3DRS_MINTESSELLATIONLEVEL */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation },
2090 { /*179, WINED3DRS_MAXTESSELLATIONLEVEL */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation },
2091 { /*180, WINED3DRS_ADAPTIVETESS_X */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation },
2092 { /*181, WINED3DRS_ADAPTIVETESS_Y */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation },
2093 { /*182, WINED3DRS_ADAPTIVETESS_Z */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation },
2094 { /*183, WINED3DRS_ADAPTIVETESS_W */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation },
2095 { /*184, WINED3DRS_ENABLEADAPTIVETESSELLATION */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation },
2096 { /*185, WINED3DRS_TWOSIDEDSTENCILMODE */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2097 { /*186, WINED3DRS_CCW_STENCILFAIL */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2098 { /*187, WINED3DRS_CCW_STENCILZFAIL */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2099 { /*188, WINED3DRS_CCW_STENCILPASS */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2100 { /*189, WINED3DRS_CCW_STENCILFUNC */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2101 { /*190, WINED3DRS_COLORWRITEENABLE1 */ STATE_RENDER(WINED3DRS_COLORWRITEENABLE), state_colorwrite },
2102 { /*191, WINED3DRS_COLORWRITEENABLE2 */ STATE_RENDER(WINED3DRS_COLORWRITEENABLE), state_colorwrite },
2103 { /*192, WINED3DRS_COLORWRITEENABLE3 */ STATE_RENDER(WINED3DRS_COLORWRITEENABLE), state_colorwrite },
2104 { /*193, WINED3DRS_BLENDFACTOR */ STATE_RENDER(WINED3DRS_BLENDFACTOR), state_blendfactor },
2105 { /*194, WINED3DRS_SRGBWRITEENABLE */ STATE_RENDER(WINED3DRS_SRGBWRITEENABLE), state_srgbwrite },
2106 { /*195, WINED3DRS_DEPTHBIAS */ STATE_RENDER(WINED3DRS_DEPTHBIAS), state_depthbias },
2107 { /*196, undefined */ 0, state_undefined },
2108 { /*197, undefined */ 0, state_undefined },
2109 { /*198, WINED3DRS_WRAP8 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2110 { /*199, WINED3DRS_WRAP9 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2111 { /*200, WINED3DRS_WRAP10 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2112 { /*201, WINED3DRS_WRAP11 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2113 { /*202, WINED3DRS_WRAP12 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2114 { /*203, WINED3DRS_WRAP13 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2115 { /*204, WINED3DRS_WRAP14 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2116 { /*205, WINED3DRS_WRAP15 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2117 { /*206, WINED3DRS_SEPARATEALPHABLENDENABLE */ STATE_RENDER(WINED3DRS_SEPARATEALPHABLENDENABLE), state_seperateblend },
2118 { /*207, WINED3DRS_SRCBLENDALPHA */ STATE_RENDER(WINED3DRS_SEPARATEALPHABLENDENABLE), state_seperateblend },
2119 { /*208, WINED3DRS_DESTBLENDALPHA */ STATE_RENDER(WINED3DRS_SEPARATEALPHABLENDENABLE), state_seperateblend },
2120 { /*209, WINED3DRS_BLENDOPALPHA */ STATE_RENDER(WINED3DRS_SEPARATEALPHABLENDENABLE), state_seperateblend },
2121 /* Texture stage states */
2122 { /*0, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop },
2123 { /*0, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop },
2124 { /*0, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop },
2125 { /*0, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), tex_alphaop },
2126 { /*0, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), tex_alphaop },
2127 { /*0, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), tex_alphaop },
2128 { /*0, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop },
2129 { /*0, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop },
2130 { /*0, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop },
2131 { /*0, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop },
2132 { /*0, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(0, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
2133 { /*0, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2134 { /*0, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2135 { /*0, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2136 { /*0, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2137 { /*0, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2138 { /*0, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2139 { /*0, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2140 { /*0, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2141 { /*0, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2142 { /*0, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2143 { /*0, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
2144 { /*0, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
2145 { /*0, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE0), transform_texture },
2146 { /*0, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2147 { /*0, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop },
2148 { /*0, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), tex_alphaop },
2149 { /*0, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(0, WINED3DTSS_RESULTARG), tex_resultarg },
2150 { /*0, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2151 { /*0, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2152 { /*0, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2153 { /*0, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
2155 { /*1, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), tex_colorop },
2156 { /*1, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), tex_colorop },
2157 { /*1, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), tex_colorop },
2158 { /*1, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP), tex_alphaop },
2159 { /*1, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP), tex_alphaop },
2160 { /*1, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP), tex_alphaop },
2161 { /*1, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), tex_colorop },
2162 { /*1, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), tex_colorop },
2163 { /*1, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), tex_colorop },
2164 { /*1, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), tex_colorop },
2165 { /*1, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(1, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
2166 { /*1, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2167 { /*1, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2168 { /*1, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2169 { /*1, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2170 { /*1, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2171 { /*1, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2172 { /*1, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2173 { /*1, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2174 { /*1, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2175 { /*1, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2176 { /*1, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
2177 { /*1, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
2178 { /*1, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE1), transform_texture },
2179 { /*1, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2180 { /*1, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), tex_colorop },
2181 { /*1, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP), tex_alphaop },
2182 { /*1, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(1, WINED3DTSS_RESULTARG), tex_resultarg },
2183 { /*1, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2184 { /*1, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2185 { /*1, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2186 { /*1, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
2188 { /*2, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), tex_colorop },
2189 { /*2, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), tex_colorop },
2190 { /*2, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), tex_colorop },
2191 { /*2, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP), tex_alphaop },
2192 { /*2, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP), tex_alphaop },
2193 { /*2, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP), tex_alphaop },
2194 { /*2, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), tex_colorop },
2195 { /*2, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), tex_colorop },
2196 { /*2, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), tex_colorop },
2197 { /*2, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), tex_colorop },
2198 { /*2, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(2, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
2199 { /*2, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2200 { /*2, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2201 { /*2, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2202 { /*2, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2203 { /*2, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2204 { /*2, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2205 { /*2, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2206 { /*2, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2207 { /*2, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2208 { /*2, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2209 { /*2, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
2210 { /*2, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
2211 { /*2, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE2), transform_texture },
2212 { /*2, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2213 { /*2, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), tex_colorop },
2214 { /*2, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP), tex_alphaop },
2215 { /*2, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(2, WINED3DTSS_RESULTARG), tex_resultarg },
2216 { /*2, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2217 { /*2, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2218 { /*2, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2219 { /*2, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
2221 { /*3, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), tex_colorop },
2222 { /*3, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), tex_colorop },
2223 { /*3, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), tex_colorop },
2224 { /*3, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP), tex_alphaop },
2225 { /*3, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP), tex_alphaop },
2226 { /*3, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP), tex_alphaop },
2227 { /*3, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), tex_colorop },
2228 { /*3, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), tex_colorop },
2229 { /*3, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), tex_colorop },
2230 { /*3, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), tex_colorop },
2231 { /*3, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(3, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
2232 { /*3, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2233 { /*3, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2234 { /*3, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2235 { /*3, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2236 { /*3, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2237 { /*3, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2238 { /*3, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2239 { /*3, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2240 { /*3, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2241 { /*3, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2242 { /*3, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
2243 { /*3, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
2244 { /*3, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE3), transform_texture },
2245 { /*3, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2246 { /*3, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), tex_colorop },
2247 { /*3, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP), tex_alphaop },
2248 { /*3, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(3, WINED3DTSS_RESULTARG), tex_resultarg },
2249 { /*3, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2250 { /*3, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2251 { /*3, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2252 { /*3, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
2254 { /*4, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), tex_colorop },
2255 { /*4, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), tex_colorop },
2256 { /*4, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), tex_colorop },
2257 { /*4, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP), tex_alphaop },
2258 { /*4, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP), tex_alphaop },
2259 { /*4, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP), tex_alphaop },
2260 { /*4, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), state_undefined },
2261 { /*4, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), state_undefined },
2262 { /*4, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), state_undefined },
2263 { /*4, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), state_undefined },
2264 { /*4, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(4, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
2265 { /*4, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2266 { /*4, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2267 { /*4, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2268 { /*4, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2269 { /*4, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2270 { /*4, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2271 { /*4, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2272 { /*4, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2273 { /*4, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2274 { /*4, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2275 { /*4, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
2276 { /*4, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
2277 { /*4, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE4), transform_texture },
2278 { /*4, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2279 { /*4, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), tex_colorop },
2280 { /*4, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP), tex_alphaop },
2281 { /*4, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(4, WINED3DTSS_RESULTARG), tex_resultarg },
2282 { /*4, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2283 { /*4, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2284 { /*4, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2285 { /*4, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
2287 { /*5, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), tex_colorop },
2288 { /*5, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), tex_colorop },
2289 { /*5, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), tex_colorop },
2290 { /*5, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP), tex_alphaop },
2291 { /*5, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP), tex_alphaop },
2292 { /*5, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP), tex_alphaop },
2293 { /*5, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), tex_colorop },
2294 { /*5, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), tex_colorop },
2295 { /*5, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), tex_colorop },
2296 { /*5, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), tex_colorop },
2297 { /*5, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(5, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
2298 { /*5, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2299 { /*5, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2300 { /*5, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2301 { /*5, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2302 { /*5, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2303 { /*5, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2304 { /*5, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2305 { /*5, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2306 { /*5, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2307 { /*5, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2308 { /*5, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
2309 { /*5, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
2310 { /*5, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE5), transform_texture },
2311 { /*5, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2312 { /*5, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), tex_colorop },
2313 { /*5, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP), tex_alphaop },
2314 { /*5, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(5, WINED3DTSS_RESULTARG), tex_resultarg },
2315 { /*5, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2316 { /*5, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2317 { /*5, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2318 { /*5, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
2320 { /*6, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), tex_colorop },
2321 { /*6, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), tex_colorop },
2322 { /*6, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), tex_colorop },
2323 { /*6, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP), tex_alphaop },
2324 { /*6, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP), tex_alphaop },
2325 { /*6, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP), tex_alphaop },
2326 { /*6, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), tex_colorop },
2327 { /*6, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), tex_colorop },
2328 { /*6, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), tex_colorop },
2329 { /*6, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), tex_colorop },
2330 { /*6, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(6, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
2331 { /*6, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2332 { /*6, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2333 { /*6, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2334 { /*6, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2335 { /*6, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2336 { /*6, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2337 { /*6, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2338 { /*6, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2339 { /*6, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2340 { /*6, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2341 { /*6, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
2342 { /*6, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
2343 { /*6, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE6), transform_texture },
2344 { /*6, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2345 { /*6, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), tex_colorop },
2346 { /*6, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP), tex_alphaop },
2347 { /*6, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(6, WINED3DTSS_RESULTARG), tex_resultarg },
2348 { /*6, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2349 { /*6, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2350 { /*6, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2351 { /*6, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
2353 { /*7, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), tex_colorop },
2354 { /*7, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), tex_colorop },
2355 { /*7, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), tex_colorop },
2356 { /*7, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP), tex_alphaop },
2357 { /*7, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP), tex_alphaop },
2358 { /*7, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP), tex_alphaop },
2359 { /*7, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), tex_colorop },
2360 { /*7, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), tex_colorop },
2361 { /*7, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), tex_colorop },
2362 { /*7, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), tex_colorop },
2363 { /*7, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(7, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
2364 { /*7, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2365 { /*7, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2366 { /*7, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2367 { /*7, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2368 { /*7, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2369 { /*7, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2370 { /*7, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2371 { /*7, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2372 { /*7, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2373 { /*7, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2374 { /*7, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
2375 { /*7, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
2376 { /*7, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE7), transform_texture },
2377 { /*7, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2378 { /*7, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), tex_colorop },
2379 { /*7, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP), tex_alphaop },
2380 { /*7, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(7, WINED3DTSS_RESULTARG), tex_resultarg },
2381 { /*7, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2382 { /*7, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2383 { /*7, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
2384 { /*7, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
2385 /* Sampler states */
2386 { /* 0, Sampler 0 */ STATE_SAMPLER(0), sampler },
2387 { /* 1, Sampler 1 */ STATE_SAMPLER(1), sampler },
2388 { /* 2, Sampler 2 */ STATE_SAMPLER(2), sampler },
2389 { /* 3, Sampler 3 */ STATE_SAMPLER(3), sampler },
2390 { /* 4, Sampler 3 */ STATE_SAMPLER(4), sampler },
2391 { /* 5, Sampler 5 */ STATE_SAMPLER(5), sampler },
2392 { /* 6, Sampler 6 */ STATE_SAMPLER(6), sampler },
2393 { /* 7, Sampler 7 */ STATE_SAMPLER(7), sampler },
2394 { /* 8, Sampler 8 */ STATE_SAMPLER(8), sampler },
2395 { /* 9, Sampler 9 */ STATE_SAMPLER(9), sampler },
2396 { /*10, Sampler 10 */ STATE_SAMPLER(10), sampler },
2397 { /*11, Sampler 11 */ STATE_SAMPLER(11), sampler },
2398 { /*12, Sampler 12 */ STATE_SAMPLER(12), sampler },
2399 { /*13, Sampler 13 */ STATE_SAMPLER(13), sampler },
2400 { /*14, Sampler 14 */ STATE_SAMPLER(14), sampler },
2401 { /*15, Sampler 15 */ STATE_SAMPLER(15), sampler },
2402 /* Pixel shader */
2403 { /* , Pixel Shader */ STATE_PIXELSHADER, pixelshader },
2404 /* Transform states follow */
2405 { /* 1, undefined */ 0, state_undefined },
2406 { /* 2, WINED3DTS_VIEW */ STATE_TRANSFORM(WINED3DTS_VIEW), transform_view },
2407 { /* 3, WINED3DTS_PROJECTION */ STATE_TRANSFORM(WINED3DTS_PROJECTION), state_undefined },
2408 { /* 4, undefined */ 0, state_undefined },
2409 { /* 5, undefined */ 0, state_undefined },
2410 { /* 6, undefined */ 0, state_undefined },
2411 { /* 7, undefined */ 0, state_undefined },
2412 { /* 8, undefined */ 0, state_undefined },
2413 { /* 9, undefined */ 0, state_undefined },
2414 { /* 10, undefined */ 0, state_undefined },
2415 { /* 11, undefined */ 0, state_undefined },
2416 { /* 12, undefined */ 0, state_undefined },
2417 { /* 13, undefined */ 0, state_undefined },
2418 { /* 14, undefined */ 0, state_undefined },
2419 { /* 15, undefined */ 0, state_undefined },
2420 { /* 16, WINED3DTS_TEXTURE0 */ STATE_TRANSFORM(WINED3DTS_TEXTURE0), transform_texture },
2421 { /* 17, WINED3DTS_TEXTURE1 */ STATE_TRANSFORM(WINED3DTS_TEXTURE1), transform_texture },
2422 { /* 18, WINED3DTS_TEXTURE2 */ STATE_TRANSFORM(WINED3DTS_TEXTURE2), transform_texture },
2423 { /* 19, WINED3DTS_TEXTURE3 */ STATE_TRANSFORM(WINED3DTS_TEXTURE3), transform_texture },
2424 { /* 20, WINED3DTS_TEXTURE4 */ STATE_TRANSFORM(WINED3DTS_TEXTURE4), transform_texture },
2425 { /* 21, WINED3DTS_TEXTURE5 */ STATE_TRANSFORM(WINED3DTS_TEXTURE5), transform_texture },
2426 { /* 22, WINED3DTS_TEXTURE6 */ STATE_TRANSFORM(WINED3DTS_TEXTURE6), transform_texture },
2427 { /* 23, WINED3DTS_TEXTURE7 */ STATE_TRANSFORM(WINED3DTS_TEXTURE7), transform_texture },
2428 /* A huge gap between TEXTURE7 and WORLDMATRIX(0) :-( But entries are needed to catch then if a broken app sets them */
2429 { /* 24, undefined */ 0, state_undefined },
2430 { /* 25, undefined */ 0, state_undefined },
2431 { /* 26, undefined */ 0, state_undefined },
2432 { /* 27, undefined */ 0, state_undefined },
2433 { /* 28, undefined */ 0, state_undefined },
2434 { /* 29, undefined */ 0, state_undefined },
2435 { /* 30, undefined */ 0, state_undefined },
2436 { /* 31, undefined */ 0, state_undefined },
2437 { /* 32, undefined */ 0, state_undefined },
2438 { /* 33, undefined */ 0, state_undefined },
2439 { /* 34, undefined */ 0, state_undefined },
2440 { /* 35, undefined */ 0, state_undefined },
2441 { /* 36, undefined */ 0, state_undefined },
2442 { /* 37, undefined */ 0, state_undefined },
2443 { /* 38, undefined */ 0, state_undefined },
2444 { /* 39, undefined */ 0, state_undefined },
2445 { /* 40, undefined */ 0, state_undefined },
2446 { /* 41, undefined */ 0, state_undefined },
2447 { /* 42, undefined */ 0, state_undefined },
2448 { /* 43, undefined */ 0, state_undefined },
2449 { /* 44, undefined */ 0, state_undefined },
2450 { /* 45, undefined */ 0, state_undefined },
2451 { /* 46, undefined */ 0, state_undefined },
2452 { /* 47, undefined */ 0, state_undefined },
2453 { /* 48, undefined */ 0, state_undefined },
2454 { /* 49, undefined */ 0, state_undefined },
2455 { /* 50, undefined */ 0, state_undefined },
2456 { /* 51, undefined */ 0, state_undefined },
2457 { /* 52, undefined */ 0, state_undefined },
2458 { /* 53, undefined */ 0, state_undefined },
2459 { /* 54, undefined */ 0, state_undefined },
2460 { /* 55, undefined */ 0, state_undefined },
2461 { /* 56, undefined */ 0, state_undefined },
2462 { /* 57, undefined */ 0, state_undefined },
2463 { /* 58, undefined */ 0, state_undefined },
2464 { /* 59, undefined */ 0, state_undefined },
2465 { /* 60, undefined */ 0, state_undefined },
2466 { /* 61, undefined */ 0, state_undefined },
2467 { /* 62, undefined */ 0, state_undefined },
2468 { /* 63, undefined */ 0, state_undefined },
2469 { /* 64, undefined */ 0, state_undefined },
2470 { /* 65, undefined */ 0, state_undefined },
2471 { /* 66, undefined */ 0, state_undefined },
2472 { /* 67, undefined */ 0, state_undefined },
2473 { /* 68, undefined */ 0, state_undefined },
2474 { /* 69, undefined */ 0, state_undefined },
2475 { /* 70, undefined */ 0, state_undefined },
2476 { /* 71, undefined */ 0, state_undefined },
2477 { /* 72, undefined */ 0, state_undefined },
2478 { /* 73, undefined */ 0, state_undefined },
2479 { /* 74, undefined */ 0, state_undefined },
2480 { /* 75, undefined */ 0, state_undefined },
2481 { /* 76, undefined */ 0, state_undefined },
2482 { /* 77, undefined */ 0, state_undefined },
2483 { /* 78, undefined */ 0, state_undefined },
2484 { /* 79, undefined */ 0, state_undefined },
2485 { /* 80, undefined */ 0, state_undefined },
2486 { /* 81, undefined */ 0, state_undefined },
2487 { /* 82, undefined */ 0, state_undefined },
2488 { /* 83, undefined */ 0, state_undefined },
2489 { /* 84, undefined */ 0, state_undefined },
2490 { /* 85, undefined */ 0, state_undefined },
2491 { /* 86, undefined */ 0, state_undefined },
2492 { /* 87, undefined */ 0, state_undefined },
2493 { /* 88, undefined */ 0, state_undefined },
2494 { /* 89, undefined */ 0, state_undefined },
2495 { /* 90, undefined */ 0, state_undefined },
2496 { /* 91, undefined */ 0, state_undefined },
2497 { /* 92, undefined */ 0, state_undefined },
2498 { /* 93, undefined */ 0, state_undefined },
2499 { /* 94, undefined */ 0, state_undefined },
2500 { /* 95, undefined */ 0, state_undefined },
2501 { /* 96, undefined */ 0, state_undefined },
2502 { /* 97, undefined */ 0, state_undefined },
2503 { /* 98, undefined */ 0, state_undefined },
2504 { /* 99, undefined */ 0, state_undefined },
2505 { /*100, undefined */ 0, state_undefined },
2506 { /*101, undefined */ 0, state_undefined },
2507 { /*102, undefined */ 0, state_undefined },
2508 { /*103, undefined */ 0, state_undefined },
2509 { /*104, undefined */ 0, state_undefined },
2510 { /*105, undefined */ 0, state_undefined },
2511 { /*106, undefined */ 0, state_undefined },
2512 { /*107, undefined */ 0, state_undefined },
2513 { /*108, undefined */ 0, state_undefined },
2514 { /*109, undefined */ 0, state_undefined },
2515 { /*110, undefined */ 0, state_undefined },
2516 { /*111, undefined */ 0, state_undefined },
2517 { /*112, undefined */ 0, state_undefined },
2518 { /*113, undefined */ 0, state_undefined },
2519 { /*114, undefined */ 0, state_undefined },
2520 { /*115, undefined */ 0, state_undefined },
2521 { /*116, undefined */ 0, state_undefined },
2522 { /*117, undefined */ 0, state_undefined },
2523 { /*118, undefined */ 0, state_undefined },
2524 { /*119, undefined */ 0, state_undefined },
2525 { /*120, undefined */ 0, state_undefined },
2526 { /*121, undefined */ 0, state_undefined },
2527 { /*122, undefined */ 0, state_undefined },
2528 { /*123, undefined */ 0, state_undefined },
2529 { /*124, undefined */ 0, state_undefined },
2530 { /*125, undefined */ 0, state_undefined },
2531 { /*126, undefined */ 0, state_undefined },
2532 { /*127, undefined */ 0, state_undefined },
2533 { /*128, undefined */ 0, state_undefined },
2534 { /*129, undefined */ 0, state_undefined },
2535 { /*130, undefined */ 0, state_undefined },
2536 { /*131, undefined */ 0, state_undefined },
2537 { /*132, undefined */ 0, state_undefined },
2538 { /*133, undefined */ 0, state_undefined },
2539 { /*134, undefined */ 0, state_undefined },
2540 { /*135, undefined */ 0, state_undefined },
2541 { /*136, undefined */ 0, state_undefined },
2542 { /*137, undefined */ 0, state_undefined },
2543 { /*138, undefined */ 0, state_undefined },
2544 { /*139, undefined */ 0, state_undefined },
2545 { /*140, undefined */ 0, state_undefined },
2546 { /*141, undefined */ 0, state_undefined },
2547 { /*142, undefined */ 0, state_undefined },
2548 { /*143, undefined */ 0, state_undefined },
2549 { /*144, undefined */ 0, state_undefined },
2550 { /*145, undefined */ 0, state_undefined },
2551 { /*146, undefined */ 0, state_undefined },
2552 { /*147, undefined */ 0, state_undefined },
2553 { /*148, undefined */ 0, state_undefined },
2554 { /*149, undefined */ 0, state_undefined },
2555 { /*150, undefined */ 0, state_undefined },
2556 { /*151, undefined */ 0, state_undefined },
2557 { /*152, undefined */ 0, state_undefined },
2558 { /*153, undefined */ 0, state_undefined },
2559 { /*154, undefined */ 0, state_undefined },
2560 { /*155, undefined */ 0, state_undefined },
2561 { /*156, undefined */ 0, state_undefined },
2562 { /*157, undefined */ 0, state_undefined },
2563 { /*158, undefined */ 0, state_undefined },
2564 { /*159, undefined */ 0, state_undefined },
2565 { /*160, undefined */ 0, state_undefined },
2566 { /*161, undefined */ 0, state_undefined },
2567 { /*162, undefined */ 0, state_undefined },
2568 { /*163, undefined */ 0, state_undefined },
2569 { /*164, undefined */ 0, state_undefined },
2570 { /*165, undefined */ 0, state_undefined },
2571 { /*166, undefined */ 0, state_undefined },
2572 { /*167, undefined */ 0, state_undefined },
2573 { /*168, undefined */ 0, state_undefined },
2574 { /*169, undefined */ 0, state_undefined },
2575 { /*170, undefined */ 0, state_undefined },
2576 { /*171, undefined */ 0, state_undefined },
2577 { /*172, undefined */ 0, state_undefined },
2578 { /*173, undefined */ 0, state_undefined },
2579 { /*174, undefined */ 0, state_undefined },
2580 { /*175, undefined */ 0, state_undefined },
2581 { /*176, undefined */ 0, state_undefined },
2582 { /*177, undefined */ 0, state_undefined },
2583 { /*178, undefined */ 0, state_undefined },
2584 { /*179, undefined */ 0, state_undefined },
2585 { /*180, undefined */ 0, state_undefined },
2586 { /*181, undefined */ 0, state_undefined },
2587 { /*182, undefined */ 0, state_undefined },
2588 { /*183, undefined */ 0, state_undefined },
2589 { /*184, undefined */ 0, state_undefined },
2590 { /*185, undefined */ 0, state_undefined },
2591 { /*186, undefined */ 0, state_undefined },
2592 { /*187, undefined */ 0, state_undefined },
2593 { /*188, undefined */ 0, state_undefined },
2594 { /*189, undefined */ 0, state_undefined },
2595 { /*190, undefined */ 0, state_undefined },
2596 { /*191, undefined */ 0, state_undefined },
2597 { /*192, undefined */ 0, state_undefined },
2598 { /*193, undefined */ 0, state_undefined },
2599 { /*194, undefined */ 0, state_undefined },
2600 { /*195, undefined */ 0, state_undefined },
2601 { /*196, undefined */ 0, state_undefined },
2602 { /*197, undefined */ 0, state_undefined },
2603 { /*198, undefined */ 0, state_undefined },
2604 { /*199, undefined */ 0, state_undefined },
2605 { /*200, undefined */ 0, state_undefined },
2606 { /*201, undefined */ 0, state_undefined },
2607 { /*202, undefined */ 0, state_undefined },
2608 { /*203, undefined */ 0, state_undefined },
2609 { /*204, undefined */ 0, state_undefined },
2610 { /*205, undefined */ 0, state_undefined },
2611 { /*206, undefined */ 0, state_undefined },
2612 { /*207, undefined */ 0, state_undefined },
2613 { /*208, undefined */ 0, state_undefined },
2614 { /*209, undefined */ 0, state_undefined },
2615 { /*210, undefined */ 0, state_undefined },
2616 { /*211, undefined */ 0, state_undefined },
2617 { /*212, undefined */ 0, state_undefined },
2618 { /*213, undefined */ 0, state_undefined },
2619 { /*214, undefined */ 0, state_undefined },
2620 { /*215, undefined */ 0, state_undefined },
2621 { /*216, undefined */ 0, state_undefined },
2622 { /*217, undefined */ 0, state_undefined },
2623 { /*218, undefined */ 0, state_undefined },
2624 { /*219, undefined */ 0, state_undefined },
2625 { /*220, undefined */ 0, state_undefined },
2626 { /*221, undefined */ 0, state_undefined },
2627 { /*222, undefined */ 0, state_undefined },
2628 { /*223, undefined */ 0, state_undefined },
2629 { /*224, undefined */ 0, state_undefined },
2630 { /*225, undefined */ 0, state_undefined },
2631 { /*226, undefined */ 0, state_undefined },
2632 { /*227, undefined */ 0, state_undefined },
2633 { /*228, undefined */ 0, state_undefined },
2634 { /*229, undefined */ 0, state_undefined },
2635 { /*230, undefined */ 0, state_undefined },
2636 { /*231, undefined */ 0, state_undefined },
2637 { /*232, undefined */ 0, state_undefined },
2638 { /*233, undefined */ 0, state_undefined },
2639 { /*234, undefined */ 0, state_undefined },
2640 { /*235, undefined */ 0, state_undefined },
2641 { /*236, undefined */ 0, state_undefined },
2642 { /*237, undefined */ 0, state_undefined },
2643 { /*238, undefined */ 0, state_undefined },
2644 { /*239, undefined */ 0, state_undefined },
2645 { /*240, undefined */ 0, state_undefined },
2646 { /*241, undefined */ 0, state_undefined },
2647 { /*242, undefined */ 0, state_undefined },
2648 { /*243, undefined */ 0, state_undefined },
2649 { /*244, undefined */ 0, state_undefined },
2650 { /*245, undefined */ 0, state_undefined },
2651 { /*246, undefined */ 0, state_undefined },
2652 { /*247, undefined */ 0, state_undefined },
2653 { /*248, undefined */ 0, state_undefined },
2654 { /*249, undefined */ 0, state_undefined },
2655 { /*250, undefined */ 0, state_undefined },
2656 { /*251, undefined */ 0, state_undefined },
2657 { /*252, undefined */ 0, state_undefined },
2658 { /*253, undefined */ 0, state_undefined },
2659 { /*254, undefined */ 0, state_undefined },
2660 { /*255, undefined */ 0, state_undefined },
2661 /* End huge gap */
2662 { /*256, WINED3DTS_WORLDMATRIX(0) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), state_undefined },
2663 { /*257, WINED3DTS_WORLDMATRIX(1) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(1)), transform_worldex },
2664 { /*258, WINED3DTS_WORLDMATRIX(2) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(2)), transform_worldex },
2665 { /*259, WINED3DTS_WORLDMATRIX(3) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(3)), transform_worldex },
2666 { /*260, WINED3DTS_WORLDMATRIX(4) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(4)), transform_worldex },
2667 { /*261, WINED3DTS_WORLDMATRIX(5) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(5)), transform_worldex },
2668 { /*262, WINED3DTS_WORLDMATRIX(6) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(6)), transform_worldex },
2669 { /*263, WINED3DTS_WORLDMATRIX(7) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(7)), transform_worldex },
2670 { /*264, WINED3DTS_WORLDMATRIX(8) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(8)), transform_worldex },
2671 { /*265, WINED3DTS_WORLDMATRIX(9) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(9)), transform_worldex },
2672 { /*266, WINED3DTS_WORLDMATRIX(10) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(10)), transform_worldex },
2673 { /*267, WINED3DTS_WORLDMATRIX(11) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(11)), transform_worldex },
2674 { /*268, WINED3DTS_WORLDMATRIX(12) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(12)), transform_worldex },
2675 { /*269, WINED3DTS_WORLDMATRIX(13) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(13)), transform_worldex },
2676 { /*270, WINED3DTS_WORLDMATRIX(14) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(14)), transform_worldex },
2677 { /*271, WINED3DTS_WORLDMATRIX(15) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(15)), transform_worldex },
2678 { /*272, WINED3DTS_WORLDMATRIX(16) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(16)), transform_worldex },
2679 { /*273, WINED3DTS_WORLDMATRIX(17) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(17)), transform_worldex },
2680 { /*274, WINED3DTS_WORLDMATRIX(18) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(18)), transform_worldex },
2681 { /*275, WINED3DTS_WORLDMATRIX(19) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(19)), transform_worldex },
2682 { /*276, WINED3DTS_WORLDMATRIX(20) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(20)), transform_worldex },
2683 { /*277, WINED3DTS_WORLDMATRIX(21) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(21)), transform_worldex },
2684 { /*278, WINED3DTS_WORLDMATRIX(22) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(22)), transform_worldex },
2685 { /*279, WINED3DTS_WORLDMATRIX(23) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(23)), transform_worldex },
2686 { /*280, WINED3DTS_WORLDMATRIX(24) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(24)), transform_worldex },
2687 { /*281, WINED3DTS_WORLDMATRIX(25) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(25)), transform_worldex },
2688 { /*282, WINED3DTS_WORLDMATRIX(26) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(26)), transform_worldex },
2689 { /*283, WINED3DTS_WORLDMATRIX(27) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(27)), transform_worldex },
2690 { /*284, WINED3DTS_WORLDMATRIX(28) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(28)), transform_worldex },
2691 { /*285, WINED3DTS_WORLDMATRIX(29) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(29)), transform_worldex },
2692 { /*286, WINED3DTS_WORLDMATRIX(30) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(30)), transform_worldex },
2693 { /*287, WINED3DTS_WORLDMATRIX(31) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(31)), transform_worldex },
2694 { /*288, WINED3DTS_WORLDMATRIX(32) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(32)), transform_worldex },
2695 { /*289, WINED3DTS_WORLDMATRIX(33) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(33)), transform_worldex },
2696 { /*290, WINED3DTS_WORLDMATRIX(34) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(34)), transform_worldex },
2697 { /*291, WINED3DTS_WORLDMATRIX(35) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(35)), transform_worldex },
2698 { /*292, WINED3DTS_WORLDMATRIX(36) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(36)), transform_worldex },
2699 { /*293, WINED3DTS_WORLDMATRIX(37) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(37)), transform_worldex },
2700 { /*294, WINED3DTS_WORLDMATRIX(38) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(38)), transform_worldex },
2701 { /*295, WINED3DTS_WORLDMATRIX(39) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(39)), transform_worldex },
2702 { /*296, WINED3DTS_WORLDMATRIX(40) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(40)), transform_worldex },
2703 { /*297, WINED3DTS_WORLDMATRIX(41) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(41)), transform_worldex },
2704 { /*298, WINED3DTS_WORLDMATRIX(42) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(42)), transform_worldex },
2705 { /*299, WINED3DTS_WORLDMATRIX(43) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(43)), transform_worldex },
2706 { /*300, WINED3DTS_WORLDMATRIX(44) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(44)), transform_worldex },
2707 { /*301, WINED3DTS_WORLDMATRIX(45) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(45)), transform_worldex },
2708 { /*302, WINED3DTS_WORLDMATRIX(46) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(46)), transform_worldex },
2709 { /*303, WINED3DTS_WORLDMATRIX(47) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(47)), transform_worldex },
2710 { /*304, WINED3DTS_WORLDMATRIX(48) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(48)), transform_worldex },
2711 { /*305, WINED3DTS_WORLDMATRIX(49) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(49)), transform_worldex },
2712 { /*306, WINED3DTS_WORLDMATRIX(50) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(50)), transform_worldex },
2713 { /*307, WINED3DTS_WORLDMATRIX(51) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(51)), transform_worldex },
2714 { /*308, WINED3DTS_WORLDMATRIX(52) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(52)), transform_worldex },
2715 { /*309, WINED3DTS_WORLDMATRIX(53) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(53)), transform_worldex },
2716 { /*310, WINED3DTS_WORLDMATRIX(54) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(54)), transform_worldex },
2717 { /*311, WINED3DTS_WORLDMATRIX(55) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(55)), transform_worldex },
2718 { /*312, WINED3DTS_WORLDMATRIX(56) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(56)), transform_worldex },
2719 { /*313, WINED3DTS_WORLDMATRIX(57) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(57)), transform_worldex },
2720 { /*314, WINED3DTS_WORLDMATRIX(58) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(58)), transform_worldex },
2721 { /*315, WINED3DTS_WORLDMATRIX(59) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(59)), transform_worldex },
2722 { /*316, WINED3DTS_WORLDMATRIX(60) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(60)), transform_worldex },
2723 { /*317, WINED3DTS_WORLDMATRIX(61) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(61)), transform_worldex },
2724 { /*318, WINED3DTS_WORLDMATRIX(62) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(62)), transform_worldex },
2725 { /*319, WINED3DTS_WORLDMATRIX(63) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(63)), transform_worldex },
2726 { /*320, WINED3DTS_WORLDMATRIX(64) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(64)), transform_worldex },
2727 { /*321, WINED3DTS_WORLDMATRIX(65) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(65)), transform_worldex },
2728 { /*322, WINED3DTS_WORLDMATRIX(66) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(66)), transform_worldex },
2729 { /*323, WINED3DTS_WORLDMATRIX(67) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(67)), transform_worldex },
2730 { /*324, WINED3DTS_WORLDMATRIX(68) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(68)), transform_worldex },
2731 { /*325, WINED3DTS_WORLDMATRIX(68) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(69)), transform_worldex },
2732 { /*326, WINED3DTS_WORLDMATRIX(70) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(70)), transform_worldex },
2733 { /*327, WINED3DTS_WORLDMATRIX(71) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(71)), transform_worldex },
2734 { /*328, WINED3DTS_WORLDMATRIX(72) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(72)), transform_worldex },
2735 { /*329, WINED3DTS_WORLDMATRIX(73) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(73)), transform_worldex },
2736 { /*330, WINED3DTS_WORLDMATRIX(74) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(74)), transform_worldex },
2737 { /*331, WINED3DTS_WORLDMATRIX(75) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(75)), transform_worldex },
2738 { /*332, WINED3DTS_WORLDMATRIX(76) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(76)), transform_worldex },
2739 { /*333, WINED3DTS_WORLDMATRIX(77) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(77)), transform_worldex },
2740 { /*334, WINED3DTS_WORLDMATRIX(78) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(78)), transform_worldex },
2741 { /*335, WINED3DTS_WORLDMATRIX(79) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(79)), transform_worldex },
2742 { /*336, WINED3DTS_WORLDMATRIX(80) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(80)), transform_worldex },
2743 { /*337, WINED3DTS_WORLDMATRIX(81) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(81)), transform_worldex },
2744 { /*338, WINED3DTS_WORLDMATRIX(82) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(82)), transform_worldex },
2745 { /*339, WINED3DTS_WORLDMATRIX(83) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(83)), transform_worldex },
2746 { /*340, WINED3DTS_WORLDMATRIX(84) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(84)), transform_worldex },
2747 { /*341, WINED3DTS_WORLDMATRIX(85) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(85)), transform_worldex },
2748 { /*341, WINED3DTS_WORLDMATRIX(86) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(86)), transform_worldex },
2749 { /*343, WINED3DTS_WORLDMATRIX(87) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(87)), transform_worldex },
2750 { /*344, WINED3DTS_WORLDMATRIX(88) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(88)), transform_worldex },
2751 { /*345, WINED3DTS_WORLDMATRIX(89) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(89)), transform_worldex },
2752 { /*346, WINED3DTS_WORLDMATRIX(90) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(90)), transform_worldex },
2753 { /*347, WINED3DTS_WORLDMATRIX(91) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(91)), transform_worldex },
2754 { /*348, WINED3DTS_WORLDMATRIX(92) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(92)), transform_worldex },
2755 { /*349, WINED3DTS_WORLDMATRIX(93) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(93)), transform_worldex },
2756 { /*350, WINED3DTS_WORLDMATRIX(94) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(94)), transform_worldex },
2757 { /*351, WINED3DTS_WORLDMATRIX(95) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(95)), transform_worldex },
2758 { /*352, WINED3DTS_WORLDMATRIX(96) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(96)), transform_worldex },
2759 { /*353, WINED3DTS_WORLDMATRIX(97) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(97)), transform_worldex },
2760 { /*354, WINED3DTS_WORLDMATRIX(98) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(98)), transform_worldex },
2761 { /*355, WINED3DTS_WORLDMATRIX(99) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(99)), transform_worldex },
2762 { /*356, WINED3DTS_WORLDMATRIX(100) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(100)), transform_worldex },
2763 { /*357, WINED3DTS_WORLDMATRIX(101) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(101)), transform_worldex },
2764 { /*358, WINED3DTS_WORLDMATRIX(102) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(102)), transform_worldex },
2765 { /*359, WINED3DTS_WORLDMATRIX(103) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(103)), transform_worldex },
2766 { /*360, WINED3DTS_WORLDMATRIX(104) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(104)), transform_worldex },
2767 { /*361, WINED3DTS_WORLDMATRIX(105) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(105)), transform_worldex },
2768 { /*362, WINED3DTS_WORLDMATRIX(106) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(106)), transform_worldex },
2769 { /*363, WINED3DTS_WORLDMATRIX(107) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(107)), transform_worldex },
2770 { /*364, WINED3DTS_WORLDMATRIX(108) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(108)), transform_worldex },
2771 { /*365, WINED3DTS_WORLDMATRIX(109) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(109)), transform_worldex },
2772 { /*366, WINED3DTS_WORLDMATRIX(110) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(110)), transform_worldex },
2773 { /*367, WINED3DTS_WORLDMATRIX(111) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(111)), transform_worldex },
2774 { /*368, WINED3DTS_WORLDMATRIX(112) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(112)), transform_worldex },
2775 { /*369, WINED3DTS_WORLDMATRIX(113) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(113)), transform_worldex },
2776 { /*370, WINED3DTS_WORLDMATRIX(114) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(114)), transform_worldex },
2777 { /*371, WINED3DTS_WORLDMATRIX(115) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(115)), transform_worldex },
2778 { /*372, WINED3DTS_WORLDMATRIX(116) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(116)), transform_worldex },
2779 { /*373, WINED3DTS_WORLDMATRIX(117) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(117)), transform_worldex },
2780 { /*374, WINED3DTS_WORLDMATRIX(118) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(118)), transform_worldex },
2781 { /*375, WINED3DTS_WORLDMATRIX(119) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(119)), transform_worldex },
2782 { /*376, WINED3DTS_WORLDMATRIX(120) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(120)), transform_worldex },
2783 { /*377, WINED3DTS_WORLDMATRIX(121) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(121)), transform_worldex },
2784 { /*378, WINED3DTS_WORLDMATRIX(122) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(122)), transform_worldex },
2785 { /*379, WINED3DTS_WORLDMATRIX(123) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(123)), transform_worldex },
2786 { /*380, WINED3DTS_WORLDMATRIX(124) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(124)), transform_worldex },
2787 { /*381, WINED3DTS_WORLDMATRIX(125) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(125)), transform_worldex },
2788 { /*382, WINED3DTS_WORLDMATRIX(126) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(126)), transform_worldex },
2789 { /*383, WINED3DTS_WORLDMATRIX(127) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(127)), transform_worldex },
2790 { /*384, WINED3DTS_WORLDMATRIX(128) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(128)), transform_worldex },
2791 { /*385, WINED3DTS_WORLDMATRIX(129) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(129)), transform_worldex },
2792 { /*386, WINED3DTS_WORLDMATRIX(130) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(130)), transform_worldex },
2793 { /*387, WINED3DTS_WORLDMATRIX(131) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(131)), transform_worldex },
2794 { /*388, WINED3DTS_WORLDMATRIX(132) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(132)), transform_worldex },
2795 { /*389, WINED3DTS_WORLDMATRIX(133) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(133)), transform_worldex },
2796 { /*390, WINED3DTS_WORLDMATRIX(134) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(134)), transform_worldex },
2797 { /*391, WINED3DTS_WORLDMATRIX(135) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(135)), transform_worldex },
2798 { /*392, WINED3DTS_WORLDMATRIX(136) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(136)), transform_worldex },
2799 { /*393, WINED3DTS_WORLDMATRIX(137) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(137)), transform_worldex },
2800 { /*394, WINED3DTS_WORLDMATRIX(138) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(138)), transform_worldex },
2801 { /*395, WINED3DTS_WORLDMATRIX(139) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(139)), transform_worldex },
2802 { /*396, WINED3DTS_WORLDMATRIX(140) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(140)), transform_worldex },
2803 { /*397, WINED3DTS_WORLDMATRIX(141) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(141)), transform_worldex },
2804 { /*398, WINED3DTS_WORLDMATRIX(142) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(142)), transform_worldex },
2805 { /*399, WINED3DTS_WORLDMATRIX(143) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(143)), transform_worldex },
2806 { /*400, WINED3DTS_WORLDMATRIX(144) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(144)), transform_worldex },
2807 { /*401, WINED3DTS_WORLDMATRIX(145) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(145)), transform_worldex },
2808 { /*402, WINED3DTS_WORLDMATRIX(146) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(146)), transform_worldex },
2809 { /*403, WINED3DTS_WORLDMATRIX(147) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(147)), transform_worldex },
2810 { /*404, WINED3DTS_WORLDMATRIX(148) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(148)), transform_worldex },
2811 { /*405, WINED3DTS_WORLDMATRIX(149) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(149)), transform_worldex },
2812 { /*406, WINED3DTS_WORLDMATRIX(150) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(150)), transform_worldex },
2813 { /*407, WINED3DTS_WORLDMATRIX(151) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(151)), transform_worldex },
2814 { /*408, WINED3DTS_WORLDMATRIX(152) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(152)), transform_worldex },
2815 { /*409, WINED3DTS_WORLDMATRIX(153) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(153)), transform_worldex },
2816 { /*410, WINED3DTS_WORLDMATRIX(154) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(154)), transform_worldex },
2817 { /*411, WINED3DTS_WORLDMATRIX(155) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(155)), transform_worldex },
2818 { /*412, WINED3DTS_WORLDMATRIX(156) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(156)), transform_worldex },
2819 { /*413, WINED3DTS_WORLDMATRIX(157) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(157)), transform_worldex },
2820 { /*414, WINED3DTS_WORLDMATRIX(158) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(158)), transform_worldex },
2821 { /*415, WINED3DTS_WORLDMATRIX(159) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(159)), transform_worldex },
2822 { /*416, WINED3DTS_WORLDMATRIX(160) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(160)), transform_worldex },
2823 { /*417, WINED3DTS_WORLDMATRIX(161) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(161)), transform_worldex },
2824 { /*418, WINED3DTS_WORLDMATRIX(162) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(162)), transform_worldex },
2825 { /*419, WINED3DTS_WORLDMATRIX(163) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(163)), transform_worldex },
2826 { /*420, WINED3DTS_WORLDMATRIX(164) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(164)), transform_worldex },
2827 { /*421, WINED3DTS_WORLDMATRIX(165) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(165)), transform_worldex },
2828 { /*422, WINED3DTS_WORLDMATRIX(166) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(166)), transform_worldex },
2829 { /*423, WINED3DTS_WORLDMATRIX(167) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(167)), transform_worldex },
2830 { /*424, WINED3DTS_WORLDMATRIX(168) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(168)), transform_worldex },
2831 { /*425, WINED3DTS_WORLDMATRIX(168) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(169)), transform_worldex },
2832 { /*426, WINED3DTS_WORLDMATRIX(170) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(170)), transform_worldex },
2833 { /*427, WINED3DTS_WORLDMATRIX(171) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(171)), transform_worldex },
2834 { /*428, WINED3DTS_WORLDMATRIX(172) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(172)), transform_worldex },
2835 { /*429, WINED3DTS_WORLDMATRIX(173) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(173)), transform_worldex },
2836 { /*430, WINED3DTS_WORLDMATRIX(174) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(174)), transform_worldex },
2837 { /*431, WINED3DTS_WORLDMATRIX(175) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(175)), transform_worldex },
2838 { /*432, WINED3DTS_WORLDMATRIX(176) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(176)), transform_worldex },
2839 { /*433, WINED3DTS_WORLDMATRIX(177) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(177)), transform_worldex },
2840 { /*434, WINED3DTS_WORLDMATRIX(178) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(178)), transform_worldex },
2841 { /*435, WINED3DTS_WORLDMATRIX(179) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(179)), transform_worldex },
2842 { /*436, WINED3DTS_WORLDMATRIX(180) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(180)), transform_worldex },
2843 { /*437, WINED3DTS_WORLDMATRIX(181) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(181)), transform_worldex },
2844 { /*438, WINED3DTS_WORLDMATRIX(182) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(182)), transform_worldex },
2845 { /*439, WINED3DTS_WORLDMATRIX(183) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(183)), transform_worldex },
2846 { /*440, WINED3DTS_WORLDMATRIX(184) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(184)), transform_worldex },
2847 { /*441, WINED3DTS_WORLDMATRIX(185) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(185)), transform_worldex },
2848 { /*441, WINED3DTS_WORLDMATRIX(186) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(186)), transform_worldex },
2849 { /*443, WINED3DTS_WORLDMATRIX(187) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(187)), transform_worldex },
2850 { /*444, WINED3DTS_WORLDMATRIX(188) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(188)), transform_worldex },
2851 { /*445, WINED3DTS_WORLDMATRIX(189) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(189)), transform_worldex },
2852 { /*446, WINED3DTS_WORLDMATRIX(190) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(190)), transform_worldex },
2853 { /*447, WINED3DTS_WORLDMATRIX(191) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(191)), transform_worldex },
2854 { /*448, WINED3DTS_WORLDMATRIX(192) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(192)), transform_worldex },
2855 { /*449, WINED3DTS_WORLDMATRIX(193) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(193)), transform_worldex },
2856 { /*450, WINED3DTS_WORLDMATRIX(194) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(194)), transform_worldex },
2857 { /*451, WINED3DTS_WORLDMATRIX(195) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(195)), transform_worldex },
2858 { /*452, WINED3DTS_WORLDMATRIX(196) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(196)), transform_worldex },
2859 { /*453, WINED3DTS_WORLDMATRIX(197) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(197)), transform_worldex },
2860 { /*454, WINED3DTS_WORLDMATRIX(198) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(198)), transform_worldex },
2861 { /*455, WINED3DTS_WORLDMATRIX(199) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(199)), transform_worldex },
2862 { /*356, WINED3DTS_WORLDMATRIX(200) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(200)), transform_worldex },
2863 { /*457, WINED3DTS_WORLDMATRIX(201) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(201)), transform_worldex },
2864 { /*458, WINED3DTS_WORLDMATRIX(202) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(202)), transform_worldex },
2865 { /*459, WINED3DTS_WORLDMATRIX(203) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(203)), transform_worldex },
2866 { /*460, WINED3DTS_WORLDMATRIX(204) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(204)), transform_worldex },
2867 { /*461, WINED3DTS_WORLDMATRIX(205) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(205)), transform_worldex },
2868 { /*462, WINED3DTS_WORLDMATRIX(206) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(206)), transform_worldex },
2869 { /*463, WINED3DTS_WORLDMATRIX(207) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(207)), transform_worldex },
2870 { /*464, WINED3DTS_WORLDMATRIX(208) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(208)), transform_worldex },
2871 { /*465, WINED3DTS_WORLDMATRIX(209) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(209)), transform_worldex },
2872 { /*466, WINED3DTS_WORLDMATRIX(210) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(210)), transform_worldex },
2873 { /*467, WINED3DTS_WORLDMATRIX(211) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(211)), transform_worldex },
2874 { /*468, WINED3DTS_WORLDMATRIX(212) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(212)), transform_worldex },
2875 { /*469, WINED3DTS_WORLDMATRIX(213) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(213)), transform_worldex },
2876 { /*470, WINED3DTS_WORLDMATRIX(214) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(214)), transform_worldex },
2877 { /*471, WINED3DTS_WORLDMATRIX(215) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(215)), transform_worldex },
2878 { /*472, WINED3DTS_WORLDMATRIX(216) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(216)), transform_worldex },
2879 { /*473, WINED3DTS_WORLDMATRIX(217) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(217)), transform_worldex },
2880 { /*474, WINED3DTS_WORLDMATRIX(218) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(218)), transform_worldex },
2881 { /*475, WINED3DTS_WORLDMATRIX(219) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(219)), transform_worldex },
2882 { /*476, WINED3DTS_WORLDMATRIX(220) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(220)), transform_worldex },
2883 { /*477, WINED3DTS_WORLDMATRIX(221) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(221)), transform_worldex },
2884 { /*478, WINED3DTS_WORLDMATRIX(222) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(222)), transform_worldex },
2885 { /*479, WINED3DTS_WORLDMATRIX(223) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(223)), transform_worldex },
2886 { /*480, WINED3DTS_WORLDMATRIX(224) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(224)), transform_worldex },
2887 { /*481, WINED3DTS_WORLDMATRIX(225) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(225)), transform_worldex },
2888 { /*482, WINED3DTS_WORLDMATRIX(226) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(226)), transform_worldex },
2889 { /*483, WINED3DTS_WORLDMATRIX(227) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(227)), transform_worldex },
2890 { /*484, WINED3DTS_WORLDMATRIX(228) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(228)), transform_worldex },
2891 { /*485, WINED3DTS_WORLDMATRIX(229) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(229)), transform_worldex },
2892 { /*486, WINED3DTS_WORLDMATRIX(230) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(230)), transform_worldex },
2893 { /*487, WINED3DTS_WORLDMATRIX(231) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(231)), transform_worldex },
2894 { /*488, WINED3DTS_WORLDMATRIX(232) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(232)), transform_worldex },
2895 { /*489, WINED3DTS_WORLDMATRIX(233) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(233)), transform_worldex },
2896 { /*490, WINED3DTS_WORLDMATRIX(234) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(234)), transform_worldex },
2897 { /*491, WINED3DTS_WORLDMATRIX(235) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(235)), transform_worldex },
2898 { /*492, WINED3DTS_WORLDMATRIX(236) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(236)), transform_worldex },
2899 { /*493, WINED3DTS_WORLDMATRIX(237) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(237)), transform_worldex },
2900 { /*494, WINED3DTS_WORLDMATRIX(238) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(238)), transform_worldex },
2901 { /*495, WINED3DTS_WORLDMATRIX(239) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(239)), transform_worldex },
2902 { /*496, WINED3DTS_WORLDMATRIX(240) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(240)), transform_worldex },
2903 { /*497, WINED3DTS_WORLDMATRIX(241) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(241)), transform_worldex },
2904 { /*498, WINED3DTS_WORLDMATRIX(242) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(242)), transform_worldex },
2905 { /*499, WINED3DTS_WORLDMATRIX(243) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(243)), transform_worldex },
2906 { /*500, WINED3DTS_WORLDMATRIX(244) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(244)), transform_worldex },
2907 { /*501, WINED3DTS_WORLDMATRIX(245) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(245)), transform_worldex },
2908 { /*502, WINED3DTS_WORLDMATRIX(246) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(246)), transform_worldex },
2909 { /*503, WINED3DTS_WORLDMATRIX(247) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(247)), transform_worldex },
2910 { /*504, WINED3DTS_WORLDMATRIX(248) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(248)), transform_worldex },
2911 { /*505, WINED3DTS_WORLDMATRIX(249) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(249)), transform_worldex },
2912 { /*506, WINED3DTS_WORLDMATRIX(250) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(250)), transform_worldex },
2913 { /*507, WINED3DTS_WORLDMATRIX(251) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(251)), transform_worldex },
2914 { /*508, WINED3DTS_WORLDMATRIX(252) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(252)), transform_worldex },
2915 { /*509, WINED3DTS_WORLDMATRIX(253) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(253)), transform_worldex },
2916 { /*510, WINED3DTS_WORLDMATRIX(254) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(254)), transform_worldex },
2917 { /*511, WINED3DTS_WORLDMATRIX(255) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(255)), transform_worldex },
2918 /* Various Vertex states follow */
2919 { /* , STATE_STREAMSRC */ STATE_VDECL, vertexdeclaration },
2920 { /* , STATE_VDECL */ STATE_VDECL, vertexdeclaration },
2921 { /* , STATE_VSHADER */ STATE_VDECL, vertexdeclaration },
2922 { /* , STATE_VIEWPORT */ STATE_VDECL, vertexdeclaration },