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-2008 Stefan Dösinger for CodeWeavers
11 * Copyright 2009-2011 Henri Verbeet for CodeWeavers
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 2.1 of the License, or (at your option) any later version.
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this library; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
33 #include "wined3d_private.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(d3d
);
36 WINE_DECLARE_DEBUG_CHANNEL(d3d_shader
);
38 /* GL locking for state handlers is done by the caller. */
40 static void state_blendop(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
);
42 static void state_undefined(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
44 ERR("Undefined state.\n");
47 static void state_nop(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
49 TRACE("%s: nop in current pipe config.\n", debug_d3dstate(state
));
52 static void state_fillmode(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
54 WINED3DFILLMODE Value
= stateblock
->state
.render_states
[WINED3DRS_FILLMODE
];
57 case WINED3DFILL_POINT
:
58 glPolygonMode(GL_FRONT_AND_BACK
, GL_POINT
);
59 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_POINT)");
61 case WINED3DFILL_WIREFRAME
:
62 glPolygonMode(GL_FRONT_AND_BACK
, GL_LINE
);
63 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)");
65 case WINED3DFILL_SOLID
:
66 glPolygonMode(GL_FRONT_AND_BACK
, GL_FILL
);
67 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)");
70 FIXME("Unrecognized WINED3DRS_FILLMODE value %d\n", Value
);
74 static void state_lighting(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
76 /* Lighting is not enabled if transformed vertices are drawn
77 * but lighting does not affect the stream sources, so it is not grouped for performance reasons.
78 * This state reads the decoded vertex declaration, so if it is dirty don't do anything. The
79 * vertex declaration applying function calls this function for updating
82 if(isStateDirty(context
, STATE_VDECL
)) {
86 if (stateblock
->state
.render_states
[WINED3DRS_LIGHTING
]
87 && !stateblock
->device
->strided_streams
.position_transformed
)
89 glEnable(GL_LIGHTING
);
90 checkGLcall("glEnable GL_LIGHTING");
92 glDisable(GL_LIGHTING
);
93 checkGLcall("glDisable GL_LIGHTING");
97 static void state_zenable(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
99 /* No z test without depth stencil buffers */
100 if (!stateblock
->device
->fb
.depth_stencil
)
102 TRACE("No Z buffer - disabling depth test\n");
103 glDisable(GL_DEPTH_TEST
); /* This also disables z writing in gl */
104 checkGLcall("glDisable GL_DEPTH_TEST");
108 switch (stateblock
->state
.render_states
[WINED3DRS_ZENABLE
])
110 case WINED3DZB_FALSE
:
111 glDisable(GL_DEPTH_TEST
);
112 checkGLcall("glDisable GL_DEPTH_TEST");
115 glEnable(GL_DEPTH_TEST
);
116 checkGLcall("glEnable GL_DEPTH_TEST");
119 glEnable(GL_DEPTH_TEST
);
120 checkGLcall("glEnable GL_DEPTH_TEST");
121 FIXME("W buffer is not well handled\n");
124 FIXME("Unrecognized D3DZBUFFERTYPE value %#x.\n",
125 stateblock
->state
.render_states
[WINED3DRS_ZENABLE
]);
129 static void state_cullmode(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
131 /* glFrontFace() is set in context.c at context init and on an
132 * offscreen / onscreen rendering switch. */
133 switch (stateblock
->state
.render_states
[WINED3DRS_CULLMODE
])
135 case WINED3DCULL_NONE
:
136 glDisable(GL_CULL_FACE
);
137 checkGLcall("glDisable GL_CULL_FACE");
140 glEnable(GL_CULL_FACE
);
141 checkGLcall("glEnable GL_CULL_FACE");
142 glCullFace(GL_FRONT
);
143 checkGLcall("glCullFace(GL_FRONT)");
145 case WINED3DCULL_CCW
:
146 glEnable(GL_CULL_FACE
);
147 checkGLcall("glEnable GL_CULL_FACE");
149 checkGLcall("glCullFace(GL_BACK)");
152 FIXME("Unrecognized/Unhandled WINED3DCULL value %#x.\n",
153 stateblock
->state
.render_states
[WINED3DRS_CULLMODE
]);
157 static void state_shademode(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
159 switch (stateblock
->state
.render_states
[WINED3DRS_SHADEMODE
])
161 case WINED3DSHADE_FLAT
:
162 glShadeModel(GL_FLAT
);
163 checkGLcall("glShadeModel(GL_FLAT)");
165 case WINED3DSHADE_GOURAUD
:
166 glShadeModel(GL_SMOOTH
);
167 checkGLcall("glShadeModel(GL_SMOOTH)");
169 case WINED3DSHADE_PHONG
:
170 FIXME("WINED3DSHADE_PHONG isn't supported\n");
173 FIXME("Unrecognized/Unhandled WINED3DSHADEMODE value %#x.\n",
174 stateblock
->state
.render_states
[WINED3DRS_SHADEMODE
]);
178 static void state_ditherenable(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
180 if (stateblock
->state
.render_states
[WINED3DRS_DITHERENABLE
])
183 checkGLcall("glEnable GL_DITHER");
187 glDisable(GL_DITHER
);
188 checkGLcall("glDisable GL_DITHER");
192 static void state_zwritenable(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
194 /* TODO: Test if in d3d z writing is enabled even if ZENABLE is off.
195 * If yes, this has to be merged with ZENABLE and ZFUNC. */
196 if (stateblock
->state
.render_states
[WINED3DRS_ZWRITEENABLE
])
199 checkGLcall("glDepthMask(1)");
204 checkGLcall("glDepthMask(0)");
208 static void state_zfunc(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
210 GLenum depth_func
= CompareFunc(stateblock
->state
.render_states
[WINED3DRS_ZFUNC
]);
212 if (!depth_func
) return;
214 if (depth_func
== GL_EQUAL
|| depth_func
== GL_NOTEQUAL
)
217 /* There are a few issues with this: First, our inability to
218 * select a proper Z depth, most of the time we're stuck with
219 * D24S8, even if the app selects D32 or D16. There seem to be
220 * some other precision problems which have to be debugged to
221 * make NOTEQUAL and EQUAL work properly. */
225 FIXME("D3DCMP_NOTEQUAL and D3DCMP_EQUAL do not work correctly yet.\n");
229 glDepthFunc(depth_func
);
230 checkGLcall("glDepthFunc");
233 static void state_ambient(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
236 D3DCOLORTOGLFLOAT4(stateblock
->state
.render_states
[WINED3DRS_AMBIENT
], col
);
238 TRACE("Setting ambient to (%f,%f,%f,%f)\n", col
[0], col
[1], col
[2], col
[3]);
239 glLightModelfv(GL_LIGHT_MODEL_AMBIENT
, col
);
240 checkGLcall("glLightModel for MODEL_AMBIENT");
243 static GLenum
gl_blend_factor(WINED3DBLEND factor
, const struct wined3d_format
*dst_format
)
247 case WINED3DBLEND_ZERO
:
249 case WINED3DBLEND_ONE
:
251 case WINED3DBLEND_SRCCOLOR
:
253 case WINED3DBLEND_INVSRCCOLOR
:
254 return GL_ONE_MINUS_SRC_COLOR
;
255 case WINED3DBLEND_SRCALPHA
:
257 case WINED3DBLEND_INVSRCALPHA
:
258 return GL_ONE_MINUS_SRC_ALPHA
;
259 case WINED3DBLEND_DESTCOLOR
:
261 case WINED3DBLEND_INVDESTCOLOR
:
262 return GL_ONE_MINUS_DST_COLOR
;
263 /* To compensate for the lack of format switching with backbuffer
264 * offscreen rendering, and with onscreen rendering, we modify the
265 * alpha test parameters for (INV)DESTALPHA if the render target
266 * doesn't support alpha blending. A nonexistent alpha channel
267 * returns 1.0, so WINED3DBLEND_DESTALPHA becomes GL_ONE, and
268 * WINED3DBLEND_INVDESTALPHA becomes GL_ZERO. */
269 case WINED3DBLEND_DESTALPHA
:
270 return dst_format
->alpha_mask
? GL_DST_ALPHA
: GL_ONE
;
271 case WINED3DBLEND_INVDESTALPHA
:
272 return dst_format
->alpha_mask
? GL_ONE_MINUS_DST_ALPHA
: GL_ZERO
;
273 case WINED3DBLEND_SRCALPHASAT
:
274 return GL_SRC_ALPHA_SATURATE
;
275 case WINED3DBLEND_BLENDFACTOR
:
276 return GL_CONSTANT_COLOR_EXT
;
277 case WINED3DBLEND_INVBLENDFACTOR
:
278 return GL_ONE_MINUS_CONSTANT_COLOR_EXT
;
280 FIXME("Unhandled blend factor %#x.\n", factor
);
285 static void state_blend(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
287 struct wined3d_surface
*target
= stateblock
->device
->fb
.render_targets
[0];
288 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
289 GLenum srcBlend
, dstBlend
;
290 WINED3DBLEND d3d_blend
;
292 /* According to the red book, GL_LINE_SMOOTH needs GL_BLEND with specific
293 * blending parameters to work. */
294 if (stateblock
->state
.render_states
[WINED3DRS_ALPHABLENDENABLE
]
295 || stateblock
->state
.render_states
[WINED3DRS_EDGEANTIALIAS
]
296 || stateblock
->state
.render_states
[WINED3DRS_ANTIALIASEDLINEENABLE
])
298 /* Disable blending in all cases even without pixelshaders.
299 * With blending on we could face a big performance penalty.
300 * The d3d9 visual test confirms the behavior. */
301 if (context
->render_offscreen
302 && !(target
->resource
.format
->flags
& WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
))
305 checkGLcall("glDisable GL_BLEND");
309 checkGLcall("glEnable GL_BLEND");
313 checkGLcall("glDisable GL_BLEND");
314 /* Nothing more to do - get out */
318 /* WINED3DBLEND_BOTHSRCALPHA and WINED3DBLEND_BOTHINVSRCALPHA are legacy
319 * source blending values which are still valid up to d3d9. They should
320 * not occur as dest blend values. */
321 d3d_blend
= stateblock
->state
.render_states
[WINED3DRS_SRCBLEND
];
322 if (d3d_blend
== WINED3DBLEND_BOTHSRCALPHA
)
324 srcBlend
= GL_SRC_ALPHA
;
325 dstBlend
= GL_ONE_MINUS_SRC_ALPHA
;
327 else if (d3d_blend
== WINED3DBLEND_BOTHINVSRCALPHA
)
329 srcBlend
= GL_ONE_MINUS_SRC_ALPHA
;
330 dstBlend
= GL_SRC_ALPHA
;
334 srcBlend
= gl_blend_factor(d3d_blend
, target
->resource
.format
);
335 dstBlend
= gl_blend_factor(stateblock
->state
.render_states
[WINED3DRS_DESTBLEND
],
336 target
->resource
.format
);
339 if (stateblock
->state
.render_states
[WINED3DRS_EDGEANTIALIAS
]
340 || stateblock
->state
.render_states
[WINED3DRS_ANTIALIASEDLINEENABLE
])
342 glEnable(GL_LINE_SMOOTH
);
343 checkGLcall("glEnable(GL_LINE_SMOOTH)");
344 if(srcBlend
!= GL_SRC_ALPHA
) {
345 WARN("WINED3DRS_EDGEANTIALIAS enabled, but unexpected src blending param\n");
347 if(dstBlend
!= GL_ONE_MINUS_SRC_ALPHA
&& dstBlend
!= GL_ONE
) {
348 WARN("WINED3DRS_EDGEANTIALIAS enabled, but unexpected dst blending param\n");
351 glDisable(GL_LINE_SMOOTH
);
352 checkGLcall("glDisable(GL_LINE_SMOOTH)");
355 /* Re-apply BLENDOP(ALPHA) because of a possible SEPARATEALPHABLENDENABLE change */
356 if(!isStateDirty(context
, STATE_RENDER(WINED3DRS_BLENDOP
))) {
357 state_blendop(STATE_RENDER(WINED3DRS_BLENDOPALPHA
), stateblock
, context
);
360 if (stateblock
->state
.render_states
[WINED3DRS_SEPARATEALPHABLENDENABLE
])
362 GLenum srcBlendAlpha
, dstBlendAlpha
;
364 /* Separate alpha blending requires GL_EXT_blend_function_separate, so make sure it is around */
365 if (!context
->gl_info
->supported
[EXT_BLEND_FUNC_SEPARATE
])
367 WARN("Unsupported in local OpenGL implementation: glBlendFuncSeparateEXT\n");
371 /* WINED3DBLEND_BOTHSRCALPHA and WINED3DBLEND_BOTHINVSRCALPHA are legacy
372 * source blending values which are still valid up to d3d9. They should
373 * not occur as dest blend values. */
374 d3d_blend
= stateblock
->state
.render_states
[WINED3DRS_SRCBLENDALPHA
];
375 if (d3d_blend
== WINED3DBLEND_BOTHSRCALPHA
)
377 srcBlendAlpha
= GL_SRC_ALPHA
;
378 dstBlendAlpha
= GL_ONE_MINUS_SRC_ALPHA
;
380 else if (d3d_blend
== WINED3DBLEND_BOTHINVSRCALPHA
)
382 srcBlendAlpha
= GL_ONE_MINUS_SRC_ALPHA
;
383 dstBlendAlpha
= GL_SRC_ALPHA
;
387 srcBlendAlpha
= gl_blend_factor(d3d_blend
, target
->resource
.format
);
388 dstBlendAlpha
= gl_blend_factor(stateblock
->state
.render_states
[WINED3DRS_DESTBLENDALPHA
],
389 target
->resource
.format
);
392 GL_EXTCALL(glBlendFuncSeparateEXT(srcBlend
, dstBlend
, srcBlendAlpha
, dstBlendAlpha
));
393 checkGLcall("glBlendFuncSeparateEXT");
395 TRACE("glBlendFunc src=%x, dst=%x\n", srcBlend
, dstBlend
);
396 glBlendFunc(srcBlend
, dstBlend
);
397 checkGLcall("glBlendFunc");
400 /* colorkey fixup for stage 0 alphaop depends on WINED3DRS_ALPHABLENDENABLE state,
401 so it may need updating */
402 if (stateblock
->state
.render_states
[WINED3DRS_COLORKEYENABLE
])
403 stateblock_apply_state(STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), stateblock
, context
);
406 static void state_blendfactor_w(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
408 WARN("Unsupported in local OpenGL implementation: glBlendColorEXT\n");
411 static void state_blendfactor(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
413 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
416 TRACE("Setting blend factor to %#x.\n", stateblock
->state
.render_states
[WINED3DRS_BLENDFACTOR
]);
417 D3DCOLORTOGLFLOAT4(stateblock
->state
.render_states
[WINED3DRS_BLENDFACTOR
], col
);
418 GL_EXTCALL(glBlendColorEXT (col
[0],col
[1],col
[2],col
[3]));
419 checkGLcall("glBlendColor");
422 static void state_alpha(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
426 BOOL enable_ckey
= FALSE
;
428 TRACE("state %#x, stateblock %p, context %p\n", state
, stateblock
, context
);
430 /* Find out if the texture on the first stage has a ckey set
431 * The alpha state func reads the texture settings, even though alpha and texture are not grouped
432 * together. This is to avoid making a huge alpha+texture+texture stage+ckey block due to the hardly
433 * used WINED3DRS_COLORKEYENABLE state(which is d3d <= 3 only). The texture function will call alpha
434 * in case it finds some texture+colorkeyenable combination which needs extra care.
436 if (stateblock
->state
.textures
[0])
438 struct wined3d_texture
*texture
= stateblock
->state
.textures
[0];
439 GLenum texture_dimensions
= texture
->target
;
441 if (texture_dimensions
== GL_TEXTURE_2D
|| texture_dimensions
== GL_TEXTURE_RECTANGLE_ARB
)
443 struct wined3d_surface
*surf
= surface_from_resource(texture
->sub_resources
[0]);
445 if (surf
->CKeyFlags
& WINEDDSD_CKSRCBLT
)
447 /* The surface conversion does not do color keying conversion for surfaces that have an alpha
448 * channel on their own. Likewise, the alpha test shouldn't be set up for color keying if the
449 * surface has alpha bits */
450 if (!surf
->resource
.format
->alpha_mask
) enable_ckey
= TRUE
;
455 if (enable_ckey
|| context
->last_was_ckey
)
456 stateblock_apply_state(STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), stateblock
, context
);
457 context
->last_was_ckey
= enable_ckey
;
459 if (stateblock
->state
.render_states
[WINED3DRS_ALPHATESTENABLE
]
460 || (stateblock
->state
.render_states
[WINED3DRS_COLORKEYENABLE
] && enable_ckey
))
462 glEnable(GL_ALPHA_TEST
);
463 checkGLcall("glEnable GL_ALPHA_TEST");
465 glDisable(GL_ALPHA_TEST
);
466 checkGLcall("glDisable GL_ALPHA_TEST");
467 /* Alpha test is disabled, don't bother setting the params - it will happen on the next
473 if (stateblock
->state
.render_states
[WINED3DRS_COLORKEYENABLE
] && enable_ckey
)
475 glParm
= GL_NOTEQUAL
;
478 ref
= ((float)stateblock
->state
.render_states
[WINED3DRS_ALPHAREF
]) / 255.0f
;
479 glParm
= CompareFunc(stateblock
->state
.render_states
[WINED3DRS_ALPHAFUNC
]);
482 glAlphaFunc(glParm
, ref
);
483 checkGLcall("glAlphaFunc");
487 static void shaderconstant(DWORD state_id
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
489 const struct wined3d_state
*state
= &stateblock
->state
;
490 struct wined3d_device
*device
= stateblock
->device
;
492 /* Vertex and pixel shader states will call a shader upload, don't do anything as long one of them
493 * has an update pending
495 if(isStateDirty(context
, STATE_VDECL
) ||
496 isStateDirty(context
, STATE_PIXELSHADER
)) {
500 device
->shader_backend
->shader_load_constants(context
, use_ps(state
), use_vs(state
));
503 static void state_clipping(DWORD state_id
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
505 const struct wined3d_state
*state
= &stateblock
->state
;
506 DWORD enable
= 0xFFFFFFFF;
507 DWORD disable
= 0x00000000;
511 const struct wined3d_device
*device
= stateblock
->device
;
513 if (!device
->vs_clipping
)
515 /* The spec says that opengl clipping planes are disabled when using shaders. Direct3D planes aren't,
516 * so that is an issue. The MacOS ATI driver keeps clipping planes activated with shaders in some
517 * conditions I got sick of tracking down. The shader state handler disables all clip planes because
518 * of that - don't do anything here and keep them disabled
520 if (state
->render_states
[WINED3DRS_CLIPPLANEENABLE
])
522 static BOOL warned
= FALSE
;
524 FIXME("Clipping not supported with vertex shaders\n");
531 /* glEnable(GL_CLIP_PLANEx) doesn't apply to vertex shaders. The enabled / disabled planes are
532 * hardcoded into the shader. Update the shader to update the enabled clipplanes */
533 if (!isStateDirty(context
, device
->StateTable
[STATE_VSHADER
].representative
))
535 device
->shader_backend
->shader_select(context
, use_ps(state
), TRUE
);
536 if (!isStateDirty(context
, STATE_VERTEXSHADERCONSTANT
)) {
537 shaderconstant(STATE_VERTEXSHADERCONSTANT
, stateblock
, context
);
542 /* TODO: Keep track of previously enabled clipplanes to avoid unnecessary resetting
543 * of already set values
546 /* If enabling / disabling all
547 * TODO: Is this correct? Doesn't D3DRS_CLIPPING disable clipping on the viewport frustrum?
549 if (state
->render_states
[WINED3DRS_CLIPPING
])
551 enable
= state
->render_states
[WINED3DRS_CLIPPLANEENABLE
];
552 disable
= ~state
->render_states
[WINED3DRS_CLIPPLANEENABLE
];
556 disable
= 0xffffffff;
560 if (enable
& WINED3DCLIPPLANE0
) { glEnable(GL_CLIP_PLANE0
); checkGLcall("glEnable(clip plane 0)"); }
561 if (enable
& WINED3DCLIPPLANE1
) { glEnable(GL_CLIP_PLANE1
); checkGLcall("glEnable(clip plane 1)"); }
562 if (enable
& WINED3DCLIPPLANE2
) { glEnable(GL_CLIP_PLANE2
); checkGLcall("glEnable(clip plane 2)"); }
563 if (enable
& WINED3DCLIPPLANE3
) { glEnable(GL_CLIP_PLANE3
); checkGLcall("glEnable(clip plane 3)"); }
564 if (enable
& WINED3DCLIPPLANE4
) { glEnable(GL_CLIP_PLANE4
); checkGLcall("glEnable(clip plane 4)"); }
565 if (enable
& WINED3DCLIPPLANE5
) { glEnable(GL_CLIP_PLANE5
); checkGLcall("glEnable(clip plane 5)"); }
567 if (disable
& WINED3DCLIPPLANE0
) { glDisable(GL_CLIP_PLANE0
); checkGLcall("glDisable(clip plane 0)"); }
568 if (disable
& WINED3DCLIPPLANE1
) { glDisable(GL_CLIP_PLANE1
); checkGLcall("glDisable(clip plane 1)"); }
569 if (disable
& WINED3DCLIPPLANE2
) { glDisable(GL_CLIP_PLANE2
); checkGLcall("glDisable(clip plane 2)"); }
570 if (disable
& WINED3DCLIPPLANE3
) { glDisable(GL_CLIP_PLANE3
); checkGLcall("glDisable(clip plane 3)"); }
571 if (disable
& WINED3DCLIPPLANE4
) { glDisable(GL_CLIP_PLANE4
); checkGLcall("glDisable(clip plane 4)"); }
572 if (disable
& WINED3DCLIPPLANE5
) { glDisable(GL_CLIP_PLANE5
); checkGLcall("glDisable(clip plane 5)"); }
574 /** update clipping status */
577 stateblock
->state
.clip_status
.ClipUnion
= 0;
578 stateblock
->state
.clip_status
.ClipIntersection
= 0xFFFFFFFF;
582 stateblock
->state
.clip_status
.ClipUnion
= 0;
583 stateblock
->state
.clip_status
.ClipIntersection
= 0;
587 static void state_blendop_w(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
589 WARN("Unsupported in local OpenGL implementation: glBlendEquation\n");
592 static GLenum
gl_blend_op(WINED3DBLENDOP op
)
596 case WINED3DBLENDOP_ADD
:
597 return GL_FUNC_ADD_EXT
;
598 case WINED3DBLENDOP_SUBTRACT
:
599 return GL_FUNC_SUBTRACT_EXT
;
600 case WINED3DBLENDOP_REVSUBTRACT
:
601 return GL_FUNC_REVERSE_SUBTRACT_EXT
;
602 case WINED3DBLENDOP_MIN
:
604 case WINED3DBLENDOP_MAX
:
607 FIXME("Unhandled blend op %#x.\n", op
);
612 static void state_blendop(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
614 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
615 int blendEquation
= GL_FUNC_ADD_EXT
;
616 int blendEquationAlpha
= GL_FUNC_ADD_EXT
;
618 /* BLENDOPALPHA requires GL_EXT_blend_equation_separate, so make sure it is around */
619 if (stateblock
->state
.render_states
[WINED3DRS_BLENDOPALPHA
]
620 && !gl_info
->supported
[EXT_BLEND_EQUATION_SEPARATE
])
622 WARN("Unsupported in local OpenGL implementation: glBlendEquationSeparateEXT\n");
626 blendEquation
= gl_blend_op(stateblock
->state
.render_states
[WINED3DRS_BLENDOP
]);
627 blendEquationAlpha
= gl_blend_op(stateblock
->state
.render_states
[WINED3DRS_BLENDOPALPHA
]);
629 if (stateblock
->state
.render_states
[WINED3DRS_SEPARATEALPHABLENDENABLE
])
631 TRACE("glBlendEquationSeparateEXT(%x, %x)\n", blendEquation
, blendEquationAlpha
);
632 GL_EXTCALL(glBlendEquationSeparateEXT(blendEquation
, blendEquationAlpha
));
633 checkGLcall("glBlendEquationSeparateEXT");
635 TRACE("glBlendEquation(%x)\n", blendEquation
);
636 GL_EXTCALL(glBlendEquationEXT(blendEquation
));
637 checkGLcall("glBlendEquation");
641 static void state_specularenable(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
643 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
644 /* Originally this used glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR)
645 * and (GL_LIGHT_MODEL_COLOR_CONTROL,GL_SINGLE_COLOR) to swap between enabled/disabled
646 * specular color. This is wrong:
647 * Separate specular color means the specular colour is maintained separately, whereas
648 * single color means it is merged in. However in both cases they are being used to
650 * To disable specular color, set it explicitly to black and turn off GL_COLOR_SUM_EXT
651 * NOTE: If not supported don't give FIXMEs the impact is really minimal and very few people are
655 * If register combiners are enabled, enabling / disabling GL_COLOR_SUM has no effect.
656 * Instead, we need to setup the FinalCombiner properly.
658 * The default setup for the FinalCombiner is:
660 * <variable> <input> <mapping> <usage>
661 * GL_VARIABLE_A_NV GL_FOG, GL_UNSIGNED_IDENTITY_NV GL_ALPHA
662 * GL_VARIABLE_B_NV GL_SPARE0_PLUS_SECONDARY_COLOR_NV GL_UNSIGNED_IDENTITY_NV GL_RGB
663 * GL_VARIABLE_C_NV GL_FOG GL_UNSIGNED_IDENTITY_NV GL_RGB
664 * GL_VARIABLE_D_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
665 * GL_VARIABLE_E_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
666 * GL_VARIABLE_F_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
667 * GL_VARIABLE_G_NV GL_SPARE0_NV GL_UNSIGNED_IDENTITY_NV GL_ALPHA
669 * That's pretty much fine as it is, except for variable B, which needs to take
670 * either GL_SPARE0_PLUS_SECONDARY_COLOR_NV or GL_SPARE0_NV, depending on
671 * whether WINED3DRS_SPECULARENABLE is enabled or not.
674 TRACE("Setting specular enable state and materials\n");
675 if (stateblock
->state
.render_states
[WINED3DRS_SPECULARENABLE
])
677 glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, (float *)&stateblock
->state
.material
.Specular
);
678 checkGLcall("glMaterialfv");
680 if (stateblock
->state
.material
.Power
> gl_info
->limits
.shininess
)
682 /* glMaterialf man page says that the material says that GL_SHININESS must be between 0.0
683 * and 128.0, although in d3d neither -1 nor 129 produce an error. GL_NV_max_light_exponent
684 * allows bigger values. If the extension is supported, gl_info->limits.shininess contains the
685 * value reported by the extension, otherwise 128. For values > gl_info->limits.shininess clamp
686 * them, it should be safe to do so without major visual distortions.
688 WARN("Material power = %f, limit %f\n", stateblock
->state
.material
.Power
, gl_info
->limits
.shininess
);
689 glMaterialf(GL_FRONT_AND_BACK
, GL_SHININESS
, gl_info
->limits
.shininess
);
693 glMaterialf(GL_FRONT_AND_BACK
, GL_SHININESS
, stateblock
->state
.material
.Power
);
695 checkGLcall("glMaterialf(GL_SHININESS)");
697 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
699 glEnable(GL_COLOR_SUM_EXT
);
703 TRACE("Specular colors cannot be enabled in this version of opengl\n");
705 checkGLcall("glEnable(GL_COLOR_SUM)");
707 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
709 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV
, GL_SPARE0_PLUS_SECONDARY_COLOR_NV
, GL_UNSIGNED_IDENTITY_NV
, GL_RGB
));
710 checkGLcall("glFinalCombinerInputNV()");
713 static const GLfloat black
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
715 /* for the case of enabled lighting: */
716 glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, &black
[0]);
717 checkGLcall("glMaterialfv");
719 /* for the case of disabled lighting: */
720 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
722 glDisable(GL_COLOR_SUM_EXT
);
726 TRACE("Specular colors cannot be disabled in this version of opengl\n");
728 checkGLcall("glDisable(GL_COLOR_SUM)");
730 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
732 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV
, GL_SPARE0_NV
, GL_UNSIGNED_IDENTITY_NV
, GL_RGB
));
733 checkGLcall("glFinalCombinerInputNV()");
737 TRACE("(%p) : Diffuse {%.8e, %.8e, %.8e, %.8e}\n", stateblock
->device
,
738 stateblock
->state
.material
.Diffuse
.r
, stateblock
->state
.material
.Diffuse
.g
,
739 stateblock
->state
.material
.Diffuse
.b
, stateblock
->state
.material
.Diffuse
.a
);
740 TRACE("(%p) : Ambient {%.8e, %.8e, %.8e, %.8e}\n", stateblock
->device
,
741 stateblock
->state
.material
.Ambient
.r
, stateblock
->state
.material
.Ambient
.g
,
742 stateblock
->state
.material
.Ambient
.b
, stateblock
->state
.material
.Ambient
.a
);
743 TRACE("(%p) : Specular {%.8e, %.8e, %.8e, %.8e}\n", stateblock
->device
,
744 stateblock
->state
.material
.Specular
.r
, stateblock
->state
.material
.Specular
.g
,
745 stateblock
->state
.material
.Specular
.b
, stateblock
->state
.material
.Specular
.a
);
746 TRACE("(%p) : Emissive {%.8e, %.8e, %.8e, %.8e}\n", stateblock
->device
,
747 stateblock
->state
.material
.Emissive
.r
, stateblock
->state
.material
.Emissive
.g
,
748 stateblock
->state
.material
.Emissive
.b
, stateblock
->state
.material
.Emissive
.a
);
750 glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float *)&stateblock
->state
.material
.Ambient
);
751 checkGLcall("glMaterialfv(GL_AMBIENT)");
752 glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float *)&stateblock
->state
.material
.Diffuse
);
753 checkGLcall("glMaterialfv(GL_DIFFUSE)");
754 glMaterialfv(GL_FRONT_AND_BACK
, GL_EMISSION
, (float *)&stateblock
->state
.material
.Emissive
);
755 checkGLcall("glMaterialfv(GL_EMISSION)");
758 static void state_texfactor(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
760 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
763 /* Note the texture color applies to all textures whereas
764 * GL_TEXTURE_ENV_COLOR applies to active only
767 D3DCOLORTOGLFLOAT4(stateblock
->state
.render_states
[WINED3DRS_TEXTUREFACTOR
], col
);
769 /* And now the default texture color as well */
770 for (i
= 0; i
< gl_info
->limits
.texture_stages
; ++i
)
772 /* Note the WINED3DRS value applies to all textures, but GL has one
773 * per texture, so apply it now ready to be used!
775 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB
+ i
));
776 checkGLcall("glActiveTextureARB");
778 glTexEnvfv(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_COLOR
, &col
[0]);
779 checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);");
783 static void renderstate_stencil_twosided(struct wined3d_context
*context
, GLint face
,
784 GLint func
, GLint ref
, GLuint mask
, GLint stencilFail
, GLint depthFail
, GLint stencilPass
)
786 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
788 glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT
);
789 checkGLcall("glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT)");
790 GL_EXTCALL(glActiveStencilFaceEXT(face
));
791 checkGLcall("glActiveStencilFaceEXT(...)");
792 glStencilFunc(func
, ref
, mask
);
793 checkGLcall("glStencilFunc(...)");
794 glStencilOp(stencilFail
, depthFail
, stencilPass
);
795 checkGLcall("glStencilOp(...)");
798 static void state_stencil(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
800 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
801 DWORD onesided_enable
= FALSE
;
802 DWORD twosided_enable
= FALSE
;
803 GLint func
= GL_ALWAYS
;
804 GLint func_ccw
= GL_ALWAYS
;
807 GLint stencilFail
= GL_KEEP
;
808 GLint depthFail
= GL_KEEP
;
809 GLint stencilPass
= GL_KEEP
;
810 GLint stencilFail_ccw
= GL_KEEP
;
811 GLint depthFail_ccw
= GL_KEEP
;
812 GLint stencilPass_ccw
= GL_KEEP
;
814 /* No stencil test without a stencil buffer. */
815 if (!stateblock
->device
->fb
.depth_stencil
)
817 glDisable(GL_STENCIL_TEST
);
818 checkGLcall("glDisable GL_STENCIL_TEST");
822 onesided_enable
= stateblock
->state
.render_states
[WINED3DRS_STENCILENABLE
];
823 twosided_enable
= stateblock
->state
.render_states
[WINED3DRS_TWOSIDEDSTENCILMODE
];
824 if (!(func
= CompareFunc(stateblock
->state
.render_states
[WINED3DRS_STENCILFUNC
])))
826 if (!(func_ccw
= CompareFunc(stateblock
->state
.render_states
[WINED3DRS_CCW_STENCILFUNC
])))
827 func_ccw
= GL_ALWAYS
;
828 ref
= stateblock
->state
.render_states
[WINED3DRS_STENCILREF
];
829 mask
= stateblock
->state
.render_states
[WINED3DRS_STENCILMASK
];
830 stencilFail
= StencilOp(stateblock
->state
.render_states
[WINED3DRS_STENCILFAIL
]);
831 depthFail
= StencilOp(stateblock
->state
.render_states
[WINED3DRS_STENCILZFAIL
]);
832 stencilPass
= StencilOp(stateblock
->state
.render_states
[WINED3DRS_STENCILPASS
]);
833 stencilFail_ccw
= StencilOp(stateblock
->state
.render_states
[WINED3DRS_CCW_STENCILFAIL
]);
834 depthFail_ccw
= StencilOp(stateblock
->state
.render_states
[WINED3DRS_CCW_STENCILZFAIL
]);
835 stencilPass_ccw
= StencilOp(stateblock
->state
.render_states
[WINED3DRS_CCW_STENCILPASS
]);
837 TRACE("(onesided %d, twosided %d, ref %x, mask %x, "
838 "GL_FRONT: func: %x, fail %x, zfail %x, zpass %x "
839 "GL_BACK: func: %x, fail %x, zfail %x, zpass %x )\n",
840 onesided_enable
, twosided_enable
, ref
, mask
,
841 func
, stencilFail
, depthFail
, stencilPass
,
842 func_ccw
, stencilFail_ccw
, depthFail_ccw
, stencilPass_ccw
);
844 if (twosided_enable
&& onesided_enable
) {
845 glEnable(GL_STENCIL_TEST
);
846 checkGLcall("glEnable GL_STENCIL_TEST");
848 if (gl_info
->supported
[EXT_STENCIL_TWO_SIDE
])
850 /* Apply back first, then front. This function calls glActiveStencilFaceEXT,
851 * which has an effect on the code below too. If we apply the front face
852 * afterwards, we are sure that the active stencil face is set to front,
853 * and other stencil functions which do not use two sided stencil do not have
856 renderstate_stencil_twosided(context
, GL_BACK
,
857 func_ccw
, ref
, mask
, stencilFail_ccw
, depthFail_ccw
, stencilPass_ccw
);
858 renderstate_stencil_twosided(context
, GL_FRONT
,
859 func
, ref
, mask
, stencilFail
, depthFail
, stencilPass
);
861 else if (gl_info
->supported
[ATI_SEPARATE_STENCIL
])
863 GL_EXTCALL(glStencilFuncSeparateATI(func
, func_ccw
, ref
, mask
));
864 checkGLcall("glStencilFuncSeparateATI(...)");
865 GL_EXTCALL(glStencilOpSeparateATI(GL_FRONT
, stencilFail
, depthFail
, stencilPass
));
866 checkGLcall("glStencilOpSeparateATI(GL_FRONT, ...)");
867 GL_EXTCALL(glStencilOpSeparateATI(GL_BACK
, stencilFail_ccw
, depthFail_ccw
, stencilPass_ccw
));
868 checkGLcall("glStencilOpSeparateATI(GL_BACK, ...)");
870 ERR("Separate (two sided) stencil not supported on this version of opengl. Caps weren't honored?\n");
873 else if(onesided_enable
)
875 if (gl_info
->supported
[EXT_STENCIL_TWO_SIDE
])
877 glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT
);
878 checkGLcall("glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT)");
881 /* This code disables the ATI extension as well, since the standard stencil functions are equal
882 * to calling the ATI functions with GL_FRONT_AND_BACK as face parameter
884 glEnable(GL_STENCIL_TEST
);
885 checkGLcall("glEnable GL_STENCIL_TEST");
886 glStencilFunc(func
, ref
, mask
);
887 checkGLcall("glStencilFunc(...)");
888 glStencilOp(stencilFail
, depthFail
, stencilPass
);
889 checkGLcall("glStencilOp(...)");
891 glDisable(GL_STENCIL_TEST
);
892 checkGLcall("glDisable GL_STENCIL_TEST");
896 static void state_stencilwrite2s(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
898 DWORD mask
= stateblock
->device
->fb
.depth_stencil
? stateblock
->state
.render_states
[WINED3DRS_STENCILWRITEMASK
] : 0;
899 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
901 GL_EXTCALL(glActiveStencilFaceEXT(GL_BACK
));
902 checkGLcall("glActiveStencilFaceEXT(GL_BACK)");
904 checkGLcall("glStencilMask");
905 GL_EXTCALL(glActiveStencilFaceEXT(GL_FRONT
));
906 checkGLcall("glActiveStencilFaceEXT(GL_FRONT)");
910 static void state_stencilwrite(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
912 DWORD mask
= stateblock
->device
->fb
.depth_stencil
? stateblock
->state
.render_states
[WINED3DRS_STENCILWRITEMASK
] : 0;
915 checkGLcall("glStencilMask");
918 static void state_fog_vertexpart(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
921 TRACE("state %#x, stateblock %p, context %p\n", state
, stateblock
, context
);
923 if (!stateblock
->state
.render_states
[WINED3DRS_FOGENABLE
]) return;
925 /* Table fog on: Never use fog coords, and use per-fragment fog */
926 if (stateblock
->state
.render_states
[WINED3DRS_FOGTABLEMODE
] != WINED3DFOG_NONE
)
928 glHint(GL_FOG_HINT
, GL_NICEST
);
929 if(context
->fog_coord
) {
930 glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FRAGMENT_DEPTH_EXT
);
931 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT)");
932 context
->fog_coord
= FALSE
;
937 /* Otherwise use per-vertex fog in any case */
938 glHint(GL_FOG_HINT
, GL_FASTEST
);
940 if (stateblock
->state
.render_states
[WINED3DRS_FOGVERTEXMODE
] == WINED3DFOG_NONE
|| context
->last_was_rhw
)
942 /* No fog at all, or transformed vertices: Use fog coord */
943 if(!context
->fog_coord
) {
944 glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FOG_COORDINATE_EXT
);
945 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT)");
946 context
->fog_coord
= TRUE
;
949 /* Otherwise, use the fragment depth */
950 if(context
->fog_coord
) {
951 glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FRAGMENT_DEPTH_EXT
);
952 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT)");
953 context
->fog_coord
= FALSE
;
958 void state_fogstartend(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
960 float fogstart
, fogend
;
966 switch(context
->fog_source
) {
972 case FOGSOURCE_COORD
:
978 tmpvalue
.d
= stateblock
->state
.render_states
[WINED3DRS_FOGSTART
];
979 fogstart
= tmpvalue
.f
;
980 tmpvalue
.d
= stateblock
->state
.render_states
[WINED3DRS_FOGEND
];
982 /* In GL, fogstart == fogend disables fog, in D3D everything's fogged.*/
983 if(fogstart
== fogend
) {
984 fogstart
= -1.0f
/ 0.0f
;
990 /* This should not happen.context->fog_source is set in wined3d, not the app.
991 * Still this is needed to make the compiler happy
993 ERR("Unexpected fog coordinate source\n");
998 glFogf(GL_FOG_START
, fogstart
);
999 checkGLcall("glFogf(GL_FOG_START, fogstart)");
1000 TRACE("Fog Start == %f\n", fogstart
);
1002 glFogf(GL_FOG_END
, fogend
);
1003 checkGLcall("glFogf(GL_FOG_END, fogend)");
1004 TRACE("Fog End == %f\n", fogend
);
1007 void state_fog_fragpart(DWORD state_id
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1009 const struct wined3d_state
*state
= &stateblock
->state
;
1010 enum fogsource new_source
;
1012 TRACE("state_id %#x, stateblock %p, context %p\n", state_id
, stateblock
, context
);
1014 if (!state
->render_states
[WINED3DRS_FOGENABLE
])
1016 /* No fog? Disable it, and we're done :-) */
1017 glDisableWINE(GL_FOG
);
1018 checkGLcall("glDisable GL_FOG");
1024 * With fixed function vertex processing, Direct3D knows 2 different fog input sources.
1025 * It can use the Z value of the vertex, or the alpha component of the specular color.
1026 * This depends on the fog vertex, fog table and the vertex declaration. If the Z value
1027 * is used, fogstart, fogend and the equation type are used, otherwise linear fog with
1028 * start = 255, end = 0 is used. Obviously the msdn is not very clear on that.
1030 * FOGTABLEMODE != NONE:
1031 * The Z value is used, with the equation specified, no matter what vertex type.
1033 * FOGTABLEMODE == NONE, FOGVERTEXMODE != NONE, untransformed:
1034 * Per vertex fog is calculated using the specified fog equation and the parameters
1036 * FOGTABLEMODE == NONE, FOGVERTEXMODE != NONE, transformed, OR
1037 * FOGTABLEMODE == NONE, FOGVERTEXMODE == NONE, untransformed:
1038 * Linear fog with start = 255.0, end = 0.0, input comes from the specular color
1041 * Rules for vertex fog with shaders:
1043 * When mixing fixed function functionality with the programmable pipeline, D3D expects
1044 * the fog computation to happen during transformation while openGL expects it to happen
1045 * during rasterization. Also, prior to pixel shader 3.0 D3D handles fog blending after
1046 * the pixel shader while openGL always expects the pixel shader to handle the blending.
1047 * To solve this problem, WineD3D does:
1048 * 1) implement a linear fog equation and fog blending at the end of every pre 3.0 pixel
1050 * and 2) disables the fog computation (in either the fixed function or programmable
1051 * rasterizer) if using a vertex program.
1053 * D3D shaders can provide an explicit fog coordinate. This fog coordinate is used with
1054 * D3DRS_FOGTABLEMODE==D3DFOG_NONE. The FOGVERTEXMODE is ignored, d3d always uses linear
1055 * fog with start=1.0 and end=0.0 in this case. This is similar to fog coordinates in
1056 * the specular color, a vertex shader counts as pretransformed geometry in this case.
1057 * There are some GL differences between specular fog coords and vertex shaders though.
1059 * With table fog the vertex shader fog coordinate is ignored.
1061 * If a fogtablemode and a fogvertexmode are specified, table fog is applied (with or
1065 /* DX 7 sdk: "If both render states(vertex and table fog) are set to valid modes,
1066 * the system will apply only pixel(=table) fog effects."
1068 if (state
->render_states
[WINED3DRS_FOGTABLEMODE
] == WINED3DFOG_NONE
)
1072 glFogi(GL_FOG_MODE
, GL_LINEAR
);
1073 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1074 new_source
= FOGSOURCE_VS
;
1078 switch (state
->render_states
[WINED3DRS_FOGVERTEXMODE
])
1080 /* If processed vertices are used, fall through to the NONE case */
1081 case WINED3DFOG_EXP
:
1082 if(!context
->last_was_rhw
) {
1083 glFogi(GL_FOG_MODE
, GL_EXP
);
1084 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP)");
1085 new_source
= FOGSOURCE_FFP
;
1090 case WINED3DFOG_EXP2
:
1091 if(!context
->last_was_rhw
) {
1092 glFogi(GL_FOG_MODE
, GL_EXP2
);
1093 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2)");
1094 new_source
= FOGSOURCE_FFP
;
1099 case WINED3DFOG_LINEAR
:
1100 if(!context
->last_was_rhw
) {
1101 glFogi(GL_FOG_MODE
, GL_LINEAR
);
1102 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1103 new_source
= FOGSOURCE_FFP
;
1108 case WINED3DFOG_NONE
:
1109 /* Both are none? According to msdn the alpha channel of the specular
1110 * color contains a fog factor. Set it in drawStridedSlow.
1111 * Same happens with Vertexfog on transformed vertices
1113 new_source
= FOGSOURCE_COORD
;
1114 glFogi(GL_FOG_MODE
, GL_LINEAR
);
1115 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1119 FIXME("Unexpected WINED3DRS_FOGVERTEXMODE %#x.\n",
1120 state
->render_states
[WINED3DRS_FOGVERTEXMODE
]);
1121 new_source
= FOGSOURCE_FFP
; /* Make the compiler happy */
1125 new_source
= FOGSOURCE_FFP
;
1127 switch (state
->render_states
[WINED3DRS_FOGTABLEMODE
])
1129 case WINED3DFOG_EXP
:
1130 glFogi(GL_FOG_MODE
, GL_EXP
);
1131 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP)");
1134 case WINED3DFOG_EXP2
:
1135 glFogi(GL_FOG_MODE
, GL_EXP2
);
1136 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2)");
1139 case WINED3DFOG_LINEAR
:
1140 glFogi(GL_FOG_MODE
, GL_LINEAR
);
1141 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1144 case WINED3DFOG_NONE
: /* Won't happen */
1146 FIXME("Unexpected WINED3DRS_FOGTABLEMODE %#x.\n",
1147 state
->render_states
[WINED3DRS_FOGTABLEMODE
]);
1151 glEnableWINE(GL_FOG
);
1152 checkGLcall("glEnable GL_FOG");
1153 if(new_source
!= context
->fog_source
) {
1154 context
->fog_source
= new_source
;
1155 state_fogstartend(STATE_RENDER(WINED3DRS_FOGSTART
), stateblock
, context
);
1159 static void state_rangefog_w(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1161 if (stateblock
->state
.render_states
[WINED3DRS_RANGEFOGENABLE
])
1162 WARN("Range fog enabled, but not supported by this opengl implementation\n");
1165 static void state_rangefog(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1167 if (stateblock
->state
.render_states
[WINED3DRS_RANGEFOGENABLE
])
1169 glFogi(GL_FOG_DISTANCE_MODE_NV
, GL_EYE_RADIAL_NV
);
1170 checkGLcall("glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_RADIAL_NV)");
1172 glFogi(GL_FOG_DISTANCE_MODE_NV
, GL_EYE_PLANE_ABSOLUTE_NV
);
1173 checkGLcall("glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_PLANE_ABSOLUTE_NV)");
1177 void state_fogcolor(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1180 D3DCOLORTOGLFLOAT4(stateblock
->state
.render_states
[WINED3DRS_FOGCOLOR
], col
);
1181 glFogfv(GL_FOG_COLOR
, &col
[0]);
1182 checkGLcall("glFog GL_FOG_COLOR");
1185 void state_fogdensity(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1191 tmpvalue
.d
= stateblock
->state
.render_states
[WINED3DRS_FOGDENSITY
];
1192 glFogfv(GL_FOG_DENSITY
, &tmpvalue
.f
);
1193 checkGLcall("glFogf(GL_FOG_DENSITY, (float) Value)");
1196 static void state_colormat(DWORD state_id
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1198 const struct wined3d_state
*state
= &stateblock
->state
;
1199 struct wined3d_device
*device
= stateblock
->device
;
1202 /* Depends on the decoded vertex declaration to read the existence of diffuse data.
1203 * The vertex declaration will call this function if the fixed function pipeline is used.
1206 if(isStateDirty(context
, STATE_VDECL
)) {
1210 context
->num_untracked_materials
= 0;
1211 if ((device
->strided_streams
.use_map
& (1 << WINED3D_FFP_DIFFUSE
))
1212 && state
->render_states
[WINED3DRS_COLORVERTEX
])
1214 TRACE("diff %d, amb %d, emis %d, spec %d\n",
1215 state
->render_states
[WINED3DRS_DIFFUSEMATERIALSOURCE
],
1216 state
->render_states
[WINED3DRS_AMBIENTMATERIALSOURCE
],
1217 state
->render_states
[WINED3DRS_EMISSIVEMATERIALSOURCE
],
1218 state
->render_states
[WINED3DRS_SPECULARMATERIALSOURCE
]);
1220 if (state
->render_states
[WINED3DRS_DIFFUSEMATERIALSOURCE
] == WINED3DMCS_COLOR1
)
1222 if (state
->render_states
[WINED3DRS_AMBIENTMATERIALSOURCE
] == WINED3DMCS_COLOR1
)
1223 Parm
= GL_AMBIENT_AND_DIFFUSE
;
1226 if (state
->render_states
[WINED3DRS_EMISSIVEMATERIALSOURCE
] == WINED3DMCS_COLOR1
)
1228 context
->untracked_materials
[context
->num_untracked_materials
] = GL_EMISSION
;
1229 context
->num_untracked_materials
++;
1231 if (state
->render_states
[WINED3DRS_SPECULARMATERIALSOURCE
] == WINED3DMCS_COLOR1
)
1233 context
->untracked_materials
[context
->num_untracked_materials
] = GL_SPECULAR
;
1234 context
->num_untracked_materials
++;
1237 else if (state
->render_states
[WINED3DRS_AMBIENTMATERIALSOURCE
] == WINED3DMCS_COLOR1
)
1240 if (state
->render_states
[WINED3DRS_EMISSIVEMATERIALSOURCE
] == WINED3DMCS_COLOR1
)
1242 context
->untracked_materials
[context
->num_untracked_materials
] = GL_EMISSION
;
1243 context
->num_untracked_materials
++;
1245 if (state
->render_states
[WINED3DRS_SPECULARMATERIALSOURCE
] == WINED3DMCS_COLOR1
)
1247 context
->untracked_materials
[context
->num_untracked_materials
] = GL_SPECULAR
;
1248 context
->num_untracked_materials
++;
1251 else if (state
->render_states
[WINED3DRS_EMISSIVEMATERIALSOURCE
] == WINED3DMCS_COLOR1
)
1254 if (state
->render_states
[WINED3DRS_SPECULARMATERIALSOURCE
] == WINED3DMCS_COLOR1
)
1256 context
->untracked_materials
[context
->num_untracked_materials
] = GL_SPECULAR
;
1257 context
->num_untracked_materials
++;
1260 else if (state
->render_states
[WINED3DRS_SPECULARMATERIALSOURCE
] == WINED3DMCS_COLOR1
)
1266 /* Nothing changed, return. */
1267 if (Parm
== context
->tracking_parm
) return;
1270 glDisable(GL_COLOR_MATERIAL
);
1271 checkGLcall("glDisable GL_COLOR_MATERIAL");
1273 glColorMaterial(GL_FRONT_AND_BACK
, Parm
);
1274 checkGLcall("glColorMaterial(GL_FRONT_AND_BACK, Parm)");
1275 glEnable(GL_COLOR_MATERIAL
);
1276 checkGLcall("glEnable(GL_COLOR_MATERIAL)");
1279 /* Apparently calls to glMaterialfv are ignored for properties we're
1280 * tracking with glColorMaterial, so apply those here. */
1281 switch (context
->tracking_parm
) {
1282 case GL_AMBIENT_AND_DIFFUSE
:
1283 glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float *)&state
->material
.Ambient
);
1284 glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float *)&state
->material
.Diffuse
);
1285 checkGLcall("glMaterialfv");
1289 glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float *)&state
->material
.Diffuse
);
1290 checkGLcall("glMaterialfv");
1294 glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float *)&state
->material
.Ambient
);
1295 checkGLcall("glMaterialfv");
1299 glMaterialfv(GL_FRONT_AND_BACK
, GL_EMISSION
, (float *)&state
->material
.Emissive
);
1300 checkGLcall("glMaterialfv");
1304 /* Only change material color if specular is enabled, otherwise it is set to black */
1305 if (state
->render_states
[WINED3DRS_SPECULARENABLE
])
1307 glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, (float *)&state
->material
.Specular
);
1308 checkGLcall("glMaterialfv");
1310 static const GLfloat black
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
1311 glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, &black
[0]);
1312 checkGLcall("glMaterialfv");
1317 context
->tracking_parm
= Parm
;
1320 static void state_linepattern(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1324 WINED3DLINEPATTERN lp
;
1326 tmppattern
.d
= stateblock
->state
.render_states
[WINED3DRS_LINEPATTERN
];
1328 TRACE("Line pattern: repeat %d bits %x\n", tmppattern
.lp
.wRepeatFactor
, tmppattern
.lp
.wLinePattern
);
1330 if (tmppattern
.lp
.wRepeatFactor
) {
1331 glLineStipple(tmppattern
.lp
.wRepeatFactor
, tmppattern
.lp
.wLinePattern
);
1332 checkGLcall("glLineStipple(repeat, linepattern)");
1333 glEnable(GL_LINE_STIPPLE
);
1334 checkGLcall("glEnable(GL_LINE_STIPPLE);");
1336 glDisable(GL_LINE_STIPPLE
);
1337 checkGLcall("glDisable(GL_LINE_STIPPLE);");
1341 static void state_normalize(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1343 if(isStateDirty(context
, STATE_VDECL
)) {
1346 /* Without vertex normals, we set the current normal to 0/0/0 to remove the diffuse factor
1347 * from the opengl lighting equation, as d3d does. Normalization of 0/0/0 can lead to a division
1348 * by zero and is not properly defined in opengl, so avoid it
1350 if (stateblock
->state
.render_states
[WINED3DRS_NORMALIZENORMALS
]
1351 && (stateblock
->device
->strided_streams
.use_map
& (1 << WINED3D_FFP_NORMAL
)))
1353 glEnable(GL_NORMALIZE
);
1354 checkGLcall("glEnable(GL_NORMALIZE);");
1356 glDisable(GL_NORMALIZE
);
1357 checkGLcall("glDisable(GL_NORMALIZE);");
1361 static void state_psizemin_w(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1368 tmpvalue
.d
= stateblock
->state
.render_states
[WINED3DRS_POINTSIZE_MIN
];
1369 if (tmpvalue
.f
!= 1.0f
)
1371 FIXME("WINED3DRS_POINTSIZE_MIN not supported on this opengl, value is %f\n", tmpvalue
.f
);
1373 tmpvalue
.d
= stateblock
->state
.render_states
[WINED3DRS_POINTSIZE_MAX
];
1374 if (tmpvalue
.f
!= 64.0f
)
1376 FIXME("WINED3DRS_POINTSIZE_MAX not supported on this opengl, value is %f\n", tmpvalue
.f
);
1381 static void state_psizemin_ext(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1383 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1390 min
.d
= stateblock
->state
.render_states
[WINED3DRS_POINTSIZE_MIN
];
1391 max
.d
= stateblock
->state
.render_states
[WINED3DRS_POINTSIZE_MAX
];
1393 /* Max point size trumps min point size */
1398 GL_EXTCALL(glPointParameterfEXT
)(GL_POINT_SIZE_MIN_EXT
, min
.f
);
1399 checkGLcall("glPointParameterfEXT(...)");
1400 GL_EXTCALL(glPointParameterfEXT
)(GL_POINT_SIZE_MAX_EXT
, max
.f
);
1401 checkGLcall("glPointParameterfEXT(...)");
1404 static void state_psizemin_arb(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1406 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1413 min
.d
= stateblock
->state
.render_states
[WINED3DRS_POINTSIZE_MIN
];
1414 max
.d
= stateblock
->state
.render_states
[WINED3DRS_POINTSIZE_MAX
];
1416 /* Max point size trumps min point size */
1421 GL_EXTCALL(glPointParameterfARB
)(GL_POINT_SIZE_MIN_ARB
, min
.f
);
1422 checkGLcall("glPointParameterfARB(...)");
1423 GL_EXTCALL(glPointParameterfARB
)(GL_POINT_SIZE_MAX_ARB
, max
.f
);
1424 checkGLcall("glPointParameterfARB(...)");
1427 static void state_pscale(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1429 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1430 /* TODO: Group this with the viewport */
1432 * POINTSCALEENABLE controls how point size value is treated. If set to
1433 * true, the point size is scaled with respect to height of viewport.
1434 * When set to false point size is in pixels.
1437 /* Default values */
1438 GLfloat att
[3] = {1.0f
, 0.0f
, 0.0f
};
1442 } pointSize
, A
, B
, C
;
1444 pointSize
.d
= stateblock
->state
.render_states
[WINED3DRS_POINTSIZE
];
1445 A
.d
= stateblock
->state
.render_states
[WINED3DRS_POINTSCALE_A
];
1446 B
.d
= stateblock
->state
.render_states
[WINED3DRS_POINTSCALE_B
];
1447 C
.d
= stateblock
->state
.render_states
[WINED3DRS_POINTSCALE_C
];
1449 if (stateblock
->state
.render_states
[WINED3DRS_POINTSCALEENABLE
])
1451 GLfloat scaleFactor
;
1452 DWORD h
= stateblock
->state
.viewport
.Height
;
1454 if (pointSize
.f
< gl_info
->limits
.pointsize_min
)
1456 /* Minimum valid point size for OpenGL is driver specific. For Direct3D it is
1457 * 0.0f. This means that OpenGL will clamp really small point sizes to the
1458 * driver minimum. To correct for this we need to multiply by the scale factor when sizes
1459 * are less than 1.0f. scale_factor = 1.0f / point_size.
1461 scaleFactor
= pointSize
.f
/ gl_info
->limits
.pointsize_min
;
1462 /* Clamp the point size, don't rely on the driver to do it. MacOS says min point size
1463 * is 1.0, but then accepts points below that and draws too small points
1465 pointSize
.f
= gl_info
->limits
.pointsize_min
;
1467 else if(pointSize
.f
> gl_info
->limits
.pointsize_max
)
1469 /* gl already scales the input to glPointSize,
1470 * d3d scales the result after the point size scale.
1471 * If the point size is bigger than the max size, use the
1472 * scaling to scale it bigger, and set the gl point size to max
1474 scaleFactor
= pointSize
.f
/ gl_info
->limits
.pointsize_max
;
1475 TRACE("scale: %f\n", scaleFactor
);
1476 pointSize
.f
= gl_info
->limits
.pointsize_max
;
1480 scaleFactor
= powf(h
* scaleFactor
, 2);
1482 att
[0] = A
.f
/ scaleFactor
;
1483 att
[1] = B
.f
/ scaleFactor
;
1484 att
[2] = C
.f
/ scaleFactor
;
1487 if (gl_info
->supported
[ARB_POINT_PARAMETERS
])
1489 GL_EXTCALL(glPointParameterfvARB
)(GL_POINT_DISTANCE_ATTENUATION_ARB
, att
);
1490 checkGLcall("glPointParameterfvARB(GL_DISTANCE_ATTENUATION_ARB, ...)");
1492 else if (gl_info
->supported
[EXT_POINT_PARAMETERS
])
1494 GL_EXTCALL(glPointParameterfvEXT
)(GL_DISTANCE_ATTENUATION_EXT
, att
);
1495 checkGLcall("glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, ...)");
1497 else if(stateblock
->state
.render_states
[WINED3DRS_POINTSCALEENABLE
])
1499 WARN("POINT_PARAMETERS not supported in this version of opengl\n");
1502 glPointSize(pointSize
.f
);
1503 checkGLcall("glPointSize(...);");
1506 static void state_debug_monitor(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1508 WARN("token: %#x\n", stateblock
->state
.render_states
[WINED3DRS_DEBUGMONITORTOKEN
]);
1511 static void state_colorwrite(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1513 DWORD mask0
= stateblock
->state
.render_states
[WINED3DRS_COLORWRITEENABLE
];
1514 DWORD mask1
= stateblock
->state
.render_states
[WINED3DRS_COLORWRITEENABLE1
];
1515 DWORD mask2
= stateblock
->state
.render_states
[WINED3DRS_COLORWRITEENABLE2
];
1516 DWORD mask3
= stateblock
->state
.render_states
[WINED3DRS_COLORWRITEENABLE3
];
1518 TRACE("Color mask: r(%d) g(%d) b(%d) a(%d)\n",
1519 mask0
& WINED3DCOLORWRITEENABLE_RED
? 1 : 0,
1520 mask0
& WINED3DCOLORWRITEENABLE_GREEN
? 1 : 0,
1521 mask0
& WINED3DCOLORWRITEENABLE_BLUE
? 1 : 0,
1522 mask0
& WINED3DCOLORWRITEENABLE_ALPHA
? 1 : 0);
1523 glColorMask(mask0
& WINED3DCOLORWRITEENABLE_RED
? GL_TRUE
: GL_FALSE
,
1524 mask0
& WINED3DCOLORWRITEENABLE_GREEN
? GL_TRUE
: GL_FALSE
,
1525 mask0
& WINED3DCOLORWRITEENABLE_BLUE
? GL_TRUE
: GL_FALSE
,
1526 mask0
& WINED3DCOLORWRITEENABLE_ALPHA
? GL_TRUE
: GL_FALSE
);
1527 checkGLcall("glColorMask(...)");
1529 if (!((mask1
== mask0
&& mask2
== mask0
&& mask3
== mask0
)
1530 || (mask1
== 0xf && mask2
== 0xf && mask3
== 0xf)))
1532 FIXME("WINED3DRS_COLORWRITEENABLE/1/2/3, %#x/%#x/%#x/%#x not yet implemented.\n",
1533 mask0
, mask1
, mask2
, mask3
);
1534 FIXME("Missing of cap D3DPMISCCAPS_INDEPENDENTWRITEMASKS wasn't honored?\n");
1538 static void set_color_mask(const struct wined3d_gl_info
*gl_info
, UINT index
, DWORD mask
)
1540 GL_EXTCALL(glColorMaskIndexedEXT(index
,
1541 mask
& WINED3DCOLORWRITEENABLE_RED
? GL_TRUE
: GL_FALSE
,
1542 mask
& WINED3DCOLORWRITEENABLE_GREEN
? GL_TRUE
: GL_FALSE
,
1543 mask
& WINED3DCOLORWRITEENABLE_BLUE
? GL_TRUE
: GL_FALSE
,
1544 mask
& WINED3DCOLORWRITEENABLE_ALPHA
? GL_TRUE
: GL_FALSE
));
1547 static void state_colorwrite0(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1549 set_color_mask(context
->gl_info
, 0, stateblock
->state
.render_states
[WINED3DRS_COLORWRITEENABLE
]);
1552 static void state_colorwrite1(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1554 set_color_mask(context
->gl_info
, 1, stateblock
->state
.render_states
[WINED3DRS_COLORWRITEENABLE1
]);
1557 static void state_colorwrite2(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1559 set_color_mask(context
->gl_info
, 2, stateblock
->state
.render_states
[WINED3DRS_COLORWRITEENABLE2
]);
1562 static void state_colorwrite3(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1564 set_color_mask(context
->gl_info
, 3, stateblock
->state
.render_states
[WINED3DRS_COLORWRITEENABLE3
]);
1567 static void state_localviewer(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1569 if (stateblock
->state
.render_states
[WINED3DRS_LOCALVIEWER
])
1571 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER
, 1);
1572 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1)");
1574 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER
, 0);
1575 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 0)");
1579 static void state_lastpixel(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1581 if (stateblock
->state
.render_states
[WINED3DRS_LASTPIXEL
])
1583 TRACE("Last Pixel Drawing Enabled\n");
1587 FIXME("Last Pixel Drawing Disabled, not handled yet\n");
1590 TRACE("Last Pixel Drawing Disabled, not handled yet\n");
1595 static void state_pointsprite_w(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1599 /* TODO: NV_POINT_SPRITE */
1600 if (!warned
&& stateblock
->state
.render_states
[WINED3DRS_POINTSPRITEENABLE
])
1602 /* A FIXME, not a WARN because point sprites should be software emulated if not supported by HW */
1603 FIXME("Point sprites not supported\n");
1608 static void state_pointsprite(DWORD state_id
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1610 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1611 const struct wined3d_state
*state
= &stateblock
->state
;
1613 if (state
->render_states
[WINED3DRS_POINTSPRITEENABLE
])
1617 if (gl_info
->limits
.point_sprite_units
< gl_info
->limits
.textures
&& !warned
)
1619 if (use_ps(state
) || state
->lowest_disabled_stage
> gl_info
->limits
.point_sprite_units
)
1621 FIXME("The app uses point sprite texture coordinates on more units than supported by the driver\n");
1626 glEnable(GL_POINT_SPRITE_ARB
);
1627 checkGLcall("glEnable(GL_POINT_SPRITE_ARB)");
1629 glDisable(GL_POINT_SPRITE_ARB
);
1630 checkGLcall("glDisable(GL_POINT_SPRITE_ARB)");
1634 static void state_wrap(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1637 http://www.cosc.brocku.ca/Offerings/3P98/course/lectures/texture/
1638 http://www.gamedev.net/reference/programming/features/rendererdll3/page2.asp
1639 Discussion on the ways to turn on WRAPing to solve an OpenGL conversion problem.
1640 http://www.flipcode.org/cgi-bin/fcmsg.cgi?thread_show=10248
1642 so far as I can tell, wrapping and texture-coordinate generate go hand in hand,
1644 if (stateblock
->state
.render_states
[WINED3DRS_WRAP0
]
1645 || stateblock
->state
.render_states
[WINED3DRS_WRAP1
]
1646 || stateblock
->state
.render_states
[WINED3DRS_WRAP2
]
1647 || stateblock
->state
.render_states
[WINED3DRS_WRAP3
]
1648 || stateblock
->state
.render_states
[WINED3DRS_WRAP4
]
1649 || stateblock
->state
.render_states
[WINED3DRS_WRAP5
]
1650 || stateblock
->state
.render_states
[WINED3DRS_WRAP6
]
1651 || stateblock
->state
.render_states
[WINED3DRS_WRAP7
]
1652 || stateblock
->state
.render_states
[WINED3DRS_WRAP8
]
1653 || stateblock
->state
.render_states
[WINED3DRS_WRAP9
]
1654 || stateblock
->state
.render_states
[WINED3DRS_WRAP10
]
1655 || stateblock
->state
.render_states
[WINED3DRS_WRAP11
]
1656 || stateblock
->state
.render_states
[WINED3DRS_WRAP12
]
1657 || stateblock
->state
.render_states
[WINED3DRS_WRAP13
]
1658 || stateblock
->state
.render_states
[WINED3DRS_WRAP14
]
1659 || stateblock
->state
.render_states
[WINED3DRS_WRAP15
])
1661 FIXME("(WINED3DRS_WRAP0) Texture wrapping not yet supported.\n");
1665 static void state_msaa_w(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1667 if (stateblock
->state
.render_states
[WINED3DRS_MULTISAMPLEANTIALIAS
])
1668 WARN("Multisample antialiasing not supported by gl\n");
1671 static void state_msaa(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1673 if (stateblock
->state
.render_states
[WINED3DRS_MULTISAMPLEANTIALIAS
])
1675 glEnable(GL_MULTISAMPLE_ARB
);
1676 checkGLcall("glEnable(GL_MULTISAMPLE_ARB)");
1678 glDisable(GL_MULTISAMPLE_ARB
);
1679 checkGLcall("glDisable(GL_MULTISAMPLE_ARB)");
1683 static void state_scissor(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1685 if (stateblock
->state
.render_states
[WINED3DRS_SCISSORTESTENABLE
])
1687 glEnable(GL_SCISSOR_TEST
);
1688 checkGLcall("glEnable(GL_SCISSOR_TEST)");
1690 glDisable(GL_SCISSOR_TEST
);
1691 checkGLcall("glDisable(GL_SCISSOR_TEST)");
1695 /* The Direct3D depth bias is specified in normalized depth coordinates. In
1696 * OpenGL the bias is specified in units of "the smallest value that is
1697 * guaranteed to produce a resolvable offset for a given implementation". To
1698 * convert from D3D to GL we need to divide the D3D depth bias by that value.
1699 * There's no practical way to retrieve that value from a given GL
1700 * implementation, but the D3D application has essentially the same problem,
1701 * which makes a guess of the depth buffer format's highest possible value a
1702 * reasonable guess. Note that SLOPESCALEDEPTHBIAS is a scaling factor for the
1703 * depth slope, and doesn't need to be scaled. */
1704 static void state_depthbias(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1706 if (stateblock
->state
.render_states
[WINED3DRS_SLOPESCALEDEPTHBIAS
]
1707 || stateblock
->state
.render_states
[WINED3DRS_DEPTHBIAS
])
1709 const struct wined3d_device
*device
= stateblock
->device
;
1710 const struct wined3d_surface
*depth
= device
->fb
.depth_stencil
;
1717 } scale_bias
, const_bias
;
1719 scale_bias
.d
= stateblock
->state
.render_states
[WINED3DRS_SLOPESCALEDEPTHBIAS
];
1720 const_bias
.d
= stateblock
->state
.render_states
[WINED3DRS_DEPTHBIAS
];
1722 glEnable(GL_POLYGON_OFFSET_FILL
);
1723 checkGLcall("glEnable(GL_POLYGON_OFFSET_FILL)");
1725 if (device
->wined3d
->flags
& WINED3D_LEGACY_DEPTH_BIAS
)
1727 float bias
= -(float)const_bias
.d
;
1728 glPolygonOffset(bias
, bias
);
1729 checkGLcall("glPolygonOffset");
1735 const struct wined3d_format
*fmt
= depth
->resource
.format
;
1736 scale
= powf(2, fmt
->depth_size
) - 1;
1737 TRACE("Depth format %s, using depthbias scale of %.8e.\n",
1738 debug_d3dformat(fmt
->id
), scale
);
1742 /* The context manager will reapply this state on a depth stencil change */
1743 TRACE("No depth stencil, using depthbias scale of 0.0.\n");
1747 glPolygonOffset(scale_bias
.f
, const_bias
.f
* scale
);
1748 checkGLcall("glPolygonOffset(...)");
1753 glDisable(GL_POLYGON_OFFSET_FILL
);
1754 checkGLcall("glDisable(GL_POLYGON_OFFSET_FILL)");
1758 static void state_zvisible(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1760 if (stateblock
->state
.render_states
[WINED3DRS_ZVISIBLE
])
1761 FIXME("WINED3DRS_ZVISIBLE not implemented.\n");
1764 static void state_perspective(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1766 if (stateblock
->state
.render_states
[WINED3DRS_TEXTUREPERSPECTIVE
])
1768 glHint(GL_PERSPECTIVE_CORRECTION_HINT
, GL_NICEST
);
1769 checkGLcall("glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)");
1771 glHint(GL_PERSPECTIVE_CORRECTION_HINT
, GL_FASTEST
);
1772 checkGLcall("glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST)");
1776 static void state_stippledalpha(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1778 if (stateblock
->state
.render_states
[WINED3DRS_STIPPLEDALPHA
])
1779 FIXME(" Stippled Alpha not supported yet.\n");
1782 static void state_antialias(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1784 if (stateblock
->state
.render_states
[WINED3DRS_ANTIALIAS
])
1785 FIXME("Antialias not supported yet.\n");
1788 static void state_multisampmask(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1790 if (stateblock
->state
.render_states
[WINED3DRS_MULTISAMPLEMASK
] != 0xffffffff)
1791 FIXME("WINED3DRS_MULTISAMPLEMASK %#x not yet implemented.\n",
1792 stateblock
->state
.render_states
[WINED3DRS_MULTISAMPLEMASK
]);
1795 static void state_patchedgestyle(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1797 if (stateblock
->state
.render_states
[WINED3DRS_PATCHEDGESTYLE
] != WINED3DPATCHEDGE_DISCRETE
)
1798 FIXME("WINED3DRS_PATCHEDGESTYLE %#x not yet implemented.\n",
1799 stateblock
->state
.render_states
[WINED3DRS_PATCHEDGESTYLE
]);
1802 static void state_patchsegments(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1810 if (stateblock
->state
.render_states
[WINED3DRS_PATCHSEGMENTS
] != tmpvalue
.d
)
1812 static BOOL displayed
= FALSE
;
1814 tmpvalue
.d
= stateblock
->state
.render_states
[WINED3DRS_PATCHSEGMENTS
];
1816 FIXME("(WINED3DRS_PATCHSEGMENTS,%f) not yet implemented\n", tmpvalue
.f
);
1822 static void state_positiondegree(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1824 if (stateblock
->state
.render_states
[WINED3DRS_POSITIONDEGREE
] != WINED3DDEGREE_CUBIC
)
1825 FIXME("WINED3DRS_POSITIONDEGREE %#x not yet implemented.\n",
1826 stateblock
->state
.render_states
[WINED3DRS_POSITIONDEGREE
]);
1829 static void state_normaldegree(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1831 if (stateblock
->state
.render_states
[WINED3DRS_NORMALDEGREE
] != WINED3DDEGREE_LINEAR
)
1832 FIXME("WINED3DRS_NORMALDEGREE %#x not yet implemented.\n",
1833 stateblock
->state
.render_states
[WINED3DRS_NORMALDEGREE
]);
1836 static void state_tessellation(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1838 if (stateblock
->state
.render_states
[WINED3DRS_ENABLEADAPTIVETESSELLATION
])
1839 FIXME("WINED3DRS_ENABLEADAPTIVETESSELLATION %#x not yet implemented.\n",
1840 stateblock
->state
.render_states
[WINED3DRS_ENABLEADAPTIVETESSELLATION
]);
1843 static void state_nvdb(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1850 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1852 if (stateblock
->state
.render_states
[WINED3DRS_ADAPTIVETESS_X
] == WINED3DFMT_NVDB
)
1854 zmin
.d
= stateblock
->state
.render_states
[WINED3DRS_ADAPTIVETESS_Z
];
1855 zmax
.d
= stateblock
->state
.render_states
[WINED3DRS_ADAPTIVETESS_W
];
1857 /* If zmin is larger than zmax INVALID_VALUE error is generated.
1858 * In d3d9 test is not performed in this case*/
1859 if (zmin
.f
<= zmax
.f
)
1861 glEnable(GL_DEPTH_BOUNDS_TEST_EXT
);
1862 checkGLcall("glEnable(GL_DEPTH_BOUNDS_TEST_EXT)");
1863 GL_EXTCALL(glDepthBoundsEXT(zmin
.f
, zmax
.f
));
1864 checkGLcall("glDepthBoundsEXT(...)");
1867 glDisable(GL_DEPTH_BOUNDS_TEST_EXT
);
1868 checkGLcall("glDisable(GL_DEPTH_BOUNDS_TEST_EXT)");
1872 glDisable(GL_DEPTH_BOUNDS_TEST_EXT
);
1873 checkGLcall("glDisable(GL_DEPTH_BOUNDS_TEST_EXT)");
1876 state_tessellation(state
, stateblock
, context
);
1879 static void state_wrapu(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1881 if (stateblock
->state
.render_states
[WINED3DRS_WRAPU
])
1882 FIXME("Render state WINED3DRS_WRAPU not implemented yet.\n");
1885 static void state_wrapv(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1887 if (stateblock
->state
.render_states
[WINED3DRS_WRAPV
])
1888 FIXME("Render state WINED3DRS_WRAPV not implemented yet.\n");
1891 static void state_monoenable(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1893 if (stateblock
->state
.render_states
[WINED3DRS_MONOENABLE
])
1894 FIXME("Render state WINED3DRS_MONOENABLE not implemented yet.\n");
1897 static void state_rop2(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1899 if (stateblock
->state
.render_states
[WINED3DRS_ROP2
])
1900 FIXME("Render state WINED3DRS_ROP2 not implemented yet.\n");
1903 static void state_planemask(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1905 if (stateblock
->state
.render_states
[WINED3DRS_PLANEMASK
])
1906 FIXME("Render state WINED3DRS_PLANEMASK not implemented yet.\n");
1909 static void state_subpixel(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1911 if (stateblock
->state
.render_states
[WINED3DRS_SUBPIXEL
])
1912 FIXME("Render state WINED3DRS_SUBPIXEL not implemented yet.\n");
1915 static void state_subpixelx(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1917 if (stateblock
->state
.render_states
[WINED3DRS_SUBPIXELX
])
1918 FIXME("Render state WINED3DRS_SUBPIXELX not implemented yet.\n");
1921 static void state_stippleenable(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1923 if (stateblock
->state
.render_states
[WINED3DRS_STIPPLEENABLE
])
1924 FIXME("Render state WINED3DRS_STIPPLEENABLE not implemented yet.\n");
1927 static void state_mipmaplodbias(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1929 if (stateblock
->state
.render_states
[WINED3DRS_MIPMAPLODBIAS
])
1930 FIXME("Render state WINED3DRS_MIPMAPLODBIAS not implemented yet.\n");
1933 static void state_anisotropy(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1935 if (stateblock
->state
.render_states
[WINED3DRS_ANISOTROPY
])
1936 FIXME("Render state WINED3DRS_ANISOTROPY not implemented yet.\n");
1939 static void state_flushbatch(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1941 if (stateblock
->state
.render_states
[WINED3DRS_FLUSHBATCH
])
1942 FIXME("Render state WINED3DRS_FLUSHBATCH not implemented yet.\n");
1945 static void state_translucentsi(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1947 if (stateblock
->state
.render_states
[WINED3DRS_TRANSLUCENTSORTINDEPENDENT
])
1948 FIXME("Render state WINED3DRS_TRANSLUCENTSORTINDEPENDENT not implemented yet.\n");
1951 static void state_extents(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1953 if (stateblock
->state
.render_states
[WINED3DRS_EXTENTS
])
1954 FIXME("Render state WINED3DRS_EXTENTS not implemented yet.\n");
1957 static void state_ckeyblend(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1959 if (stateblock
->state
.render_states
[WINED3DRS_COLORKEYBLENDENABLE
])
1960 FIXME("Render state WINED3DRS_COLORKEYBLENDENABLE not implemented yet.\n");
1963 static void state_swvp(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
1965 if (stateblock
->state
.render_states
[WINED3DRS_SOFTWAREVERTEXPROCESSING
])
1966 FIXME("Software vertex processing not implemented.\n");
1969 /* Set texture operations up - The following avoids lots of ifdefs in this routine!*/
1970 #if defined (GL_VERSION_1_3)
1971 # define useext(A) A
1972 #elif defined (GL_EXT_texture_env_combine)
1973 # define useext(A) A##_EXT
1974 #elif defined (GL_ARB_texture_env_combine)
1975 # define useext(A) A##_ARB
1978 static void get_src_and_opr(DWORD arg
, BOOL is_alpha
, GLenum
* source
, GLenum
* operand
) {
1979 /* The WINED3DTA_ALPHAREPLICATE flag specifies the alpha component of the
1980 * input should be used for all input components. The WINED3DTA_COMPLEMENT
1981 * flag specifies the complement of the input should be used. */
1982 BOOL from_alpha
= is_alpha
|| arg
& WINED3DTA_ALPHAREPLICATE
;
1983 BOOL complement
= arg
& WINED3DTA_COMPLEMENT
;
1985 /* Calculate the operand */
1987 if (from_alpha
) *operand
= GL_ONE_MINUS_SRC_ALPHA
;
1988 else *operand
= GL_ONE_MINUS_SRC_COLOR
;
1990 if (from_alpha
) *operand
= GL_SRC_ALPHA
;
1991 else *operand
= GL_SRC_COLOR
;
1994 /* Calculate the source */
1995 switch (arg
& WINED3DTA_SELECTMASK
) {
1996 case WINED3DTA_CURRENT
: *source
= GL_PREVIOUS_EXT
; break;
1997 case WINED3DTA_DIFFUSE
: *source
= GL_PRIMARY_COLOR_EXT
; break;
1998 case WINED3DTA_TEXTURE
: *source
= GL_TEXTURE
; break;
1999 case WINED3DTA_TFACTOR
: *source
= GL_CONSTANT_EXT
; break;
2000 case WINED3DTA_SPECULAR
:
2002 * According to the GL_ARB_texture_env_combine specs, SPECULAR is
2003 * 'Secondary color' and isn't supported until base GL supports it
2004 * There is no concept of temp registers as far as I can tell
2006 FIXME("Unhandled texture arg WINED3DTA_SPECULAR\n");
2007 *source
= GL_TEXTURE
;
2010 FIXME("Unrecognized texture arg %#x\n", arg
);
2011 *source
= GL_TEXTURE
;
2016 /* Setup the texture operations texture stage states */
2017 static void set_tex_op(const struct wined3d_gl_info
*gl_info
, const struct wined3d_state
*state
,
2018 BOOL isAlpha
, int Stage
, WINED3DTEXTUREOP op
, DWORD arg1
, DWORD arg2
, DWORD arg3
)
2020 GLenum src1
, src2
, src3
;
2021 GLenum opr1
, opr2
, opr3
;
2023 GLenum src0_target
, src1_target
, src2_target
;
2024 GLenum opr0_target
, opr1_target
, opr2_target
;
2026 GLenum opr
=0, invopr
, src3_target
, opr3_target
;
2027 BOOL Handled
= FALSE
;
2029 TRACE("Alpha?(%d), Stage:%d Op(%s), a1(%d), a2(%d), a3(%d)\n", isAlpha
, Stage
, debug_d3dtop(op
), arg1
, arg2
, arg3
);
2031 /* This is called by a state handler which has the gl lock held and a context for the thread */
2033 /* Note: Operations usually involve two ars, src0 and src1 and are operations of
2034 the form (a1 <operation> a2). However, some of the more complex operations
2035 take 3 parameters. Instead of the (sensible) addition of a3, Microsoft added
2036 in a third parameter called a0. Therefore these are operations of the form
2037 a0 <operation> a1 <operation> a2, i.e., the new parameter goes to the front.
2039 However, below we treat the new (a0) parameter as src2/opr2, so in the actual
2040 functions below, expect their syntax to differ slightly to those listed in the
2041 manuals, i.e., replace arg1 with arg3, arg2 with arg1 and arg3 with arg2
2042 This affects WINED3DTOP_MULTIPLYADD and WINED3DTOP_LERP */
2045 comb_target
= useext(GL_COMBINE_ALPHA
);
2046 src0_target
= useext(GL_SOURCE0_ALPHA
);
2047 src1_target
= useext(GL_SOURCE1_ALPHA
);
2048 src2_target
= useext(GL_SOURCE2_ALPHA
);
2049 opr0_target
= useext(GL_OPERAND0_ALPHA
);
2050 opr1_target
= useext(GL_OPERAND1_ALPHA
);
2051 opr2_target
= useext(GL_OPERAND2_ALPHA
);
2052 scal_target
= GL_ALPHA_SCALE
;
2055 comb_target
= useext(GL_COMBINE_RGB
);
2056 src0_target
= useext(GL_SOURCE0_RGB
);
2057 src1_target
= useext(GL_SOURCE1_RGB
);
2058 src2_target
= useext(GL_SOURCE2_RGB
);
2059 opr0_target
= useext(GL_OPERAND0_RGB
);
2060 opr1_target
= useext(GL_OPERAND1_RGB
);
2061 opr2_target
= useext(GL_OPERAND2_RGB
);
2062 scal_target
= useext(GL_RGB_SCALE
);
2065 /* If a texture stage references an invalid texture unit the stage just
2066 * passes through the result from the previous stage */
2067 if (is_invalid_op(state
, Stage
, op
, arg1
, arg2
, arg3
))
2069 arg1
= WINED3DTA_CURRENT
;
2070 op
= WINED3DTOP_SELECTARG1
;
2073 if (isAlpha
&& !state
->textures
[Stage
] && arg1
== WINED3DTA_TEXTURE
)
2075 get_src_and_opr(WINED3DTA_DIFFUSE
, isAlpha
, &src1
, &opr1
);
2077 get_src_and_opr(arg1
, isAlpha
, &src1
, &opr1
);
2079 get_src_and_opr(arg2
, isAlpha
, &src2
, &opr2
);
2080 get_src_and_opr(arg3
, isAlpha
, &src3
, &opr3
);
2082 TRACE("ct(%x), 1:(%x,%x), 2:(%x,%x), 3:(%x,%x)\n", comb_target
, src1
, opr1
, src2
, opr2
, src3
, opr3
);
2084 Handled
= TRUE
; /* Assume will be handled */
2086 /* Other texture operations require special extensions: */
2087 if (gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
2091 invopr
= GL_ONE_MINUS_SRC_ALPHA
;
2092 src3_target
= GL_SOURCE3_ALPHA_NV
;
2093 opr3_target
= GL_OPERAND3_ALPHA_NV
;
2096 invopr
= GL_ONE_MINUS_SRC_COLOR
;
2097 src3_target
= GL_SOURCE3_RGB_NV
;
2098 opr3_target
= GL_OPERAND3_RGB_NV
;
2101 case WINED3DTOP_DISABLE
: /* Only for alpha */
2102 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2103 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2104 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_PREVIOUS_EXT
);
2105 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2106 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_SRC_ALPHA
);
2107 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2108 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2109 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2110 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2111 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2112 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2113 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_ZERO");
2114 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2115 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2116 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2117 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2118 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2119 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2121 case WINED3DTOP_SELECTARG1
: /* = a1 * 1 + 0 * 0 */
2122 case WINED3DTOP_SELECTARG2
: /* = a2 * 1 + 0 * 0 */
2123 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2124 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2125 if (op
== WINED3DTOP_SELECTARG1
) {
2126 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2127 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2128 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2129 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2131 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src2
);
2132 checkGLcall("GL_TEXTURE_ENV, src0_target, src2");
2133 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr2
);
2134 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr2");
2136 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2137 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2138 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2139 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2140 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2141 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_ZERO");
2142 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2143 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2144 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2145 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2146 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2147 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2150 case WINED3DTOP_MODULATE
:
2151 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2152 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2153 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2154 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2155 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2156 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2157 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2158 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2159 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2160 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2161 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2162 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2163 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2164 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2165 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2166 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2167 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2168 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2169 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2170 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2172 case WINED3DTOP_MODULATE2X
:
2173 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2174 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2175 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2176 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2177 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2178 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2179 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2180 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2181 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2182 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2183 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2184 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2185 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2186 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2187 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2188 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2189 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2190 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2191 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2192 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2194 case WINED3DTOP_MODULATE4X
:
2195 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2196 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2197 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2198 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2199 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2200 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2201 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2202 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2203 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2204 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2205 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2206 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2207 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2208 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2209 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2210 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2211 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2212 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2213 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 4);
2214 checkGLcall("GL_TEXTURE_ENV, scal_target, 4");
2217 case WINED3DTOP_ADD
:
2218 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2219 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2220 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2221 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2222 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2223 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2224 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2225 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2226 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2227 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2228 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2229 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2230 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2231 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2232 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2233 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2234 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2235 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2236 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2237 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2240 case WINED3DTOP_ADDSIGNED
:
2241 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_ADD_SIGNED
));
2242 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_ADD_SIGNED)");
2243 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2244 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2245 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2246 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2247 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2248 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2249 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2250 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2251 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2252 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2253 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2254 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2255 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2256 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2257 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2258 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2259 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2260 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2263 case WINED3DTOP_ADDSIGNED2X
:
2264 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_ADD_SIGNED
));
2265 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_ADD_SIGNED)");
2266 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2267 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2268 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2269 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2270 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2271 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2272 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2273 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2274 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2275 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2276 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2277 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2278 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2279 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2280 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2281 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2282 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2283 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2286 case WINED3DTOP_ADDSMOOTH
:
2287 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2288 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2289 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2290 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2291 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2292 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2293 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2294 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2295 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2296 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2297 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2298 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2299 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2300 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2301 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
2302 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2304 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2305 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2306 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2307 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2309 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2310 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2311 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2312 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2315 case WINED3DTOP_BLENDDIFFUSEALPHA
:
2316 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2317 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2318 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2319 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2320 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2321 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2322 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, useext(GL_PRIMARY_COLOR
));
2323 checkGLcall("GL_TEXTURE_ENV, src1_target, useext(GL_PRIMARY_COLOR)");
2324 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2325 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2326 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2327 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2328 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2329 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2330 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, useext(GL_PRIMARY_COLOR
));
2331 checkGLcall("GL_TEXTURE_ENV, src3_target, useext(GL_PRIMARY_COLOR)");
2332 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2333 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2334 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2335 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2337 case WINED3DTOP_BLENDTEXTUREALPHA
:
2338 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2339 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2340 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2341 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2342 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2343 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2344 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_TEXTURE
);
2345 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_TEXTURE");
2346 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2347 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2348 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2349 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2350 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2351 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2352 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_TEXTURE
);
2353 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_TEXTURE");
2354 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2355 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2356 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2357 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2359 case WINED3DTOP_BLENDFACTORALPHA
:
2360 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2361 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2362 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2363 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2364 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2365 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2366 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, useext(GL_CONSTANT
));
2367 checkGLcall("GL_TEXTURE_ENV, src1_target, useext(GL_CONSTANT)");
2368 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2369 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2370 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2371 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2372 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2373 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2374 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, useext(GL_CONSTANT
));
2375 checkGLcall("GL_TEXTURE_ENV, src3_target, useext(GL_CONSTANT)");
2376 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2377 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2378 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2379 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2381 case WINED3DTOP_BLENDTEXTUREALPHAPM
:
2382 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2383 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2384 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2385 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2386 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2387 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2388 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2389 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2390 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2391 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2392 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2393 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2394 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2395 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2396 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_TEXTURE
);
2397 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_TEXTURE");
2398 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2399 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2400 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2401 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2403 case WINED3DTOP_MODULATEALPHA_ADDCOLOR
:
2404 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2405 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2406 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
); /* a0 = src1/opr1 */
2407 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2408 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2409 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1"); /* a1 = 1 (see docs) */
2410 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2411 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2412 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2413 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2414 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
); /* a2 = arg2 */
2415 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2416 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2417 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2"); /* a3 = src1 alpha */
2418 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
2419 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2421 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2422 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2424 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2425 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2426 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2427 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2429 case WINED3DTOP_MODULATECOLOR_ADDALPHA
:
2430 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2431 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2432 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2433 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2434 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2435 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2436 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2437 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2438 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2439 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2440 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
2441 checkGLcall("GL_TEXTURE_ENV, src2_target, src1");
2443 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2444 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2446 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2447 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2448 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2449 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2450 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2451 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2452 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2453 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2455 case WINED3DTOP_MODULATEINVALPHA_ADDCOLOR
:
2456 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2457 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2458 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2459 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2460 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2461 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2462 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2463 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2464 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2465 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2466 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2467 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2468 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2469 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2470 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
2471 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2473 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2474 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2475 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2476 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2478 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2479 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2480 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2481 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2483 case WINED3DTOP_MODULATEINVCOLOR_ADDALPHA
:
2484 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2485 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2486 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2487 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2489 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2490 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2491 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2492 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2494 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2495 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2496 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2497 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2498 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2499 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2500 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
2501 checkGLcall("GL_TEXTURE_ENV, src2_target, src1");
2503 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2504 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2506 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2507 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2508 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2509 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2510 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2511 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2512 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2513 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2515 case WINED3DTOP_MULTIPLYADD
:
2516 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2517 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2518 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src3
);
2519 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2520 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr3
);
2521 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2522 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2523 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2524 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2525 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2526 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
2527 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2528 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr1
);
2529 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2530 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src2
);
2531 checkGLcall("GL_TEXTURE_ENV, src3_target, src3");
2532 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr2
);
2533 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr3");
2534 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2535 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2538 case WINED3DTOP_BUMPENVMAP
:
2542 case WINED3DTOP_BUMPENVMAPLUMINANCE
:
2543 FIXME("Implement bump environment mapping in GL_NV_texture_env_combine4 path\n");
2549 glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_COMBINE4_NV
);
2550 checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV");
2554 } /* GL_NV_texture_env_combine4 */
2556 Handled
= TRUE
; /* Again, assume handled */
2558 case WINED3DTOP_DISABLE
: /* Only for alpha */
2559 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
2560 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2561 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_PREVIOUS_EXT
);
2562 checkGLcall("GL_TEXTURE_ENV, src0_target, GL_PREVIOUS_EXT");
2563 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_SRC_ALPHA
);
2564 checkGLcall("GL_TEXTURE_ENV, opr0_target, GL_SRC_ALPHA");
2565 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2566 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2568 case WINED3DTOP_SELECTARG1
:
2569 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
2570 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2571 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2572 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2573 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2574 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2575 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2576 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2578 case WINED3DTOP_SELECTARG2
:
2579 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
2580 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2581 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src2
);
2582 checkGLcall("GL_TEXTURE_ENV, src0_target, src2");
2583 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr2
);
2584 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr2");
2585 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2586 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2588 case WINED3DTOP_MODULATE
:
2589 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
2590 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2591 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2592 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2593 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2594 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2595 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2596 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2597 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2598 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2599 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2600 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2602 case WINED3DTOP_MODULATE2X
:
2603 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
2604 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2605 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2606 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2607 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2608 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2609 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2610 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2611 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2612 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2613 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2614 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2616 case WINED3DTOP_MODULATE4X
:
2617 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
2618 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2619 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2620 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2621 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2622 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2623 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2624 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2625 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2626 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2627 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 4);
2628 checkGLcall("GL_TEXTURE_ENV, scal_target, 4");
2630 case WINED3DTOP_ADD
:
2631 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2632 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2633 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2634 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2635 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2636 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2637 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2638 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2639 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2640 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2641 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2642 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2644 case WINED3DTOP_ADDSIGNED
:
2645 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_ADD_SIGNED
));
2646 checkGLcall("GL_TEXTURE_ENV, comb_target, useext((GL_ADD_SIGNED)");
2647 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2648 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2649 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2650 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2651 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2652 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2653 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2654 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2655 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2656 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2658 case WINED3DTOP_ADDSIGNED2X
:
2659 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_ADD_SIGNED
));
2660 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_ADD_SIGNED)");
2661 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2662 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2663 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2664 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2665 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2666 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2667 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2668 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2669 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2670 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2672 case WINED3DTOP_SUBTRACT
:
2673 if (gl_info
->supported
[ARB_TEXTURE_ENV_COMBINE
])
2675 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_SUBTRACT
);
2676 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_SUBTRACT)");
2677 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2678 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2679 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2680 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2681 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2682 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2683 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2684 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2685 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2686 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2688 FIXME("This version of opengl does not support GL_SUBTRACT\n");
2692 case WINED3DTOP_BLENDDIFFUSEALPHA
:
2693 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_INTERPOLATE
));
2694 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_INTERPOLATE)");
2695 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2696 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2697 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2698 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2699 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2700 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2701 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2702 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2703 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, useext(GL_PRIMARY_COLOR
));
2704 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_PRIMARY_COLOR");
2705 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2706 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2707 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2708 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2710 case WINED3DTOP_BLENDTEXTUREALPHA
:
2711 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_INTERPOLATE
));
2712 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_INTERPOLATE)");
2713 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2714 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2715 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2716 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2717 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2718 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2719 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2720 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2721 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_TEXTURE
);
2722 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_TEXTURE");
2723 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2724 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2725 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2726 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2728 case WINED3DTOP_BLENDFACTORALPHA
:
2729 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_INTERPOLATE
));
2730 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_INTERPOLATE)");
2731 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2732 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2733 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2734 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2735 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2736 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2737 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2738 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2739 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, useext(GL_CONSTANT
));
2740 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_CONSTANT");
2741 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2742 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2743 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2744 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2746 case WINED3DTOP_BLENDCURRENTALPHA
:
2747 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_INTERPOLATE
));
2748 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_INTERPOLATE)");
2749 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2750 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2751 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2752 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2753 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2754 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2755 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2756 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2757 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, useext(GL_PREVIOUS
));
2758 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_PREVIOUS");
2759 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2760 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2761 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2762 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2764 case WINED3DTOP_DOTPRODUCT3
:
2765 if (gl_info
->supported
[ARB_TEXTURE_ENV_DOT3
])
2767 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_DOT3_RGBA_ARB
);
2768 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_ARB");
2770 else if (gl_info
->supported
[EXT_TEXTURE_ENV_DOT3
])
2772 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_DOT3_RGBA_EXT
);
2773 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_EXT");
2775 FIXME("This version of opengl does not support GL_DOT3\n");
2777 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2778 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2779 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2780 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2781 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2782 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2783 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2784 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2785 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2786 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2788 case WINED3DTOP_LERP
:
2789 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_INTERPOLATE
));
2790 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_INTERPOLATE)");
2791 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2792 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2793 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2794 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2795 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2796 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2797 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2798 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2799 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src3
);
2800 checkGLcall("GL_TEXTURE_ENV, src2_target, src3");
2801 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr3
);
2802 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr3");
2803 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2804 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2806 case WINED3DTOP_ADDSMOOTH
:
2807 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2809 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2810 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2811 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2812 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2814 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2815 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2816 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2817 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2819 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2820 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2821 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2822 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2823 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2824 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2825 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2826 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2827 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2828 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2829 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2830 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2834 case WINED3DTOP_BLENDTEXTUREALPHAPM
:
2835 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2837 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2838 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2839 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_TEXTURE
);
2840 checkGLcall("GL_TEXTURE_ENV, src0_target, GL_TEXTURE");
2841 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_ONE_MINUS_SRC_ALPHA
);
2842 checkGLcall("GL_TEXTURE_ENV, opr0_target, GL_ONE_MINUS_SRC_APHA");
2843 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2844 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2845 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2846 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2847 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2848 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2849 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2850 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2851 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2852 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2856 case WINED3DTOP_MODULATEALPHA_ADDCOLOR
:
2857 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2859 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2860 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2861 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2862 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2864 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2865 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2866 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2867 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2869 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2870 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2871 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2872 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2873 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2874 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2875 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2876 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2877 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2878 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2879 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2880 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2884 case WINED3DTOP_MODULATECOLOR_ADDALPHA
:
2885 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2887 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2888 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2889 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2890 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2891 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2892 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2893 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2894 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2896 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2897 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2898 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2899 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2901 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr
);
2902 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr");
2903 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2904 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2905 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2906 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2907 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2908 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2912 case WINED3DTOP_MODULATEINVALPHA_ADDCOLOR
:
2913 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2915 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2916 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2917 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2918 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2920 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2921 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2922 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2923 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2925 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2926 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2927 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2928 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2929 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2930 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2931 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2932 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2933 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2934 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2935 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2936 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2940 case WINED3DTOP_MODULATEINVCOLOR_ADDALPHA
:
2941 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2943 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2944 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2945 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2946 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2948 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2949 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2950 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2951 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2953 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2954 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2955 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2956 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2958 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2959 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2960 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2961 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2963 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr
);
2964 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr");
2965 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2966 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2967 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2968 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2969 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2970 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2974 case WINED3DTOP_MULTIPLYADD
:
2975 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2977 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2978 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2979 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2980 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2981 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2982 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2983 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src3
);
2984 checkGLcall("GL_TEXTURE_ENV, src1_target, src3");
2985 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr3
);
2986 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr3");
2987 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2988 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2989 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2990 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2991 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2992 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2996 case WINED3DTOP_BUMPENVMAPLUMINANCE
:
2997 case WINED3DTOP_BUMPENVMAP
:
2998 if (gl_info
->supported
[NV_TEXTURE_SHADER2
])
3000 /* Technically texture shader support without register combiners is possible, but not expected to occur
3001 * on real world cards, so for now a fixme should be enough
3003 FIXME("Implement bump mapping with GL_NV_texture_shader in non register combiner path\n");
3010 BOOL combineOK
= TRUE
;
3011 if (gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
3016 op2
= state
->texture_states
[Stage
][WINED3DTSS_COLOROP
];
3018 op2
= state
->texture_states
[Stage
][WINED3DTSS_ALPHAOP
];
3020 /* Note: If COMBINE4 in effect can't go back to combine! */
3022 case WINED3DTOP_ADDSMOOTH
:
3023 case WINED3DTOP_BLENDTEXTUREALPHAPM
:
3024 case WINED3DTOP_MODULATEALPHA_ADDCOLOR
:
3025 case WINED3DTOP_MODULATECOLOR_ADDALPHA
:
3026 case WINED3DTOP_MODULATEINVALPHA_ADDCOLOR
:
3027 case WINED3DTOP_MODULATEINVCOLOR_ADDALPHA
:
3028 case WINED3DTOP_MULTIPLYADD
:
3029 /* Ignore those implemented in both cases */
3031 case WINED3DTOP_SELECTARG1
:
3032 case WINED3DTOP_SELECTARG2
:
3037 FIXME("Can't use COMBINE4 and COMBINE together, thisop=%s, otherop=%s, isAlpha(%d)\n", debug_d3dtop(op
), debug_d3dtop(op2
), isAlpha
);
3044 glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, useext(GL_COMBINE
));
3045 checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, useext(GL_COMBINE)");
3051 /* After all the extensions, if still unhandled, report fixme */
3052 FIXME("Unhandled texture operation %s\n", debug_d3dtop(op
));
3056 static void tex_colorop(DWORD state_id
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
3058 DWORD stage
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3059 BOOL tex_used
= stateblock
->device
->fixed_function_usage_map
& (1 << stage
);
3060 DWORD mapped_stage
= stateblock
->device
->texUnitMap
[stage
];
3061 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3062 const struct wined3d_state
*state
= &stateblock
->state
;
3064 TRACE("Setting color op for stage %d\n", stage
);
3066 /* Using a pixel shader? Don't care for anything here, the shader applying does it */
3067 if (use_ps(state
)) return;
3069 if (stage
!= mapped_stage
) WARN("Using non 1:1 mapping: %d -> %d!\n", stage
, mapped_stage
);
3071 if (mapped_stage
!= WINED3D_UNMAPPED_STAGE
)
3073 if (tex_used
&& mapped_stage
>= gl_info
->limits
.textures
)
3075 FIXME("Attempt to enable unsupported stage!\n");
3078 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
3079 checkGLcall("glActiveTextureARB");
3082 if (stage
>= state
->lowest_disabled_stage
)
3084 TRACE("Stage disabled\n");
3085 if (mapped_stage
!= WINED3D_UNMAPPED_STAGE
)
3087 /* Disable everything here */
3088 glDisable(GL_TEXTURE_2D
);
3089 checkGLcall("glDisable(GL_TEXTURE_2D)");
3090 glDisable(GL_TEXTURE_3D
);
3091 checkGLcall("glDisable(GL_TEXTURE_3D)");
3092 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
3094 glDisable(GL_TEXTURE_CUBE_MAP_ARB
);
3095 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
3097 if (gl_info
->supported
[ARB_TEXTURE_RECTANGLE
])
3099 glDisable(GL_TEXTURE_RECTANGLE_ARB
);
3100 checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)");
3107 /* The sampler will also activate the correct texture dimensions, so no
3108 * need to do it here if the sampler for this stage is dirty. */
3109 if (!isStateDirty(context
, STATE_SAMPLER(stage
)) && tex_used
)
3110 texture_activate_dimensions(state
->textures
[stage
], gl_info
);
3112 set_tex_op(gl_info
, state
, FALSE
, stage
,
3113 state
->texture_states
[stage
][WINED3DTSS_COLOROP
],
3114 state
->texture_states
[stage
][WINED3DTSS_COLORARG1
],
3115 state
->texture_states
[stage
][WINED3DTSS_COLORARG2
],
3116 state
->texture_states
[stage
][WINED3DTSS_COLORARG0
]);
3119 void tex_alphaop(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
3121 DWORD stage
= (state
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3122 BOOL tex_used
= stateblock
->device
->fixed_function_usage_map
& (1 << stage
);
3123 DWORD mapped_stage
= stateblock
->device
->texUnitMap
[stage
];
3124 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3125 DWORD op
, arg1
, arg2
, arg0
;
3127 TRACE("Setting alpha op for stage %d\n", stage
);
3128 /* Do not care for enabled / disabled stages, just assign the settings. colorop disables / enables required stuff */
3129 if (mapped_stage
!= WINED3D_UNMAPPED_STAGE
)
3131 if (tex_used
&& mapped_stage
>= gl_info
->limits
.textures
)
3133 FIXME("Attempt to enable unsupported stage!\n");
3136 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
3137 checkGLcall("glActiveTextureARB");
3140 op
= stateblock
->state
.texture_states
[stage
][WINED3DTSS_ALPHAOP
];
3141 arg1
= stateblock
->state
.texture_states
[stage
][WINED3DTSS_ALPHAARG1
];
3142 arg2
= stateblock
->state
.texture_states
[stage
][WINED3DTSS_ALPHAARG2
];
3143 arg0
= stateblock
->state
.texture_states
[stage
][WINED3DTSS_ALPHAARG0
];
3145 if (stateblock
->state
.render_states
[WINED3DRS_COLORKEYENABLE
] && !stage
&& stateblock
->state
.textures
[0])
3147 struct wined3d_texture
*texture
= stateblock
->state
.textures
[0];
3148 GLenum texture_dimensions
= texture
->target
;
3150 if (texture_dimensions
== GL_TEXTURE_2D
|| texture_dimensions
== GL_TEXTURE_RECTANGLE_ARB
)
3152 struct wined3d_surface
*surf
= surface_from_resource(texture
->sub_resources
[0]);
3154 if (surf
->CKeyFlags
& WINEDDSD_CKSRCBLT
&& !surf
->resource
.format
->alpha_mask
)
3156 /* Color keying needs to pass alpha values from the texture through to have the alpha test work
3157 * properly. On the other hand applications can still use texture combiners apparently. This code
3158 * takes care that apps cannot remove the texture's alpha channel entirely.
3160 * The fixup is required for Prince of Persia 3D(prison bars), while Moto racer 2 requires
3161 * D3DTOP_MODULATE to work on color keyed surfaces. Aliens vs Predator 1 uses color keyed textures
3162 * and alpha component of diffuse color to draw things like translucent text and perform other
3165 * Aliens vs Predator 1 relies on diffuse alpha having an effect, so it cannot be ignored. To
3166 * provide the behavior expected by the game, while emulating the colorkey, diffuse alpha must be
3167 * modulated with texture alpha. OTOH, Moto racer 2 at some points sets alphaop/alphaarg to
3168 * SELECTARG/CURRENT, yet puts garbage in diffuse alpha (zeroes). This works on native, because the
3169 * game disables alpha test and alpha blending. Alpha test is overwritten by wine's for purposes of
3170 * color-keying though, so this will lead to missing geometry if texture alpha is modulated (pixels
3171 * fail alpha test). To get around this, ALPHABLENDENABLE state is checked: if the app enables alpha
3172 * blending, it can be expected to provide meaningful values in diffuse alpha, so it should be
3173 * modulated with texture alpha; otherwise, selecting diffuse alpha is ignored in favour of texture
3176 * What to do with multitexturing? So far no app has been found that uses color keying with
3178 if (op
== WINED3DTOP_DISABLE
)
3180 arg1
= WINED3DTA_TEXTURE
;
3181 op
= WINED3DTOP_SELECTARG1
;
3183 else if(op
== WINED3DTOP_SELECTARG1
&& arg1
!= WINED3DTA_TEXTURE
)
3185 if (stateblock
->state
.render_states
[WINED3DRS_ALPHABLENDENABLE
])
3187 arg2
= WINED3DTA_TEXTURE
;
3188 op
= WINED3DTOP_MODULATE
;
3190 else arg1
= WINED3DTA_TEXTURE
;
3192 else if(op
== WINED3DTOP_SELECTARG2
&& arg2
!= WINED3DTA_TEXTURE
)
3194 if (stateblock
->state
.render_states
[WINED3DRS_ALPHABLENDENABLE
])
3196 arg1
= WINED3DTA_TEXTURE
;
3197 op
= WINED3DTOP_MODULATE
;
3199 else arg2
= WINED3DTA_TEXTURE
;
3205 /* tex_alphaop is shared between the ffp and nvrc because the difference only comes down to
3206 * this if block here, and the other code(color keying, texture unit selection) are the same
3208 TRACE("Setting alpha op for stage %d\n", stage
);
3209 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
3211 set_tex_op_nvrc(gl_info
, &stateblock
->state
, TRUE
, stage
, op
, arg1
, arg2
, arg0
,
3212 mapped_stage
, stateblock
->state
.texture_states
[stage
][WINED3DTSS_RESULTARG
]);
3216 set_tex_op(gl_info
, &stateblock
->state
, TRUE
, stage
, op
, arg1
, arg2
, arg0
);
3220 static void transform_texture(DWORD state_id
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
3222 DWORD texUnit
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3223 DWORD mapped_stage
= stateblock
->device
->texUnitMap
[texUnit
];
3224 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3225 const struct wined3d_state
*state
= &stateblock
->state
;
3229 /* Ignore this when a vertex shader is used, or if the streams aren't sorted out yet */
3230 if (use_vs(state
) || isStateDirty(context
, STATE_VDECL
))
3232 TRACE("Using a vertex shader, or stream sources not sorted out yet, skipping\n");
3236 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
) return;
3237 if (mapped_stage
>= gl_info
->limits
.textures
) return;
3239 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
3240 checkGLcall("glActiveTextureARB");
3241 generated
= (state
->texture_states
[texUnit
][WINED3DTSS_TEXCOORDINDEX
] & 0xffff0000) != WINED3DTSS_TCI_PASSTHRU
;
3242 coordIdx
= min(state
->texture_states
[texUnit
][WINED3DTSS_TEXCOORDINDEX
& 0x0000ffff], MAX_TEXTURES
- 1);
3244 set_texture_matrix(&state
->transforms
[WINED3DTS_TEXTURE0
+ texUnit
].u
.m
[0][0],
3245 state
->texture_states
[texUnit
][WINED3DTSS_TEXTURETRANSFORMFLAGS
],
3246 generated
, context
->last_was_rhw
,
3247 stateblock
->device
->strided_streams
.use_map
& (1 << (WINED3D_FFP_TEXCOORD0
+ coordIdx
))
3248 ? stateblock
->device
->strided_streams
.elements
[WINED3D_FFP_TEXCOORD0
+ coordIdx
].format
->id
3249 : WINED3DFMT_UNKNOWN
,
3250 stateblock
->device
->frag_pipe
->ffp_proj_control
);
3252 /* The sampler applying function calls us if this changes */
3253 if ((context
->lastWasPow2Texture
& (1 << texUnit
)) && state
->textures
[texUnit
])
3256 FIXME("Non-power2 texture being used with generated texture coords\n");
3258 /* NP2 texcoord fixup is implemented for pixelshaders so only enable the
3259 fixed-function-pipeline fixup via pow2Matrix when no PS is used. */
3262 TRACE("Non power two matrix multiply fixup\n");
3263 glMultMatrixf(state
->textures
[texUnit
]->pow2_matrix
);
3268 static void unloadTexCoords(const struct wined3d_gl_info
*gl_info
)
3270 unsigned int texture_idx
;
3272 for (texture_idx
= 0; texture_idx
< gl_info
->limits
.texture_stages
; ++texture_idx
)
3274 GL_EXTCALL(glClientActiveTextureARB(GL_TEXTURE0_ARB
+ texture_idx
));
3275 glDisableClientState(GL_TEXTURE_COORD_ARRAY
);
3279 static void loadTexCoords(const struct wined3d_gl_info
*gl_info
, struct wined3d_stateblock
*stateblock
,
3280 const struct wined3d_stream_info
*si
, GLuint
*curVBO
)
3282 unsigned int mapped_stage
= 0;
3283 unsigned int textureNo
= 0;
3285 for (textureNo
= 0; textureNo
< gl_info
->limits
.texture_stages
; ++textureNo
)
3287 int coordIdx
= stateblock
->state
.texture_states
[textureNo
][WINED3DTSS_TEXCOORDINDEX
];
3289 mapped_stage
= stateblock
->device
->texUnitMap
[textureNo
];
3290 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
) continue;
3292 if (coordIdx
< MAX_TEXTURES
&& (si
->use_map
& (1 << (WINED3D_FFP_TEXCOORD0
+ coordIdx
))))
3294 const struct wined3d_stream_info_element
*e
= &si
->elements
[WINED3D_FFP_TEXCOORD0
+ coordIdx
];
3295 const struct wined3d_stream_state
*stream
= &stateblock
->state
.streams
[e
->stream_idx
];
3297 TRACE("Setting up texture %u, idx %d, coordindx %u, data {%#x:%p}.\n",
3298 textureNo
, mapped_stage
, coordIdx
, e
->data
.buffer_object
, e
->data
.addr
);
3300 if (*curVBO
!= e
->data
.buffer_object
)
3302 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, e
->data
.buffer_object
));
3303 checkGLcall("glBindBufferARB");
3304 *curVBO
= e
->data
.buffer_object
;
3307 GL_EXTCALL(glClientActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
3308 checkGLcall("glClientActiveTextureARB");
3310 /* The coords to supply depend completely on the fvf / vertex shader */
3311 glTexCoordPointer(e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
3312 e
->data
.addr
+ stateblock
->state
.load_base_vertex_index
* e
->stride
+ stream
->offset
);
3313 glEnableClientState(GL_TEXTURE_COORD_ARRAY
);
3317 GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB
+ mapped_stage
, 0, 0, 0, 1));
3320 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
3322 /* The number of the mapped stages increases monotonically, so it's fine to use the last used one. */
3323 for (textureNo
= mapped_stage
+ 1; textureNo
< gl_info
->limits
.textures
; ++textureNo
)
3325 GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB
+ textureNo
, 0, 0, 0, 1));
3329 checkGLcall("loadTexCoords");
3332 static void tex_coordindex(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
3334 DWORD stage
= (state
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3335 DWORD mapped_stage
= stateblock
->device
->texUnitMap
[stage
];
3336 static const GLfloat s_plane
[] = { 1.0f
, 0.0f
, 0.0f
, 0.0f
};
3337 static const GLfloat t_plane
[] = { 0.0f
, 1.0f
, 0.0f
, 0.0f
};
3338 static const GLfloat r_plane
[] = { 0.0f
, 0.0f
, 1.0f
, 0.0f
};
3339 static const GLfloat q_plane
[] = { 0.0f
, 0.0f
, 0.0f
, 1.0f
};
3340 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3342 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
)
3344 TRACE("No texture unit mapped to stage %d. Skipping texture coordinates.\n", stage
);
3348 if (mapped_stage
>= gl_info
->limits
.fragment_samplers
)
3350 WARN("stage %u not mapped to a valid texture unit (%u)\n", stage
, mapped_stage
);
3353 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
3354 checkGLcall("glActiveTextureARB");
3356 /* Values 0-7 are indexes into the FVF tex coords - See comments in DrawPrimitive
3358 * FIXME: When using generated texture coordinates, the index value is used to specify the wrapping mode.
3359 * eg. SetTextureStageState( 0, WINED3DTSS_TEXCOORDINDEX, WINED3DTSS_TCI_CAMERASPACEPOSITION | 1 );
3360 * means use the vertex position (camera-space) as the input texture coordinates
3361 * for this texture stage, and the wrap mode set in the WINED3DRS_WRAP1 render
3362 * state. We do not (yet) support the WINED3DRENDERSTATE_WRAPx values, nor tie them up
3363 * to the TEXCOORDINDEX value
3365 switch (stateblock
->state
.texture_states
[stage
][WINED3DTSS_TEXCOORDINDEX
] & 0xffff0000)
3367 case WINED3DTSS_TCI_PASSTHRU
:
3368 /* Use the specified texture coordinates contained within the
3369 * vertex format. This value resolves to zero. */
3370 glDisable(GL_TEXTURE_GEN_S
);
3371 glDisable(GL_TEXTURE_GEN_T
);
3372 glDisable(GL_TEXTURE_GEN_R
);
3373 glDisable(GL_TEXTURE_GEN_Q
);
3374 checkGLcall("WINED3DTSS_TCI_PASSTHRU - Disable texgen.");
3377 case WINED3DTSS_TCI_CAMERASPACEPOSITION
:
3378 /* CameraSpacePosition means use the vertex position, transformed to camera space,
3379 * as the input texture coordinates for this stage's texture transformation. This
3380 * equates roughly to EYE_LINEAR */
3382 glMatrixMode(GL_MODELVIEW
);
3385 glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
3386 glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
3387 glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
3388 glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
3390 checkGLcall("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set eye plane.");
3392 glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
3393 glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
3394 glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
3395 checkGLcall("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set texgen mode.");
3397 glEnable(GL_TEXTURE_GEN_S
);
3398 glEnable(GL_TEXTURE_GEN_T
);
3399 glEnable(GL_TEXTURE_GEN_R
);
3400 checkGLcall("WINED3DTSS_TCI_CAMERASPACEPOSITION - Enable texgen.");
3404 case WINED3DTSS_TCI_CAMERASPACENORMAL
:
3405 /* Note that NV_TEXGEN_REFLECTION support is implied when
3406 * ARB_TEXTURE_CUBE_MAP is supported */
3407 if (!gl_info
->supported
[NV_TEXGEN_REFLECTION
])
3409 FIXME("WINED3DTSS_TCI_CAMERASPACENORMAL not supported.\n");
3413 glMatrixMode(GL_MODELVIEW
);
3416 glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
3417 glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
3418 glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
3419 glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
3421 checkGLcall("WINED3DTSS_TCI_CAMERASPACENORMAL - Set eye plane.");
3423 glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
3424 glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
3425 glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
3426 checkGLcall("WINED3DTSS_TCI_CAMERASPACENORMAL - Set texgen mode.");
3428 glEnable(GL_TEXTURE_GEN_S
);
3429 glEnable(GL_TEXTURE_GEN_T
);
3430 glEnable(GL_TEXTURE_GEN_R
);
3431 checkGLcall("WINED3DTSS_TCI_CAMERASPACENORMAL - Enable texgen.");
3435 case WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR
:
3436 /* Note that NV_TEXGEN_REFLECTION support is implied when
3437 * ARB_TEXTURE_CUBE_MAP is supported */
3438 if (!gl_info
->supported
[NV_TEXGEN_REFLECTION
])
3440 FIXME("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR not supported.\n");
3444 glMatrixMode(GL_MODELVIEW
);
3447 glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
3448 glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
3449 glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
3450 glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
3452 checkGLcall("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Set eye plane.");
3454 glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
3455 glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
3456 glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
3457 checkGLcall("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Set texgen mode.");
3459 glEnable(GL_TEXTURE_GEN_S
);
3460 glEnable(GL_TEXTURE_GEN_T
);
3461 glEnable(GL_TEXTURE_GEN_R
);
3462 checkGLcall("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Enable texgen.");
3466 case WINED3DTSS_TCI_SPHEREMAP
:
3467 glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_SPHERE_MAP
);
3468 glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_SPHERE_MAP
);
3469 checkGLcall("WINED3DTSS_TCI_SPHEREMAP - Set texgen mode.");
3471 glEnable(GL_TEXTURE_GEN_S
);
3472 glEnable(GL_TEXTURE_GEN_T
);
3473 glDisable(GL_TEXTURE_GEN_R
);
3474 checkGLcall("WINED3DTSS_TCI_SPHEREMAP - Enable texgen.");
3479 FIXME("Unhandled WINED3DTSS_TEXCOORDINDEX %#x.\n",
3480 stateblock
->state
.texture_states
[stage
][WINED3DTSS_TEXCOORDINDEX
]);
3481 glDisable(GL_TEXTURE_GEN_S
);
3482 glDisable(GL_TEXTURE_GEN_T
);
3483 glDisable(GL_TEXTURE_GEN_R
);
3484 glDisable(GL_TEXTURE_GEN_Q
);
3485 checkGLcall("Disable texgen.");
3490 /* Update the texture matrix */
3491 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_TEXTURE0
+ stage
))) {
3492 transform_texture(STATE_TEXTURESTAGE(stage
, WINED3DTSS_TEXTURETRANSFORMFLAGS
), stateblock
, context
);
3495 if(!isStateDirty(context
, STATE_VDECL
) && context
->namedArraysLoaded
) {
3496 /* Reload the arrays if we are using fixed function arrays to reflect the selected coord input
3497 * source. Call loadTexCoords directly because there is no need to reparse the vertex declaration
3498 * and do all the things linked to it
3499 * TODO: Tidy that up to reload only the arrays of the changed unit
3501 GLuint curVBO
= gl_info
->supported
[ARB_VERTEX_BUFFER_OBJECT
] ? ~0U : 0;
3503 unloadTexCoords(gl_info
);
3504 loadTexCoords(gl_info
, stateblock
, &stateblock
->device
->strided_streams
, &curVBO
);
3508 static void tex_bumpenvlscale(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
3510 DWORD stage
= (state
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3511 const struct wined3d_shader
*ps
= stateblock
->state
.pixel_shader
;
3513 if (ps
&& stage
&& (ps
->reg_maps
.luminanceparams
& (1 << stage
)))
3515 /* The pixel shader has to know the luminance scale. Do a constants update if it
3516 * isn't scheduled anyway
3518 if(!isStateDirty(context
, STATE_PIXELSHADERCONSTANT
) &&
3519 !isStateDirty(context
, STATE_PIXELSHADER
)) {
3520 shaderconstant(STATE_PIXELSHADERCONSTANT
, stateblock
, context
);
3525 static void sampler_texmatrix(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
3527 const DWORD sampler
= state
- STATE_SAMPLER(0);
3528 struct wined3d_texture
*texture
= stateblock
->state
.textures
[sampler
];
3530 TRACE("state %#x, stateblock %p, context %p\n", state
, stateblock
, context
);
3532 if(!texture
) return;
3533 /* The fixed function np2 texture emulation uses the texture matrix to fix up the coordinates
3534 * wined3d_texture_apply_state_changes() multiplies the set matrix with a fixup matrix. Before the
3535 * scaling is reapplied or removed, the texture matrix has to be reapplied
3537 * The mapped stage is already active because the sampler() function below, which is part of the
3540 if (sampler
< MAX_TEXTURES
)
3542 const BOOL texIsPow2
= !(texture
->flags
& WINED3D_TEXTURE_POW2_MAT_IDENT
);
3544 if (texIsPow2
|| (context
->lastWasPow2Texture
& (1 << sampler
)))
3546 if (texIsPow2
) context
->lastWasPow2Texture
|= 1 << sampler
;
3547 else context
->lastWasPow2Texture
&= ~(1 << sampler
);
3548 transform_texture(STATE_TEXTURESTAGE(stateblock
->device
->texUnitMap
[sampler
],
3549 WINED3DTSS_TEXTURETRANSFORMFLAGS
), stateblock
, context
);
3554 static void sampler(DWORD state_id
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
3556 DWORD sampler
= state_id
- STATE_SAMPLER(0);
3557 struct wined3d_device
*device
= stateblock
->device
;
3558 DWORD mapped_stage
= device
->texUnitMap
[sampler
];
3559 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3560 const struct wined3d_state
*state
= &stateblock
->state
;
3566 TRACE("Sampler: %d\n", sampler
);
3567 /* Enabling and disabling texture dimensions is done by texture stage state / pixel shader setup, this function
3568 * only has to bind textures and set the per texture states
3571 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
)
3573 TRACE("No sampler mapped to stage %d. Returning.\n", sampler
);
3577 if (mapped_stage
>= gl_info
->limits
.combined_samplers
)
3581 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
3582 checkGLcall("glActiveTextureARB");
3584 if (state
->textures
[sampler
])
3586 struct wined3d_texture
*texture
= state
->textures
[sampler
];
3587 BOOL srgb
= state
->sampler_states
[sampler
][WINED3DSAMP_SRGBTEXTURE
];
3589 texture
->texture_ops
->texture_bind(texture
, gl_info
, srgb
);
3590 wined3d_texture_apply_state_changes(texture
, state
->sampler_states
[sampler
], gl_info
);
3592 if (gl_info
->supported
[EXT_TEXTURE_LOD_BIAS
])
3594 tmpvalue
.d
= state
->sampler_states
[sampler
][WINED3DSAMP_MIPMAPLODBIAS
];
3595 glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT
,
3596 GL_TEXTURE_LOD_BIAS_EXT
,
3598 checkGLcall("glTexEnvf(GL_TEXTURE_LOD_BIAS_EXT, ...)");
3601 if (!use_ps(state
) && sampler
< state
->lowest_disabled_stage
)
3603 if (state
->render_states
[WINED3DRS_COLORKEYENABLE
] && !sampler
)
3605 /* If color keying is enabled update the alpha test, it depends on the existence
3606 * of a color key in stage 0
3608 state_alpha(WINED3DRS_COLORKEYENABLE
, stateblock
, context
);
3612 /* Trigger shader constant reloading (for NP2 texcoord fixup) */
3613 if (!(texture
->flags
& WINED3D_TEXTURE_POW2_MAT_IDENT
))
3614 device
->shader_backend
->shader_load_np2fixup_constants(device
->shader_priv
, gl_info
, state
);
3616 else if (mapped_stage
< gl_info
->limits
.textures
)
3618 if (sampler
< state
->lowest_disabled_stage
)
3620 /* TODO: What should I do with pixel shaders here ??? */
3621 if (state
->render_states
[WINED3DRS_COLORKEYENABLE
] && !sampler
)
3623 /* If color keying is enabled update the alpha test, it depends on the existence
3624 * of a color key in stage 0
3626 state_alpha(WINED3DRS_COLORKEYENABLE
, stateblock
, context
);
3628 } /* Otherwise tex_colorop disables the stage */
3629 glBindTexture(GL_TEXTURE_2D
, device
->dummyTextureName
[sampler
]);
3630 checkGLcall("glBindTexture(GL_TEXTURE_2D, device->dummyTextureName[sampler])");
3634 void apply_pixelshader(DWORD state_id
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
3636 const struct wined3d_state
*state
= &stateblock
->state
;
3637 struct wined3d_device
*device
= stateblock
->device
;
3638 BOOL use_vshader
= use_vs(state
);
3639 BOOL use_pshader
= use_ps(state
);
3643 if(!context
->last_was_pshader
) {
3644 /* Former draw without a pixel shader, some samplers
3645 * may be disabled because of WINED3DTSS_COLOROP = WINED3DTOP_DISABLE
3646 * make sure to enable them
3648 for(i
=0; i
< MAX_FRAGMENT_SAMPLERS
; i
++) {
3649 if(!isStateDirty(context
, STATE_SAMPLER(i
))) {
3650 sampler(STATE_SAMPLER(i
), stateblock
, context
);
3653 context
->last_was_pshader
= TRUE
;
3655 /* Otherwise all samplers were activated by the code above in earlier draws, or by sampler()
3656 * if a different texture was bound. I don't have to do anything.
3660 /* Disabled the pixel shader - color ops weren't applied
3661 * while it was enabled, so re-apply them. */
3662 for (i
= 0; i
< context
->gl_info
->limits
.texture_stages
; ++i
)
3664 if (!isStateDirty(context
, STATE_TEXTURESTAGE(i
, WINED3DTSS_COLOROP
)))
3665 stateblock_apply_state(STATE_TEXTURESTAGE(i
, WINED3DTSS_COLOROP
), stateblock
, context
);
3667 context
->last_was_pshader
= FALSE
;
3670 if(!isStateDirty(context
, device
->StateTable
[STATE_VSHADER
].representative
)) {
3671 device
->shader_backend
->shader_select(context
, use_pshader
, use_vshader
);
3673 if (!isStateDirty(context
, STATE_VERTEXSHADERCONSTANT
) && (use_vshader
|| use_pshader
)) {
3674 shaderconstant(STATE_VERTEXSHADERCONSTANT
, stateblock
, context
);
3679 static void shader_bumpenvmat(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
3681 DWORD stage
= (state
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3682 const struct wined3d_shader
*ps
= stateblock
->state
.pixel_shader
;
3684 if (ps
&& stage
&& (ps
->reg_maps
.bumpmat
& (1 << stage
)))
3686 /* The pixel shader has to know the bump env matrix. Do a constants update if it isn't scheduled
3689 if(!isStateDirty(context
, STATE_PIXELSHADERCONSTANT
) &&
3690 !isStateDirty(context
, STATE_PIXELSHADER
)) {
3691 shaderconstant(STATE_PIXELSHADERCONSTANT
, stateblock
, context
);
3696 static void transform_world(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
3698 /* This function is called by transform_view below if the view matrix was changed too
3700 * Deliberately no check if the vertex declaration is dirty because the vdecl state
3701 * does not always update the world matrix, only on a switch between transformed
3702 * and untransformed draws. It *may* happen that the world matrix is set 2 times during one
3703 * draw, but that should be rather rare and cheaper in total.
3705 glMatrixMode(GL_MODELVIEW
);
3706 checkGLcall("glMatrixMode");
3708 if(context
->last_was_rhw
) {
3710 checkGLcall("glLoadIdentity()");
3712 /* In the general case, the view matrix is the identity matrix */
3713 if (stateblock
->device
->view_ident
)
3715 glLoadMatrixf(&stateblock
->state
.transforms
[WINED3DTS_WORLDMATRIX(0)].u
.m
[0][0]);
3716 checkGLcall("glLoadMatrixf");
3720 glLoadMatrixf(&stateblock
->state
.transforms
[WINED3DTS_VIEW
].u
.m
[0][0]);
3721 checkGLcall("glLoadMatrixf");
3722 glMultMatrixf(&stateblock
->state
.transforms
[WINED3DTS_WORLDMATRIX(0)].u
.m
[0][0]);
3723 checkGLcall("glMultMatrixf");
3728 static void clipplane(DWORD state_id
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
3730 const struct wined3d_state
*state
= &stateblock
->state
;
3731 UINT index
= state_id
- STATE_CLIPPLANE(0);
3733 if (isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_VIEW
)) || index
>= context
->gl_info
->limits
.clipplanes
)
3738 glMatrixMode(GL_MODELVIEW
);
3741 /* Clip Plane settings are affected by the model view in OpenGL, the View transform in direct3d */
3743 glLoadMatrixf(&state
->transforms
[WINED3DTS_VIEW
].u
.m
[0][0]);
3745 /* with vertex shaders, clip planes are not transformed in direct3d,
3746 * in OpenGL they are still transformed by the model view.
3750 TRACE("Clipplane [%.8e, %.8e, %.8e, %.8e]\n",
3751 state
->clip_planes
[index
][0],
3752 state
->clip_planes
[index
][1],
3753 state
->clip_planes
[index
][2],
3754 state
->clip_planes
[index
][3]);
3755 glClipPlane(GL_CLIP_PLANE0
+ index
, state
->clip_planes
[index
]);
3756 checkGLcall("glClipPlane");
3761 static void transform_worldex(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
3763 UINT matrix
= state
- STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0));
3765 TRACE("Setting world matrix %d\n", matrix
);
3767 if (matrix
>= context
->gl_info
->limits
.blends
)
3769 WARN("Unsupported blend matrix set\n");
3771 } else if(isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_VIEW
))) {
3775 /* GL_MODELVIEW0_ARB: 0x1700
3776 * GL_MODELVIEW1_ARB: 0x850a
3777 * GL_MODELVIEW2_ARB: 0x8722
3778 * GL_MODELVIEW3_ARB: 0x8723
3780 * GL_MODELVIEW31_ARB: 0x873F
3782 if(matrix
== 1) glMat
= GL_MODELVIEW1_ARB
;
3783 else glMat
= GL_MODELVIEW2_ARB
- 2 + matrix
;
3785 glMatrixMode(glMat
);
3786 checkGLcall("glMatrixMode(glMat)");
3788 /* World matrix 0 is multiplied with the view matrix because d3d uses 3 matrices while gl uses only 2. To avoid
3789 * weighting the view matrix incorrectly it has to be multiplied into every gl modelview matrix
3791 if (stateblock
->device
->view_ident
)
3793 glLoadMatrixf(&stateblock
->state
.transforms
[WINED3DTS_WORLDMATRIX(matrix
)].u
.m
[0][0]);
3794 checkGLcall("glLoadMatrixf");
3798 glLoadMatrixf(&stateblock
->state
.transforms
[WINED3DTS_VIEW
].u
.m
[0][0]);
3799 checkGLcall("glLoadMatrixf");
3800 glMultMatrixf(&stateblock
->state
.transforms
[WINED3DTS_WORLDMATRIX(matrix
)].u
.m
[0][0]);
3801 checkGLcall("glMultMatrixf");
3805 static void state_vertexblend_w(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
3807 WINED3DVERTEXBLENDFLAGS f
= stateblock
->state
.render_states
[WINED3DRS_VERTEXBLEND
];
3808 static unsigned int once
;
3810 if (f
== WINED3DVBF_DISABLE
) return;
3812 if (!once
++) FIXME("Vertex blend flags %#x not supported.\n", f
);
3813 else WARN("Vertex blend flags %#x not supported.\n", f
);
3816 static void state_vertexblend(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
3818 WINED3DVERTEXBLENDFLAGS val
= stateblock
->state
.render_states
[WINED3DRS_VERTEXBLEND
];
3819 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3820 static unsigned int once
;
3823 case WINED3DVBF_1WEIGHTS
:
3824 case WINED3DVBF_2WEIGHTS
:
3825 case WINED3DVBF_3WEIGHTS
:
3826 glEnable(GL_VERTEX_BLEND_ARB
);
3827 checkGLcall("glEnable(GL_VERTEX_BLEND_ARB)");
3829 /* D3D adds one more matrix which has weight (1 - sum(weights)). This is enabled at context
3830 * creation with enabling GL_WEIGHT_SUM_UNITY_ARB.
3832 GL_EXTCALL(glVertexBlendARB(stateblock
->state
.render_states
[WINED3DRS_VERTEXBLEND
] + 1));
3834 if (!stateblock
->device
->vertexBlendUsed
)
3837 for (i
= 1; i
< gl_info
->limits
.blends
; ++i
)
3839 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(i
))))
3841 transform_worldex(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(i
)), stateblock
, context
);
3844 stateblock
->device
->vertexBlendUsed
= TRUE
;
3848 case WINED3DVBF_TWEENING
:
3849 case WINED3DVBF_0WEIGHTS
: /* Indexed vertex blending, not supported. */
3850 if (!once
++) FIXME("Vertex blend flags %#x not supported.\n", val
);
3851 else WARN("Vertex blend flags %#x not supported.\n", val
);
3853 case WINED3DVBF_DISABLE
:
3854 glDisable(GL_VERTEX_BLEND_ARB
);
3855 checkGLcall("glDisable(GL_VERTEX_BLEND_ARB)");
3860 static void transform_view(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
3862 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3863 const struct wined3d_light_info
*light
= NULL
;
3866 /* If we are changing the View matrix, reset the light and clipping planes to the new view
3867 * NOTE: We have to reset the positions even if the light/plane is not currently
3868 * enabled, since the call to enable it will not reset the position.
3869 * NOTE2: Apparently texture transforms do NOT need reapplying
3872 glMatrixMode(GL_MODELVIEW
);
3873 checkGLcall("glMatrixMode(GL_MODELVIEW)");
3874 glLoadMatrixf(&stateblock
->state
.transforms
[WINED3DTS_VIEW
].u
.m
[0][0]);
3875 checkGLcall("glLoadMatrixf(...)");
3877 /* Reset lights. TODO: Call light apply func */
3878 for (k
= 0; k
< gl_info
->limits
.lights
; ++k
)
3880 light
= stateblock
->state
.lights
[k
];
3881 if(!light
) continue;
3882 glLightfv(GL_LIGHT0
+ light
->glIndex
, GL_POSITION
, light
->lightPosn
);
3883 checkGLcall("glLightfv posn");
3884 glLightfv(GL_LIGHT0
+ light
->glIndex
, GL_SPOT_DIRECTION
, light
->lightDirn
);
3885 checkGLcall("glLightfv dirn");
3888 /* Reset Clipping Planes */
3889 for (k
= 0; k
< gl_info
->limits
.clipplanes
; ++k
)
3891 if(!isStateDirty(context
, STATE_CLIPPLANE(k
))) {
3892 clipplane(STATE_CLIPPLANE(k
), stateblock
, context
);
3896 if(context
->last_was_rhw
) {
3898 checkGLcall("glLoadIdentity()");
3899 /* No need to update the world matrix, the identity is fine */
3903 /* Call the world matrix state, this will apply the combined WORLD + VIEW matrix
3904 * No need to do it here if the state is scheduled for update.
3906 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)))) {
3907 transform_world(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), stateblock
, context
);
3910 /* Avoid looping over a number of matrices if the app never used the functionality */
3911 if (stateblock
->device
->vertexBlendUsed
)
3913 for (k
= 1; k
< gl_info
->limits
.blends
; ++k
)
3915 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(k
)))) {
3916 transform_worldex(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(k
)), stateblock
, context
);
3922 static void transform_projection(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
3924 glMatrixMode(GL_PROJECTION
);
3925 checkGLcall("glMatrixMode(GL_PROJECTION)");
3927 checkGLcall("glLoadIdentity");
3929 if (context
->last_was_rhw
)
3931 double x
= stateblock
->state
.viewport
.X
;
3932 double y
= stateblock
->state
.viewport
.Y
;
3933 double w
= stateblock
->state
.viewport
.Width
;
3934 double h
= stateblock
->state
.viewport
.Height
;
3936 TRACE("Calling glOrtho with x %.8e, y %.8e, w %.8e, h %.8e.\n", x
, y
, w
, h
);
3937 if (context
->render_offscreen
)
3938 glOrtho(x
, x
+ w
, -y
, -y
- h
, 0.0, -1.0);
3940 glOrtho(x
, x
+ w
, y
+ h
, y
, 0.0, -1.0);
3941 checkGLcall("glOrtho");
3943 /* D3D texture coordinates are flipped compared to OpenGL ones, so
3944 * render everything upside down when rendering offscreen. */
3945 if (context
->render_offscreen
)
3947 glScalef(1.0f
, -1.0f
, 1.0f
);
3948 checkGLcall("glScalef");
3951 /* Window Coord 0 is the middle of the first pixel, so translate by 1/2 pixels */
3952 glTranslatef(63.0f
/ 128.0f
, 63.0f
/ 128.0f
, 0.0f
);
3953 checkGLcall("glTranslatef(63.0f / 128.0f, 63.0f / 128.0f, 0.0f)");
3957 /* The rule is that the window coordinate 0 does not correspond to the
3958 beginning of the first pixel, but the center of the first pixel.
3959 As a consequence if you want to correctly draw one line exactly from
3960 the left to the right end of the viewport (with all matrices set to
3961 be identity), the x coords of both ends of the line would be not
3962 -1 and 1 respectively but (-1-1/viewport_widh) and (1-1/viewport_width)
3965 1.0 / Width is used because the coord range goes from -1.0 to 1.0, then we
3966 divide by the Width/Height, so we need the half range(1.0) to translate by
3969 The other fun is that d3d's output z range after the transformation is [0;1],
3970 but opengl's is [-1;1]. Since the z buffer is in range [0;1] for both, gl
3971 scales [-1;1] to [0;1]. This would mean that we end up in [0.5;1] and loose a lot
3972 of Z buffer precision and the clear values do not match in the z test. Thus scale
3973 [0;1] to [-1;1], so when gl undoes that we utilize the full z range
3977 * Careful with the order of operations here, we're essentially working backwards:
3979 * y = (y - 1/h) * flip;
3983 * glTranslatef(0.0, 0.0, -1.0);
3984 * glScalef(1.0, 1.0, 2.0);
3986 * glScalef(1.0, flip, 1.0);
3987 * glTranslatef(1/w, -1/h, 0.0);
3989 * This is equivalent to:
3990 * glTranslatef(1/w, -flip/h, -1.0)
3991 * glScalef(1.0, flip, 2.0);
3994 /* Translate by slightly less than a half pixel to force a top-left
3995 * filling convention. We want the difference to be large enough that
3996 * it doesn't get lost due to rounding inside the driver, but small
3997 * enough to prevent it from interfering with any anti-aliasing. */
3998 GLfloat xoffset
= (63.0f
/ 64.0f
) / stateblock
->state
.viewport
.Width
;
3999 GLfloat yoffset
= -(63.0f
/ 64.0f
) / stateblock
->state
.viewport
.Height
;
4001 if (context
->render_offscreen
)
4003 /* D3D texture coordinates are flipped compared to OpenGL ones, so
4004 * render everything upside down when rendering offscreen. */
4005 glTranslatef(xoffset
, -yoffset
, -1.0f
);
4006 checkGLcall("glTranslatef(xoffset, -yoffset, -1.0f)");
4007 glScalef(1.0f
, -1.0f
, 2.0f
);
4009 glTranslatef(xoffset
, yoffset
, -1.0f
);
4010 checkGLcall("glTranslatef(xoffset, yoffset, -1.0f)");
4011 glScalef(1.0f
, 1.0f
, 2.0f
);
4013 checkGLcall("glScalef");
4015 glMultMatrixf(&stateblock
->state
.transforms
[WINED3DTS_PROJECTION
].u
.m
[0][0]);
4016 checkGLcall("glLoadMatrixf");
4020 /* This should match any arrays loaded in loadVertexData.
4021 * TODO: Only load / unload arrays if we have to.
4023 static inline void unloadVertexData(const struct wined3d_gl_info
*gl_info
)
4025 glDisableClientState(GL_VERTEX_ARRAY
);
4026 glDisableClientState(GL_NORMAL_ARRAY
);
4027 glDisableClientState(GL_COLOR_ARRAY
);
4028 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
4030 glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT
);
4032 if (gl_info
->supported
[ARB_VERTEX_BLEND
])
4034 glDisableClientState(GL_WEIGHT_ARRAY_ARB
);
4036 unloadTexCoords(gl_info
);
4039 static inline void unload_numbered_array(struct wined3d_context
*context
, int i
)
4041 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4043 GL_EXTCALL(glDisableVertexAttribArrayARB(i
));
4044 checkGLcall("glDisableVertexAttribArrayARB(reg)");
4046 context
->numbered_array_mask
&= ~(1 << i
);
4049 /* This should match any arrays loaded in loadNumberedArrays
4050 * TODO: Only load / unload arrays if we have to.
4052 static inline void unloadNumberedArrays(struct wined3d_context
*context
)
4054 /* disable any attribs (this is the same for both GLSL and ARB modes) */
4055 GLint maxAttribs
= 16;
4058 /* Leave all the attribs disabled */
4059 glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB
, &maxAttribs
);
4060 /* MESA does not support it right not */
4061 if (glGetError() != GL_NO_ERROR
)
4063 for (i
= 0; i
< maxAttribs
; ++i
) {
4064 unload_numbered_array(context
, i
);
4068 static void loadNumberedArrays(struct wined3d_stateblock
*stateblock
,
4069 const struct wined3d_stream_info
*stream_info
, struct wined3d_context
*context
)
4071 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4072 GLuint curVBO
= gl_info
->supported
[ARB_VERTEX_BUFFER_OBJECT
] ? ~0U : 0;
4074 struct wined3d_buffer
*vb
;
4076 /* Default to no instancing */
4077 stateblock
->device
->instancedDraw
= FALSE
;
4079 for (i
= 0; i
< MAX_ATTRIBS
; i
++)
4081 const struct wined3d_stream_state
*stream
;
4083 if (!(stream_info
->use_map
& (1 << i
)))
4085 if (context
->numbered_array_mask
& (1 << i
)) unload_numbered_array(context
, i
);
4089 stream
= &stateblock
->state
.streams
[stream_info
->elements
[i
].stream_idx
];
4091 /* Do not load instance data. It will be specified using glTexCoord by drawprim */
4092 if (stream
->flags
& WINED3DSTREAMSOURCE_INSTANCEDATA
)
4094 if (context
->numbered_array_mask
& (1 << i
)) unload_numbered_array(context
, i
);
4095 stateblock
->device
->instancedDraw
= TRUE
;
4099 TRACE_(d3d_shader
)("Loading array %u [VBO=%u]\n", i
, stream_info
->elements
[i
].data
.buffer_object
);
4101 if (stream_info
->elements
[i
].stride
)
4103 if (curVBO
!= stream_info
->elements
[i
].data
.buffer_object
)
4105 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, stream_info
->elements
[i
].data
.buffer_object
));
4106 checkGLcall("glBindBufferARB");
4107 curVBO
= stream_info
->elements
[i
].data
.buffer_object
;
4109 /* Use the VBO to find out if a vertex buffer exists, not the vb
4110 * pointer. vb can point to a user pointer data blob. In that case
4111 * curVBO will be 0. If there is a vertex buffer but no vbo we
4112 * won't be load converted attributes anyway. */
4113 vb
= stream
->buffer
;
4114 GL_EXTCALL(glVertexAttribPointerARB(i
, stream_info
->elements
[i
].format
->gl_vtx_format
,
4115 stream_info
->elements
[i
].format
->gl_vtx_type
,
4116 stream_info
->elements
[i
].format
->gl_normalized
,
4117 stream_info
->elements
[i
].stride
, stream_info
->elements
[i
].data
.addr
4118 + stateblock
->state
.load_base_vertex_index
* stream_info
->elements
[i
].stride
4121 if (!(context
->numbered_array_mask
& (1 << i
)))
4123 GL_EXTCALL(glEnableVertexAttribArrayARB(i
));
4124 context
->numbered_array_mask
|= (1 << i
);
4129 /* Stride = 0 means always the same values.
4130 * glVertexAttribPointerARB doesn't do that. Instead disable the
4131 * pointer and set up the attribute statically. But we have to
4132 * figure out the system memory address. */
4133 const BYTE
*ptr
= stream_info
->elements
[i
].data
.addr
+ stream
->offset
;
4134 if (stream_info
->elements
[i
].data
.buffer_object
)
4136 vb
= stream
->buffer
;
4137 ptr
+= (ULONG_PTR
)buffer_get_sysmem(vb
, gl_info
);
4140 if (context
->numbered_array_mask
& (1 << i
)) unload_numbered_array(context
, i
);
4142 switch (stream_info
->elements
[i
].format
->id
)
4144 case WINED3DFMT_R32_FLOAT
:
4145 GL_EXTCALL(glVertexAttrib1fvARB(i
, (const GLfloat
*)ptr
));
4147 case WINED3DFMT_R32G32_FLOAT
:
4148 GL_EXTCALL(glVertexAttrib2fvARB(i
, (const GLfloat
*)ptr
));
4150 case WINED3DFMT_R32G32B32_FLOAT
:
4151 GL_EXTCALL(glVertexAttrib3fvARB(i
, (const GLfloat
*)ptr
));
4153 case WINED3DFMT_R32G32B32A32_FLOAT
:
4154 GL_EXTCALL(glVertexAttrib4fvARB(i
, (const GLfloat
*)ptr
));
4157 case WINED3DFMT_R8G8B8A8_UINT
:
4158 GL_EXTCALL(glVertexAttrib4NubvARB(i
, ptr
));
4160 case WINED3DFMT_B8G8R8A8_UNORM
:
4161 if (gl_info
->supported
[ARB_VERTEX_ARRAY_BGRA
])
4163 const DWORD
*src
= (const DWORD
*)ptr
;
4164 DWORD c
= *src
& 0xff00ff00;
4165 c
|= (*src
& 0xff0000) >> 16;
4166 c
|= (*src
& 0xff) << 16;
4167 GL_EXTCALL(glVertexAttrib4NubvARB(i
, (GLubyte
*)&c
));
4170 /* else fallthrough */
4171 case WINED3DFMT_R8G8B8A8_UNORM
:
4172 GL_EXTCALL(glVertexAttrib4NubvARB(i
, ptr
));
4175 case WINED3DFMT_R16G16_SINT
:
4176 GL_EXTCALL(glVertexAttrib4svARB(i
, (const GLshort
*)ptr
));
4178 case WINED3DFMT_R16G16B16A16_SINT
:
4179 GL_EXTCALL(glVertexAttrib4svARB(i
, (const GLshort
*)ptr
));
4182 case WINED3DFMT_R16G16_SNORM
:
4184 const GLshort s
[4] = {((const GLshort
*)ptr
)[0], ((const GLshort
*)ptr
)[1], 0, 1};
4185 GL_EXTCALL(glVertexAttrib4NsvARB(i
, s
));
4188 case WINED3DFMT_R16G16_UNORM
:
4190 const GLushort s
[4] = {((const GLushort
*)ptr
)[0], ((const GLushort
*)ptr
)[1], 0, 1};
4191 GL_EXTCALL(glVertexAttrib4NusvARB(i
, s
));
4194 case WINED3DFMT_R16G16B16A16_SNORM
:
4195 GL_EXTCALL(glVertexAttrib4NsvARB(i
, (const GLshort
*)ptr
));
4197 case WINED3DFMT_R16G16B16A16_UNORM
:
4198 GL_EXTCALL(glVertexAttrib4NusvARB(i
, (const GLushort
*)ptr
));
4201 case WINED3DFMT_R10G10B10A2_UINT
:
4202 FIXME("Unsure about WINED3DDECLTYPE_UDEC3\n");
4203 /*glVertexAttrib3usvARB(i, (const GLushort *)ptr); Does not exist */
4205 case WINED3DFMT_R10G10B10A2_SNORM
:
4206 FIXME("Unsure about WINED3DDECLTYPE_DEC3N\n");
4207 /*glVertexAttrib3NusvARB(i, (const GLushort *)ptr); Does not exist */
4210 case WINED3DFMT_R16G16_FLOAT
:
4211 /* Are those 16 bit floats. C doesn't have a 16 bit float type. I could read the single bits and calculate a 4
4212 * byte float according to the IEEE standard
4214 FIXME("Unsupported WINED3DDECLTYPE_FLOAT16_2\n");
4216 case WINED3DFMT_R16G16B16A16_FLOAT
:
4217 FIXME("Unsupported WINED3DDECLTYPE_FLOAT16_4\n");
4221 ERR("Unexpected declaration in stride 0 attributes\n");
4227 checkGLcall("Loading numbered arrays");
4230 /* Used from 2 different functions, and too big to justify making it inlined */
4231 static void loadVertexData(const struct wined3d_context
*context
, struct wined3d_stateblock
*stateblock
,
4232 const struct wined3d_stream_info
*si
)
4234 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4235 GLuint curVBO
= gl_info
->supported
[ARB_VERTEX_BUFFER_OBJECT
] ? ~0U : 0;
4236 const struct wined3d_stream_info_element
*e
;
4237 const struct wined3d_stream_state
*stream
;
4239 TRACE("Using fast vertex array code\n");
4241 /* This is fixed function pipeline only, and the fixed function pipeline doesn't do instancing */
4242 stateblock
->device
->instancedDraw
= FALSE
;
4244 /* Blend Data ---------------------------------------------- */
4245 if ((si
->use_map
& (1 << WINED3D_FFP_BLENDWEIGHT
))
4246 || si
->use_map
& (1 << WINED3D_FFP_BLENDINDICES
))
4248 e
= &si
->elements
[WINED3D_FFP_BLENDWEIGHT
];
4249 stream
= &stateblock
->state
.streams
[e
->stream_idx
];
4251 if (gl_info
->supported
[ARB_VERTEX_BLEND
])
4253 TRACE("Blend %u %p %u\n", e
->format
->component_count
,
4254 e
->data
.addr
+ stateblock
->state
.load_base_vertex_index
* e
->stride
, e
->stride
+ stream
->offset
);
4256 glEnableClientState(GL_WEIGHT_ARRAY_ARB
);
4257 checkGLcall("glEnableClientState(GL_WEIGHT_ARRAY_ARB)");
4259 GL_EXTCALL(glVertexBlendARB(e
->format
->component_count
+ 1));
4261 if (curVBO
!= e
->data
.buffer_object
)
4263 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, e
->data
.buffer_object
));
4264 checkGLcall("glBindBufferARB");
4265 curVBO
= e
->data
.buffer_object
;
4268 TRACE("glWeightPointerARB(%#x, %#x, %#x, %p);\n",
4269 e
->format
->gl_vtx_format
,
4270 e
->format
->gl_vtx_type
,
4272 e
->data
.addr
+ stateblock
->state
.load_base_vertex_index
* e
->stride
+ stream
->offset
);
4273 GL_EXTCALL(glWeightPointerARB(e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
4274 e
->data
.addr
+ stateblock
->state
.load_base_vertex_index
* e
->stride
+ stream
->offset
));
4276 checkGLcall("glWeightPointerARB");
4278 if (si
->use_map
& (1 << WINED3D_FFP_BLENDINDICES
))
4283 FIXME("blendMatrixIndices support\n");
4288 /* TODO: support blends in drawStridedSlow
4289 * No need to write a FIXME here, this is done after the general vertex decl decoding
4291 WARN("unsupported blending in openGl\n");
4296 if (gl_info
->supported
[ARB_VERTEX_BLEND
])
4298 static const GLbyte one
= 1;
4299 GL_EXTCALL(glWeightbvARB(1, &one
));
4300 checkGLcall("glWeightbvARB(gl_info->max_blends, weights)");
4304 /* Point Size ----------------------------------------------*/
4305 if (si
->use_map
& (1 << WINED3D_FFP_PSIZE
))
4307 /* no such functionality in the fixed function GL pipeline */
4308 TRACE("Cannot change ptSize here in openGl\n");
4309 /* TODO: Implement this function in using shaders if they are available */
4312 /* Vertex Pointers -----------------------------------------*/
4313 if (si
->use_map
& (1 << WINED3D_FFP_POSITION
))
4315 e
= &si
->elements
[WINED3D_FFP_POSITION
];
4316 stream
= &stateblock
->state
.streams
[e
->stream_idx
];
4318 if (curVBO
!= e
->data
.buffer_object
)
4320 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, e
->data
.buffer_object
));
4321 checkGLcall("glBindBufferARB");
4322 curVBO
= e
->data
.buffer_object
;
4325 /* min(WINED3D_ATR_FORMAT(position),3) to Disable RHW mode as 'w' coord
4326 handling for rhw mode should not impact screen position whereas in GL it does.
4327 This may result in very slightly distorted textures in rhw mode.
4328 There's always the other option of fixing the view matrix to
4329 prevent w from having any effect.
4331 This only applies to user pointer sources, in VBOs the vertices are fixed up
4333 if (!e
->data
.buffer_object
)
4335 TRACE("glVertexPointer(3, %#x, %#x, %p);\n", e
->format
->gl_vtx_type
, e
->stride
,
4336 e
->data
.addr
+ stateblock
->state
.load_base_vertex_index
* e
->stride
+ stream
->offset
);
4337 glVertexPointer(3 /* min(e->format->gl_vtx_format, 3) */, e
->format
->gl_vtx_type
, e
->stride
,
4338 e
->data
.addr
+ stateblock
->state
.load_base_vertex_index
* e
->stride
+ stream
->offset
);
4342 TRACE("glVertexPointer(%#x, %#x, %#x, %p);\n",
4343 e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
4344 e
->data
.addr
+ stateblock
->state
.load_base_vertex_index
* e
->stride
+ stream
->offset
);
4345 glVertexPointer(e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
4346 e
->data
.addr
+ stateblock
->state
.load_base_vertex_index
* e
->stride
+ stream
->offset
);
4348 checkGLcall("glVertexPointer(...)");
4349 glEnableClientState(GL_VERTEX_ARRAY
);
4350 checkGLcall("glEnableClientState(GL_VERTEX_ARRAY)");
4353 /* Normals -------------------------------------------------*/
4354 if (si
->use_map
& (1 << WINED3D_FFP_NORMAL
))
4356 e
= &si
->elements
[WINED3D_FFP_NORMAL
];
4357 stream
= &stateblock
->state
.streams
[e
->stream_idx
];
4359 if (curVBO
!= e
->data
.buffer_object
)
4361 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, e
->data
.buffer_object
));
4362 checkGLcall("glBindBufferARB");
4363 curVBO
= e
->data
.buffer_object
;
4366 TRACE("glNormalPointer(%#x, %#x, %p);\n", e
->format
->gl_vtx_type
, e
->stride
,
4367 e
->data
.addr
+ stateblock
->state
.load_base_vertex_index
* e
->stride
+ stream
->offset
);
4368 glNormalPointer(e
->format
->gl_vtx_type
, e
->stride
,
4369 e
->data
.addr
+ stateblock
->state
.load_base_vertex_index
* e
->stride
+ stream
->offset
);
4370 checkGLcall("glNormalPointer(...)");
4371 glEnableClientState(GL_NORMAL_ARRAY
);
4372 checkGLcall("glEnableClientState(GL_NORMAL_ARRAY)");
4375 glNormal3f(0, 0, 0);
4376 checkGLcall("glNormal3f(0, 0, 0)");
4379 /* Diffuse Colour --------------------------------------------*/
4380 /* WARNING: Data here MUST be in RGBA format, so cannot */
4381 /* go directly into fast mode from app pgm, because */
4382 /* directx requires data in BGRA format. */
4383 /* currently fixupVertices swizzles the format, but this isn't*/
4384 /* very practical when using VBOs */
4385 /* NOTE: Unless we write a vertex shader to swizzle the colour*/
4386 /* , or the user doesn't care and wants the speed advantage */
4388 if (si
->use_map
& (1 << WINED3D_FFP_DIFFUSE
))
4390 e
= &si
->elements
[WINED3D_FFP_DIFFUSE
];
4391 stream
= &stateblock
->state
.streams
[e
->stream_idx
];
4393 if (curVBO
!= e
->data
.buffer_object
)
4395 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, e
->data
.buffer_object
));
4396 checkGLcall("glBindBufferARB");
4397 curVBO
= e
->data
.buffer_object
;
4400 TRACE("glColorPointer(%#x, %#x %#x, %p);\n",
4401 e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
4402 e
->data
.addr
+ stateblock
->state
.load_base_vertex_index
* e
->stride
+ stream
->offset
);
4403 glColorPointer(e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
4404 e
->data
.addr
+ stateblock
->state
.load_base_vertex_index
* e
->stride
+ stream
->offset
);
4405 checkGLcall("glColorPointer(4, GL_UNSIGNED_BYTE, ...)");
4406 glEnableClientState(GL_COLOR_ARRAY
);
4407 checkGLcall("glEnableClientState(GL_COLOR_ARRAY)");
4410 glColor4f(1.0f
, 1.0f
, 1.0f
, 1.0f
);
4411 checkGLcall("glColor4f(1, 1, 1, 1)");
4414 /* Specular Colour ------------------------------------------*/
4415 if (si
->use_map
& (1 << WINED3D_FFP_SPECULAR
))
4417 TRACE("setting specular colour\n");
4419 e
= &si
->elements
[WINED3D_FFP_SPECULAR
];
4420 stream
= &stateblock
->state
.streams
[e
->stream_idx
];
4422 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
4424 GLenum type
= e
->format
->gl_vtx_type
;
4425 GLint format
= e
->format
->gl_vtx_format
;
4427 if (curVBO
!= e
->data
.buffer_object
)
4429 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, e
->data
.buffer_object
));
4430 checkGLcall("glBindBufferARB");
4431 curVBO
= e
->data
.buffer_object
;
4434 if (format
!= 4 || (gl_info
->quirks
& WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA
))
4436 /* Usually specular colors only allow 3 components, since they have no alpha. In D3D, the specular alpha
4437 * contains the fog coordinate, which is passed to GL with GL_EXT_fog_coord. However, the fixed function
4438 * vertex pipeline can pass the specular alpha through, and pixel shaders can read it. So it GL accepts
4439 * 4 component secondary colors use it
4441 TRACE("glSecondaryColorPointer(%#x, %#x, %#x, %p);\n", format
, type
, e
->stride
,
4442 e
->data
.addr
+ stateblock
->state
.load_base_vertex_index
* e
->stride
+ stream
->offset
);
4443 GL_EXTCALL(glSecondaryColorPointerEXT(format
, type
, e
->stride
,
4444 e
->data
.addr
+ stateblock
->state
.load_base_vertex_index
* e
->stride
+ stream
->offset
));
4445 checkGLcall("glSecondaryColorPointerEXT(format, type, ...)");
4451 case GL_UNSIGNED_BYTE
:
4452 TRACE("glSecondaryColorPointer(3, GL_UNSIGNED_BYTE, %#x, %p);\n", e
->stride
,
4453 e
->data
.addr
+ stateblock
->state
.load_base_vertex_index
* e
->stride
+ stream
->offset
);
4454 GL_EXTCALL(glSecondaryColorPointerEXT(3, GL_UNSIGNED_BYTE
, e
->stride
,
4455 e
->data
.addr
+ stateblock
->state
.load_base_vertex_index
* e
->stride
+ stream
->offset
));
4456 checkGLcall("glSecondaryColorPointerEXT(3, GL_UNSIGNED_BYTE, ...)");
4460 FIXME("Add 4 component specular color pointers for type %x\n", type
);
4461 /* Make sure that the right color component is dropped */
4462 TRACE("glSecondaryColorPointer(3, %#x, %#x, %p);\n", type
, e
->stride
,
4463 e
->data
.addr
+ stateblock
->state
.load_base_vertex_index
* e
->stride
+ stream
->offset
);
4464 GL_EXTCALL(glSecondaryColorPointerEXT(3, type
, e
->stride
,
4465 e
->data
.addr
+ stateblock
->state
.load_base_vertex_index
* e
->stride
+ stream
->offset
));
4466 checkGLcall("glSecondaryColorPointerEXT(3, type, ...)");
4469 glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT
);
4470 checkGLcall("glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
4474 WARN("Specular colour is not supported in this GL implementation.\n");
4479 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
4481 GL_EXTCALL(glSecondaryColor3fEXT
)(0, 0, 0);
4482 checkGLcall("glSecondaryColor3fEXT(0, 0, 0)");
4486 WARN("Specular colour is not supported in this GL implementation.\n");
4490 /* Texture coords -------------------------------------------*/
4491 loadTexCoords(gl_info
, stateblock
, si
, &curVBO
);
4494 static void streamsrc(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
4496 struct wined3d_device
*device
= stateblock
->device
;
4497 BOOL load_numbered
= use_vs(&stateblock
->state
) && !device
->useDrawStridedSlow
;
4498 BOOL load_named
= !use_vs(&stateblock
->state
) && !device
->useDrawStridedSlow
;
4500 if (isStateDirty(context
, STATE_VDECL
)) return;
4501 if (context
->numberedArraysLoaded
&& !load_numbered
)
4503 unloadNumberedArrays(context
);
4504 context
->numberedArraysLoaded
= FALSE
;
4505 context
->numbered_array_mask
= 0;
4507 else if (context
->namedArraysLoaded
)
4509 unloadVertexData(context
->gl_info
);
4510 context
->namedArraysLoaded
= FALSE
;
4515 TRACE("Loading numbered arrays\n");
4516 loadNumberedArrays(stateblock
, &device
->strided_streams
, context
);
4517 context
->numberedArraysLoaded
= TRUE
;
4519 else if (load_named
)
4521 TRACE("Loading vertex data\n");
4522 loadVertexData(context
, stateblock
, &device
->strided_streams
);
4523 context
->namedArraysLoaded
= TRUE
;
4527 static void vdecl_miscpart(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
4529 if (isStateDirty(context
, STATE_STREAMSRC
)) return;
4530 streamsrc(state
, stateblock
, context
);
4533 static void vertexdeclaration(DWORD state_id
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
4535 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4536 const struct wined3d_state
*state
= &stateblock
->state
;
4537 struct wined3d_device
*device
= stateblock
->device
;
4538 BOOL useVertexShaderFunction
= use_vs(state
);
4539 BOOL usePixelShaderFunction
= use_ps(state
);
4540 BOOL updateFog
= FALSE
;
4542 BOOL wasrhw
= context
->last_was_rhw
;
4545 transformed
= device
->strided_streams
.position_transformed
;
4546 if (transformed
!= context
->last_was_rhw
&& !useVertexShaderFunction
)
4550 context
->last_was_rhw
= TRUE
;
4553 /* Untransformed, so relies on the view and projection matrices */
4554 context
->last_was_rhw
= FALSE
;
4555 /* This turns off the Z scale trick to 'disable' viewport frustum clipping in rhw mode*/
4556 device
->untransformed
= TRUE
;
4559 /* Don't have to apply the matrices when vertex shaders are used. When vshaders are turned
4560 * off this function will be called again anyway to make sure they're properly set
4562 if(!useVertexShaderFunction
) {
4563 /* TODO: Move this mainly to the viewport state and only apply when the vp has changed
4564 * or transformed / untransformed was switched
4566 if(wasrhw
!= context
->last_was_rhw
&&
4567 !isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_PROJECTION
)) &&
4568 !isStateDirty(context
, STATE_VIEWPORT
)) {
4569 transform_projection(STATE_TRANSFORM(WINED3DTS_PROJECTION
), stateblock
, context
);
4571 /* World matrix needs reapplication here only if we're switching between rhw and non-rhw
4574 * If a vertex shader is used, the world matrix changed and then vertex shader unbound
4575 * this check will fail and the matrix not applied again. This is OK because a simple
4576 * world matrix change reapplies the matrix - These checks here are only to satisfy the
4577 * needs of the vertex declaration.
4579 * World and view matrix go into the same gl matrix, so only apply them when neither is
4582 if(transformed
!= wasrhw
&&
4583 !isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0))) &&
4584 !isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_VIEW
))) {
4585 transform_world(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), stateblock
, context
);
4588 if(!isStateDirty(context
, STATE_RENDER(WINED3DRS_COLORVERTEX
))) {
4589 state_colormat(STATE_RENDER(WINED3DRS_COLORVERTEX
), stateblock
, context
);
4591 if(!isStateDirty(context
, STATE_RENDER(WINED3DRS_LIGHTING
))) {
4592 state_lighting(STATE_RENDER(WINED3DRS_LIGHTING
), stateblock
, context
);
4595 if(context
->last_was_vshader
) {
4597 if(!device
->vs_clipping
&& !isStateDirty(context
, STATE_RENDER(WINED3DRS_CLIPPLANEENABLE
))) {
4598 state_clipping(STATE_RENDER(WINED3DRS_CLIPPLANEENABLE
), stateblock
, context
);
4600 for (i
= 0; i
< gl_info
->limits
.clipplanes
; ++i
)
4602 clipplane(STATE_CLIPPLANE(i
), stateblock
, context
);
4605 if(!isStateDirty(context
, STATE_RENDER(WINED3DRS_NORMALIZENORMALS
))) {
4606 state_normalize(STATE_RENDER(WINED3DRS_NORMALIZENORMALS
), stateblock
, context
);
4609 if(!context
->last_was_vshader
) {
4610 static BOOL warned
= FALSE
;
4611 if(!device
->vs_clipping
) {
4612 /* Disable all clip planes to get defined results on all drivers. See comment in the
4613 * state_clipping state handler
4615 for (i
= 0; i
< gl_info
->limits
.clipplanes
; ++i
)
4617 glDisable(GL_CLIP_PLANE0
+ i
);
4618 checkGLcall("glDisable(GL_CLIP_PLANE0 + i)");
4621 if (!warned
&& stateblock
->state
.render_states
[WINED3DRS_CLIPPLANEENABLE
])
4623 FIXME("Clipping not supported with vertex shaders\n");
4628 /* Apply the transform matrices when switching from rhw drawing to vertex shaders. Vertex
4629 * shaders themselves do not need it, but the matrices are not reapplied automatically when
4630 * switching back from vertex shaders to fixed function processing. So make sure we leave the
4631 * fixed function vertex processing states back in a sane state before switching to shaders
4633 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_PROJECTION
))) {
4634 transform_projection(STATE_TRANSFORM(WINED3DTS_PROJECTION
), stateblock
, context
);
4636 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)))) {
4637 transform_world(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), stateblock
, context
);
4642 /* Vertex shader clipping ignores the view matrix. Update all clipplanes
4643 * (Note: ARB shaders can read the clip planes for clipping emulation even if
4644 * device->vs_clipping is false.
4646 for (i
= 0; i
< gl_info
->limits
.clipplanes
; ++i
)
4648 clipplane(STATE_CLIPPLANE(i
), stateblock
, context
);
4653 /* Vertex and pixel shaders are applied together for now, so let the last dirty state do the
4656 if (!isStateDirty(context
, STATE_PIXELSHADER
)) {
4657 device
->shader_backend
->shader_select(context
, usePixelShaderFunction
, useVertexShaderFunction
);
4659 if (!isStateDirty(context
, STATE_VERTEXSHADERCONSTANT
) && (useVertexShaderFunction
|| usePixelShaderFunction
)) {
4660 shaderconstant(STATE_VERTEXSHADERCONSTANT
, stateblock
, context
);
4664 context
->last_was_vshader
= useVertexShaderFunction
;
4666 if (updateFog
) stateblock_apply_state(STATE_RENDER(WINED3DRS_FOGVERTEXMODE
), stateblock
, context
);
4668 if(!useVertexShaderFunction
) {
4670 for(i
= 0; i
< MAX_TEXTURES
; i
++) {
4671 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_TEXTURE0
+ i
))) {
4672 transform_texture(STATE_TEXTURESTAGE(i
, WINED3DTSS_TEXTURETRANSFORMFLAGS
), stateblock
, context
);
4678 static void viewport_miscpart(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
4680 struct wined3d_surface
*target
= stateblock
->device
->fb
.render_targets
[0];
4682 WINED3DVIEWPORT vp
= stateblock
->state
.viewport
;
4684 if (vp
.Width
> target
->resource
.width
)
4685 vp
.Width
= target
->resource
.width
;
4686 if (vp
.Height
> target
->resource
.height
)
4687 vp
.Height
= target
->resource
.height
;
4689 glDepthRange(vp
.MinZ
, vp
.MaxZ
);
4690 checkGLcall("glDepthRange");
4691 /* Note: GL requires lower left, DirectX supplies upper left. This is reversed when using offscreen rendering
4693 if (context
->render_offscreen
)
4695 glViewport(vp
.X
, vp
.Y
, vp
.Width
, vp
.Height
);
4697 target
->get_drawable_size(context
, &width
, &height
);
4700 (height
- (vp
.Y
+ vp
.Height
)),
4701 vp
.Width
, vp
.Height
);
4704 checkGLcall("glViewport");
4707 static void viewport_vertexpart(DWORD state_id
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
4709 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_PROJECTION
))) {
4710 transform_projection(STATE_TRANSFORM(WINED3DTS_PROJECTION
), stateblock
, context
);
4712 if(!isStateDirty(context
, STATE_RENDER(WINED3DRS_POINTSCALEENABLE
))) {
4713 state_pscale(STATE_RENDER(WINED3DRS_POINTSCALEENABLE
), stateblock
, context
);
4715 /* Update the position fixup. */
4716 if (!isStateDirty(context
, STATE_VERTEXSHADERCONSTANT
))
4717 shaderconstant(STATE_VERTEXSHADERCONSTANT
, stateblock
, context
);
4720 static void light(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
4722 UINT Index
= state
- STATE_ACTIVELIGHT(0);
4723 const struct wined3d_light_info
*lightInfo
= stateblock
->state
.lights
[Index
];
4726 glDisable(GL_LIGHT0
+ Index
);
4727 checkGLcall("glDisable(GL_LIGHT0 + Index)");
4730 float colRGBA
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
4732 /* Light settings are affected by the model view in OpenGL, the View transform in direct3d*/
4733 glMatrixMode(GL_MODELVIEW
);
4735 glLoadMatrixf(&stateblock
->state
.transforms
[WINED3DTS_VIEW
].u
.m
[0][0]);
4738 colRGBA
[0] = lightInfo
->OriginalParms
.Diffuse
.r
;
4739 colRGBA
[1] = lightInfo
->OriginalParms
.Diffuse
.g
;
4740 colRGBA
[2] = lightInfo
->OriginalParms
.Diffuse
.b
;
4741 colRGBA
[3] = lightInfo
->OriginalParms
.Diffuse
.a
;
4742 glLightfv(GL_LIGHT0
+ Index
, GL_DIFFUSE
, colRGBA
);
4743 checkGLcall("glLightfv");
4746 colRGBA
[0] = lightInfo
->OriginalParms
.Specular
.r
;
4747 colRGBA
[1] = lightInfo
->OriginalParms
.Specular
.g
;
4748 colRGBA
[2] = lightInfo
->OriginalParms
.Specular
.b
;
4749 colRGBA
[3] = lightInfo
->OriginalParms
.Specular
.a
;
4750 glLightfv(GL_LIGHT0
+ Index
, GL_SPECULAR
, colRGBA
);
4751 checkGLcall("glLightfv");
4754 colRGBA
[0] = lightInfo
->OriginalParms
.Ambient
.r
;
4755 colRGBA
[1] = lightInfo
->OriginalParms
.Ambient
.g
;
4756 colRGBA
[2] = lightInfo
->OriginalParms
.Ambient
.b
;
4757 colRGBA
[3] = lightInfo
->OriginalParms
.Ambient
.a
;
4758 glLightfv(GL_LIGHT0
+ Index
, GL_AMBIENT
, colRGBA
);
4759 checkGLcall("glLightfv");
4761 if ((lightInfo
->OriginalParms
.Range
*lightInfo
->OriginalParms
.Range
) >= FLT_MIN
) {
4762 quad_att
= 1.4f
/(lightInfo
->OriginalParms
.Range
*lightInfo
->OriginalParms
.Range
);
4764 quad_att
= 0.0f
; /* 0 or MAX? (0 seems to be ok) */
4767 /* Do not assign attenuation values for lights that do not use them. D3D apps are free to pass any junk,
4768 * but gl drivers use them and may crash due to bad Attenuation values. Need for Speed most wanted sets
4769 * Attenuation0 to NaN and crashes in the gl lib
4772 switch (lightInfo
->OriginalParms
.Type
) {
4773 case WINED3DLIGHT_POINT
:
4775 glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->lightPosn
[0]);
4776 checkGLcall("glLightfv");
4777 glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
4778 checkGLcall("glLightf");
4779 /* Attenuation - Are these right? guessing... */
4780 glLightf(GL_LIGHT0
+ Index
, GL_CONSTANT_ATTENUATION
, lightInfo
->OriginalParms
.Attenuation0
);
4781 checkGLcall("glLightf");
4782 glLightf(GL_LIGHT0
+ Index
, GL_LINEAR_ATTENUATION
, lightInfo
->OriginalParms
.Attenuation1
);
4783 checkGLcall("glLightf");
4784 if (quad_att
< lightInfo
->OriginalParms
.Attenuation2
) quad_att
= lightInfo
->OriginalParms
.Attenuation2
;
4785 glLightf(GL_LIGHT0
+ Index
, GL_QUADRATIC_ATTENUATION
, quad_att
);
4786 checkGLcall("glLightf");
4790 case WINED3DLIGHT_SPOT
:
4792 glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->lightPosn
[0]);
4793 checkGLcall("glLightfv");
4795 glLightfv(GL_LIGHT0
+ Index
, GL_SPOT_DIRECTION
, &lightInfo
->lightDirn
[0]);
4796 checkGLcall("glLightfv");
4797 glLightf(GL_LIGHT0
+ Index
, GL_SPOT_EXPONENT
, lightInfo
->exponent
);
4798 checkGLcall("glLightf");
4799 glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
4800 checkGLcall("glLightf");
4801 /* Attenuation - Are these right? guessing... */
4802 glLightf(GL_LIGHT0
+ Index
, GL_CONSTANT_ATTENUATION
, lightInfo
->OriginalParms
.Attenuation0
);
4803 checkGLcall("glLightf");
4804 glLightf(GL_LIGHT0
+ Index
, GL_LINEAR_ATTENUATION
, lightInfo
->OriginalParms
.Attenuation1
);
4805 checkGLcall("glLightf");
4806 if (quad_att
< lightInfo
->OriginalParms
.Attenuation2
) quad_att
= lightInfo
->OriginalParms
.Attenuation2
;
4807 glLightf(GL_LIGHT0
+ Index
, GL_QUADRATIC_ATTENUATION
, quad_att
);
4808 checkGLcall("glLightf");
4812 case WINED3DLIGHT_DIRECTIONAL
:
4814 glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->lightPosn
[0]); /* Note gl uses w position of 0 for direction! */
4815 checkGLcall("glLightfv");
4816 glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
4817 checkGLcall("glLightf");
4818 glLightf(GL_LIGHT0
+ Index
, GL_SPOT_EXPONENT
, 0.0f
);
4819 checkGLcall("glLightf");
4823 FIXME("Unrecognized light type %d\n", lightInfo
->OriginalParms
.Type
);
4826 /* Restore the modelview matrix */
4829 glEnable(GL_LIGHT0
+ Index
);
4830 checkGLcall("glEnable(GL_LIGHT0 + Index)");
4834 static void scissorrect(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
4836 struct wined3d_surface
*target
= stateblock
->device
->fb
.render_targets
[0];
4837 RECT
*pRect
= &stateblock
->state
.scissor_rect
;
4841 target
->get_drawable_size(context
, &width
, &height
);
4842 /* Warning: glScissor uses window coordinates, not viewport coordinates, so our viewport correction does not apply
4843 * Warning2: Even in windowed mode the coords are relative to the window, not the screen
4845 TRACE("(%p) Setting new Scissor Rect to %d:%d-%d:%d\n", stateblock
->device
, pRect
->left
, pRect
->bottom
- height
,
4846 pRect
->right
- pRect
->left
, pRect
->bottom
- pRect
->top
);
4848 if (context
->render_offscreen
)
4850 glScissor(pRect
->left
, pRect
->top
, pRect
->right
- pRect
->left
, pRect
->bottom
- pRect
->top
);
4852 glScissor(pRect
->left
, height
- pRect
->bottom
, pRect
->right
- pRect
->left
, pRect
->bottom
- pRect
->top
);
4854 checkGLcall("glScissor");
4857 static void indexbuffer(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
4859 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4861 if (stateblock
->state
.user_stream
|| !stateblock
->state
.index_buffer
)
4863 GL_EXTCALL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB
, 0));
4867 struct wined3d_buffer
*ib
= stateblock
->state
.index_buffer
;
4868 GL_EXTCALL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB
, ib
->buffer_object
));
4872 static void frontface(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
4874 if (context
->render_offscreen
)
4876 glFrontFace(GL_CCW
);
4877 checkGLcall("glFrontFace(GL_CCW)");
4880 checkGLcall("glFrontFace(GL_CW)");
4884 static void psorigin_w(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
4890 WARN("Point sprite coordinate origin switching not supported.\n");
4895 static void psorigin(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
4897 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4898 GLint origin
= context
->render_offscreen
? GL_LOWER_LEFT
: GL_UPPER_LEFT
;
4900 if (glPointParameteri
)
4902 glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN
, origin
);
4903 checkGLcall("glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, ...)");
4905 else if (gl_info
->supported
[NV_POINT_SPRITE
])
4907 GL_EXTCALL(glPointParameteriNV(GL_POINT_SPRITE_COORD_ORIGIN
, origin
));
4908 checkGLcall("glPointParameteriNV(GL_POINT_SPRITE_COORD_ORIGIN, ...)");
4912 const struct StateEntryTemplate misc_state_template
[] = {
4913 { STATE_RENDER(WINED3DRS_SRCBLEND
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4914 { STATE_RENDER(WINED3DRS_DESTBLEND
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4915 { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
}, WINED3D_GL_EXT_NONE
},
4916 { STATE_RENDER(WINED3DRS_EDGEANTIALIAS
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4917 { STATE_RENDER(WINED3DRS_ANTIALIASEDLINEENABLE
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4918 { STATE_RENDER(WINED3DRS_SEPARATEALPHABLENDENABLE
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4919 { STATE_RENDER(WINED3DRS_SRCBLENDALPHA
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4920 { STATE_RENDER(WINED3DRS_DESTBLENDALPHA
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4921 { STATE_RENDER(WINED3DRS_DESTBLENDALPHA
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4922 { STATE_RENDER(WINED3DRS_BLENDOPALPHA
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4923 { STATE_STREAMSRC
, { STATE_STREAMSRC
, streamsrc
}, WINED3D_GL_EXT_NONE
},
4924 { STATE_VDECL
, { STATE_VDECL
, vdecl_miscpart
}, WINED3D_GL_EXT_NONE
},
4925 { STATE_FRONTFACE
, { STATE_FRONTFACE
, frontface
}, WINED3D_GL_EXT_NONE
},
4926 { STATE_SCISSORRECT
, { STATE_SCISSORRECT
, scissorrect
}, WINED3D_GL_EXT_NONE
},
4927 { STATE_POINTSPRITECOORDORIGIN
, { STATE_POINTSPRITECOORDORIGIN
, psorigin
}, WINED3D_GL_VERSION_2_0
},
4928 { STATE_POINTSPRITECOORDORIGIN
, { STATE_POINTSPRITECOORDORIGIN
, psorigin_w
}, WINED3D_GL_EXT_NONE
},
4930 /* TODO: Move shader constant loading to vertex and fragment pipeline repectively, as soon as the pshader and
4931 * vshader loadings are untied from each other
4933 { STATE_VERTEXSHADERCONSTANT
, { STATE_VERTEXSHADERCONSTANT
, shaderconstant
}, WINED3D_GL_EXT_NONE
},
4934 { STATE_PIXELSHADERCONSTANT
, { STATE_VERTEXSHADERCONSTANT
, NULL
}, WINED3D_GL_EXT_NONE
},
4935 { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4936 { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4937 { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4938 { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4939 { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4940 { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4941 { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4942 { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4943 { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4944 { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4945 { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4946 { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4947 { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4948 { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4949 { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4950 { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4951 { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4952 { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4953 { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4954 { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4955 { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4956 { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4957 { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4958 { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4959 { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4960 { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4961 { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4962 { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4963 { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4964 { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4965 { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4966 { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4967 { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
4968 { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4969 { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
4970 { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4971 { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
4972 { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4973 { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
4974 { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4975 { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
4976 { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4977 { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
4978 { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4979 { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
4980 { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4981 { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
4982 { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4984 { STATE_VIEWPORT
, { STATE_VIEWPORT
, viewport_miscpart
}, WINED3D_GL_EXT_NONE
},
4985 { STATE_INDEXBUFFER
, { STATE_INDEXBUFFER
, indexbuffer
}, ARB_VERTEX_BUFFER_OBJECT
},
4986 { STATE_INDEXBUFFER
, { STATE_INDEXBUFFER
, state_nop
}, WINED3D_GL_EXT_NONE
},
4987 { STATE_RENDER(WINED3DRS_ANTIALIAS
), { STATE_RENDER(WINED3DRS_ANTIALIAS
), state_antialias
}, WINED3D_GL_EXT_NONE
},
4988 { STATE_RENDER(WINED3DRS_TEXTUREPERSPECTIVE
), { STATE_RENDER(WINED3DRS_TEXTUREPERSPECTIVE
), state_perspective
}, WINED3D_GL_EXT_NONE
},
4989 { STATE_RENDER(WINED3DRS_ZENABLE
), { STATE_RENDER(WINED3DRS_ZENABLE
), state_zenable
}, WINED3D_GL_EXT_NONE
},
4990 { STATE_RENDER(WINED3DRS_WRAPU
), { STATE_RENDER(WINED3DRS_WRAPU
), state_wrapu
}, WINED3D_GL_EXT_NONE
},
4991 { STATE_RENDER(WINED3DRS_WRAPV
), { STATE_RENDER(WINED3DRS_WRAPV
), state_wrapv
}, WINED3D_GL_EXT_NONE
},
4992 { STATE_RENDER(WINED3DRS_FILLMODE
), { STATE_RENDER(WINED3DRS_FILLMODE
), state_fillmode
}, WINED3D_GL_EXT_NONE
},
4993 { STATE_RENDER(WINED3DRS_SHADEMODE
), { STATE_RENDER(WINED3DRS_SHADEMODE
), state_shademode
}, WINED3D_GL_EXT_NONE
},
4994 { STATE_RENDER(WINED3DRS_LINEPATTERN
), { STATE_RENDER(WINED3DRS_LINEPATTERN
), state_linepattern
}, WINED3D_GL_EXT_NONE
},
4995 { STATE_RENDER(WINED3DRS_MONOENABLE
), { STATE_RENDER(WINED3DRS_MONOENABLE
), state_monoenable
}, WINED3D_GL_EXT_NONE
},
4996 { STATE_RENDER(WINED3DRS_ROP2
), { STATE_RENDER(WINED3DRS_ROP2
), state_rop2
}, WINED3D_GL_EXT_NONE
},
4997 { STATE_RENDER(WINED3DRS_PLANEMASK
), { STATE_RENDER(WINED3DRS_PLANEMASK
), state_planemask
}, WINED3D_GL_EXT_NONE
},
4998 { STATE_RENDER(WINED3DRS_ZWRITEENABLE
), { STATE_RENDER(WINED3DRS_ZWRITEENABLE
), state_zwritenable
}, WINED3D_GL_EXT_NONE
},
4999 { STATE_RENDER(WINED3DRS_ALPHATESTENABLE
), { STATE_RENDER(WINED3DRS_ALPHATESTENABLE
), state_alpha
}, WINED3D_GL_EXT_NONE
},
5000 { STATE_RENDER(WINED3DRS_ALPHAREF
), { STATE_RENDER(WINED3DRS_ALPHATESTENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5001 { STATE_RENDER(WINED3DRS_ALPHAFUNC
), { STATE_RENDER(WINED3DRS_ALPHATESTENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5002 { STATE_RENDER(WINED3DRS_COLORKEYENABLE
), { STATE_RENDER(WINED3DRS_ALPHATESTENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5003 { STATE_RENDER(WINED3DRS_LASTPIXEL
), { STATE_RENDER(WINED3DRS_LASTPIXEL
), state_lastpixel
}, WINED3D_GL_EXT_NONE
},
5004 { STATE_RENDER(WINED3DRS_CULLMODE
), { STATE_RENDER(WINED3DRS_CULLMODE
), state_cullmode
}, WINED3D_GL_EXT_NONE
},
5005 { STATE_RENDER(WINED3DRS_ZFUNC
), { STATE_RENDER(WINED3DRS_ZFUNC
), state_zfunc
}, WINED3D_GL_EXT_NONE
},
5006 { STATE_RENDER(WINED3DRS_DITHERENABLE
), { STATE_RENDER(WINED3DRS_DITHERENABLE
), state_ditherenable
}, WINED3D_GL_EXT_NONE
},
5007 { STATE_RENDER(WINED3DRS_SUBPIXEL
), { STATE_RENDER(WINED3DRS_SUBPIXEL
), state_subpixel
}, WINED3D_GL_EXT_NONE
},
5008 { STATE_RENDER(WINED3DRS_SUBPIXELX
), { STATE_RENDER(WINED3DRS_SUBPIXELX
), state_subpixelx
}, WINED3D_GL_EXT_NONE
},
5009 { STATE_RENDER(WINED3DRS_STIPPLEDALPHA
), { STATE_RENDER(WINED3DRS_STIPPLEDALPHA
), state_stippledalpha
}, WINED3D_GL_EXT_NONE
},
5010 { STATE_RENDER(WINED3DRS_STIPPLEENABLE
), { STATE_RENDER(WINED3DRS_STIPPLEENABLE
), state_stippleenable
}, WINED3D_GL_EXT_NONE
},
5011 { STATE_RENDER(WINED3DRS_MIPMAPLODBIAS
), { STATE_RENDER(WINED3DRS_MIPMAPLODBIAS
), state_mipmaplodbias
}, WINED3D_GL_EXT_NONE
},
5012 { STATE_RENDER(WINED3DRS_ANISOTROPY
), { STATE_RENDER(WINED3DRS_ANISOTROPY
), state_anisotropy
}, WINED3D_GL_EXT_NONE
},
5013 { STATE_RENDER(WINED3DRS_FLUSHBATCH
), { STATE_RENDER(WINED3DRS_FLUSHBATCH
), state_flushbatch
}, WINED3D_GL_EXT_NONE
},
5014 { STATE_RENDER(WINED3DRS_TRANSLUCENTSORTINDEPENDENT
), { STATE_RENDER(WINED3DRS_TRANSLUCENTSORTINDEPENDENT
), state_translucentsi
}, WINED3D_GL_EXT_NONE
},
5015 { STATE_RENDER(WINED3DRS_STENCILENABLE
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
}, WINED3D_GL_EXT_NONE
},
5016 { STATE_RENDER(WINED3DRS_STENCILFAIL
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5017 { STATE_RENDER(WINED3DRS_STENCILZFAIL
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5018 { STATE_RENDER(WINED3DRS_STENCILPASS
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5019 { STATE_RENDER(WINED3DRS_STENCILFUNC
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5020 { STATE_RENDER(WINED3DRS_STENCILREF
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5021 { STATE_RENDER(WINED3DRS_STENCILMASK
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5022 { STATE_RENDER(WINED3DRS_STENCILWRITEMASK
), { STATE_RENDER(WINED3DRS_STENCILWRITEMASK
), state_stencilwrite2s
}, EXT_STENCIL_TWO_SIDE
},
5023 { STATE_RENDER(WINED3DRS_STENCILWRITEMASK
), { STATE_RENDER(WINED3DRS_STENCILWRITEMASK
), state_stencilwrite
}, WINED3D_GL_EXT_NONE
},
5024 { STATE_RENDER(WINED3DRS_TWOSIDEDSTENCILMODE
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5025 { STATE_RENDER(WINED3DRS_CCW_STENCILFAIL
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5026 { STATE_RENDER(WINED3DRS_CCW_STENCILZFAIL
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5027 { STATE_RENDER(WINED3DRS_CCW_STENCILPASS
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5028 { STATE_RENDER(WINED3DRS_CCW_STENCILFUNC
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5029 { STATE_RENDER(WINED3DRS_WRAP0
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, WINED3D_GL_EXT_NONE
},
5030 { STATE_RENDER(WINED3DRS_WRAP1
), { STATE_RENDER(WINED3DRS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5031 { STATE_RENDER(WINED3DRS_WRAP2
), { STATE_RENDER(WINED3DRS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5032 { STATE_RENDER(WINED3DRS_WRAP3
), { STATE_RENDER(WINED3DRS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5033 { STATE_RENDER(WINED3DRS_WRAP4
), { STATE_RENDER(WINED3DRS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5034 { STATE_RENDER(WINED3DRS_WRAP5
), { STATE_RENDER(WINED3DRS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5035 { STATE_RENDER(WINED3DRS_WRAP6
), { STATE_RENDER(WINED3DRS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5036 { STATE_RENDER(WINED3DRS_WRAP7
), { STATE_RENDER(WINED3DRS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5037 { STATE_RENDER(WINED3DRS_WRAP8
), { STATE_RENDER(WINED3DRS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5038 { STATE_RENDER(WINED3DRS_WRAP9
), { STATE_RENDER(WINED3DRS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5039 { STATE_RENDER(WINED3DRS_WRAP10
), { STATE_RENDER(WINED3DRS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5040 { STATE_RENDER(WINED3DRS_WRAP11
), { STATE_RENDER(WINED3DRS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5041 { STATE_RENDER(WINED3DRS_WRAP12
), { STATE_RENDER(WINED3DRS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5042 { STATE_RENDER(WINED3DRS_WRAP13
), { STATE_RENDER(WINED3DRS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5043 { STATE_RENDER(WINED3DRS_WRAP14
), { STATE_RENDER(WINED3DRS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5044 { STATE_RENDER(WINED3DRS_WRAP15
), { STATE_RENDER(WINED3DRS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5045 { STATE_RENDER(WINED3DRS_EXTENTS
), { STATE_RENDER(WINED3DRS_EXTENTS
), state_extents
}, WINED3D_GL_EXT_NONE
},
5046 { STATE_RENDER(WINED3DRS_COLORKEYBLENDENABLE
), { STATE_RENDER(WINED3DRS_COLORKEYBLENDENABLE
), state_ckeyblend
}, WINED3D_GL_EXT_NONE
},
5047 { STATE_RENDER(WINED3DRS_SOFTWAREVERTEXPROCESSING
), { STATE_RENDER(WINED3DRS_SOFTWAREVERTEXPROCESSING
), state_swvp
}, WINED3D_GL_EXT_NONE
},
5048 { STATE_RENDER(WINED3DRS_PATCHEDGESTYLE
), { STATE_RENDER(WINED3DRS_PATCHEDGESTYLE
), state_patchedgestyle
}, WINED3D_GL_EXT_NONE
},
5049 { STATE_RENDER(WINED3DRS_PATCHSEGMENTS
), { STATE_RENDER(WINED3DRS_PATCHSEGMENTS
), state_patchsegments
}, WINED3D_GL_EXT_NONE
},
5050 { STATE_RENDER(WINED3DRS_POSITIONDEGREE
), { STATE_RENDER(WINED3DRS_POSITIONDEGREE
), state_positiondegree
}, WINED3D_GL_EXT_NONE
},
5051 { STATE_RENDER(WINED3DRS_NORMALDEGREE
), { STATE_RENDER(WINED3DRS_NORMALDEGREE
), state_normaldegree
}, WINED3D_GL_EXT_NONE
},
5052 { STATE_RENDER(WINED3DRS_MINTESSELLATIONLEVEL
), { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), NULL
}, WINED3D_GL_EXT_NONE
},
5053 { STATE_RENDER(WINED3DRS_MAXTESSELLATIONLEVEL
), { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), NULL
}, WINED3D_GL_EXT_NONE
},
5054 { STATE_RENDER(WINED3DRS_ADAPTIVETESS_X
), { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), NULL
}, WINED3D_GL_EXT_NONE
},
5055 { STATE_RENDER(WINED3DRS_ADAPTIVETESS_Y
), { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), NULL
}, WINED3D_GL_EXT_NONE
},
5056 { STATE_RENDER(WINED3DRS_ADAPTIVETESS_Z
), { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), NULL
}, WINED3D_GL_EXT_NONE
},
5057 { STATE_RENDER(WINED3DRS_ADAPTIVETESS_W
), { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), NULL
}, WINED3D_GL_EXT_NONE
},
5058 { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), state_nvdb
}, EXT_DEPTH_BOUNDS_TEST
},
5059 { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), state_tessellation
}, WINED3D_GL_EXT_NONE
},
5060 { STATE_RENDER(WINED3DRS_MULTISAMPLEANTIALIAS
), { STATE_RENDER(WINED3DRS_MULTISAMPLEANTIALIAS
), state_msaa
}, ARB_MULTISAMPLE
},
5061 { STATE_RENDER(WINED3DRS_MULTISAMPLEANTIALIAS
), { STATE_RENDER(WINED3DRS_MULTISAMPLEANTIALIAS
), state_msaa_w
}, WINED3D_GL_EXT_NONE
},
5062 { STATE_RENDER(WINED3DRS_MULTISAMPLEMASK
), { STATE_RENDER(WINED3DRS_MULTISAMPLEMASK
), state_multisampmask
}, WINED3D_GL_EXT_NONE
},
5063 { STATE_RENDER(WINED3DRS_DEBUGMONITORTOKEN
), { STATE_RENDER(WINED3DRS_DEBUGMONITORTOKEN
), state_debug_monitor
}, WINED3D_GL_EXT_NONE
},
5064 { STATE_RENDER(WINED3DRS_COLORWRITEENABLE
), { STATE_RENDER(WINED3DRS_COLORWRITEENABLE
), state_colorwrite0
}, EXT_DRAW_BUFFERS2
},
5065 { STATE_RENDER(WINED3DRS_COLORWRITEENABLE
), { STATE_RENDER(WINED3DRS_COLORWRITEENABLE
), state_colorwrite
}, WINED3D_GL_EXT_NONE
},
5066 { STATE_RENDER(WINED3DRS_BLENDOP
), { STATE_RENDER(WINED3DRS_BLENDOP
), state_blendop
}, EXT_BLEND_MINMAX
},
5067 { STATE_RENDER(WINED3DRS_BLENDOP
), { STATE_RENDER(WINED3DRS_BLENDOP
), state_blendop_w
}, WINED3D_GL_EXT_NONE
},
5068 { STATE_RENDER(WINED3DRS_SCISSORTESTENABLE
), { STATE_RENDER(WINED3DRS_SCISSORTESTENABLE
), state_scissor
}, WINED3D_GL_EXT_NONE
},
5069 { STATE_RENDER(WINED3DRS_SLOPESCALEDEPTHBIAS
), { STATE_RENDER(WINED3DRS_DEPTHBIAS
), NULL
}, WINED3D_GL_EXT_NONE
},
5070 { STATE_RENDER(WINED3DRS_COLORWRITEENABLE1
), { STATE_RENDER(WINED3DRS_COLORWRITEENABLE1
), state_colorwrite1
}, EXT_DRAW_BUFFERS2
},
5071 { STATE_RENDER(WINED3DRS_COLORWRITEENABLE1
), { STATE_RENDER(WINED3DRS_COLORWRITEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5072 { STATE_RENDER(WINED3DRS_COLORWRITEENABLE2
), { STATE_RENDER(WINED3DRS_COLORWRITEENABLE2
), state_colorwrite2
}, EXT_DRAW_BUFFERS2
},
5073 { STATE_RENDER(WINED3DRS_COLORWRITEENABLE2
), { STATE_RENDER(WINED3DRS_COLORWRITEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5074 { STATE_RENDER(WINED3DRS_COLORWRITEENABLE3
), { STATE_RENDER(WINED3DRS_COLORWRITEENABLE3
), state_colorwrite3
}, EXT_DRAW_BUFFERS2
},
5075 { STATE_RENDER(WINED3DRS_COLORWRITEENABLE3
), { STATE_RENDER(WINED3DRS_COLORWRITEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5076 { STATE_RENDER(WINED3DRS_BLENDFACTOR
), { STATE_RENDER(WINED3DRS_BLENDFACTOR
), state_blendfactor
}, EXT_BLEND_COLOR
},
5077 { STATE_RENDER(WINED3DRS_BLENDFACTOR
), { STATE_RENDER(WINED3DRS_BLENDFACTOR
), state_blendfactor_w
}, WINED3D_GL_EXT_NONE
},
5078 { STATE_RENDER(WINED3DRS_DEPTHBIAS
), { STATE_RENDER(WINED3DRS_DEPTHBIAS
), state_depthbias
}, WINED3D_GL_EXT_NONE
},
5079 { STATE_RENDER(WINED3DRS_ZVISIBLE
), { STATE_RENDER(WINED3DRS_ZVISIBLE
), state_zvisible
}, WINED3D_GL_EXT_NONE
},
5081 { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler
}, WINED3D_GL_EXT_NONE
},
5082 { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler
}, WINED3D_GL_EXT_NONE
},
5083 { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler
}, WINED3D_GL_EXT_NONE
},
5084 { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler
}, WINED3D_GL_EXT_NONE
},
5085 { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler
}, WINED3D_GL_EXT_NONE
},
5086 { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler
}, WINED3D_GL_EXT_NONE
},
5087 { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler
}, WINED3D_GL_EXT_NONE
},
5088 { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler
}, WINED3D_GL_EXT_NONE
},
5089 { STATE_SAMPLER(8), { STATE_SAMPLER(8), sampler
}, WINED3D_GL_EXT_NONE
},
5090 { STATE_SAMPLER(9), { STATE_SAMPLER(9), sampler
}, WINED3D_GL_EXT_NONE
},
5091 { STATE_SAMPLER(10), { STATE_SAMPLER(10), sampler
}, WINED3D_GL_EXT_NONE
},
5092 { STATE_SAMPLER(11), { STATE_SAMPLER(11), sampler
}, WINED3D_GL_EXT_NONE
},
5093 { STATE_SAMPLER(12), { STATE_SAMPLER(12), sampler
}, WINED3D_GL_EXT_NONE
},
5094 { STATE_SAMPLER(13), { STATE_SAMPLER(13), sampler
}, WINED3D_GL_EXT_NONE
},
5095 { STATE_SAMPLER(14), { STATE_SAMPLER(14), sampler
}, WINED3D_GL_EXT_NONE
},
5096 { STATE_SAMPLER(15), { STATE_SAMPLER(15), sampler
}, WINED3D_GL_EXT_NONE
},
5097 { STATE_SAMPLER(16), /* Vertex sampler 0 */ { STATE_SAMPLER(16), sampler
}, WINED3D_GL_EXT_NONE
},
5098 { STATE_SAMPLER(17), /* Vertex sampler 1 */ { STATE_SAMPLER(17), sampler
}, WINED3D_GL_EXT_NONE
},
5099 { STATE_SAMPLER(18), /* Vertex sampler 2 */ { STATE_SAMPLER(18), sampler
}, WINED3D_GL_EXT_NONE
},
5100 { STATE_SAMPLER(19), /* Vertex sampler 3 */ { STATE_SAMPLER(19), sampler
}, WINED3D_GL_EXT_NONE
},
5101 { STATE_BASEVERTEXINDEX
, { STATE_BASEVERTEXINDEX
, state_nop
, }, ARB_DRAW_ELEMENTS_BASE_VERTEX
},
5102 { STATE_BASEVERTEXINDEX
, { STATE_STREAMSRC
, NULL
, }, WINED3D_GL_EXT_NONE
},
5103 { STATE_FRAMEBUFFER
, { STATE_FRAMEBUFFER
, context_state_fb
}, WINED3D_GL_EXT_NONE
},
5104 { STATE_PIXELSHADER
, { STATE_PIXELSHADER
, context_state_drawbuf
},WINED3D_GL_EXT_NONE
},
5105 {0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE
},
5108 const struct StateEntryTemplate ffp_vertexstate_template
[] = {
5109 { STATE_VDECL
, { STATE_VDECL
, vertexdeclaration
}, WINED3D_GL_EXT_NONE
},
5110 { STATE_VSHADER
, { STATE_VDECL
, NULL
}, WINED3D_GL_EXT_NONE
},
5111 { STATE_MATERIAL
, { STATE_RENDER(WINED3DRS_SPECULARENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5112 { STATE_RENDER(WINED3DRS_SPECULARENABLE
), { STATE_RENDER(WINED3DRS_SPECULARENABLE
), state_specularenable
}, WINED3D_GL_EXT_NONE
},
5114 { STATE_CLIPPLANE(0), { STATE_CLIPPLANE(0), clipplane
}, WINED3D_GL_EXT_NONE
},
5115 { STATE_CLIPPLANE(1), { STATE_CLIPPLANE(1), clipplane
}, WINED3D_GL_EXT_NONE
},
5116 { STATE_CLIPPLANE(2), { STATE_CLIPPLANE(2), clipplane
}, WINED3D_GL_EXT_NONE
},
5117 { STATE_CLIPPLANE(3), { STATE_CLIPPLANE(3), clipplane
}, WINED3D_GL_EXT_NONE
},
5118 { STATE_CLIPPLANE(4), { STATE_CLIPPLANE(4), clipplane
}, WINED3D_GL_EXT_NONE
},
5119 { STATE_CLIPPLANE(5), { STATE_CLIPPLANE(5), clipplane
}, WINED3D_GL_EXT_NONE
},
5120 { STATE_CLIPPLANE(6), { STATE_CLIPPLANE(6), clipplane
}, WINED3D_GL_EXT_NONE
},
5121 { STATE_CLIPPLANE(7), { STATE_CLIPPLANE(7), clipplane
}, WINED3D_GL_EXT_NONE
},
5122 { STATE_CLIPPLANE(8), { STATE_CLIPPLANE(8), clipplane
}, WINED3D_GL_EXT_NONE
},
5123 { STATE_CLIPPLANE(9), { STATE_CLIPPLANE(9), clipplane
}, WINED3D_GL_EXT_NONE
},
5124 { STATE_CLIPPLANE(10), { STATE_CLIPPLANE(10), clipplane
}, WINED3D_GL_EXT_NONE
},
5125 { STATE_CLIPPLANE(11), { STATE_CLIPPLANE(11), clipplane
}, WINED3D_GL_EXT_NONE
},
5126 { STATE_CLIPPLANE(12), { STATE_CLIPPLANE(12), clipplane
}, WINED3D_GL_EXT_NONE
},
5127 { STATE_CLIPPLANE(13), { STATE_CLIPPLANE(13), clipplane
}, WINED3D_GL_EXT_NONE
},
5128 { STATE_CLIPPLANE(14), { STATE_CLIPPLANE(14), clipplane
}, WINED3D_GL_EXT_NONE
},
5129 { STATE_CLIPPLANE(15), { STATE_CLIPPLANE(15), clipplane
}, WINED3D_GL_EXT_NONE
},
5130 { STATE_CLIPPLANE(16), { STATE_CLIPPLANE(16), clipplane
}, WINED3D_GL_EXT_NONE
},
5131 { STATE_CLIPPLANE(17), { STATE_CLIPPLANE(17), clipplane
}, WINED3D_GL_EXT_NONE
},
5132 { STATE_CLIPPLANE(18), { STATE_CLIPPLANE(18), clipplane
}, WINED3D_GL_EXT_NONE
},
5133 { STATE_CLIPPLANE(19), { STATE_CLIPPLANE(19), clipplane
}, WINED3D_GL_EXT_NONE
},
5134 { STATE_CLIPPLANE(20), { STATE_CLIPPLANE(20), clipplane
}, WINED3D_GL_EXT_NONE
},
5135 { STATE_CLIPPLANE(21), { STATE_CLIPPLANE(21), clipplane
}, WINED3D_GL_EXT_NONE
},
5136 { STATE_CLIPPLANE(22), { STATE_CLIPPLANE(22), clipplane
}, WINED3D_GL_EXT_NONE
},
5137 { STATE_CLIPPLANE(23), { STATE_CLIPPLANE(23), clipplane
}, WINED3D_GL_EXT_NONE
},
5138 { STATE_CLIPPLANE(24), { STATE_CLIPPLANE(24), clipplane
}, WINED3D_GL_EXT_NONE
},
5139 { STATE_CLIPPLANE(25), { STATE_CLIPPLANE(25), clipplane
}, WINED3D_GL_EXT_NONE
},
5140 { STATE_CLIPPLANE(26), { STATE_CLIPPLANE(26), clipplane
}, WINED3D_GL_EXT_NONE
},
5141 { STATE_CLIPPLANE(27), { STATE_CLIPPLANE(27), clipplane
}, WINED3D_GL_EXT_NONE
},
5142 { STATE_CLIPPLANE(28), { STATE_CLIPPLANE(28), clipplane
}, WINED3D_GL_EXT_NONE
},
5143 { STATE_CLIPPLANE(29), { STATE_CLIPPLANE(29), clipplane
}, WINED3D_GL_EXT_NONE
},
5144 { STATE_CLIPPLANE(30), { STATE_CLIPPLANE(30), clipplane
}, WINED3D_GL_EXT_NONE
},
5145 { STATE_CLIPPLANE(31), { STATE_CLIPPLANE(31), clipplane
}, WINED3D_GL_EXT_NONE
},
5147 { STATE_ACTIVELIGHT(0), { STATE_ACTIVELIGHT(0), light
}, WINED3D_GL_EXT_NONE
},
5148 { STATE_ACTIVELIGHT(1), { STATE_ACTIVELIGHT(1), light
}, WINED3D_GL_EXT_NONE
},
5149 { STATE_ACTIVELIGHT(2), { STATE_ACTIVELIGHT(2), light
}, WINED3D_GL_EXT_NONE
},
5150 { STATE_ACTIVELIGHT(3), { STATE_ACTIVELIGHT(3), light
}, WINED3D_GL_EXT_NONE
},
5151 { STATE_ACTIVELIGHT(4), { STATE_ACTIVELIGHT(4), light
}, WINED3D_GL_EXT_NONE
},
5152 { STATE_ACTIVELIGHT(5), { STATE_ACTIVELIGHT(5), light
}, WINED3D_GL_EXT_NONE
},
5153 { STATE_ACTIVELIGHT(6), { STATE_ACTIVELIGHT(6), light
}, WINED3D_GL_EXT_NONE
},
5154 { STATE_ACTIVELIGHT(7), { STATE_ACTIVELIGHT(7), light
}, WINED3D_GL_EXT_NONE
},
5156 { STATE_VIEWPORT
, { STATE_VIEWPORT
, viewport_vertexpart
}, WINED3D_GL_EXT_NONE
},
5157 /* Transform states follow */
5158 { STATE_TRANSFORM(WINED3DTS_VIEW
), { STATE_TRANSFORM(WINED3DTS_VIEW
), transform_view
}, WINED3D_GL_EXT_NONE
},
5159 { STATE_TRANSFORM(WINED3DTS_PROJECTION
), { STATE_TRANSFORM(WINED3DTS_PROJECTION
), transform_projection
}, WINED3D_GL_EXT_NONE
},
5160 { STATE_TRANSFORM(WINED3DTS_TEXTURE0
), { STATE_TEXTURESTAGE(0,WINED3DTSS_TEXTURETRANSFORMFLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5161 { STATE_TRANSFORM(WINED3DTS_TEXTURE1
), { STATE_TEXTURESTAGE(1,WINED3DTSS_TEXTURETRANSFORMFLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5162 { STATE_TRANSFORM(WINED3DTS_TEXTURE2
), { STATE_TEXTURESTAGE(2,WINED3DTSS_TEXTURETRANSFORMFLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5163 { STATE_TRANSFORM(WINED3DTS_TEXTURE3
), { STATE_TEXTURESTAGE(3,WINED3DTSS_TEXTURETRANSFORMFLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5164 { STATE_TRANSFORM(WINED3DTS_TEXTURE4
), { STATE_TEXTURESTAGE(4,WINED3DTSS_TEXTURETRANSFORMFLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5165 { STATE_TRANSFORM(WINED3DTS_TEXTURE5
), { STATE_TEXTURESTAGE(5,WINED3DTSS_TEXTURETRANSFORMFLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5166 { STATE_TRANSFORM(WINED3DTS_TEXTURE6
), { STATE_TEXTURESTAGE(6,WINED3DTSS_TEXTURETRANSFORMFLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5167 { STATE_TRANSFORM(WINED3DTS_TEXTURE7
), { STATE_TEXTURESTAGE(7,WINED3DTSS_TEXTURETRANSFORMFLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5168 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 0)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 0)), transform_world
}, WINED3D_GL_EXT_NONE
},
5169 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 1)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 1)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5170 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 2)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 2)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5171 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 3)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 3)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5172 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 4)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 4)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5173 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 5)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 5)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5174 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 6)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 6)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5175 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 7)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 7)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5176 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 8)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 8)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5177 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 9)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 9)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5178 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 10)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 10)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5179 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 11)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 11)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5180 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 12)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 12)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5181 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 13)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 13)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5182 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 14)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 14)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5183 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 15)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 15)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5184 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 16)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 16)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5185 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 17)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 17)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5186 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 18)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 18)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5187 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 19)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 19)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5188 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 20)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 20)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5189 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 21)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 21)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5190 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 22)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 22)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5191 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 23)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 23)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5192 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 24)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 24)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5193 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 25)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 25)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5194 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 26)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 26)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5195 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 27)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 27)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5196 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 28)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 28)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5197 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 29)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 29)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5198 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 30)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 30)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5199 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 31)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 31)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5200 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 32)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 32)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5201 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 33)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 33)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5202 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 34)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 34)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5203 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 35)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 35)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5204 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 36)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 36)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5205 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 37)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 37)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5206 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 38)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 38)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5207 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 39)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 39)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5208 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 40)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 40)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5209 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 41)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 41)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5210 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 42)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 42)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5211 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 43)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 43)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5212 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 44)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 44)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5213 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 45)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 45)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5214 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 46)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 46)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5215 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 47)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 47)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5216 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 48)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 48)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5217 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 49)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 49)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5218 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 50)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 50)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5219 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 51)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 51)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5220 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 52)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 52)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5221 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 53)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 53)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5222 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 54)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 54)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5223 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 55)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 55)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5224 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 56)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 56)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5225 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 57)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 57)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5226 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 58)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 58)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5227 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 59)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 59)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5228 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 60)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 60)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5229 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 61)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 61)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5230 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 62)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 62)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5231 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 63)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 63)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5232 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 64)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 64)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5233 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 65)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 65)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5234 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 66)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 66)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5235 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 67)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 67)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5236 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 68)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 68)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5237 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 69)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 69)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5238 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 70)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 70)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5239 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 71)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 71)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5240 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 72)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 72)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5241 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 73)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 73)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5242 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 74)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 74)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5243 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 75)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 75)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5244 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 76)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 76)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5245 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 77)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 77)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5246 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 78)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 78)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5247 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 79)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 79)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5248 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 80)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 80)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5249 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 81)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 81)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5250 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 82)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 82)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5251 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 83)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 83)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5252 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 84)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 84)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5253 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 85)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 85)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5254 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 86)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 86)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5255 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 87)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 87)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5256 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 88)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 88)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5257 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 89)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 89)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5258 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 90)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 90)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5259 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 91)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 91)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5260 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 92)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 92)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5261 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 93)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 93)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5262 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 94)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 94)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5263 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 95)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 95)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5264 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 96)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 96)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5265 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 97)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 97)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5266 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 98)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 98)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5267 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 99)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 99)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5268 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(100)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(100)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5269 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(101)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(101)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5270 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(102)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(102)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5271 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(103)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(103)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5272 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(104)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(104)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5273 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(105)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(105)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5274 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(106)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(106)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5275 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(107)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(107)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5276 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(108)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(108)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5277 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(109)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(109)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5278 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(110)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(110)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5279 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(111)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(111)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5280 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(112)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(112)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5281 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(113)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(113)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5282 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(114)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(114)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5283 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(115)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(115)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5284 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(116)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(116)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5285 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(117)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(117)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5286 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(118)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(118)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5287 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(119)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(119)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5288 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(120)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(120)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5289 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(121)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(121)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5290 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(122)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(122)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5291 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(123)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(123)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5292 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(124)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(124)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5293 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(125)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(125)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5294 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(126)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(126)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5295 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(127)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(127)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5296 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(128)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(128)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5297 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(129)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(129)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5298 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(130)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(130)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5299 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(131)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(131)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5300 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(132)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(132)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5301 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(133)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(133)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5302 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(134)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(134)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5303 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(135)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(135)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5304 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(136)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(136)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5305 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(137)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(137)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5306 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(138)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(138)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5307 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(139)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(139)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5308 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(140)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(140)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5309 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(141)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(141)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5310 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(142)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(142)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5311 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(143)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(143)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5312 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(144)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(144)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5313 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(145)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(145)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5314 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(146)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(146)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5315 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(147)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(147)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5316 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(148)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(148)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5317 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(149)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(149)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5318 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(150)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(150)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5319 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(151)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(151)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5320 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(152)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(152)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5321 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(153)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(153)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5322 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(154)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(154)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5323 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(155)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(155)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5324 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(156)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(156)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5325 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(157)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(157)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5326 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(158)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(158)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5327 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(159)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(159)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5328 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(160)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(160)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5329 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(161)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(161)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5330 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(162)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(162)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5331 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(163)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(163)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5332 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(164)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(164)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5333 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(165)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(165)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5334 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(166)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(166)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5335 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(167)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(167)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5336 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(168)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(168)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5337 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(169)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(169)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5338 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(170)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(170)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5339 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(171)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(171)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5340 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(172)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(172)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5341 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(173)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(173)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5342 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(174)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(174)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5343 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(175)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(175)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5344 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(176)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(176)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5345 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(177)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(177)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5346 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(178)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(178)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5347 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(179)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(179)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5348 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(180)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(180)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5349 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(181)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(181)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5350 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(182)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(182)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5351 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(183)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(183)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5352 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(184)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(184)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5353 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(185)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(185)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5354 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(186)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(186)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5355 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(187)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(187)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5356 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(188)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(188)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5357 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(189)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(189)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5358 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(190)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(190)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5359 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(191)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(191)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5360 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(192)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(192)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5361 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(193)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(193)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5362 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(194)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(194)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5363 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(195)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(195)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5364 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(196)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(196)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5365 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(197)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(197)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5366 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(198)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(198)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5367 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(199)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(199)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5368 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(200)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(200)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5369 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(201)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(201)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5370 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(202)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(202)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5371 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(203)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(203)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5372 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(204)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(204)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5373 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(205)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(205)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5374 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(206)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(206)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5375 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(207)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(207)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5376 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(208)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(208)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5377 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(209)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(209)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5378 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(210)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(210)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5379 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(211)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(211)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5380 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(212)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(212)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5381 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(213)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(213)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5382 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(214)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(214)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5383 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(215)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(215)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5384 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(216)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(216)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5385 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(217)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(217)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5386 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(218)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(218)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5387 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(219)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(219)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5388 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(220)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(220)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5389 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(221)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(221)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5390 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(222)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(222)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5391 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(223)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(223)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5392 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(224)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(224)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5393 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(225)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(225)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5394 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(226)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(226)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5395 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(227)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(227)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5396 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(228)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(228)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5397 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(229)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(229)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5398 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(230)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(230)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5399 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(231)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(231)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5400 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(232)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(232)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5401 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(233)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(233)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5402 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(234)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(234)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5403 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(235)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(235)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5404 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(236)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(236)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5405 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(237)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(237)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5406 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(238)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(238)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5407 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(239)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(239)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5408 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(240)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(240)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5409 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(241)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(241)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5410 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(242)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(242)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5411 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(243)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(243)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5412 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(244)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(244)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5413 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(245)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(245)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5414 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(246)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(246)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5415 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(247)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(247)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5416 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(248)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(248)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5417 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(249)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(249)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5418 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(250)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(250)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5419 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(251)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(251)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5420 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(252)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(252)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5421 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(253)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(253)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5422 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(254)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(254)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5423 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(255)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(255)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5424 { STATE_TEXTURESTAGE(0,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(0,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, WINED3D_GL_EXT_NONE
},
5425 { STATE_TEXTURESTAGE(1,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(1,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, WINED3D_GL_EXT_NONE
},
5426 { STATE_TEXTURESTAGE(2,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(2,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, WINED3D_GL_EXT_NONE
},
5427 { STATE_TEXTURESTAGE(3,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(3,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, WINED3D_GL_EXT_NONE
},
5428 { STATE_TEXTURESTAGE(4,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(4,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, WINED3D_GL_EXT_NONE
},
5429 { STATE_TEXTURESTAGE(5,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(5,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, WINED3D_GL_EXT_NONE
},
5430 { STATE_TEXTURESTAGE(6,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(6,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, WINED3D_GL_EXT_NONE
},
5431 { STATE_TEXTURESTAGE(7,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(7,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, WINED3D_GL_EXT_NONE
},
5432 { STATE_TEXTURESTAGE(0, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(0, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5433 { STATE_TEXTURESTAGE(1, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(1, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5434 { STATE_TEXTURESTAGE(2, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(2, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5435 { STATE_TEXTURESTAGE(3, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(3, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5436 { STATE_TEXTURESTAGE(4, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(4, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5437 { STATE_TEXTURESTAGE(5, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(5, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5438 { STATE_TEXTURESTAGE(6, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(6, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5439 { STATE_TEXTURESTAGE(7, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(7, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5441 { STATE_RENDER(WINED3DRS_FOGENABLE
), { STATE_RENDER(WINED3DRS_FOGENABLE
), state_fog_vertexpart
}, WINED3D_GL_EXT_NONE
},
5442 { STATE_RENDER(WINED3DRS_FOGTABLEMODE
), { STATE_RENDER(WINED3DRS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5443 { STATE_RENDER(WINED3DRS_FOGVERTEXMODE
), { STATE_RENDER(WINED3DRS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5444 { STATE_RENDER(WINED3DRS_RANGEFOGENABLE
), { STATE_RENDER(WINED3DRS_RANGEFOGENABLE
), state_rangefog
}, NV_FOG_DISTANCE
},
5445 { STATE_RENDER(WINED3DRS_RANGEFOGENABLE
), { STATE_RENDER(WINED3DRS_RANGEFOGENABLE
), state_rangefog_w
}, WINED3D_GL_EXT_NONE
},
5446 { STATE_RENDER(WINED3DRS_CLIPPING
), { STATE_RENDER(WINED3DRS_CLIPPING
), state_clipping
}, WINED3D_GL_EXT_NONE
},
5447 { STATE_RENDER(WINED3DRS_CLIPPLANEENABLE
), { STATE_RENDER(WINED3DRS_CLIPPING
), NULL
}, WINED3D_GL_EXT_NONE
},
5448 { STATE_RENDER(WINED3DRS_LIGHTING
), { STATE_RENDER(WINED3DRS_LIGHTING
), state_lighting
}, WINED3D_GL_EXT_NONE
},
5449 { STATE_RENDER(WINED3DRS_AMBIENT
), { STATE_RENDER(WINED3DRS_AMBIENT
), state_ambient
}, WINED3D_GL_EXT_NONE
},
5450 { STATE_RENDER(WINED3DRS_COLORVERTEX
), { STATE_RENDER(WINED3DRS_COLORVERTEX
), state_colormat
}, WINED3D_GL_EXT_NONE
},
5451 { STATE_RENDER(WINED3DRS_LOCALVIEWER
), { STATE_RENDER(WINED3DRS_LOCALVIEWER
), state_localviewer
}, WINED3D_GL_EXT_NONE
},
5452 { STATE_RENDER(WINED3DRS_NORMALIZENORMALS
), { STATE_RENDER(WINED3DRS_NORMALIZENORMALS
), state_normalize
}, WINED3D_GL_EXT_NONE
},
5453 { STATE_RENDER(WINED3DRS_DIFFUSEMATERIALSOURCE
), { STATE_RENDER(WINED3DRS_COLORVERTEX
), NULL
}, WINED3D_GL_EXT_NONE
},
5454 { STATE_RENDER(WINED3DRS_SPECULARMATERIALSOURCE
), { STATE_RENDER(WINED3DRS_COLORVERTEX
), NULL
}, WINED3D_GL_EXT_NONE
},
5455 { STATE_RENDER(WINED3DRS_AMBIENTMATERIALSOURCE
), { STATE_RENDER(WINED3DRS_COLORVERTEX
), NULL
}, WINED3D_GL_EXT_NONE
},
5456 { STATE_RENDER(WINED3DRS_EMISSIVEMATERIALSOURCE
), { STATE_RENDER(WINED3DRS_COLORVERTEX
), NULL
}, WINED3D_GL_EXT_NONE
},
5457 { STATE_RENDER(WINED3DRS_VERTEXBLEND
), { STATE_RENDER(WINED3DRS_VERTEXBLEND
), state_vertexblend
}, ARB_VERTEX_BLEND
},
5458 { STATE_RENDER(WINED3DRS_VERTEXBLEND
), { STATE_RENDER(WINED3DRS_VERTEXBLEND
), state_vertexblend_w
}, WINED3D_GL_EXT_NONE
},
5459 { STATE_RENDER(WINED3DRS_POINTSIZE
), { STATE_RENDER(WINED3DRS_POINTSCALEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5460 { STATE_RENDER(WINED3DRS_POINTSIZE_MIN
), { STATE_RENDER(WINED3DRS_POINTSIZE_MIN
), state_psizemin_arb
}, ARB_POINT_PARAMETERS
},
5461 { STATE_RENDER(WINED3DRS_POINTSIZE_MIN
), { STATE_RENDER(WINED3DRS_POINTSIZE_MIN
), state_psizemin_ext
}, EXT_POINT_PARAMETERS
},
5462 { STATE_RENDER(WINED3DRS_POINTSIZE_MIN
), { STATE_RENDER(WINED3DRS_POINTSIZE_MIN
), state_psizemin_w
}, WINED3D_GL_EXT_NONE
},
5463 { STATE_RENDER(WINED3DRS_POINTSPRITEENABLE
), { STATE_RENDER(WINED3DRS_POINTSPRITEENABLE
), state_pointsprite
}, ARB_POINT_SPRITE
},
5464 { STATE_RENDER(WINED3DRS_POINTSPRITEENABLE
), { STATE_RENDER(WINED3DRS_POINTSPRITEENABLE
), state_pointsprite_w
}, WINED3D_GL_EXT_NONE
},
5465 { STATE_RENDER(WINED3DRS_POINTSCALEENABLE
), { STATE_RENDER(WINED3DRS_POINTSCALEENABLE
), state_pscale
}, WINED3D_GL_EXT_NONE
},
5466 { STATE_RENDER(WINED3DRS_POINTSCALE_A
), { STATE_RENDER(WINED3DRS_POINTSCALEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5467 { STATE_RENDER(WINED3DRS_POINTSCALE_B
), { STATE_RENDER(WINED3DRS_POINTSCALEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5468 { STATE_RENDER(WINED3DRS_POINTSCALE_C
), { STATE_RENDER(WINED3DRS_POINTSCALEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5469 { STATE_RENDER(WINED3DRS_POINTSIZE_MAX
), { STATE_RENDER(WINED3DRS_POINTSIZE_MIN
), NULL
}, ARB_POINT_PARAMETERS
},
5470 { STATE_RENDER(WINED3DRS_POINTSIZE_MAX
), { STATE_RENDER(WINED3DRS_POINTSIZE_MIN
), NULL
}, EXT_POINT_PARAMETERS
},
5471 { STATE_RENDER(WINED3DRS_POINTSIZE_MAX
), { STATE_RENDER(WINED3DRS_POINTSIZE_MIN
), NULL
}, WINED3D_GL_EXT_NONE
},
5472 { STATE_RENDER(WINED3DRS_TWEENFACTOR
), { STATE_RENDER(WINED3DRS_VERTEXBLEND
), NULL
}, WINED3D_GL_EXT_NONE
},
5473 { STATE_RENDER(WINED3DRS_INDEXEDVERTEXBLENDENABLE
), { STATE_RENDER(WINED3DRS_VERTEXBLEND
), NULL
}, WINED3D_GL_EXT_NONE
},
5475 /* Samplers for NP2 texture matrix adjustions. They are not needed if GL_ARB_texture_non_power_of_two is supported,
5476 * so register a NULL state handler in that case to get the vertex part of sampler() skipped(VTF is handled in the misc states.
5477 * otherwise, register sampler_texmatrix, which takes care of updating the texture matrix
5479 { STATE_SAMPLER(0), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5480 { STATE_SAMPLER(0), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5481 { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5482 { STATE_SAMPLER(1), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5483 { STATE_SAMPLER(1), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5484 { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5485 { STATE_SAMPLER(2), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5486 { STATE_SAMPLER(2), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5487 { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5488 { STATE_SAMPLER(3), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5489 { STATE_SAMPLER(3), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5490 { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5491 { STATE_SAMPLER(4), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5492 { STATE_SAMPLER(4), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5493 { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5494 { STATE_SAMPLER(5), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5495 { STATE_SAMPLER(5), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5496 { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5497 { STATE_SAMPLER(6), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5498 { STATE_SAMPLER(6), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5499 { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5500 { STATE_SAMPLER(7), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5501 { STATE_SAMPLER(7), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5502 { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5503 {0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE
},
5506 static const struct StateEntryTemplate ffp_fragmentstate_template
[] = {
5507 { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5508 { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5509 { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5510 { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5511 { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5512 { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5513 { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5514 { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5515 { STATE_TEXTURESTAGE(0, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5516 { STATE_TEXTURESTAGE(0, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5517 { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5518 { STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5519 { STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5520 { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5521 { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5522 { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5523 { STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5524 { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5525 { STATE_TEXTURESTAGE(1, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5526 { STATE_TEXTURESTAGE(1, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5527 { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5528 { STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5529 { STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5530 { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5531 { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5532 { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5533 { STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5534 { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5535 { STATE_TEXTURESTAGE(2, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5536 { STATE_TEXTURESTAGE(2, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5537 { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5538 { STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5539 { STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5540 { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5541 { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5542 { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5543 { STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5544 { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5545 { STATE_TEXTURESTAGE(3, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5546 { STATE_TEXTURESTAGE(3, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5547 { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5548 { STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5549 { STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5550 { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5551 { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5552 { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5553 { STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5554 { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5555 { STATE_TEXTURESTAGE(4, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5556 { STATE_TEXTURESTAGE(4, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5557 { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5558 { STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5559 { STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5560 { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5561 { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5562 { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5563 { STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5564 { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5565 { STATE_TEXTURESTAGE(5, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5566 { STATE_TEXTURESTAGE(5, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5567 { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5568 { STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5569 { STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5570 { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5571 { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5572 { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5573 { STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5574 { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5575 { STATE_TEXTURESTAGE(6, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5576 { STATE_TEXTURESTAGE(6, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5577 { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5578 { STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5579 { STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5580 { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5581 { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5582 { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5583 { STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5584 { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5585 { STATE_TEXTURESTAGE(7, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5586 { STATE_TEXTURESTAGE(7, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5587 { STATE_PIXELSHADER
, { STATE_PIXELSHADER
, apply_pixelshader
}, WINED3D_GL_EXT_NONE
},
5588 { STATE_RENDER(WINED3DRS_SRGBWRITEENABLE
), { STATE_PIXELSHADER
, NULL
}, WINED3D_GL_EXT_NONE
},
5589 { STATE_RENDER(WINED3DRS_TEXTUREFACTOR
), { STATE_RENDER(WINED3DRS_TEXTUREFACTOR
), state_texfactor
}, WINED3D_GL_EXT_NONE
},
5590 { STATE_RENDER(WINED3DRS_FOGCOLOR
), { STATE_RENDER(WINED3DRS_FOGCOLOR
), state_fogcolor
}, WINED3D_GL_EXT_NONE
},
5591 { STATE_RENDER(WINED3DRS_FOGDENSITY
), { STATE_RENDER(WINED3DRS_FOGDENSITY
), state_fogdensity
}, WINED3D_GL_EXT_NONE
},
5592 { STATE_RENDER(WINED3DRS_FOGENABLE
), { STATE_RENDER(WINED3DRS_FOGENABLE
), state_fog_fragpart
}, WINED3D_GL_EXT_NONE
},
5593 { STATE_RENDER(WINED3DRS_FOGTABLEMODE
), { STATE_RENDER(WINED3DRS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5594 { STATE_RENDER(WINED3DRS_FOGVERTEXMODE
), { STATE_RENDER(WINED3DRS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5595 { STATE_RENDER(WINED3DRS_FOGSTART
), { STATE_RENDER(WINED3DRS_FOGSTART
), state_fogstartend
}, WINED3D_GL_EXT_NONE
},
5596 { STATE_RENDER(WINED3DRS_FOGEND
), { STATE_RENDER(WINED3DRS_FOGSTART
), NULL
}, WINED3D_GL_EXT_NONE
},
5597 { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5598 { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5599 { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5600 { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5601 { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5602 { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5603 { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5604 { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5605 {0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE
},
5608 /* Context activation and GL locking are done by the caller. */
5609 static void ffp_enable(BOOL enable
) {}
5611 static void ffp_fragment_get_caps(const struct wined3d_gl_info
*gl_info
, struct fragment_caps
*caps
)
5613 caps
->PrimitiveMiscCaps
= 0;
5614 caps
->TextureOpCaps
= WINED3DTEXOPCAPS_ADD
5615 | WINED3DTEXOPCAPS_ADDSIGNED
5616 | WINED3DTEXOPCAPS_ADDSIGNED2X
5617 | WINED3DTEXOPCAPS_MODULATE
5618 | WINED3DTEXOPCAPS_MODULATE2X
5619 | WINED3DTEXOPCAPS_MODULATE4X
5620 | WINED3DTEXOPCAPS_SELECTARG1
5621 | WINED3DTEXOPCAPS_SELECTARG2
5622 | WINED3DTEXOPCAPS_DISABLE
;
5624 if (gl_info
->supported
[ARB_TEXTURE_ENV_COMBINE
]
5625 || gl_info
->supported
[EXT_TEXTURE_ENV_COMBINE
]
5626 || gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
5628 caps
->TextureOpCaps
|= WINED3DTEXOPCAPS_BLENDDIFFUSEALPHA
5629 | WINED3DTEXOPCAPS_BLENDTEXTUREALPHA
5630 | WINED3DTEXOPCAPS_BLENDFACTORALPHA
5631 | WINED3DTEXOPCAPS_BLENDCURRENTALPHA
5632 | WINED3DTEXOPCAPS_LERP
5633 | WINED3DTEXOPCAPS_SUBTRACT
;
5635 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
]
5636 || gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
5638 caps
->TextureOpCaps
|= WINED3DTEXOPCAPS_ADDSMOOTH
5639 | WINED3DTEXOPCAPS_MULTIPLYADD
5640 | WINED3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR
5641 | WINED3DTEXOPCAPS_MODULATECOLOR_ADDALPHA
5642 | WINED3DTEXOPCAPS_BLENDTEXTUREALPHAPM
;
5644 if (gl_info
->supported
[ARB_TEXTURE_ENV_DOT3
])
5645 caps
->TextureOpCaps
|= WINED3DTEXOPCAPS_DOTPRODUCT3
;
5647 caps
->MaxTextureBlendStages
= gl_info
->limits
.textures
;
5648 caps
->MaxSimultaneousTextures
= gl_info
->limits
.textures
;
5651 static HRESULT
ffp_fragment_alloc(struct wined3d_device
*device
) { return WINED3D_OK
; }
5652 static void ffp_fragment_free(struct wined3d_device
*device
) {}
5653 static BOOL
ffp_color_fixup_supported(struct color_fixup_desc fixup
)
5657 TRACE("Checking support for fixup:\n");
5658 dump_color_fixup_desc(fixup
);
5661 /* We only support identity conversions. */
5662 if (is_identity_fixup(fixup
))
5668 TRACE("[FAILED]\n");
5672 const struct fragment_pipeline ffp_fragment_pipeline
= {
5674 ffp_fragment_get_caps
,
5677 ffp_color_fixup_supported
,
5678 ffp_fragmentstate_template
,
5679 FALSE
/* we cannot disable projected textures. The vertex pipe has to do it */
5682 static unsigned int num_handlers(const APPLYSTATEFUNC
*funcs
)
5685 for(i
= 0; funcs
[i
]; i
++);
5689 static void multistate_apply_2(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
5691 stateblock
->device
->multistate_funcs
[state
][0](state
, stateblock
, context
);
5692 stateblock
->device
->multistate_funcs
[state
][1](state
, stateblock
, context
);
5695 static void multistate_apply_3(DWORD state
, struct wined3d_stateblock
*stateblock
, struct wined3d_context
*context
)
5697 stateblock
->device
->multistate_funcs
[state
][0](state
, stateblock
, context
);
5698 stateblock
->device
->multistate_funcs
[state
][1](state
, stateblock
, context
);
5699 stateblock
->device
->multistate_funcs
[state
][2](state
, stateblock
, context
);
5702 static void prune_invalid_states(struct StateEntry
*state_table
, const struct wined3d_gl_info
*gl_info
)
5704 unsigned int start
, last
, i
;
5706 start
= STATE_TEXTURESTAGE(gl_info
->limits
.texture_stages
, 0);
5707 last
= STATE_TEXTURESTAGE(MAX_TEXTURES
- 1, WINED3D_HIGHEST_TEXTURE_STATE
);
5708 for (i
= start
; i
<= last
; ++i
)
5710 state_table
[i
].representative
= 0;
5711 state_table
[i
].apply
= state_undefined
;
5714 start
= STATE_TRANSFORM(WINED3DTS_TEXTURE0
+ gl_info
->limits
.texture_stages
);
5715 last
= STATE_TRANSFORM(WINED3DTS_TEXTURE0
+ MAX_TEXTURES
- 1);
5716 for (i
= start
; i
<= last
; ++i
)
5718 state_table
[i
].representative
= 0;
5719 state_table
[i
].apply
= state_undefined
;
5722 start
= STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(gl_info
->limits
.blends
));
5723 last
= STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(255));
5724 for (i
= start
; i
<= last
; ++i
)
5726 state_table
[i
].representative
= 0;
5727 state_table
[i
].apply
= state_undefined
;
5731 static void validate_state_table(struct StateEntry
*state_table
)
5753 static const DWORD simple_states
[] =
5759 STATE_VERTEXSHADERCONSTANT
,
5760 STATE_PIXELSHADERCONSTANT
,
5766 STATE_POINTSPRITECOORDORIGIN
,
5767 STATE_BASEVERTEXINDEX
,
5770 unsigned int i
, current
;
5772 for (i
= STATE_RENDER(1), current
= 0; i
<= STATE_RENDER(WINEHIGHEST_RENDER_STATE
); ++i
)
5774 if (!rs_holes
[current
].first
|| i
< STATE_RENDER(rs_holes
[current
].first
))
5776 if (!state_table
[i
].representative
)
5777 ERR("State %s (%#x) should have a representative.\n", debug_d3dstate(i
), i
);
5779 else if (state_table
[i
].representative
)
5780 ERR("State %s (%#x) shouldn't have a representative.\n", debug_d3dstate(i
), i
);
5782 if (i
== STATE_RENDER(rs_holes
[current
].last
)) ++current
;
5785 for (i
= 0; i
< sizeof(simple_states
) / sizeof(*simple_states
); ++i
)
5787 if (!state_table
[simple_states
[i
]].representative
)
5788 ERR("State %s (%#x) should have a representative.\n",
5789 debug_d3dstate(simple_states
[i
]), simple_states
[i
]);
5792 for (i
= 0; i
< STATE_HIGHEST
+ 1; ++i
)
5794 DWORD rep
= state_table
[i
].representative
;
5797 if (state_table
[rep
].representative
!= rep
)
5799 ERR("State %s (%#x) has invalid representative %s (%#x).\n",
5800 debug_d3dstate(i
), i
, debug_d3dstate(rep
), rep
);
5801 state_table
[i
].representative
= 0;
5806 if (state_table
[i
].apply
)
5807 ERR("State %s (%#x) has both a handler and representative.\n", debug_d3dstate(i
), i
);
5809 else if (!state_table
[i
].apply
)
5811 ERR("Self representing state %s (%#x) has no handler.\n", debug_d3dstate(i
), i
);
5817 HRESULT
compile_state_table(struct StateEntry
*StateTable
, APPLYSTATEFUNC
**dev_multistate_funcs
,
5818 const struct wined3d_gl_info
*gl_info
, const struct StateEntryTemplate
*vertex
,
5819 const struct fragment_pipeline
*fragment
, const struct StateEntryTemplate
*misc
)
5821 unsigned int i
, type
, handlers
;
5822 APPLYSTATEFUNC multistate_funcs
[STATE_HIGHEST
+ 1][3];
5823 const struct StateEntryTemplate
*cur
;
5824 BOOL set
[STATE_HIGHEST
+ 1];
5826 memset(multistate_funcs
, 0, sizeof(multistate_funcs
));
5828 for(i
= 0; i
< STATE_HIGHEST
+ 1; i
++) {
5829 StateTable
[i
].representative
= 0;
5830 StateTable
[i
].apply
= state_undefined
;
5833 for(type
= 0; type
< 3; type
++) {
5834 /* This switch decides the order in which the states are applied */
5836 case 0: cur
= misc
; break;
5837 case 1: cur
= fragment
->states
; break;
5838 case 2: cur
= vertex
; break;
5839 default: cur
= NULL
; /* Stupid compiler */
5843 /* GL extension filtering should not prevent multiple handlers being applied from different
5846 memset(set
, 0, sizeof(set
));
5848 for(i
= 0; cur
[i
].state
; i
++) {
5849 APPLYSTATEFUNC
*funcs_array
;
5851 /* Only use the first matching state with the available extension from one template.
5853 * {D3DRS_FOOBAR, {D3DRS_FOOBAR, func1}, XYZ_FANCY},
5854 * {D3DRS_FOOBAR, {D3DRS_FOOBAR, func2}, 0 }
5856 * if GL_XYZ_fancy is supported, ignore the 2nd line
5858 if(set
[cur
[i
].state
]) continue;
5859 /* Skip state lines depending on unsupported extensions */
5860 if (!gl_info
->supported
[cur
[i
].extension
]) continue;
5861 set
[cur
[i
].state
] = TRUE
;
5862 /* In some cases having an extension means that nothing has to be
5863 * done for a state, e.g. if GL_ARB_texture_non_power_of_two is
5864 * supported, the texture coordinate fixup can be ignored. If the
5865 * apply function is used, mark the state set(done above) to prevent
5866 * applying later lines, but do not record anything in the state
5869 if (!cur
[i
].content
.representative
) continue;
5871 handlers
= num_handlers(multistate_funcs
[cur
[i
].state
]);
5872 multistate_funcs
[cur
[i
].state
][handlers
] = cur
[i
].content
.apply
;
5875 StateTable
[cur
[i
].state
].apply
= cur
[i
].content
.apply
;
5878 StateTable
[cur
[i
].state
].apply
= multistate_apply_2
;
5879 dev_multistate_funcs
[cur
[i
].state
] = HeapAlloc(GetProcessHeap(),
5881 sizeof(**dev_multistate_funcs
) * 2);
5882 if (!dev_multistate_funcs
[cur
[i
].state
]) {
5886 dev_multistate_funcs
[cur
[i
].state
][0] = multistate_funcs
[cur
[i
].state
][0];
5887 dev_multistate_funcs
[cur
[i
].state
][1] = multistate_funcs
[cur
[i
].state
][1];
5890 StateTable
[cur
[i
].state
].apply
= multistate_apply_3
;
5891 funcs_array
= HeapReAlloc(GetProcessHeap(),
5893 dev_multistate_funcs
[cur
[i
].state
],
5894 sizeof(**dev_multistate_funcs
) * 3);
5899 dev_multistate_funcs
[cur
[i
].state
] = funcs_array
;
5900 dev_multistate_funcs
[cur
[i
].state
][2] = multistate_funcs
[cur
[i
].state
][2];
5903 ERR("Unexpected amount of state handlers for state %u: %u\n",
5904 cur
[i
].state
, handlers
+ 1);
5907 if(StateTable
[cur
[i
].state
].representative
&&
5908 StateTable
[cur
[i
].state
].representative
!= cur
[i
].content
.representative
) {
5909 FIXME("State %u has different representatives in different pipeline parts\n",
5912 StateTable
[cur
[i
].state
].representative
= cur
[i
].content
.representative
;
5916 prune_invalid_states(StateTable
, gl_info
);
5917 validate_state_table(StateTable
);
5922 for (i
= 0; i
<= STATE_HIGHEST
; ++i
) {
5923 HeapFree(GetProcessHeap(), 0, dev_multistate_funcs
[i
]);
5926 memset(dev_multistate_funcs
, 0, (STATE_HIGHEST
+ 1)*sizeof(*dev_multistate_funcs
));
5928 return E_OUTOFMEMORY
;