2 * Direct3D state management
4 * Copyright 2002 Lionel Ulmer
5 * Copyright 2002-2005 Jason Edmeades
6 * Copyright 2003-2004 Raphael Junqueira
7 * Copyright 2004 Christian Costa
8 * Copyright 2005 Oliver Stieber
9 * Copyright 2006 Henri Verbeet
10 * Copyright 2006-2007 Stefan Dösinger for CodeWeavers
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
32 #include "wined3d_private.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
35 WINE_DECLARE_DEBUG_CHANNEL(d3d_shader);
37 #define GLINFO_LOCATION ((IWineD3DImpl *)(stateblock->wineD3DDevice->wineD3D))->gl_info
39 static void state_nogl(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
40 /* Used for states which are not mapped to a gl state as-is, but used somehow different,
41 * e.g as a parameter for drawing, or which are unimplemented in windows d3d
43 if(STATE_IS_RENDER(state)) {
44 WINED3DRENDERSTATETYPE RenderState = state - STATE_RENDER(0);
45 TRACE("(%s,%d) no direct mapping to gl\n", debug_d3drenderstate(RenderState), stateblock->renderState[RenderState]);
47 /* Shouldn't have an unknown type here */
48 FIXME("%d no direct mapping to gl of state with unknown type\n", state);
52 static void state_undefined(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
53 /* Print a WARN, this allows the stateblock code to loop over all states to generate a display
54 * list without causing confusing terminal output. Deliberately no special debug name here
55 * because its undefined.
57 WARN("undefined state %d\n", state);
60 static void state_fillmode(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
61 D3DFILLMODE Value = stateblock->renderState[WINED3DRS_FILLMODE];
65 glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
66 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_POINT)");
68 case D3DFILL_WIREFRAME:
69 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
70 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)");
73 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
74 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)");
77 FIXME("Unrecognized WINED3DRS_FILLMODE value %d\n", Value);
81 static void state_lighting(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
84 /* Lighting is only enabled if Vertex normals are passed by the application,
85 * but lighting does not affect the stream sources, so it is not grouped for performance reasons.
86 * This state reads the decoded vertex decl, so if it is dirty don't do anything. The
87 * vertex declaration appplying function calls this function for updating
90 if(isStateDirty(context, STATE_VDECL)) {
94 normals = stateblock->wineD3DDevice->strided_streams.u.s.normal.lpData != NULL ||
95 stateblock->wineD3DDevice->strided_streams.u.s.normal.VBO != 0;
97 if (stateblock->renderState[WINED3DRS_LIGHTING] && normals) {
98 glEnable(GL_LIGHTING);
99 checkGLcall("glEnable GL_LIGHTING");
101 glDisable(GL_LIGHTING);
102 checkGLcall("glDisable GL_LIGHTING");
106 static void state_zenable(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
107 switch ((WINED3DZBUFFERTYPE) stateblock->renderState[WINED3DRS_ZENABLE]) {
108 case WINED3DZB_FALSE:
109 glDisable(GL_DEPTH_TEST);
110 checkGLcall("glDisable GL_DEPTH_TEST");
113 glEnable(GL_DEPTH_TEST);
114 checkGLcall("glEnable GL_DEPTH_TEST");
117 glEnable(GL_DEPTH_TEST);
118 checkGLcall("glEnable GL_DEPTH_TEST");
119 FIXME("W buffer is not well handled\n");
122 FIXME("Unrecognized D3DZBUFFERTYPE value %d\n", stateblock->renderState[WINED3DRS_ZENABLE]);
126 static void state_cullmode(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
127 /* TODO: Put this into the offscreen / onscreen rendering block due to device->render_offscreen */
129 /* If we are culling "back faces with clockwise vertices" then
130 set front faces to be counter clockwise and enable culling
132 switch ((WINED3DCULL) stateblock->renderState[WINED3DRS_CULLMODE]) {
133 case WINED3DCULL_NONE:
134 glDisable(GL_CULL_FACE);
135 checkGLcall("glDisable GL_CULL_FACE");
138 glEnable(GL_CULL_FACE);
139 checkGLcall("glEnable GL_CULL_FACE");
140 if (stateblock->wineD3DDevice->render_offscreen) {
142 checkGLcall("glFrontFace GL_CW");
145 checkGLcall("glFrontFace GL_CCW");
149 case WINED3DCULL_CCW:
150 glEnable(GL_CULL_FACE);
151 checkGLcall("glEnable GL_CULL_FACE");
152 if (stateblock->wineD3DDevice->render_offscreen) {
154 checkGLcall("glFrontFace GL_CCW");
157 checkGLcall("glFrontFace GL_CW");
162 FIXME("Unrecognized/Unhandled WINED3DCULL value %d\n", stateblock->renderState[WINED3DRS_CULLMODE]);
166 static void state_shademode(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
167 switch ((WINED3DSHADEMODE) stateblock->renderState[WINED3DRS_SHADEMODE]) {
168 case WINED3DSHADE_FLAT:
169 glShadeModel(GL_FLAT);
170 checkGLcall("glShadeModel(GL_FLAT)");
172 case WINED3DSHADE_GOURAUD:
173 glShadeModel(GL_SMOOTH);
174 checkGLcall("glShadeModel(GL_SMOOTH)");
176 case WINED3DSHADE_PHONG:
177 FIXME("WINED3DSHADE_PHONG isn't supported\n");
180 FIXME("Unrecognized/Unhandled WINED3DSHADEMODE value %d\n", stateblock->renderState[WINED3DRS_SHADEMODE]);
184 static void state_ditherenable(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
185 if (stateblock->renderState[WINED3DRS_DITHERENABLE]) {
187 checkGLcall("glEnable GL_DITHER");
189 glDisable(GL_DITHER);
190 checkGLcall("glDisable GL_DITHER");
194 static void state_zwritenable(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
195 /* TODO: Test if in d3d z writing is enabled even if ZENABLE is off. If yes,
196 * this has to be merged with ZENABLE and ZFUNC
198 if (stateblock->renderState[WINED3DRS_ZWRITEENABLE]) {
200 checkGLcall("glDepthMask(1)");
203 checkGLcall("glDepthMask(0)");
207 static void state_zfunc(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
208 int glParm = CompareFunc(stateblock->renderState[WINED3DRS_ZFUNC]);
212 checkGLcall("glDepthFunc");
216 static void state_ambient(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
218 D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_AMBIENT], col);
220 TRACE("Setting ambient to (%f,%f,%f,%f)\n", col[0], col[1], col[2], col[3]);
221 glLightModelfv(GL_LIGHT_MODEL_AMBIENT, col);
222 checkGLcall("glLightModel for MODEL_AMBIENT");
225 static void state_blend(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
226 int srcBlend = GL_ZERO;
227 int dstBlend = GL_ZERO;
229 /* GL_LINE_SMOOTH needs GL_BLEND to work, according to the red book, and special blending params */
230 if (stateblock->renderState[WINED3DRS_ALPHABLENDENABLE] ||
231 stateblock->renderState[WINED3DRS_EDGEANTIALIAS] ||
232 stateblock->renderState[WINED3DRS_ANTIALIASEDLINEENABLE]) {
234 checkGLcall("glEnable GL_BLEND");
237 checkGLcall("glDisable GL_BLEND");
238 /* Nothing more to do - get out */
242 switch (stateblock->renderState[WINED3DRS_SRCBLEND]) {
243 case WINED3DBLEND_ZERO : srcBlend = GL_ZERO; break;
244 case WINED3DBLEND_ONE : srcBlend = GL_ONE; break;
245 case WINED3DBLEND_SRCCOLOR : srcBlend = GL_SRC_COLOR; break;
246 case WINED3DBLEND_INVSRCCOLOR : srcBlend = GL_ONE_MINUS_SRC_COLOR; break;
247 case WINED3DBLEND_SRCALPHA : srcBlend = GL_SRC_ALPHA; break;
248 case WINED3DBLEND_INVSRCALPHA : srcBlend = GL_ONE_MINUS_SRC_ALPHA; break;
249 case WINED3DBLEND_DESTALPHA : srcBlend = GL_DST_ALPHA; break;
250 case WINED3DBLEND_INVDESTALPHA : srcBlend = GL_ONE_MINUS_DST_ALPHA; break;
251 case WINED3DBLEND_DESTCOLOR : srcBlend = GL_DST_COLOR; break;
252 case WINED3DBLEND_INVDESTCOLOR : srcBlend = GL_ONE_MINUS_DST_COLOR; break;
253 case WINED3DBLEND_SRCALPHASAT : srcBlend = GL_SRC_ALPHA_SATURATE; break;
255 case WINED3DBLEND_BOTHSRCALPHA : srcBlend = GL_SRC_ALPHA;
256 dstBlend = GL_SRC_ALPHA;
259 case WINED3DBLEND_BOTHINVSRCALPHA : srcBlend = GL_ONE_MINUS_SRC_ALPHA;
260 dstBlend = GL_ONE_MINUS_SRC_ALPHA;
263 case WINED3DBLEND_BLENDFACTOR : srcBlend = GL_CONSTANT_COLOR; break;
264 case WINED3DBLEND_INVBLENDFACTOR : srcBlend = GL_ONE_MINUS_CONSTANT_COLOR; break;
266 FIXME("Unrecognized src blend value %d\n", stateblock->renderState[WINED3DRS_SRCBLEND]);
269 switch (stateblock->renderState[WINED3DRS_DESTBLEND]) {
270 case WINED3DBLEND_ZERO : dstBlend = GL_ZERO; break;
271 case WINED3DBLEND_ONE : dstBlend = GL_ONE; break;
272 case WINED3DBLEND_SRCCOLOR : dstBlend = GL_SRC_COLOR; break;
273 case WINED3DBLEND_INVSRCCOLOR : dstBlend = GL_ONE_MINUS_SRC_COLOR; break;
274 case WINED3DBLEND_SRCALPHA : dstBlend = GL_SRC_ALPHA; break;
275 case WINED3DBLEND_INVSRCALPHA : dstBlend = GL_ONE_MINUS_SRC_ALPHA; break;
276 case WINED3DBLEND_DESTALPHA : dstBlend = GL_DST_ALPHA; break;
277 case WINED3DBLEND_INVDESTALPHA : dstBlend = GL_ONE_MINUS_DST_ALPHA; break;
278 case WINED3DBLEND_DESTCOLOR : dstBlend = GL_DST_COLOR; break;
279 case WINED3DBLEND_INVDESTCOLOR : dstBlend = GL_ONE_MINUS_DST_COLOR; break;
280 case WINED3DBLEND_SRCALPHASAT : dstBlend = GL_SRC_ALPHA_SATURATE; break;
282 case WINED3DBLEND_BOTHSRCALPHA : dstBlend = GL_SRC_ALPHA;
283 srcBlend = GL_SRC_ALPHA;
286 case WINED3DBLEND_BOTHINVSRCALPHA : dstBlend = GL_ONE_MINUS_SRC_ALPHA;
287 srcBlend = GL_ONE_MINUS_SRC_ALPHA;
290 case D3DBLEND_BLENDFACTOR : dstBlend = GL_CONSTANT_COLOR; break;
291 case D3DBLEND_INVBLENDFACTOR : dstBlend = GL_ONE_MINUS_CONSTANT_COLOR; break;
293 FIXME("Unrecognized dst blend value %d\n", stateblock->renderState[WINED3DRS_DESTBLEND]);
296 if(stateblock->renderState[WINED3DRS_EDGEANTIALIAS] ||
297 stateblock->renderState[WINED3DRS_ANTIALIASEDLINEENABLE]) {
298 glEnable(GL_LINE_SMOOTH);
299 checkGLcall("glEnable(GL_LINE_SMOOTH)");
300 if(srcBlend != GL_SRC_ALPHA) {
301 FIXME("WINED3DRS_EDGEANTIALIAS enabled, but incompatible src blending param - what to do?\n");
302 srcBlend = GL_SRC_ALPHA;
304 if(dstBlend != GL_ONE_MINUS_SRC_ALPHA) {
305 FIXME("WINED3DRS_EDGEANTIALIAS enabled, but incompatible dst blending param - what to do?\n");
306 dstBlend = GL_ONE_MINUS_SRC_ALPHA;
309 glDisable(GL_LINE_SMOOTH);
310 checkGLcall("glDisable(GL_LINE_SMOOTH)");
313 TRACE("glBlendFunc src=%x, dst=%x\n", srcBlend, dstBlend);
314 glBlendFunc(srcBlend, dstBlend);
315 checkGLcall("glBlendFunc");
318 static void state_blendfactor(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
321 TRACE("Setting BlendFactor to %d\n", stateblock->renderState[WINED3DRS_BLENDFACTOR]);
322 D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_BLENDFACTOR], col);
323 glBlendColor (col[0],col[1],col[2],col[3]);
324 checkGLcall("glBlendColor");
327 static void state_alpha(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
330 BOOL enable_ckey = FALSE;
332 IWineD3DSurfaceImpl *surf;
334 /* Find out if the texture on the first stage has a ckey set
335 * The alpha state func reads the texture settings, even though alpha and texture are not grouped
336 * together. This is to avoid making a huge alpha+texture+texture stage+ckey block due to the hardly
337 * used WINED3DRS_COLORKEYENABLE state(which is d3d <= 3 only). The texture function will call alpha
338 * in case it finds some texture+colorkeyenable combination which needs extra care.
340 if(stateblock->textures[0]) {
341 surf = (IWineD3DSurfaceImpl *) ((IWineD3DTextureImpl *)stateblock->textures[0])->surfaces[0];
342 if(surf->CKeyFlags & DDSD_CKSRCBLT) enable_ckey = TRUE;
345 if (stateblock->renderState[WINED3DRS_ALPHATESTENABLE] ||
346 (stateblock->renderState[WINED3DRS_COLORKEYENABLE] && enable_ckey)) {
347 glEnable(GL_ALPHA_TEST);
348 checkGLcall("glEnable GL_ALPHA_TEST");
350 glDisable(GL_ALPHA_TEST);
351 checkGLcall("glDisable GL_ALPHA_TEST");
352 /* Alpha test is disabled, don't bother setting the params - it will happen on the next
358 if(stateblock->renderState[WINED3DRS_COLORKEYENABLE] && enable_ckey) {
359 glParm = GL_NOTEQUAL;
362 ref = ((float) stateblock->renderState[WINED3DRS_ALPHAREF]) / 255.0f;
363 glParm = CompareFunc(stateblock->renderState[WINED3DRS_ALPHAFUNC]);
366 glAlphaFunc(glParm, ref);
367 checkGLcall("glAlphaFunc");
369 /* TODO: Some texture blending operations seem to affect the alpha test */
372 static void state_clipping(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
373 DWORD enable = 0xFFFFFFFF;
374 DWORD disable = 0x00000000;
376 /* TODO: Keep track of previously enabled clipplanes to avoid unneccessary resetting
377 * of already set values
380 /* If enabling / disabling all
381 * TODO: Is this correct? Doesn't D3DRS_CLIPPING disable clipping on the viewport frustrum?
383 if (stateblock->renderState[WINED3DRS_CLIPPING]) {
384 enable = stateblock->renderState[WINED3DRS_CLIPPLANEENABLE];
385 disable = ~stateblock->renderState[WINED3DRS_CLIPPLANEENABLE];
387 disable = 0xffffffff;
391 if (enable & WINED3DCLIPPLANE0) { glEnable(GL_CLIP_PLANE0); checkGLcall("glEnable(clip plane 0)"); }
392 if (enable & WINED3DCLIPPLANE1) { glEnable(GL_CLIP_PLANE1); checkGLcall("glEnable(clip plane 1)"); }
393 if (enable & WINED3DCLIPPLANE2) { glEnable(GL_CLIP_PLANE2); checkGLcall("glEnable(clip plane 2)"); }
394 if (enable & WINED3DCLIPPLANE3) { glEnable(GL_CLIP_PLANE3); checkGLcall("glEnable(clip plane 3)"); }
395 if (enable & WINED3DCLIPPLANE4) { glEnable(GL_CLIP_PLANE4); checkGLcall("glEnable(clip plane 4)"); }
396 if (enable & WINED3DCLIPPLANE5) { glEnable(GL_CLIP_PLANE5); checkGLcall("glEnable(clip plane 5)"); }
398 if (disable & WINED3DCLIPPLANE0) { glDisable(GL_CLIP_PLANE0); checkGLcall("glDisable(clip plane 0)"); }
399 if (disable & WINED3DCLIPPLANE1) { glDisable(GL_CLIP_PLANE1); checkGLcall("glDisable(clip plane 1)"); }
400 if (disable & WINED3DCLIPPLANE2) { glDisable(GL_CLIP_PLANE2); checkGLcall("glDisable(clip plane 2)"); }
401 if (disable & WINED3DCLIPPLANE3) { glDisable(GL_CLIP_PLANE3); checkGLcall("glDisable(clip plane 3)"); }
402 if (disable & WINED3DCLIPPLANE4) { glDisable(GL_CLIP_PLANE4); checkGLcall("glDisable(clip plane 4)"); }
403 if (disable & WINED3DCLIPPLANE5) { glDisable(GL_CLIP_PLANE5); checkGLcall("glDisable(clip plane 5)"); }
405 /** update clipping status */
407 stateblock->clip_status.ClipUnion = 0;
408 stateblock->clip_status.ClipIntersection = 0xFFFFFFFF;
410 stateblock->clip_status.ClipUnion = 0;
411 stateblock->clip_status.ClipIntersection = 0;
415 static void state_blendop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
416 int glParm = GL_FUNC_ADD;
418 if(!GL_SUPPORT(EXT_BLEND_MINMAX)) {
419 WARN("Unsupported in local OpenGL implementation: glBlendEquation\n");
423 switch ((WINED3DBLENDOP) stateblock->renderState[WINED3DRS_BLENDOP]) {
424 case WINED3DBLENDOP_ADD : glParm = GL_FUNC_ADD; break;
425 case WINED3DBLENDOP_SUBTRACT : glParm = GL_FUNC_SUBTRACT; break;
426 case WINED3DBLENDOP_REVSUBTRACT : glParm = GL_FUNC_REVERSE_SUBTRACT; break;
427 case WINED3DBLENDOP_MIN : glParm = GL_MIN; break;
428 case WINED3DBLENDOP_MAX : glParm = GL_MAX; break;
430 FIXME("Unrecognized/Unhandled D3DBLENDOP value %d\n", stateblock->renderState[WINED3DRS_BLENDOP]);
433 TRACE("glBlendEquation(%x)\n", glParm);
434 GL_EXTCALL(glBlendEquation(glParm));
435 checkGLcall("glBlendEquation");
439 state_specularenable(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
440 /* Originally this used glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR)
441 * and (GL_LIGHT_MODEL_COLOR_CONTROL,GL_SINGLE_COLOR) to swap between enabled/disabled
442 * specular color. This is wrong:
443 * Separate specular color means the specular colour is maintained separately, whereas
444 * single color means it is merged in. However in both cases they are being used to
446 * To disable specular color, set it explicitly to black and turn off GL_COLOR_SUM_EXT
447 * NOTE: If not supported don't give FIXMEs the impact is really minimal and very few people are
451 * If register combiners are enabled, enabling / disabling GL_COLOR_SUM has no effect.
452 * Instead, we need to setup the FinalCombiner properly.
454 * The default setup for the FinalCombiner is:
456 * <variable> <input> <mapping> <usage>
457 * GL_VARIABLE_A_NV GL_FOG, GL_UNSIGNED_IDENTITY_NV GL_ALPHA
458 * GL_VARIABLE_B_NV GL_SPARE0_PLUS_SECONDARY_COLOR_NV GL_UNSIGNED_IDENTITY_NV GL_RGB
459 * GL_VARIABLE_C_NV GL_FOG GL_UNSIGNED_IDENTITY_NV GL_RGB
460 * GL_VARIABLE_D_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
461 * GL_VARIABLE_E_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
462 * GL_VARIABLE_F_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
463 * GL_VARIABLE_G_NV GL_SPARE0_NV GL_UNSIGNED_IDENTITY_NV GL_ALPHA
465 * That's pretty much fine as it is, except for variable B, which needs to take
466 * either GL_SPARE0_PLUS_SECONDARY_COLOR_NV or GL_SPARE0_NV, depending on
467 * whether WINED3DRS_SPECULARENABLE is enabled or not.
470 TRACE("Setting specular enable state\n");
471 /* TODO: Add to the material setting functions */
472 if (stateblock->renderState[WINED3DRS_SPECULARENABLE]) {
473 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float*) &stateblock->material.Specular);
474 checkGLcall("glMaterialfv");
475 if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
476 glEnable(GL_COLOR_SUM_EXT);
478 TRACE("Specular colors cannot be enabled in this version of opengl\n");
480 checkGLcall("glEnable(GL_COLOR_SUM)");
482 if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
483 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_SPARE0_PLUS_SECONDARY_COLOR_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB));
484 checkGLcall("glFinalCombinerInputNV()");
487 float black[4] = {0.0f, 0.0f, 0.0f, 0.0f};
489 /* for the case of enabled lighting: */
490 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, &black[0]);
491 checkGLcall("glMaterialfv");
493 /* for the case of disabled lighting: */
494 if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
495 glDisable(GL_COLOR_SUM_EXT);
497 TRACE("Specular colors cannot be disabled in this version of opengl\n");
499 checkGLcall("glDisable(GL_COLOR_SUM)");
501 if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
502 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB));
503 checkGLcall("glFinalCombinerInputNV()");
508 static void state_texfactor(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
511 /* Note the texture color applies to all textures whereas
512 * GL_TEXTURE_ENV_COLOR applies to active only
515 D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_TEXTUREFACTOR], col);
517 if (!GL_SUPPORT(NV_REGISTER_COMBINERS)) {
518 /* And now the default texture color as well */
519 for (i = 0; i < GL_LIMITS(texture_stages); i++) {
520 /* Note the WINED3DRS value applies to all textures, but GL has one
521 * per texture, so apply it now ready to be used!
523 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
524 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + i));
525 checkGLcall("glActiveTextureARB");
527 FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
530 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &col[0]);
531 checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);");
534 GL_EXTCALL(glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV, &col[0]));
539 renderstate_stencil_twosided(IWineD3DStateBlockImpl *stateblock, GLint face, GLint func, GLint ref, GLuint mask, GLint stencilFail, GLint depthFail, GLint stencilPass ) {
540 #if 0 /* Don't use OpenGL 2.0 calls for now */
541 if(GL_EXTCALL(glStencilFuncSeparate) && GL_EXTCALL(glStencilOpSeparate)) {
542 GL_EXTCALL(glStencilFuncSeparate(face, func, ref, mask));
543 checkGLcall("glStencilFuncSeparate(...)");
544 GL_EXTCALL(glStencilOpSeparate(face, stencilFail, depthFail, stencilPass));
545 checkGLcall("glStencilOpSeparate(...)");
549 if(GL_SUPPORT(EXT_STENCIL_TWO_SIDE)) {
550 glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT);
551 checkGLcall("glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT)");
552 GL_EXTCALL(glActiveStencilFaceEXT(face));
553 checkGLcall("glActiveStencilFaceEXT(...)");
554 glStencilFunc(func, ref, mask);
555 checkGLcall("glStencilFunc(...)");
556 glStencilOp(stencilFail, depthFail, stencilPass);
557 checkGLcall("glStencilOp(...)");
558 } else if(GL_SUPPORT(ATI_SEPARATE_STENCIL)) {
559 GL_EXTCALL(glStencilFuncSeparateATI(face, func, ref, mask));
560 checkGLcall("glStencilFuncSeparateATI(...)");
561 GL_EXTCALL(glStencilOpSeparateATI(face, stencilFail, depthFail, stencilPass));
562 checkGLcall("glStencilOpSeparateATI(...)");
564 ERR("Separate (two sided) stencil not supported on this version of opengl. Caps weren't honored?\n");
569 state_stencil(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
570 DWORD onesided_enable = FALSE;
571 DWORD twosided_enable = FALSE;
572 GLint func = GL_ALWAYS;
573 GLint func_ccw = GL_ALWAYS;
576 GLint stencilFail = GL_KEEP;
577 GLint depthFail = GL_KEEP;
578 GLint stencilPass = GL_KEEP;
579 GLint stencilFail_ccw = GL_KEEP;
580 GLint depthFail_ccw = GL_KEEP;
581 GLint stencilPass_ccw = GL_KEEP;
583 if( stateblock->set.renderState[WINED3DRS_STENCILENABLE] )
584 onesided_enable = stateblock->renderState[WINED3DRS_STENCILENABLE];
585 if( stateblock->set.renderState[WINED3DRS_TWOSIDEDSTENCILMODE] )
586 twosided_enable = stateblock->renderState[WINED3DRS_TWOSIDEDSTENCILMODE];
587 if( stateblock->set.renderState[WINED3DRS_STENCILFUNC] )
588 if( !( func = CompareFunc(stateblock->renderState[WINED3DRS_STENCILFUNC]) ) )
590 if( stateblock->set.renderState[WINED3DRS_CCW_STENCILFUNC] )
591 if( !( func_ccw = CompareFunc(stateblock->renderState[WINED3DRS_CCW_STENCILFUNC]) ) )
593 if( stateblock->set.renderState[WINED3DRS_STENCILREF] )
594 ref = stateblock->renderState[WINED3DRS_STENCILREF];
595 if( stateblock->set.renderState[WINED3DRS_STENCILMASK] )
596 mask = stateblock->renderState[WINED3DRS_STENCILMASK];
597 if( stateblock->set.renderState[WINED3DRS_STENCILFAIL] )
598 stencilFail = StencilOp(stateblock->renderState[WINED3DRS_STENCILFAIL]);
599 if( stateblock->set.renderState[WINED3DRS_STENCILZFAIL] )
600 depthFail = StencilOp(stateblock->renderState[WINED3DRS_STENCILZFAIL]);
601 if( stateblock->set.renderState[WINED3DRS_STENCILPASS] )
602 stencilPass = StencilOp(stateblock->renderState[WINED3DRS_STENCILPASS]);
603 if( stateblock->set.renderState[WINED3DRS_CCW_STENCILFAIL] )
604 stencilFail_ccw = StencilOp(stateblock->renderState[WINED3DRS_CCW_STENCILFAIL]);
605 if( stateblock->set.renderState[WINED3DRS_CCW_STENCILZFAIL] )
606 depthFail_ccw = StencilOp(stateblock->renderState[WINED3DRS_CCW_STENCILZFAIL]);
607 if( stateblock->set.renderState[WINED3DRS_CCW_STENCILPASS] )
608 stencilPass_ccw = StencilOp(stateblock->renderState[WINED3DRS_CCW_STENCILPASS]);
610 TRACE("(onesided %d, twosided %d, ref %x, mask %x, "
611 "GL_FRONT: func: %x, fail %x, zfail %x, zpass %x "
612 "GL_BACK: func: %x, fail %x, zfail %x, zpass %x )\n",
613 onesided_enable, twosided_enable, ref, mask,
614 func, stencilFail, depthFail, stencilPass,
615 func_ccw, stencilFail_ccw, depthFail_ccw, stencilPass_ccw);
617 if (twosided_enable) {
618 renderstate_stencil_twosided(stateblock, GL_FRONT, func, ref, mask, stencilFail, depthFail, stencilPass);
619 renderstate_stencil_twosided(stateblock, GL_BACK, func_ccw, ref, mask, stencilFail_ccw, depthFail_ccw, stencilPass_ccw);
621 if (onesided_enable) {
622 glEnable(GL_STENCIL_TEST);
623 checkGLcall("glEnable GL_STENCIL_TEST");
624 glStencilFunc(func, ref, mask);
625 checkGLcall("glStencilFunc(...)");
626 glStencilOp(stencilFail, depthFail, stencilPass);
627 checkGLcall("glStencilOp(...)");
629 glDisable(GL_STENCIL_TEST);
630 checkGLcall("glDisable GL_STENCIL_TEST");
635 static void state_stencilwrite(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
636 glStencilMask(stateblock->renderState[WINED3DRS_STENCILWRITEMASK]);
637 checkGLcall("glStencilMask");
640 static void state_fog(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
641 /* TODO: Put this into the vertex type block once that is in the state table */
642 BOOL fogenable = stateblock->renderState[WINED3DRS_FOGENABLE];
643 float fogstart, fogend;
651 /* No fog? Disable it, and we're done :-) */
653 checkGLcall("glDisable GL_FOG");
656 tmpvalue.d = stateblock->renderState[WINED3DRS_FOGSTART];
657 fogstart = tmpvalue.f;
658 tmpvalue.d = stateblock->renderState[WINED3DRS_FOGEND];
661 /* Activate when vertex shaders are in the state table */
662 if(stateblock->vertexShader && ((IWineD3DVertexShaderImpl *)stateblock->vertexShader)->baseShader.function &&
663 ((IWineD3DVertexShaderImpl *)stateblock->vertexShader)->usesFog) {
664 glFogi(GL_FOG_MODE, GL_LINEAR);
665 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
668 context->last_was_foggy_shader = TRUE;
670 /* DX 7 sdk: "If both render states(vertex and table fog) are set to valid modes,
671 * the system will apply only pixel(=table) fog effects."
673 else if(stateblock->renderState[WINED3DRS_FOGTABLEMODE] == D3DFOG_NONE) {
674 glHint(GL_FOG_HINT, GL_FASTEST);
675 checkGLcall("glHint(GL_FOG_HINT, GL_FASTEST)");
676 context->last_was_foggy_shader = FALSE;
678 switch (stateblock->renderState[WINED3DRS_FOGVERTEXMODE]) {
679 /* Processed vertices have their fog factor stored in the specular value. Fall too the none case.
680 * If we are drawing untransformed vertices atm, d3ddevice_set_ortho will update the fog
683 if(!context->last_was_rhw) {
684 glFogi(GL_FOG_MODE, GL_EXP);
685 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP");
686 if(GL_SUPPORT(EXT_FOG_COORD)) {
687 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
688 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
694 if(!context->last_was_rhw) {
695 glFogi(GL_FOG_MODE, GL_EXP2);
696 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2");
697 if(GL_SUPPORT(EXT_FOG_COORD)) {
698 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
699 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
704 case D3DFOG_LINEAR: {
705 if(!context->last_was_rhw) {
706 glFogi(GL_FOG_MODE, GL_LINEAR);
707 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR");
708 if(GL_SUPPORT(EXT_FOG_COORD)) {
709 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
710 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
716 /* Both are none? According to msdn the alpha channel of the specular
717 * color contains a fog factor. Set it in drawStridedSlow.
718 * Same happens with Vertexfog on transformed vertices
720 if(GL_SUPPORT(EXT_FOG_COORD)) {
721 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);
722 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT)\n");
723 glFogi(GL_FOG_MODE, GL_LINEAR);
724 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
728 /* Disable GL fog, handle this in software in drawStridedSlow */
733 default: FIXME("Unexpected WINED3DRS_FOGVERTEXMODE %d\n", stateblock->renderState[WINED3DRS_FOGVERTEXMODE]);
736 glHint(GL_FOG_HINT, GL_NICEST);
737 checkGLcall("glHint(GL_FOG_HINT, GL_NICEST)");
738 context->last_was_foggy_shader = FALSE;
740 switch (stateblock->renderState[WINED3DRS_FOGTABLEMODE]) {
742 glFogi(GL_FOG_MODE, GL_EXP);
743 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP");
744 if(GL_SUPPORT(EXT_FOG_COORD)) {
745 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
746 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
751 glFogi(GL_FOG_MODE, GL_EXP2);
752 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2");
753 if(GL_SUPPORT(EXT_FOG_COORD)) {
754 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
755 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
760 glFogi(GL_FOG_MODE, GL_LINEAR);
761 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR");
762 if(GL_SUPPORT(EXT_FOG_COORD)) {
763 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
764 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
768 case D3DFOG_NONE: /* Won't happen */
770 FIXME("Unexpected WINED3DRS_FOGTABLEMODE %d\n", stateblock->renderState[WINED3DRS_FOGTABLEMODE]);
776 checkGLcall("glEnable GL_FOG");
778 glFogfv(GL_FOG_START, &fogstart);
779 checkGLcall("glFogf(GL_FOG_START, fogstart");
780 TRACE("Fog Start == %f\n", fogstart);
782 glFogfv(GL_FOG_END, &fogend);
783 checkGLcall("glFogf(GL_FOG_END, fogend");
784 TRACE("Fog End == %f\n", fogend);
787 checkGLcall("glDisable GL_FOG");
790 if (GL_SUPPORT(NV_FOG_DISTANCE)) {
791 glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_PLANE_ABSOLUTE_NV);
795 static void state_fogcolor(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
797 D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_FOGCOLOR], col);
798 /* Set the default alpha blend color */
799 glFogfv(GL_FOG_COLOR, &col[0]);
800 checkGLcall("glFog GL_FOG_COLOR");
803 static void state_fogdensity(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
808 tmpvalue.d = stateblock->renderState[WINED3DRS_FOGDENSITY];
809 glFogfv(GL_FOG_DENSITY, &tmpvalue.f);
810 checkGLcall("glFogf(GL_FOG_DENSITY, (float) Value)");
813 /* TODO: Merge with primitive type + init_materials()!! */
814 static void state_colormat(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
815 IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)stateblock->wineD3DDevice;
817 WineDirect3DStridedData *diffuse = &device->strided_streams.u.s.diffuse;
818 BOOL isDiffuseSupplied;
820 /* Depends on the decoded vertex declaration to read the existance of diffuse data.
821 * The vertex declaration will call this function if the fixed function pipeline is used.
824 if(isStateDirty(context, STATE_VDECL)) {
828 isDiffuseSupplied = diffuse->lpData || diffuse->VBO;
830 if (isDiffuseSupplied && stateblock->renderState[WINED3DRS_COLORVERTEX]) {
831 TRACE("diff %d, amb %d, emis %d, spec %d\n",
832 stateblock->renderState[WINED3DRS_DIFFUSEMATERIALSOURCE],
833 stateblock->renderState[WINED3DRS_AMBIENTMATERIALSOURCE],
834 stateblock->renderState[WINED3DRS_EMISSIVEMATERIALSOURCE],
835 stateblock->renderState[WINED3DRS_SPECULARMATERIALSOURCE]);
837 if (stateblock->renderState[WINED3DRS_DIFFUSEMATERIALSOURCE] == D3DMCS_COLOR1) {
838 if (stateblock->renderState[WINED3DRS_AMBIENTMATERIALSOURCE] == D3DMCS_COLOR1) {
839 Parm = GL_AMBIENT_AND_DIFFUSE;
843 } else if (stateblock->renderState[WINED3DRS_AMBIENTMATERIALSOURCE] == D3DMCS_COLOR1) {
845 } else if (stateblock->renderState[WINED3DRS_EMISSIVEMATERIALSOURCE] == D3DMCS_COLOR1) {
847 } else if (stateblock->renderState[WINED3DRS_SPECULARMATERIALSOURCE] == D3DMCS_COLOR1) {
852 /* Nothing changed, return. */
853 if (Parm == context->tracking_parm) return;
856 glDisable(GL_COLOR_MATERIAL);
857 checkGLcall("glDisable GL_COLOR_MATERIAL");
859 glColorMaterial(GL_FRONT_AND_BACK, Parm);
860 checkGLcall("glColorMaterial(GL_FRONT_AND_BACK, Parm)");
861 glEnable(GL_COLOR_MATERIAL);
862 checkGLcall("glEnable(GL_COLOR_MATERIAL)");
865 /* Apparently calls to glMaterialfv are ignored for properties we're
866 * tracking with glColorMaterial, so apply those here. */
867 switch (context->tracking_parm) {
868 case GL_AMBIENT_AND_DIFFUSE:
869 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (float*)&device->updateStateBlock->material.Ambient);
870 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, (float*)&device->updateStateBlock->material.Diffuse);
871 checkGLcall("glMaterialfv");
875 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, (float*)&device->updateStateBlock->material.Diffuse);
876 checkGLcall("glMaterialfv");
880 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (float*)&device->updateStateBlock->material.Ambient);
881 checkGLcall("glMaterialfv");
885 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, (float*)&device->updateStateBlock->material.Emissive);
886 checkGLcall("glMaterialfv");
890 /* Only change material color if specular is enabled, otherwise it is set to black */
891 if (device->stateBlock->renderState[WINED3DRS_SPECULARENABLE]) {
892 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float*)&device->updateStateBlock->material.Specular);
893 checkGLcall("glMaterialfv");
895 float black[4] = {0.0f, 0.0f, 0.0f, 0.0f};
896 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, &black[0]);
897 checkGLcall("glMaterialfv");
902 context->tracking_parm = Parm;
905 static void state_linepattern(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
908 WINED3DLINEPATTERN lp;
910 tmppattern.d = stateblock->renderState[WINED3DRS_LINEPATTERN];
912 TRACE("Line pattern: repeat %d bits %x\n", tmppattern.lp.wRepeatFactor, tmppattern.lp.wLinePattern);
914 if (tmppattern.lp.wRepeatFactor) {
915 glLineStipple(tmppattern.lp.wRepeatFactor, tmppattern.lp.wLinePattern);
916 checkGLcall("glLineStipple(repeat, linepattern)");
917 glEnable(GL_LINE_STIPPLE);
918 checkGLcall("glEnable(GL_LINE_STIPPLE);");
920 glDisable(GL_LINE_STIPPLE);
921 checkGLcall("glDisable(GL_LINE_STIPPLE);");
925 static void state_zbias(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
931 if (stateblock->renderState[WINED3DRS_ZBIAS]) {
932 tmpvalue.d = stateblock->renderState[WINED3DRS_ZBIAS];
933 TRACE("ZBias value %f\n", tmpvalue.f);
934 glPolygonOffset(0, -tmpvalue.f);
935 checkGLcall("glPolygonOffset(0, -Value)");
936 glEnable(GL_POLYGON_OFFSET_FILL);
937 checkGLcall("glEnable(GL_POLYGON_OFFSET_FILL);");
938 glEnable(GL_POLYGON_OFFSET_LINE);
939 checkGLcall("glEnable(GL_POLYGON_OFFSET_LINE);");
940 glEnable(GL_POLYGON_OFFSET_POINT);
941 checkGLcall("glEnable(GL_POLYGON_OFFSET_POINT);");
943 glDisable(GL_POLYGON_OFFSET_FILL);
944 checkGLcall("glDisable(GL_POLYGON_OFFSET_FILL);");
945 glDisable(GL_POLYGON_OFFSET_LINE);
946 checkGLcall("glDisable(GL_POLYGON_OFFSET_LINE);");
947 glDisable(GL_POLYGON_OFFSET_POINT);
948 checkGLcall("glDisable(GL_POLYGON_OFFSET_POINT);");
953 static void state_normalize(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
954 if (stateblock->renderState[WINED3DRS_NORMALIZENORMALS]) {
955 glEnable(GL_NORMALIZE);
956 checkGLcall("glEnable(GL_NORMALIZE);");
958 glDisable(GL_NORMALIZE);
959 checkGLcall("glDisable(GL_NORMALIZE);");
963 static void state_psize(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
969 /* FIXME: check that pointSize isn't outside glGetFloatv( GL_POINT_SIZE_MAX_ARB, &maxSize ); or -ve */
970 tmpvalue.d = stateblock->renderState[WINED3DRS_POINTSIZE];
971 TRACE("Set point size to %f\n", tmpvalue.f);
972 glPointSize(tmpvalue.f);
973 checkGLcall("glPointSize(...);");
976 static void state_psizemin(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
982 tmpvalue.d = stateblock->renderState[WINED3DRS_POINTSIZE_MIN];
983 if(GL_SUPPORT(ARB_POINT_PARAMETERS)) {
984 GL_EXTCALL(glPointParameterfARB)(GL_POINT_SIZE_MIN_ARB, tmpvalue.f);
985 checkGLcall("glPointParameterfARB(...");
987 else if(GL_SUPPORT(EXT_POINT_PARAMETERS)) {
988 GL_EXTCALL(glPointParameterfEXT)(GL_POINT_SIZE_MIN_EXT, tmpvalue.f);
989 checkGLcall("glPointParameterfEXT(...);");
990 } else if(tmpvalue.f != 1.0) {
991 FIXME("WINED3DRS_POINTSIZE_MIN not supported on this opengl, value is %f\n", tmpvalue.f);
995 static void state_psizemax(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1001 tmpvalue.d = stateblock->renderState[WINED3DRS_POINTSIZE_MAX];
1002 if(GL_SUPPORT(ARB_POINT_PARAMETERS)) {
1003 GL_EXTCALL(glPointParameterfARB)(GL_POINT_SIZE_MAX_ARB, tmpvalue.f);
1004 checkGLcall("glPointParameterfARB(...");
1006 else if(GL_SUPPORT(EXT_POINT_PARAMETERS)) {
1007 GL_EXTCALL(glPointParameterfEXT)(GL_POINT_SIZE_MAX_EXT, tmpvalue.f);
1008 checkGLcall("glPointParameterfEXT(...);");
1009 } else if(tmpvalue.f != 64.0) {
1010 FIXME("WINED3DRS_POINTSIZE_MAX not supported on this opengl, value is %f\n", tmpvalue.f);
1014 static void state_pscale(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1015 /* TODO: Group this with the viewport */
1017 * POINTSCALEENABLE controls how point size value is treated. If set to
1018 * true, the point size is scaled with respect to height of viewport.
1019 * When set to false point size is in pixels.
1021 * http://msdn.microsoft.com/library/en-us/directx9_c/point_sprites.asp
1024 /* Default values */
1025 GLfloat att[3] = {1.0f, 0.0f, 0.0f};
1028 * Minimum valid point size for OpenGL is 1.0f. For Direct3D it is 0.0f.
1029 * This means that OpenGL will clamp really small point sizes to 1.0f.
1030 * To correct for this we need to multiply by the scale factor when sizes
1031 * are less than 1.0f. scale_factor = 1.0f / point_size.
1033 GLfloat pointSize = *((float*)&stateblock->renderState[WINED3DRS_POINTSIZE]);
1034 if(pointSize > 0.0f) {
1035 GLfloat scaleFactor;
1037 if(pointSize < 1.0f) {
1038 scaleFactor = pointSize * pointSize;
1043 if(stateblock->renderState[WINED3DRS_POINTSCALEENABLE]) {
1044 att[0] = *((float*)&stateblock->renderState[WINED3DRS_POINTSCALE_A]) /
1045 (stateblock->viewport.Height * stateblock->viewport.Height * scaleFactor);
1046 att[1] = *((float*)&stateblock->renderState[WINED3DRS_POINTSCALE_B]) /
1047 (stateblock->viewport.Height * stateblock->viewport.Height * scaleFactor);
1048 att[2] = *((float*)&stateblock->renderState[WINED3DRS_POINTSCALE_C]) /
1049 (stateblock->viewport.Height * stateblock->viewport.Height * scaleFactor);
1053 if(GL_SUPPORT(ARB_POINT_PARAMETERS)) {
1054 GL_EXTCALL(glPointParameterfvARB)(GL_POINT_DISTANCE_ATTENUATION_ARB, att);
1055 checkGLcall("glPointParameterfvARB(GL_DISTANCE_ATTENUATION_ARB, ...");
1057 else if(GL_SUPPORT(EXT_POINT_PARAMETERS)) {
1058 GL_EXTCALL(glPointParameterfvEXT)(GL_DISTANCE_ATTENUATION_EXT, att);
1059 checkGLcall("glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, ...");
1061 TRACE("POINT_PARAMETERS not supported in this version of opengl\n");
1065 static void state_colorwrite(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1066 DWORD Value = stateblock->renderState[WINED3DRS_COLORWRITEENABLE];
1068 TRACE("Color mask: r(%d) g(%d) b(%d) a(%d)\n",
1069 Value & D3DCOLORWRITEENABLE_RED ? 1 : 0,
1070 Value & D3DCOLORWRITEENABLE_GREEN ? 1 : 0,
1071 Value & D3DCOLORWRITEENABLE_BLUE ? 1 : 0,
1072 Value & D3DCOLORWRITEENABLE_ALPHA ? 1 : 0);
1073 glColorMask(Value & D3DCOLORWRITEENABLE_RED ? GL_TRUE : GL_FALSE,
1074 Value & D3DCOLORWRITEENABLE_GREEN ? GL_TRUE : GL_FALSE,
1075 Value & D3DCOLORWRITEENABLE_BLUE ? GL_TRUE : GL_FALSE,
1076 Value & D3DCOLORWRITEENABLE_ALPHA ? GL_TRUE : GL_FALSE);
1077 checkGLcall("glColorMask(...)");
1079 /* depends on WINED3DRS_COLORWRITEENABLE. */
1080 if(stateblock->renderState[WINED3DRS_COLORWRITEENABLE1] != 0x0000000F ||
1081 stateblock->renderState[WINED3DRS_COLORWRITEENABLE2] != 0x0000000F ||
1082 stateblock->renderState[WINED3DRS_COLORWRITEENABLE3] != 0x0000000F ) {
1083 ERR("(WINED3DRS_COLORWRITEENABLE1/2/3,%d,%d,%d) not yet implemented. Missing of cap D3DPMISCCAPS_INDEPENDENTWRITEMASKS wasn't honored?\n",
1084 stateblock->renderState[WINED3DRS_COLORWRITEENABLE1],
1085 stateblock->renderState[WINED3DRS_COLORWRITEENABLE2],
1086 stateblock->renderState[WINED3DRS_COLORWRITEENABLE3]);
1090 static void state_localviewer(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1091 if(stateblock->renderState[WINED3DRS_LOCALVIEWER]) {
1092 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);
1093 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1)");
1095 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 0);
1096 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 0)");
1100 static void state_lastpixel(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1101 if(stateblock->renderState[WINED3DRS_LASTPIXEL]) {
1102 TRACE("Last Pixel Drawing Enabled\n");
1104 FIXME("Last Pixel Drawing Disabled, not handled yet\n");
1108 static void state_pointsprite(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1112 /* TODO: NV_POINT_SPRITE */
1113 if (!GL_SUPPORT(ARB_POINT_SPRITE)) {
1114 TRACE("Point sprites not supported\n");
1118 if (stateblock->renderState[WINED3DRS_POINTSPRITEENABLE]) {
1124 for (i = 0; i < GL_LIMITS(texture_stages); i++) {
1125 /* Note the WINED3DRS value applies to all textures, but GL has one
1126 * per texture, so apply it now ready to be used!
1128 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
1129 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + i));
1130 checkGLcall("glActiveTextureARB");
1132 FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
1136 glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, val);
1137 checkGLcall((val?"glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE)":
1138 "glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_FALSE)"));
1142 static void state_wrap(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1144 http://www.cosc.brocku.ca/Offerings/3P98/course/lectures/texture/
1145 http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/graphics/programmingguide/FixedFunction/Textures/texturewrapping.asp
1146 http://www.gamedev.net/reference/programming/features/rendererdll3/page2.asp
1147 Descussion that ways to turn on WRAPing to solve an opengl conversion problem.
1148 http://www.flipcode.org/cgi-bin/fcmsg.cgi?thread_show=10248
1150 so far as I can tell, wrapping and texture-coordinate generate go hand in hand,
1153 if(stateblock->renderState[WINED3DRS_WRAP0] ||
1154 stateblock->renderState[WINED3DRS_WRAP1] ||
1155 stateblock->renderState[WINED3DRS_WRAP2] ||
1156 stateblock->renderState[WINED3DRS_WRAP3] ||
1157 stateblock->renderState[WINED3DRS_WRAP4] ||
1158 stateblock->renderState[WINED3DRS_WRAP5] ||
1159 stateblock->renderState[WINED3DRS_WRAP6] ||
1160 stateblock->renderState[WINED3DRS_WRAP7] ||
1161 stateblock->renderState[WINED3DRS_WRAP8] ||
1162 stateblock->renderState[WINED3DRS_WRAP9] ||
1163 stateblock->renderState[WINED3DRS_WRAP10] ||
1164 stateblock->renderState[WINED3DRS_WRAP11] ||
1165 stateblock->renderState[WINED3DRS_WRAP12] ||
1166 stateblock->renderState[WINED3DRS_WRAP13] ||
1167 stateblock->renderState[WINED3DRS_WRAP14] ||
1168 stateblock->renderState[WINED3DRS_WRAP15] ) {
1169 ERR("(WINED3DRS_WRAP0) Texture wraping not yet supported\n");
1173 static void state_multisampleaa(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1174 if( GL_SUPPORT(ARB_MULTISAMPLE) ) {
1175 if(stateblock->renderState[WINED3DRS_MULTISAMPLEANTIALIAS]) {
1176 glEnable(GL_MULTISAMPLE_ARB);
1177 checkGLcall("glEnable(GL_MULTISAMPLE_ARB)");
1179 glDisable(GL_MULTISAMPLE_ARB);
1180 checkGLcall("glDisable(GL_MULTISAMPLE_ARB)");
1183 if(stateblock->renderState[WINED3DRS_MULTISAMPLEANTIALIAS]) {
1184 ERR("Multisample antialiasing not supported by gl\n");
1189 static void state_scissor(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1190 if(stateblock->renderState[WINED3DRS_SCISSORTESTENABLE]) {
1191 glEnable(GL_SCISSOR_TEST);
1192 checkGLcall("glEnable(GL_SCISSOR_TEST)");
1194 glDisable(GL_SCISSOR_TEST);
1195 checkGLcall("glDisable(GL_SCISSOR_TEST)");
1199 static void state_depthbias(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1205 if(stateblock->renderState[WINED3DRS_SLOPESCALEDEPTHBIAS] ||
1206 stateblock->renderState[WINED3DRS_DEPTHBIAS]) {
1207 tmpvalue.d = stateblock->renderState[WINED3DRS_SLOPESCALEDEPTHBIAS];
1208 glEnable(GL_POLYGON_OFFSET_FILL);
1209 checkGLcall("glEnable(GL_POLYGON_OFFSET_FILL)");
1210 glPolygonOffset(tmpvalue.f, *((float*)&stateblock->renderState[WINED3DRS_DEPTHBIAS]));
1211 checkGLcall("glPolygonOffset(...)");
1213 glDisable(GL_POLYGON_OFFSET_FILL);
1214 checkGLcall("glDisable(GL_POLYGON_OFFSET_FILL)");
1218 static void state_perspective(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1219 if (stateblock->renderState[WINED3DRS_TEXTUREPERSPECTIVE]) {
1220 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
1221 checkGLcall("glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)");
1223 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
1224 checkGLcall("glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST)");
1228 static void state_stippledalpha(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1230 if (stateblock->renderState[WINED3DRS_STIPPLEDALPHA])
1231 ERR(" Stippled Alpha not supported yet.\n");
1234 static void state_antialias(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1236 if (stateblock->renderState[WINED3DRS_ANTIALIAS])
1237 ERR(" Antialias not supported yet.\n");
1240 static void state_multisampmask(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1242 if (stateblock->renderState[WINED3DRS_MULTISAMPLEMASK] != 0xFFFFFFFF)
1243 ERR("(WINED3DRS_MULTISAMPLEMASK,%d) not yet implemented\n", stateblock->renderState[WINED3DRS_MULTISAMPLEMASK]);
1246 static void state_patchedgestyle(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1248 if (stateblock->renderState[WINED3DRS_PATCHEDGESTYLE] != D3DPATCHEDGE_DISCRETE)
1249 ERR("(WINED3DRS_PATCHEDGESTYLE,%d) not yet implemented\n", stateblock->renderState[WINED3DRS_PATCHEDGESTYLE]);
1252 static void state_patchsegments(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1260 if (stateblock->renderState[WINED3DRS_PATCHSEGMENTS] != tmpvalue.d)
1261 ERR("(WINED3DRS_PATCHSEGMENTS,%d) not yet implemented\n", tmpvalue.d);
1264 static void state_positiondegree(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1266 if (stateblock->renderState[WINED3DRS_POSITIONDEGREE] != D3DDEGREE_CUBIC)
1267 ERR("(WINED3DRS_POSITIONDEGREE,%d) not yet implemented\n", stateblock->renderState[WINED3DRS_POSITIONDEGREE]);
1270 static void state_normaldegree(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1272 if (stateblock->renderState[WINED3DRS_NORMALDEGREE] != D3DDEGREE_LINEAR)
1273 ERR("(WINED3DRS_NORMALDEGREE,%d) not yet implemented\n", stateblock->renderState[WINED3DRS_NORMALDEGREE]);
1276 static void state_tessellation(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1278 if(stateblock->renderState[WINED3DRS_ENABLEADAPTIVETESSELLATION])
1279 FIXME("(WINED3DRS_ENABLEADAPTIVETESSELLATION,%d) not yet implemented\n", stateblock->renderState[WINED3DRS_ENABLEADAPTIVETESSELLATION]);
1283 static void state_srgbwrite(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1284 if(stateblock->renderState[WINED3DRS_SRGBWRITEENABLE])
1285 ERR("Render state WINED3DRS_SRGBWRITEENABLE not yet implemented\n");
1288 static void state_seperateblend(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1290 if(stateblock->renderState[WINED3DRS_SEPARATEALPHABLENDENABLE])
1291 FIXME("(WINED3DRS_SEPARATEALPHABLENDENABLE,%d) not yet implemented\n", stateblock->renderState[WINED3DRS_SEPARATEALPHABLENDENABLE]);
1294 static void state_wrapu(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1295 if(stateblock->renderState[WINED3DRS_WRAPU]) {
1296 FIXME("Render state WINED3DRS_WRAPU not implemented yet\n");
1300 static void state_wrapv(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1301 if(stateblock->renderState[WINED3DRS_WRAPV]) {
1302 FIXME("Render state WINED3DRS_WRAPV not implemented yet\n");
1306 static void state_monoenable(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1307 if(stateblock->renderState[WINED3DRS_MONOENABLE]) {
1308 FIXME("Render state WINED3DRS_MONOENABLE not implemented yet\n");
1312 static void state_rop2(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1313 if(stateblock->renderState[WINED3DRS_ROP2]) {
1314 FIXME("Render state WINED3DRS_ROP2 not implemented yet\n");
1318 static void state_planemask(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1319 if(stateblock->renderState[WINED3DRS_PLANEMASK]) {
1320 FIXME("Render state WINED3DRS_PLANEMASK not implemented yet\n");
1324 static void state_subpixel(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1325 if(stateblock->renderState[WINED3DRS_SUBPIXEL]) {
1326 FIXME("Render state WINED3DRS_SUBPIXEL not implemented yet\n");
1330 static void state_subpixelx(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1331 if(stateblock->renderState[WINED3DRS_SUBPIXELX]) {
1332 FIXME("Render state WINED3DRS_SUBPIXELX not implemented yet\n");
1336 static void state_stippleenable(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1337 if(stateblock->renderState[WINED3DRS_STIPPLEENABLE]) {
1338 FIXME("Render state WINED3DRS_STIPPLEENABLE not implemented yet\n");
1342 static void state_bordercolor(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1343 if(stateblock->renderState[WINED3DRS_BORDERCOLOR]) {
1344 FIXME("Render state WINED3DRS_BORDERCOLOR not implemented yet\n");
1348 static void state_mipmaplodbias(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1349 if(stateblock->renderState[WINED3DRS_MIPMAPLODBIAS]) {
1350 FIXME("Render state WINED3DRS_MIPMAPLODBIAS not implemented yet\n");
1354 static void state_anisotropy(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1355 if(stateblock->renderState[WINED3DRS_ANISOTROPY]) {
1356 FIXME("Render state WINED3DRS_ANISOTROPY not implemented yet\n");
1360 static void state_flushbatch(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1361 if(stateblock->renderState[WINED3DRS_FLUSHBATCH]) {
1362 FIXME("Render state WINED3DRS_FLUSHBATCH not implemented yet\n");
1366 static void state_translucentsi(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1367 if(stateblock->renderState[WINED3DRS_TRANSLUCENTSORTINDEPENDENT]) {
1368 FIXME("Render state WINED3DRS_TRANSLUCENTSORTINDEPENDENT not implemented yet\n");
1372 static void state_extents(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1373 if(stateblock->renderState[WINED3DRS_EXTENTS]) {
1374 FIXME("Render state WINED3DRS_EXTENTS not implemented yet\n");
1378 static void state_ckeyblend(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1379 if(stateblock->renderState[WINED3DRS_COLORKEYBLENDENABLE]) {
1380 FIXME("Render state WINED3DRS_COLORKEYBLENDENABLE not implemented yet\n");
1384 /* Activates the texture dimension according to the bound D3D texture.
1385 * Does not care for the colorop or correct gl texture unit(when using nvrc)
1386 * Requires the caller to activate the correct unit before
1388 static void activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock) {
1389 if(stateblock->textures[stage]) {
1390 glDisable(GL_TEXTURE_1D);
1391 checkGLcall("glDisable(GL_TEXTURE_1D)");
1392 switch(stateblock->textureDimensions[stage]) {
1394 glDisable(GL_TEXTURE_3D);
1395 checkGLcall("glDisable(GL_TEXTURE_3D)");
1396 glDisable(GL_TEXTURE_CUBE_MAP_ARB);
1397 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
1398 glEnable(GL_TEXTURE_2D);
1399 checkGLcall("glEnable(GL_TEXTURE_2D)");
1402 glDisable(GL_TEXTURE_CUBE_MAP_ARB);
1403 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
1404 glDisable(GL_TEXTURE_2D);
1405 checkGLcall("glDisable(GL_TEXTURE_2D)");
1406 glEnable(GL_TEXTURE_3D);
1407 checkGLcall("glEnable(GL_TEXTURE_3D)");
1409 case GL_TEXTURE_CUBE_MAP_ARB:
1410 glDisable(GL_TEXTURE_2D);
1411 checkGLcall("glDisable(GL_TEXTURE_2D)");
1412 glDisable(GL_TEXTURE_3D);
1413 checkGLcall("glDisable(GL_TEXTURE_3D)");
1414 glEnable(GL_TEXTURE_CUBE_MAP_ARB);
1415 checkGLcall("glEnable(GL_TEXTURE_CUBE_MAP_ARB)");
1419 glDisable(GL_TEXTURE_2D);
1420 checkGLcall("glDisable(GL_TEXTURE_2D)");
1421 glDisable(GL_TEXTURE_3D);
1422 checkGLcall("glDisable(GL_TEXTURE_3D)");
1423 glDisable(GL_TEXTURE_CUBE_MAP_ARB);
1424 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
1425 glEnable(GL_TEXTURE_1D);
1426 checkGLcall("glEnable(GL_TEXTURE_1D)");
1427 /* Binding textures is done by samplers. A dummy texture will be bound */
1431 static void tex_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1432 DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE;
1433 DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[stage];
1435 TRACE("Setting color op for stage %d\n", stage);
1437 if (stateblock->pixelShader && stateblock->wineD3DDevice->ps_selected_mode != SHADER_NONE &&
1438 ((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.function) {
1439 /* Using a pixel shader? Don't care for anything here, the shader applying does it */
1443 if (stage != mapped_stage) WARN("Using non 1:1 mapping: %d -> %d!\n", stage, mapped_stage);
1445 if (mapped_stage != -1) {
1446 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
1447 if (mapped_stage >= GL_LIMITS(sampler_stages)) {
1448 if (stateblock->textureState[stage][WINED3DTSS_COLOROP] != WINED3DTOP_DISABLE &&
1449 stateblock->textureState[stage][WINED3DTSS_COLOROP] != 0) {
1450 FIXME("Attempt to enable unsupported stage!\n");
1454 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
1455 checkGLcall("glActiveTextureARB");
1456 } else if (stage > 0) {
1457 WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
1462 if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
1463 if(stateblock->lowest_disabled_stage > 0) {
1464 glEnable(GL_REGISTER_COMBINERS_NV);
1465 GL_EXTCALL(glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, stateblock->lowest_disabled_stage));
1467 glDisable(GL_REGISTER_COMBINERS_NV);
1470 if(stage >= stateblock->lowest_disabled_stage) {
1471 TRACE("Stage disabled\n");
1472 if (mapped_stage != -1) {
1473 /* Disable everything here */
1474 glDisable(GL_TEXTURE_1D);
1475 checkGLcall("glDisable(GL_TEXTURE_1D)");
1476 glDisable(GL_TEXTURE_2D);
1477 checkGLcall("glDisable(GL_TEXTURE_2D)");
1478 glDisable(GL_TEXTURE_3D);
1479 checkGLcall("glDisable(GL_TEXTURE_3D)");
1480 glDisable(GL_TEXTURE_CUBE_MAP_ARB);
1481 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
1487 /* The sampler will also activate the correct texture dimensions, so no need to do it here
1488 * if the sampler for this stage is dirty
1490 if(!isStateDirty(context, STATE_SAMPLER(stage))) {
1491 if (mapped_stage != -1) activate_dimensions(stage, stateblock);
1494 /* Set the texture combiners */
1495 if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
1496 set_tex_op_nvrc((IWineD3DDevice *)stateblock->wineD3DDevice, FALSE, stage,
1497 stateblock->textureState[stage][WINED3DTSS_COLOROP],
1498 stateblock->textureState[stage][WINED3DTSS_COLORARG1],
1499 stateblock->textureState[stage][WINED3DTSS_COLORARG2],
1500 stateblock->textureState[stage][WINED3DTSS_COLORARG0],
1503 set_tex_op((IWineD3DDevice *)stateblock->wineD3DDevice, FALSE, stage,
1504 stateblock->textureState[stage][WINED3DTSS_COLOROP],
1505 stateblock->textureState[stage][WINED3DTSS_COLORARG1],
1506 stateblock->textureState[stage][WINED3DTSS_COLORARG2],
1507 stateblock->textureState[stage][WINED3DTSS_COLORARG0]);
1511 static void tex_alphaop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1512 DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE;
1513 DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[stage];
1515 TRACE("Setting alpha op for stage %d\n", stage);
1516 /* Do not care for enabled / disabled stages, just assign the settigns. colorop disables / enables required stuff */
1517 if (mapped_stage != -1) {
1518 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
1519 if (stage >= GL_LIMITS(sampler_stages)) {
1520 if (stateblock->textureState[stage][WINED3DTSS_COLOROP] != WINED3DTOP_DISABLE &&
1521 stateblock->textureState[stage][WINED3DTSS_COLOROP] != 0) {
1522 FIXME("Attempt to enable unsupported stage!\n");
1526 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
1527 checkGLcall("glActiveTextureARB");
1528 } else if (stage > 0) {
1529 /* We can't do anything here */
1530 WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
1535 TRACE("Setting alpha op for stage %d\n", stage);
1536 if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
1537 set_tex_op_nvrc((IWineD3DDevice *)stateblock->wineD3DDevice, TRUE, stage,
1538 stateblock->textureState[stage][WINED3DTSS_ALPHAOP],
1539 stateblock->textureState[stage][WINED3DTSS_ALPHAARG1],
1540 stateblock->textureState[stage][WINED3DTSS_ALPHAARG2],
1541 stateblock->textureState[stage][WINED3DTSS_ALPHAARG0],
1544 set_tex_op((IWineD3DDevice *)stateblock->wineD3DDevice, TRUE, stage, stateblock->textureState[stage][WINED3DTSS_ALPHAOP],
1545 stateblock->textureState[stage][WINED3DTSS_ALPHAARG1],
1546 stateblock->textureState[stage][WINED3DTSS_ALPHAARG2],
1547 stateblock->textureState[stage][WINED3DTSS_ALPHAARG0]);
1551 static void transform_texture(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1552 DWORD texUnit = state - STATE_TRANSFORM(WINED3DTS_TEXTURE0);
1554 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
1555 if(texUnit >= GL_LIMITS(sampler_stages)) {
1558 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + stateblock->wineD3DDevice->texUnitMap[texUnit]));
1559 checkGLcall("glActiveTextureARB");
1560 } else if (texUnit > 0) {
1561 /* We can't do anything here */
1562 WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
1566 set_texture_matrix((float *)&stateblock->transforms[WINED3DTS_TEXTURE0 + texUnit].u.m[0][0],
1567 stateblock->textureState[texUnit][WINED3DTSS_TEXTURETRANSFORMFLAGS],
1568 (stateblock->textureState[texUnit][WINED3DTSS_TEXCOORDINDEX] & 0xFFFF0000) != WINED3DTSS_TCI_PASSTHRU);
1572 static void loadVertexData(IWineD3DStateBlockImpl *stateblock, WineDirect3DVertexStridedData *sd);
1574 static void tex_coordindex(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1575 DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE;
1576 DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[stage];
1578 if (mapped_stage == -1) {
1579 TRACE("No texture unit mapped to stage %d. Skipping texture coordinates.\n", stage);
1583 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
1584 if(stage >= GL_LIMITS(sampler_stages)) {
1587 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
1588 checkGLcall("glActiveTextureARB");
1589 } else if (stage > 0) {
1590 /* We can't do anything here */
1591 WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
1595 /* Values 0-7 are indexes into the FVF tex coords - See comments in DrawPrimitive
1597 * FIXME: From MSDN: The WINED3DTSS_TCI_* flags are mutually exclusive. If you include
1598 * one flag, you can still specify an index value, which the system uses to
1599 * determine the texture wrapping mode.
1600 * eg. SetTextureStageState( 0, WINED3DTSS_TEXCOORDINDEX, WINED3DTSS_TCI_CAMERASPACEPOSITION | 1 );
1601 * means use the vertex position (camera-space) as the input texture coordinates
1602 * for this texture stage, and the wrap mode set in the WINED3DRS_WRAP1 render
1603 * state. We do not (yet) support the WINED3DRENDERSTATE_WRAPx values, nor tie them up
1604 * to the TEXCOORDINDEX value
1608 * Be careful the value of the mask 0xF0000 come from d3d8types.h infos
1610 switch (stateblock->textureState[stage][WINED3DTSS_TEXCOORDINDEX] & 0xFFFF0000) {
1611 case WINED3DTSS_TCI_PASSTHRU:
1612 /*Use the specified texture coordinates contained within the vertex format. This value resolves to zero.*/
1613 glDisable(GL_TEXTURE_GEN_S);
1614 glDisable(GL_TEXTURE_GEN_T);
1615 glDisable(GL_TEXTURE_GEN_R);
1616 glDisable(GL_TEXTURE_GEN_Q);
1617 checkGLcall("glDisable(GL_TEXTURE_GEN_S,T,R,Q)");
1620 case WINED3DTSS_TCI_CAMERASPACEPOSITION:
1621 /* CameraSpacePosition means use the vertex position, transformed to camera space,
1622 * as the input texture coordinates for this stage's texture transformation. This
1623 * equates roughly to EYE_LINEAR
1626 float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
1627 float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
1628 float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
1629 float q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
1630 TRACE("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set eye plane\n");
1632 glMatrixMode(GL_MODELVIEW);
1635 glTexGenfv(GL_S, GL_EYE_PLANE, s_plane);
1636 glTexGenfv(GL_T, GL_EYE_PLANE, t_plane);
1637 glTexGenfv(GL_R, GL_EYE_PLANE, r_plane);
1638 glTexGenfv(GL_Q, GL_EYE_PLANE, q_plane);
1641 TRACE("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set GL_TEXTURE_GEN_x and GL_x, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR\n");
1642 glEnable(GL_TEXTURE_GEN_S);
1643 checkGLcall("glEnable(GL_TEXTURE_GEN_S);");
1644 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
1645 checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)");
1646 glEnable(GL_TEXTURE_GEN_T);
1647 checkGLcall("glEnable(GL_TEXTURE_GEN_T);");
1648 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
1649 checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)");
1650 glEnable(GL_TEXTURE_GEN_R);
1651 checkGLcall("glEnable(GL_TEXTURE_GEN_R);");
1652 glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
1653 checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)");
1657 case WINED3DTSS_TCI_CAMERASPACENORMAL:
1659 if (GL_SUPPORT(NV_TEXGEN_REFLECTION)) {
1660 float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
1661 float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
1662 float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
1663 float q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
1664 TRACE("WINED3DTSS_TCI_CAMERASPACENORMAL - Set eye plane\n");
1666 glMatrixMode(GL_MODELVIEW);
1669 glTexGenfv(GL_S, GL_EYE_PLANE, s_plane);
1670 glTexGenfv(GL_T, GL_EYE_PLANE, t_plane);
1671 glTexGenfv(GL_R, GL_EYE_PLANE, r_plane);
1672 glTexGenfv(GL_Q, GL_EYE_PLANE, q_plane);
1675 glEnable(GL_TEXTURE_GEN_S);
1676 checkGLcall("glEnable(GL_TEXTURE_GEN_S);");
1677 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV);
1678 checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV)");
1679 glEnable(GL_TEXTURE_GEN_T);
1680 checkGLcall("glEnable(GL_TEXTURE_GEN_T);");
1681 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV);
1682 checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV)");
1683 glEnable(GL_TEXTURE_GEN_R);
1684 checkGLcall("glEnable(GL_TEXTURE_GEN_R);");
1685 glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV);
1686 checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV)");
1691 case WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR:
1693 if (GL_SUPPORT(NV_TEXGEN_REFLECTION)) {
1694 float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
1695 float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
1696 float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
1697 float q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
1698 TRACE("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Set eye plane\n");
1700 glMatrixMode(GL_MODELVIEW);
1703 glTexGenfv(GL_S, GL_EYE_PLANE, s_plane);
1704 glTexGenfv(GL_T, GL_EYE_PLANE, t_plane);
1705 glTexGenfv(GL_R, GL_EYE_PLANE, r_plane);
1706 glTexGenfv(GL_Q, GL_EYE_PLANE, q_plane);
1709 glEnable(GL_TEXTURE_GEN_S);
1710 checkGLcall("glEnable(GL_TEXTURE_GEN_S);");
1711 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV);
1712 checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV)");
1713 glEnable(GL_TEXTURE_GEN_T);
1714 checkGLcall("glEnable(GL_TEXTURE_GEN_T);");
1715 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV);
1716 checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV)");
1717 glEnable(GL_TEXTURE_GEN_R);
1718 checkGLcall("glEnable(GL_TEXTURE_GEN_R);");
1719 glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV);
1720 checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV)");
1725 /* Unhandled types: */
1728 /* ? disable GL_TEXTURE_GEN_n ? */
1729 glDisable(GL_TEXTURE_GEN_S);
1730 glDisable(GL_TEXTURE_GEN_T);
1731 glDisable(GL_TEXTURE_GEN_R);
1732 glDisable(GL_TEXTURE_GEN_Q);
1733 FIXME("Unhandled WINED3DTSS_TEXCOORDINDEX %x\n", stateblock->textureState[stage][WINED3DTSS_TEXCOORDINDEX]);
1737 /* Update the texture matrix */
1738 if(!isStateDirty(context, STATE_TRANSFORM(WINED3DTS_TEXTURE0 + stage))) {
1739 transform_texture(STATE_TRANSFORM(WINED3DTS_TEXTURE0 + stage), stateblock, context);
1742 if(!isStateDirty(context, STATE_VDECL) && context->namedArraysLoaded) {
1743 /* Reload the arrays if we are using fixed function arrays to reflect the selected coord input
1744 * source. Call loadVertexData directly because there is no need to reparse the vertex declaration
1745 * and do all the things linked to it
1746 * TODO: Tidy that up to reload only the arrays of the changed unit
1748 loadVertexData(stateblock, &stateblock->wineD3DDevice->strided_streams);
1752 static void tex_bumpenvlscale(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1753 DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE;
1759 tmpvalue.d = stateblock->textureState[stage][WINED3DTSS_BUMPENVLSCALE];
1760 if(tmpvalue.f != 0.0) {
1761 ERR("WINED3DTSS_BUMPENVLSCALE not supported yet\n");
1765 static void tex_bumpenvloffset(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1766 DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE;
1772 tmpvalue.d = stateblock->textureState[stage][WINED3DTSS_BUMPENVLOFFSET];
1773 if(tmpvalue.f != 0.0) {
1774 ERR("WINED3DTSS_BUMPENVLOFFSET not supported yet\n");
1778 static void tex_resultarg(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1779 DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE;
1781 if(stage >= GL_LIMITS(texture_stages)) {
1785 if(stateblock->textureState[stage][WINED3DTSS_RESULTARG] != D3DTA_CURRENT) {
1786 ERR("WINED3DTSS_RESULTARG not supported yet\n");
1790 static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1791 DWORD sampler = state - STATE_SAMPLER(0);
1792 DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[sampler];
1798 TRACE("Sampler: %d\n", sampler);
1799 /* Enabling and disabling texture dimensions is done by texture stage state / pixel shader setup, this function
1800 * only has to bind textures and set the per texture states
1803 if (mapped_stage == -1) {
1804 TRACE("No sampler mapped to stage %d. Returning.\n", sampler);
1808 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
1809 if(sampler >= GL_LIMITS(sampler_stages)) {
1812 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
1813 checkGLcall("glActiveTextureARB");
1814 } else if (sampler > 0) {
1815 /* We can't do anything here */
1816 WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
1820 if(stateblock->textures[sampler]) {
1821 BOOL texIsPow2 = FALSE;
1823 /* The fixed function np2 texture emulation uses the texture matrix to fix up the coordinates
1824 * IWineD3DBaseTexture::ApplyStateChanges multiplies the set matrix with a fixup matrix. Before the
1825 * scaling is reapplied or removed, the texture matrix has to be reapplied
1827 if(wined3d_settings.nonpower2_mode != NP2_NATIVE && sampler < MAX_TEXTURES) {
1828 if(stateblock->textureDimensions[sampler] == GL_TEXTURE_2D) {
1829 if(((IWineD3DTextureImpl *) stateblock->textures[sampler])->pow2scalingFactorX != 1.0 ||
1830 ((IWineD3DTextureImpl *) stateblock->textures[sampler])->pow2scalingFactorY != 1.0 ) {
1833 } else if(stateblock->textureDimensions[sampler] == GL_TEXTURE_CUBE_MAP_ARB) {
1834 if(((IWineD3DCubeTextureImpl *) stateblock->textures[sampler])->pow2scalingFactor != 1.0) {
1839 if(texIsPow2 || context->lastWasPow2Texture[sampler]) {
1840 transform_texture(STATE_TRANSFORM(WINED3DTS_TEXTURE0 + stateblock->wineD3DDevice->texUnitMap[sampler]), stateblock, context);
1841 context->lastWasPow2Texture[sampler] = texIsPow2;
1845 IWineD3DBaseTexture_PreLoad((IWineD3DBaseTexture *) stateblock->textures[sampler]);
1846 IWineD3DBaseTexture_ApplyStateChanges(stateblock->textures[sampler], stateblock->textureState[sampler], stateblock->samplerState[sampler]);
1848 if (GL_SUPPORT(EXT_TEXTURE_LOD_BIAS)) {
1849 tmpvalue.d = stateblock->samplerState[sampler][WINED3DSAMP_MIPMAPLODBIAS];
1850 glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT,
1851 GL_TEXTURE_LOD_BIAS_EXT,
1853 checkGLcall("glTexEnvi GL_TEXTURE_LOD_BIAS_EXT ...");
1856 if (stateblock->wineD3DDevice->ps_selected_mode != SHADER_NONE && stateblock->pixelShader &&
1857 ((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.function) {
1858 /* Using a pixel shader? Verify the sampler types */
1860 /* Make sure that the texture dimensions are enabled. I don't have to disable the other
1861 * dimensions because the shader knows from which texture type to sample from. For the sake of
1862 * debugging all dimensions could be enabled and a texture with some ugly pink bound to the unused
1863 * dimensions. This should make wrong sampling sources visible :-)
1865 glEnable(stateblock->textureDimensions[sampler]);
1866 checkGLcall("glEnable(stateblock->textureDimensions[sampler])");
1867 } else if(sampler < stateblock->lowest_disabled_stage) {
1868 if(!isStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3DTSS_COLOROP))) {
1869 activate_dimensions(sampler, stateblock);
1872 if(stateblock->renderState[WINED3DRS_COLORKEYENABLE] && sampler == 0) {
1873 /* If color keying is enabled update the alpha test, it depends on the existence
1874 * of a color key in stage 0
1876 state_alpha(WINED3DRS_COLORKEYENABLE, stateblock, context);
1879 } else if(sampler < GL_LIMITS(texture_stages)) {
1880 if(sampler < stateblock->lowest_disabled_stage) {
1881 /* TODO: What should I do with pixel shaders here ??? */
1882 if(!isStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3DTSS_COLOROP))) {
1883 activate_dimensions(sampler, stateblock);
1885 } /* Otherwise tex_colorop disables the stage */
1886 glBindTexture(GL_TEXTURE_1D, stateblock->wineD3DDevice->dummyTextureName[sampler]);
1887 checkGLcall("glBindTexture(GL_TEXTURE_1D, stateblock->wineD3DDevice->dummyTextureName[sampler])");
1891 static void shaderconstant(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1892 IWineD3DDeviceImpl *device = stateblock->wineD3DDevice;
1894 /* Vertex and pixel shader states will call a shader upload, don't do anything as long one of them
1895 * has an update pending
1897 if(isStateDirty(context, STATE_VDECL) ||
1898 isStateDirty(context, STATE_PIXELSHADER)) {
1902 device->shader_backend->shader_load_constants((IWineD3DDevice *) device,
1903 stateblock->pixelShader && ((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.function,
1904 stateblock->vertexShader && ((IWineD3DVertexShaderImpl *)stateblock->vertexShader)->baseShader.function);
1907 static void pixelshader(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1910 if(stateblock->pixelShader && ((IWineD3DPixelShaderImpl *) stateblock->pixelShader)->baseShader.function != NULL) {
1911 if(!context->last_was_pshader) {
1912 /* Former draw without a pixel shader, some samplers
1913 * may be disabled because of WINED3DTSS_COLOROP = WINED3DTOP_DISABLE
1914 * make sure to enable them
1916 for(i=0; i < MAX_SAMPLERS; i++) {
1917 if(!isStateDirty(context, STATE_SAMPLER(i))) {
1918 sampler(STATE_SAMPLER(i), stateblock, context);
1922 /* Otherwise all samplers were activated by the code above in earlier draws, or by sampler()
1923 * if a different texture was bound. I don't have to do anything.
1927 /* Compile and bind the shader */
1928 IWineD3DPixelShader_CompileShader(stateblock->pixelShader);
1930 if(!isStateDirty(context, StateTable[STATE_VSHADER].representative)) {
1931 stateblock->wineD3DDevice->shader_backend->shader_select(
1932 (IWineD3DDevice *) stateblock->wineD3DDevice,
1934 !stateblock->vertexShader ? FALSE : ((IWineD3DVertexShaderImpl *) stateblock->vertexShader)->baseShader.function != NULL);
1936 if(!isStateDirty(context, STATE_VERTEXSHADERCONSTANT)) {
1937 shaderconstant(STATE_VERTEXSHADERCONSTANT, stateblock, context);
1940 context->last_was_pshader = TRUE;
1942 /* Disabled the pixel shader - color ops weren't applied
1943 * while it was enabled, so re-apply them.
1945 for(i=0; i < MAX_TEXTURES; i++) {
1946 if(!isStateDirty(context, STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP))) {
1947 tex_colorop(STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP), stateblock, context);
1950 context->last_was_pshader = FALSE;
1952 if(!isStateDirty(context, StateTable[STATE_VSHADER].representative)) {
1953 stateblock->wineD3DDevice->shader_backend->shader_select(
1954 (IWineD3DDevice *) stateblock->wineD3DDevice,
1956 !stateblock->vertexShader ? FALSE : ((IWineD3DVertexShaderImpl *) stateblock->vertexShader)->baseShader.function != NULL);
1958 if(!isStateDirty(context, STATE_VERTEXSHADERCONSTANT)) {
1959 shaderconstant(STATE_VERTEXSHADERCONSTANT, stateblock, context);
1965 static void transform_world(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1966 /* This function is called by transform_view below if the view matrix was changed too
1968 * Deliberately no check if the vertex declaration is dirty because the vdecl state
1969 * does not always update the world matrix, only on a switch between transformed
1970 * and untrannsformed draws. It *may* happen that the world matrix is set 2 times during one
1971 * draw, but that should be rather rare and cheaper in total.
1973 glMatrixMode(GL_MODELVIEW);
1974 checkGLcall("glMatrixMode");
1976 if(context->last_was_rhw) {
1978 checkGLcall("glLoadIdentity()");
1980 /* In the general case, the view matrix is the identity matrix */
1981 if (stateblock->wineD3DDevice->view_ident) {
1982 glLoadMatrixf((float *) &stateblock->transforms[WINED3DTS_WORLDMATRIX(0)].u.m[0][0]);
1983 checkGLcall("glLoadMatrixf");
1985 glLoadMatrixf((float *) &stateblock->transforms[WINED3DTS_VIEW].u.m[0][0]);
1986 checkGLcall("glLoadMatrixf");
1987 glMultMatrixf((float *) &stateblock->transforms[WINED3DTS_WORLDMATRIX(0)].u.m[0][0]);
1988 checkGLcall("glMultMatrixf");
1993 static void transform_view(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
1996 /* If we are changing the View matrix, reset the light and clipping planes to the new view
1997 * NOTE: We have to reset the positions even if the light/plane is not currently
1998 * enabled, since the call to enable it will not reset the position.
1999 * NOTE2: Apparently texture transforms do NOT need reapplying
2002 PLIGHTINFOEL *lightChain = NULL;
2004 glMatrixMode(GL_MODELVIEW);
2005 checkGLcall("glMatrixMode(GL_MODELVIEW)");
2006 glLoadMatrixf((float *)(float *) &stateblock->transforms[WINED3DTS_VIEW].u.m[0][0]);
2007 checkGLcall("glLoadMatrixf(...)");
2009 /* Reset lights. TODO: Call light apply func */
2010 lightChain = stateblock->lights;
2011 while (lightChain && lightChain->glIndex != -1) {
2012 glLightfv(GL_LIGHT0 + lightChain->glIndex, GL_POSITION, lightChain->lightPosn);
2013 checkGLcall("glLightfv posn");
2014 glLightfv(GL_LIGHT0 + lightChain->glIndex, GL_SPOT_DIRECTION, lightChain->lightDirn);
2015 checkGLcall("glLightfv dirn");
2016 lightChain = lightChain->next;
2019 /* Reset Clipping Planes if clipping is enabled. TODO: Call clipplane apply func */
2020 for (k = 0; k < GL_LIMITS(clipplanes); k++) {
2021 glClipPlane(GL_CLIP_PLANE0 + k, stateblock->clipplane[k]);
2022 checkGLcall("glClipPlane");
2025 if(context->last_was_rhw) {
2027 checkGLcall("glLoadIdentity()");
2028 /* No need to update the world matrix, the identity is fine */
2032 /* Call the world matrix state, this will apply the combined WORLD + VIEW matrix
2033 * No need to do it here if the state is scheduled for update.
2035 if(!isStateDirty(context, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)))) {
2036 transform_world(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), stateblock, context);
2040 static void transform_worldex(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
2041 WARN("World matrix 1 - 255 not supported yet\n");
2044 static const GLfloat invymat[16] = {
2045 1.0f, 0.0f, 0.0f, 0.0f,
2046 0.0f, -1.0f, 0.0f, 0.0f,
2047 0.0f, 0.0f, 1.0f, 0.0f,
2048 0.0f, 0.0f, 0.0f, 1.0f};
2050 static void transform_projection(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
2051 glMatrixMode(GL_PROJECTION);
2052 checkGLcall("glMatrixMode(GL_PROJECTION)");
2054 checkGLcall("glLoadIdentity");
2056 if(context->last_was_rhw) {
2057 double X, Y, height, width, minZ, maxZ;
2059 X = stateblock->viewport.X;
2060 Y = stateblock->viewport.Y;
2061 height = stateblock->viewport.Height;
2062 width = stateblock->viewport.Width;
2063 minZ = stateblock->viewport.MinZ;
2064 maxZ = stateblock->viewport.MaxZ;
2066 if(!stateblock->wineD3DDevice->untransformed) {
2067 /* Transformed vertices are supposed to bypass the whole transform pipeline including
2068 * frustum clipping. This can't be done in opengl, so this code adjusts the Z range to
2069 * suppress depth clipping. This can be done because it is an orthogonal projection and
2070 * the Z coordinate does not affect the size of the primitives
2072 TRACE("Calling glOrtho with %f, %f, %f, %f\n", width, height, -minZ, -maxZ);
2073 glOrtho(X, X + width, Y + height, Y, -minZ, -maxZ);
2075 /* If the app mixes transformed and untransformed primitives we can't use the coordinate system
2076 * trick above because this would mess up transformed and untransformed Z order. Pass the z position
2077 * unmodified to opengl.
2079 * If the app depends on mixed types and disabled clipping we're out of luck without a pipeline
2080 * replacement shader.
2082 TRACE("Calling glOrtho with %f, %f, %f, %f\n", width, height, 1.0, -1.0);
2083 glOrtho(X, X + width, Y + height, Y, 1.0, -1.0);
2085 checkGLcall("glOrtho");
2087 /* Window Coord 0 is the middle of the first pixel, so translate by 3/8 pixels */
2088 glTranslatef(0.375, 0.375, 0);
2089 checkGLcall("glTranslatef(0.375, 0.375, 0)");
2090 /* D3D texture coordinates are flipped compared to OpenGL ones, so
2091 * render everything upside down when rendering offscreen. */
2092 if (stateblock->wineD3DDevice->render_offscreen) {
2093 glMultMatrixf(invymat);
2094 checkGLcall("glMultMatrixf(invymat)");
2097 /* The rule is that the window coordinate 0 does not correspond to the
2098 beginning of the first pixel, but the center of the first pixel.
2099 As a consequence if you want to correctly draw one line exactly from
2100 the left to the right end of the viewport (with all matrices set to
2101 be identity), the x coords of both ends of the line would be not
2102 -1 and 1 respectively but (-1-1/viewport_widh) and (1-1/viewport_width)
2104 glTranslatef(0.9 / stateblock->viewport.Width, -0.9 / stateblock->viewport.Height, 0);
2105 checkGLcall("glTranslatef (0.9 / width, -0.9 / height, 0)");
2107 /* D3D texture coordinates are flipped compared to OpenGL ones, so
2108 * render everything upside down when rendering offscreen. */
2109 if (stateblock->wineD3DDevice->render_offscreen) {
2110 glMultMatrixf(invymat);
2111 checkGLcall("glMultMatrixf(invymat)");
2113 glMultMatrixf((float *) &stateblock->transforms[WINED3DTS_PROJECTION].u.m[0][0]);
2114 checkGLcall("glLoadMatrixf");
2118 /* This should match any arrays loaded in loadVertexData.
2119 * stateblock impl is required for GL_SUPPORT
2120 * TODO: Only load / unload arrays if we have to.
2122 static inline void unloadVertexData(IWineD3DStateBlockImpl *stateblock) {
2125 glDisableClientState(GL_VERTEX_ARRAY);
2126 glDisableClientState(GL_NORMAL_ARRAY);
2127 glDisableClientState(GL_COLOR_ARRAY);
2128 if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
2129 glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
2131 for (texture_idx = 0; texture_idx < GL_LIMITS(textures); ++texture_idx) {
2132 GL_EXTCALL(glClientActiveTextureARB(GL_TEXTURE0_ARB + texture_idx));
2133 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
2137 /* This should match any arrays loaded in loadNumberedArrays
2138 * TODO: Only load / unload arrays if we have to.
2140 static inline void unloadNumberedArrays(IWineD3DStateBlockImpl *stateblock) {
2141 /* disable any attribs (this is the same for both GLSL and ARB modes) */
2145 /* Leave all the attribs disabled */
2146 glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB, &maxAttribs);
2147 /* MESA does not support it right not */
2148 if (glGetError() != GL_NO_ERROR)
2150 for (i = 0; i < maxAttribs; ++i) {
2151 GL_EXTCALL(glDisableVertexAttribArrayARB(i));
2152 checkGLcall("glDisableVertexAttribArrayARB(reg);");
2156 static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock, WineDirect3DVertexStridedData *strided) {
2157 GLint curVBO = GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT) ? -1 : 0;
2159 UINT *offset = stateblock->streamOffset;
2161 for (i = 0; i < MAX_ATTRIBS; i++) {
2163 if (!strided->u.input[i].lpData && !strided->u.input[i].VBO)
2166 TRACE_(d3d_shader)("Loading array %u [VBO=%u]\n", i, strided->u.input[i].VBO);
2168 if(curVBO != strided->u.input[i].VBO) {
2169 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, strided->u.input[i].VBO));
2170 checkGLcall("glBindBufferARB");
2171 curVBO = strided->u.input[i].VBO;
2173 GL_EXTCALL(glVertexAttribPointerARB(i,
2174 WINED3D_ATR_SIZE(strided->u.input[i].dwType),
2175 WINED3D_ATR_GLTYPE(strided->u.input[i].dwType),
2176 WINED3D_ATR_NORMALIZED(strided->u.input[i].dwType),
2177 strided->u.input[i].dwStride,
2178 strided->u.input[i].lpData + stateblock->loadBaseVertexIndex * strided->u.input[i].dwStride + offset[strided->u.input[i].streamNo]) );
2179 GL_EXTCALL(glEnableVertexAttribArrayARB(i));
2183 /* Used from 2 different functions, and too big to justify making it inlined */
2184 static void loadVertexData(IWineD3DStateBlockImpl *stateblock, WineDirect3DVertexStridedData *sd) {
2185 unsigned int textureNo = 0;
2186 unsigned int texture_idx = 0;
2187 UINT *offset = stateblock->streamOffset;
2188 GLint curVBO = GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT) ? -1 : 0;
2190 TRACE("Using fast vertex array code\n");
2191 /* Blend Data ---------------------------------------------- */
2192 if( (sd->u.s.blendWeights.lpData) || (sd->u.s.blendWeights.VBO) ||
2193 (sd->u.s.blendMatrixIndices.lpData) || (sd->u.s.blendMatrixIndices.VBO) ) {
2196 if (GL_SUPPORT(ARB_VERTEX_BLEND)) {
2199 glEnableClientState(GL_WEIGHT_ARRAY_ARB);
2200 checkGLcall("glEnableClientState(GL_WEIGHT_ARRAY_ARB)");
2203 TRACE("Blend %d %p %d\n", WINED3D_ATR_SIZE(sd->u.s.blendWeights.dwType),
2204 sd->u.s.blendWeights.lpData + stateblock->loadBaseVertexIndex * sd->u.s.blendWeights.dwStride, sd->u.s.blendWeights.dwStride + offset[sd->u.s.blendWeights.streamNo]);
2205 /* FIXME("TODO\n");*/
2206 /* Note dwType == float3 or float4 == 2 or 3 */
2209 /* with this on, the normals appear to be being modified,
2210 but the vertices aren't being translated as they should be
2211 Maybe the world matrix aren't being setup properly? */
2212 glVertexBlendARB(WINED3D_ATR_SIZE(sd->u.s.blendWeights.dwType) + 1);
2216 VTRACE(("glWeightPointerARB(%d, GL_FLOAT, %d, %p)\n",
2217 WINED3D_ATR_SIZE(sd->u.s.blendWeights.dwType) ,
2218 sd->u.s.blendWeights.dwStride,
2219 sd->u.s.blendWeights.lpData + stateblock->loadBaseVertexIndex * sd->u.s.blendWeights.dwStride + offset[sd->u.s.blendWeights.streamNo]));
2221 if(curVBO != sd->u.s.blendWeights.VBO) {
2222 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, sd->u.s.blendWeights.VBO));
2223 checkGLcall("glBindBufferARB");
2224 curVBO = sd->u.s.blendWeights.VBO;
2227 GL_EXTCALL(glWeightPointerARB)(
2228 WINED3D_ATR_SIZE(sd->u.s.blendWeights.dwType),
2229 WINED3D_ATR_GLTYPE(sd->u.s.blendWeights.dwType),
2230 sd->u.s.blendWeights.dwStride,
2231 sd->u.s.blendWeights.lpData + stateblock->loadBaseVertexIndex * sd->u.s.blendWeights.dwStride + offset[sd->u.s.blendWeights.streamNo]);
2233 checkGLcall("glWeightPointerARB");
2235 if((sd->u.s.blendMatrixIndices.lpData) || (sd->u.s.blendMatrixIndices.VBO)){
2236 static BOOL showfixme = TRUE;
2238 FIXME("blendMatrixIndices support\n");
2243 } else if (GL_SUPPORT(EXT_VERTEX_WEIGHTING)) {
2244 /* FIXME("TODO\n");*/
2247 GL_EXTCALL(glVertexWeightPointerEXT)(
2248 WINED3D_ATR_SIZE(sd->u.s.blendWeights.dwType),
2249 WINED3D_ATR_GLTYPE(sd->u.s.blendWeights.dwType),
2250 sd->u.s.blendWeights.dwStride,
2251 sd->u.s.blendWeights.lpData + stateblock->loadBaseVertexIndex * sd->u.s.blendWeights.dwStride);
2252 checkGLcall("glVertexWeightPointerEXT(numBlends, ...)");
2253 glEnableClientState(GL_VERTEX_WEIGHT_ARRAY_EXT);
2254 checkGLcall("glEnableClientState(GL_VERTEX_WEIGHT_ARRAY_EXT)");
2258 /* TODO: support blends in fixupVertices */
2259 FIXME("unsupported blending in openGl\n");
2262 if (GL_SUPPORT(ARB_VERTEX_BLEND)) {
2263 #if 0 /* TODO: Vertex blending */
2264 glDisable(GL_VERTEX_BLEND_ARB);
2266 TRACE("ARB_VERTEX_BLEND\n");
2267 } else if (GL_SUPPORT(EXT_VERTEX_WEIGHTING)) {
2268 TRACE(" EXT_VERTEX_WEIGHTING\n");
2269 glDisableClientState(GL_VERTEX_WEIGHT_ARRAY_EXT);
2270 checkGLcall("glDisableClientState(GL_VERTEX_WEIGHT_ARRAY_EXT)");
2275 #if 0 /* FOG ----------------------------------------------*/
2276 if (sd->u.s.fog.lpData || sd->u.s.fog.VBO) {
2278 if (GL_SUPPORT(EXT_FOG_COORD) {
2279 glEnableClientState(GL_FOG_COORDINATE_EXT);
2280 (GL_EXTCALL)(FogCoordPointerEXT)(
2281 WINED3D_ATR_GLTYPE(sd->u.s.fog.dwType),
2282 sd->u.s.fog.dwStride,
2283 sd->u.s.fog.lpData + stateblock->loadBaseVertexIndex * sd->u.s.fog.dwStride);
2285 /* don't bother falling back to 'slow' as we don't support software FOG yet. */
2286 /* FIXME: fixme once */
2287 TRACE("Hardware support for FOG is not avaiable, FOG disabled.\n");
2290 if (GL_SUPPRT(EXT_FOR_COORD) {
2291 /* make sure fog is disabled */
2292 glDisableClientState(GL_FOG_COORDINATE_EXT);
2297 #if 0 /* tangents ----------------------------------------------*/
2298 if (sd->u.s.tangent.lpData || sd->u.s.tangent.VBO ||
2299 sd->u.s.binormal.lpData || sd->u.s.binormal.VBO) {
2301 if (GL_SUPPORT(EXT_COORDINATE_FRAME) {
2302 if (sd->u.s.tangent.lpData || sd->u.s.tangent.VBO) {
2303 glEnable(GL_TANGENT_ARRAY_EXT);
2304 (GL_EXTCALL)(TangentPointerEXT)(
2305 WINED3D_ATR_GLTYPE(sd->u.s.tangent.dwType),
2306 sd->u.s.tangent.dwStride,
2307 sd->u.s.tangent.lpData + stateblock->loadBaseVertexIndex * sd->u.s.tangent.dwStride);
2309 glDisable(GL_TANGENT_ARRAY_EXT);
2311 if (sd->u.s.binormal.lpData || sd->u.s.binormal.VBO) {
2312 glEnable(GL_BINORMAL_ARRAY_EXT);
2313 (GL_EXTCALL)(BinormalPointerEXT)(
2314 WINED3D_ATR_GLTYPE(sd->u.s.binormal.dwType),
2315 sd->u.s.binormal.dwStride,
2316 sd->u.s.binormal.lpData + stateblock->loadBaseVertexIndex * sd->u.s.binormal.dwStride);
2318 glDisable(GL_BINORMAL_ARRAY_EXT);
2322 /* don't bother falling back to 'slow' as we don't support software tangents and binormals yet . */
2323 /* FIXME: fixme once */
2324 TRACE("Hardware support for tangents and binormals is not avaiable, tangents and binormals disabled.\n");
2327 if (GL_SUPPORT(EXT_COORDINATE_FRAME) {
2328 /* make sure fog is disabled */
2329 glDisable(GL_TANGENT_ARRAY_EXT);
2330 glDisable(GL_BINORMAL_ARRAY_EXT);
2335 /* Point Size ----------------------------------------------*/
2336 if (sd->u.s.pSize.lpData || sd->u.s.pSize.VBO) {
2338 /* no such functionality in the fixed function GL pipeline */
2339 TRACE("Cannot change ptSize here in openGl\n");
2340 /* TODO: Implement this function in using shaders if they are available */
2344 /* Vertex Pointers -----------------------------------------*/
2345 if (sd->u.s.position.lpData != NULL || sd->u.s.position.VBO != 0) {
2346 /* Note dwType == float3 or float4 == 2 or 3 */
2347 VTRACE(("glVertexPointer(%d, GL_FLOAT, %d, %p)\n",
2348 sd->u.s.position.dwStride,
2349 sd->u.s.position.dwType + 1,
2350 sd->u.s.position.lpData));
2352 if(curVBO != sd->u.s.position.VBO) {
2353 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, sd->u.s.position.VBO));
2354 checkGLcall("glBindBufferARB");
2355 curVBO = sd->u.s.position.VBO;
2358 /* min(WINED3D_ATR_SIZE(position),3) to Disable RHW mode as 'w' coord
2359 handling for rhw mode should not impact screen position whereas in GL it does.
2360 This may result in very slightly distored textures in rhw mode, but
2361 a very minimal different. There's always the other option of
2362 fixing the view matrix to prevent w from having any effect
2364 This only applies to user pointer sources, in VBOs the vertices are fixed up
2366 if(sd->u.s.position.VBO == 0) {
2367 glVertexPointer(3 /* min(WINED3D_ATR_SIZE(sd->u.s.position.dwType),3) */,
2368 WINED3D_ATR_GLTYPE(sd->u.s.position.dwType),
2369 sd->u.s.position.dwStride, sd->u.s.position.lpData + stateblock->loadBaseVertexIndex * sd->u.s.position.dwStride + offset[sd->u.s.position.streamNo]);
2372 WINED3D_ATR_SIZE(sd->u.s.position.dwType),
2373 WINED3D_ATR_GLTYPE(sd->u.s.position.dwType),
2374 sd->u.s.position.dwStride, sd->u.s.position.lpData + stateblock->loadBaseVertexIndex * sd->u.s.position.dwStride + offset[sd->u.s.position.streamNo]);
2376 checkGLcall("glVertexPointer(...)");
2377 glEnableClientState(GL_VERTEX_ARRAY);
2378 checkGLcall("glEnableClientState(GL_VERTEX_ARRAY)");
2381 glDisableClientState(GL_VERTEX_ARRAY);
2382 checkGLcall("glDisableClientState(GL_VERTEX_ARRAY)");
2385 /* Normals -------------------------------------------------*/
2386 if (sd->u.s.normal.lpData || sd->u.s.normal.VBO) {
2387 /* Note dwType == float3 or float4 == 2 or 3 */
2388 VTRACE(("glNormalPointer(GL_FLOAT, %d, %p)\n",
2389 sd->u.s.normal.dwStride,
2390 sd->u.s.normal.lpData));
2391 if(curVBO != sd->u.s.normal.VBO) {
2392 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, sd->u.s.normal.VBO));
2393 checkGLcall("glBindBufferARB");
2394 curVBO = sd->u.s.normal.VBO;
2397 WINED3D_ATR_GLTYPE(sd->u.s.normal.dwType),
2398 sd->u.s.normal.dwStride,
2399 sd->u.s.normal.lpData + stateblock->loadBaseVertexIndex * sd->u.s.normal.dwStride + offset[sd->u.s.normal.streamNo]);
2400 checkGLcall("glNormalPointer(...)");
2401 glEnableClientState(GL_NORMAL_ARRAY);
2402 checkGLcall("glEnableClientState(GL_NORMAL_ARRAY)");
2405 glDisableClientState(GL_NORMAL_ARRAY);
2406 checkGLcall("glDisableClientState(GL_NORMAL_ARRAY)");
2407 glNormal3f(0, 0, 1);
2408 checkGLcall("glNormal3f(0, 0, 1)");
2411 /* Diffuse Colour --------------------------------------------*/
2412 /* WARNING: Data here MUST be in RGBA format, so cannot */
2413 /* go directly into fast mode from app pgm, because */
2414 /* directx requires data in BGRA format. */
2415 /* currently fixupVertices swizels the format, but this isn't */
2416 /* very practical when using VBOS */
2417 /* NOTE: Unless we write a vertex shader to swizel the colour */
2418 /* , or the user doesn't care and wants the speed advantage */
2420 if (sd->u.s.diffuse.lpData || sd->u.s.diffuse.VBO) {
2421 /* Note dwType == float3 or float4 == 2 or 3 */
2422 VTRACE(("glColorPointer(4, GL_UNSIGNED_BYTE, %d, %p)\n",
2423 sd->u.s.diffuse.dwStride,
2424 sd->u.s.diffuse.lpData));
2426 if(curVBO != sd->u.s.diffuse.VBO) {
2427 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, sd->u.s.diffuse.VBO));
2428 checkGLcall("glBindBufferARB");
2429 curVBO = sd->u.s.diffuse.VBO;
2431 glColorPointer(4, GL_UNSIGNED_BYTE,
2432 sd->u.s.diffuse.dwStride,
2433 sd->u.s.diffuse.lpData + stateblock->loadBaseVertexIndex * sd->u.s.diffuse.dwStride + offset[sd->u.s.diffuse.streamNo]);
2434 checkGLcall("glColorPointer(4, GL_UNSIGNED_BYTE, ...)");
2435 glEnableClientState(GL_COLOR_ARRAY);
2436 checkGLcall("glEnableClientState(GL_COLOR_ARRAY)");
2439 glDisableClientState(GL_COLOR_ARRAY);
2440 checkGLcall("glDisableClientState(GL_COLOR_ARRAY)");
2441 glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
2442 checkGLcall("glColor4f(1, 1, 1, 1)");
2445 /* Specular Colour ------------------------------------------*/
2446 if (sd->u.s.specular.lpData || sd->u.s.specular.VBO) {
2447 TRACE("setting specular colour\n");
2448 /* Note dwType == float3 or float4 == 2 or 3 */
2449 VTRACE(("glSecondaryColorPointer(4, GL_UNSIGNED_BYTE, %d, %p)\n",
2450 sd->u.s.specular.dwStride,
2451 sd->u.s.specular.lpData));
2452 if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
2453 if(curVBO != sd->u.s.specular.VBO) {
2454 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, sd->u.s.specular.VBO));
2455 checkGLcall("glBindBufferARB");
2456 curVBO = sd->u.s.specular.VBO;
2458 GL_EXTCALL(glSecondaryColorPointerEXT)(4, GL_UNSIGNED_BYTE,
2459 sd->u.s.specular.dwStride,
2460 sd->u.s.specular.lpData + stateblock->loadBaseVertexIndex * sd->u.s.specular.dwStride + offset[sd->u.s.specular.streamNo]);
2461 vcheckGLcall("glSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, ...)");
2462 glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
2463 vcheckGLcall("glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
2466 /* Missing specular color is not critical, no warnings */
2467 VTRACE(("Specular colour is not supported in this GL implementation\n"));
2471 if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
2473 glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
2474 checkGLcall("glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
2475 GL_EXTCALL(glSecondaryColor3fEXT)(0, 0, 0);
2476 checkGLcall("glSecondaryColor3fEXT(0, 0, 0)");
2479 /* Missing specular color is not critical, no warnings */
2480 VTRACE(("Specular colour is not supported in this GL implementation\n"));
2484 /* Texture coords -------------------------------------------*/
2486 for (textureNo = 0, texture_idx = 0; textureNo < GL_LIMITS(texture_stages); ++textureNo) {
2487 /* The code below uses glClientActiveTexture and glMultiTexCoord* which are all part of the GL_ARB_multitexture extension. */
2488 /* Abort if we don't support the extension. */
2489 if (!GL_SUPPORT(ARB_MULTITEXTURE)) {
2490 FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
2494 if (/*!GL_SUPPORT(NV_REGISTER_COMBINERS) || stateblock->textures[textureNo]*/ TRUE) {
2495 /* Select the correct texture stage */
2496 GL_EXTCALL(glClientActiveTextureARB(GL_TEXTURE0_ARB + texture_idx));
2499 if (stateblock->textures[textureNo] != NULL) {
2500 int coordIdx = stateblock->textureState[textureNo][WINED3DTSS_TEXCOORDINDEX];
2502 if (coordIdx >= MAX_TEXTURES) {
2503 VTRACE(("tex: %d - Skip tex coords, as being system generated\n", textureNo));
2504 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
2505 GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + texture_idx, 0, 0, 0, 1));
2507 } else if (sd->u.s.texCoords[coordIdx].lpData == NULL && sd->u.s.texCoords[coordIdx].VBO == 0) {
2508 VTRACE(("Bound texture but no texture coordinates supplied, so skipping\n"));
2509 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
2510 GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + texture_idx, 0, 0, 0, 1));
2513 TRACE("Setting up texture %u, idx %d, cordindx %u, data %p\n",
2514 textureNo, texture_idx, coordIdx, sd->u.s.texCoords[coordIdx].lpData);
2515 if(curVBO != sd->u.s.texCoords[coordIdx].VBO) {
2516 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, sd->u.s.texCoords[coordIdx].VBO));
2517 checkGLcall("glBindBufferARB");
2518 curVBO = sd->u.s.texCoords[coordIdx].VBO;
2520 /* The coords to supply depend completely on the fvf / vertex shader */
2522 WINED3D_ATR_SIZE(sd->u.s.texCoords[coordIdx].dwType),
2523 WINED3D_ATR_GLTYPE(sd->u.s.texCoords[coordIdx].dwType),
2524 sd->u.s.texCoords[coordIdx].dwStride,
2525 sd->u.s.texCoords[coordIdx].lpData + stateblock->loadBaseVertexIndex * sd->u.s.texCoords[coordIdx].dwStride + offset[sd->u.s.texCoords[coordIdx].streamNo]);
2526 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
2528 } else if (!GL_SUPPORT(NV_REGISTER_COMBINERS)) {
2529 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
2530 GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + textureNo, 0, 0, 0, 1));
2532 if (/*!GL_SUPPORT(NV_REGISTER_COMBINERS) || stateblock->textures[textureNo]*/ TRUE) ++texture_idx;
2534 if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
2535 for (textureNo = texture_idx; textureNo < GL_LIMITS(textures); ++textureNo) {
2536 GL_EXTCALL(glClientActiveTextureARB(GL_TEXTURE0_ARB + textureNo));
2537 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
2538 GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + textureNo, 0, 0, 0, 1));
2543 inline void drawPrimitiveTraceDataLocations(
2544 WineDirect3DVertexStridedData *dataLocations) {
2546 /* Dump out what parts we have supplied */
2547 TRACE("Strided Data:\n");
2548 TRACE_STRIDED((dataLocations), position);
2549 TRACE_STRIDED((dataLocations), blendWeights);
2550 TRACE_STRIDED((dataLocations), blendMatrixIndices);
2551 TRACE_STRIDED((dataLocations), normal);
2552 TRACE_STRIDED((dataLocations), pSize);
2553 TRACE_STRIDED((dataLocations), diffuse);
2554 TRACE_STRIDED((dataLocations), specular);
2555 TRACE_STRIDED((dataLocations), texCoords[0]);
2556 TRACE_STRIDED((dataLocations), texCoords[1]);
2557 TRACE_STRIDED((dataLocations), texCoords[2]);
2558 TRACE_STRIDED((dataLocations), texCoords[3]);
2559 TRACE_STRIDED((dataLocations), texCoords[4]);
2560 TRACE_STRIDED((dataLocations), texCoords[5]);
2561 TRACE_STRIDED((dataLocations), texCoords[6]);
2562 TRACE_STRIDED((dataLocations), texCoords[7]);
2563 TRACE_STRIDED((dataLocations), position2);
2564 TRACE_STRIDED((dataLocations), normal2);
2565 TRACE_STRIDED((dataLocations), tangent);
2566 TRACE_STRIDED((dataLocations), binormal);
2567 TRACE_STRIDED((dataLocations), tessFactor);
2568 TRACE_STRIDED((dataLocations), fog);
2569 TRACE_STRIDED((dataLocations), depth);
2570 TRACE_STRIDED((dataLocations), sample);
2575 /* Helper for vertexdeclaration() */
2576 static inline void handleStreams(IWineD3DStateBlockImpl *stateblock, BOOL useVertexShaderFunction, WineD3DContext *context) {
2577 IWineD3DDeviceImpl *device = stateblock->wineD3DDevice;
2579 WineDirect3DVertexStridedData *dataLocations = &device->strided_streams;
2581 if(device->up_strided) {
2582 /* Note: this is a ddraw fixed-function code path */
2583 TRACE("================ Strided Input ===================\n");
2584 memcpy(dataLocations, device->up_strided, sizeof(*dataLocations));
2587 drawPrimitiveTraceDataLocations(dataLocations);
2589 } else if (stateblock->vertexDecl || stateblock->vertexShader) {
2590 /* Note: This is a fixed function or shader codepath.
2591 * This means it must handle both types of strided data.
2592 * Shaders must go through here to zero the strided data, even if they
2593 * don't set any declaration at all
2595 TRACE("================ Vertex Declaration ===================\n");
2596 memset(dataLocations, 0, sizeof(*dataLocations));
2598 if (stateblock->vertexDecl != NULL ||
2599 ((IWineD3DVertexShaderImpl *)stateblock->vertexShader)->vertexDeclaration != NULL) {
2601 primitiveDeclarationConvertToStridedData((IWineD3DDevice *) device, useVertexShaderFunction,
2602 dataLocations, &fixup);
2605 /* Note: This codepath is not reachable from d3d9 (see fvf->decl9 conversion)
2606 * It is reachable through d3d8, but only for fixed-function.
2607 * It will not work properly for shaders.
2609 TRACE("================ FVF ===================\n");
2610 memset(dataLocations, 0, sizeof(*dataLocations));
2611 primitiveConvertToStridedData((IWineD3DDevice *) device, dataLocations, &fixup);
2613 drawPrimitiveTraceDataLocations(dataLocations);
2617 /* Unload the old arrays before loading the new ones to get old junk out */
2618 if(context->numberedArraysLoaded) {
2619 unloadNumberedArrays(stateblock);
2620 context->numberedArraysLoaded = FALSE;
2622 if(context->namedArraysLoaded) {
2623 unloadVertexData(stateblock);
2624 context->namedArraysLoaded = FALSE;
2627 if(useVertexShaderFunction) {
2628 TRACE("Loading numbered arrays\n");
2629 loadNumberedArrays(stateblock, dataLocations);
2630 device->useDrawStridedSlow = FALSE;
2631 context->numberedArraysLoaded = TRUE;
2633 (dataLocations->u.s.pSize.lpData == NULL &&
2634 dataLocations->u.s.diffuse.lpData == NULL &&
2635 dataLocations->u.s.specular.lpData == NULL)) {
2636 /* Load the vertex data using named arrays */
2637 TRACE("Loading vertex data\n");
2638 loadVertexData(stateblock, dataLocations);
2639 device->useDrawStridedSlow = FALSE;
2640 context->namedArraysLoaded = TRUE;
2642 TRACE("Not loading vertex data\n");
2643 device->useDrawStridedSlow = TRUE;
2646 /* Generate some fixme's if unsupported functionality is being used */
2647 #define BUFFER_OR_DATA(_attribute) dataLocations->u.s._attribute.lpData
2648 /* TODO: Either support missing functionality in fixupVertices or by creating a shader to replace the pipeline. */
2649 if (!useVertexShaderFunction && (BUFFER_OR_DATA(blendMatrixIndices) || BUFFER_OR_DATA(blendWeights))) {
2650 FIXME("Blending data is only valid with vertex shaders %p %p\n",dataLocations->u.s.blendWeights.lpData,dataLocations->u.s.blendWeights.lpData);
2652 if (!useVertexShaderFunction && (BUFFER_OR_DATA(position2) || BUFFER_OR_DATA(normal2))) {
2653 FIXME("Tweening is only valid with vertex shaders\n");
2655 if (!useVertexShaderFunction && (BUFFER_OR_DATA(tangent) || BUFFER_OR_DATA(binormal))) {
2656 FIXME("Tangent and binormal bump mapping is only valid with vertex shaders\n");
2658 if (!useVertexShaderFunction && (BUFFER_OR_DATA(tessFactor) || BUFFER_OR_DATA(fog) || BUFFER_OR_DATA(depth) || BUFFER_OR_DATA(sample))) {
2659 FIXME("Extended attributes are only valid with vertex shaders\n");
2661 #undef BUFFER_OR_DATA
2664 static void vertexdeclaration(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
2665 BOOL useVertexShaderFunction = FALSE, updateFog = FALSE;
2667 /* Some stuff is in the device until we have per context tracking */
2668 IWineD3DDeviceImpl *device = stateblock->wineD3DDevice;
2669 BOOL wasrhw = context->last_was_rhw;
2671 /* Shaders can be implemented using ARB_PROGRAM, GLSL, or software -
2672 * here simply check whether a shader was set, or the user disabled shaders
2674 if (device->vs_selected_mode != SHADER_NONE && stateblock->vertexShader &&
2675 ((IWineD3DVertexShaderImpl *)stateblock->vertexShader)->baseShader.function != NULL) {
2676 useVertexShaderFunction = TRUE;
2678 if(((IWineD3DVertexShaderImpl *)stateblock->vertexShader)->usesFog != context->last_was_foggy_shader) {
2681 } else if(context->last_was_foggy_shader) {
2685 handleStreams(stateblock, useVertexShaderFunction, context);
2687 /* Do I have to use ? TRUE : FALSE ? Or can I rely on 15==15 being equal to TRUE(=1)? */
2688 transformed = ((device->strided_streams.u.s.position.lpData != NULL ||
2689 device->strided_streams.u.s.position.VBO != 0) &&
2690 device->strided_streams.u.s.position_transformed) ? TRUE : FALSE;
2692 if(transformed != context->last_was_rhw && !useVertexShaderFunction) {
2696 /* Reapply lighting if it is not sheduled for reapplication already */
2697 if(!isStateDirty(context, STATE_RENDER(WINED3DRS_LIGHTING))) {
2698 state_lighting(STATE_RENDER(WINED3DRS_LIGHTING), stateblock, context);
2701 if (!useVertexShaderFunction && transformed) {
2702 context->last_was_rhw = TRUE;
2705 /* Untransformed, so relies on the view and projection matrices */
2706 context->last_was_rhw = FALSE;
2707 /* This turns off the Z scale trick to 'disable' viewport frustum clipping in rhw mode*/
2708 device->untransformed = TRUE;
2710 /* Todo for sw shaders: Vertex Shader output is already transformed, so set up identity matrices
2711 * Not needed as long as only hw shaders are supported
2714 /* This sets the shader output position correction constants.
2715 * TODO: Move to the viewport state
2717 if (useVertexShaderFunction) {
2718 device->posFixup[1] = device->render_offscreen ? -1.0 : 1.0;
2722 /* Don't have to apply the matrices when vertex shaders are used. When vshaders are turned
2723 * off this function will be called again anyway to make sure they're properly set
2725 if(!useVertexShaderFunction) {
2726 /* TODO: Move this mainly to the viewport state and only apply when the vp has changed
2727 * or transformed / untransformed was switched
2729 if(wasrhw != context->last_was_rhw &&
2730 !isStateDirty(context, STATE_TRANSFORM(WINED3DTS_PROJECTION)) &&
2731 !isStateDirty(context, STATE_VIEWPORT)) {
2732 transform_projection(STATE_TRANSFORM(WINED3DTS_PROJECTION), stateblock, context);
2734 /* World matrix needs reapplication here only if we're switching between rhw and non-rhw
2737 * If a vertex shader is used, the world matrix changed and then vertex shader unbound
2738 * this check will fail and the matrix not applied again. This is OK because a simple
2739 * world matrix change reapplies the matrix - These checks here are only to satisfy the
2740 * needs of the vertex declaration.
2742 * World and view matrix go into the same gl matrix, so only apply them when neither is
2745 if(transformed != wasrhw &&
2746 !isStateDirty(context, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0))) &&
2747 !isStateDirty(context, STATE_TRANSFORM(WINED3DTS_VIEW))) {
2748 transform_world(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), stateblock, context);
2751 if(!isStateDirty(context, STATE_RENDER(WINED3DRS_COLORVERTEX))) {
2752 state_colormat(STATE_RENDER(WINED3DRS_COLORVERTEX), stateblock, context);
2755 /* We compile the shader here because we need the vertex declaration
2756 * in order to determine if we need to do any swizzling for D3DCOLOR
2757 * registers. If the shader is already compiled this call will do nothing. */
2758 IWineD3DVertexShader_CompileShader(stateblock->vertexShader);
2761 if(useVertexShaderFunction || context->last_was_vshader) {
2762 BOOL usePixelShaderFunction = device->ps_selected_mode != SHADER_NONE &&
2763 stateblock->pixelShader &&
2764 ((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.function;
2766 /* Vertex and pixel shaders are applied together for now, so let the last dirty state do the
2769 if(!isStateDirty(context, STATE_PIXELSHADER)) {
2770 device->shader_backend->shader_select((IWineD3DDevice *) device, usePixelShaderFunction, useVertexShaderFunction);
2772 if(!isStateDirty(context, STATE_VERTEXSHADERCONSTANT) && (useVertexShaderFunction || usePixelShaderFunction)) {
2773 shaderconstant(STATE_VERTEXSHADERCONSTANT, stateblock, context);
2776 context->last_was_vshader = useVertexShaderFunction;
2780 state_fog(STATE_RENDER(WINED3DRS_FOGENABLE), stateblock, context);
2784 static void viewport(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
2785 glDepthRange(stateblock->viewport.MinZ, stateblock->viewport.MaxZ);
2786 checkGLcall("glDepthRange");
2787 /* Note: GL requires lower left, DirectX supplies upper left */
2788 /* TODO: replace usage of renderTarget with context management */
2789 glViewport(stateblock->viewport.X,
2790 (((IWineD3DSurfaceImpl *)stateblock->wineD3DDevice->render_targets[0])->currentDesc.Height - (stateblock->viewport.Y + stateblock->viewport.Height)),
2791 stateblock->viewport.Width, stateblock->viewport.Height);
2793 checkGLcall("glViewport");
2795 stateblock->wineD3DDevice->posFixup[2] = 0.9 / stateblock->viewport.Width;
2796 stateblock->wineD3DDevice->posFixup[3] = -0.9 / stateblock->viewport.Height;
2797 if(!isStateDirty(context, STATE_TRANSFORM(D3DTS_PROJECTION))) {
2798 transform_projection(STATE_TRANSFORM(D3DTS_PROJECTION), stateblock, context);
2803 const struct StateEntry StateTable[] =
2805 /* State name representative, apply function */
2806 { /* 0, Undefined */ 0, state_undefined },
2807 { /* 1, WINED3DRS_TEXTUREHANDLE */ 0 /* Handled in ddraw */, state_undefined },
2808 { /* 2, WINED3DRS_ANTIALIAS */ STATE_RENDER(WINED3DRS_ANTIALIAS), state_antialias },
2809 { /* 3, WINED3DRS_TEXTUREADDRESS */ 0 /* Handled in ddraw */, state_undefined },
2810 { /* 4, WINED3DRS_TEXTUREPERSPECTIVE */ STATE_RENDER(WINED3DRS_TEXTUREPERSPECTIVE), state_perspective },
2811 { /* 5, WINED3DRS_WRAPU */ STATE_RENDER(WINED3DRS_WRAPU), state_wrapu },
2812 { /* 6, WINED3DRS_WRAPV */ STATE_RENDER(WINED3DRS_WRAPV), state_wrapv },
2813 { /* 7, WINED3DRS_ZENABLE */ STATE_RENDER(WINED3DRS_ZENABLE), state_zenable },
2814 { /* 8, WINED3DRS_FILLMODE */ STATE_RENDER(WINED3DRS_FILLMODE), state_fillmode },
2815 { /* 9, WINED3DRS_SHADEMODE */ STATE_RENDER(WINED3DRS_SHADEMODE), state_shademode },
2816 { /* 10, WINED3DRS_LINEPATTERN */ STATE_RENDER(WINED3DRS_LINEPATTERN), state_linepattern },
2817 { /* 11, WINED3DRS_MONOENABLE */ STATE_RENDER(WINED3DRS_MONOENABLE), state_monoenable },
2818 { /* 12, WINED3DRS_ROP2 */ STATE_RENDER(WINED3DRS_ROP2), state_rop2 },
2819 { /* 13, WINED3DRS_PLANEMASK */ STATE_RENDER(WINED3DRS_PLANEMASK), state_planemask },
2820 { /* 14, WINED3DRS_ZWRITEENABLE */ STATE_RENDER(WINED3DRS_ZWRITEENABLE), state_zwritenable },
2821 { /* 15, WINED3DRS_ALPHATESTENABLE */ STATE_RENDER(WINED3DRS_ALPHATESTENABLE), state_alpha },
2822 { /* 16, WINED3DRS_LASTPIXEL */ STATE_RENDER(WINED3DRS_LASTPIXEL), state_lastpixel },
2823 { /* 17, WINED3DRS_TEXTUREMAG */ 0 /* Handled in ddraw */, state_undefined },
2824 { /* 18, WINED3DRS_TEXTUREMIN */ 0 /* Handled in ddraw */, state_undefined },
2825 { /* 19, WINED3DRS_SRCBLEND */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), state_blend },
2826 { /* 20, WINED3DRS_DESTBLEND */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), state_blend },
2827 { /* 21, WINED3DRS_TEXTUREMAPBLEND */ 0 /* Handled in ddraw */, state_undefined },
2828 { /* 22, WINED3DRS_CULLMODE */ STATE_RENDER(WINED3DRS_CULLMODE), state_cullmode },
2829 { /* 23, WINED3DRS_ZFUNC */ STATE_RENDER(WINED3DRS_ZFUNC), state_zfunc },
2830 { /* 24, WINED3DRS_ALPHAREF */ STATE_RENDER(WINED3DRS_ALPHATESTENABLE), state_alpha },
2831 { /* 25, WINED3DRS_ALPHAFUNC */ STATE_RENDER(WINED3DRS_ALPHATESTENABLE), state_alpha },
2832 { /* 26, WINED3DRS_DITHERENABLE */ STATE_RENDER(WINED3DRS_DITHERENABLE), state_ditherenable },
2833 { /* 27, WINED3DRS_ALPHABLENDENABLE */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), state_blend },
2834 { /* 28, WINED3DRS_FOGENABLE */ STATE_RENDER(WINED3DRS_FOGENABLE), state_fog },
2835 { /* 29, WINED3DRS_SPECULARENABLE */ STATE_RENDER(WINED3DRS_SPECULARENABLE), state_specularenable},
2836 { /* 30, WINED3DRS_ZVISIBLE */ 0 /* Not supported according to the msdn */, state_nogl },
2837 { /* 31, WINED3DRS_SUBPIXEL */ STATE_RENDER(WINED3DRS_SUBPIXEL), state_subpixel },
2838 { /* 32, WINED3DRS_SUBPIXELX */ STATE_RENDER(WINED3DRS_SUBPIXELX), state_subpixelx },
2839 { /* 33, WINED3DRS_STIPPLEDALPHA */ STATE_RENDER(WINED3DRS_STIPPLEDALPHA), state_stippledalpha },
2840 { /* 34, WINED3DRS_FOGCOLOR */ STATE_RENDER(WINED3DRS_FOGCOLOR), state_fogcolor },
2841 { /* 35, WINED3DRS_FOGTABLEMODE */ STATE_RENDER(WINED3DRS_FOGENABLE), state_fog },
2842 { /* 36, WINED3DRS_FOGSTART */ STATE_RENDER(WINED3DRS_FOGENABLE), state_fog },
2843 { /* 37, WINED3DRS_FOGEND */ STATE_RENDER(WINED3DRS_FOGENABLE), state_fog },
2844 { /* 38, WINED3DRS_FOGDENSITY */ STATE_RENDER(WINED3DRS_FOGDENSITY), state_fogdensity },
2845 { /* 39, WINED3DRS_STIPPLEENABLE */ STATE_RENDER(WINED3DRS_STIPPLEENABLE), state_stippleenable },
2846 { /* 40, WINED3DRS_EDGEANTIALIAS */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), state_blend },
2847 { /* 41, WINED3DRS_COLORKEYENABLE */ STATE_RENDER(WINED3DRS_ALPHATESTENABLE), state_alpha },
2848 { /* 42, undefined */ 0, state_undefined },
2849 { /* 43, WINED3DRS_BORDERCOLOR */ STATE_RENDER(WINED3DRS_BORDERCOLOR), state_bordercolor },
2850 { /* 44, WINED3DRS_TEXTUREADDRESSU */ 0, /* Handled in ddraw */ state_undefined },
2851 { /* 45, WINED3DRS_TEXTUREADDRESSV */ 0, /* Handled in ddraw */ state_undefined },
2852 { /* 46, WINED3DRS_MIPMAPLODBIAS */ STATE_RENDER(WINED3DRS_MIPMAPLODBIAS), state_mipmaplodbias },
2853 { /* 47, WINED3DRS_ZBIAS */ STATE_RENDER(WINED3DRS_ZBIAS), state_zbias },
2854 { /* 48, WINED3DRS_RANGEFOGENABLE */ 0, state_nogl },
2855 { /* 49, WINED3DRS_ANISOTROPY */ STATE_RENDER(WINED3DRS_ANISOTROPY), state_anisotropy },
2856 { /* 50, WINED3DRS_FLUSHBATCH */ STATE_RENDER(WINED3DRS_FLUSHBATCH), state_flushbatch },
2857 { /* 51, WINED3DRS_TRANSLUCENTSORTINDEPENDENT */ STATE_RENDER(WINED3DRS_TRANSLUCENTSORTINDEPENDENT), state_translucentsi },
2858 { /* 52, WINED3DRS_STENCILENABLE */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2859 { /* 53, WINED3DRS_STENCILFAIL */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2860 { /* 54, WINED3DRS_STENCILZFAIL */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2861 { /* 55, WINED3DRS_STENCILPASS */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2862 { /* 56, WINED3DRS_STENCILFUNC */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2863 { /* 57, WINED3DRS_STENCILREF */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2864 { /* 58, WINED3DRS_STENCILMASK */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2865 { /* 59, WINED3DRS_STENCILWRITEMASK */ STATE_RENDER(WINED3DRS_STENCILWRITEMASK), state_stencilwrite },
2866 { /* 60, WINED3DRS_TEXTUREFACTOR */ STATE_RENDER(WINED3DRS_TEXTUREFACTOR), state_texfactor },
2867 { /* 61, Undefined */ 0, state_undefined },
2868 { /* 62, Undefined */ 0, state_undefined },
2869 { /* 63, Undefined */ 0, state_undefined },
2870 { /* 64, WINED3DRS_STIPPLEPATTERN00 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2871 { /* 65, WINED3DRS_STIPPLEPATTERN01 */ 0 /* Obsolete, should he handled by ddraw */, state_undefined },
2872 { /* 66, WINED3DRS_STIPPLEPATTERN02 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2873 { /* 67, WINED3DRS_STIPPLEPATTERN03 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2874 { /* 68, WINED3DRS_STIPPLEPATTERN04 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2875 { /* 69, WINED3DRS_STIPPLEPATTERN05 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2876 { /* 70, WINED3DRS_STIPPLEPATTERN06 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2877 { /* 71, WINED3DRS_STIPPLEPATTERN07 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2878 { /* 72, WINED3DRS_STIPPLEPATTERN08 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2879 { /* 73, WINED3DRS_STIPPLEPATTERN09 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2880 { /* 74, WINED3DRS_STIPPLEPATTERN10 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2881 { /* 75, WINED3DRS_STIPPLEPATTERN11 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2882 { /* 76, WINED3DRS_STIPPLEPATTERN12 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2883 { /* 77, WINED3DRS_STIPPLEPATTERN13 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2884 { /* 78, WINED3DRS_STIPPLEPATTERN14 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2885 { /* 79, WINED3DRS_STIPPLEPATTERN15 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2886 { /* 80, WINED3DRS_STIPPLEPATTERN16 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2887 { /* 81, WINED3DRS_STIPPLEPATTERN17 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2888 { /* 82, WINED3DRS_STIPPLEPATTERN18 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2889 { /* 83, WINED3DRS_STIPPLEPATTERN19 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2890 { /* 84, WINED3DRS_STIPPLEPATTERN20 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2891 { /* 85, WINED3DRS_STIPPLEPATTERN21 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2892 { /* 86, WINED3DRS_STIPPLEPATTERN22 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2893 { /* 87, WINED3DRS_STIPPLEPATTERN23 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2894 { /* 88, WINED3DRS_STIPPLEPATTERN24 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2895 { /* 89, WINED3DRS_STIPPLEPATTERN25 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2896 { /* 90, WINED3DRS_STIPPLEPATTERN26 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2897 { /* 91, WINED3DRS_STIPPLEPATTERN27 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2898 { /* 92, WINED3DRS_STIPPLEPATTERN28 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2899 { /* 93, WINED3DRS_STIPPLEPATTERN29 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2900 { /* 94, WINED3DRS_STIPPLEPATTERN30 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2901 { /* 95, WINED3DRS_STIPPLEPATTERN31 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
2902 { /* 96, Undefined */ 0, state_undefined },
2903 { /* 97, Undefined */ 0, state_undefined },
2904 { /* 98, Undefined */ 0, state_undefined },
2905 { /* 99, Undefined */ 0, state_undefined },
2906 { /*100, Undefined */ 0, state_undefined },
2907 { /*101, Undefined */ 0, state_undefined },
2908 { /*102, Undefined */ 0, state_undefined },
2909 { /*103, Undefined */ 0, state_undefined },
2910 { /*104, Undefined */ 0, state_undefined },
2911 { /*105, Undefined */ 0, state_undefined },
2912 { /*106, Undefined */ 0, state_undefined },
2913 { /*107, Undefined */ 0, state_undefined },
2914 { /*108, Undefined */ 0, state_undefined },
2915 { /*109, Undefined */ 0, state_undefined },
2916 { /*110, Undefined */ 0, state_undefined },
2917 { /*111, Undefined */ 0, state_undefined },
2918 { /*112, Undefined */ 0, state_undefined },
2919 { /*113, Undefined */ 0, state_undefined },
2920 { /*114, Undefined */ 0, state_undefined },
2921 { /*115, Undefined */ 0, state_undefined },
2922 { /*116, Undefined */ 0, state_undefined },
2923 { /*117, Undefined */ 0, state_undefined },
2924 { /*118, Undefined */ 0, state_undefined },
2925 { /*119, Undefined */ 0, state_undefined },
2926 { /*120, Undefined */ 0, state_undefined },
2927 { /*121, Undefined */ 0, state_undefined },
2928 { /*122, Undefined */ 0, state_undefined },
2929 { /*123, Undefined */ 0, state_undefined },
2930 { /*124, Undefined */ 0, state_undefined },
2931 { /*125, Undefined */ 0, state_undefined },
2932 { /*126, Undefined */ 0, state_undefined },
2933 { /*127, Undefined */ 0, state_undefined },
2935 { /*128, WINED3DRS_WRAP0 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2936 { /*129, WINED3DRS_WRAP1 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2937 { /*130, WINED3DRS_WRAP2 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2938 { /*131, WINED3DRS_WRAP3 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2939 { /*132, WINED3DRS_WRAP4 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2940 { /*133, WINED3DRS_WRAP5 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2941 { /*134, WINED3DRS_WRAP6 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2942 { /*135, WINED3DRS_WRAP7 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
2943 { /*136, WINED3DRS_CLIPPING */ STATE_RENDER(WINED3DRS_CLIPPING), state_clipping },
2944 { /*137, WINED3DRS_LIGHTING */ STATE_RENDER(WINED3DRS_LIGHTING), state_lighting },
2945 { /*138, WINED3DRS_EXTENTS */ STATE_RENDER(WINED3DRS_EXTENTS), state_extents },
2946 { /*139, WINED3DRS_AMBIENT */ STATE_RENDER(WINED3DRS_AMBIENT), state_ambient },
2947 { /*140, WINED3DRS_FOGVERTEXMODE */ STATE_RENDER(WINED3DRS_FOGENABLE), state_fog },
2948 { /*141, WINED3DRS_COLORVERTEX */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat },
2949 { /*142, WINED3DRS_LOCALVIEWER */ STATE_RENDER(WINED3DRS_LOCALVIEWER), state_localviewer },
2950 { /*143, WINED3DRS_NORMALIZENORMALS */ STATE_RENDER(WINED3DRS_NORMALIZENORMALS), state_normalize },
2951 { /*144, WINED3DRS_COLORKEYBLENDENABLE */ STATE_RENDER(WINED3DRS_COLORKEYBLENDENABLE), state_ckeyblend },
2952 { /*145, WINED3DRS_DIFFUSEMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat },
2953 { /*146, WINED3DRS_SPECULARMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat },
2954 { /*147, WINED3DRS_AMBIENTMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat },
2955 { /*148, WINED3DRS_EMISSIVEMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat },
2956 { /*149, Undefined */ 0, state_undefined },
2957 { /*150, Undefined */ 0, state_undefined },
2958 { /*151, WINED3DRS_VERTEXBLEND */ 0, state_nogl },
2959 { /*152, WINED3DRS_CLIPPLANEENABLE */ STATE_RENDER(WINED3DRS_CLIPPING), state_clipping },
2960 { /*153, WINED3DRS_SOFTWAREVERTEXPROCESSING */ 0, state_nogl },
2961 { /*154, WINED3DRS_POINTSIZE */ STATE_RENDER(WINED3DRS_POINTSIZE), state_psize },
2962 { /*155, WINED3DRS_POINTSIZE_MIN */ STATE_RENDER(WINED3DRS_POINTSIZE_MIN), state_psizemin },
2963 { /*156, WINED3DRS_POINTSPRITEENABLE */ STATE_RENDER(WINED3DRS_POINTSPRITEENABLE), state_pointsprite },
2964 { /*157, WINED3DRS_POINTSCALEENABLE */ STATE_RENDER(WINED3DRS_POINTSCALEENABLE), state_pscale },
2965 { /*158, WINED3DRS_POINTSCALE_A */ STATE_RENDER(WINED3DRS_POINTSCALEENABLE), state_pscale },
2966 { /*159, WINED3DRS_POINTSCALE_B */ STATE_RENDER(WINED3DRS_POINTSCALEENABLE), state_pscale },
2967 { /*160, WINED3DRS_POINTSCALE_C */ STATE_RENDER(WINED3DRS_POINTSCALEENABLE), state_pscale },
2968 { /*161, WINED3DRS_MULTISAMPLEANTIALIAS */ STATE_RENDER(WINED3DRS_MULTISAMPLEANTIALIAS), state_multisampleaa },
2969 { /*162, WINED3DRS_MULTISAMPLEMASK */ STATE_RENDER(WINED3DRS_MULTISAMPLEMASK), state_multisampmask },
2970 { /*163, WINED3DRS_PATCHEDGESTYLE */ STATE_RENDER(WINED3DRS_PATCHEDGESTYLE), state_patchedgestyle},
2971 { /*164, WINED3DRS_PATCHSEGMENTS */ STATE_RENDER(WINED3DRS_PATCHSEGMENTS), state_patchsegments },
2972 { /*165, WINED3DRS_DEBUGMONITORTOKEN */ STATE_RENDER(WINED3DRS_DEBUGMONITORTOKEN), state_nogl },
2973 { /*166, WINED3DRS_POINTSIZE_MAX */ STATE_RENDER(WINED3DRS_POINTSIZE_MAX), state_psizemax },
2974 { /*167, WINED3DRS_INDEXEDVERTEXBLENDENABLE */ 0, state_nogl },
2975 { /*168, WINED3DRS_COLORWRITEENABLE */ STATE_RENDER(WINED3DRS_COLORWRITEENABLE), state_colorwrite },
2976 { /*169, Undefined */ 0, state_undefined },
2977 { /*170, WINED3DRS_TWEENFACTOR */ 0, state_nogl },
2978 { /*171, WINED3DRS_BLENDOP */ STATE_RENDER(WINED3DRS_BLENDOP), state_blendop },
2979 { /*172, WINED3DRS_POSITIONDEGREE */ STATE_RENDER(WINED3DRS_POSITIONDEGREE), state_positiondegree},
2980 { /*173, WINED3DRS_NORMALDEGREE */ STATE_RENDER(WINED3DRS_NORMALDEGREE), state_normaldegree },
2981 /*172, WINED3DRS_POSITIONORDER */ /* Value assigned to 2 state names */
2982 /*173, WINED3DRS_NORMALORDER */ /* Value assigned to 2 state names */
2983 { /*174, WINED3DRS_SCISSORTESTENABLE */ STATE_RENDER(WINED3DRS_SCISSORTESTENABLE), state_scissor },
2984 { /*175, WINED3DRS_SLOPESCALEDEPTHBIAS */ STATE_RENDER(WINED3DRS_DEPTHBIAS), state_depthbias },
2985 { /*176, WINED3DRS_ANTIALIASEDLINEENABLE */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), state_blend },
2986 { /*177, undefined */ 0, state_undefined },
2987 { /*178, WINED3DRS_MINTESSELLATIONLEVEL */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation },
2988 { /*179, WINED3DRS_MAXTESSELLATIONLEVEL */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation },
2989 { /*180, WINED3DRS_ADAPTIVETESS_X */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation },
2990 { /*181, WINED3DRS_ADAPTIVETESS_Y */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation },
2991 { /*182, WINED3DRS_ADAPTIVETESS_Z */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation },
2992 { /*183, WINED3DRS_ADAPTIVETESS_W */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation },
2993 { /*184, WINED3DRS_ENABLEADAPTIVETESSELLATION */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation },
2994 { /*185, WINED3DRS_TWOSIDEDSTENCILMODE */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2995 { /*186, WINED3DRS_CCW_STENCILFAIL */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2996 { /*187, WINED3DRS_CCW_STENCILZFAIL */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2997 { /*188, WINED3DRS_CCW_STENCILPASS */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2998 { /*189, WINED3DRS_CCW_STENCILFUNC */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
2999 { /*190, WINED3DRS_COLORWRITEENABLE1 */ STATE_RENDER(WINED3DRS_COLORWRITEENABLE), state_colorwrite },
3000 { /*191, WINED3DRS_COLORWRITEENABLE2 */ STATE_RENDER(WINED3DRS_COLORWRITEENABLE), state_colorwrite },
3001 { /*192, WINED3DRS_COLORWRITEENABLE3 */ STATE_RENDER(WINED3DRS_COLORWRITEENABLE), state_colorwrite },
3002 { /*193, WINED3DRS_BLENDFACTOR */ STATE_RENDER(WINED3DRS_BLENDFACTOR), state_blendfactor },
3003 { /*194, WINED3DRS_SRGBWRITEENABLE */ STATE_RENDER(WINED3DRS_SRGBWRITEENABLE), state_srgbwrite },
3004 { /*195, WINED3DRS_DEPTHBIAS */ STATE_RENDER(WINED3DRS_DEPTHBIAS), state_depthbias },
3005 { /*196, undefined */ 0, state_undefined },
3006 { /*197, undefined */ 0, state_undefined },
3007 { /*198, WINED3DRS_WRAP8 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
3008 { /*199, WINED3DRS_WRAP9 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
3009 { /*200, WINED3DRS_WRAP10 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
3010 { /*201, WINED3DRS_WRAP11 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
3011 { /*202, WINED3DRS_WRAP12 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
3012 { /*203, WINED3DRS_WRAP13 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
3013 { /*204, WINED3DRS_WRAP14 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
3014 { /*205, WINED3DRS_WRAP15 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
3015 { /*206, WINED3DRS_SEPARATEALPHABLENDENABLE */ STATE_RENDER(WINED3DRS_SEPARATEALPHABLENDENABLE), state_seperateblend },
3016 { /*207, WINED3DRS_SRCBLENDALPHA */ STATE_RENDER(WINED3DRS_SEPARATEALPHABLENDENABLE), state_seperateblend },
3017 { /*208, WINED3DRS_DESTBLENDALPHA */ STATE_RENDER(WINED3DRS_SEPARATEALPHABLENDENABLE), state_seperateblend },
3018 { /*209, WINED3DRS_BLENDOPALPHA */ STATE_RENDER(WINED3DRS_SEPARATEALPHABLENDENABLE), state_seperateblend },
3019 /* Texture stage states */
3020 { /*0, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop },
3021 { /*0, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop },
3022 { /*0, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop },
3023 { /*0, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), tex_alphaop },
3024 { /*0, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), tex_alphaop },
3025 { /*0, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), tex_alphaop },
3026 { /*0, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop },
3027 { /*0, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop },
3028 { /*0, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop },
3029 { /*0, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop },
3030 { /*0, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(0, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
3031 { /*0, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3032 { /*0, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3033 { /*0, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3034 { /*0, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3035 { /*0, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3036 { /*0, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3037 { /*0, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3038 { /*0, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3039 { /*0, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3040 { /*0, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3041 { /*0, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
3042 { /*0, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
3043 { /*0, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE0), transform_texture },
3044 { /*0, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3045 { /*0, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop },
3046 { /*0, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), tex_alphaop },
3047 { /*0, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(0, WINED3DTSS_RESULTARG), tex_resultarg },
3048 { /*0, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3049 { /*0, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3050 { /*0, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3051 { /*0, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
3053 { /*1, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), tex_colorop },
3054 { /*1, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), tex_colorop },
3055 { /*1, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), tex_colorop },
3056 { /*1, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP), tex_alphaop },
3057 { /*1, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP), tex_alphaop },
3058 { /*1, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP), tex_alphaop },
3059 { /*1, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), tex_colorop },
3060 { /*1, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), tex_colorop },
3061 { /*1, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), tex_colorop },
3062 { /*1, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), tex_colorop },
3063 { /*1, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(1, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
3064 { /*1, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3065 { /*1, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3066 { /*1, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3067 { /*1, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3068 { /*1, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3069 { /*1, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3070 { /*1, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3071 { /*1, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3072 { /*1, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3073 { /*1, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3074 { /*1, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
3075 { /*1, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
3076 { /*1, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE1), transform_texture },
3077 { /*1, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3078 { /*1, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), tex_colorop },
3079 { /*1, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP), tex_alphaop },
3080 { /*1, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(1, WINED3DTSS_RESULTARG), tex_resultarg },
3081 { /*1, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3082 { /*1, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3083 { /*1, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3084 { /*1, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
3086 { /*2, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), tex_colorop },
3087 { /*2, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), tex_colorop },
3088 { /*2, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), tex_colorop },
3089 { /*2, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP), tex_alphaop },
3090 { /*2, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP), tex_alphaop },
3091 { /*2, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP), tex_alphaop },
3092 { /*2, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), tex_colorop },
3093 { /*2, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), tex_colorop },
3094 { /*2, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), tex_colorop },
3095 { /*2, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), tex_colorop },
3096 { /*2, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(2, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
3097 { /*2, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3098 { /*2, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3099 { /*2, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3100 { /*2, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3101 { /*2, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3102 { /*2, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3103 { /*2, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3104 { /*2, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3105 { /*2, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3106 { /*2, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3107 { /*2, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
3108 { /*2, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
3109 { /*2, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE2), transform_texture },
3110 { /*2, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3111 { /*2, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), tex_colorop },
3112 { /*2, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP), tex_alphaop },
3113 { /*2, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(2, WINED3DTSS_RESULTARG), tex_resultarg },
3114 { /*2, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3115 { /*2, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3116 { /*2, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3117 { /*2, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
3119 { /*3, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), tex_colorop },
3120 { /*3, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), tex_colorop },
3121 { /*3, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), tex_colorop },
3122 { /*3, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP), tex_alphaop },
3123 { /*3, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP), tex_alphaop },
3124 { /*3, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP), tex_alphaop },
3125 { /*3, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), tex_colorop },
3126 { /*3, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), tex_colorop },
3127 { /*3, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), tex_colorop },
3128 { /*3, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), tex_colorop },
3129 { /*3, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(3, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
3130 { /*3, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3131 { /*3, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3132 { /*3, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3133 { /*3, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3134 { /*3, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3135 { /*3, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3136 { /*3, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3137 { /*3, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3138 { /*3, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3139 { /*3, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3140 { /*3, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
3141 { /*3, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
3142 { /*3, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE3), transform_texture },
3143 { /*3, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3144 { /*3, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), tex_colorop },
3145 { /*3, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP), tex_alphaop },
3146 { /*3, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(3, WINED3DTSS_RESULTARG), tex_resultarg },
3147 { /*3, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3148 { /*3, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3149 { /*3, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3150 { /*3, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
3152 { /*4, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), tex_colorop },
3153 { /*4, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), tex_colorop },
3154 { /*4, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), tex_colorop },
3155 { /*4, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP), tex_alphaop },
3156 { /*4, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP), tex_alphaop },
3157 { /*4, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP), tex_alphaop },
3158 { /*4, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), state_undefined },
3159 { /*4, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), state_undefined },
3160 { /*4, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), state_undefined },
3161 { /*4, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), state_undefined },
3162 { /*4, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(4, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
3163 { /*4, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3164 { /*4, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3165 { /*4, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3166 { /*4, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3167 { /*4, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3168 { /*4, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3169 { /*4, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3170 { /*4, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3171 { /*4, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3172 { /*4, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3173 { /*4, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
3174 { /*4, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
3175 { /*4, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE4), transform_texture },
3176 { /*4, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3177 { /*4, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), tex_colorop },
3178 { /*4, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP), tex_alphaop },
3179 { /*4, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(4, WINED3DTSS_RESULTARG), tex_resultarg },
3180 { /*4, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3181 { /*4, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3182 { /*4, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3183 { /*4, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
3185 { /*5, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), tex_colorop },
3186 { /*5, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), tex_colorop },
3187 { /*5, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), tex_colorop },
3188 { /*5, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP), tex_alphaop },
3189 { /*5, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP), tex_alphaop },
3190 { /*5, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP), tex_alphaop },
3191 { /*5, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), tex_colorop },
3192 { /*5, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), tex_colorop },
3193 { /*5, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), tex_colorop },
3194 { /*5, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), tex_colorop },
3195 { /*5, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(5, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
3196 { /*5, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3197 { /*5, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3198 { /*5, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3199 { /*5, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3200 { /*5, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3201 { /*5, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3202 { /*5, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3203 { /*5, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3204 { /*5, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3205 { /*5, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3206 { /*5, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
3207 { /*5, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
3208 { /*5, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE5), transform_texture },
3209 { /*5, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3210 { /*5, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), tex_colorop },
3211 { /*5, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP), tex_alphaop },
3212 { /*5, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(5, WINED3DTSS_RESULTARG), tex_resultarg },
3213 { /*5, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3214 { /*5, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3215 { /*5, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3216 { /*5, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
3218 { /*6, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), tex_colorop },
3219 { /*6, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), tex_colorop },
3220 { /*6, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), tex_colorop },
3221 { /*6, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP), tex_alphaop },
3222 { /*6, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP), tex_alphaop },
3223 { /*6, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP), tex_alphaop },
3224 { /*6, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), tex_colorop },
3225 { /*6, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), tex_colorop },
3226 { /*6, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), tex_colorop },
3227 { /*6, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), tex_colorop },
3228 { /*6, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(6, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
3229 { /*6, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3230 { /*6, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3231 { /*6, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3232 { /*6, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3233 { /*6, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3234 { /*6, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3235 { /*6, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3236 { /*6, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3237 { /*6, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3238 { /*6, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3239 { /*6, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
3240 { /*6, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
3241 { /*6, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE6), transform_texture },
3242 { /*6, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3243 { /*6, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), tex_colorop },
3244 { /*6, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP), tex_alphaop },
3245 { /*6, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(6, WINED3DTSS_RESULTARG), tex_resultarg },
3246 { /*6, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3247 { /*6, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3248 { /*6, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3249 { /*6, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
3251 { /*7, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), tex_colorop },
3252 { /*7, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), tex_colorop },
3253 { /*7, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), tex_colorop },
3254 { /*7, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP), tex_alphaop },
3255 { /*7, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP), tex_alphaop },
3256 { /*7, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP), tex_alphaop },
3257 { /*7, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), tex_colorop },
3258 { /*7, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), tex_colorop },
3259 { /*7, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), tex_colorop },
3260 { /*7, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), tex_colorop },
3261 { /*7, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(7, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
3262 { /*7, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3263 { /*7, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3264 { /*7, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3265 { /*7, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3266 { /*7, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3267 { /*7, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3268 { /*7, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3269 { /*7, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3270 { /*7, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3271 { /*7, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3272 { /*7, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
3273 { /*7, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
3274 { /*7, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE7), transform_texture },
3275 { /*7, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3276 { /*7, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), tex_colorop },
3277 { /*7, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP), tex_alphaop },
3278 { /*7, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(7, WINED3DTSS_RESULTARG), tex_resultarg },
3279 { /*7, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3280 { /*7, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3281 { /*7, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3282 { /*7, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
3283 /* Sampler states */
3284 { /* 0, Sampler 0 */ STATE_SAMPLER(0), sampler },
3285 { /* 1, Sampler 1 */ STATE_SAMPLER(1), sampler },
3286 { /* 2, Sampler 2 */ STATE_SAMPLER(2), sampler },
3287 { /* 3, Sampler 3 */ STATE_SAMPLER(3), sampler },
3288 { /* 4, Sampler 3 */ STATE_SAMPLER(4), sampler },
3289 { /* 5, Sampler 5 */ STATE_SAMPLER(5), sampler },
3290 { /* 6, Sampler 6 */ STATE_SAMPLER(6), sampler },
3291 { /* 7, Sampler 7 */ STATE_SAMPLER(7), sampler },
3292 { /* 8, Sampler 8 */ STATE_SAMPLER(8), sampler },
3293 { /* 9, Sampler 9 */ STATE_SAMPLER(9), sampler },
3294 { /*10, Sampler 10 */ STATE_SAMPLER(10), sampler },
3295 { /*11, Sampler 11 */ STATE_SAMPLER(11), sampler },
3296 { /*12, Sampler 12 */ STATE_SAMPLER(12), sampler },
3297 { /*13, Sampler 13 */ STATE_SAMPLER(13), sampler },
3298 { /*14, Sampler 14 */ STATE_SAMPLER(14), sampler },
3299 { /*15, Sampler 15 */ STATE_SAMPLER(15), sampler },
3301 { /* , Pixel Shader */ STATE_PIXELSHADER, pixelshader },
3302 /* Transform states follow */
3303 { /* 1, undefined */ 0, state_undefined },
3304 { /* 2, WINED3DTS_VIEW */ STATE_TRANSFORM(WINED3DTS_VIEW), transform_view },
3305 { /* 3, WINED3DTS_PROJECTION */ STATE_TRANSFORM(WINED3DTS_PROJECTION), transform_projection},
3306 { /* 4, undefined */ 0, state_undefined },
3307 { /* 5, undefined */ 0, state_undefined },
3308 { /* 6, undefined */ 0, state_undefined },
3309 { /* 7, undefined */ 0, state_undefined },
3310 { /* 8, undefined */ 0, state_undefined },
3311 { /* 9, undefined */ 0, state_undefined },
3312 { /* 10, undefined */ 0, state_undefined },
3313 { /* 11, undefined */ 0, state_undefined },
3314 { /* 12, undefined */ 0, state_undefined },
3315 { /* 13, undefined */ 0, state_undefined },
3316 { /* 14, undefined */ 0, state_undefined },
3317 { /* 15, undefined */ 0, state_undefined },
3318 { /* 16, WINED3DTS_TEXTURE0 */ STATE_TRANSFORM(WINED3DTS_TEXTURE0), transform_texture },
3319 { /* 17, WINED3DTS_TEXTURE1 */ STATE_TRANSFORM(WINED3DTS_TEXTURE1), transform_texture },
3320 { /* 18, WINED3DTS_TEXTURE2 */ STATE_TRANSFORM(WINED3DTS_TEXTURE2), transform_texture },
3321 { /* 19, WINED3DTS_TEXTURE3 */ STATE_TRANSFORM(WINED3DTS_TEXTURE3), transform_texture },
3322 { /* 20, WINED3DTS_TEXTURE4 */ STATE_TRANSFORM(WINED3DTS_TEXTURE4), transform_texture },
3323 { /* 21, WINED3DTS_TEXTURE5 */ STATE_TRANSFORM(WINED3DTS_TEXTURE5), transform_texture },
3324 { /* 22, WINED3DTS_TEXTURE6 */ STATE_TRANSFORM(WINED3DTS_TEXTURE6), transform_texture },
3325 { /* 23, WINED3DTS_TEXTURE7 */ STATE_TRANSFORM(WINED3DTS_TEXTURE7), transform_texture },
3326 /* A huge gap between TEXTURE7 and WORLDMATRIX(0) :-( But entries are needed to catch then if a broken app sets them */
3327 { /* 24, undefined */ 0, state_undefined },
3328 { /* 25, undefined */ 0, state_undefined },
3329 { /* 26, undefined */ 0, state_undefined },
3330 { /* 27, undefined */ 0, state_undefined },
3331 { /* 28, undefined */ 0, state_undefined },
3332 { /* 29, undefined */ 0, state_undefined },
3333 { /* 30, undefined */ 0, state_undefined },
3334 { /* 31, undefined */ 0, state_undefined },
3335 { /* 32, undefined */ 0, state_undefined },
3336 { /* 33, undefined */ 0, state_undefined },
3337 { /* 34, undefined */ 0, state_undefined },
3338 { /* 35, undefined */ 0, state_undefined },
3339 { /* 36, undefined */ 0, state_undefined },
3340 { /* 37, undefined */ 0, state_undefined },
3341 { /* 38, undefined */ 0, state_undefined },
3342 { /* 39, undefined */ 0, state_undefined },
3343 { /* 40, undefined */ 0, state_undefined },
3344 { /* 41, undefined */ 0, state_undefined },
3345 { /* 42, undefined */ 0, state_undefined },
3346 { /* 43, undefined */ 0, state_undefined },
3347 { /* 44, undefined */ 0, state_undefined },
3348 { /* 45, undefined */ 0, state_undefined },
3349 { /* 46, undefined */ 0, state_undefined },
3350 { /* 47, undefined */ 0, state_undefined },
3351 { /* 48, undefined */ 0, state_undefined },
3352 { /* 49, undefined */ 0, state_undefined },
3353 { /* 50, undefined */ 0, state_undefined },
3354 { /* 51, undefined */ 0, state_undefined },
3355 { /* 52, undefined */ 0, state_undefined },
3356 { /* 53, undefined */ 0, state_undefined },
3357 { /* 54, undefined */ 0, state_undefined },
3358 { /* 55, undefined */ 0, state_undefined },
3359 { /* 56, undefined */ 0, state_undefined },
3360 { /* 57, undefined */ 0, state_undefined },
3361 { /* 58, undefined */ 0, state_undefined },
3362 { /* 59, undefined */ 0, state_undefined },
3363 { /* 60, undefined */ 0, state_undefined },
3364 { /* 61, undefined */ 0, state_undefined },
3365 { /* 62, undefined */ 0, state_undefined },
3366 { /* 63, undefined */ 0, state_undefined },
3367 { /* 64, undefined */ 0, state_undefined },
3368 { /* 65, undefined */ 0, state_undefined },
3369 { /* 66, undefined */ 0, state_undefined },
3370 { /* 67, undefined */ 0, state_undefined },
3371 { /* 68, undefined */ 0, state_undefined },
3372 { /* 69, undefined */ 0, state_undefined },
3373 { /* 70, undefined */ 0, state_undefined },
3374 { /* 71, undefined */ 0, state_undefined },
3375 { /* 72, undefined */ 0, state_undefined },
3376 { /* 73, undefined */ 0, state_undefined },
3377 { /* 74, undefined */ 0, state_undefined },
3378 { /* 75, undefined */ 0, state_undefined },
3379 { /* 76, undefined */ 0, state_undefined },
3380 { /* 77, undefined */ 0, state_undefined },
3381 { /* 78, undefined */ 0, state_undefined },
3382 { /* 79, undefined */ 0, state_undefined },
3383 { /* 80, undefined */ 0, state_undefined },
3384 { /* 81, undefined */ 0, state_undefined },
3385 { /* 82, undefined */ 0, state_undefined },
3386 { /* 83, undefined */ 0, state_undefined },
3387 { /* 84, undefined */ 0, state_undefined },
3388 { /* 85, undefined */ 0, state_undefined },
3389 { /* 86, undefined */ 0, state_undefined },
3390 { /* 87, undefined */ 0, state_undefined },
3391 { /* 88, undefined */ 0, state_undefined },
3392 { /* 89, undefined */ 0, state_undefined },
3393 { /* 90, undefined */ 0, state_undefined },
3394 { /* 91, undefined */ 0, state_undefined },
3395 { /* 92, undefined */ 0, state_undefined },
3396 { /* 93, undefined */ 0, state_undefined },
3397 { /* 94, undefined */ 0, state_undefined },
3398 { /* 95, undefined */ 0, state_undefined },
3399 { /* 96, undefined */ 0, state_undefined },
3400 { /* 97, undefined */ 0, state_undefined },
3401 { /* 98, undefined */ 0, state_undefined },
3402 { /* 99, undefined */ 0, state_undefined },
3403 { /*100, undefined */ 0, state_undefined },
3404 { /*101, undefined */ 0, state_undefined },
3405 { /*102, undefined */ 0, state_undefined },
3406 { /*103, undefined */ 0, state_undefined },
3407 { /*104, undefined */ 0, state_undefined },
3408 { /*105, undefined */ 0, state_undefined },
3409 { /*106, undefined */ 0, state_undefined },
3410 { /*107, undefined */ 0, state_undefined },
3411 { /*108, undefined */ 0, state_undefined },
3412 { /*109, undefined */ 0, state_undefined },
3413 { /*110, undefined */ 0, state_undefined },
3414 { /*111, undefined */ 0, state_undefined },
3415 { /*112, undefined */ 0, state_undefined },
3416 { /*113, undefined */ 0, state_undefined },
3417 { /*114, undefined */ 0, state_undefined },
3418 { /*115, undefined */ 0, state_undefined },
3419 { /*116, undefined */ 0, state_undefined },
3420 { /*117, undefined */ 0, state_undefined },
3421 { /*118, undefined */ 0, state_undefined },
3422 { /*119, undefined */ 0, state_undefined },
3423 { /*120, undefined */ 0, state_undefined },
3424 { /*121, undefined */ 0, state_undefined },
3425 { /*122, undefined */ 0, state_undefined },
3426 { /*123, undefined */ 0, state_undefined },
3427 { /*124, undefined */ 0, state_undefined },
3428 { /*125, undefined */ 0, state_undefined },
3429 { /*126, undefined */ 0, state_undefined },
3430 { /*127, undefined */ 0, state_undefined },
3431 { /*128, undefined */ 0, state_undefined },
3432 { /*129, undefined */ 0, state_undefined },
3433 { /*130, undefined */ 0, state_undefined },
3434 { /*131, undefined */ 0, state_undefined },
3435 { /*132, undefined */ 0, state_undefined },
3436 { /*133, undefined */ 0, state_undefined },
3437 { /*134, undefined */ 0, state_undefined },
3438 { /*135, undefined */ 0, state_undefined },
3439 { /*136, undefined */ 0, state_undefined },
3440 { /*137, undefined */ 0, state_undefined },
3441 { /*138, undefined */ 0, state_undefined },
3442 { /*139, undefined */ 0, state_undefined },
3443 { /*140, undefined */ 0, state_undefined },
3444 { /*141, undefined */ 0, state_undefined },
3445 { /*142, undefined */ 0, state_undefined },
3446 { /*143, undefined */ 0, state_undefined },
3447 { /*144, undefined */ 0, state_undefined },
3448 { /*145, undefined */ 0, state_undefined },
3449 { /*146, undefined */ 0, state_undefined },
3450 { /*147, undefined */ 0, state_undefined },
3451 { /*148, undefined */ 0, state_undefined },
3452 { /*149, undefined */ 0, state_undefined },
3453 { /*150, undefined */ 0, state_undefined },
3454 { /*151, undefined */ 0, state_undefined },
3455 { /*152, undefined */ 0, state_undefined },
3456 { /*153, undefined */ 0, state_undefined },
3457 { /*154, undefined */ 0, state_undefined },
3458 { /*155, undefined */ 0, state_undefined },
3459 { /*156, undefined */ 0, state_undefined },
3460 { /*157, undefined */ 0, state_undefined },
3461 { /*158, undefined */ 0, state_undefined },
3462 { /*159, undefined */ 0, state_undefined },
3463 { /*160, undefined */ 0, state_undefined },
3464 { /*161, undefined */ 0, state_undefined },
3465 { /*162, undefined */ 0, state_undefined },
3466 { /*163, undefined */ 0, state_undefined },
3467 { /*164, undefined */ 0, state_undefined },
3468 { /*165, undefined */ 0, state_undefined },
3469 { /*166, undefined */ 0, state_undefined },
3470 { /*167, undefined */ 0, state_undefined },
3471 { /*168, undefined */ 0, state_undefined },
3472 { /*169, undefined */ 0, state_undefined },
3473 { /*170, undefined */ 0, state_undefined },
3474 { /*171, undefined */ 0, state_undefined },
3475 { /*172, undefined */ 0, state_undefined },
3476 { /*173, undefined */ 0, state_undefined },
3477 { /*174, undefined */ 0, state_undefined },
3478 { /*175, undefined */ 0, state_undefined },
3479 { /*176, undefined */ 0, state_undefined },
3480 { /*177, undefined */ 0, state_undefined },
3481 { /*178, undefined */ 0, state_undefined },
3482 { /*179, undefined */ 0, state_undefined },
3483 { /*180, undefined */ 0, state_undefined },
3484 { /*181, undefined */ 0, state_undefined },
3485 { /*182, undefined */ 0, state_undefined },
3486 { /*183, undefined */ 0, state_undefined },
3487 { /*184, undefined */ 0, state_undefined },
3488 { /*185, undefined */ 0, state_undefined },
3489 { /*186, undefined */ 0, state_undefined },
3490 { /*187, undefined */ 0, state_undefined },
3491 { /*188, undefined */ 0, state_undefined },
3492 { /*189, undefined */ 0, state_undefined },
3493 { /*190, undefined */ 0, state_undefined },
3494 { /*191, undefined */ 0, state_undefined },
3495 { /*192, undefined */ 0, state_undefined },
3496 { /*193, undefined */ 0, state_undefined },
3497 { /*194, undefined */ 0, state_undefined },
3498 { /*195, undefined */ 0, state_undefined },
3499 { /*196, undefined */ 0, state_undefined },
3500 { /*197, undefined */ 0, state_undefined },
3501 { /*198, undefined */ 0, state_undefined },
3502 { /*199, undefined */ 0, state_undefined },
3503 { /*200, undefined */ 0, state_undefined },
3504 { /*201, undefined */ 0, state_undefined },
3505 { /*202, undefined */ 0, state_undefined },
3506 { /*203, undefined */ 0, state_undefined },
3507 { /*204, undefined */ 0, state_undefined },
3508 { /*205, undefined */ 0, state_undefined },
3509 { /*206, undefined */ 0, state_undefined },
3510 { /*207, undefined */ 0, state_undefined },
3511 { /*208, undefined */ 0, state_undefined },
3512 { /*209, undefined */ 0, state_undefined },
3513 { /*210, undefined */ 0, state_undefined },
3514 { /*211, undefined */ 0, state_undefined },
3515 { /*212, undefined */ 0, state_undefined },
3516 { /*213, undefined */ 0, state_undefined },
3517 { /*214, undefined */ 0, state_undefined },
3518 { /*215, undefined */ 0, state_undefined },
3519 { /*216, undefined */ 0, state_undefined },
3520 { /*217, undefined */ 0, state_undefined },
3521 { /*218, undefined */ 0, state_undefined },
3522 { /*219, undefined */ 0, state_undefined },
3523 { /*220, undefined */ 0, state_undefined },
3524 { /*221, undefined */ 0, state_undefined },
3525 { /*222, undefined */ 0, state_undefined },
3526 { /*223, undefined */ 0, state_undefined },
3527 { /*224, undefined */ 0, state_undefined },
3528 { /*225, undefined */ 0, state_undefined },
3529 { /*226, undefined */ 0, state_undefined },
3530 { /*227, undefined */ 0, state_undefined },
3531 { /*228, undefined */ 0, state_undefined },
3532 { /*229, undefined */ 0, state_undefined },
3533 { /*230, undefined */ 0, state_undefined },
3534 { /*231, undefined */ 0, state_undefined },
3535 { /*232, undefined */ 0, state_undefined },
3536 { /*233, undefined */ 0, state_undefined },
3537 { /*234, undefined */ 0, state_undefined },
3538 { /*235, undefined */ 0, state_undefined },
3539 { /*236, undefined */ 0, state_undefined },
3540 { /*237, undefined */ 0, state_undefined },
3541 { /*238, undefined */ 0, state_undefined },
3542 { /*239, undefined */ 0, state_undefined },
3543 { /*240, undefined */ 0, state_undefined },
3544 { /*241, undefined */ 0, state_undefined },
3545 { /*242, undefined */ 0, state_undefined },
3546 { /*243, undefined */ 0, state_undefined },
3547 { /*244, undefined */ 0, state_undefined },
3548 { /*245, undefined */ 0, state_undefined },
3549 { /*246, undefined */ 0, state_undefined },
3550 { /*247, undefined */ 0, state_undefined },
3551 { /*248, undefined */ 0, state_undefined },
3552 { /*249, undefined */ 0, state_undefined },
3553 { /*250, undefined */ 0, state_undefined },
3554 { /*251, undefined */ 0, state_undefined },
3555 { /*252, undefined */ 0, state_undefined },
3556 { /*253, undefined */ 0, state_undefined },
3557 { /*254, undefined */ 0, state_undefined },
3558 { /*255, undefined */ 0, state_undefined },
3560 { /*256, WINED3DTS_WORLDMATRIX(0) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), transform_world },
3561 { /*257, WINED3DTS_WORLDMATRIX(1) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(1)), transform_worldex },
3562 { /*258, WINED3DTS_WORLDMATRIX(2) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(2)), transform_worldex },
3563 { /*259, WINED3DTS_WORLDMATRIX(3) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(3)), transform_worldex },
3564 { /*260, WINED3DTS_WORLDMATRIX(4) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(4)), transform_worldex },
3565 { /*261, WINED3DTS_WORLDMATRIX(5) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(5)), transform_worldex },
3566 { /*262, WINED3DTS_WORLDMATRIX(6) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(6)), transform_worldex },
3567 { /*263, WINED3DTS_WORLDMATRIX(7) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(7)), transform_worldex },
3568 { /*264, WINED3DTS_WORLDMATRIX(8) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(8)), transform_worldex },
3569 { /*265, WINED3DTS_WORLDMATRIX(9) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(9)), transform_worldex },
3570 { /*266, WINED3DTS_WORLDMATRIX(10) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(10)), transform_worldex },
3571 { /*267, WINED3DTS_WORLDMATRIX(11) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(11)), transform_worldex },
3572 { /*268, WINED3DTS_WORLDMATRIX(12) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(12)), transform_worldex },
3573 { /*269, WINED3DTS_WORLDMATRIX(13) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(13)), transform_worldex },
3574 { /*270, WINED3DTS_WORLDMATRIX(14) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(14)), transform_worldex },
3575 { /*271, WINED3DTS_WORLDMATRIX(15) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(15)), transform_worldex },
3576 { /*272, WINED3DTS_WORLDMATRIX(16) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(16)), transform_worldex },
3577 { /*273, WINED3DTS_WORLDMATRIX(17) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(17)), transform_worldex },
3578 { /*274, WINED3DTS_WORLDMATRIX(18) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(18)), transform_worldex },
3579 { /*275, WINED3DTS_WORLDMATRIX(19) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(19)), transform_worldex },
3580 { /*276, WINED3DTS_WORLDMATRIX(20) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(20)), transform_worldex },
3581 { /*277, WINED3DTS_WORLDMATRIX(21) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(21)), transform_worldex },
3582 { /*278, WINED3DTS_WORLDMATRIX(22) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(22)), transform_worldex },
3583 { /*279, WINED3DTS_WORLDMATRIX(23) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(23)), transform_worldex },
3584 { /*280, WINED3DTS_WORLDMATRIX(24) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(24)), transform_worldex },
3585 { /*281, WINED3DTS_WORLDMATRIX(25) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(25)), transform_worldex },
3586 { /*282, WINED3DTS_WORLDMATRIX(26) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(26)), transform_worldex },
3587 { /*283, WINED3DTS_WORLDMATRIX(27) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(27)), transform_worldex },
3588 { /*284, WINED3DTS_WORLDMATRIX(28) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(28)), transform_worldex },
3589 { /*285, WINED3DTS_WORLDMATRIX(29) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(29)), transform_worldex },
3590 { /*286, WINED3DTS_WORLDMATRIX(30) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(30)), transform_worldex },
3591 { /*287, WINED3DTS_WORLDMATRIX(31) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(31)), transform_worldex },
3592 { /*288, WINED3DTS_WORLDMATRIX(32) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(32)), transform_worldex },
3593 { /*289, WINED3DTS_WORLDMATRIX(33) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(33)), transform_worldex },
3594 { /*290, WINED3DTS_WORLDMATRIX(34) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(34)), transform_worldex },
3595 { /*291, WINED3DTS_WORLDMATRIX(35) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(35)), transform_worldex },
3596 { /*292, WINED3DTS_WORLDMATRIX(36) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(36)), transform_worldex },
3597 { /*293, WINED3DTS_WORLDMATRIX(37) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(37)), transform_worldex },
3598 { /*294, WINED3DTS_WORLDMATRIX(38) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(38)), transform_worldex },
3599 { /*295, WINED3DTS_WORLDMATRIX(39) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(39)), transform_worldex },
3600 { /*296, WINED3DTS_WORLDMATRIX(40) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(40)), transform_worldex },
3601 { /*297, WINED3DTS_WORLDMATRIX(41) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(41)), transform_worldex },
3602 { /*298, WINED3DTS_WORLDMATRIX(42) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(42)), transform_worldex },
3603 { /*299, WINED3DTS_WORLDMATRIX(43) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(43)), transform_worldex },
3604 { /*300, WINED3DTS_WORLDMATRIX(44) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(44)), transform_worldex },
3605 { /*301, WINED3DTS_WORLDMATRIX(45) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(45)), transform_worldex },
3606 { /*302, WINED3DTS_WORLDMATRIX(46) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(46)), transform_worldex },
3607 { /*303, WINED3DTS_WORLDMATRIX(47) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(47)), transform_worldex },
3608 { /*304, WINED3DTS_WORLDMATRIX(48) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(48)), transform_worldex },
3609 { /*305, WINED3DTS_WORLDMATRIX(49) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(49)), transform_worldex },
3610 { /*306, WINED3DTS_WORLDMATRIX(50) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(50)), transform_worldex },
3611 { /*307, WINED3DTS_WORLDMATRIX(51) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(51)), transform_worldex },
3612 { /*308, WINED3DTS_WORLDMATRIX(52) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(52)), transform_worldex },
3613 { /*309, WINED3DTS_WORLDMATRIX(53) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(53)), transform_worldex },
3614 { /*310, WINED3DTS_WORLDMATRIX(54) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(54)), transform_worldex },
3615 { /*311, WINED3DTS_WORLDMATRIX(55) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(55)), transform_worldex },
3616 { /*312, WINED3DTS_WORLDMATRIX(56) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(56)), transform_worldex },
3617 { /*313, WINED3DTS_WORLDMATRIX(57) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(57)), transform_worldex },
3618 { /*314, WINED3DTS_WORLDMATRIX(58) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(58)), transform_worldex },
3619 { /*315, WINED3DTS_WORLDMATRIX(59) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(59)), transform_worldex },
3620 { /*316, WINED3DTS_WORLDMATRIX(60) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(60)), transform_worldex },
3621 { /*317, WINED3DTS_WORLDMATRIX(61) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(61)), transform_worldex },
3622 { /*318, WINED3DTS_WORLDMATRIX(62) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(62)), transform_worldex },
3623 { /*319, WINED3DTS_WORLDMATRIX(63) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(63)), transform_worldex },
3624 { /*320, WINED3DTS_WORLDMATRIX(64) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(64)), transform_worldex },
3625 { /*321, WINED3DTS_WORLDMATRIX(65) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(65)), transform_worldex },
3626 { /*322, WINED3DTS_WORLDMATRIX(66) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(66)), transform_worldex },
3627 { /*323, WINED3DTS_WORLDMATRIX(67) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(67)), transform_worldex },
3628 { /*324, WINED3DTS_WORLDMATRIX(68) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(68)), transform_worldex },
3629 { /*325, WINED3DTS_WORLDMATRIX(68) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(69)), transform_worldex },
3630 { /*326, WINED3DTS_WORLDMATRIX(70) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(70)), transform_worldex },
3631 { /*327, WINED3DTS_WORLDMATRIX(71) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(71)), transform_worldex },
3632 { /*328, WINED3DTS_WORLDMATRIX(72) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(72)), transform_worldex },
3633 { /*329, WINED3DTS_WORLDMATRIX(73) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(73)), transform_worldex },
3634 { /*330, WINED3DTS_WORLDMATRIX(74) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(74)), transform_worldex },
3635 { /*331, WINED3DTS_WORLDMATRIX(75) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(75)), transform_worldex },
3636 { /*332, WINED3DTS_WORLDMATRIX(76) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(76)), transform_worldex },
3637 { /*333, WINED3DTS_WORLDMATRIX(77) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(77)), transform_worldex },
3638 { /*334, WINED3DTS_WORLDMATRIX(78) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(78)), transform_worldex },
3639 { /*335, WINED3DTS_WORLDMATRIX(79) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(79)), transform_worldex },
3640 { /*336, WINED3DTS_WORLDMATRIX(80) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(80)), transform_worldex },
3641 { /*337, WINED3DTS_WORLDMATRIX(81) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(81)), transform_worldex },
3642 { /*338, WINED3DTS_WORLDMATRIX(82) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(82)), transform_worldex },
3643 { /*339, WINED3DTS_WORLDMATRIX(83) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(83)), transform_worldex },
3644 { /*340, WINED3DTS_WORLDMATRIX(84) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(84)), transform_worldex },
3645 { /*341, WINED3DTS_WORLDMATRIX(85) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(85)), transform_worldex },
3646 { /*341, WINED3DTS_WORLDMATRIX(86) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(86)), transform_worldex },
3647 { /*343, WINED3DTS_WORLDMATRIX(87) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(87)), transform_worldex },
3648 { /*344, WINED3DTS_WORLDMATRIX(88) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(88)), transform_worldex },
3649 { /*345, WINED3DTS_WORLDMATRIX(89) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(89)), transform_worldex },
3650 { /*346, WINED3DTS_WORLDMATRIX(90) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(90)), transform_worldex },
3651 { /*347, WINED3DTS_WORLDMATRIX(91) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(91)), transform_worldex },
3652 { /*348, WINED3DTS_WORLDMATRIX(92) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(92)), transform_worldex },
3653 { /*349, WINED3DTS_WORLDMATRIX(93) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(93)), transform_worldex },
3654 { /*350, WINED3DTS_WORLDMATRIX(94) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(94)), transform_worldex },
3655 { /*351, WINED3DTS_WORLDMATRIX(95) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(95)), transform_worldex },
3656 { /*352, WINED3DTS_WORLDMATRIX(96) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(96)), transform_worldex },
3657 { /*353, WINED3DTS_WORLDMATRIX(97) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(97)), transform_worldex },
3658 { /*354, WINED3DTS_WORLDMATRIX(98) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(98)), transform_worldex },
3659 { /*355, WINED3DTS_WORLDMATRIX(99) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(99)), transform_worldex },
3660 { /*356, WINED3DTS_WORLDMATRIX(100) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(100)), transform_worldex },
3661 { /*357, WINED3DTS_WORLDMATRIX(101) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(101)), transform_worldex },
3662 { /*358, WINED3DTS_WORLDMATRIX(102) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(102)), transform_worldex },
3663 { /*359, WINED3DTS_WORLDMATRIX(103) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(103)), transform_worldex },
3664 { /*360, WINED3DTS_WORLDMATRIX(104) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(104)), transform_worldex },
3665 { /*361, WINED3DTS_WORLDMATRIX(105) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(105)), transform_worldex },
3666 { /*362, WINED3DTS_WORLDMATRIX(106) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(106)), transform_worldex },
3667 { /*363, WINED3DTS_WORLDMATRIX(107) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(107)), transform_worldex },
3668 { /*364, WINED3DTS_WORLDMATRIX(108) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(108)), transform_worldex },
3669 { /*365, WINED3DTS_WORLDMATRIX(109) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(109)), transform_worldex },
3670 { /*366, WINED3DTS_WORLDMATRIX(110) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(110)), transform_worldex },
3671 { /*367, WINED3DTS_WORLDMATRIX(111) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(111)), transform_worldex },
3672 { /*368, WINED3DTS_WORLDMATRIX(112) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(112)), transform_worldex },
3673 { /*369, WINED3DTS_WORLDMATRIX(113) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(113)), transform_worldex },
3674 { /*370, WINED3DTS_WORLDMATRIX(114) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(114)), transform_worldex },
3675 { /*371, WINED3DTS_WORLDMATRIX(115) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(115)), transform_worldex },
3676 { /*372, WINED3DTS_WORLDMATRIX(116) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(116)), transform_worldex },
3677 { /*373, WINED3DTS_WORLDMATRIX(117) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(117)), transform_worldex },
3678 { /*374, WINED3DTS_WORLDMATRIX(118) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(118)), transform_worldex },
3679 { /*375, WINED3DTS_WORLDMATRIX(119) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(119)), transform_worldex },
3680 { /*376, WINED3DTS_WORLDMATRIX(120) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(120)), transform_worldex },
3681 { /*377, WINED3DTS_WORLDMATRIX(121) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(121)), transform_worldex },
3682 { /*378, WINED3DTS_WORLDMATRIX(122) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(122)), transform_worldex },
3683 { /*379, WINED3DTS_WORLDMATRIX(123) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(123)), transform_worldex },
3684 { /*380, WINED3DTS_WORLDMATRIX(124) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(124)), transform_worldex },
3685 { /*381, WINED3DTS_WORLDMATRIX(125) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(125)), transform_worldex },
3686 { /*382, WINED3DTS_WORLDMATRIX(126) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(126)), transform_worldex },
3687 { /*383, WINED3DTS_WORLDMATRIX(127) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(127)), transform_worldex },
3688 { /*384, WINED3DTS_WORLDMATRIX(128) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(128)), transform_worldex },
3689 { /*385, WINED3DTS_WORLDMATRIX(129) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(129)), transform_worldex },
3690 { /*386, WINED3DTS_WORLDMATRIX(130) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(130)), transform_worldex },
3691 { /*387, WINED3DTS_WORLDMATRIX(131) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(131)), transform_worldex },
3692 { /*388, WINED3DTS_WORLDMATRIX(132) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(132)), transform_worldex },
3693 { /*389, WINED3DTS_WORLDMATRIX(133) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(133)), transform_worldex },
3694 { /*390, WINED3DTS_WORLDMATRIX(134) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(134)), transform_worldex },
3695 { /*391, WINED3DTS_WORLDMATRIX(135) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(135)), transform_worldex },
3696 { /*392, WINED3DTS_WORLDMATRIX(136) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(136)), transform_worldex },
3697 { /*393, WINED3DTS_WORLDMATRIX(137) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(137)), transform_worldex },
3698 { /*394, WINED3DTS_WORLDMATRIX(138) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(138)), transform_worldex },
3699 { /*395, WINED3DTS_WORLDMATRIX(139) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(139)), transform_worldex },
3700 { /*396, WINED3DTS_WORLDMATRIX(140) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(140)), transform_worldex },
3701 { /*397, WINED3DTS_WORLDMATRIX(141) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(141)), transform_worldex },
3702 { /*398, WINED3DTS_WORLDMATRIX(142) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(142)), transform_worldex },
3703 { /*399, WINED3DTS_WORLDMATRIX(143) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(143)), transform_worldex },
3704 { /*400, WINED3DTS_WORLDMATRIX(144) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(144)), transform_worldex },
3705 { /*401, WINED3DTS_WORLDMATRIX(145) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(145)), transform_worldex },
3706 { /*402, WINED3DTS_WORLDMATRIX(146) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(146)), transform_worldex },
3707 { /*403, WINED3DTS_WORLDMATRIX(147) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(147)), transform_worldex },
3708 { /*404, WINED3DTS_WORLDMATRIX(148) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(148)), transform_worldex },
3709 { /*405, WINED3DTS_WORLDMATRIX(149) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(149)), transform_worldex },
3710 { /*406, WINED3DTS_WORLDMATRIX(150) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(150)), transform_worldex },
3711 { /*407, WINED3DTS_WORLDMATRIX(151) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(151)), transform_worldex },
3712 { /*408, WINED3DTS_WORLDMATRIX(152) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(152)), transform_worldex },
3713 { /*409, WINED3DTS_WORLDMATRIX(153) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(153)), transform_worldex },
3714 { /*410, WINED3DTS_WORLDMATRIX(154) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(154)), transform_worldex },
3715 { /*411, WINED3DTS_WORLDMATRIX(155) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(155)), transform_worldex },
3716 { /*412, WINED3DTS_WORLDMATRIX(156) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(156)), transform_worldex },
3717 { /*413, WINED3DTS_WORLDMATRIX(157) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(157)), transform_worldex },
3718 { /*414, WINED3DTS_WORLDMATRIX(158) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(158)), transform_worldex },
3719 { /*415, WINED3DTS_WORLDMATRIX(159) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(159)), transform_worldex },
3720 { /*416, WINED3DTS_WORLDMATRIX(160) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(160)), transform_worldex },
3721 { /*417, WINED3DTS_WORLDMATRIX(161) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(161)), transform_worldex },
3722 { /*418, WINED3DTS_WORLDMATRIX(162) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(162)), transform_worldex },
3723 { /*419, WINED3DTS_WORLDMATRIX(163) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(163)), transform_worldex },
3724 { /*420, WINED3DTS_WORLDMATRIX(164) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(164)), transform_worldex },
3725 { /*421, WINED3DTS_WORLDMATRIX(165) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(165)), transform_worldex },
3726 { /*422, WINED3DTS_WORLDMATRIX(166) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(166)), transform_worldex },
3727 { /*423, WINED3DTS_WORLDMATRIX(167) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(167)), transform_worldex },
3728 { /*424, WINED3DTS_WORLDMATRIX(168) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(168)), transform_worldex },
3729 { /*425, WINED3DTS_WORLDMATRIX(168) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(169)), transform_worldex },
3730 { /*426, WINED3DTS_WORLDMATRIX(170) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(170)), transform_worldex },
3731 { /*427, WINED3DTS_WORLDMATRIX(171) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(171)), transform_worldex },
3732 { /*428, WINED3DTS_WORLDMATRIX(172) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(172)), transform_worldex },
3733 { /*429, WINED3DTS_WORLDMATRIX(173) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(173)), transform_worldex },
3734 { /*430, WINED3DTS_WORLDMATRIX(174) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(174)), transform_worldex },
3735 { /*431, WINED3DTS_WORLDMATRIX(175) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(175)), transform_worldex },
3736 { /*432, WINED3DTS_WORLDMATRIX(176) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(176)), transform_worldex },
3737 { /*433, WINED3DTS_WORLDMATRIX(177) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(177)), transform_worldex },
3738 { /*434, WINED3DTS_WORLDMATRIX(178) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(178)), transform_worldex },
3739 { /*435, WINED3DTS_WORLDMATRIX(179) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(179)), transform_worldex },
3740 { /*436, WINED3DTS_WORLDMATRIX(180) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(180)), transform_worldex },
3741 { /*437, WINED3DTS_WORLDMATRIX(181) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(181)), transform_worldex },
3742 { /*438, WINED3DTS_WORLDMATRIX(182) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(182)), transform_worldex },
3743 { /*439, WINED3DTS_WORLDMATRIX(183) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(183)), transform_worldex },
3744 { /*440, WINED3DTS_WORLDMATRIX(184) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(184)), transform_worldex },
3745 { /*441, WINED3DTS_WORLDMATRIX(185) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(185)), transform_worldex },
3746 { /*441, WINED3DTS_WORLDMATRIX(186) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(186)), transform_worldex },
3747 { /*443, WINED3DTS_WORLDMATRIX(187) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(187)), transform_worldex },
3748 { /*444, WINED3DTS_WORLDMATRIX(188) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(188)), transform_worldex },
3749 { /*445, WINED3DTS_WORLDMATRIX(189) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(189)), transform_worldex },
3750 { /*446, WINED3DTS_WORLDMATRIX(190) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(190)), transform_worldex },
3751 { /*447, WINED3DTS_WORLDMATRIX(191) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(191)), transform_worldex },
3752 { /*448, WINED3DTS_WORLDMATRIX(192) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(192)), transform_worldex },
3753 { /*449, WINED3DTS_WORLDMATRIX(193) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(193)), transform_worldex },
3754 { /*450, WINED3DTS_WORLDMATRIX(194) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(194)), transform_worldex },
3755 { /*451, WINED3DTS_WORLDMATRIX(195) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(195)), transform_worldex },
3756 { /*452, WINED3DTS_WORLDMATRIX(196) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(196)), transform_worldex },
3757 { /*453, WINED3DTS_WORLDMATRIX(197) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(197)), transform_worldex },
3758 { /*454, WINED3DTS_WORLDMATRIX(198) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(198)), transform_worldex },
3759 { /*455, WINED3DTS_WORLDMATRIX(199) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(199)), transform_worldex },
3760 { /*356, WINED3DTS_WORLDMATRIX(200) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(200)), transform_worldex },
3761 { /*457, WINED3DTS_WORLDMATRIX(201) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(201)), transform_worldex },
3762 { /*458, WINED3DTS_WORLDMATRIX(202) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(202)), transform_worldex },
3763 { /*459, WINED3DTS_WORLDMATRIX(203) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(203)), transform_worldex },
3764 { /*460, WINED3DTS_WORLDMATRIX(204) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(204)), transform_worldex },
3765 { /*461, WINED3DTS_WORLDMATRIX(205) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(205)), transform_worldex },
3766 { /*462, WINED3DTS_WORLDMATRIX(206) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(206)), transform_worldex },
3767 { /*463, WINED3DTS_WORLDMATRIX(207) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(207)), transform_worldex },
3768 { /*464, WINED3DTS_WORLDMATRIX(208) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(208)), transform_worldex },
3769 { /*465, WINED3DTS_WORLDMATRIX(209) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(209)), transform_worldex },
3770 { /*466, WINED3DTS_WORLDMATRIX(210) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(210)), transform_worldex },
3771 { /*467, WINED3DTS_WORLDMATRIX(211) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(211)), transform_worldex },
3772 { /*468, WINED3DTS_WORLDMATRIX(212) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(212)), transform_worldex },
3773 { /*469, WINED3DTS_WORLDMATRIX(213) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(213)), transform_worldex },
3774 { /*470, WINED3DTS_WORLDMATRIX(214) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(214)), transform_worldex },
3775 { /*471, WINED3DTS_WORLDMATRIX(215) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(215)), transform_worldex },
3776 { /*472, WINED3DTS_WORLDMATRIX(216) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(216)), transform_worldex },
3777 { /*473, WINED3DTS_WORLDMATRIX(217) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(217)), transform_worldex },
3778 { /*474, WINED3DTS_WORLDMATRIX(218) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(218)), transform_worldex },
3779 { /*475, WINED3DTS_WORLDMATRIX(219) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(219)), transform_worldex },
3780 { /*476, WINED3DTS_WORLDMATRIX(220) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(220)), transform_worldex },
3781 { /*477, WINED3DTS_WORLDMATRIX(221) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(221)), transform_worldex },
3782 { /*478, WINED3DTS_WORLDMATRIX(222) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(222)), transform_worldex },
3783 { /*479, WINED3DTS_WORLDMATRIX(223) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(223)), transform_worldex },
3784 { /*480, WINED3DTS_WORLDMATRIX(224) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(224)), transform_worldex },
3785 { /*481, WINED3DTS_WORLDMATRIX(225) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(225)), transform_worldex },
3786 { /*482, WINED3DTS_WORLDMATRIX(226) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(226)), transform_worldex },
3787 { /*483, WINED3DTS_WORLDMATRIX(227) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(227)), transform_worldex },
3788 { /*484, WINED3DTS_WORLDMATRIX(228) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(228)), transform_worldex },
3789 { /*485, WINED3DTS_WORLDMATRIX(229) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(229)), transform_worldex },
3790 { /*486, WINED3DTS_WORLDMATRIX(230) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(230)), transform_worldex },
3791 { /*487, WINED3DTS_WORLDMATRIX(231) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(231)), transform_worldex },
3792 { /*488, WINED3DTS_WORLDMATRIX(232) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(232)), transform_worldex },
3793 { /*489, WINED3DTS_WORLDMATRIX(233) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(233)), transform_worldex },
3794 { /*490, WINED3DTS_WORLDMATRIX(234) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(234)), transform_worldex },
3795 { /*491, WINED3DTS_WORLDMATRIX(235) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(235)), transform_worldex },
3796 { /*492, WINED3DTS_WORLDMATRIX(236) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(236)), transform_worldex },
3797 { /*493, WINED3DTS_WORLDMATRIX(237) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(237)), transform_worldex },
3798 { /*494, WINED3DTS_WORLDMATRIX(238) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(238)), transform_worldex },
3799 { /*495, WINED3DTS_WORLDMATRIX(239) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(239)), transform_worldex },
3800 { /*496, WINED3DTS_WORLDMATRIX(240) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(240)), transform_worldex },
3801 { /*497, WINED3DTS_WORLDMATRIX(241) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(241)), transform_worldex },
3802 { /*498, WINED3DTS_WORLDMATRIX(242) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(242)), transform_worldex },
3803 { /*499, WINED3DTS_WORLDMATRIX(243) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(243)), transform_worldex },
3804 { /*500, WINED3DTS_WORLDMATRIX(244) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(244)), transform_worldex },
3805 { /*501, WINED3DTS_WORLDMATRIX(245) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(245)), transform_worldex },
3806 { /*502, WINED3DTS_WORLDMATRIX(246) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(246)), transform_worldex },
3807 { /*503, WINED3DTS_WORLDMATRIX(247) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(247)), transform_worldex },
3808 { /*504, WINED3DTS_WORLDMATRIX(248) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(248)), transform_worldex },
3809 { /*505, WINED3DTS_WORLDMATRIX(249) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(249)), transform_worldex },
3810 { /*506, WINED3DTS_WORLDMATRIX(250) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(250)), transform_worldex },
3811 { /*507, WINED3DTS_WORLDMATRIX(251) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(251)), transform_worldex },
3812 { /*508, WINED3DTS_WORLDMATRIX(252) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(252)), transform_worldex },
3813 { /*509, WINED3DTS_WORLDMATRIX(253) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(253)), transform_worldex },
3814 { /*510, WINED3DTS_WORLDMATRIX(254) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(254)), transform_worldex },
3815 { /*511, WINED3DTS_WORLDMATRIX(255) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(255)), transform_worldex },
3816 /* Various Vertex states follow */
3817 { /* , STATE_STREAMSRC */ STATE_VDECL, vertexdeclaration },
3818 { /* , STATE_VDECL */ STATE_VDECL, vertexdeclaration },
3819 { /* , STATE_VSHADER */ STATE_VDECL, vertexdeclaration },
3820 { /* , STATE_VIEWPORT */ STATE_VIEWPORT, viewport },
3821 { /* , STATE_VERTEXSHADERCONSTANT */ STATE_VERTEXSHADERCONSTANT, shaderconstant },
3822 { /* , STATE_PIXELSHADERCONSTANT */ STATE_VERTEXSHADERCONSTANT, shaderconstant },