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
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
32 #include "wined3d_private.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(d3d
);
35 WINE_DECLARE_DEBUG_CHANNEL(d3d_shader
);
37 #define GLINFO_LOCATION stateblock->wineD3DDevice->adapter->gl_info
39 /* GL locking for state handlers is done by the caller. */
41 static void state_blendop(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
);
43 static void state_nogl(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
44 /* Used for states which are not mapped to a gl state as-is, but used somehow different,
45 * e.g as a parameter for drawing, or which are unimplemented in windows d3d
47 if(STATE_IS_RENDER(state
)) {
48 WINED3DRENDERSTATETYPE RenderState
= state
- STATE_RENDER(0);
49 TRACE("(%s,%d) no direct mapping to gl\n", debug_d3drenderstate(RenderState
), stateblock
->renderState
[RenderState
]);
51 /* Shouldn't have an unknown type here */
52 FIXME("%d no direct mapping to gl of state with unknown type\n", state
);
56 static void state_undefined(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
57 /* Print a WARN, this allows the stateblock code to loop over all states to generate a display
58 * list without causing confusing terminal output. Deliberately no special debug name here
59 * because its undefined.
61 WARN("undefined state %d\n", state
);
64 static void state_fillmode(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
65 WINED3DFILLMODE Value
= stateblock
->renderState
[WINED3DRS_FILLMODE
];
68 case WINED3DFILL_POINT
:
69 glPolygonMode(GL_FRONT_AND_BACK
, GL_POINT
);
70 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_POINT)");
72 case WINED3DFILL_WIREFRAME
:
73 glPolygonMode(GL_FRONT_AND_BACK
, GL_LINE
);
74 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)");
76 case WINED3DFILL_SOLID
:
77 glPolygonMode(GL_FRONT_AND_BACK
, GL_FILL
);
78 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)");
81 FIXME("Unrecognized WINED3DRS_FILLMODE value %d\n", Value
);
85 static void state_lighting(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
86 /* Lighting is not enabled if transformed vertices are drawn
87 * but lighting does not affect the stream sources, so it is not grouped for performance reasons.
88 * This state reads the decoded vertex declaration, so if it is dirty don't do anything. The
89 * vertex declaration applying function calls this function for updating
92 if(isStateDirty(context
, STATE_VDECL
)) {
96 if (stateblock
->renderState
[WINED3DRS_LIGHTING
]
97 && !stateblock
->wineD3DDevice
->strided_streams
.position_transformed
)
99 glEnable(GL_LIGHTING
);
100 checkGLcall("glEnable GL_LIGHTING");
102 glDisable(GL_LIGHTING
);
103 checkGLcall("glDisable GL_LIGHTING");
107 static void state_zenable(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
108 /* No z test without depth stencil buffers */
109 if(stateblock
->wineD3DDevice
->stencilBufferTarget
== NULL
) {
110 TRACE("No Z buffer - disabling depth test\n");
111 glDisable(GL_DEPTH_TEST
); /* This also disables z writing in gl */
112 checkGLcall("glDisable GL_DEPTH_TEST");
116 switch ((WINED3DZBUFFERTYPE
) stateblock
->renderState
[WINED3DRS_ZENABLE
]) {
117 case WINED3DZB_FALSE
:
118 glDisable(GL_DEPTH_TEST
);
119 checkGLcall("glDisable GL_DEPTH_TEST");
122 glEnable(GL_DEPTH_TEST
);
123 checkGLcall("glEnable GL_DEPTH_TEST");
126 glEnable(GL_DEPTH_TEST
);
127 checkGLcall("glEnable GL_DEPTH_TEST");
128 FIXME("W buffer is not well handled\n");
131 FIXME("Unrecognized D3DZBUFFERTYPE value %d\n", stateblock
->renderState
[WINED3DRS_ZENABLE
]);
135 static void state_cullmode(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
136 /* glFrontFace() is set in context.c at context init and on an offscreen / onscreen rendering
139 switch ((WINED3DCULL
) stateblock
->renderState
[WINED3DRS_CULLMODE
]) {
140 case WINED3DCULL_NONE
:
141 glDisable(GL_CULL_FACE
);
142 checkGLcall("glDisable GL_CULL_FACE");
145 glEnable(GL_CULL_FACE
);
146 checkGLcall("glEnable GL_CULL_FACE");
147 glCullFace(GL_FRONT
);
148 checkGLcall("glCullFace(GL_FRONT)");
150 case WINED3DCULL_CCW
:
151 glEnable(GL_CULL_FACE
);
152 checkGLcall("glEnable GL_CULL_FACE");
154 checkGLcall("glCullFace(GL_BACK)");
157 FIXME("Unrecognized/Unhandled WINED3DCULL value %d\n", stateblock
->renderState
[WINED3DRS_CULLMODE
]);
161 static void state_shademode(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
162 switch ((WINED3DSHADEMODE
) stateblock
->renderState
[WINED3DRS_SHADEMODE
]) {
163 case WINED3DSHADE_FLAT
:
164 glShadeModel(GL_FLAT
);
165 checkGLcall("glShadeModel(GL_FLAT)");
167 case WINED3DSHADE_GOURAUD
:
168 glShadeModel(GL_SMOOTH
);
169 checkGLcall("glShadeModel(GL_SMOOTH)");
171 case WINED3DSHADE_PHONG
:
172 FIXME("WINED3DSHADE_PHONG isn't supported\n");
175 FIXME("Unrecognized/Unhandled WINED3DSHADEMODE value %d\n", stateblock
->renderState
[WINED3DRS_SHADEMODE
]);
179 static void state_ditherenable(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
180 if (stateblock
->renderState
[WINED3DRS_DITHERENABLE
]) {
182 checkGLcall("glEnable GL_DITHER");
184 glDisable(GL_DITHER
);
185 checkGLcall("glDisable GL_DITHER");
189 static void state_zwritenable(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
190 /* TODO: Test if in d3d z writing is enabled even if ZENABLE is off. If yes,
191 * this has to be merged with ZENABLE and ZFUNC
193 if (stateblock
->renderState
[WINED3DRS_ZWRITEENABLE
]) {
195 checkGLcall("glDepthMask(1)");
198 checkGLcall("glDepthMask(0)");
202 static void state_zfunc(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
203 int glParm
= CompareFunc(stateblock
->renderState
[WINED3DRS_ZFUNC
]);
206 if(glParm
== GL_EQUAL
|| glParm
== GL_NOTEQUAL
) {
207 static BOOL once
= FALSE
;
208 /* There are a few issues with this: First, our inability to
209 * select a proper Z depth, most of the time we're stuck with
210 * D24S8, even if the app selects D32 or D16. There seem to be
211 * some other precision problems which have to be debugged to
212 * make NOTEQUAL and EQUAL work properly
216 FIXME("D3DCMP_NOTEQUAL and D3DCMP_EQUAL do not work correctly yet\n");
221 checkGLcall("glDepthFunc");
225 static void state_ambient(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
227 D3DCOLORTOGLFLOAT4(stateblock
->renderState
[WINED3DRS_AMBIENT
], col
);
229 TRACE("Setting ambient to (%f,%f,%f,%f)\n", col
[0], col
[1], col
[2], col
[3]);
230 glLightModelfv(GL_LIGHT_MODEL_AMBIENT
, col
);
231 checkGLcall("glLightModel for MODEL_AMBIENT");
234 static void state_blend(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
235 int srcBlend
= GL_ZERO
;
236 int dstBlend
= GL_ZERO
;
237 IWineD3DSurfaceImpl
*target
= (IWineD3DSurfaceImpl
*) stateblock
->wineD3DDevice
->render_targets
[0];
239 /* GL_LINE_SMOOTH needs GL_BLEND to work, according to the red book, and special blending params */
240 if (stateblock
->renderState
[WINED3DRS_ALPHABLENDENABLE
] ||
241 stateblock
->renderState
[WINED3DRS_EDGEANTIALIAS
] ||
242 stateblock
->renderState
[WINED3DRS_ANTIALIASEDLINEENABLE
]) {
244 /* Disable blending in all cases even without pixelshaders. With blending on we could face a big performance penalty.
245 * The d3d9 visual test confirms the behavior. */
246 if (!(target
->resource
.format_desc
->Flags
& WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
))
249 checkGLcall("glDisable GL_BLEND");
253 checkGLcall("glEnable GL_BLEND");
257 checkGLcall("glDisable GL_BLEND");
258 /* Nothing more to do - get out */
262 switch (stateblock
->renderState
[WINED3DRS_DESTBLEND
]) {
263 case WINED3DBLEND_ZERO
: dstBlend
= GL_ZERO
; break;
264 case WINED3DBLEND_ONE
: dstBlend
= GL_ONE
; break;
265 case WINED3DBLEND_SRCCOLOR
: dstBlend
= GL_SRC_COLOR
; break;
266 case WINED3DBLEND_INVSRCCOLOR
: dstBlend
= GL_ONE_MINUS_SRC_COLOR
; break;
267 case WINED3DBLEND_SRCALPHA
: dstBlend
= GL_SRC_ALPHA
; break;
268 case WINED3DBLEND_INVSRCALPHA
: dstBlend
= GL_ONE_MINUS_SRC_ALPHA
; break;
269 case WINED3DBLEND_DESTCOLOR
: dstBlend
= GL_DST_COLOR
; break;
270 case WINED3DBLEND_INVDESTCOLOR
: dstBlend
= GL_ONE_MINUS_DST_COLOR
; break;
272 /* To compensate the lack of format switching with backbuffer offscreen rendering,
273 * and with onscreen rendering, we modify the alpha test parameters for (INV)DESTALPHA
274 * if the render target doesn't support alpha blending. A nonexistent alpha channel
275 * returns 1.0, so D3DBLEND_DESTALPHA is GL_ONE, and D3DBLEND_INVDESTALPHA is GL_ZERO
277 case WINED3DBLEND_DESTALPHA
:
278 dstBlend
= target
->resource
.format_desc
->alpha_mask
? GL_DST_ALPHA
: GL_ONE
;
280 case WINED3DBLEND_INVDESTALPHA
:
281 dstBlend
= target
->resource
.format_desc
->alpha_mask
? GL_ONE_MINUS_DST_ALPHA
: GL_ZERO
;
284 case WINED3DBLEND_SRCALPHASAT
:
285 dstBlend
= GL_SRC_ALPHA_SATURATE
;
286 WARN("Application uses SRCALPHASAT as dest blend factor, expect problems\n");
289 /* WINED3DBLEND_BOTHSRCALPHA and WINED3DBLEND_BOTHINVSRCALPHA are legacy source blending
290 * values which are still valid up to d3d9. They should not occur as dest blend values
292 case WINED3DBLEND_BOTHSRCALPHA
: dstBlend
= GL_SRC_ALPHA
;
293 srcBlend
= GL_SRC_ALPHA
;
294 FIXME("WINED3DRS_DESTBLEND = WINED3DBLEND_BOTHSRCALPHA, what to do?\n");
297 case WINED3DBLEND_BOTHINVSRCALPHA
: dstBlend
= GL_ONE_MINUS_SRC_ALPHA
;
298 srcBlend
= GL_ONE_MINUS_SRC_ALPHA
;
299 FIXME("WINED3DRS_DESTBLEND = WINED3DBLEND_BOTHINVSRCALPHA, what to do?\n");
302 case WINED3DBLEND_BLENDFACTOR
: dstBlend
= GL_CONSTANT_COLOR
; break;
303 case WINED3DBLEND_INVBLENDFACTOR
: dstBlend
= GL_ONE_MINUS_CONSTANT_COLOR
; break;
305 FIXME("Unrecognized dst blend value %d\n", stateblock
->renderState
[WINED3DRS_DESTBLEND
]);
308 switch (stateblock
->renderState
[WINED3DRS_SRCBLEND
]) {
309 case WINED3DBLEND_ZERO
: srcBlend
= GL_ZERO
; break;
310 case WINED3DBLEND_ONE
: srcBlend
= GL_ONE
; break;
311 case WINED3DBLEND_SRCCOLOR
: srcBlend
= GL_SRC_COLOR
; break;
312 case WINED3DBLEND_INVSRCCOLOR
: srcBlend
= GL_ONE_MINUS_SRC_COLOR
; break;
313 case WINED3DBLEND_SRCALPHA
: srcBlend
= GL_SRC_ALPHA
; break;
314 case WINED3DBLEND_INVSRCALPHA
: srcBlend
= GL_ONE_MINUS_SRC_ALPHA
; break;
315 case WINED3DBLEND_DESTCOLOR
: srcBlend
= GL_DST_COLOR
; break;
316 case WINED3DBLEND_INVDESTCOLOR
: srcBlend
= GL_ONE_MINUS_DST_COLOR
; break;
317 case WINED3DBLEND_SRCALPHASAT
: srcBlend
= GL_SRC_ALPHA_SATURATE
; break;
319 case WINED3DBLEND_DESTALPHA
:
320 srcBlend
= target
->resource
.format_desc
->alpha_mask
? GL_DST_ALPHA
: GL_ONE
;
322 case WINED3DBLEND_INVDESTALPHA
:
323 srcBlend
= target
->resource
.format_desc
->alpha_mask
? GL_ONE_MINUS_DST_ALPHA
: GL_ZERO
;
326 case WINED3DBLEND_BOTHSRCALPHA
: srcBlend
= GL_SRC_ALPHA
;
327 dstBlend
= GL_ONE_MINUS_SRC_ALPHA
;
330 case WINED3DBLEND_BOTHINVSRCALPHA
: srcBlend
= GL_ONE_MINUS_SRC_ALPHA
;
331 dstBlend
= GL_SRC_ALPHA
;
334 case WINED3DBLEND_BLENDFACTOR
: srcBlend
= GL_CONSTANT_COLOR
; break;
335 case WINED3DBLEND_INVBLENDFACTOR
: srcBlend
= GL_ONE_MINUS_CONSTANT_COLOR
; break;
337 FIXME("Unrecognized src blend value %d\n", stateblock
->renderState
[WINED3DRS_SRCBLEND
]);
340 if(stateblock
->renderState
[WINED3DRS_EDGEANTIALIAS
] ||
341 stateblock
->renderState
[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
->renderState
[WINED3DRS_SEPARATEALPHABLENDENABLE
]) {
361 int srcBlendAlpha
= GL_ZERO
;
362 int dstBlendAlpha
= GL_ZERO
;
364 /* Separate alpha blending requires GL_EXT_blend_function_separate, so make sure it is around */
365 if(!GL_SUPPORT(EXT_BLEND_FUNC_SEPARATE
)) {
366 WARN("Unsupported in local OpenGL implementation: glBlendFuncSeparateEXT\n");
370 switch (stateblock
->renderState
[WINED3DRS_DESTBLENDALPHA
]) {
371 case WINED3DBLEND_ZERO
: dstBlendAlpha
= GL_ZERO
; break;
372 case WINED3DBLEND_ONE
: dstBlendAlpha
= GL_ONE
; break;
373 case WINED3DBLEND_SRCCOLOR
: dstBlendAlpha
= GL_SRC_COLOR
; break;
374 case WINED3DBLEND_INVSRCCOLOR
: dstBlendAlpha
= GL_ONE_MINUS_SRC_COLOR
; break;
375 case WINED3DBLEND_SRCALPHA
: dstBlendAlpha
= GL_SRC_ALPHA
; break;
376 case WINED3DBLEND_INVSRCALPHA
: dstBlendAlpha
= GL_ONE_MINUS_SRC_ALPHA
; break;
377 case WINED3DBLEND_DESTCOLOR
: dstBlendAlpha
= GL_DST_COLOR
; break;
378 case WINED3DBLEND_INVDESTCOLOR
: dstBlendAlpha
= GL_ONE_MINUS_DST_COLOR
; break;
379 case WINED3DBLEND_DESTALPHA
: dstBlendAlpha
= GL_DST_ALPHA
; break;
380 case WINED3DBLEND_INVDESTALPHA
: dstBlendAlpha
= GL_DST_ALPHA
; break;
381 case WINED3DBLEND_SRCALPHASAT
:
382 dstBlend
= GL_SRC_ALPHA_SATURATE
;
383 WARN("Application uses SRCALPHASAT as dest blend factor, expect problems\n");
385 /* WINED3DBLEND_BOTHSRCALPHA and WINED3DBLEND_BOTHINVSRCALPHA are legacy source blending
386 * values which are still valid up to d3d9. They should not occur as dest blend values
388 case WINED3DBLEND_BOTHSRCALPHA
:
389 dstBlendAlpha
= GL_SRC_ALPHA
;
390 srcBlendAlpha
= GL_SRC_ALPHA
;
391 FIXME("WINED3DRS_DESTBLENDALPHA = WINED3DBLEND_BOTHSRCALPHA, what to do?\n");
393 case WINED3DBLEND_BOTHINVSRCALPHA
:
394 dstBlendAlpha
= GL_ONE_MINUS_SRC_ALPHA
;
395 srcBlendAlpha
= GL_ONE_MINUS_SRC_ALPHA
;
396 FIXME("WINED3DRS_DESTBLENDALPHA = WINED3DBLEND_BOTHINVSRCALPHA, what to do?\n");
398 case WINED3DBLEND_BLENDFACTOR
: dstBlendAlpha
= GL_CONSTANT_COLOR
; break;
399 case WINED3DBLEND_INVBLENDFACTOR
: dstBlendAlpha
= GL_ONE_MINUS_CONSTANT_COLOR
; break;
401 FIXME("Unrecognized dst blend alpha value %d\n", stateblock
->renderState
[WINED3DRS_DESTBLENDALPHA
]);
404 switch (stateblock
->renderState
[WINED3DRS_SRCBLENDALPHA
]) {
405 case WINED3DBLEND_ZERO
: srcBlendAlpha
= GL_ZERO
; break;
406 case WINED3DBLEND_ONE
: srcBlendAlpha
= GL_ONE
; break;
407 case WINED3DBLEND_SRCCOLOR
: srcBlendAlpha
= GL_SRC_COLOR
; break;
408 case WINED3DBLEND_INVSRCCOLOR
: srcBlendAlpha
= GL_ONE_MINUS_SRC_COLOR
; break;
409 case WINED3DBLEND_SRCALPHA
: srcBlendAlpha
= GL_SRC_ALPHA
; break;
410 case WINED3DBLEND_INVSRCALPHA
: srcBlendAlpha
= GL_ONE_MINUS_SRC_ALPHA
; break;
411 case WINED3DBLEND_DESTCOLOR
: srcBlendAlpha
= GL_DST_COLOR
; break;
412 case WINED3DBLEND_INVDESTCOLOR
: srcBlendAlpha
= GL_ONE_MINUS_DST_COLOR
; break;
413 case WINED3DBLEND_SRCALPHASAT
: srcBlendAlpha
= GL_SRC_ALPHA_SATURATE
; break;
414 case WINED3DBLEND_DESTALPHA
: srcBlendAlpha
= GL_DST_ALPHA
; break;
415 case WINED3DBLEND_INVDESTALPHA
: srcBlendAlpha
= GL_DST_ALPHA
; break;
416 case WINED3DBLEND_BOTHSRCALPHA
:
417 srcBlendAlpha
= GL_SRC_ALPHA
;
418 dstBlendAlpha
= GL_ONE_MINUS_SRC_ALPHA
;
420 case WINED3DBLEND_BOTHINVSRCALPHA
:
421 srcBlendAlpha
= GL_ONE_MINUS_SRC_ALPHA
;
422 dstBlendAlpha
= GL_SRC_ALPHA
;
424 case WINED3DBLEND_BLENDFACTOR
: srcBlendAlpha
= GL_CONSTANT_COLOR
; break;
425 case WINED3DBLEND_INVBLENDFACTOR
: srcBlendAlpha
= GL_ONE_MINUS_CONSTANT_COLOR
; break;
427 FIXME("Unrecognized src blend alpha value %d\n", stateblock
->renderState
[WINED3DRS_SRCBLENDALPHA
]);
430 GL_EXTCALL(glBlendFuncSeparateEXT(srcBlend
, dstBlend
, srcBlendAlpha
, dstBlendAlpha
));
431 checkGLcall("glBlendFuncSeparateEXT");
433 TRACE("glBlendFunc src=%x, dst=%x\n", srcBlend
, dstBlend
);
434 glBlendFunc(srcBlend
, dstBlend
);
435 checkGLcall("glBlendFunc");
438 /* colorkey fixup for stage 0 alphaop depends on WINED3DRS_ALPHABLENDENABLE state,
439 so it may need updating */
440 if (stateblock
->renderState
[WINED3DRS_COLORKEYENABLE
]) {
441 const struct StateEntry
*StateTable
= stateblock
->wineD3DDevice
->StateTable
;
442 StateTable
[STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
)].apply(STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), stateblock
, context
);
446 static void state_blendfactor_w(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
447 WARN("Unsupported in local OpenGL implementation: glBlendColorEXT\n");
450 static void state_blendfactor(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
453 TRACE("Setting BlendFactor to %d\n", stateblock
->renderState
[WINED3DRS_BLENDFACTOR
]);
454 D3DCOLORTOGLFLOAT4(stateblock
->renderState
[WINED3DRS_BLENDFACTOR
], col
);
455 GL_EXTCALL(glBlendColorEXT (col
[0],col
[1],col
[2],col
[3]));
456 checkGLcall("glBlendColor");
459 static void state_alpha(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
462 BOOL enable_ckey
= FALSE
;
464 TRACE("state %#x, stateblock %p, context %p\n", state
, stateblock
, context
);
466 /* Find out if the texture on the first stage has a ckey set
467 * The alpha state func reads the texture settings, even though alpha and texture are not grouped
468 * together. This is to avoid making a huge alpha+texture+texture stage+ckey block due to the hardly
469 * used WINED3DRS_COLORKEYENABLE state(which is d3d <= 3 only). The texture function will call alpha
470 * in case it finds some texture+colorkeyenable combination which needs extra care.
472 if (stateblock
->textures
[0])
474 UINT texture_dimensions
= IWineD3DBaseTexture_GetTextureDimensions(stateblock
->textures
[0]);
476 if (texture_dimensions
== GL_TEXTURE_2D
|| texture_dimensions
== GL_TEXTURE_RECTANGLE_ARB
)
478 IWineD3DSurfaceImpl
*surf
;
480 surf
= (IWineD3DSurfaceImpl
*) ((IWineD3DTextureImpl
*)stateblock
->textures
[0])->surfaces
[0];
482 if (surf
->CKeyFlags
& WINEDDSD_CKSRCBLT
)
484 /* The surface conversion does not do color keying conversion for surfaces that have an alpha
485 * channel on their own. Likewise, the alpha test shouldn't be set up for color keying if the
486 * surface has alpha bits */
487 if (!surf
->resource
.format_desc
->alpha_mask
) enable_ckey
= TRUE
;
492 if(enable_ckey
|| context
->last_was_ckey
) {
493 const struct StateEntry
*StateTable
= stateblock
->wineD3DDevice
->StateTable
;
494 StateTable
[STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
)].apply(STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), stateblock
, context
);
496 context
->last_was_ckey
= enable_ckey
;
498 if (stateblock
->renderState
[WINED3DRS_ALPHATESTENABLE
] ||
499 (stateblock
->renderState
[WINED3DRS_COLORKEYENABLE
] && enable_ckey
)) {
500 glEnable(GL_ALPHA_TEST
);
501 checkGLcall("glEnable GL_ALPHA_TEST");
503 glDisable(GL_ALPHA_TEST
);
504 checkGLcall("glDisable GL_ALPHA_TEST");
505 /* Alpha test is disabled, don't bother setting the params - it will happen on the next
511 if(stateblock
->renderState
[WINED3DRS_COLORKEYENABLE
] && enable_ckey
) {
512 glParm
= GL_NOTEQUAL
;
515 ref
= ((float) stateblock
->renderState
[WINED3DRS_ALPHAREF
]) / 255.0f
;
516 glParm
= CompareFunc(stateblock
->renderState
[WINED3DRS_ALPHAFUNC
]);
519 glAlphaFunc(glParm
, ref
);
520 checkGLcall("glAlphaFunc");
524 static void state_clipping(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
525 DWORD enable
= 0xFFFFFFFF;
526 DWORD disable
= 0x00000000;
528 if (!stateblock
->wineD3DDevice
->vs_clipping
&& use_vs(stateblock
))
530 /* The spec says that opengl clipping planes are disabled when using shaders. Direct3D planes aren't,
531 * so that is an issue. The MacOS ATI driver keeps clipping planes activated with shaders in some
532 * conditions I got sick of tracking down. The shader state handler disables all clip planes because
533 * of that - don't do anything here and keep them disabled
535 if(stateblock
->renderState
[WINED3DRS_CLIPPLANEENABLE
]) {
536 static BOOL warned
= FALSE
;
538 FIXME("Clipping not supported with vertex shaders\n");
545 /* TODO: Keep track of previously enabled clipplanes to avoid unnecessary resetting
546 * of already set values
549 /* If enabling / disabling all
550 * TODO: Is this correct? Doesn't D3DRS_CLIPPING disable clipping on the viewport frustrum?
552 if (stateblock
->renderState
[WINED3DRS_CLIPPING
]) {
553 enable
= stateblock
->renderState
[WINED3DRS_CLIPPLANEENABLE
];
554 disable
= ~stateblock
->renderState
[WINED3DRS_CLIPPLANEENABLE
];
555 if(GL_SUPPORT(NV_DEPTH_CLAMP
)) {
556 glDisable(GL_DEPTH_CLAMP_NV
);
557 checkGLcall("glDisable(GL_DEPTH_CLAMP_NV)");
560 disable
= 0xffffffff;
562 if(GL_SUPPORT(NV_DEPTH_CLAMP
)) {
563 glEnable(GL_DEPTH_CLAMP_NV
);
564 checkGLcall("glEnable(GL_DEPTH_CLAMP_NV)");
568 if (enable
& WINED3DCLIPPLANE0
) { glEnable(GL_CLIP_PLANE0
); checkGLcall("glEnable(clip plane 0)"); }
569 if (enable
& WINED3DCLIPPLANE1
) { glEnable(GL_CLIP_PLANE1
); checkGLcall("glEnable(clip plane 1)"); }
570 if (enable
& WINED3DCLIPPLANE2
) { glEnable(GL_CLIP_PLANE2
); checkGLcall("glEnable(clip plane 2)"); }
571 if (enable
& WINED3DCLIPPLANE3
) { glEnable(GL_CLIP_PLANE3
); checkGLcall("glEnable(clip plane 3)"); }
572 if (enable
& WINED3DCLIPPLANE4
) { glEnable(GL_CLIP_PLANE4
); checkGLcall("glEnable(clip plane 4)"); }
573 if (enable
& WINED3DCLIPPLANE5
) { glEnable(GL_CLIP_PLANE5
); checkGLcall("glEnable(clip plane 5)"); }
575 if (disable
& WINED3DCLIPPLANE0
) { glDisable(GL_CLIP_PLANE0
); checkGLcall("glDisable(clip plane 0)"); }
576 if (disable
& WINED3DCLIPPLANE1
) { glDisable(GL_CLIP_PLANE1
); checkGLcall("glDisable(clip plane 1)"); }
577 if (disable
& WINED3DCLIPPLANE2
) { glDisable(GL_CLIP_PLANE2
); checkGLcall("glDisable(clip plane 2)"); }
578 if (disable
& WINED3DCLIPPLANE3
) { glDisable(GL_CLIP_PLANE3
); checkGLcall("glDisable(clip plane 3)"); }
579 if (disable
& WINED3DCLIPPLANE4
) { glDisable(GL_CLIP_PLANE4
); checkGLcall("glDisable(clip plane 4)"); }
580 if (disable
& WINED3DCLIPPLANE5
) { glDisable(GL_CLIP_PLANE5
); checkGLcall("glDisable(clip plane 5)"); }
582 /** update clipping status */
584 stateblock
->clip_status
.ClipUnion
= 0;
585 stateblock
->clip_status
.ClipIntersection
= 0xFFFFFFFF;
587 stateblock
->clip_status
.ClipUnion
= 0;
588 stateblock
->clip_status
.ClipIntersection
= 0;
592 static void state_blendop_w(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
593 WARN("Unsupported in local OpenGL implementation: glBlendEquation\n");
596 static void state_blendop(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
597 int blendEquation
= GL_FUNC_ADD
;
598 int blendEquationAlpha
= GL_FUNC_ADD
;
600 /* BLENDOPALPHA requires GL_EXT_blend_equation_separate, so make sure it is around */
601 if(stateblock
->renderState
[WINED3DRS_BLENDOPALPHA
] && !GL_SUPPORT(EXT_BLEND_EQUATION_SEPARATE
)) {
602 WARN("Unsupported in local OpenGL implementation: glBlendEquationSeparateEXT\n");
606 switch ((WINED3DBLENDOP
) stateblock
->renderState
[WINED3DRS_BLENDOP
]) {
607 case WINED3DBLENDOP_ADD
: blendEquation
= GL_FUNC_ADD
; break;
608 case WINED3DBLENDOP_SUBTRACT
: blendEquation
= GL_FUNC_SUBTRACT
; break;
609 case WINED3DBLENDOP_REVSUBTRACT
: blendEquation
= GL_FUNC_REVERSE_SUBTRACT
; break;
610 case WINED3DBLENDOP_MIN
: blendEquation
= GL_MIN
; break;
611 case WINED3DBLENDOP_MAX
: blendEquation
= GL_MAX
; break;
613 FIXME("Unrecognized/Unhandled D3DBLENDOP value %d\n", stateblock
->renderState
[WINED3DRS_BLENDOP
]);
616 switch ((WINED3DBLENDOP
) stateblock
->renderState
[WINED3DRS_BLENDOPALPHA
]) {
617 case WINED3DBLENDOP_ADD
: blendEquationAlpha
= GL_FUNC_ADD
; break;
618 case WINED3DBLENDOP_SUBTRACT
: blendEquationAlpha
= GL_FUNC_SUBTRACT
; break;
619 case WINED3DBLENDOP_REVSUBTRACT
: blendEquationAlpha
= GL_FUNC_REVERSE_SUBTRACT
; break;
620 case WINED3DBLENDOP_MIN
: blendEquationAlpha
= GL_MIN
; break;
621 case WINED3DBLENDOP_MAX
: blendEquationAlpha
= GL_MAX
; break;
623 FIXME("Unrecognized/Unhandled D3DBLENDOP value %d\n", stateblock
->renderState
[WINED3DRS_BLENDOPALPHA
]);
626 if(stateblock
->renderState
[WINED3DRS_SEPARATEALPHABLENDENABLE
]) {
627 TRACE("glBlendEquationSeparateEXT(%x, %x)\n", blendEquation
, blendEquationAlpha
);
628 GL_EXTCALL(glBlendEquationSeparateEXT(blendEquation
, blendEquationAlpha
));
629 checkGLcall("glBlendEquationSeparateEXT");
631 TRACE("glBlendEquation(%x)\n", blendEquation
);
632 GL_EXTCALL(glBlendEquationEXT(blendEquation
));
633 checkGLcall("glBlendEquation");
638 state_specularenable(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
639 /* Originally this used glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR)
640 * and (GL_LIGHT_MODEL_COLOR_CONTROL,GL_SINGLE_COLOR) to swap between enabled/disabled
641 * specular color. This is wrong:
642 * Separate specular color means the specular colour is maintained separately, whereas
643 * single color means it is merged in. However in both cases they are being used to
645 * To disable specular color, set it explicitly to black and turn off GL_COLOR_SUM_EXT
646 * NOTE: If not supported don't give FIXMEs the impact is really minimal and very few people are
650 * If register combiners are enabled, enabling / disabling GL_COLOR_SUM has no effect.
651 * Instead, we need to setup the FinalCombiner properly.
653 * The default setup for the FinalCombiner is:
655 * <variable> <input> <mapping> <usage>
656 * GL_VARIABLE_A_NV GL_FOG, GL_UNSIGNED_IDENTITY_NV GL_ALPHA
657 * GL_VARIABLE_B_NV GL_SPARE0_PLUS_SECONDARY_COLOR_NV GL_UNSIGNED_IDENTITY_NV GL_RGB
658 * GL_VARIABLE_C_NV GL_FOG GL_UNSIGNED_IDENTITY_NV GL_RGB
659 * GL_VARIABLE_D_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
660 * GL_VARIABLE_E_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
661 * GL_VARIABLE_F_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
662 * GL_VARIABLE_G_NV GL_SPARE0_NV GL_UNSIGNED_IDENTITY_NV GL_ALPHA
664 * That's pretty much fine as it is, except for variable B, which needs to take
665 * either GL_SPARE0_PLUS_SECONDARY_COLOR_NV or GL_SPARE0_NV, depending on
666 * whether WINED3DRS_SPECULARENABLE is enabled or not.
669 TRACE("Setting specular enable state and materials\n");
670 if (stateblock
->renderState
[WINED3DRS_SPECULARENABLE
]) {
671 glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, (float*) &stateblock
->material
.Specular
);
672 checkGLcall("glMaterialfv");
674 if(stateblock
->material
.Power
> GL_LIMITS(shininess
)) {
675 /* glMaterialf man page says that the material says that GL_SHININESS must be between 0.0
676 * and 128.0, although in d3d neither -1 nor 129 produce an error. GL_NV_max_light_exponent
677 * allows bigger values. If the extension is supported, GL_LIMITS(shininess) contains the
678 * value reported by the extension, otherwise 128. For values > GL_LIMITS(shininess) clamp
679 * them, it should be safe to do so without major visual distortions.
681 WARN("Material power = %f, limit %f\n", stateblock
->material
.Power
, GL_LIMITS(shininess
));
682 glMaterialf(GL_FRONT_AND_BACK
, GL_SHININESS
, GL_LIMITS(shininess
));
684 glMaterialf(GL_FRONT_AND_BACK
, GL_SHININESS
, stateblock
->material
.Power
);
686 checkGLcall("glMaterialf(GL_SHININESS)");
688 if (GL_SUPPORT(EXT_SECONDARY_COLOR
)) {
689 glEnable(GL_COLOR_SUM_EXT
);
691 TRACE("Specular colors cannot be enabled in this version of opengl\n");
693 checkGLcall("glEnable(GL_COLOR_SUM)");
695 if (GL_SUPPORT(NV_REGISTER_COMBINERS
)) {
696 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV
, GL_SPARE0_PLUS_SECONDARY_COLOR_NV
, GL_UNSIGNED_IDENTITY_NV
, GL_RGB
));
697 checkGLcall("glFinalCombinerInputNV()");
700 static const GLfloat black
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
702 /* for the case of enabled lighting: */
703 glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, &black
[0]);
704 checkGLcall("glMaterialfv");
706 /* for the case of disabled lighting: */
707 if (GL_SUPPORT(EXT_SECONDARY_COLOR
)) {
708 glDisable(GL_COLOR_SUM_EXT
);
710 TRACE("Specular colors cannot be disabled in this version of opengl\n");
712 checkGLcall("glDisable(GL_COLOR_SUM)");
714 if (GL_SUPPORT(NV_REGISTER_COMBINERS
)) {
715 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV
, GL_SPARE0_NV
, GL_UNSIGNED_IDENTITY_NV
, GL_RGB
));
716 checkGLcall("glFinalCombinerInputNV()");
720 TRACE("(%p) : Diffuse (%f,%f,%f,%f)\n", stateblock
->wineD3DDevice
, stateblock
->material
.Diffuse
.r
, stateblock
->material
.Diffuse
.g
,
721 stateblock
->material
.Diffuse
.b
, stateblock
->material
.Diffuse
.a
);
722 TRACE("(%p) : Ambient (%f,%f,%f,%f)\n", stateblock
->wineD3DDevice
, stateblock
->material
.Ambient
.r
, stateblock
->material
.Ambient
.g
,
723 stateblock
->material
.Ambient
.b
, stateblock
->material
.Ambient
.a
);
724 TRACE("(%p) : Specular (%f,%f,%f,%f)\n", stateblock
->wineD3DDevice
, stateblock
->material
.Specular
.r
, stateblock
->material
.Specular
.g
,
725 stateblock
->material
.Specular
.b
, stateblock
->material
.Specular
.a
);
726 TRACE("(%p) : Emissive (%f,%f,%f,%f)\n", stateblock
->wineD3DDevice
, stateblock
->material
.Emissive
.r
, stateblock
->material
.Emissive
.g
,
727 stateblock
->material
.Emissive
.b
, stateblock
->material
.Emissive
.a
);
729 glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float*) &stateblock
->material
.Ambient
);
730 checkGLcall("glMaterialfv(GL_AMBIENT)");
731 glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float*) &stateblock
->material
.Diffuse
);
732 checkGLcall("glMaterialfv(GL_DIFFUSE)");
733 glMaterialfv(GL_FRONT_AND_BACK
, GL_EMISSION
, (float*) &stateblock
->material
.Emissive
);
734 checkGLcall("glMaterialfv(GL_EMISSION)");
737 static void state_texfactor(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
740 /* Note the texture color applies to all textures whereas
741 * GL_TEXTURE_ENV_COLOR applies to active only
744 D3DCOLORTOGLFLOAT4(stateblock
->renderState
[WINED3DRS_TEXTUREFACTOR
], col
);
746 /* And now the default texture color as well */
747 for (i
= 0; i
< GL_LIMITS(texture_stages
); i
++) {
748 /* Note the WINED3DRS value applies to all textures, but GL has one
749 * per texture, so apply it now ready to be used!
751 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB
+ i
));
752 checkGLcall("glActiveTextureARB");
754 glTexEnvfv(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_COLOR
, &col
[0]);
755 checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);");
760 renderstate_stencil_twosided(IWineD3DStateBlockImpl
*stateblock
, GLint face
, GLint func
, GLint ref
, GLuint mask
, GLint stencilFail
, GLint depthFail
, GLint stencilPass
) {
761 glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT
);
762 checkGLcall("glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT)");
763 GL_EXTCALL(glActiveStencilFaceEXT(face
));
764 checkGLcall("glActiveStencilFaceEXT(...)");
765 glStencilFunc(func
, ref
, mask
);
766 checkGLcall("glStencilFunc(...)");
767 glStencilOp(stencilFail
, depthFail
, stencilPass
);
768 checkGLcall("glStencilOp(...)");
772 state_stencil(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
773 DWORD onesided_enable
= FALSE
;
774 DWORD twosided_enable
= FALSE
;
775 GLint func
= GL_ALWAYS
;
776 GLint func_ccw
= GL_ALWAYS
;
779 GLint stencilFail
= GL_KEEP
;
780 GLint depthFail
= GL_KEEP
;
781 GLint stencilPass
= GL_KEEP
;
782 GLint stencilFail_ccw
= GL_KEEP
;
783 GLint depthFail_ccw
= GL_KEEP
;
784 GLint stencilPass_ccw
= GL_KEEP
;
786 /* No stencil test without a stencil buffer */
787 if(stateblock
->wineD3DDevice
->stencilBufferTarget
== NULL
) {
788 glDisable(GL_STENCIL_TEST
);
789 checkGLcall("glDisable GL_STENCIL_TEST");
793 onesided_enable
= stateblock
->renderState
[WINED3DRS_STENCILENABLE
];
794 twosided_enable
= stateblock
->renderState
[WINED3DRS_TWOSIDEDSTENCILMODE
];
795 if( !( func
= CompareFunc(stateblock
->renderState
[WINED3DRS_STENCILFUNC
]) ) )
797 if( !( func_ccw
= CompareFunc(stateblock
->renderState
[WINED3DRS_CCW_STENCILFUNC
]) ) )
798 func_ccw
= GL_ALWAYS
;
799 ref
= stateblock
->renderState
[WINED3DRS_STENCILREF
];
800 mask
= stateblock
->renderState
[WINED3DRS_STENCILMASK
];
801 stencilFail
= StencilOp(stateblock
->renderState
[WINED3DRS_STENCILFAIL
]);
802 depthFail
= StencilOp(stateblock
->renderState
[WINED3DRS_STENCILZFAIL
]);
803 stencilPass
= StencilOp(stateblock
->renderState
[WINED3DRS_STENCILPASS
]);
804 stencilFail_ccw
= StencilOp(stateblock
->renderState
[WINED3DRS_CCW_STENCILFAIL
]);
805 depthFail_ccw
= StencilOp(stateblock
->renderState
[WINED3DRS_CCW_STENCILZFAIL
]);
806 stencilPass_ccw
= StencilOp(stateblock
->renderState
[WINED3DRS_CCW_STENCILPASS
]);
808 TRACE("(onesided %d, twosided %d, ref %x, mask %x, "
809 "GL_FRONT: func: %x, fail %x, zfail %x, zpass %x "
810 "GL_BACK: func: %x, fail %x, zfail %x, zpass %x )\n",
811 onesided_enable
, twosided_enable
, ref
, mask
,
812 func
, stencilFail
, depthFail
, stencilPass
,
813 func_ccw
, stencilFail_ccw
, depthFail_ccw
, stencilPass_ccw
);
815 if (twosided_enable
&& onesided_enable
) {
816 glEnable(GL_STENCIL_TEST
);
817 checkGLcall("glEnable GL_STENCIL_TEST");
819 if(GL_SUPPORT(EXT_STENCIL_TWO_SIDE
)) {
820 /* Apply back first, then front. This function calls glActiveStencilFaceEXT,
821 * which has an effect on the code below too. If we apply the front face
822 * afterwards, we are sure that the active stencil face is set to front,
823 * and other stencil functions which do not use two sided stencil do not have
826 renderstate_stencil_twosided(stateblock
, GL_BACK
, func_ccw
, ref
, mask
,
827 stencilFail_ccw
, depthFail_ccw
, stencilPass_ccw
);
828 renderstate_stencil_twosided(stateblock
, GL_FRONT
, func
, ref
, mask
,
829 stencilFail
, depthFail
, stencilPass
);
830 } else if(GL_SUPPORT(ATI_SEPARATE_STENCIL
)) {
831 GL_EXTCALL(glStencilFuncSeparateATI(func
, func_ccw
, ref
, mask
));
832 checkGLcall("glStencilFuncSeparateATI(...)");
833 GL_EXTCALL(glStencilOpSeparateATI(GL_FRONT
, stencilFail
, depthFail
, stencilPass
));
834 checkGLcall("glStencilOpSeparateATI(GL_FRONT, ...)");
835 GL_EXTCALL(glStencilOpSeparateATI(GL_BACK
, stencilFail_ccw
, depthFail_ccw
, stencilPass_ccw
));
836 checkGLcall("glStencilOpSeparateATI(GL_BACK, ...)");
838 ERR("Separate (two sided) stencil not supported on this version of opengl. Caps weren't honored?\n");
840 } else if(onesided_enable
) {
841 if(GL_SUPPORT(EXT_STENCIL_TWO_SIDE
)) {
842 glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT
);
843 checkGLcall("glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT)");
846 /* This code disables the ATI extension as well, since the standard stencil functions are equal
847 * to calling the ATI functions with GL_FRONT_AND_BACK as face parameter
849 glEnable(GL_STENCIL_TEST
);
850 checkGLcall("glEnable GL_STENCIL_TEST");
851 glStencilFunc(func
, ref
, mask
);
852 checkGLcall("glStencilFunc(...)");
853 glStencilOp(stencilFail
, depthFail
, stencilPass
);
854 checkGLcall("glStencilOp(...)");
856 glDisable(GL_STENCIL_TEST
);
857 checkGLcall("glDisable GL_STENCIL_TEST");
861 static void state_stencilwrite2s(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
864 if(stateblock
->wineD3DDevice
->stencilBufferTarget
) {
865 mask
= stateblock
->renderState
[WINED3DRS_STENCILWRITEMASK
];
870 GL_EXTCALL(glActiveStencilFaceEXT(GL_BACK
));
871 checkGLcall("glActiveStencilFaceEXT(GL_BACK)");
873 checkGLcall("glStencilMask");
874 GL_EXTCALL(glActiveStencilFaceEXT(GL_FRONT
));
875 checkGLcall("glActiveStencilFaceEXT(GL_FRONT)");
879 static void state_stencilwrite(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
882 if(stateblock
->wineD3DDevice
->stencilBufferTarget
) {
883 mask
= stateblock
->renderState
[WINED3DRS_STENCILWRITEMASK
];
889 checkGLcall("glStencilMask");
892 static void state_fog_vertexpart(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
894 TRACE("state %#x, stateblock %p, context %p\n", state
, stateblock
, context
);
896 if (!stateblock
->renderState
[WINED3DRS_FOGENABLE
]) return;
898 /* Table fog on: Never use fog coords, and use per-fragment fog */
899 if(stateblock
->renderState
[WINED3DRS_FOGTABLEMODE
] != WINED3DFOG_NONE
) {
900 glHint(GL_FOG_HINT
, GL_NICEST
);
901 if(context
->fog_coord
) {
902 glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FRAGMENT_DEPTH_EXT
);
903 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT)");
904 context
->fog_coord
= FALSE
;
909 /* Otherwise use per-vertex fog in any case */
910 glHint(GL_FOG_HINT
, GL_FASTEST
);
912 if(stateblock
->renderState
[WINED3DRS_FOGVERTEXMODE
] == WINED3DFOG_NONE
|| context
->last_was_rhw
) {
913 /* No fog at all, or transformed vertices: Use fog coord */
914 if(!context
->fog_coord
) {
915 glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FOG_COORDINATE_EXT
);
916 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT)");
917 context
->fog_coord
= TRUE
;
920 /* Otherwise, use the fragment depth */
921 if(context
->fog_coord
) {
922 glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FRAGMENT_DEPTH_EXT
);
923 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT)");
924 context
->fog_coord
= FALSE
;
929 void state_fogstartend(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
930 float fogstart
, fogend
;
936 switch(context
->fog_source
) {
942 case FOGSOURCE_COORD
:
948 tmpvalue
.d
= stateblock
->renderState
[WINED3DRS_FOGSTART
];
949 fogstart
= tmpvalue
.f
;
950 tmpvalue
.d
= stateblock
->renderState
[WINED3DRS_FOGEND
];
952 /* In GL, fogstart == fogend disables fog, in D3D everything's fogged.*/
953 if(fogstart
== fogend
) {
954 fogstart
= -1.0 / 0.0;
960 /* This should not happen.context->fog_source is set in wined3d, not the app.
961 * Still this is needed to make the compiler happy
963 ERR("Unexpected fog coordinate source\n");
968 glFogf(GL_FOG_START
, fogstart
);
969 checkGLcall("glFogf(GL_FOG_START, fogstart)");
970 TRACE("Fog Start == %f\n", fogstart
);
972 glFogf(GL_FOG_END
, fogend
);
973 checkGLcall("glFogf(GL_FOG_END, fogend)");
974 TRACE("Fog End == %f\n", fogend
);
977 void state_fog_fragpart(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
978 enum fogsource new_source
;
980 TRACE("state %#x, stateblock %p, context %p\n", state
, stateblock
, context
);
982 if (!stateblock
->renderState
[WINED3DRS_FOGENABLE
]) {
983 /* No fog? Disable it, and we're done :-) */
984 glDisableWINE(GL_FOG
);
985 checkGLcall("glDisable GL_FOG");
991 * With fixed function vertex processing, Direct3D knows 2 different fog input sources.
992 * It can use the Z value of the vertex, or the alpha component of the specular color.
993 * This depends on the fog vertex, fog table and the vertex declaration. If the Z value
994 * is used, fogstart, fogend and the equation type are used, otherwise linear fog with
995 * start = 255, end = 0 is used. Obviously the msdn is not very clear on that.
997 * FOGTABLEMODE != NONE:
998 * The Z value is used, with the equation specified, no matter what vertex type.
1000 * FOGTABLEMODE == NONE, FOGVERTEXMODE != NONE, untransformed:
1001 * Per vertex fog is calculated using the specified fog equation and the parameters
1003 * FOGTABLEMODE == NONE, FOGVERTEXMODE != NONE, transformed, OR
1004 * FOGTABLEMODE == NONE, FOGVERTEXMODE == NONE, untransformed:
1005 * Linear fog with start = 255.0, end = 0.0, input comes from the specular color
1008 * Rules for vertex fog with shaders:
1010 * When mixing fixed function functionality with the programmable pipeline, D3D expects
1011 * the fog computation to happen during transformation while openGL expects it to happen
1012 * during rasterization. Also, prior to pixel shader 3.0 D3D handles fog blending after
1013 * the pixel shader while openGL always expects the pixel shader to handle the blending.
1014 * To solve this problem, WineD3D does:
1015 * 1) implement a linear fog equation and fog blending at the end of every pre 3.0 pixel
1017 * and 2) disables the fog computation (in either the fixed function or programmable
1018 * rasterizer) if using a vertex program.
1020 * D3D shaders can provide an explicit fog coordinate. This fog coordinate is used with
1021 * D3DRS_FOGTABLEMODE==D3DFOG_NONE. The FOGVERTEXMODE is ignored, d3d always uses linear
1022 * fog with start=1.0 and end=0.0 in this case. This is similar to fog coordinates in
1023 * the specular color, a vertex shader counts as pretransformed geometry in this case.
1024 * There are some GL differences between specular fog coords and vertex shaders though.
1026 * With table fog the vertex shader fog coordinate is ignored.
1028 * If a fogtablemode and a fogvertexmode are specified, table fog is applied (with or
1032 /* DX 7 sdk: "If both render states(vertex and table fog) are set to valid modes,
1033 * the system will apply only pixel(=table) fog effects."
1035 if(stateblock
->renderState
[WINED3DRS_FOGTABLEMODE
] == WINED3DFOG_NONE
) {
1036 if(use_vs(stateblock
)) {
1037 glFogi(GL_FOG_MODE
, GL_LINEAR
);
1038 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1039 new_source
= FOGSOURCE_VS
;
1041 switch (stateblock
->renderState
[WINED3DRS_FOGVERTEXMODE
]) {
1042 /* If processed vertices are used, fall through to the NONE case */
1043 case WINED3DFOG_EXP
:
1044 if(!context
->last_was_rhw
) {
1045 glFogi(GL_FOG_MODE
, GL_EXP
);
1046 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP)");
1047 new_source
= FOGSOURCE_FFP
;
1052 case WINED3DFOG_EXP2
:
1053 if(!context
->last_was_rhw
) {
1054 glFogi(GL_FOG_MODE
, GL_EXP2
);
1055 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2)");
1056 new_source
= FOGSOURCE_FFP
;
1061 case WINED3DFOG_LINEAR
:
1062 if(!context
->last_was_rhw
) {
1063 glFogi(GL_FOG_MODE
, GL_LINEAR
);
1064 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1065 new_source
= FOGSOURCE_FFP
;
1070 case WINED3DFOG_NONE
:
1071 /* Both are none? According to msdn the alpha channel of the specular
1072 * color contains a fog factor. Set it in drawStridedSlow.
1073 * Same happens with Vertexfog on transformed vertices
1075 new_source
= FOGSOURCE_COORD
;
1076 glFogi(GL_FOG_MODE
, GL_LINEAR
);
1077 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1081 FIXME("Unexpected WINED3DRS_FOGVERTEXMODE %d\n", stateblock
->renderState
[WINED3DRS_FOGVERTEXMODE
]);
1082 new_source
= FOGSOURCE_FFP
; /* Make the compiler happy */
1086 new_source
= FOGSOURCE_FFP
;
1088 switch (stateblock
->renderState
[WINED3DRS_FOGTABLEMODE
]) {
1089 case WINED3DFOG_EXP
:
1090 glFogi(GL_FOG_MODE
, GL_EXP
);
1091 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP)");
1094 case WINED3DFOG_EXP2
:
1095 glFogi(GL_FOG_MODE
, GL_EXP2
);
1096 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2)");
1099 case WINED3DFOG_LINEAR
:
1100 glFogi(GL_FOG_MODE
, GL_LINEAR
);
1101 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1104 case WINED3DFOG_NONE
: /* Won't happen */
1106 FIXME("Unexpected WINED3DRS_FOGTABLEMODE %d\n", stateblock
->renderState
[WINED3DRS_FOGTABLEMODE
]);
1110 glEnableWINE(GL_FOG
);
1111 checkGLcall("glEnable GL_FOG");
1112 if(new_source
!= context
->fog_source
) {
1113 context
->fog_source
= new_source
;
1114 state_fogstartend(STATE_RENDER(WINED3DRS_FOGSTART
), stateblock
, context
);
1118 static void state_rangefog_w(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1119 if(stateblock
->renderState
[WINED3DRS_RANGEFOGENABLE
]) {
1120 WARN("Range fog enabled, but not supported by this opengl implementation\n");
1124 static void state_rangefog(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1125 if(stateblock
->renderState
[WINED3DRS_RANGEFOGENABLE
]) {
1126 glFogi(GL_FOG_DISTANCE_MODE_NV
, GL_EYE_RADIAL_NV
);
1127 checkGLcall("glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_RADIAL_NV)");
1129 glFogi(GL_FOG_DISTANCE_MODE_NV
, GL_EYE_PLANE_ABSOLUTE_NV
);
1130 checkGLcall("glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_PLANE_ABSOLUTE_NV)");
1134 void state_fogcolor(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1136 D3DCOLORTOGLFLOAT4(stateblock
->renderState
[WINED3DRS_FOGCOLOR
], col
);
1137 glFogfv(GL_FOG_COLOR
, &col
[0]);
1138 checkGLcall("glFog GL_FOG_COLOR");
1141 void state_fogdensity(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1146 tmpvalue
.d
= stateblock
->renderState
[WINED3DRS_FOGDENSITY
];
1147 glFogfv(GL_FOG_DENSITY
, &tmpvalue
.f
);
1148 checkGLcall("glFogf(GL_FOG_DENSITY, (float) Value)");
1151 static void state_colormat(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1152 IWineD3DDeviceImpl
*device
= stateblock
->wineD3DDevice
;
1154 const struct wined3d_stream_info_element
*diffuse
= &device
->strided_streams
.elements
[WINED3D_FFP_DIFFUSE
];
1155 BOOL isDiffuseSupplied
;
1157 /* Depends on the decoded vertex declaration to read the existence of diffuse data.
1158 * The vertex declaration will call this function if the fixed function pipeline is used.
1161 if(isStateDirty(context
, STATE_VDECL
)) {
1165 isDiffuseSupplied
= diffuse
->data
|| diffuse
->buffer_object
;
1167 context
->num_untracked_materials
= 0;
1168 if (isDiffuseSupplied
&& stateblock
->renderState
[WINED3DRS_COLORVERTEX
]) {
1169 TRACE("diff %d, amb %d, emis %d, spec %d\n",
1170 stateblock
->renderState
[WINED3DRS_DIFFUSEMATERIALSOURCE
],
1171 stateblock
->renderState
[WINED3DRS_AMBIENTMATERIALSOURCE
],
1172 stateblock
->renderState
[WINED3DRS_EMISSIVEMATERIALSOURCE
],
1173 stateblock
->renderState
[WINED3DRS_SPECULARMATERIALSOURCE
]);
1175 if (stateblock
->renderState
[WINED3DRS_DIFFUSEMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1176 if (stateblock
->renderState
[WINED3DRS_AMBIENTMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1177 Parm
= GL_AMBIENT_AND_DIFFUSE
;
1181 if(stateblock
->renderState
[WINED3DRS_EMISSIVEMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1182 context
->untracked_materials
[context
->num_untracked_materials
] = GL_EMISSION
;
1183 context
->num_untracked_materials
++;
1185 if(stateblock
->renderState
[WINED3DRS_SPECULARMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1186 context
->untracked_materials
[context
->num_untracked_materials
] = GL_SPECULAR
;
1187 context
->num_untracked_materials
++;
1189 } else if (stateblock
->renderState
[WINED3DRS_AMBIENTMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1191 if(stateblock
->renderState
[WINED3DRS_EMISSIVEMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1192 context
->untracked_materials
[context
->num_untracked_materials
] = GL_EMISSION
;
1193 context
->num_untracked_materials
++;
1195 if(stateblock
->renderState
[WINED3DRS_SPECULARMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1196 context
->untracked_materials
[context
->num_untracked_materials
] = GL_SPECULAR
;
1197 context
->num_untracked_materials
++;
1199 } else if (stateblock
->renderState
[WINED3DRS_EMISSIVEMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1201 if(stateblock
->renderState
[WINED3DRS_SPECULARMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1202 context
->untracked_materials
[context
->num_untracked_materials
] = GL_SPECULAR
;
1203 context
->num_untracked_materials
++;
1205 } else if (stateblock
->renderState
[WINED3DRS_SPECULARMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1210 /* Nothing changed, return. */
1211 if (Parm
== context
->tracking_parm
) return;
1214 glDisable(GL_COLOR_MATERIAL
);
1215 checkGLcall("glDisable GL_COLOR_MATERIAL");
1217 glColorMaterial(GL_FRONT_AND_BACK
, Parm
);
1218 checkGLcall("glColorMaterial(GL_FRONT_AND_BACK, Parm)");
1219 glEnable(GL_COLOR_MATERIAL
);
1220 checkGLcall("glEnable(GL_COLOR_MATERIAL)");
1223 /* Apparently calls to glMaterialfv are ignored for properties we're
1224 * tracking with glColorMaterial, so apply those here. */
1225 switch (context
->tracking_parm
) {
1226 case GL_AMBIENT_AND_DIFFUSE
:
1227 glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float*)&device
->updateStateBlock
->material
.Ambient
);
1228 glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float*)&device
->updateStateBlock
->material
.Diffuse
);
1229 checkGLcall("glMaterialfv");
1233 glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float*)&device
->updateStateBlock
->material
.Diffuse
);
1234 checkGLcall("glMaterialfv");
1238 glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float*)&device
->updateStateBlock
->material
.Ambient
);
1239 checkGLcall("glMaterialfv");
1243 glMaterialfv(GL_FRONT_AND_BACK
, GL_EMISSION
, (float*)&device
->updateStateBlock
->material
.Emissive
);
1244 checkGLcall("glMaterialfv");
1248 /* Only change material color if specular is enabled, otherwise it is set to black */
1249 if (device
->stateBlock
->renderState
[WINED3DRS_SPECULARENABLE
]) {
1250 glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, (float*)&device
->updateStateBlock
->material
.Specular
);
1251 checkGLcall("glMaterialfv");
1253 static const GLfloat black
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
1254 glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, &black
[0]);
1255 checkGLcall("glMaterialfv");
1260 context
->tracking_parm
= Parm
;
1263 static void state_linepattern(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1266 WINED3DLINEPATTERN lp
;
1268 tmppattern
.d
= stateblock
->renderState
[WINED3DRS_LINEPATTERN
];
1270 TRACE("Line pattern: repeat %d bits %x\n", tmppattern
.lp
.wRepeatFactor
, tmppattern
.lp
.wLinePattern
);
1272 if (tmppattern
.lp
.wRepeatFactor
) {
1273 glLineStipple(tmppattern
.lp
.wRepeatFactor
, tmppattern
.lp
.wLinePattern
);
1274 checkGLcall("glLineStipple(repeat, linepattern)");
1275 glEnable(GL_LINE_STIPPLE
);
1276 checkGLcall("glEnable(GL_LINE_STIPPLE);");
1278 glDisable(GL_LINE_STIPPLE
);
1279 checkGLcall("glDisable(GL_LINE_STIPPLE);");
1283 static void state_zbias(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1289 if (stateblock
->renderState
[WINED3DRS_ZBIAS
]) {
1290 tmpvalue
.d
= stateblock
->renderState
[WINED3DRS_ZBIAS
];
1291 TRACE("ZBias value %f\n", tmpvalue
.f
);
1292 glPolygonOffset(0, -tmpvalue
.f
);
1293 checkGLcall("glPolygonOffset(0, -Value)");
1294 glEnable(GL_POLYGON_OFFSET_FILL
);
1295 checkGLcall("glEnable(GL_POLYGON_OFFSET_FILL);");
1296 glEnable(GL_POLYGON_OFFSET_LINE
);
1297 checkGLcall("glEnable(GL_POLYGON_OFFSET_LINE);");
1298 glEnable(GL_POLYGON_OFFSET_POINT
);
1299 checkGLcall("glEnable(GL_POLYGON_OFFSET_POINT);");
1301 glDisable(GL_POLYGON_OFFSET_FILL
);
1302 checkGLcall("glDisable(GL_POLYGON_OFFSET_FILL);");
1303 glDisable(GL_POLYGON_OFFSET_LINE
);
1304 checkGLcall("glDisable(GL_POLYGON_OFFSET_LINE);");
1305 glDisable(GL_POLYGON_OFFSET_POINT
);
1306 checkGLcall("glDisable(GL_POLYGON_OFFSET_POINT);");
1311 static void state_normalize(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1312 if(isStateDirty(context
, STATE_VDECL
)) {
1315 /* Without vertex normals, we set the current normal to 0/0/0 to remove the diffuse factor
1316 * from the opengl lighting equation, as d3d does. Normalization of 0/0/0 can lead to a division
1317 * by zero and is not properly defined in opengl, so avoid it
1319 if (stateblock
->renderState
[WINED3DRS_NORMALIZENORMALS
]
1320 && (stateblock
->wineD3DDevice
->strided_streams
.elements
[WINED3D_FFP_NORMAL
].data
1321 || stateblock
->wineD3DDevice
->strided_streams
.elements
[WINED3D_FFP_NORMAL
].buffer_object
))
1323 glEnable(GL_NORMALIZE
);
1324 checkGLcall("glEnable(GL_NORMALIZE);");
1326 glDisable(GL_NORMALIZE
);
1327 checkGLcall("glDisable(GL_NORMALIZE);");
1331 static void state_psizemin_w(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1337 tmpvalue
.d
= stateblock
->renderState
[WINED3DRS_POINTSIZE_MIN
];
1338 if(tmpvalue
.f
!= 1.0) {
1339 FIXME("WINED3DRS_POINTSIZE_MIN not supported on this opengl, value is %f\n", tmpvalue
.f
);
1341 tmpvalue
.d
= stateblock
->renderState
[WINED3DRS_POINTSIZE_MAX
];
1342 if(tmpvalue
.f
!= 64.0) {
1343 FIXME("WINED3DRS_POINTSIZE_MAX not supported on this opengl, value is %f\n", tmpvalue
.f
);
1348 static void state_psizemin_ext(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1354 min
.d
= stateblock
->renderState
[WINED3DRS_POINTSIZE_MIN
];
1355 max
.d
= stateblock
->renderState
[WINED3DRS_POINTSIZE_MAX
];
1357 /* Max point size trumps min point size */
1362 GL_EXTCALL(glPointParameterfEXT
)(GL_POINT_SIZE_MIN_EXT
, min
.f
);
1363 checkGLcall("glPointParameterfEXT(...)");
1364 GL_EXTCALL(glPointParameterfEXT
)(GL_POINT_SIZE_MAX_EXT
, max
.f
);
1365 checkGLcall("glPointParameterfEXT(...)");
1368 static void state_psizemin_arb(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1374 min
.d
= stateblock
->renderState
[WINED3DRS_POINTSIZE_MIN
];
1375 max
.d
= stateblock
->renderState
[WINED3DRS_POINTSIZE_MAX
];
1377 /* Max point size trumps min point size */
1382 GL_EXTCALL(glPointParameterfARB
)(GL_POINT_SIZE_MIN_ARB
, min
.f
);
1383 checkGLcall("glPointParameterfARB(...)");
1384 GL_EXTCALL(glPointParameterfARB
)(GL_POINT_SIZE_MAX_ARB
, max
.f
);
1385 checkGLcall("glPointParameterfARB(...)");
1388 static void state_pscale(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1389 /* TODO: Group this with the viewport */
1391 * POINTSCALEENABLE controls how point size value is treated. If set to
1392 * true, the point size is scaled with respect to height of viewport.
1393 * When set to false point size is in pixels.
1396 /* Default values */
1397 GLfloat att
[3] = {1.0f
, 0.0f
, 0.0f
};
1401 } pointSize
, A
, B
, C
;
1403 pointSize
.d
= stateblock
->renderState
[WINED3DRS_POINTSIZE
];
1404 A
.d
= stateblock
->renderState
[WINED3DRS_POINTSCALE_A
];
1405 B
.d
= stateblock
->renderState
[WINED3DRS_POINTSCALE_B
];
1406 C
.d
= stateblock
->renderState
[WINED3DRS_POINTSCALE_C
];
1408 if(stateblock
->renderState
[WINED3DRS_POINTSCALEENABLE
]) {
1409 GLfloat scaleFactor
;
1410 float h
= stateblock
->viewport
.Height
;
1412 if(pointSize
.f
< GL_LIMITS(pointsizemin
)) {
1414 * Minimum valid point size for OpenGL is driver specific. For Direct3D it is
1415 * 0.0f. This means that OpenGL will clamp really small point sizes to the
1416 * driver minimum. To correct for this we need to multiply by the scale factor when sizes
1417 * are less than 1.0f. scale_factor = 1.0f / point_size.
1419 scaleFactor
= pointSize
.f
/ GL_LIMITS(pointsizemin
);
1420 /* Clamp the point size, don't rely on the driver to do it. MacOS says min point size
1421 * is 1.0, but then accepts points below that and draws too small points
1423 pointSize
.f
= GL_LIMITS(pointsizemin
);
1424 } else if(pointSize
.f
> GL_LIMITS(pointsize
)) {
1425 /* gl already scales the input to glPointSize,
1426 * d3d scales the result after the point size scale.
1427 * If the point size is bigger than the max size, use the
1428 * scaling to scale it bigger, and set the gl point size to max
1430 scaleFactor
= pointSize
.f
/ GL_LIMITS(pointsize
);
1431 TRACE("scale: %f\n", scaleFactor
);
1432 pointSize
.f
= GL_LIMITS(pointsize
);
1436 scaleFactor
= pow(h
* scaleFactor
, 2);
1438 att
[0] = A
.f
/ scaleFactor
;
1439 att
[1] = B
.f
/ scaleFactor
;
1440 att
[2] = C
.f
/ scaleFactor
;
1443 if(GL_SUPPORT(ARB_POINT_PARAMETERS
)) {
1444 GL_EXTCALL(glPointParameterfvARB
)(GL_POINT_DISTANCE_ATTENUATION_ARB
, att
);
1445 checkGLcall("glPointParameterfvARB(GL_DISTANCE_ATTENUATION_ARB, ...)");
1447 else if(GL_SUPPORT(EXT_POINT_PARAMETERS
)) {
1448 GL_EXTCALL(glPointParameterfvEXT
)(GL_DISTANCE_ATTENUATION_EXT
, att
);
1449 checkGLcall("glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, ...)");
1450 } else if(stateblock
->renderState
[WINED3DRS_POINTSCALEENABLE
]) {
1451 WARN("POINT_PARAMETERS not supported in this version of opengl\n");
1454 glPointSize(pointSize
.f
);
1455 checkGLcall("glPointSize(...);");
1458 static void state_colorwrite(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1459 DWORD Value
= stateblock
->renderState
[WINED3DRS_COLORWRITEENABLE
];
1461 TRACE("Color mask: r(%d) g(%d) b(%d) a(%d)\n",
1462 Value
& WINED3DCOLORWRITEENABLE_RED
? 1 : 0,
1463 Value
& WINED3DCOLORWRITEENABLE_GREEN
? 1 : 0,
1464 Value
& WINED3DCOLORWRITEENABLE_BLUE
? 1 : 0,
1465 Value
& WINED3DCOLORWRITEENABLE_ALPHA
? 1 : 0);
1466 glColorMask(Value
& WINED3DCOLORWRITEENABLE_RED
? GL_TRUE
: GL_FALSE
,
1467 Value
& WINED3DCOLORWRITEENABLE_GREEN
? GL_TRUE
: GL_FALSE
,
1468 Value
& WINED3DCOLORWRITEENABLE_BLUE
? GL_TRUE
: GL_FALSE
,
1469 Value
& WINED3DCOLORWRITEENABLE_ALPHA
? GL_TRUE
: GL_FALSE
);
1470 checkGLcall("glColorMask(...)");
1472 /* depends on WINED3DRS_COLORWRITEENABLE. */
1473 if(stateblock
->renderState
[WINED3DRS_COLORWRITEENABLE1
] != 0x0000000F ||
1474 stateblock
->renderState
[WINED3DRS_COLORWRITEENABLE2
] != 0x0000000F ||
1475 stateblock
->renderState
[WINED3DRS_COLORWRITEENABLE3
] != 0x0000000F ) {
1476 ERR("(WINED3DRS_COLORWRITEENABLE1/2/3,%d,%d,%d) not yet implemented. Missing of cap D3DPMISCCAPS_INDEPENDENTWRITEMASKS wasn't honored?\n",
1477 stateblock
->renderState
[WINED3DRS_COLORWRITEENABLE1
],
1478 stateblock
->renderState
[WINED3DRS_COLORWRITEENABLE2
],
1479 stateblock
->renderState
[WINED3DRS_COLORWRITEENABLE3
]);
1483 static void state_localviewer(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1484 if(stateblock
->renderState
[WINED3DRS_LOCALVIEWER
]) {
1485 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER
, 1);
1486 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1)");
1488 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER
, 0);
1489 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 0)");
1493 static void state_lastpixel(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1494 if(stateblock
->renderState
[WINED3DRS_LASTPIXEL
]) {
1495 TRACE("Last Pixel Drawing Enabled\n");
1499 FIXME("Last Pixel Drawing Disabled, not handled yet\n");
1502 TRACE("Last Pixel Drawing Disabled, not handled yet\n");
1507 static void state_pointsprite_w(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1508 BOOL warned
= FALSE
;
1509 /* TODO: NV_POINT_SPRITE */
1510 if (!warned
&& stateblock
->renderState
[WINED3DRS_POINTSPRITEENABLE
]) {
1511 /* A FIXME, not a WARN because point sprites should be software emulated if not supported by HW */
1512 FIXME("Point sprites not supported\n");
1517 static void state_pointsprite(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1518 if (stateblock
->renderState
[WINED3DRS_POINTSPRITEENABLE
]) {
1519 BOOL warned
= FALSE
;
1520 if(GL_LIMITS(point_sprite_units
) < GL_LIMITS(textures
) && !warned
) {
1521 if(use_ps(stateblock
) || stateblock
->lowest_disabled_stage
> GL_LIMITS(point_sprite_units
)) {
1522 FIXME("The app uses point sprite texture coordinates on more units than supported by the driver\n");
1527 glEnable(GL_POINT_SPRITE_ARB
);
1528 checkGLcall("glEnable(GL_POINT_SPRITE_ARB)");
1530 glDisable(GL_POINT_SPRITE_ARB
);
1531 checkGLcall("glDisable(GL_POINT_SPRITE_ARB)");
1535 static void state_wrap(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1537 http://www.cosc.brocku.ca/Offerings/3P98/course/lectures/texture/
1538 http://www.gamedev.net/reference/programming/features/rendererdll3/page2.asp
1539 Discussion on the ways to turn on WRAPing to solve an OpenGL conversion problem.
1540 http://www.flipcode.org/cgi-bin/fcmsg.cgi?thread_show=10248
1542 so far as I can tell, wrapping and texture-coordinate generate go hand in hand,
1545 if(stateblock
->renderState
[WINED3DRS_WRAP0
] ||
1546 stateblock
->renderState
[WINED3DRS_WRAP1
] ||
1547 stateblock
->renderState
[WINED3DRS_WRAP2
] ||
1548 stateblock
->renderState
[WINED3DRS_WRAP3
] ||
1549 stateblock
->renderState
[WINED3DRS_WRAP4
] ||
1550 stateblock
->renderState
[WINED3DRS_WRAP5
] ||
1551 stateblock
->renderState
[WINED3DRS_WRAP6
] ||
1552 stateblock
->renderState
[WINED3DRS_WRAP7
] ||
1553 stateblock
->renderState
[WINED3DRS_WRAP8
] ||
1554 stateblock
->renderState
[WINED3DRS_WRAP9
] ||
1555 stateblock
->renderState
[WINED3DRS_WRAP10
] ||
1556 stateblock
->renderState
[WINED3DRS_WRAP11
] ||
1557 stateblock
->renderState
[WINED3DRS_WRAP12
] ||
1558 stateblock
->renderState
[WINED3DRS_WRAP13
] ||
1559 stateblock
->renderState
[WINED3DRS_WRAP14
] ||
1560 stateblock
->renderState
[WINED3DRS_WRAP15
] ) {
1561 FIXME("(WINED3DRS_WRAP0) Texture wraping not yet supported\n");
1565 static void state_msaa_w(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1566 if(stateblock
->renderState
[WINED3DRS_MULTISAMPLEANTIALIAS
]) {
1567 WARN("Multisample antialiasing not supported by gl\n");
1571 static void state_msaa(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1572 if(stateblock
->renderState
[WINED3DRS_MULTISAMPLEANTIALIAS
]) {
1573 glEnable(GL_MULTISAMPLE_ARB
);
1574 checkGLcall("glEnable(GL_MULTISAMPLE_ARB)");
1576 glDisable(GL_MULTISAMPLE_ARB
);
1577 checkGLcall("glDisable(GL_MULTISAMPLE_ARB)");
1581 static void state_scissor(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1582 if(stateblock
->renderState
[WINED3DRS_SCISSORTESTENABLE
]) {
1583 glEnable(GL_SCISSOR_TEST
);
1584 checkGLcall("glEnable(GL_SCISSOR_TEST)");
1586 glDisable(GL_SCISSOR_TEST
);
1587 checkGLcall("glDisable(GL_SCISSOR_TEST)");
1591 static void state_depthbias(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1597 if(stateblock
->renderState
[WINED3DRS_SLOPESCALEDEPTHBIAS
] ||
1598 stateblock
->renderState
[WINED3DRS_DEPTHBIAS
]) {
1599 tmpvalue
.d
= stateblock
->renderState
[WINED3DRS_SLOPESCALEDEPTHBIAS
];
1600 glEnable(GL_POLYGON_OFFSET_FILL
);
1601 checkGLcall("glEnable(GL_POLYGON_OFFSET_FILL)");
1602 glPolygonOffset(tmpvalue
.f
, *((float*)&stateblock
->renderState
[WINED3DRS_DEPTHBIAS
]));
1603 checkGLcall("glPolygonOffset(...)");
1605 glDisable(GL_POLYGON_OFFSET_FILL
);
1606 checkGLcall("glDisable(GL_POLYGON_OFFSET_FILL)");
1610 static void state_perspective(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1611 if (stateblock
->renderState
[WINED3DRS_TEXTUREPERSPECTIVE
]) {
1612 glHint(GL_PERSPECTIVE_CORRECTION_HINT
, GL_NICEST
);
1613 checkGLcall("glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)");
1615 glHint(GL_PERSPECTIVE_CORRECTION_HINT
, GL_FASTEST
);
1616 checkGLcall("glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST)");
1620 static void state_stippledalpha(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1622 if (stateblock
->renderState
[WINED3DRS_STIPPLEDALPHA
])
1623 FIXME(" Stippled Alpha not supported yet.\n");
1626 static void state_antialias(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1628 if (stateblock
->renderState
[WINED3DRS_ANTIALIAS
])
1629 FIXME(" Antialias not supported yet.\n");
1632 static void state_multisampmask(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1634 if (stateblock
->renderState
[WINED3DRS_MULTISAMPLEMASK
] != 0xFFFFFFFF)
1635 FIXME("(WINED3DRS_MULTISAMPLEMASK,%d) not yet implemented\n", stateblock
->renderState
[WINED3DRS_MULTISAMPLEMASK
]);
1638 static void state_patchedgestyle(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1640 if (stateblock
->renderState
[WINED3DRS_PATCHEDGESTYLE
] != WINED3DPATCHEDGE_DISCRETE
)
1641 FIXME("(WINED3DRS_PATCHEDGESTYLE,%d) not yet implemented\n", stateblock
->renderState
[WINED3DRS_PATCHEDGESTYLE
]);
1644 static void state_patchsegments(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1652 if (stateblock
->renderState
[WINED3DRS_PATCHSEGMENTS
] != tmpvalue
.d
)
1654 static BOOL displayed
= FALSE
;
1656 tmpvalue
.d
= stateblock
->renderState
[WINED3DRS_PATCHSEGMENTS
];
1658 FIXME("(WINED3DRS_PATCHSEGMENTS,%f) not yet implemented\n", tmpvalue
.f
);
1664 static void state_positiondegree(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1666 if (stateblock
->renderState
[WINED3DRS_POSITIONDEGREE
] != WINED3DDEGREE_CUBIC
)
1667 FIXME("(WINED3DRS_POSITIONDEGREE,%d) not yet implemented\n", stateblock
->renderState
[WINED3DRS_POSITIONDEGREE
]);
1670 static void state_normaldegree(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1672 if (stateblock
->renderState
[WINED3DRS_NORMALDEGREE
] != WINED3DDEGREE_LINEAR
)
1673 FIXME("(WINED3DRS_NORMALDEGREE,%d) not yet implemented\n", stateblock
->renderState
[WINED3DRS_NORMALDEGREE
]);
1676 static void state_tessellation(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1678 if(stateblock
->renderState
[WINED3DRS_ENABLEADAPTIVETESSELLATION
])
1679 FIXME("(WINED3DRS_ENABLEADAPTIVETESSELLATION,%d) not yet implemented\n", stateblock
->renderState
[WINED3DRS_ENABLEADAPTIVETESSELLATION
]);
1682 static void state_wrapu(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1683 if(stateblock
->renderState
[WINED3DRS_WRAPU
]) {
1684 FIXME("Render state WINED3DRS_WRAPU not implemented yet\n");
1688 static void state_wrapv(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1689 if(stateblock
->renderState
[WINED3DRS_WRAPV
]) {
1690 FIXME("Render state WINED3DRS_WRAPV not implemented yet\n");
1694 static void state_monoenable(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1695 if(stateblock
->renderState
[WINED3DRS_MONOENABLE
]) {
1696 FIXME("Render state WINED3DRS_MONOENABLE not implemented yet\n");
1700 static void state_rop2(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1701 if(stateblock
->renderState
[WINED3DRS_ROP2
]) {
1702 FIXME("Render state WINED3DRS_ROP2 not implemented yet\n");
1706 static void state_planemask(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1707 if(stateblock
->renderState
[WINED3DRS_PLANEMASK
]) {
1708 FIXME("Render state WINED3DRS_PLANEMASK not implemented yet\n");
1712 static void state_subpixel(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1713 if(stateblock
->renderState
[WINED3DRS_SUBPIXEL
]) {
1714 FIXME("Render state WINED3DRS_SUBPIXEL not implemented yet\n");
1718 static void state_subpixelx(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1719 if(stateblock
->renderState
[WINED3DRS_SUBPIXELX
]) {
1720 FIXME("Render state WINED3DRS_SUBPIXELX not implemented yet\n");
1724 static void state_stippleenable(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1725 if(stateblock
->renderState
[WINED3DRS_STIPPLEENABLE
]) {
1726 FIXME("Render state WINED3DRS_STIPPLEENABLE not implemented yet\n");
1730 static void state_bordercolor(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1731 if(stateblock
->renderState
[WINED3DRS_BORDERCOLOR
]) {
1732 FIXME("Render state WINED3DRS_BORDERCOLOR not implemented yet\n");
1736 static void state_mipmaplodbias(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1737 if(stateblock
->renderState
[WINED3DRS_MIPMAPLODBIAS
]) {
1738 FIXME("Render state WINED3DRS_MIPMAPLODBIAS not implemented yet\n");
1742 static void state_anisotropy(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1743 if(stateblock
->renderState
[WINED3DRS_ANISOTROPY
]) {
1744 FIXME("Render state WINED3DRS_ANISOTROPY not implemented yet\n");
1748 static void state_flushbatch(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1749 if(stateblock
->renderState
[WINED3DRS_FLUSHBATCH
]) {
1750 FIXME("Render state WINED3DRS_FLUSHBATCH not implemented yet\n");
1754 static void state_translucentsi(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1755 if(stateblock
->renderState
[WINED3DRS_TRANSLUCENTSORTINDEPENDENT
]) {
1756 FIXME("Render state WINED3DRS_TRANSLUCENTSORTINDEPENDENT not implemented yet\n");
1760 static void state_extents(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1761 if(stateblock
->renderState
[WINED3DRS_EXTENTS
]) {
1762 FIXME("Render state WINED3DRS_EXTENTS not implemented yet\n");
1766 static void state_ckeyblend(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
1767 if(stateblock
->renderState
[WINED3DRS_COLORKEYBLENDENABLE
]) {
1768 FIXME("Render state WINED3DRS_COLORKEYBLENDENABLE not implemented yet\n");
1772 /* Set texture operations up - The following avoids lots of ifdefs in this routine!*/
1773 #if defined (GL_VERSION_1_3)
1774 # define useext(A) A
1775 #elif defined (GL_EXT_texture_env_combine)
1776 # define useext(A) A##_EXT
1777 #elif defined (GL_ARB_texture_env_combine)
1778 # define useext(A) A##_ARB
1781 static void get_src_and_opr(DWORD arg
, BOOL is_alpha
, GLenum
* source
, GLenum
* operand
) {
1782 /* The WINED3DTA_ALPHAREPLICATE flag specifies the alpha component of the
1783 * input should be used for all input components. The WINED3DTA_COMPLEMENT
1784 * flag specifies the complement of the input should be used. */
1785 BOOL from_alpha
= is_alpha
|| arg
& WINED3DTA_ALPHAREPLICATE
;
1786 BOOL complement
= arg
& WINED3DTA_COMPLEMENT
;
1788 /* Calculate the operand */
1790 if (from_alpha
) *operand
= GL_ONE_MINUS_SRC_ALPHA
;
1791 else *operand
= GL_ONE_MINUS_SRC_COLOR
;
1793 if (from_alpha
) *operand
= GL_SRC_ALPHA
;
1794 else *operand
= GL_SRC_COLOR
;
1797 /* Calculate the source */
1798 switch (arg
& WINED3DTA_SELECTMASK
) {
1799 case WINED3DTA_CURRENT
: *source
= GL_PREVIOUS_EXT
; break;
1800 case WINED3DTA_DIFFUSE
: *source
= GL_PRIMARY_COLOR_EXT
; break;
1801 case WINED3DTA_TEXTURE
: *source
= GL_TEXTURE
; break;
1802 case WINED3DTA_TFACTOR
: *source
= GL_CONSTANT_EXT
; break;
1803 case WINED3DTA_SPECULAR
:
1805 * According to the GL_ARB_texture_env_combine specs, SPECULAR is
1806 * 'Secondary color' and isn't supported until base GL supports it
1807 * There is no concept of temp registers as far as I can tell
1809 FIXME("Unhandled texture arg WINED3DTA_SPECULAR\n");
1810 *source
= GL_TEXTURE
;
1813 FIXME("Unrecognized texture arg %#x\n", arg
);
1814 *source
= GL_TEXTURE
;
1819 /* Setup the texture operations texture stage states */
1820 static void set_tex_op(IWineD3DDevice
*iface
, BOOL isAlpha
, int Stage
, WINED3DTEXTUREOP op
, DWORD arg1
, DWORD arg2
, DWORD arg3
)
1822 GLenum src1
, src2
, src3
;
1823 GLenum opr1
, opr2
, opr3
;
1825 GLenum src0_target
, src1_target
, src2_target
;
1826 GLenum opr0_target
, opr1_target
, opr2_target
;
1828 GLenum opr
=0, invopr
, src3_target
, opr3_target
;
1829 BOOL Handled
= FALSE
;
1830 IWineD3DDeviceImpl
*This
= (IWineD3DDeviceImpl
*)iface
;
1831 IWineD3DStateBlockImpl
*stateblock
= This
->stateBlock
; /* for GLINFO_LOCATION */
1833 TRACE("Alpha?(%d), Stage:%d Op(%s), a1(%d), a2(%d), a3(%d)\n", isAlpha
, Stage
, debug_d3dtop(op
), arg1
, arg2
, arg3
);
1835 /* This is called by a state handler which has the gl lock held and a context for the thread */
1837 /* Note: Operations usually involve two ars, src0 and src1 and are operations of
1838 the form (a1 <operation> a2). However, some of the more complex operations
1839 take 3 parameters. Instead of the (sensible) addition of a3, Microsoft added
1840 in a third parameter called a0. Therefore these are operations of the form
1841 a0 <operation> a1 <operation> a2, i.e., the new parameter goes to the front.
1843 However, below we treat the new (a0) parameter as src2/opr2, so in the actual
1844 functions below, expect their syntax to differ slightly to those listed in the
1845 manuals, i.e., replace arg1 with arg3, arg2 with arg1 and arg3 with arg2
1846 This affects WINED3DTOP_MULTIPLYADD and WINED3DTOP_LERP */
1849 comb_target
= useext(GL_COMBINE_ALPHA
);
1850 src0_target
= useext(GL_SOURCE0_ALPHA
);
1851 src1_target
= useext(GL_SOURCE1_ALPHA
);
1852 src2_target
= useext(GL_SOURCE2_ALPHA
);
1853 opr0_target
= useext(GL_OPERAND0_ALPHA
);
1854 opr1_target
= useext(GL_OPERAND1_ALPHA
);
1855 opr2_target
= useext(GL_OPERAND2_ALPHA
);
1856 scal_target
= GL_ALPHA_SCALE
;
1859 comb_target
= useext(GL_COMBINE_RGB
);
1860 src0_target
= useext(GL_SOURCE0_RGB
);
1861 src1_target
= useext(GL_SOURCE1_RGB
);
1862 src2_target
= useext(GL_SOURCE2_RGB
);
1863 opr0_target
= useext(GL_OPERAND0_RGB
);
1864 opr1_target
= useext(GL_OPERAND1_RGB
);
1865 opr2_target
= useext(GL_OPERAND2_RGB
);
1866 scal_target
= useext(GL_RGB_SCALE
);
1869 /* If a texture stage references an invalid texture unit the stage just
1870 * passes through the result from the previous stage */
1871 if (is_invalid_op(This
, Stage
, op
, arg1
, arg2
, arg3
)) {
1872 arg1
= WINED3DTA_CURRENT
;
1873 op
= WINED3DTOP_SELECTARG1
;
1876 if (isAlpha
&& This
->stateBlock
->textures
[Stage
] == NULL
&& arg1
== WINED3DTA_TEXTURE
) {
1877 get_src_and_opr(WINED3DTA_DIFFUSE
, isAlpha
, &src1
, &opr1
);
1879 get_src_and_opr(arg1
, isAlpha
, &src1
, &opr1
);
1881 get_src_and_opr(arg2
, isAlpha
, &src2
, &opr2
);
1882 get_src_and_opr(arg3
, isAlpha
, &src3
, &opr3
);
1884 TRACE("ct(%x), 1:(%x,%x), 2:(%x,%x), 3:(%x,%x)\n", comb_target
, src1
, opr1
, src2
, opr2
, src3
, opr3
);
1886 Handled
= TRUE
; /* Assume will be handled */
1888 /* Other texture operations require special extensions: */
1889 if (GL_SUPPORT(NV_TEXTURE_ENV_COMBINE4
)) {
1892 invopr
= GL_ONE_MINUS_SRC_ALPHA
;
1893 src3_target
= GL_SOURCE3_ALPHA_NV
;
1894 opr3_target
= GL_OPERAND3_ALPHA_NV
;
1897 invopr
= GL_ONE_MINUS_SRC_COLOR
;
1898 src3_target
= GL_SOURCE3_RGB_NV
;
1899 opr3_target
= GL_OPERAND3_RGB_NV
;
1902 case WINED3DTOP_DISABLE
: /* Only for alpha */
1903 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
1904 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
1905 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_PREVIOUS_EXT
);
1906 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
1907 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_SRC_ALPHA
);
1908 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
1909 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
1910 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
1911 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
1912 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
1913 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
1914 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_ZERO");
1915 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
1916 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
1917 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
1918 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
1919 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
1920 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
1922 case WINED3DTOP_SELECTARG1
: /* = a1 * 1 + 0 * 0 */
1923 case WINED3DTOP_SELECTARG2
: /* = a2 * 1 + 0 * 0 */
1924 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
1925 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
1926 if (op
== WINED3DTOP_SELECTARG1
) {
1927 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
1928 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
1929 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
1930 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
1932 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src2
);
1933 checkGLcall("GL_TEXTURE_ENV, src0_target, src2");
1934 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr2
);
1935 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr2");
1937 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
1938 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
1939 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
1940 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
1941 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
1942 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_ZERO");
1943 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
1944 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
1945 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
1946 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
1947 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
1948 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
1951 case WINED3DTOP_MODULATE
:
1952 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
1953 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
1954 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
1955 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
1956 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
1957 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
1958 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
1959 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
1960 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
1961 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
1962 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
1963 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
1964 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
1965 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
1966 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
1967 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
1968 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
1969 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
1970 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
1971 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
1973 case WINED3DTOP_MODULATE2X
:
1974 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
1975 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
1976 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
1977 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
1978 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
1979 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
1980 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
1981 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
1982 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
1983 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
1984 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
1985 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
1986 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
1987 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
1988 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
1989 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
1990 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
1991 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
1992 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
1993 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
1995 case WINED3DTOP_MODULATE4X
:
1996 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
1997 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
1998 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
1999 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2000 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2001 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2002 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2003 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2004 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2005 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2006 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2007 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2008 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2009 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2010 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2011 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2012 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2013 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2014 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 4);
2015 checkGLcall("GL_TEXTURE_ENV, scal_target, 4");
2018 case WINED3DTOP_ADD
:
2019 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2020 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2021 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2022 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2023 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2024 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2025 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2026 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2027 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2028 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2029 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2030 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2031 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2032 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2033 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2034 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2035 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2036 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2037 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2038 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2041 case WINED3DTOP_ADDSIGNED
:
2042 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_ADD_SIGNED
));
2043 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_ADD_SIGNED)");
2044 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2045 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2046 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2047 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2048 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2049 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2050 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2051 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2052 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2053 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2054 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2055 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2056 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2057 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2058 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2059 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2060 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2061 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2064 case WINED3DTOP_ADDSIGNED2X
:
2065 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_ADD_SIGNED
));
2066 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_ADD_SIGNED)");
2067 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2068 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2069 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2070 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2071 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2072 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2073 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2074 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2075 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2076 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2077 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2078 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2079 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2080 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2081 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2082 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2083 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2084 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2087 case WINED3DTOP_ADDSMOOTH
:
2088 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2089 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2090 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2091 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2092 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2093 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2094 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2095 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2096 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2097 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2098 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2099 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2100 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2101 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2102 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
2103 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2105 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2106 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2107 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2108 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2110 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2111 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2112 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2113 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2116 case WINED3DTOP_BLENDDIFFUSEALPHA
:
2117 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2118 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2119 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2120 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2121 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2122 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2123 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, useext(GL_PRIMARY_COLOR
));
2124 checkGLcall("GL_TEXTURE_ENV, src1_target, useext(GL_PRIMARY_COLOR)");
2125 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2126 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2127 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2128 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2129 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2130 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2131 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, useext(GL_PRIMARY_COLOR
));
2132 checkGLcall("GL_TEXTURE_ENV, src3_target, useext(GL_PRIMARY_COLOR)");
2133 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2134 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2135 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2136 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2138 case WINED3DTOP_BLENDTEXTUREALPHA
:
2139 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2140 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2141 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2142 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2143 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2144 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2145 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_TEXTURE
);
2146 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_TEXTURE");
2147 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2148 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2149 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2150 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2151 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2152 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2153 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_TEXTURE
);
2154 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_TEXTURE");
2155 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2156 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2157 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2158 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2160 case WINED3DTOP_BLENDFACTORALPHA
:
2161 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2162 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2163 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2164 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2165 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2166 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2167 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, useext(GL_CONSTANT
));
2168 checkGLcall("GL_TEXTURE_ENV, src1_target, useext(GL_CONSTANT)");
2169 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2170 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2171 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2172 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2173 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2174 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2175 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, useext(GL_CONSTANT
));
2176 checkGLcall("GL_TEXTURE_ENV, src3_target, useext(GL_CONSTANT)");
2177 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2178 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2179 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2180 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2182 case WINED3DTOP_BLENDTEXTUREALPHAPM
:
2183 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2184 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2185 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2186 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2187 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2188 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2189 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2190 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2191 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2192 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2193 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2194 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2195 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2196 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2197 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_TEXTURE
);
2198 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_TEXTURE");
2199 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2200 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2201 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2202 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2204 case WINED3DTOP_MODULATEALPHA_ADDCOLOR
:
2205 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2206 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2207 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
); /* a0 = src1/opr1 */
2208 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2209 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2210 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1"); /* a1 = 1 (see docs) */
2211 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2212 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2213 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2214 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2215 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
); /* a2 = arg2 */
2216 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2217 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2218 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2"); /* a3 = src1 alpha */
2219 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
2220 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2222 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2223 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2225 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2226 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2227 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2228 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2230 case WINED3DTOP_MODULATECOLOR_ADDALPHA
:
2231 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2232 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2233 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2234 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2235 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2236 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2237 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2238 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2239 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2240 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2241 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
2242 checkGLcall("GL_TEXTURE_ENV, src2_target, src1");
2244 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2245 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2247 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2248 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2249 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2250 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2251 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2252 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2253 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2254 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2256 case WINED3DTOP_MODULATEINVALPHA_ADDCOLOR
:
2257 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2258 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2259 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2260 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2261 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2262 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2263 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2264 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2265 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2266 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2267 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2268 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2269 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2270 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2271 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
2272 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2274 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2275 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2276 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2277 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2279 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2280 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2281 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2282 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2284 case WINED3DTOP_MODULATEINVCOLOR_ADDALPHA
:
2285 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2286 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2287 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2288 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2290 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2291 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2292 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2293 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2295 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2296 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2297 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2298 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2299 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2300 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2301 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
2302 checkGLcall("GL_TEXTURE_ENV, src2_target, src1");
2304 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2305 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2307 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2308 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2309 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2310 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2311 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2312 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2313 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2314 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2316 case WINED3DTOP_MULTIPLYADD
:
2317 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2318 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2319 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src3
);
2320 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2321 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr3
);
2322 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2323 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2324 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2325 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2326 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2327 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
2328 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2329 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr1
);
2330 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2331 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src2
);
2332 checkGLcall("GL_TEXTURE_ENV, src3_target, src3");
2333 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr2
);
2334 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr3");
2335 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2336 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2339 case WINED3DTOP_BUMPENVMAP
:
2343 case WINED3DTOP_BUMPENVMAPLUMINANCE
:
2344 FIXME("Implement bump environment mapping in GL_NV_texture_env_combine4 path\n");
2350 glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_COMBINE4_NV
);
2351 checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV");
2355 } /* GL_NV_texture_env_combine4 */
2357 Handled
= TRUE
; /* Again, assume handled */
2359 case WINED3DTOP_DISABLE
: /* Only for alpha */
2360 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
2361 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2362 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_PREVIOUS_EXT
);
2363 checkGLcall("GL_TEXTURE_ENV, src0_target, GL_PREVIOUS_EXT");
2364 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_SRC_ALPHA
);
2365 checkGLcall("GL_TEXTURE_ENV, opr0_target, GL_SRC_ALPHA");
2366 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2367 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2369 case WINED3DTOP_SELECTARG1
:
2370 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
2371 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2372 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2373 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2374 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2375 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2376 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2377 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2379 case WINED3DTOP_SELECTARG2
:
2380 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
2381 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2382 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src2
);
2383 checkGLcall("GL_TEXTURE_ENV, src0_target, src2");
2384 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr2
);
2385 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr2");
2386 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2387 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2389 case WINED3DTOP_MODULATE
:
2390 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
2391 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2392 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2393 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2394 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2395 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2396 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2397 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2398 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2399 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2400 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2401 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2403 case WINED3DTOP_MODULATE2X
:
2404 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
2405 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2406 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2407 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2408 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2409 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2410 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2411 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2412 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2413 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2414 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2415 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2417 case WINED3DTOP_MODULATE4X
:
2418 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
2419 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2420 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2421 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2422 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2423 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2424 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2425 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2426 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2427 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2428 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 4);
2429 checkGLcall("GL_TEXTURE_ENV, scal_target, 4");
2431 case WINED3DTOP_ADD
:
2432 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2433 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2434 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2435 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2436 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2437 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2438 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2439 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2440 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2441 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2442 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2443 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2445 case WINED3DTOP_ADDSIGNED
:
2446 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_ADD_SIGNED
));
2447 checkGLcall("GL_TEXTURE_ENV, comb_target, useext((GL_ADD_SIGNED)");
2448 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2449 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2450 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2451 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2452 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2453 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2454 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2455 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2456 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2457 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2459 case WINED3DTOP_ADDSIGNED2X
:
2460 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_ADD_SIGNED
));
2461 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_ADD_SIGNED)");
2462 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2463 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2464 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2465 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2466 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2467 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2468 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2469 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2470 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2471 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2473 case WINED3DTOP_SUBTRACT
:
2474 if (GL_SUPPORT(ARB_TEXTURE_ENV_COMBINE
)) {
2475 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_SUBTRACT
);
2476 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_SUBTRACT)");
2477 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2478 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2479 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2480 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2481 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2482 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2483 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2484 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2485 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2486 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2488 FIXME("This version of opengl does not support GL_SUBTRACT\n");
2492 case WINED3DTOP_BLENDDIFFUSEALPHA
:
2493 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_INTERPOLATE
));
2494 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_INTERPOLATE)");
2495 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2496 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2497 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2498 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2499 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2500 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2501 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2502 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2503 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, useext(GL_PRIMARY_COLOR
));
2504 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_PRIMARY_COLOR");
2505 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2506 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2507 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2508 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2510 case WINED3DTOP_BLENDTEXTUREALPHA
:
2511 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_INTERPOLATE
));
2512 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_INTERPOLATE)");
2513 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2514 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2515 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2516 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2517 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2518 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2519 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2520 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2521 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_TEXTURE
);
2522 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_TEXTURE");
2523 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2524 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2525 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2526 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2528 case WINED3DTOP_BLENDFACTORALPHA
:
2529 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_INTERPOLATE
));
2530 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_INTERPOLATE)");
2531 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2532 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2533 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2534 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2535 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2536 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2537 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2538 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2539 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, useext(GL_CONSTANT
));
2540 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_CONSTANT");
2541 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2542 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2543 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2544 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2546 case WINED3DTOP_BLENDCURRENTALPHA
:
2547 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_INTERPOLATE
));
2548 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_INTERPOLATE)");
2549 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2550 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2551 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2552 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2553 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2554 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2555 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2556 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2557 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, useext(GL_PREVIOUS
));
2558 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_PREVIOUS");
2559 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2560 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2561 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2562 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2564 case WINED3DTOP_DOTPRODUCT3
:
2565 if (GL_SUPPORT(ARB_TEXTURE_ENV_DOT3
)) {
2566 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_DOT3_RGBA_ARB
);
2567 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_ARB");
2568 } else if (GL_SUPPORT(EXT_TEXTURE_ENV_DOT3
)) {
2569 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_DOT3_RGBA_EXT
);
2570 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_EXT");
2572 FIXME("This version of opengl does not support GL_DOT3\n");
2574 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2575 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2576 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2577 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2578 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2579 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2580 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2581 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2582 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2583 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2585 case WINED3DTOP_LERP
:
2586 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_INTERPOLATE
));
2587 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_INTERPOLATE)");
2588 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2589 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2590 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2591 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2592 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2593 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2594 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2595 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2596 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src3
);
2597 checkGLcall("GL_TEXTURE_ENV, src2_target, src3");
2598 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr3
);
2599 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr3");
2600 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2601 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2603 case WINED3DTOP_ADDSMOOTH
:
2604 if (GL_SUPPORT(ATI_TEXTURE_ENV_COMBINE3
)) {
2605 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2606 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2607 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2608 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2610 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2611 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2612 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2613 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2615 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2616 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2617 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2618 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2619 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2620 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2621 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2622 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2623 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2624 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2625 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2626 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2630 case WINED3DTOP_BLENDTEXTUREALPHAPM
:
2631 if (GL_SUPPORT(ATI_TEXTURE_ENV_COMBINE3
)) {
2632 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2633 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2634 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_TEXTURE
);
2635 checkGLcall("GL_TEXTURE_ENV, src0_target, GL_TEXTURE");
2636 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_ONE_MINUS_SRC_ALPHA
);
2637 checkGLcall("GL_TEXTURE_ENV, opr0_target, GL_ONE_MINUS_SRC_APHA");
2638 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2639 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2640 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2641 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2642 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2643 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2644 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2645 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2646 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2647 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2651 case WINED3DTOP_MODULATEALPHA_ADDCOLOR
:
2652 if (GL_SUPPORT(ATI_TEXTURE_ENV_COMBINE3
)) {
2653 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2654 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2655 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2656 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2658 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2659 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2660 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2661 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2663 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2664 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2665 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2666 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2667 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2668 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2669 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2670 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2671 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2672 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2673 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2674 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2678 case WINED3DTOP_MODULATECOLOR_ADDALPHA
:
2679 if (GL_SUPPORT(ATI_TEXTURE_ENV_COMBINE3
)) {
2680 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2681 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2682 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2683 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2684 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2685 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2686 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2687 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2689 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2690 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2691 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2692 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2694 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr
);
2695 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr");
2696 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2697 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2698 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2699 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2700 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2701 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2705 case WINED3DTOP_MODULATEINVALPHA_ADDCOLOR
:
2706 if (GL_SUPPORT(ATI_TEXTURE_ENV_COMBINE3
)) {
2707 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2708 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2709 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2710 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2712 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2713 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2714 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2715 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2717 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2718 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2719 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2720 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2721 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2722 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2723 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2724 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2725 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2726 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2727 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2728 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2732 case WINED3DTOP_MODULATEINVCOLOR_ADDALPHA
:
2733 if (GL_SUPPORT(ATI_TEXTURE_ENV_COMBINE3
)) {
2734 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2735 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2736 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2737 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2739 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2740 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2741 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2742 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2744 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2745 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2746 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2747 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2749 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2750 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2751 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2752 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2754 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr
);
2755 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr");
2756 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2757 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2758 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2759 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2760 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2761 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2765 case WINED3DTOP_MULTIPLYADD
:
2766 if (GL_SUPPORT(ATI_TEXTURE_ENV_COMBINE3
)) {
2767 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2768 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2769 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2770 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2771 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2772 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2773 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src3
);
2774 checkGLcall("GL_TEXTURE_ENV, src1_target, src3");
2775 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr3
);
2776 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr3");
2777 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2778 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2779 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2780 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2781 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2782 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2786 case WINED3DTOP_BUMPENVMAPLUMINANCE
:
2787 case WINED3DTOP_BUMPENVMAP
:
2788 if(GL_SUPPORT(NV_TEXTURE_SHADER2
)) {
2789 /* Technically texture shader support without register combiners is possible, but not expected to occur
2790 * on real world cards, so for now a fixme should be enough
2792 FIXME("Implement bump mapping with GL_NV_texture_shader in non register combiner path\n");
2799 BOOL combineOK
= TRUE
;
2800 if (GL_SUPPORT(NV_TEXTURE_ENV_COMBINE4
)) {
2804 op2
= This
->stateBlock
->textureState
[Stage
][WINED3DTSS_COLOROP
];
2806 op2
= This
->stateBlock
->textureState
[Stage
][WINED3DTSS_ALPHAOP
];
2809 /* Note: If COMBINE4 in effect can't go back to combine! */
2811 case WINED3DTOP_ADDSMOOTH
:
2812 case WINED3DTOP_BLENDTEXTUREALPHAPM
:
2813 case WINED3DTOP_MODULATEALPHA_ADDCOLOR
:
2814 case WINED3DTOP_MODULATECOLOR_ADDALPHA
:
2815 case WINED3DTOP_MODULATEINVALPHA_ADDCOLOR
:
2816 case WINED3DTOP_MODULATEINVCOLOR_ADDALPHA
:
2817 case WINED3DTOP_MULTIPLYADD
:
2818 /* Ignore those implemented in both cases */
2820 case WINED3DTOP_SELECTARG1
:
2821 case WINED3DTOP_SELECTARG2
:
2826 FIXME("Can't use COMBINE4 and COMBINE together, thisop=%s, otherop=%s, isAlpha(%d)\n", debug_d3dtop(op
), debug_d3dtop(op2
), isAlpha
);
2833 glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, useext(GL_COMBINE
));
2834 checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, useext(GL_COMBINE)");
2840 /* After all the extensions, if still unhandled, report fixme */
2841 FIXME("Unhandled texture operation %s\n", debug_d3dtop(op
));
2845 static void tex_colorop(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
2846 DWORD stage
= (state
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
2847 DWORD mapped_stage
= stateblock
->wineD3DDevice
->texUnitMap
[stage
];
2848 BOOL tex_used
= stateblock
->wineD3DDevice
->fixed_function_usage_map
& (1 << stage
);
2850 TRACE("Setting color op for stage %d\n", stage
);
2852 /* Using a pixel shader? Don't care for anything here, the shader applying does it */
2853 if (use_ps(stateblock
)) return;
2855 if (stage
!= mapped_stage
) WARN("Using non 1:1 mapping: %d -> %d!\n", stage
, mapped_stage
);
2857 if (mapped_stage
!= WINED3D_UNMAPPED_STAGE
)
2859 if (tex_used
&& mapped_stage
>= GL_LIMITS(textures
)) {
2860 FIXME("Attempt to enable unsupported stage!\n");
2863 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
2864 checkGLcall("glActiveTextureARB");
2867 if(stage
>= stateblock
->lowest_disabled_stage
) {
2868 TRACE("Stage disabled\n");
2869 if (mapped_stage
!= WINED3D_UNMAPPED_STAGE
)
2871 /* Disable everything here */
2872 glDisable(GL_TEXTURE_2D
);
2873 checkGLcall("glDisable(GL_TEXTURE_2D)");
2874 glDisable(GL_TEXTURE_3D
);
2875 checkGLcall("glDisable(GL_TEXTURE_3D)");
2876 if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP
)) {
2877 glDisable(GL_TEXTURE_CUBE_MAP_ARB
);
2878 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
2880 if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE
)) {
2881 glDisable(GL_TEXTURE_RECTANGLE_ARB
);
2882 checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)");
2889 /* The sampler will also activate the correct texture dimensions, so no need to do it here
2890 * if the sampler for this stage is dirty
2892 if(!isStateDirty(context
, STATE_SAMPLER(stage
))) {
2893 if (tex_used
) texture_activate_dimensions(stage
, stateblock
, context
);
2896 set_tex_op((IWineD3DDevice
*)stateblock
->wineD3DDevice
, FALSE
, stage
,
2897 stateblock
->textureState
[stage
][WINED3DTSS_COLOROP
],
2898 stateblock
->textureState
[stage
][WINED3DTSS_COLORARG1
],
2899 stateblock
->textureState
[stage
][WINED3DTSS_COLORARG2
],
2900 stateblock
->textureState
[stage
][WINED3DTSS_COLORARG0
]);
2903 void tex_alphaop(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
2904 DWORD stage
= (state
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
2905 DWORD mapped_stage
= stateblock
->wineD3DDevice
->texUnitMap
[stage
];
2906 BOOL tex_used
= stateblock
->wineD3DDevice
->fixed_function_usage_map
& (1 << stage
);
2907 DWORD op
, arg1
, arg2
, arg0
;
2909 TRACE("Setting alpha op for stage %d\n", stage
);
2910 /* Do not care for enabled / disabled stages, just assign the settings. colorop disables / enables required stuff */
2911 if (mapped_stage
!= WINED3D_UNMAPPED_STAGE
)
2913 if (tex_used
&& mapped_stage
>= GL_LIMITS(textures
)) {
2914 FIXME("Attempt to enable unsupported stage!\n");
2917 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
2918 checkGLcall("glActiveTextureARB");
2921 op
= stateblock
->textureState
[stage
][WINED3DTSS_ALPHAOP
];
2922 arg1
= stateblock
->textureState
[stage
][WINED3DTSS_ALPHAARG1
];
2923 arg2
= stateblock
->textureState
[stage
][WINED3DTSS_ALPHAARG2
];
2924 arg0
= stateblock
->textureState
[stage
][WINED3DTSS_ALPHAARG0
];
2926 if (stateblock
->renderState
[WINED3DRS_COLORKEYENABLE
] && stage
== 0 && stateblock
->textures
[0])
2928 UINT texture_dimensions
= IWineD3DBaseTexture_GetTextureDimensions(stateblock
->textures
[0]);
2930 if (texture_dimensions
== GL_TEXTURE_2D
|| texture_dimensions
== GL_TEXTURE_RECTANGLE_ARB
)
2932 IWineD3DSurfaceImpl
*surf
;
2934 surf
= (IWineD3DSurfaceImpl
*) ((IWineD3DTextureImpl
*) stateblock
->textures
[0])->surfaces
[0];
2936 if (surf
->CKeyFlags
& WINEDDSD_CKSRCBLT
&& !surf
->resource
.format_desc
->alpha_mask
)
2938 /* Color keying needs to pass alpha values from the texture through to have the alpha test work
2939 * properly. On the other hand applications can still use texture combiners apparently. This code
2940 * takes care that apps cannot remove the texture's alpha channel entirely.
2942 * The fixup is required for Prince of Persia 3D(prison bars), while Moto racer 2 requires
2943 * D3DTOP_MODULATE to work on color keyed surfaces. Aliens vs Predator 1 uses color keyed textures
2944 * and alpha component of diffuse color to draw things like translucent text and perform other
2947 * Aliens vs Predator 1 relies on diffuse alpha having an effect, so it cannot be ignored. To
2948 * provide the behavior expected by the game, while emulating the colorkey, diffuse alpha must be
2949 * modulated with texture alpha. OTOH, Moto racer 2 at some points sets alphaop/alphaarg to
2950 * SELECTARG/CURRENT, yet puts garbage in diffuse alpha (zeroes). This works on native, because the
2951 * game disables alpha test and alpha blending. Alpha test is overwritten by wine's for purposes of
2952 * color-keying though, so this will lead to missing geometry if texture alpha is modulated (pixels
2953 * fail alpha test). To get around this, ALPHABLENDENABLE state is checked: if the app enables alpha
2954 * blending, it can be expected to provide meaningful values in diffuse alpha, so it should be
2955 * modulated with texture alpha; otherwise, selecting diffuse alpha is ignored in favour of texture
2958 * What to do with multitexturing? So far no app has been found that uses color keying with
2960 if (op
== WINED3DTOP_DISABLE
)
2962 arg1
= WINED3DTA_TEXTURE
;
2963 op
= WINED3DTOP_SELECTARG1
;
2965 else if(op
== WINED3DTOP_SELECTARG1
&& arg1
!= WINED3DTA_TEXTURE
)
2967 if (stateblock
->renderState
[WINED3DRS_ALPHABLENDENABLE
])
2969 arg2
= WINED3DTA_TEXTURE
;
2970 op
= WINED3DTOP_MODULATE
;
2972 else arg1
= WINED3DTA_TEXTURE
;
2974 else if(op
== WINED3DTOP_SELECTARG2
&& arg2
!= WINED3DTA_TEXTURE
)
2976 if (stateblock
->renderState
[WINED3DRS_ALPHABLENDENABLE
])
2978 arg1
= WINED3DTA_TEXTURE
;
2979 op
= WINED3DTOP_MODULATE
;
2981 else arg2
= WINED3DTA_TEXTURE
;
2987 /* tex_alphaop is shared between the ffp and nvrc because the difference only comes down to
2988 * this if block here, and the other code(color keying, texture unit selection) are the same
2990 TRACE("Setting alpha op for stage %d\n", stage
);
2991 if (GL_SUPPORT(NV_REGISTER_COMBINERS
)) {
2992 set_tex_op_nvrc((IWineD3DDevice
*)stateblock
->wineD3DDevice
, TRUE
, stage
,
2993 op
, arg1
, arg2
, arg0
,
2995 stateblock
->textureState
[stage
][WINED3DTSS_RESULTARG
]);
2997 set_tex_op((IWineD3DDevice
*)stateblock
->wineD3DDevice
, TRUE
, stage
,
2998 op
, arg1
, arg2
, arg0
);
3002 static void transform_texture(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
3003 DWORD texUnit
= (state
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3004 DWORD mapped_stage
= stateblock
->wineD3DDevice
->texUnitMap
[texUnit
];
3008 /* Ignore this when a vertex shader is used, or if the streams aren't sorted out yet */
3009 if (use_vs(stateblock
) || isStateDirty(context
, STATE_VDECL
))
3011 TRACE("Using a vertex shader, or stream sources not sorted out yet, skipping\n");
3015 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
) return;
3017 if(mapped_stage
>= GL_LIMITS(textures
)) {
3020 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
3021 checkGLcall("glActiveTextureARB");
3022 generated
= (stateblock
->textureState
[texUnit
][WINED3DTSS_TEXCOORDINDEX
] & 0xFFFF0000) != WINED3DTSS_TCI_PASSTHRU
;
3023 coordIdx
= min(stateblock
->textureState
[texUnit
][WINED3DTSS_TEXCOORDINDEX
& 0x0000FFFF], MAX_TEXTURES
- 1);
3025 set_texture_matrix(&stateblock
->transforms
[WINED3DTS_TEXTURE0
+ texUnit
].u
.m
[0][0],
3026 stateblock
->textureState
[texUnit
][WINED3DTSS_TEXTURETRANSFORMFLAGS
], generated
, context
->last_was_rhw
,
3027 stateblock
->wineD3DDevice
->strided_streams
.elements
[WINED3D_FFP_TEXCOORD0
+ coordIdx
].stride
3028 ? stateblock
->wineD3DDevice
->strided_streams
.elements
[WINED3D_FFP_TEXCOORD0
+ coordIdx
].format_desc
->format
3029 : WINED3DFMT_UNKNOWN
,
3030 stateblock
->wineD3DDevice
->frag_pipe
->ffp_proj_control
);
3032 /* The sampler applying function calls us if this changes */
3033 if ((context
->lastWasPow2Texture
& (1 << texUnit
)) && stateblock
->textures
[texUnit
])
3036 FIXME("Non-power2 texture being used with generated texture coords\n");
3038 /* NP2 texcoord fixup is implemented for pixelshaders (currently only in GLSL backend) so
3039 only enable the fixed-function-pipeline fixup via pow2Matrix when no PS is used. */
3040 if (!use_ps(stateblock
)) {
3041 TRACE("Non power two matrix multiply fixup\n");
3042 glMultMatrixf(((IWineD3DTextureImpl
*) stateblock
->textures
[texUnit
])->baseTexture
.pow2Matrix
);
3047 static void unloadTexCoords(IWineD3DStateBlockImpl
*stateblock
) {
3048 unsigned int texture_idx
;
3050 for (texture_idx
= 0; texture_idx
< GL_LIMITS(texture_stages
); ++texture_idx
) {
3051 GL_EXTCALL(glClientActiveTextureARB(GL_TEXTURE0_ARB
+ texture_idx
));
3052 glDisableClientState(GL_TEXTURE_COORD_ARRAY
);
3056 static void loadTexCoords(IWineD3DStateBlockImpl
*stateblock
, const struct wined3d_stream_info
*si
, GLuint
*curVBO
)
3058 const UINT
*offset
= stateblock
->streamOffset
;
3059 unsigned int mapped_stage
= 0;
3060 unsigned int textureNo
= 0;
3062 for (textureNo
= 0; textureNo
< GL_LIMITS(texture_stages
); ++textureNo
) {
3063 int coordIdx
= stateblock
->textureState
[textureNo
][WINED3DTSS_TEXCOORDINDEX
];
3064 const struct wined3d_stream_info_element
*e
;
3066 mapped_stage
= stateblock
->wineD3DDevice
->texUnitMap
[textureNo
];
3067 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
) continue;
3069 e
= &si
->elements
[WINED3D_FFP_TEXCOORD0
+ coordIdx
];
3070 if (coordIdx
< MAX_TEXTURES
&& (e
->data
|| e
->buffer_object
))
3072 TRACE("Setting up texture %u, idx %d, cordindx %u, data %p\n",
3073 textureNo
, mapped_stage
, coordIdx
, e
->data
);
3075 if (*curVBO
!= e
->buffer_object
)
3077 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, e
->buffer_object
));
3078 checkGLcall("glBindBufferARB");
3079 *curVBO
= e
->buffer_object
;
3082 GL_EXTCALL(glClientActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
3083 checkGLcall("glClientActiveTextureARB");
3085 /* The coords to supply depend completely on the fvf / vertex shader */
3086 glTexCoordPointer(e
->format_desc
->gl_vtx_format
, e
->format_desc
->gl_vtx_type
, e
->stride
,
3087 e
->data
+ stateblock
->loadBaseVertexIndex
* e
->stride
+ offset
[e
->stream_idx
]);
3088 glEnableClientState(GL_TEXTURE_COORD_ARRAY
);
3090 GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB
+ mapped_stage
, 0, 0, 0, 1));
3093 if (GL_SUPPORT(NV_REGISTER_COMBINERS
)) {
3094 /* The number of the mapped stages increases monotonically, so it's fine to use the last used one */
3095 for (textureNo
= mapped_stage
+ 1; textureNo
< GL_LIMITS(textures
); ++textureNo
) {
3096 GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB
+ textureNo
, 0, 0, 0, 1));
3100 checkGLcall("loadTexCoords");
3103 static void tex_coordindex(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
3104 DWORD stage
= (state
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3105 DWORD mapped_stage
= stateblock
->wineD3DDevice
->texUnitMap
[stage
];
3106 static const GLfloat s_plane
[] = { 1.0, 0.0, 0.0, 0.0 };
3107 static const GLfloat t_plane
[] = { 0.0, 1.0, 0.0, 0.0 };
3108 static const GLfloat r_plane
[] = { 0.0, 0.0, 1.0, 0.0 };
3109 static const GLfloat q_plane
[] = { 0.0, 0.0, 0.0, 1.0 };
3111 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
)
3113 TRACE("No texture unit mapped to stage %d. Skipping texture coordinates.\n", stage
);
3117 if(mapped_stage
>= GL_LIMITS(fragment_samplers
)) {
3118 WARN("stage %u not mapped to a valid texture unit (%u)\n", stage
, mapped_stage
);
3121 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
3122 checkGLcall("glActiveTextureARB");
3124 /* Values 0-7 are indexes into the FVF tex coords - See comments in DrawPrimitive
3126 * FIXME: When using generated texture coordinates, the index value is used to specify the wrapping mode.
3127 * eg. SetTextureStageState( 0, WINED3DTSS_TEXCOORDINDEX, WINED3DTSS_TCI_CAMERASPACEPOSITION | 1 );
3128 * means use the vertex position (camera-space) as the input texture coordinates
3129 * for this texture stage, and the wrap mode set in the WINED3DRS_WRAP1 render
3130 * state. We do not (yet) support the WINED3DRENDERSTATE_WRAPx values, nor tie them up
3131 * to the TEXCOORDINDEX value
3133 switch (stateblock
->textureState
[stage
][WINED3DTSS_TEXCOORDINDEX
] & 0xffff0000)
3135 case WINED3DTSS_TCI_PASSTHRU
:
3136 /* Use the specified texture coordinates contained within the
3137 * vertex format. This value resolves to zero. */
3138 glDisable(GL_TEXTURE_GEN_S
);
3139 glDisable(GL_TEXTURE_GEN_T
);
3140 glDisable(GL_TEXTURE_GEN_R
);
3141 glDisable(GL_TEXTURE_GEN_Q
);
3142 checkGLcall("WINED3DTSS_TCI_PASSTHRU - Disable texgen.");
3145 case WINED3DTSS_TCI_CAMERASPACEPOSITION
:
3146 /* CameraSpacePosition means use the vertex position, transformed to camera space,
3147 * as the input texture coordinates for this stage's texture transformation. This
3148 * equates roughly to EYE_LINEAR */
3150 glMatrixMode(GL_MODELVIEW
);
3153 glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
3154 glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
3155 glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
3156 glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
3158 checkGLcall("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set eye plane.");
3160 glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
3161 glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
3162 glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
3163 checkGLcall("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set texgen mode.");
3165 glEnable(GL_TEXTURE_GEN_S
);
3166 glEnable(GL_TEXTURE_GEN_T
);
3167 glEnable(GL_TEXTURE_GEN_R
);
3168 checkGLcall("WINED3DTSS_TCI_CAMERASPACEPOSITION - Enable texgen.");
3172 case WINED3DTSS_TCI_CAMERASPACENORMAL
:
3173 /* Note that NV_TEXGEN_REFLECTION support is implied when
3174 * ARB_TEXTURE_CUBE_MAP is supported */
3175 if (!GL_SUPPORT(NV_TEXGEN_REFLECTION
))
3177 FIXME("WINED3DTSS_TCI_CAMERASPACENORMAL not supported.\n");
3181 glMatrixMode(GL_MODELVIEW
);
3184 glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
3185 glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
3186 glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
3187 glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
3189 checkGLcall("WINED3DTSS_TCI_CAMERASPACENORMAL - Set eye plane.");
3191 glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
3192 glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
3193 glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
3194 checkGLcall("WINED3DTSS_TCI_CAMERASPACENORMAL - Set texgen mode.");
3196 glEnable(GL_TEXTURE_GEN_S
);
3197 glEnable(GL_TEXTURE_GEN_T
);
3198 glEnable(GL_TEXTURE_GEN_R
);
3199 checkGLcall("WINED3DTSS_TCI_CAMERASPACENORMAL - Enable texgen.");
3203 case WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR
:
3204 /* Note that NV_TEXGEN_REFLECTION support is implied when
3205 * ARB_TEXTURE_CUBE_MAP is supported */
3206 if (!GL_SUPPORT(NV_TEXGEN_REFLECTION
))
3208 FIXME("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR not supported.\n");
3212 glMatrixMode(GL_MODELVIEW
);
3215 glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
3216 glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
3217 glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
3218 glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
3220 checkGLcall("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Set eye plane.");
3222 glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
3223 glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
3224 glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
3225 checkGLcall("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Set texgen mode.");
3227 glEnable(GL_TEXTURE_GEN_S
);
3228 glEnable(GL_TEXTURE_GEN_T
);
3229 glEnable(GL_TEXTURE_GEN_R
);
3230 checkGLcall("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Enable texgen.");
3234 case WINED3DTSS_TCI_SPHEREMAP
:
3235 glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_SPHERE_MAP
);
3236 glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_SPHERE_MAP
);
3237 checkGLcall("WINED3DTSS_TCI_SPHEREMAP - Set texgen mode.");
3239 glEnable(GL_TEXTURE_GEN_S
);
3240 glEnable(GL_TEXTURE_GEN_T
);
3241 glDisable(GL_TEXTURE_GEN_R
);
3242 checkGLcall("WINED3DTSS_TCI_SPHEREMAP - Enable texgen.");
3247 FIXME("Unhandled WINED3DTSS_TEXCOORDINDEX %#x\n",
3248 stateblock
->textureState
[stage
][WINED3DTSS_TEXCOORDINDEX
]);
3249 glDisable(GL_TEXTURE_GEN_S
);
3250 glDisable(GL_TEXTURE_GEN_T
);
3251 glDisable(GL_TEXTURE_GEN_R
);
3252 glDisable(GL_TEXTURE_GEN_Q
);
3253 checkGLcall("Disable texgen.");
3258 /* Update the texture matrix */
3259 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_TEXTURE0
+ stage
))) {
3260 transform_texture(STATE_TEXTURESTAGE(stage
, WINED3DTSS_TEXTURETRANSFORMFLAGS
), stateblock
, context
);
3263 if(!isStateDirty(context
, STATE_VDECL
) && context
->namedArraysLoaded
) {
3264 /* Reload the arrays if we are using fixed function arrays to reflect the selected coord input
3265 * source. Call loadTexCoords directly because there is no need to reparse the vertex declaration
3266 * and do all the things linked to it
3267 * TODO: Tidy that up to reload only the arrays of the changed unit
3269 GLuint curVBO
= GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT
) ? ~0U : 0;
3271 unloadTexCoords(stateblock
);
3272 loadTexCoords(stateblock
, &stateblock
->wineD3DDevice
->strided_streams
, &curVBO
);
3276 static void shaderconstant(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
3277 IWineD3DDeviceImpl
*device
= stateblock
->wineD3DDevice
;
3279 /* Vertex and pixel shader states will call a shader upload, don't do anything as long one of them
3280 * has an update pending
3282 if(isStateDirty(context
, STATE_VDECL
) ||
3283 isStateDirty(context
, STATE_PIXELSHADER
)) {
3287 device
->shader_backend
->shader_load_constants((IWineD3DDevice
*)device
, use_ps(stateblock
), use_vs(stateblock
));
3290 static void tex_bumpenvlscale(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
3291 DWORD stage
= (state
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3293 if(stateblock
->pixelShader
&& stage
!= 0 &&
3294 ((IWineD3DPixelShaderImpl
*) stateblock
->pixelShader
)->baseShader
.reg_maps
.luminanceparams
[stage
]) {
3295 /* The pixel shader has to know the luminance scale. Do a constants update if it
3296 * isn't scheduled anyway
3298 if(!isStateDirty(context
, STATE_PIXELSHADERCONSTANT
) &&
3299 !isStateDirty(context
, STATE_PIXELSHADER
)) {
3300 shaderconstant(STATE_PIXELSHADERCONSTANT
, stateblock
, context
);
3305 static void sampler_texmatrix(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
3306 const DWORD sampler
= state
- STATE_SAMPLER(0);
3307 IWineD3DBaseTexture
*texture
= stateblock
->textures
[sampler
];
3309 TRACE("state %#x, stateblock %p, context %p\n", state
, stateblock
, context
);
3311 if(!texture
) return;
3312 /* The fixed function np2 texture emulation uses the texture matrix to fix up the coordinates
3313 * basetexture_apply_state_changes() multiplies the set matrix with a fixup matrix. Before the
3314 * scaling is reapplied or removed, the texture matrix has to be reapplied
3316 * The mapped stage is already active because the sampler() function below, which is part of the
3319 if(sampler
< MAX_TEXTURES
) {
3320 const BOOL texIsPow2
= !((IWineD3DBaseTextureImpl
*)texture
)->baseTexture
.pow2Matrix_identity
;
3322 if (texIsPow2
|| (context
->lastWasPow2Texture
& (1 << sampler
)))
3324 if (texIsPow2
) context
->lastWasPow2Texture
|= 1 << sampler
;
3325 else context
->lastWasPow2Texture
&= ~(1 << sampler
);
3326 transform_texture(STATE_TEXTURESTAGE(stateblock
->wineD3DDevice
->texUnitMap
[sampler
], WINED3DTSS_TEXTURETRANSFORMFLAGS
), stateblock
, context
);
3331 static void sampler(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
3332 DWORD sampler
= state
- STATE_SAMPLER(0);
3333 DWORD mapped_stage
= stateblock
->wineD3DDevice
->texUnitMap
[sampler
];
3339 TRACE("Sampler: %d\n", sampler
);
3340 /* Enabling and disabling texture dimensions is done by texture stage state / pixel shader setup, this function
3341 * only has to bind textures and set the per texture states
3344 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
)
3346 TRACE("No sampler mapped to stage %d. Returning.\n", sampler
);
3350 if (mapped_stage
>= GL_LIMITS(combined_samplers
)) {
3353 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
3354 checkGLcall("glActiveTextureARB");
3356 if(stateblock
->textures
[sampler
]) {
3357 BOOL srgb
= stateblock
->samplerState
[sampler
][WINED3DSAMP_SRGBTEXTURE
];
3358 IWineD3DBaseTextureImpl
*tex_impl
= (IWineD3DBaseTextureImpl
*) stateblock
->textures
[sampler
];
3359 tex_impl
->baseTexture
.internal_preload(stateblock
->textures
[sampler
], srgb
? SRGB_SRGB
: SRGB_RGB
);
3360 IWineD3DBaseTexture_BindTexture(stateblock
->textures
[sampler
], srgb
);
3361 basetexture_apply_state_changes(stateblock
->textures
[sampler
],
3362 stateblock
->textureState
[sampler
], stateblock
->samplerState
[sampler
]);
3364 if (GL_SUPPORT(EXT_TEXTURE_LOD_BIAS
)) {
3365 tmpvalue
.d
= stateblock
->samplerState
[sampler
][WINED3DSAMP_MIPMAPLODBIAS
];
3366 glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT
,
3367 GL_TEXTURE_LOD_BIAS_EXT
,
3369 checkGLcall("glTexEnvi(GL_TEXTURE_LOD_BIAS_EXT, ...)");
3372 if (!use_ps(stateblock
) && sampler
< stateblock
->lowest_disabled_stage
)
3374 if(stateblock
->renderState
[WINED3DRS_COLORKEYENABLE
] && sampler
== 0) {
3375 /* If color keying is enabled update the alpha test, it depends on the existence
3376 * of a color key in stage 0
3378 state_alpha(WINED3DRS_COLORKEYENABLE
, stateblock
, context
);
3382 /* Trigger shader constant reloading (for NP2 texcoord fixup)
3383 * Only do this if pshaders are used (note: fixup is currently only implemented in GLSL). */
3384 if (!tex_impl
->baseTexture
.pow2Matrix_identity
) {
3385 IWineD3DDeviceImpl
* d3ddevice
= stateblock
->wineD3DDevice
;
3386 d3ddevice
->shader_backend
->shader_load_np2fixup_constants(
3387 (IWineD3DDevice
*)d3ddevice
, use_ps(stateblock
), use_vs(stateblock
));
3389 } else if(mapped_stage
< GL_LIMITS(textures
)) {
3390 if(sampler
< stateblock
->lowest_disabled_stage
) {
3391 /* TODO: What should I do with pixel shaders here ??? */
3392 if(stateblock
->renderState
[WINED3DRS_COLORKEYENABLE
] && sampler
== 0) {
3393 /* If color keying is enabled update the alpha test, it depends on the existence
3394 * of a color key in stage 0
3396 state_alpha(WINED3DRS_COLORKEYENABLE
, stateblock
, context
);
3398 } /* Otherwise tex_colorop disables the stage */
3399 glBindTexture(GL_TEXTURE_2D
, stateblock
->wineD3DDevice
->dummyTextureName
[sampler
]);
3400 checkGLcall("glBindTexture(GL_TEXTURE_2D, stateblock->wineD3DDevice->dummyTextureName[sampler])");
3404 void apply_pixelshader(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
3405 IWineD3DDeviceImpl
*device
= stateblock
->wineD3DDevice
;
3406 BOOL use_pshader
= use_ps(stateblock
);
3407 BOOL use_vshader
= use_vs(stateblock
);
3411 if(!context
->last_was_pshader
) {
3412 /* Former draw without a pixel shader, some samplers
3413 * may be disabled because of WINED3DTSS_COLOROP = WINED3DTOP_DISABLE
3414 * make sure to enable them
3416 for(i
=0; i
< MAX_FRAGMENT_SAMPLERS
; i
++) {
3417 if(!isStateDirty(context
, STATE_SAMPLER(i
))) {
3418 sampler(STATE_SAMPLER(i
), stateblock
, context
);
3421 context
->last_was_pshader
= TRUE
;
3423 /* Otherwise all samplers were activated by the code above in earlier draws, or by sampler()
3424 * if a different texture was bound. I don't have to do anything.
3428 /* Disabled the pixel shader - color ops weren't applied
3429 * while it was enabled, so re-apply them.
3431 for(i
=0; i
< MAX_TEXTURES
; i
++) {
3432 if(!isStateDirty(context
, STATE_TEXTURESTAGE(i
, WINED3DTSS_COLOROP
))) {
3433 device
->StateTable
[STATE_TEXTURESTAGE(i
, WINED3DTSS_COLOROP
)].apply
3434 (STATE_TEXTURESTAGE(i
, WINED3DTSS_COLOROP
), stateblock
, context
);
3437 context
->last_was_pshader
= FALSE
;
3440 if(!isStateDirty(context
, device
->StateTable
[STATE_VSHADER
].representative
)) {
3441 device
->shader_backend
->shader_select((IWineD3DDevice
*)stateblock
->wineD3DDevice
, use_pshader
, use_vshader
);
3443 if (!isStateDirty(context
, STATE_VERTEXSHADERCONSTANT
) && (use_vshader
|| use_pshader
)) {
3444 shaderconstant(STATE_VERTEXSHADERCONSTANT
, stateblock
, context
);
3449 static void shader_bumpenvmat(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
3450 DWORD stage
= (state
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3451 if(stateblock
->pixelShader
&& stage
!= 0 &&
3452 ((IWineD3DPixelShaderImpl
*) stateblock
->pixelShader
)->baseShader
.reg_maps
.bumpmat
[stage
]) {
3453 /* The pixel shader has to know the bump env matrix. Do a constants update if it isn't scheduled
3456 if(!isStateDirty(context
, STATE_PIXELSHADERCONSTANT
) &&
3457 !isStateDirty(context
, STATE_PIXELSHADER
)) {
3458 shaderconstant(STATE_PIXELSHADERCONSTANT
, stateblock
, context
);
3463 static void transform_world(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
3464 /* This function is called by transform_view below if the view matrix was changed too
3466 * Deliberately no check if the vertex declaration is dirty because the vdecl state
3467 * does not always update the world matrix, only on a switch between transformed
3468 * and untransformed draws. It *may* happen that the world matrix is set 2 times during one
3469 * draw, but that should be rather rare and cheaper in total.
3471 glMatrixMode(GL_MODELVIEW
);
3472 checkGLcall("glMatrixMode");
3474 if(context
->last_was_rhw
) {
3476 checkGLcall("glLoadIdentity()");
3478 /* In the general case, the view matrix is the identity matrix */
3479 if (stateblock
->wineD3DDevice
->view_ident
) {
3480 glLoadMatrixf(&stateblock
->transforms
[WINED3DTS_WORLDMATRIX(0)].u
.m
[0][0]);
3481 checkGLcall("glLoadMatrixf");
3483 glLoadMatrixf(&stateblock
->transforms
[WINED3DTS_VIEW
].u
.m
[0][0]);
3484 checkGLcall("glLoadMatrixf");
3485 glMultMatrixf(&stateblock
->transforms
[WINED3DTS_WORLDMATRIX(0)].u
.m
[0][0]);
3486 checkGLcall("glMultMatrixf");
3491 static void clipplane(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
3492 UINT index
= state
- STATE_CLIPPLANE(0);
3494 if(isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_VIEW
)) || index
>= GL_LIMITS(clipplanes
)) {
3498 /* Clip Plane settings are affected by the model view in OpenGL, the View transform in direct3d */
3499 if(!use_vs(stateblock
)) {
3500 glMatrixMode(GL_MODELVIEW
);
3502 glLoadMatrixf(&stateblock
->transforms
[WINED3DTS_VIEW
].u
.m
[0][0]);
3504 /* with vertex shaders, clip planes are not transformed in direct3d,
3505 * in OpenGL they are still transformed by the model view.
3506 * Use this to swap the y coordinate if necessary
3508 glMatrixMode(GL_MODELVIEW
);
3511 if(stateblock
->wineD3DDevice
->render_offscreen
) {
3512 glScalef(1.0, -1.0, 1.0);
3516 TRACE("Clipplane [%f,%f,%f,%f]\n",
3517 stateblock
->clipplane
[index
][0],
3518 stateblock
->clipplane
[index
][1],
3519 stateblock
->clipplane
[index
][2],
3520 stateblock
->clipplane
[index
][3]);
3521 glClipPlane(GL_CLIP_PLANE0
+ index
, stateblock
->clipplane
[index
]);
3522 checkGLcall("glClipPlane");
3527 static void transform_worldex(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
3528 UINT matrix
= state
- STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0));
3530 TRACE("Setting world matrix %d\n", matrix
);
3532 if(matrix
>= GL_LIMITS(blends
)) {
3533 WARN("Unsupported blend matrix set\n");
3535 } else if(isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_VIEW
))) {
3539 /* GL_MODELVIEW0_ARB: 0x1700
3540 * GL_MODELVIEW1_ARB: 0x850a
3541 * GL_MODELVIEW2_ARB: 0x8722
3542 * GL_MODELVIEW3_ARB: 0x8723
3544 * GL_MODELVIEW31_ARB: 0x873F
3546 if(matrix
== 1) glMat
= GL_MODELVIEW1_ARB
;
3547 else glMat
= GL_MODELVIEW2_ARB
- 2 + matrix
;
3549 glMatrixMode(glMat
);
3550 checkGLcall("glMatrixMode(glMat)");
3552 /* World matrix 0 is multiplied with the view matrix because d3d uses 3 matrices while gl uses only 2. To avoid
3553 * weighting the view matrix incorrectly it has to be multiplied into every gl modelview matrix
3555 if(stateblock
->wineD3DDevice
->view_ident
) {
3556 glLoadMatrixf(&stateblock
->transforms
[WINED3DTS_WORLDMATRIX(matrix
)].u
.m
[0][0]);
3557 checkGLcall("glLoadMatrixf");
3559 glLoadMatrixf(&stateblock
->transforms
[WINED3DTS_VIEW
].u
.m
[0][0]);
3560 checkGLcall("glLoadMatrixf");
3561 glMultMatrixf(&stateblock
->transforms
[WINED3DTS_WORLDMATRIX(matrix
)].u
.m
[0][0]);
3562 checkGLcall("glMultMatrixf");
3566 static void state_vertexblend_w(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
3567 static BOOL once
= FALSE
;
3569 switch(stateblock
->renderState
[WINED3DRS_VERTEXBLEND
]) {
3570 case WINED3DVBF_1WEIGHTS
:
3571 case WINED3DVBF_2WEIGHTS
:
3572 case WINED3DVBF_3WEIGHTS
:
3575 /* TODO: Implement vertex blending in drawStridedSlow */
3576 FIXME("Vertex blending enabled, but not supported by hardware\n");
3580 case WINED3DVBF_TWEENING
:
3581 WARN("Tweening not supported yet\n");
3585 static void state_vertexblend(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
3586 WINED3DVERTEXBLENDFLAGS val
= stateblock
->renderState
[WINED3DRS_VERTEXBLEND
];
3589 case WINED3DVBF_1WEIGHTS
:
3590 case WINED3DVBF_2WEIGHTS
:
3591 case WINED3DVBF_3WEIGHTS
:
3592 glEnable(GL_VERTEX_BLEND_ARB
);
3593 checkGLcall("glEnable(GL_VERTEX_BLEND_ARB)");
3595 /* D3D adds one more matrix which has weight (1 - sum(weights)). This is enabled at context
3596 * creation with enabling GL_WEIGHT_SUM_UNITY_ARB.
3598 GL_EXTCALL(glVertexBlendARB(stateblock
->renderState
[WINED3DRS_VERTEXBLEND
] + 1));
3600 if(!stateblock
->wineD3DDevice
->vertexBlendUsed
) {
3602 for(i
= 1; i
< GL_LIMITS(blends
); i
++) {
3603 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(i
)))) {
3604 transform_worldex(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(i
)), stateblock
, context
);
3607 stateblock
->wineD3DDevice
->vertexBlendUsed
= TRUE
;
3611 case WINED3DVBF_DISABLE
:
3612 case WINED3DVBF_0WEIGHTS
: /* for Indexed vertex blending - not supported */
3613 glDisable(GL_VERTEX_BLEND_ARB
);
3614 checkGLcall("glDisable(GL_VERTEX_BLEND_ARB)");
3617 case WINED3DVBF_TWEENING
:
3618 /* Just set the vertex weight for weight 0, enable vertex blending and hope the app doesn't have
3619 * vertex weights in the vertices?
3620 * For now we don't report that as supported, so a warn should suffice
3622 WARN("Tweening not supported yet\n");
3627 static void transform_view(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
3630 /* If we are changing the View matrix, reset the light and clipping planes to the new view
3631 * NOTE: We have to reset the positions even if the light/plane is not currently
3632 * enabled, since the call to enable it will not reset the position.
3633 * NOTE2: Apparently texture transforms do NOT need reapplying
3636 const PLIGHTINFOEL
*light
= NULL
;
3638 glMatrixMode(GL_MODELVIEW
);
3639 checkGLcall("glMatrixMode(GL_MODELVIEW)");
3640 glLoadMatrixf(&stateblock
->transforms
[WINED3DTS_VIEW
].u
.m
[0][0]);
3641 checkGLcall("glLoadMatrixf(...)");
3643 /* Reset lights. TODO: Call light apply func */
3644 for(k
= 0; k
< stateblock
->wineD3DDevice
->maxConcurrentLights
; k
++) {
3645 light
= stateblock
->activeLights
[k
];
3646 if(!light
) continue;
3647 glLightfv(GL_LIGHT0
+ light
->glIndex
, GL_POSITION
, light
->lightPosn
);
3648 checkGLcall("glLightfv posn");
3649 glLightfv(GL_LIGHT0
+ light
->glIndex
, GL_SPOT_DIRECTION
, light
->lightDirn
);
3650 checkGLcall("glLightfv dirn");
3653 /* Reset Clipping Planes */
3654 for (k
= 0; k
< GL_LIMITS(clipplanes
); k
++) {
3655 if(!isStateDirty(context
, STATE_CLIPPLANE(k
))) {
3656 clipplane(STATE_CLIPPLANE(k
), stateblock
, context
);
3660 if(context
->last_was_rhw
) {
3662 checkGLcall("glLoadIdentity()");
3663 /* No need to update the world matrix, the identity is fine */
3667 /* Call the world matrix state, this will apply the combined WORLD + VIEW matrix
3668 * No need to do it here if the state is scheduled for update.
3670 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)))) {
3671 transform_world(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), stateblock
, context
);
3674 /* Avoid looping over a number of matrices if the app never used the functionality */
3675 if(stateblock
->wineD3DDevice
->vertexBlendUsed
) {
3676 for(k
= 1; k
< GL_LIMITS(blends
); k
++) {
3677 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(k
)))) {
3678 transform_worldex(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(k
)), stateblock
, context
);
3684 static void transform_projection(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
3685 glMatrixMode(GL_PROJECTION
);
3686 checkGLcall("glMatrixMode(GL_PROJECTION)");
3688 checkGLcall("glLoadIdentity");
3690 if(context
->last_was_rhw
) {
3691 double X
, Y
, height
, width
, minZ
, maxZ
;
3693 X
= stateblock
->viewport
.X
;
3694 Y
= stateblock
->viewport
.Y
;
3695 height
= stateblock
->viewport
.Height
;
3696 width
= stateblock
->viewport
.Width
;
3697 minZ
= stateblock
->viewport
.MinZ
;
3698 maxZ
= stateblock
->viewport
.MaxZ
;
3700 if(!stateblock
->wineD3DDevice
->untransformed
) {
3701 /* Transformed vertices are supposed to bypass the whole transform pipeline including
3702 * frustum clipping. This can't be done in opengl, so this code adjusts the Z range to
3703 * suppress depth clipping. This can be done because it is an orthogonal projection and
3704 * the Z coordinate does not affect the size of the primitives. Half Life 1 and Prince of
3705 * Persia 3D need this.
3707 * Note that using minZ and maxZ here doesn't entirely fix the problem, since view frustum
3708 * clipping is still enabled, but it seems to fix it for all apps tested so far. A minor
3709 * problem can be witnessed in half-life 1 engine based games, the weapon is clipped close
3712 * Also note that this breaks z comparison against z values filled in with clear,
3713 * but no app depending on that and disabled clipping has been found yet. Comparing
3714 * primitives against themselves works, so the Z buffer is still intact for normal hidden
3717 * We could disable clipping entirely by setting the near to infinity and far to -infinity,
3718 * but this would break Z buffer operation. Raising the range to something less than
3719 * infinity would help a bit at the cost of Z precision, but it wouldn't eliminate the
3722 TRACE("Calling glOrtho with %f, %f, %f, %f\n", width
, height
, -minZ
, -maxZ
);
3723 if(stateblock
->wineD3DDevice
->render_offscreen
) {
3724 glOrtho(X
, X
+ width
, -Y
, -Y
- height
, -minZ
, -maxZ
);
3726 glOrtho(X
, X
+ width
, Y
+ height
, Y
, -minZ
, -maxZ
);
3729 /* If the app mixes transformed and untransformed primitives we can't use the coordinate system
3730 * trick above because this would mess up transformed and untransformed Z order. Pass the z position
3731 * unmodified to opengl.
3733 * If the app depends on mixed types and disabled clipping we're out of luck without a pipeline
3734 * replacement shader.
3736 TRACE("Calling glOrtho with %f, %f, %f, %f\n", width
, height
, 1.0, -1.0);
3737 if(stateblock
->wineD3DDevice
->render_offscreen
) {
3738 glOrtho(X
, X
+ width
, -Y
, -Y
- height
, 0.0, -1.0);
3740 glOrtho(X
, X
+ width
, Y
+ height
, Y
, 0.0, -1.0);
3743 checkGLcall("glOrtho");
3745 /* Window Coord 0 is the middle of the first pixel, so translate by 1/2 pixels */
3746 glTranslatef(0.5, 0.5, 0);
3747 checkGLcall("glTranslatef(0.5, 0.5, 0)");
3748 /* D3D texture coordinates are flipped compared to OpenGL ones, so
3749 * render everything upside down when rendering offscreen. */
3750 if (stateblock
->wineD3DDevice
->render_offscreen
) {
3751 glScalef(1.0, -1.0, 1.0);
3752 checkGLcall("glScalef");
3755 /* The rule is that the window coordinate 0 does not correspond to the
3756 beginning of the first pixel, but the center of the first pixel.
3757 As a consequence if you want to correctly draw one line exactly from
3758 the left to the right end of the viewport (with all matrices set to
3759 be identity), the x coords of both ends of the line would be not
3760 -1 and 1 respectively but (-1-1/viewport_widh) and (1-1/viewport_width)
3763 1.0 / Width is used because the coord range goes from -1.0 to 1.0, then we
3764 divide by the Width/Height, so we need the half range(1.0) to translate by
3767 The other fun is that d3d's output z range after the transformation is [0;1],
3768 but opengl's is [-1;1]. Since the z buffer is in range [0;1] for both, gl
3769 scales [-1;1] to [0;1]. This would mean that we end up in [0.5;1] and loose a lot
3770 of Z buffer precision and the clear values do not match in the z test. Thus scale
3771 [0;1] to [-1;1], so when gl undoes that we utilize the full z range
3775 * Careful with the order of operations here, we're essentially working backwards:
3777 * y = (y - 1/h) * flip;
3781 * glTranslatef(0.0, 0.0, -1.0);
3782 * glScalef(1.0, 1.0, 2.0);
3784 * glScalef(1.0, flip, 1.0);
3785 * glTranslatef(1/w, -1/h, 0.0);
3787 * This is equivalent to:
3788 * glTranslatef(1/w, -flip/h, -1.0)
3789 * glScalef(1.0, flip, 2.0);
3792 if (stateblock
->wineD3DDevice
->render_offscreen
) {
3793 /* D3D texture coordinates are flipped compared to OpenGL ones, so
3794 * render everything upside down when rendering offscreen. */
3795 glTranslatef(1.0 / stateblock
->viewport
.Width
, 1.0 / stateblock
->viewport
.Height
, -1.0);
3796 checkGLcall("glTranslatef(1.0 / width, 1.0 / height, -1.0)");
3797 glScalef(1.0, -1.0, 2.0);
3799 glTranslatef(1.0 / stateblock
->viewport
.Width
, -1.0 / stateblock
->viewport
.Height
, -1.0);
3800 checkGLcall("glTranslatef(1.0 / width, -1.0 / height, -1.0)");
3801 glScalef(1.0, 1.0, 2.0);
3803 checkGLcall("glScalef");
3805 glMultMatrixf(&stateblock
->transforms
[WINED3DTS_PROJECTION
].u
.m
[0][0]);
3806 checkGLcall("glLoadMatrixf");
3810 /* This should match any arrays loaded in loadVertexData.
3811 * stateblock impl is required for GL_SUPPORT
3812 * TODO: Only load / unload arrays if we have to.
3814 static inline void unloadVertexData(IWineD3DStateBlockImpl
*stateblock
) {
3815 glDisableClientState(GL_VERTEX_ARRAY
);
3816 glDisableClientState(GL_NORMAL_ARRAY
);
3817 glDisableClientState(GL_COLOR_ARRAY
);
3818 if (GL_SUPPORT(EXT_SECONDARY_COLOR
)) {
3819 glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT
);
3821 if (GL_SUPPORT(ARB_VERTEX_BLEND
)) {
3822 glDisableClientState(GL_WEIGHT_ARRAY_ARB
);
3824 unloadTexCoords(stateblock
);
3827 static inline void unload_numbered_array(IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
, int i
)
3829 GL_EXTCALL(glDisableVertexAttribArrayARB(i
));
3830 checkGLcall("glDisableVertexAttribArrayARB(reg)");
3831 /* Some Windows drivers(NV GF 7) use the latest value that was used when drawing with the now
3832 * deactivated stream disabled, some other drivers(ATI, NV GF 8) set the undefined values to 0x00.
3833 * Let's set them to 0x00 to avoid hitting some undefined aspects of OpenGL. All that is really
3834 * important here is the glDisableVertexAttribArrayARB call above. The test shows that the refrast
3835 * keeps dereferencing the pointers, which would cause crashes in some games like Half Life 2: Episode Two.
3837 GL_EXTCALL(glVertexAttrib4NubARB(i
, 0, 0, 0, 0));
3838 checkGLcall("glVertexAttrib4NubARB(i, 0, 0, 0, 0)");
3840 context
->numbered_array_mask
&= ~(1 << i
);
3843 /* This should match any arrays loaded in loadNumberedArrays
3844 * TODO: Only load / unload arrays if we have to.
3846 static inline void unloadNumberedArrays(IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
)
3848 /* disable any attribs (this is the same for both GLSL and ARB modes) */
3849 GLint maxAttribs
= 16;
3852 /* Leave all the attribs disabled */
3853 glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB
, &maxAttribs
);
3854 /* MESA does not support it right not */
3855 if (glGetError() != GL_NO_ERROR
)
3857 for (i
= 0; i
< maxAttribs
; ++i
) {
3858 unload_numbered_array(stateblock
, context
, i
);
3862 static inline void loadNumberedArrays(IWineD3DStateBlockImpl
*stateblock
,
3863 const struct wined3d_stream_info
*stream_info
, WineD3DContext
*context
)
3865 GLuint curVBO
= GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT
) ? ~0U : 0;
3867 const UINT
*offset
= stateblock
->streamOffset
;
3868 struct wined3d_buffer
*vb
;
3869 DWORD_PTR shift_index
;
3871 /* Default to no instancing */
3872 stateblock
->wineD3DDevice
->instancedDraw
= FALSE
;
3874 for (i
= 0; i
< MAX_ATTRIBS
; i
++) {
3875 if (!(stream_info
->use_map
& (1 << i
)))
3877 if (context
->numbered_array_mask
& (1 << i
)) unload_numbered_array(stateblock
, context
, i
);
3881 /* Do not load instance data. It will be specified using glTexCoord by drawprim */
3882 if (stateblock
->streamFlags
[stream_info
->elements
[i
].stream_idx
] & WINED3DSTREAMSOURCE_INSTANCEDATA
)
3884 if (context
->numbered_array_mask
& (1 << i
)) unload_numbered_array(stateblock
, context
, i
);
3885 stateblock
->wineD3DDevice
->instancedDraw
= TRUE
;
3889 TRACE_(d3d_shader
)("Loading array %u [VBO=%u]\n", i
, stream_info
->elements
[i
].buffer_object
);
3891 if (stream_info
->elements
[i
].stride
)
3893 if (curVBO
!= stream_info
->elements
[i
].buffer_object
)
3895 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, stream_info
->elements
[i
].buffer_object
));
3896 checkGLcall("glBindBufferARB");
3897 curVBO
= stream_info
->elements
[i
].buffer_object
;
3899 vb
= (struct wined3d_buffer
*)stateblock
->streamSource
[stream_info
->elements
[i
].stream_idx
];
3900 /* Use the VBO to find out if a vertex buffer exists, not the vb pointer. vb can point to a
3901 * user pointer data blob. In that case curVBO will be 0. If there is a vertex buffer but no
3902 * vbo we won't be load converted attributes anyway
3904 if (curVBO
&& vb
->conversion_shift
)
3906 TRACE("Loading attribute from shifted buffer\n");
3907 TRACE("Attrib %d has original stride %d, new stride %d\n",
3908 i
, stream_info
->elements
[i
].stride
, vb
->conversion_stride
);
3909 TRACE("Original offset %p, additional offset 0x%08x\n",
3910 stream_info
->elements
[i
].data
, vb
->conversion_shift
[(DWORD_PTR
)stream_info
->elements
[i
].data
]);
3911 TRACE("Opengl type %#x\n", stream_info
->elements
[i
].format_desc
->gl_vtx_type
);
3912 shift_index
= ((DWORD_PTR
)stream_info
->elements
[i
].data
+ offset
[stream_info
->elements
[i
].stream_idx
]);
3913 shift_index
= shift_index
% stream_info
->elements
[i
].stride
;
3914 GL_EXTCALL(glVertexAttribPointerARB(i
, stream_info
->elements
[i
].format_desc
->gl_vtx_format
,
3915 stream_info
->elements
[i
].format_desc
->gl_vtx_type
,
3916 stream_info
->elements
[i
].format_desc
->gl_normalized
,
3917 vb
->conversion_stride
, stream_info
->elements
[i
].data
+ vb
->conversion_shift
[shift_index
]
3918 + stateblock
->loadBaseVertexIndex
* stream_info
->elements
[i
].stride
3919 + offset
[stream_info
->elements
[i
].stream_idx
]));
3922 GL_EXTCALL(glVertexAttribPointerARB(i
, stream_info
->elements
[i
].format_desc
->gl_vtx_format
,
3923 stream_info
->elements
[i
].format_desc
->gl_vtx_type
,
3924 stream_info
->elements
[i
].format_desc
->gl_normalized
,
3925 stream_info
->elements
[i
].stride
, stream_info
->elements
[i
].data
3926 + stateblock
->loadBaseVertexIndex
* stream_info
->elements
[i
].stride
3927 + offset
[stream_info
->elements
[i
].stream_idx
]));
3930 if (!(context
->numbered_array_mask
& (1 << i
)))
3932 GL_EXTCALL(glEnableVertexAttribArrayARB(i
));
3933 context
->numbered_array_mask
|= (1 << i
);
3936 /* Stride = 0 means always the same values. glVertexAttribPointerARB doesn't do that. Instead disable the pointer and
3937 * set up the attribute statically. But we have to figure out the system memory address.
3939 const BYTE
*ptr
= stream_info
->elements
[i
].data
+ offset
[stream_info
->elements
[i
].stream_idx
];
3940 if (stream_info
->elements
[i
].buffer_object
)
3942 vb
= (struct wined3d_buffer
*)stateblock
->streamSource
[stream_info
->elements
[i
].stream_idx
];
3943 ptr
+= (long) buffer_get_sysmem(vb
);
3946 if (context
->numbered_array_mask
& (1 << i
)) unload_numbered_array(stateblock
, context
, i
);
3948 switch (stream_info
->elements
[i
].format_desc
->format
)
3950 case WINED3DFMT_R32_FLOAT
:
3951 GL_EXTCALL(glVertexAttrib1fvARB(i
, (const GLfloat
*)ptr
));
3953 case WINED3DFMT_R32G32_FLOAT
:
3954 GL_EXTCALL(glVertexAttrib2fvARB(i
, (const GLfloat
*)ptr
));
3956 case WINED3DFMT_R32G32B32_FLOAT
:
3957 GL_EXTCALL(glVertexAttrib3fvARB(i
, (const GLfloat
*)ptr
));
3959 case WINED3DFMT_R32G32B32A32_FLOAT
:
3960 GL_EXTCALL(glVertexAttrib4fvARB(i
, (const GLfloat
*)ptr
));
3963 case WINED3DFMT_R8G8B8A8_UINT
:
3964 GL_EXTCALL(glVertexAttrib4NubvARB(i
, ptr
));
3966 case WINED3DFMT_A8R8G8B8
:
3967 if (GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA
))
3969 const DWORD
*src
= (const DWORD
*)ptr
;
3970 DWORD c
= *src
& 0xff00ff00;
3971 c
|= (*src
& 0xff0000) >> 16;
3972 c
|= (*src
& 0xff) << 16;
3973 GL_EXTCALL(glVertexAttrib4NubvARB(i
, (GLubyte
*)&c
));
3976 /* else fallthrough */
3977 case WINED3DFMT_R8G8B8A8_UNORM
:
3978 GL_EXTCALL(glVertexAttrib4NubvARB(i
, ptr
));
3981 case WINED3DFMT_R16G16_SINT
:
3982 GL_EXTCALL(glVertexAttrib4svARB(i
, (const GLshort
*)ptr
));
3984 case WINED3DFMT_R16G16B16A16_SINT
:
3985 GL_EXTCALL(glVertexAttrib4svARB(i
, (const GLshort
*)ptr
));
3988 case WINED3DFMT_R16G16_SNORM
:
3990 const GLshort s
[4] = {((const GLshort
*)ptr
)[0], ((const GLshort
*)ptr
)[1], 0, 1};
3991 GL_EXTCALL(glVertexAttrib4NsvARB(i
, s
));
3994 case WINED3DFMT_R16G16_UNORM
:
3996 const GLushort s
[4] = {((const GLushort
*)ptr
)[0], ((const GLushort
*)ptr
)[1], 0, 1};
3997 GL_EXTCALL(glVertexAttrib4NusvARB(i
, s
));
4000 case WINED3DFMT_R16G16B16A16_SNORM
:
4001 GL_EXTCALL(glVertexAttrib4NsvARB(i
, (const GLshort
*)ptr
));
4003 case WINED3DFMT_R16G16B16A16_UNORM
:
4004 GL_EXTCALL(glVertexAttrib4NusvARB(i
, (const GLushort
*)ptr
));
4007 case WINED3DFMT_R10G10B10A2_UINT
:
4008 FIXME("Unsure about WINED3DDECLTYPE_UDEC3\n");
4009 /*glVertexAttrib3usvARB(i, (const GLushort *)ptr); Does not exist */
4011 case WINED3DFMT_R10G10B10A2_SNORM
:
4012 FIXME("Unsure about WINED3DDECLTYPE_DEC3N\n");
4013 /*glVertexAttrib3NusvARB(i, (const GLushort *)ptr); Does not exist */
4016 case WINED3DFMT_R16G16_FLOAT
:
4017 /* Are those 16 bit floats. C doesn't have a 16 bit float type. I could read the single bits and calculate a 4
4018 * byte float according to the IEEE standard
4020 FIXME("Unsupported WINED3DDECLTYPE_FLOAT16_2\n");
4022 case WINED3DFMT_R16G16B16A16_FLOAT
:
4023 FIXME("Unsupported WINED3DDECLTYPE_FLOAT16_4\n");
4027 ERR("Unexpected declaration in stride 0 attributes\n");
4033 checkGLcall("Loading numbered arrays");
4036 /* Used from 2 different functions, and too big to justify making it inlined */
4037 static void loadVertexData(IWineD3DStateBlockImpl
*stateblock
, const struct wined3d_stream_info
*si
)
4039 const UINT
*offset
= stateblock
->streamOffset
;
4040 GLuint curVBO
= GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT
) ? ~0U : 0;
4041 const struct wined3d_stream_info_element
*e
;
4043 TRACE("Using fast vertex array code\n");
4045 /* This is fixed function pipeline only, and the fixed function pipeline doesn't do instancing */
4046 stateblock
->wineD3DDevice
->instancedDraw
= FALSE
;
4048 /* Blend Data ---------------------------------------------- */
4049 e
= &si
->elements
[WINED3D_FFP_BLENDWEIGHT
];
4050 if (e
->data
|| e
->buffer_object
4051 || si
->elements
[WINED3D_FFP_BLENDINDICES
].data
4052 || si
->elements
[WINED3D_FFP_BLENDINDICES
].buffer_object
)
4054 if (GL_SUPPORT(ARB_VERTEX_BLEND
)) {
4055 TRACE("Blend %d %p %d\n", e
->format_desc
->component_count
,
4056 e
->data
+ stateblock
->loadBaseVertexIndex
* e
->stride
, e
->stride
+ offset
[e
->stream_idx
]);
4058 glEnableClientState(GL_WEIGHT_ARRAY_ARB
);
4059 checkGLcall("glEnableClientState(GL_WEIGHT_ARRAY_ARB)");
4061 GL_EXTCALL(glVertexBlendARB(e
->format_desc
->component_count
+ 1));
4063 VTRACE(("glWeightPointerARB(%d, GL_FLOAT, %d, %p)\n",
4064 WINED3D_ATR_FORMAT(sd
->u
.s
.blendWeights
.dwType
) ,
4065 sd
->u
.s
.blendWeights
.dwStride
,
4066 sd
->u
.s
.blendWeights
.lpData
+ stateblock
->loadBaseVertexIndex
* sd
->u
.s
.blendWeights
.dwStride
+ offset
[sd
->u
.s
.blendWeights
.streamNo
]));
4068 if (curVBO
!= e
->buffer_object
)
4070 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, e
->buffer_object
));
4071 checkGLcall("glBindBufferARB");
4072 curVBO
= e
->buffer_object
;
4075 GL_EXTCALL(glWeightPointerARB
)(e
->format_desc
->gl_vtx_format
, e
->format_desc
->gl_vtx_type
, e
->stride
,
4076 e
->data
+ stateblock
->loadBaseVertexIndex
* e
->stride
+ offset
[e
->stream_idx
]);
4078 checkGLcall("glWeightPointerARB");
4080 if (si
->elements
[WINED3D_FFP_BLENDINDICES
].data
4081 || (si
->elements
[WINED3D_FFP_BLENDINDICES
].buffer_object
))
4086 FIXME("blendMatrixIndices support\n");
4091 /* TODO: support blends in drawStridedSlow
4092 * No need to write a FIXME here, this is done after the general vertex decl decoding
4094 WARN("unsupported blending in openGl\n");
4097 if (GL_SUPPORT(ARB_VERTEX_BLEND
)) {
4098 static const GLbyte one
= 1;
4099 GL_EXTCALL(glWeightbvARB(1, &one
));
4100 checkGLcall("glWeightivARB(GL_LIMITS(blends), weights)");
4104 /* Point Size ----------------------------------------------*/
4105 e
= &si
->elements
[WINED3D_FFP_PSIZE
];
4106 if (e
->data
|| e
->buffer_object
)
4108 /* no such functionality in the fixed function GL pipeline */
4109 TRACE("Cannot change ptSize here in openGl\n");
4110 /* TODO: Implement this function in using shaders if they are available */
4113 /* Vertex Pointers -----------------------------------------*/
4114 e
= &si
->elements
[WINED3D_FFP_POSITION
];
4115 if (e
->data
|| e
->buffer_object
)
4117 VTRACE(("glVertexPointer(%d, GL_FLOAT, %d, %p)\n", e
->stride
, e
->size
, e
->data
));
4119 if (curVBO
!= e
->buffer_object
)
4121 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, e
->buffer_object
));
4122 checkGLcall("glBindBufferARB");
4123 curVBO
= e
->buffer_object
;
4126 /* min(WINED3D_ATR_FORMAT(position),3) to Disable RHW mode as 'w' coord
4127 handling for rhw mode should not impact screen position whereas in GL it does.
4128 This may result in very slightly distorted textures in rhw mode.
4129 There's always the other option of fixing the view matrix to
4130 prevent w from having any effect.
4132 This only applies to user pointer sources, in VBOs the vertices are fixed up
4134 if (!e
->buffer_object
)
4136 glVertexPointer(3 /* min(e->format_desc->gl_vtx_format, 3) */, e
->format_desc
->gl_vtx_type
, e
->stride
,
4137 e
->data
+ stateblock
->loadBaseVertexIndex
* e
->stride
+ offset
[e
->stream_idx
]);
4139 glVertexPointer(e
->format_desc
->gl_vtx_format
, e
->format_desc
->gl_vtx_type
, e
->stride
,
4140 e
->data
+ stateblock
->loadBaseVertexIndex
* e
->stride
+ offset
[e
->stream_idx
]);
4142 checkGLcall("glVertexPointer(...)");
4143 glEnableClientState(GL_VERTEX_ARRAY
);
4144 checkGLcall("glEnableClientState(GL_VERTEX_ARRAY)");
4147 /* Normals -------------------------------------------------*/
4148 e
= &si
->elements
[WINED3D_FFP_NORMAL
];
4149 if (e
->data
|| e
->buffer_object
)
4151 VTRACE(("glNormalPointer(GL_FLOAT, %d, %p)\n", e
->stride
, e
->data
));
4152 if (curVBO
!= e
->buffer_object
)
4154 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, e
->buffer_object
));
4155 checkGLcall("glBindBufferARB");
4156 curVBO
= e
->buffer_object
;
4158 glNormalPointer(e
->format_desc
->gl_vtx_type
, e
->stride
,
4159 e
->data
+ stateblock
->loadBaseVertexIndex
* e
->stride
+ offset
[e
->stream_idx
]);
4160 checkGLcall("glNormalPointer(...)");
4161 glEnableClientState(GL_NORMAL_ARRAY
);
4162 checkGLcall("glEnableClientState(GL_NORMAL_ARRAY)");
4165 glNormal3f(0, 0, 0);
4166 checkGLcall("glNormal3f(0, 0, 0)");
4169 /* Diffuse Colour --------------------------------------------*/
4170 /* WARNING: Data here MUST be in RGBA format, so cannot */
4171 /* go directly into fast mode from app pgm, because */
4172 /* directx requires data in BGRA format. */
4173 /* currently fixupVertices swizzles the format, but this isn't*/
4174 /* very practical when using VBOs */
4175 /* NOTE: Unless we write a vertex shader to swizzle the colour*/
4176 /* , or the user doesn't care and wants the speed advantage */
4178 e
= &si
->elements
[WINED3D_FFP_DIFFUSE
];
4179 if (e
->data
|| e
->buffer_object
)
4181 VTRACE(("glColorPointer(4, GL_UNSIGNED_BYTE, %d, %p)\n", e
->stride
, e
->data
));
4183 if (curVBO
!= e
->buffer_object
)
4185 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, e
->buffer_object
));
4186 checkGLcall("glBindBufferARB");
4187 curVBO
= e
->buffer_object
;
4190 glColorPointer(e
->format_desc
->gl_vtx_format
, e
->format_desc
->gl_vtx_type
, e
->stride
,
4191 e
->data
+ stateblock
->loadBaseVertexIndex
* e
->stride
+ offset
[e
->stream_idx
]);
4192 checkGLcall("glColorPointer(4, GL_UNSIGNED_BYTE, ...)");
4193 glEnableClientState(GL_COLOR_ARRAY
);
4194 checkGLcall("glEnableClientState(GL_COLOR_ARRAY)");
4197 glColor4f(1.0f
, 1.0f
, 1.0f
, 1.0f
);
4198 checkGLcall("glColor4f(1, 1, 1, 1)");
4201 /* Specular Colour ------------------------------------------*/
4202 e
= &si
->elements
[WINED3D_FFP_SPECULAR
];
4203 if (e
->data
|| e
->buffer_object
)
4205 TRACE("setting specular colour\n");
4206 VTRACE(("glSecondaryColorPointer(4, GL_UNSIGNED_BYTE, %d, %p)\n", e
->stride
, e
->data
));
4208 if (GL_SUPPORT(EXT_SECONDARY_COLOR
)) {
4209 if (curVBO
!= e
->buffer_object
)
4211 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, e
->buffer_object
));
4212 checkGLcall("glBindBufferARB");
4213 curVBO
= e
->buffer_object
;
4215 GL_EXTCALL(glSecondaryColorPointerEXT
)(e
->format_desc
->gl_vtx_format
, e
->format_desc
->gl_vtx_type
,
4216 e
->stride
, e
->data
+ stateblock
->loadBaseVertexIndex
* e
->stride
+ offset
[e
->stream_idx
]);
4217 checkGLcall("glSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, ...)");
4218 glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT
);
4219 checkGLcall("glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
4222 /* Missing specular color is not critical, no warnings */
4223 VTRACE(("Specular colour is not supported in this GL implementation\n"));
4227 if (GL_SUPPORT(EXT_SECONDARY_COLOR
)) {
4228 GL_EXTCALL(glSecondaryColor3fEXT
)(0, 0, 0);
4229 checkGLcall("glSecondaryColor3fEXT(0, 0, 0)");
4232 /* Missing specular color is not critical, no warnings */
4233 VTRACE(("Specular colour is not supported in this GL implementation\n"));
4237 /* Texture coords -------------------------------------------*/
4238 loadTexCoords(stateblock
, si
, &curVBO
);
4241 static inline void drawPrimitiveTraceDataLocations(const struct wined3d_stream_info
*dataLocations
)
4243 /* Dump out what parts we have supplied */
4244 TRACE("Strided Data:\n");
4245 TRACE_STRIDED((dataLocations
), WINED3D_FFP_POSITION
);
4246 TRACE_STRIDED((dataLocations
), WINED3D_FFP_BLENDWEIGHT
);
4247 TRACE_STRIDED((dataLocations
), WINED3D_FFP_BLENDINDICES
);
4248 TRACE_STRIDED((dataLocations
), WINED3D_FFP_NORMAL
);
4249 TRACE_STRIDED((dataLocations
), WINED3D_FFP_PSIZE
);
4250 TRACE_STRIDED((dataLocations
), WINED3D_FFP_DIFFUSE
);
4251 TRACE_STRIDED((dataLocations
), WINED3D_FFP_SPECULAR
);
4252 TRACE_STRIDED((dataLocations
), WINED3D_FFP_TEXCOORD0
);
4253 TRACE_STRIDED((dataLocations
), WINED3D_FFP_TEXCOORD1
);
4254 TRACE_STRIDED((dataLocations
), WINED3D_FFP_TEXCOORD2
);
4255 TRACE_STRIDED((dataLocations
), WINED3D_FFP_TEXCOORD3
);
4256 TRACE_STRIDED((dataLocations
), WINED3D_FFP_TEXCOORD4
);
4257 TRACE_STRIDED((dataLocations
), WINED3D_FFP_TEXCOORD5
);
4258 TRACE_STRIDED((dataLocations
), WINED3D_FFP_TEXCOORD6
);
4259 TRACE_STRIDED((dataLocations
), WINED3D_FFP_TEXCOORD7
);
4264 static void streamsrc(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
4265 IWineD3DDeviceImpl
*device
= stateblock
->wineD3DDevice
;
4267 struct wined3d_stream_info
*dataLocations
= &device
->strided_streams
;
4268 BOOL useVertexShaderFunction
;
4269 BOOL load_numbered
= FALSE
;
4270 BOOL load_named
= FALSE
;
4272 useVertexShaderFunction
= (device
->vs_selected_mode
!= SHADER_NONE
&& stateblock
->vertexShader
) ? TRUE
: FALSE
;
4274 if(device
->up_strided
) {
4275 /* Note: this is a ddraw fixed-function code path */
4276 TRACE("================ Strided Input ===================\n");
4277 device_stream_info_from_strided(device
, device
->up_strided
, dataLocations
);
4280 drawPrimitiveTraceDataLocations(dataLocations
);
4283 /* Note: This is a fixed function or shader codepath.
4284 * This means it must handle both types of strided data.
4285 * Shaders must go through here to zero the strided data, even if they
4286 * don't set any declaration at all
4288 TRACE("================ Vertex Declaration ===================\n");
4289 device_stream_info_from_declaration(device
, useVertexShaderFunction
, dataLocations
, &fixup
);
4292 if (dataLocations
->position_transformed
) useVertexShaderFunction
= FALSE
;
4294 if(useVertexShaderFunction
) {
4295 if(((IWineD3DVertexDeclarationImpl
*) stateblock
->vertexDecl
)->half_float_conv_needed
&& !fixup
) {
4296 TRACE("Using drawStridedSlow with vertex shaders for FLOAT16 conversion\n");
4297 device
->useDrawStridedSlow
= TRUE
;
4299 load_numbered
= TRUE
;
4300 device
->useDrawStridedSlow
= FALSE
;
4303 else if (fixup
|| (!dataLocations
->elements
[WINED3D_FFP_PSIZE
].data
4304 && !dataLocations
->position_transformed
4305 && (GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA
)
4306 || (!dataLocations
->elements
[WINED3D_FFP_DIFFUSE
].data
4307 && !dataLocations
->elements
[WINED3D_FFP_SPECULAR
].data
))))
4309 /* Load the vertex data using named arrays */
4311 device
->useDrawStridedSlow
= FALSE
;
4313 TRACE("Not loading vertex data\n");
4314 device
->useDrawStridedSlow
= TRUE
;
4317 if (context
->numberedArraysLoaded
&& !load_numbered
)
4319 unloadNumberedArrays(stateblock
, context
);
4320 context
->numberedArraysLoaded
= FALSE
;
4321 context
->numbered_array_mask
= 0;
4323 else if (context
->namedArraysLoaded
)
4325 unloadVertexData(stateblock
);
4326 context
->namedArraysLoaded
= FALSE
;
4331 TRACE("Loading numbered arrays\n");
4332 loadNumberedArrays(stateblock
, dataLocations
, context
);
4333 context
->numberedArraysLoaded
= TRUE
;
4335 else if (load_named
)
4337 TRACE("Loading vertex data\n");
4338 loadVertexData(stateblock
, dataLocations
);
4339 context
->namedArraysLoaded
= TRUE
;
4343 static void vertexdeclaration(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
4344 BOOL updateFog
= FALSE
;
4345 BOOL useVertexShaderFunction
= use_vs(stateblock
);
4346 BOOL usePixelShaderFunction
= use_ps(stateblock
);
4348 /* Some stuff is in the device until we have per context tracking */
4349 IWineD3DDeviceImpl
*device
= stateblock
->wineD3DDevice
;
4350 BOOL wasrhw
= context
->last_was_rhw
;
4352 transformed
= device
->strided_streams
.position_transformed
;
4353 if(transformed
!= context
->last_was_rhw
&& !useVertexShaderFunction
) {
4357 /* Reapply lighting if it is not scheduled for reapplication already */
4358 if(!isStateDirty(context
, STATE_RENDER(WINED3DRS_LIGHTING
))) {
4359 state_lighting(STATE_RENDER(WINED3DRS_LIGHTING
), stateblock
, context
);
4363 context
->last_was_rhw
= TRUE
;
4366 /* Untransformed, so relies on the view and projection matrices */
4367 context
->last_was_rhw
= FALSE
;
4368 /* This turns off the Z scale trick to 'disable' viewport frustum clipping in rhw mode*/
4369 device
->untransformed
= TRUE
;
4371 /* Todo for sw shaders: Vertex Shader output is already transformed, so set up identity matrices
4372 * Not needed as long as only hw shaders are supported
4375 /* This sets the shader output position correction constants.
4376 * TODO: Move to the viewport state
4378 if (useVertexShaderFunction
) {
4379 device
->posFixup
[1] = device
->render_offscreen
? -1.0 : 1.0;
4380 device
->posFixup
[3] = -device
->posFixup
[1] / stateblock
->viewport
.Height
;
4384 /* Don't have to apply the matrices when vertex shaders are used. When vshaders are turned
4385 * off this function will be called again anyway to make sure they're properly set
4387 if(!useVertexShaderFunction
) {
4388 /* TODO: Move this mainly to the viewport state and only apply when the vp has changed
4389 * or transformed / untransformed was switched
4391 if(wasrhw
!= context
->last_was_rhw
&&
4392 !isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_PROJECTION
)) &&
4393 !isStateDirty(context
, STATE_VIEWPORT
)) {
4394 transform_projection(STATE_TRANSFORM(WINED3DTS_PROJECTION
), stateblock
, context
);
4396 /* World matrix needs reapplication here only if we're switching between rhw and non-rhw
4399 * If a vertex shader is used, the world matrix changed and then vertex shader unbound
4400 * this check will fail and the matrix not applied again. This is OK because a simple
4401 * world matrix change reapplies the matrix - These checks here are only to satisfy the
4402 * needs of the vertex declaration.
4404 * World and view matrix go into the same gl matrix, so only apply them when neither is
4407 if(transformed
!= wasrhw
&&
4408 !isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0))) &&
4409 !isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_VIEW
))) {
4410 transform_world(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), stateblock
, context
);
4413 if(!isStateDirty(context
, STATE_RENDER(WINED3DRS_COLORVERTEX
))) {
4414 state_colormat(STATE_RENDER(WINED3DRS_COLORVERTEX
), stateblock
, context
);
4417 if(context
->last_was_vshader
) {
4419 if(!device
->vs_clipping
&& !isStateDirty(context
, STATE_RENDER(WINED3DRS_CLIPPLANEENABLE
))) {
4420 state_clipping(STATE_RENDER(WINED3DRS_CLIPPLANEENABLE
), stateblock
, context
);
4423 if(!isStateDirty(context
, STATE_RENDER(WINED3DRS_NORMALIZENORMALS
))) {
4424 state_normalize(STATE_RENDER(WINED3DRS_NORMALIZENORMALS
), stateblock
, context
);
4427 if(!context
->last_was_vshader
) {
4429 static BOOL warned
= FALSE
;
4430 if(!device
->vs_clipping
) {
4431 /* Disable all clip planes to get defined results on all drivers. See comment in the
4432 * state_clipping state handler
4434 for(i
= 0; i
< GL_LIMITS(clipplanes
); i
++) {
4435 glDisable(GL_CLIP_PLANE0
+ i
);
4436 checkGLcall("glDisable(GL_CLIP_PLANE0 + i)");
4439 if(!warned
&& stateblock
->renderState
[WINED3DRS_CLIPPLANEENABLE
]) {
4440 FIXME("Clipping not supported with vertex shaders\n");
4445 /* Apply the transform matrices when switching from rhw drawing to vertex shaders. Vertex
4446 * shaders themselves do not need it, but the matrices are not reapplied automatically when
4447 * switching back from vertex shaders to fixed function processing. So make sure we leave the
4448 * fixed function vertex processing states back in a sane state before switching to shaders
4450 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_PROJECTION
))) {
4451 transform_projection(STATE_TRANSFORM(WINED3DTS_PROJECTION
), stateblock
, context
);
4453 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)))) {
4454 transform_world(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), stateblock
, context
);
4461 /* Vertex and pixel shaders are applied together for now, so let the last dirty state do the
4464 if (!isStateDirty(context
, STATE_PIXELSHADER
)) {
4465 device
->shader_backend
->shader_select((IWineD3DDevice
*)device
, usePixelShaderFunction
, useVertexShaderFunction
);
4467 if (!isStateDirty(context
, STATE_VERTEXSHADERCONSTANT
) && (useVertexShaderFunction
|| usePixelShaderFunction
)) {
4468 shaderconstant(STATE_VERTEXSHADERCONSTANT
, stateblock
, context
);
4472 context
->last_was_vshader
= useVertexShaderFunction
;
4475 device
->StateTable
[STATE_RENDER(WINED3DRS_FOGVERTEXMODE
)].apply(STATE_RENDER(WINED3DRS_FOGVERTEXMODE
), stateblock
, context
);
4477 if(!useVertexShaderFunction
) {
4479 for(i
= 0; i
< MAX_TEXTURES
; i
++) {
4480 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_TEXTURE0
+ i
))) {
4481 transform_texture(STATE_TEXTURESTAGE(i
, WINED3DTSS_TEXTURETRANSFORMFLAGS
), stateblock
, context
);
4487 static void viewport_miscpart(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
4489 IWineD3DSurfaceImpl
*target
;
4491 glDepthRange(stateblock
->viewport
.MinZ
, stateblock
->viewport
.MaxZ
);
4492 checkGLcall("glDepthRange");
4493 /* Note: GL requires lower left, DirectX supplies upper left. This is reversed when using offscreen rendering
4495 if(stateblock
->wineD3DDevice
->render_offscreen
) {
4496 glViewport(stateblock
->viewport
.X
,
4497 stateblock
->viewport
.Y
,
4498 stateblock
->viewport
.Width
, stateblock
->viewport
.Height
);
4500 target
= (IWineD3DSurfaceImpl
*) stateblock
->wineD3DDevice
->render_targets
[0];
4501 target
->get_drawable_size(target
, &width
, &height
);
4503 glViewport(stateblock
->viewport
.X
,
4504 (height
- (stateblock
->viewport
.Y
+ stateblock
->viewport
.Height
)),
4505 stateblock
->viewport
.Width
, stateblock
->viewport
.Height
);
4508 checkGLcall("glViewport");
4511 static void viewport_vertexpart(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
4512 stateblock
->wineD3DDevice
->posFixup
[2] = 1.0 / stateblock
->viewport
.Width
;
4513 stateblock
->wineD3DDevice
->posFixup
[3] = -stateblock
->wineD3DDevice
->posFixup
[1] / stateblock
->viewport
.Height
;
4514 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_PROJECTION
))) {
4515 transform_projection(STATE_TRANSFORM(WINED3DTS_PROJECTION
), stateblock
, context
);
4517 if(!isStateDirty(context
, STATE_RENDER(WINED3DRS_POINTSCALEENABLE
))) {
4518 state_pscale(STATE_RENDER(WINED3DRS_POINTSCALEENABLE
), stateblock
, context
);
4522 static void light(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
4523 UINT Index
= state
- STATE_ACTIVELIGHT(0);
4524 const PLIGHTINFOEL
*lightInfo
= stateblock
->activeLights
[Index
];
4527 glDisable(GL_LIGHT0
+ Index
);
4528 checkGLcall("glDisable(GL_LIGHT0 + Index)");
4531 float colRGBA
[] = {0.0, 0.0, 0.0, 0.0};
4533 /* Light settings are affected by the model view in OpenGL, the View transform in direct3d*/
4534 glMatrixMode(GL_MODELVIEW
);
4536 glLoadMatrixf(&stateblock
->transforms
[WINED3DTS_VIEW
].u
.m
[0][0]);
4539 colRGBA
[0] = lightInfo
->OriginalParms
.Diffuse
.r
;
4540 colRGBA
[1] = lightInfo
->OriginalParms
.Diffuse
.g
;
4541 colRGBA
[2] = lightInfo
->OriginalParms
.Diffuse
.b
;
4542 colRGBA
[3] = lightInfo
->OriginalParms
.Diffuse
.a
;
4543 glLightfv(GL_LIGHT0
+ Index
, GL_DIFFUSE
, colRGBA
);
4544 checkGLcall("glLightfv");
4547 colRGBA
[0] = lightInfo
->OriginalParms
.Specular
.r
;
4548 colRGBA
[1] = lightInfo
->OriginalParms
.Specular
.g
;
4549 colRGBA
[2] = lightInfo
->OriginalParms
.Specular
.b
;
4550 colRGBA
[3] = lightInfo
->OriginalParms
.Specular
.a
;
4551 glLightfv(GL_LIGHT0
+ Index
, GL_SPECULAR
, colRGBA
);
4552 checkGLcall("glLightfv");
4555 colRGBA
[0] = lightInfo
->OriginalParms
.Ambient
.r
;
4556 colRGBA
[1] = lightInfo
->OriginalParms
.Ambient
.g
;
4557 colRGBA
[2] = lightInfo
->OriginalParms
.Ambient
.b
;
4558 colRGBA
[3] = lightInfo
->OriginalParms
.Ambient
.a
;
4559 glLightfv(GL_LIGHT0
+ Index
, GL_AMBIENT
, colRGBA
);
4560 checkGLcall("glLightfv");
4562 if ((lightInfo
->OriginalParms
.Range
*lightInfo
->OriginalParms
.Range
) >= FLT_MIN
) {
4563 quad_att
= 1.4/(lightInfo
->OriginalParms
.Range
*lightInfo
->OriginalParms
.Range
);
4565 quad_att
= 0; /* 0 or MAX? (0 seems to be ok) */
4568 /* Do not assign attenuation values for lights that do not use them. D3D apps are free to pass any junk,
4569 * but gl drivers use them and may crash due to bad Attenuation values. Need for Speed most wanted sets
4570 * Attenuation0 to NaN and crashes in the gl lib
4573 switch (lightInfo
->OriginalParms
.Type
) {
4574 case WINED3DLIGHT_POINT
:
4576 glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->lightPosn
[0]);
4577 checkGLcall("glLightfv");
4578 glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
4579 checkGLcall("glLightf");
4580 /* Attenuation - Are these right? guessing... */
4581 glLightf(GL_LIGHT0
+ Index
, GL_CONSTANT_ATTENUATION
, lightInfo
->OriginalParms
.Attenuation0
);
4582 checkGLcall("glLightf");
4583 glLightf(GL_LIGHT0
+ Index
, GL_LINEAR_ATTENUATION
, lightInfo
->OriginalParms
.Attenuation1
);
4584 checkGLcall("glLightf");
4585 if (quad_att
< lightInfo
->OriginalParms
.Attenuation2
) quad_att
= lightInfo
->OriginalParms
.Attenuation2
;
4586 glLightf(GL_LIGHT0
+ Index
, GL_QUADRATIC_ATTENUATION
, quad_att
);
4587 checkGLcall("glLightf");
4591 case WINED3DLIGHT_SPOT
:
4593 glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->lightPosn
[0]);
4594 checkGLcall("glLightfv");
4596 glLightfv(GL_LIGHT0
+ Index
, GL_SPOT_DIRECTION
, &lightInfo
->lightDirn
[0]);
4597 checkGLcall("glLightfv");
4598 glLightf(GL_LIGHT0
+ Index
, GL_SPOT_EXPONENT
, lightInfo
->exponent
);
4599 checkGLcall("glLightf");
4600 glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
4601 checkGLcall("glLightf");
4602 /* Attenuation - Are these right? guessing... */
4603 glLightf(GL_LIGHT0
+ Index
, GL_CONSTANT_ATTENUATION
, lightInfo
->OriginalParms
.Attenuation0
);
4604 checkGLcall("glLightf");
4605 glLightf(GL_LIGHT0
+ Index
, GL_LINEAR_ATTENUATION
, lightInfo
->OriginalParms
.Attenuation1
);
4606 checkGLcall("glLightf");
4607 if (quad_att
< lightInfo
->OriginalParms
.Attenuation2
) quad_att
= lightInfo
->OriginalParms
.Attenuation2
;
4608 glLightf(GL_LIGHT0
+ Index
, GL_QUADRATIC_ATTENUATION
, quad_att
);
4609 checkGLcall("glLightf");
4613 case WINED3DLIGHT_DIRECTIONAL
:
4615 glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->lightPosn
[0]); /* Note gl uses w position of 0 for direction! */
4616 checkGLcall("glLightfv");
4617 glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
4618 checkGLcall("glLightf");
4619 glLightf(GL_LIGHT0
+ Index
, GL_SPOT_EXPONENT
, 0.0f
);
4620 checkGLcall("glLightf");
4624 FIXME("Unrecognized light type %d\n", lightInfo
->OriginalParms
.Type
);
4627 /* Restore the modelview matrix */
4630 glEnable(GL_LIGHT0
+ Index
);
4631 checkGLcall("glEnable(GL_LIGHT0 + Index)");
4637 static void scissorrect(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
4638 RECT
*pRect
= &stateblock
->scissorRect
;
4641 IWineD3DSurfaceImpl
*target
= (IWineD3DSurfaceImpl
*) stateblock
->wineD3DDevice
->render_targets
[0];
4643 target
->get_drawable_size(target
, &width
, &height
);
4644 /* Warning: glScissor uses window coordinates, not viewport coordinates, so our viewport correction does not apply
4645 * Warning2: Even in windowed mode the coords are relative to the window, not the screen
4647 TRACE("(%p) Setting new Scissor Rect to %d:%d-%d:%d\n", stateblock
->wineD3DDevice
, pRect
->left
, pRect
->bottom
- height
,
4648 pRect
->right
- pRect
->left
, pRect
->bottom
- pRect
->top
);
4650 if (stateblock
->wineD3DDevice
->render_offscreen
) {
4651 glScissor(pRect
->left
, pRect
->top
, pRect
->right
- pRect
->left
, pRect
->bottom
- pRect
->top
);
4653 glScissor(pRect
->left
, height
- pRect
->bottom
, pRect
->right
- pRect
->left
, pRect
->bottom
- pRect
->top
);
4655 checkGLcall("glScissor");
4658 static void indexbuffer(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
4659 if(stateblock
->streamIsUP
|| stateblock
->pIndexData
== NULL
) {
4660 GL_EXTCALL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB
, 0));
4662 struct wined3d_buffer
*ib
= (struct wined3d_buffer
*) stateblock
->pIndexData
;
4663 GL_EXTCALL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB
, ib
->buffer_object
));
4667 static void frontface(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
4668 if(stateblock
->wineD3DDevice
->render_offscreen
) {
4669 glFrontFace(GL_CCW
);
4670 checkGLcall("glFrontFace(GL_CCW)");
4673 checkGLcall("glFrontFace(GL_CW)");
4677 const struct StateEntryTemplate misc_state_template
[] = {
4678 { STATE_RENDER(WINED3DRS_SRCBLEND
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
}, 0 },
4679 { STATE_RENDER(WINED3DRS_DESTBLEND
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
}, 0 },
4680 { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
}, 0 },
4681 { STATE_RENDER(WINED3DRS_EDGEANTIALIAS
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
}, 0 },
4682 { STATE_RENDER(WINED3DRS_ANTIALIASEDLINEENABLE
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
}, 0 },
4683 { STATE_RENDER(WINED3DRS_SEPARATEALPHABLENDENABLE
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
}, 0 },
4684 { STATE_RENDER(WINED3DRS_SRCBLENDALPHA
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
}, 0 },
4685 { STATE_RENDER(WINED3DRS_DESTBLENDALPHA
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
}, 0 },
4686 { STATE_RENDER(WINED3DRS_DESTBLENDALPHA
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
}, 0 },
4687 { STATE_RENDER(WINED3DRS_BLENDOPALPHA
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
}, 0 },
4688 { STATE_STREAMSRC
, { STATE_VDECL
, streamsrc
}, 0 },
4689 { STATE_VDECL
, { STATE_VDECL
, streamsrc
}, 0 },
4690 { STATE_FRONTFACE
, { STATE_FRONTFACE
, frontface
}, 0 },
4691 { STATE_SCISSORRECT
, { STATE_SCISSORRECT
, scissorrect
}, 0 },
4692 /* TODO: Move shader constant loading to vertex and fragment pipeline repectively, as soon as the pshader and
4693 * vshader loadings are untied from each other
4695 { STATE_VERTEXSHADERCONSTANT
, { STATE_VERTEXSHADERCONSTANT
, shaderconstant
}, 0 },
4696 { STATE_PIXELSHADERCONSTANT
, { STATE_VERTEXSHADERCONSTANT
, shaderconstant
}, 0 },
4697 { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4698 { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4699 { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4700 { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4701 { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4702 { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4703 { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4704 { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4705 { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4706 { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4707 { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4708 { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4709 { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4710 { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4711 { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4712 { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4713 { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4714 { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4715 { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4716 { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4717 { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4718 { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4719 { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4720 { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4721 { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4722 { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4723 { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4724 { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4725 { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4726 { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4727 { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4728 { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, 0 },
4729 { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, 0 },
4730 { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, 0 },
4731 { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, 0 },
4732 { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, 0 },
4733 { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, 0 },
4734 { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, 0 },
4735 { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, 0 },
4736 { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, 0 },
4737 { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, 0 },
4738 { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, 0 },
4739 { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, 0 },
4740 { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, 0 },
4741 { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, 0 },
4742 { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, 0 },
4743 { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, 0 },
4744 { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, 0 },
4746 { STATE_VIEWPORT
, { STATE_VIEWPORT
, viewport_miscpart
}, 0 },
4747 { STATE_INDEXBUFFER
, { STATE_INDEXBUFFER
, indexbuffer
}, ARB_VERTEX_BUFFER_OBJECT
},
4748 { STATE_RENDER(WINED3DRS_ANTIALIAS
), { STATE_RENDER(WINED3DRS_ANTIALIAS
), state_antialias
}, 0 },
4749 { STATE_RENDER(WINED3DRS_TEXTUREPERSPECTIVE
), { STATE_RENDER(WINED3DRS_TEXTUREPERSPECTIVE
), state_perspective
}, 0 },
4750 { STATE_RENDER(WINED3DRS_ZENABLE
), { STATE_RENDER(WINED3DRS_ZENABLE
), state_zenable
}, 0 },
4751 { STATE_RENDER(WINED3DRS_WRAPU
), { STATE_RENDER(WINED3DRS_WRAPU
), state_wrapu
}, 0 },
4752 { STATE_RENDER(WINED3DRS_WRAPV
), { STATE_RENDER(WINED3DRS_WRAPV
), state_wrapv
}, 0 },
4753 { STATE_RENDER(WINED3DRS_FILLMODE
), { STATE_RENDER(WINED3DRS_FILLMODE
), state_fillmode
}, 0 },
4754 { STATE_RENDER(WINED3DRS_SHADEMODE
), { STATE_RENDER(WINED3DRS_SHADEMODE
), state_shademode
}, 0 },
4755 { STATE_RENDER(WINED3DRS_LINEPATTERN
), { STATE_RENDER(WINED3DRS_LINEPATTERN
), state_linepattern
}, 0 },
4756 { STATE_RENDER(WINED3DRS_MONOENABLE
), { STATE_RENDER(WINED3DRS_MONOENABLE
), state_monoenable
}, 0 },
4757 { STATE_RENDER(WINED3DRS_ROP2
), { STATE_RENDER(WINED3DRS_ROP2
), state_rop2
}, 0 },
4758 { STATE_RENDER(WINED3DRS_PLANEMASK
), { STATE_RENDER(WINED3DRS_PLANEMASK
), state_planemask
}, 0 },
4759 { STATE_RENDER(WINED3DRS_ZWRITEENABLE
), { STATE_RENDER(WINED3DRS_ZWRITEENABLE
), state_zwritenable
}, 0 },
4760 { STATE_RENDER(WINED3DRS_ALPHATESTENABLE
), { STATE_RENDER(WINED3DRS_ALPHATESTENABLE
), state_alpha
}, 0 },
4761 { STATE_RENDER(WINED3DRS_ALPHAREF
), { STATE_RENDER(WINED3DRS_ALPHATESTENABLE
), state_alpha
}, 0 },
4762 { STATE_RENDER(WINED3DRS_ALPHAFUNC
), { STATE_RENDER(WINED3DRS_ALPHATESTENABLE
), state_alpha
}, 0 },
4763 { STATE_RENDER(WINED3DRS_COLORKEYENABLE
), { STATE_RENDER(WINED3DRS_ALPHATESTENABLE
), state_alpha
}, 0 },
4764 { STATE_RENDER(WINED3DRS_LASTPIXEL
), { STATE_RENDER(WINED3DRS_LASTPIXEL
), state_lastpixel
}, 0 },
4765 { STATE_RENDER(WINED3DRS_CULLMODE
), { STATE_RENDER(WINED3DRS_CULLMODE
), state_cullmode
}, 0 },
4766 { STATE_RENDER(WINED3DRS_ZFUNC
), { STATE_RENDER(WINED3DRS_ZFUNC
), state_zfunc
}, 0 },
4767 { STATE_RENDER(WINED3DRS_DITHERENABLE
), { STATE_RENDER(WINED3DRS_DITHERENABLE
), state_ditherenable
}, 0 },
4768 { STATE_RENDER(WINED3DRS_SUBPIXEL
), { STATE_RENDER(WINED3DRS_SUBPIXEL
), state_subpixel
}, 0 },
4769 { STATE_RENDER(WINED3DRS_SUBPIXELX
), { STATE_RENDER(WINED3DRS_SUBPIXELX
), state_subpixelx
}, 0 },
4770 { STATE_RENDER(WINED3DRS_STIPPLEDALPHA
), { STATE_RENDER(WINED3DRS_STIPPLEDALPHA
), state_stippledalpha
}, 0 },
4771 { STATE_RENDER(WINED3DRS_ZBIAS
), { STATE_RENDER(WINED3DRS_ZBIAS
), state_zbias
}, 0 },
4772 { STATE_RENDER(WINED3DRS_STIPPLEENABLE
), { STATE_RENDER(WINED3DRS_STIPPLEENABLE
), state_stippleenable
}, 0 },
4773 { STATE_RENDER(WINED3DRS_MIPMAPLODBIAS
), { STATE_RENDER(WINED3DRS_MIPMAPLODBIAS
), state_mipmaplodbias
}, 0 },
4774 { STATE_RENDER(WINED3DRS_ANISOTROPY
), { STATE_RENDER(WINED3DRS_ANISOTROPY
), state_anisotropy
}, 0 },
4775 { STATE_RENDER(WINED3DRS_FLUSHBATCH
), { STATE_RENDER(WINED3DRS_FLUSHBATCH
), state_flushbatch
}, 0 },
4776 { STATE_RENDER(WINED3DRS_TRANSLUCENTSORTINDEPENDENT
), { STATE_RENDER(WINED3DRS_TRANSLUCENTSORTINDEPENDENT
), state_translucentsi
}, 0 },
4777 { STATE_RENDER(WINED3DRS_STENCILENABLE
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
}, 0 },
4778 { STATE_RENDER(WINED3DRS_STENCILFAIL
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
}, 0 },
4779 { STATE_RENDER(WINED3DRS_STENCILZFAIL
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
}, 0 },
4780 { STATE_RENDER(WINED3DRS_STENCILPASS
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
}, 0 },
4781 { STATE_RENDER(WINED3DRS_STENCILFUNC
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
}, 0 },
4782 { STATE_RENDER(WINED3DRS_STENCILREF
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
}, 0 },
4783 { STATE_RENDER(WINED3DRS_STENCILMASK
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
}, 0 },
4784 { STATE_RENDER(WINED3DRS_STENCILWRITEMASK
), { STATE_RENDER(WINED3DRS_STENCILWRITEMASK
), state_stencilwrite2s
}, EXT_STENCIL_TWO_SIDE
},
4785 { STATE_RENDER(WINED3DRS_STENCILWRITEMASK
), { STATE_RENDER(WINED3DRS_STENCILWRITEMASK
), state_stencilwrite
}, 0 },
4786 { STATE_RENDER(WINED3DRS_TWOSIDEDSTENCILMODE
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
}, 0 },
4787 { STATE_RENDER(WINED3DRS_CCW_STENCILFAIL
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
}, 0 },
4788 { STATE_RENDER(WINED3DRS_CCW_STENCILZFAIL
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
}, 0 },
4789 { STATE_RENDER(WINED3DRS_CCW_STENCILPASS
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
}, 0 },
4790 { STATE_RENDER(WINED3DRS_CCW_STENCILFUNC
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
}, 0 },
4791 { STATE_RENDER(WINED3DRS_WRAP0
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, 0 },
4792 { STATE_RENDER(WINED3DRS_WRAP1
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, 0 },
4793 { STATE_RENDER(WINED3DRS_WRAP2
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, 0 },
4794 { STATE_RENDER(WINED3DRS_WRAP3
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, 0 },
4795 { STATE_RENDER(WINED3DRS_WRAP4
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, 0 },
4796 { STATE_RENDER(WINED3DRS_WRAP5
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, 0 },
4797 { STATE_RENDER(WINED3DRS_WRAP6
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, 0 },
4798 { STATE_RENDER(WINED3DRS_WRAP7
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, 0 },
4799 { STATE_RENDER(WINED3DRS_WRAP8
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, 0 },
4800 { STATE_RENDER(WINED3DRS_WRAP9
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, 0 },
4801 { STATE_RENDER(WINED3DRS_WRAP10
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, 0 },
4802 { STATE_RENDER(WINED3DRS_WRAP11
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, 0 },
4803 { STATE_RENDER(WINED3DRS_WRAP12
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, 0 },
4804 { STATE_RENDER(WINED3DRS_WRAP13
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, 0 },
4805 { STATE_RENDER(WINED3DRS_WRAP14
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, 0 },
4806 { STATE_RENDER(WINED3DRS_WRAP15
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, 0 },
4807 { STATE_RENDER(WINED3DRS_EXTENTS
), { STATE_RENDER(WINED3DRS_EXTENTS
), state_extents
}, 0 },
4808 { STATE_RENDER(WINED3DRS_COLORKEYBLENDENABLE
), { STATE_RENDER(WINED3DRS_COLORKEYBLENDENABLE
), state_ckeyblend
}, 0 },
4809 { STATE_RENDER(WINED3DRS_PATCHEDGESTYLE
), { STATE_RENDER(WINED3DRS_PATCHEDGESTYLE
), state_patchedgestyle
}, 0 },
4810 { STATE_RENDER(WINED3DRS_PATCHSEGMENTS
), { STATE_RENDER(WINED3DRS_PATCHSEGMENTS
), state_patchsegments
}, 0 },
4811 { STATE_RENDER(WINED3DRS_POSITIONDEGREE
), { STATE_RENDER(WINED3DRS_POSITIONDEGREE
), state_positiondegree
}, 0 },
4812 { STATE_RENDER(WINED3DRS_NORMALDEGREE
), { STATE_RENDER(WINED3DRS_NORMALDEGREE
), state_normaldegree
}, 0 },
4813 { STATE_RENDER(WINED3DRS_MINTESSELLATIONLEVEL
), { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), state_tessellation
}, 0 },
4814 { STATE_RENDER(WINED3DRS_MAXTESSELLATIONLEVEL
), { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), state_tessellation
}, 0 },
4815 { STATE_RENDER(WINED3DRS_ADAPTIVETESS_X
), { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), state_tessellation
}, 0 },
4816 { STATE_RENDER(WINED3DRS_ADAPTIVETESS_Y
), { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), state_tessellation
}, 0 },
4817 { STATE_RENDER(WINED3DRS_ADAPTIVETESS_Z
), { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), state_tessellation
}, 0 },
4818 { STATE_RENDER(WINED3DRS_ADAPTIVETESS_W
), { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), state_tessellation
}, 0 },
4819 { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), state_tessellation
}, 0 },
4820 { STATE_RENDER(WINED3DRS_MULTISAMPLEANTIALIAS
), { STATE_RENDER(WINED3DRS_MULTISAMPLEANTIALIAS
), state_msaa
}, ARB_MULTISAMPLE
},
4821 { STATE_RENDER(WINED3DRS_MULTISAMPLEANTIALIAS
), { STATE_RENDER(WINED3DRS_MULTISAMPLEANTIALIAS
), state_msaa_w
}, 0 },
4822 { STATE_RENDER(WINED3DRS_MULTISAMPLEMASK
), { STATE_RENDER(WINED3DRS_MULTISAMPLEMASK
), state_multisampmask
}, 0 },
4823 { STATE_RENDER(WINED3DRS_COLORWRITEENABLE
), { STATE_RENDER(WINED3DRS_COLORWRITEENABLE
), state_colorwrite
}, 0 },
4824 { STATE_RENDER(WINED3DRS_BLENDOP
), { STATE_RENDER(WINED3DRS_BLENDOP
), state_blendop
}, EXT_BLEND_MINMAX
},
4825 { STATE_RENDER(WINED3DRS_BLENDOP
), { STATE_RENDER(WINED3DRS_BLENDOP
), state_blendop_w
}, 0 },
4826 { STATE_RENDER(WINED3DRS_SCISSORTESTENABLE
), { STATE_RENDER(WINED3DRS_SCISSORTESTENABLE
), state_scissor
}, 0 },
4827 { STATE_RENDER(WINED3DRS_SLOPESCALEDEPTHBIAS
), { STATE_RENDER(WINED3DRS_DEPTHBIAS
), state_depthbias
}, 0 },
4828 { STATE_RENDER(WINED3DRS_COLORWRITEENABLE1
), { STATE_RENDER(WINED3DRS_COLORWRITEENABLE
), state_colorwrite
}, 0 },
4829 { STATE_RENDER(WINED3DRS_COLORWRITEENABLE2
), { STATE_RENDER(WINED3DRS_COLORWRITEENABLE
), state_colorwrite
}, 0 },
4830 { STATE_RENDER(WINED3DRS_COLORWRITEENABLE3
), { STATE_RENDER(WINED3DRS_COLORWRITEENABLE
), state_colorwrite
}, 0 },
4831 { STATE_RENDER(WINED3DRS_BLENDFACTOR
), { STATE_RENDER(WINED3DRS_BLENDFACTOR
), state_blendfactor
}, EXT_BLEND_COLOR
},
4832 { STATE_RENDER(WINED3DRS_BLENDFACTOR
), { STATE_RENDER(WINED3DRS_BLENDFACTOR
), state_blendfactor_w
}, 0 },
4833 { STATE_RENDER(WINED3DRS_DEPTHBIAS
), { STATE_RENDER(WINED3DRS_DEPTHBIAS
), state_depthbias
}, 0 },
4835 { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler
}, 0 },
4836 { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler
}, 0 },
4837 { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler
}, 0 },
4838 { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler
}, 0 },
4839 { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler
}, 0 },
4840 { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler
}, 0 },
4841 { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler
}, 0 },
4842 { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler
}, 0 },
4843 { STATE_SAMPLER(8), { STATE_SAMPLER(8), sampler
}, 0 },
4844 { STATE_SAMPLER(9), { STATE_SAMPLER(9), sampler
}, 0 },
4845 { STATE_SAMPLER(10), { STATE_SAMPLER(10), sampler
}, 0 },
4846 { STATE_SAMPLER(11), { STATE_SAMPLER(11), sampler
}, 0 },
4847 { STATE_SAMPLER(12), { STATE_SAMPLER(12), sampler
}, 0 },
4848 { STATE_SAMPLER(13), { STATE_SAMPLER(13), sampler
}, 0 },
4849 { STATE_SAMPLER(14), { STATE_SAMPLER(14), sampler
}, 0 },
4850 { STATE_SAMPLER(15), { STATE_SAMPLER(15), sampler
}, 0 },
4851 { STATE_SAMPLER(16), /* Vertex sampler 0 */ { STATE_SAMPLER(16), sampler
}, 0 },
4852 { STATE_SAMPLER(17), /* Vertex sampler 1 */ { STATE_SAMPLER(17), sampler
}, 0 },
4853 { STATE_SAMPLER(18), /* Vertex sampler 2 */ { STATE_SAMPLER(18), sampler
}, 0 },
4854 { STATE_SAMPLER(19), /* Vertex sampler 3 */ { STATE_SAMPLER(19), sampler
}, 0 },
4855 {0 /* Terminate */, { 0, 0 }, 0 },
4858 const struct StateEntryTemplate ffp_vertexstate_template
[] = {
4859 { STATE_VDECL
, { STATE_VDECL
, vertexdeclaration
}, 0 },
4860 { STATE_VSHADER
, { STATE_VDECL
, vertexdeclaration
}, 0 },
4861 { STATE_MATERIAL
, { STATE_RENDER(WINED3DRS_SPECULARENABLE
), state_specularenable
}, 0 },
4862 { STATE_RENDER(WINED3DRS_SPECULARENABLE
), { STATE_RENDER(WINED3DRS_SPECULARENABLE
), state_specularenable
}, 0 },
4864 { STATE_CLIPPLANE(0), { STATE_CLIPPLANE(0), clipplane
}, 0 },
4865 { STATE_CLIPPLANE(1), { STATE_CLIPPLANE(1), clipplane
}, 0 },
4866 { STATE_CLIPPLANE(2), { STATE_CLIPPLANE(2), clipplane
}, 0 },
4867 { STATE_CLIPPLANE(3), { STATE_CLIPPLANE(3), clipplane
}, 0 },
4868 { STATE_CLIPPLANE(4), { STATE_CLIPPLANE(4), clipplane
}, 0 },
4869 { STATE_CLIPPLANE(5), { STATE_CLIPPLANE(5), clipplane
}, 0 },
4870 { STATE_CLIPPLANE(6), { STATE_CLIPPLANE(6), clipplane
}, 0 },
4871 { STATE_CLIPPLANE(7), { STATE_CLIPPLANE(7), clipplane
}, 0 },
4872 { STATE_CLIPPLANE(8), { STATE_CLIPPLANE(8), clipplane
}, 0 },
4873 { STATE_CLIPPLANE(9), { STATE_CLIPPLANE(9), clipplane
}, 0 },
4874 { STATE_CLIPPLANE(10), { STATE_CLIPPLANE(10), clipplane
}, 0 },
4875 { STATE_CLIPPLANE(11), { STATE_CLIPPLANE(11), clipplane
}, 0 },
4876 { STATE_CLIPPLANE(12), { STATE_CLIPPLANE(12), clipplane
}, 0 },
4877 { STATE_CLIPPLANE(13), { STATE_CLIPPLANE(13), clipplane
}, 0 },
4878 { STATE_CLIPPLANE(14), { STATE_CLIPPLANE(14), clipplane
}, 0 },
4879 { STATE_CLIPPLANE(15), { STATE_CLIPPLANE(15), clipplane
}, 0 },
4880 { STATE_CLIPPLANE(16), { STATE_CLIPPLANE(16), clipplane
}, 0 },
4881 { STATE_CLIPPLANE(17), { STATE_CLIPPLANE(17), clipplane
}, 0 },
4882 { STATE_CLIPPLANE(18), { STATE_CLIPPLANE(18), clipplane
}, 0 },
4883 { STATE_CLIPPLANE(19), { STATE_CLIPPLANE(19), clipplane
}, 0 },
4884 { STATE_CLIPPLANE(20), { STATE_CLIPPLANE(20), clipplane
}, 0 },
4885 { STATE_CLIPPLANE(21), { STATE_CLIPPLANE(21), clipplane
}, 0 },
4886 { STATE_CLIPPLANE(22), { STATE_CLIPPLANE(22), clipplane
}, 0 },
4887 { STATE_CLIPPLANE(23), { STATE_CLIPPLANE(23), clipplane
}, 0 },
4888 { STATE_CLIPPLANE(24), { STATE_CLIPPLANE(24), clipplane
}, 0 },
4889 { STATE_CLIPPLANE(25), { STATE_CLIPPLANE(25), clipplane
}, 0 },
4890 { STATE_CLIPPLANE(26), { STATE_CLIPPLANE(26), clipplane
}, 0 },
4891 { STATE_CLIPPLANE(27), { STATE_CLIPPLANE(27), clipplane
}, 0 },
4892 { STATE_CLIPPLANE(28), { STATE_CLIPPLANE(28), clipplane
}, 0 },
4893 { STATE_CLIPPLANE(29), { STATE_CLIPPLANE(29), clipplane
}, 0 },
4894 { STATE_CLIPPLANE(30), { STATE_CLIPPLANE(30), clipplane
}, 0 },
4895 { STATE_CLIPPLANE(31), { STATE_CLIPPLANE(31), clipplane
}, 0 },
4897 { STATE_ACTIVELIGHT(0), { STATE_ACTIVELIGHT(0), light
}, 0 },
4898 { STATE_ACTIVELIGHT(1), { STATE_ACTIVELIGHT(1), light
}, 0 },
4899 { STATE_ACTIVELIGHT(2), { STATE_ACTIVELIGHT(2), light
}, 0 },
4900 { STATE_ACTIVELIGHT(3), { STATE_ACTIVELIGHT(3), light
}, 0 },
4901 { STATE_ACTIVELIGHT(4), { STATE_ACTIVELIGHT(4), light
}, 0 },
4902 { STATE_ACTIVELIGHT(5), { STATE_ACTIVELIGHT(5), light
}, 0 },
4903 { STATE_ACTIVELIGHT(6), { STATE_ACTIVELIGHT(6), light
}, 0 },
4904 { STATE_ACTIVELIGHT(7), { STATE_ACTIVELIGHT(7), light
}, 0 },
4906 { STATE_VIEWPORT
, { STATE_VIEWPORT
, viewport_vertexpart
}, 0 },
4907 /* Transform states follow */
4908 { STATE_TRANSFORM(WINED3DTS_VIEW
), { STATE_TRANSFORM(WINED3DTS_VIEW
), transform_view
}, 0 },
4909 { STATE_TRANSFORM(WINED3DTS_PROJECTION
), { STATE_TRANSFORM(WINED3DTS_PROJECTION
), transform_projection
}, 0 },
4910 { STATE_TRANSFORM(WINED3DTS_TEXTURE0
), { STATE_TEXTURESTAGE(0,WINED3DTSS_TEXTURETRANSFORMFLAGS
), transform_texture
}, 0 },
4911 { STATE_TRANSFORM(WINED3DTS_TEXTURE1
), { STATE_TEXTURESTAGE(1,WINED3DTSS_TEXTURETRANSFORMFLAGS
), transform_texture
}, 0 },
4912 { STATE_TRANSFORM(WINED3DTS_TEXTURE2
), { STATE_TEXTURESTAGE(2,WINED3DTSS_TEXTURETRANSFORMFLAGS
), transform_texture
}, 0 },
4913 { STATE_TRANSFORM(WINED3DTS_TEXTURE3
), { STATE_TEXTURESTAGE(3,WINED3DTSS_TEXTURETRANSFORMFLAGS
), transform_texture
}, 0 },
4914 { STATE_TRANSFORM(WINED3DTS_TEXTURE4
), { STATE_TEXTURESTAGE(4,WINED3DTSS_TEXTURETRANSFORMFLAGS
), transform_texture
}, 0 },
4915 { STATE_TRANSFORM(WINED3DTS_TEXTURE5
), { STATE_TEXTURESTAGE(5,WINED3DTSS_TEXTURETRANSFORMFLAGS
), transform_texture
}, 0 },
4916 { STATE_TRANSFORM(WINED3DTS_TEXTURE6
), { STATE_TEXTURESTAGE(6,WINED3DTSS_TEXTURETRANSFORMFLAGS
), transform_texture
}, 0 },
4917 { STATE_TRANSFORM(WINED3DTS_TEXTURE7
), { STATE_TEXTURESTAGE(7,WINED3DTSS_TEXTURETRANSFORMFLAGS
), transform_texture
}, 0 },
4918 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 0)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 0)), transform_world
}, 0 },
4919 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 1)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 1)), transform_worldex
}, 0 },
4920 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 2)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 2)), transform_worldex
}, 0 },
4921 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 3)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 3)), transform_worldex
}, 0 },
4922 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 4)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 4)), transform_worldex
}, 0 },
4923 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 5)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 5)), transform_worldex
}, 0 },
4924 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 6)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 6)), transform_worldex
}, 0 },
4925 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 7)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 7)), transform_worldex
}, 0 },
4926 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 8)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 8)), transform_worldex
}, 0 },
4927 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 9)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 9)), transform_worldex
}, 0 },
4928 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 10)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 10)), transform_worldex
}, 0 },
4929 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 11)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 11)), transform_worldex
}, 0 },
4930 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 12)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 12)), transform_worldex
}, 0 },
4931 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 13)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 13)), transform_worldex
}, 0 },
4932 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 14)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 14)), transform_worldex
}, 0 },
4933 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 15)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 15)), transform_worldex
}, 0 },
4934 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 16)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 16)), transform_worldex
}, 0 },
4935 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 17)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 17)), transform_worldex
}, 0 },
4936 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 18)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 18)), transform_worldex
}, 0 },
4937 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 19)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 19)), transform_worldex
}, 0 },
4938 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 20)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 20)), transform_worldex
}, 0 },
4939 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 21)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 21)), transform_worldex
}, 0 },
4940 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 22)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 22)), transform_worldex
}, 0 },
4941 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 23)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 23)), transform_worldex
}, 0 },
4942 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 24)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 24)), transform_worldex
}, 0 },
4943 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 25)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 25)), transform_worldex
}, 0 },
4944 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 26)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 26)), transform_worldex
}, 0 },
4945 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 27)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 27)), transform_worldex
}, 0 },
4946 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 28)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 28)), transform_worldex
}, 0 },
4947 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 29)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 29)), transform_worldex
}, 0 },
4948 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 30)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 30)), transform_worldex
}, 0 },
4949 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 31)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 31)), transform_worldex
}, 0 },
4950 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 32)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 32)), transform_worldex
}, 0 },
4951 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 33)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 33)), transform_worldex
}, 0 },
4952 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 34)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 34)), transform_worldex
}, 0 },
4953 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 35)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 35)), transform_worldex
}, 0 },
4954 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 36)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 36)), transform_worldex
}, 0 },
4955 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 37)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 37)), transform_worldex
}, 0 },
4956 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 38)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 38)), transform_worldex
}, 0 },
4957 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 39)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 39)), transform_worldex
}, 0 },
4958 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 40)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 40)), transform_worldex
}, 0 },
4959 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 41)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 41)), transform_worldex
}, 0 },
4960 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 42)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 42)), transform_worldex
}, 0 },
4961 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 43)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 43)), transform_worldex
}, 0 },
4962 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 44)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 44)), transform_worldex
}, 0 },
4963 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 45)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 45)), transform_worldex
}, 0 },
4964 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 46)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 46)), transform_worldex
}, 0 },
4965 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 47)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 47)), transform_worldex
}, 0 },
4966 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 48)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 48)), transform_worldex
}, 0 },
4967 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 49)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 49)), transform_worldex
}, 0 },
4968 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 50)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 50)), transform_worldex
}, 0 },
4969 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 51)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 51)), transform_worldex
}, 0 },
4970 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 52)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 52)), transform_worldex
}, 0 },
4971 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 53)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 53)), transform_worldex
}, 0 },
4972 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 54)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 54)), transform_worldex
}, 0 },
4973 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 55)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 55)), transform_worldex
}, 0 },
4974 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 56)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 56)), transform_worldex
}, 0 },
4975 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 57)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 57)), transform_worldex
}, 0 },
4976 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 58)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 58)), transform_worldex
}, 0 },
4977 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 59)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 59)), transform_worldex
}, 0 },
4978 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 60)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 60)), transform_worldex
}, 0 },
4979 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 61)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 61)), transform_worldex
}, 0 },
4980 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 62)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 62)), transform_worldex
}, 0 },
4981 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 63)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 63)), transform_worldex
}, 0 },
4982 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 64)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 64)), transform_worldex
}, 0 },
4983 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 65)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 65)), transform_worldex
}, 0 },
4984 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 66)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 66)), transform_worldex
}, 0 },
4985 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 67)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 67)), transform_worldex
}, 0 },
4986 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 68)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 68)), transform_worldex
}, 0 },
4987 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 69)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 69)), transform_worldex
}, 0 },
4988 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 70)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 70)), transform_worldex
}, 0 },
4989 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 71)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 71)), transform_worldex
}, 0 },
4990 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 72)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 72)), transform_worldex
}, 0 },
4991 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 73)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 73)), transform_worldex
}, 0 },
4992 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 74)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 74)), transform_worldex
}, 0 },
4993 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 75)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 75)), transform_worldex
}, 0 },
4994 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 76)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 76)), transform_worldex
}, 0 },
4995 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 77)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 77)), transform_worldex
}, 0 },
4996 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 78)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 78)), transform_worldex
}, 0 },
4997 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 79)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 79)), transform_worldex
}, 0 },
4998 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 80)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 80)), transform_worldex
}, 0 },
4999 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 81)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 81)), transform_worldex
}, 0 },
5000 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 82)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 82)), transform_worldex
}, 0 },
5001 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 83)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 83)), transform_worldex
}, 0 },
5002 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 84)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 84)), transform_worldex
}, 0 },
5003 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 85)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 85)), transform_worldex
}, 0 },
5004 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 86)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 86)), transform_worldex
}, 0 },
5005 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 87)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 87)), transform_worldex
}, 0 },
5006 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 88)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 88)), transform_worldex
}, 0 },
5007 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 89)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 89)), transform_worldex
}, 0 },
5008 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 90)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 90)), transform_worldex
}, 0 },
5009 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 91)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 91)), transform_worldex
}, 0 },
5010 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 92)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 92)), transform_worldex
}, 0 },
5011 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 93)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 93)), transform_worldex
}, 0 },
5012 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 94)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 94)), transform_worldex
}, 0 },
5013 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 95)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 95)), transform_worldex
}, 0 },
5014 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 96)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 96)), transform_worldex
}, 0 },
5015 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 97)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 97)), transform_worldex
}, 0 },
5016 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 98)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 98)), transform_worldex
}, 0 },
5017 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 99)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 99)), transform_worldex
}, 0 },
5018 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(100)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(100)), transform_worldex
}, 0 },
5019 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(101)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(101)), transform_worldex
}, 0 },
5020 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(102)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(102)), transform_worldex
}, 0 },
5021 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(103)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(103)), transform_worldex
}, 0 },
5022 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(104)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(104)), transform_worldex
}, 0 },
5023 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(105)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(105)), transform_worldex
}, 0 },
5024 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(106)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(106)), transform_worldex
}, 0 },
5025 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(107)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(107)), transform_worldex
}, 0 },
5026 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(108)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(108)), transform_worldex
}, 0 },
5027 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(109)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(109)), transform_worldex
}, 0 },
5028 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(110)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(110)), transform_worldex
}, 0 },
5029 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(111)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(111)), transform_worldex
}, 0 },
5030 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(112)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(112)), transform_worldex
}, 0 },
5031 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(113)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(113)), transform_worldex
}, 0 },
5032 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(114)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(114)), transform_worldex
}, 0 },
5033 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(115)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(115)), transform_worldex
}, 0 },
5034 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(116)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(116)), transform_worldex
}, 0 },
5035 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(117)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(117)), transform_worldex
}, 0 },
5036 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(118)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(118)), transform_worldex
}, 0 },
5037 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(119)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(119)), transform_worldex
}, 0 },
5038 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(120)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(120)), transform_worldex
}, 0 },
5039 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(121)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(121)), transform_worldex
}, 0 },
5040 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(122)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(122)), transform_worldex
}, 0 },
5041 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(123)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(123)), transform_worldex
}, 0 },
5042 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(124)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(124)), transform_worldex
}, 0 },
5043 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(125)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(125)), transform_worldex
}, 0 },
5044 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(126)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(126)), transform_worldex
}, 0 },
5045 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(127)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(127)), transform_worldex
}, 0 },
5046 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(128)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(128)), transform_worldex
}, 0 },
5047 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(129)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(129)), transform_worldex
}, 0 },
5048 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(130)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(130)), transform_worldex
}, 0 },
5049 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(131)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(131)), transform_worldex
}, 0 },
5050 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(132)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(132)), transform_worldex
}, 0 },
5051 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(133)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(133)), transform_worldex
}, 0 },
5052 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(134)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(134)), transform_worldex
}, 0 },
5053 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(135)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(135)), transform_worldex
}, 0 },
5054 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(136)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(136)), transform_worldex
}, 0 },
5055 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(137)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(137)), transform_worldex
}, 0 },
5056 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(138)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(138)), transform_worldex
}, 0 },
5057 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(139)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(139)), transform_worldex
}, 0 },
5058 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(140)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(140)), transform_worldex
}, 0 },
5059 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(141)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(141)), transform_worldex
}, 0 },
5060 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(142)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(142)), transform_worldex
}, 0 },
5061 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(143)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(143)), transform_worldex
}, 0 },
5062 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(144)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(144)), transform_worldex
}, 0 },
5063 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(145)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(145)), transform_worldex
}, 0 },
5064 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(146)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(146)), transform_worldex
}, 0 },
5065 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(147)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(147)), transform_worldex
}, 0 },
5066 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(148)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(148)), transform_worldex
}, 0 },
5067 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(149)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(149)), transform_worldex
}, 0 },
5068 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(150)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(150)), transform_worldex
}, 0 },
5069 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(151)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(151)), transform_worldex
}, 0 },
5070 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(152)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(152)), transform_worldex
}, 0 },
5071 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(153)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(153)), transform_worldex
}, 0 },
5072 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(154)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(154)), transform_worldex
}, 0 },
5073 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(155)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(155)), transform_worldex
}, 0 },
5074 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(156)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(156)), transform_worldex
}, 0 },
5075 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(157)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(157)), transform_worldex
}, 0 },
5076 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(158)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(158)), transform_worldex
}, 0 },
5077 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(159)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(159)), transform_worldex
}, 0 },
5078 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(160)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(160)), transform_worldex
}, 0 },
5079 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(161)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(161)), transform_worldex
}, 0 },
5080 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(162)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(162)), transform_worldex
}, 0 },
5081 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(163)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(163)), transform_worldex
}, 0 },
5082 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(164)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(164)), transform_worldex
}, 0 },
5083 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(165)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(165)), transform_worldex
}, 0 },
5084 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(166)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(166)), transform_worldex
}, 0 },
5085 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(167)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(167)), transform_worldex
}, 0 },
5086 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(168)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(168)), transform_worldex
}, 0 },
5087 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(169)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(169)), transform_worldex
}, 0 },
5088 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(170)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(170)), transform_worldex
}, 0 },
5089 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(171)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(171)), transform_worldex
}, 0 },
5090 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(172)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(172)), transform_worldex
}, 0 },
5091 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(173)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(173)), transform_worldex
}, 0 },
5092 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(174)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(174)), transform_worldex
}, 0 },
5093 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(175)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(175)), transform_worldex
}, 0 },
5094 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(176)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(176)), transform_worldex
}, 0 },
5095 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(177)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(177)), transform_worldex
}, 0 },
5096 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(178)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(178)), transform_worldex
}, 0 },
5097 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(179)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(179)), transform_worldex
}, 0 },
5098 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(180)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(180)), transform_worldex
}, 0 },
5099 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(181)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(181)), transform_worldex
}, 0 },
5100 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(182)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(182)), transform_worldex
}, 0 },
5101 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(183)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(183)), transform_worldex
}, 0 },
5102 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(184)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(184)), transform_worldex
}, 0 },
5103 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(185)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(185)), transform_worldex
}, 0 },
5104 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(186)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(186)), transform_worldex
}, 0 },
5105 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(187)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(187)), transform_worldex
}, 0 },
5106 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(188)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(188)), transform_worldex
}, 0 },
5107 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(189)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(189)), transform_worldex
}, 0 },
5108 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(190)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(190)), transform_worldex
}, 0 },
5109 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(191)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(191)), transform_worldex
}, 0 },
5110 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(192)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(192)), transform_worldex
}, 0 },
5111 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(193)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(193)), transform_worldex
}, 0 },
5112 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(194)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(194)), transform_worldex
}, 0 },
5113 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(195)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(195)), transform_worldex
}, 0 },
5114 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(196)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(196)), transform_worldex
}, 0 },
5115 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(197)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(197)), transform_worldex
}, 0 },
5116 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(198)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(198)), transform_worldex
}, 0 },
5117 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(199)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(199)), transform_worldex
}, 0 },
5118 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(200)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(200)), transform_worldex
}, 0 },
5119 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(201)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(201)), transform_worldex
}, 0 },
5120 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(202)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(202)), transform_worldex
}, 0 },
5121 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(203)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(203)), transform_worldex
}, 0 },
5122 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(204)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(204)), transform_worldex
}, 0 },
5123 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(205)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(205)), transform_worldex
}, 0 },
5124 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(206)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(206)), transform_worldex
}, 0 },
5125 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(207)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(207)), transform_worldex
}, 0 },
5126 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(208)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(208)), transform_worldex
}, 0 },
5127 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(209)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(209)), transform_worldex
}, 0 },
5128 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(210)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(210)), transform_worldex
}, 0 },
5129 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(211)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(211)), transform_worldex
}, 0 },
5130 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(212)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(212)), transform_worldex
}, 0 },
5131 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(213)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(213)), transform_worldex
}, 0 },
5132 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(214)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(214)), transform_worldex
}, 0 },
5133 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(215)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(215)), transform_worldex
}, 0 },
5134 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(216)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(216)), transform_worldex
}, 0 },
5135 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(217)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(217)), transform_worldex
}, 0 },
5136 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(218)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(218)), transform_worldex
}, 0 },
5137 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(219)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(219)), transform_worldex
}, 0 },
5138 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(220)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(220)), transform_worldex
}, 0 },
5139 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(221)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(221)), transform_worldex
}, 0 },
5140 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(222)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(222)), transform_worldex
}, 0 },
5141 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(223)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(223)), transform_worldex
}, 0 },
5142 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(224)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(224)), transform_worldex
}, 0 },
5143 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(225)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(225)), transform_worldex
}, 0 },
5144 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(226)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(226)), transform_worldex
}, 0 },
5145 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(227)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(227)), transform_worldex
}, 0 },
5146 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(228)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(228)), transform_worldex
}, 0 },
5147 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(229)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(229)), transform_worldex
}, 0 },
5148 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(230)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(230)), transform_worldex
}, 0 },
5149 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(231)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(231)), transform_worldex
}, 0 },
5150 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(232)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(232)), transform_worldex
}, 0 },
5151 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(233)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(233)), transform_worldex
}, 0 },
5152 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(234)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(234)), transform_worldex
}, 0 },
5153 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(235)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(235)), transform_worldex
}, 0 },
5154 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(236)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(236)), transform_worldex
}, 0 },
5155 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(237)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(237)), transform_worldex
}, 0 },
5156 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(238)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(238)), transform_worldex
}, 0 },
5157 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(239)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(239)), transform_worldex
}, 0 },
5158 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(240)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(240)), transform_worldex
}, 0 },
5159 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(241)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(241)), transform_worldex
}, 0 },
5160 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(242)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(242)), transform_worldex
}, 0 },
5161 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(243)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(243)), transform_worldex
}, 0 },
5162 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(244)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(244)), transform_worldex
}, 0 },
5163 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(245)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(245)), transform_worldex
}, 0 },
5164 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(246)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(246)), transform_worldex
}, 0 },
5165 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(247)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(247)), transform_worldex
}, 0 },
5166 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(248)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(248)), transform_worldex
}, 0 },
5167 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(249)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(249)), transform_worldex
}, 0 },
5168 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(250)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(250)), transform_worldex
}, 0 },
5169 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(251)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(251)), transform_worldex
}, 0 },
5170 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(252)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(252)), transform_worldex
}, 0 },
5171 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(253)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(253)), transform_worldex
}, 0 },
5172 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(254)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(254)), transform_worldex
}, 0 },
5173 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(255)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(255)), transform_worldex
}, 0 },
5174 { STATE_TEXTURESTAGE(0,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(0,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, 0 },
5175 { STATE_TEXTURESTAGE(1,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(1,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, 0 },
5176 { STATE_TEXTURESTAGE(2,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(2,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, 0 },
5177 { STATE_TEXTURESTAGE(3,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(3,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, 0 },
5178 { STATE_TEXTURESTAGE(4,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(4,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, 0 },
5179 { STATE_TEXTURESTAGE(5,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(5,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, 0 },
5180 { STATE_TEXTURESTAGE(6,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(6,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, 0 },
5181 { STATE_TEXTURESTAGE(7,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(7,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, 0 },
5182 { STATE_TEXTURESTAGE(0, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(0, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, 0 },
5183 { STATE_TEXTURESTAGE(1, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(1, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, 0 },
5184 { STATE_TEXTURESTAGE(2, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(2, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, 0 },
5185 { STATE_TEXTURESTAGE(3, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(3, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, 0 },
5186 { STATE_TEXTURESTAGE(4, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(4, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, 0 },
5187 { STATE_TEXTURESTAGE(5, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(5, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, 0 },
5188 { STATE_TEXTURESTAGE(6, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(6, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, 0 },
5189 { STATE_TEXTURESTAGE(7, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(7, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, 0 },
5191 { STATE_RENDER(WINED3DRS_FOGENABLE
), { STATE_RENDER(WINED3DRS_FOGENABLE
), state_fog_vertexpart
}, 0 },
5192 { STATE_RENDER(WINED3DRS_FOGTABLEMODE
), { STATE_RENDER(WINED3DRS_FOGENABLE
), state_fog_vertexpart
}, 0 },
5193 { STATE_RENDER(WINED3DRS_FOGVERTEXMODE
), { STATE_RENDER(WINED3DRS_FOGENABLE
), state_fog_vertexpart
}, 0 },
5194 { STATE_RENDER(WINED3DRS_RANGEFOGENABLE
), { STATE_RENDER(WINED3DRS_RANGEFOGENABLE
), state_rangefog
}, NV_FOG_DISTANCE
},
5195 { STATE_RENDER(WINED3DRS_RANGEFOGENABLE
), { STATE_RENDER(WINED3DRS_RANGEFOGENABLE
), state_rangefog_w
}, 0 },
5196 { STATE_RENDER(WINED3DRS_CLIPPING
), { STATE_RENDER(WINED3DRS_CLIPPING
), state_clipping
}, 0 },
5197 { STATE_RENDER(WINED3DRS_CLIPPLANEENABLE
), { STATE_RENDER(WINED3DRS_CLIPPING
), state_clipping
}, 0 },
5198 { STATE_RENDER(WINED3DRS_LIGHTING
), { STATE_RENDER(WINED3DRS_LIGHTING
), state_lighting
}, 0 },
5199 { STATE_RENDER(WINED3DRS_AMBIENT
), { STATE_RENDER(WINED3DRS_AMBIENT
), state_ambient
}, 0 },
5200 { STATE_RENDER(WINED3DRS_COLORVERTEX
), { STATE_RENDER(WINED3DRS_COLORVERTEX
), state_colormat
}, 0 },
5201 { STATE_RENDER(WINED3DRS_LOCALVIEWER
), { STATE_RENDER(WINED3DRS_LOCALVIEWER
), state_localviewer
}, 0 },
5202 { STATE_RENDER(WINED3DRS_NORMALIZENORMALS
), { STATE_RENDER(WINED3DRS_NORMALIZENORMALS
), state_normalize
}, 0 },
5203 { STATE_RENDER(WINED3DRS_DIFFUSEMATERIALSOURCE
), { STATE_RENDER(WINED3DRS_COLORVERTEX
), state_colormat
}, 0 },
5204 { STATE_RENDER(WINED3DRS_SPECULARMATERIALSOURCE
), { STATE_RENDER(WINED3DRS_COLORVERTEX
), state_colormat
}, 0 },
5205 { STATE_RENDER(WINED3DRS_AMBIENTMATERIALSOURCE
), { STATE_RENDER(WINED3DRS_COLORVERTEX
), state_colormat
}, 0 },
5206 { STATE_RENDER(WINED3DRS_EMISSIVEMATERIALSOURCE
), { STATE_RENDER(WINED3DRS_COLORVERTEX
), state_colormat
}, 0 },
5207 { STATE_RENDER(WINED3DRS_VERTEXBLEND
), { STATE_RENDER(WINED3DRS_VERTEXBLEND
), state_vertexblend
}, ARB_VERTEX_BLEND
},
5208 { STATE_RENDER(WINED3DRS_VERTEXBLEND
), { STATE_RENDER(WINED3DRS_VERTEXBLEND
), state_vertexblend_w
}, 0 },
5209 { STATE_RENDER(WINED3DRS_POINTSIZE
), { STATE_RENDER(WINED3DRS_POINTSCALEENABLE
), state_pscale
}, 0 },
5210 { STATE_RENDER(WINED3DRS_POINTSIZE_MIN
), { STATE_RENDER(WINED3DRS_POINTSIZE_MIN
), state_psizemin_arb
}, ARB_POINT_PARAMETERS
},
5211 { STATE_RENDER(WINED3DRS_POINTSIZE_MIN
), { STATE_RENDER(WINED3DRS_POINTSIZE_MIN
), state_psizemin_ext
}, EXT_POINT_PARAMETERS
},
5212 { STATE_RENDER(WINED3DRS_POINTSIZE_MIN
), { STATE_RENDER(WINED3DRS_POINTSIZE_MIN
), state_psizemin_w
}, 0 },
5213 { STATE_RENDER(WINED3DRS_POINTSPRITEENABLE
), { STATE_RENDER(WINED3DRS_POINTSPRITEENABLE
), state_pointsprite
}, ARB_POINT_SPRITE
},
5214 { STATE_RENDER(WINED3DRS_POINTSPRITEENABLE
), { STATE_RENDER(WINED3DRS_POINTSPRITEENABLE
), state_pointsprite_w
}, 0 },
5215 { STATE_RENDER(WINED3DRS_POINTSCALEENABLE
), { STATE_RENDER(WINED3DRS_POINTSCALEENABLE
), state_pscale
}, 0 },
5216 { STATE_RENDER(WINED3DRS_POINTSCALE_A
), { STATE_RENDER(WINED3DRS_POINTSCALEENABLE
), state_pscale
}, 0 },
5217 { STATE_RENDER(WINED3DRS_POINTSCALE_B
), { STATE_RENDER(WINED3DRS_POINTSCALEENABLE
), state_pscale
}, 0 },
5218 { STATE_RENDER(WINED3DRS_POINTSCALE_C
), { STATE_RENDER(WINED3DRS_POINTSCALEENABLE
), state_pscale
}, 0 },
5219 { STATE_RENDER(WINED3DRS_POINTSIZE_MAX
), { STATE_RENDER(WINED3DRS_POINTSIZE_MIN
), state_psizemin_arb
}, ARB_POINT_PARAMETERS
},
5220 { STATE_RENDER(WINED3DRS_POINTSIZE_MAX
), { STATE_RENDER(WINED3DRS_POINTSIZE_MIN
), state_psizemin_ext
}, EXT_POINT_PARAMETERS
},
5221 { STATE_RENDER(WINED3DRS_POINTSIZE_MAX
), { STATE_RENDER(WINED3DRS_POINTSIZE_MIN
), state_psizemin_w
}, 0 },
5222 /* Samplers for NP2 texture matrix adjustions. They are not needed if GL_ARB_texture_non_power_of_two is supported,
5223 * so register a NULL state handler in that case to get the vertex part of sampler() skipped(VTF is handled in the misc states.
5224 * otherwise, register sampler_texmatrix, which takes care of updating the texture matrix
5226 { STATE_SAMPLER(0), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5227 { STATE_SAMPLER(0), { 0, NULL
}, WINE_NORMALIZED_TEXRECT
},
5228 { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texmatrix
}, 0 },
5229 { STATE_SAMPLER(1), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5230 { STATE_SAMPLER(1), { 0, NULL
}, WINE_NORMALIZED_TEXRECT
},
5231 { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texmatrix
}, 0 },
5232 { STATE_SAMPLER(2), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5233 { STATE_SAMPLER(2), { 0, NULL
}, WINE_NORMALIZED_TEXRECT
},
5234 { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texmatrix
}, 0 },
5235 { STATE_SAMPLER(3), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5236 { STATE_SAMPLER(3), { 0, NULL
}, WINE_NORMALIZED_TEXRECT
},
5237 { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler_texmatrix
}, 0 },
5238 { STATE_SAMPLER(4), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5239 { STATE_SAMPLER(4), { 0, NULL
}, WINE_NORMALIZED_TEXRECT
},
5240 { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler_texmatrix
}, 0 },
5241 { STATE_SAMPLER(5), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5242 { STATE_SAMPLER(5), { 0, NULL
}, WINE_NORMALIZED_TEXRECT
},
5243 { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler_texmatrix
}, 0 },
5244 { STATE_SAMPLER(6), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5245 { STATE_SAMPLER(6), { 0, NULL
}, WINE_NORMALIZED_TEXRECT
},
5246 { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler_texmatrix
}, 0 },
5247 { STATE_SAMPLER(7), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5248 { STATE_SAMPLER(7), { 0, NULL
}, WINE_NORMALIZED_TEXRECT
},
5249 { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texmatrix
}, 0 },
5250 {0 /* Terminate */, { 0, 0 }, 0 },
5253 static const struct StateEntryTemplate ffp_fragmentstate_template
[] = {
5254 { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5255 { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5256 { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5257 { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5258 { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5259 { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5260 { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5261 { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5262 { STATE_TEXTURESTAGE(0, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5263 { STATE_TEXTURESTAGE(0, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl
}, 0 },
5264 { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5265 { STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5266 { STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5267 { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5268 { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5269 { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5270 { STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5271 { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5272 { STATE_TEXTURESTAGE(1, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5273 { STATE_TEXTURESTAGE(1, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl
}, 0 },
5274 { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5275 { STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5276 { STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5277 { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5278 { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5279 { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5280 { STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5281 { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5282 { STATE_TEXTURESTAGE(2, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5283 { STATE_TEXTURESTAGE(2, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl
}, 0 },
5284 { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5285 { STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5286 { STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5287 { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5288 { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5289 { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5290 { STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5291 { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5292 { STATE_TEXTURESTAGE(3, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5293 { STATE_TEXTURESTAGE(3, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl
}, 0 },
5294 { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5295 { STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5296 { STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5297 { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5298 { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5299 { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5300 { STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5301 { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5302 { STATE_TEXTURESTAGE(4, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5303 { STATE_TEXTURESTAGE(4, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl
}, 0 },
5304 { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5305 { STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5306 { STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5307 { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5308 { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5309 { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5310 { STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5311 { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5312 { STATE_TEXTURESTAGE(5, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5313 { STATE_TEXTURESTAGE(5, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl
}, 0 },
5314 { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5315 { STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5316 { STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5317 { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5318 { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5319 { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5320 { STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5321 { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5322 { STATE_TEXTURESTAGE(6, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5323 { STATE_TEXTURESTAGE(6, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl
}, 0 },
5324 { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5325 { STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5326 { STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5327 { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5328 { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5329 { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5330 { STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5331 { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP
), tex_alphaop
}, 0 },
5332 { STATE_TEXTURESTAGE(7, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP
), tex_colorop
}, 0 },
5333 { STATE_TEXTURESTAGE(7, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl
}, 0 },
5334 { STATE_PIXELSHADER
, { STATE_PIXELSHADER
, apply_pixelshader
}, 0 },
5335 { STATE_RENDER(WINED3DRS_SRGBWRITEENABLE
), { STATE_PIXELSHADER
, apply_pixelshader
}, 0 },
5336 { STATE_RENDER(WINED3DRS_BORDERCOLOR
), { STATE_RENDER(WINED3DRS_BORDERCOLOR
), state_bordercolor
}, 0 },
5337 { STATE_RENDER(WINED3DRS_TEXTUREFACTOR
), { STATE_RENDER(WINED3DRS_TEXTUREFACTOR
), state_texfactor
}, 0 },
5338 { STATE_RENDER(WINED3DRS_FOGCOLOR
), { STATE_RENDER(WINED3DRS_FOGCOLOR
), state_fogcolor
}, 0 },
5339 { STATE_RENDER(WINED3DRS_FOGDENSITY
), { STATE_RENDER(WINED3DRS_FOGDENSITY
), state_fogdensity
}, 0 },
5340 { STATE_RENDER(WINED3DRS_FOGENABLE
), { STATE_RENDER(WINED3DRS_FOGENABLE
), state_fog_fragpart
}, 0 },
5341 { STATE_RENDER(WINED3DRS_FOGTABLEMODE
), { STATE_RENDER(WINED3DRS_FOGENABLE
), state_fog_fragpart
}, 0 },
5342 { STATE_RENDER(WINED3DRS_FOGVERTEXMODE
), { STATE_RENDER(WINED3DRS_FOGENABLE
), state_fog_fragpart
}, 0 },
5343 { STATE_RENDER(WINED3DRS_FOGSTART
), { STATE_RENDER(WINED3DRS_FOGSTART
), state_fogstartend
}, 0 },
5344 { STATE_RENDER(WINED3DRS_FOGEND
), { STATE_RENDER(WINED3DRS_FOGSTART
), state_fogstartend
}, 0 },
5345 { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texdim
}, 0 },
5346 { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texdim
}, 0 },
5347 { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texdim
}, 0 },
5348 { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler_texdim
}, 0 },
5349 { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler_texdim
}, 0 },
5350 { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler_texdim
}, 0 },
5351 { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler_texdim
}, 0 },
5352 { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texdim
}, 0 },
5353 {0 /* Terminate */, { 0, 0 }, 0 },
5355 #undef GLINFO_LOCATION
5357 #define GLINFO_LOCATION (*gl_info)
5358 static void ffp_enable(IWineD3DDevice
*iface
, BOOL enable
) { }
5360 static void ffp_fragment_get_caps(WINED3DDEVTYPE devtype
, const WineD3D_GL_Info
*gl_info
, struct fragment_caps
*pCaps
)
5362 pCaps
->TextureOpCaps
= WINED3DTEXOPCAPS_ADD
|
5363 WINED3DTEXOPCAPS_ADDSIGNED
|
5364 WINED3DTEXOPCAPS_ADDSIGNED2X
|
5365 WINED3DTEXOPCAPS_MODULATE
|
5366 WINED3DTEXOPCAPS_MODULATE2X
|
5367 WINED3DTEXOPCAPS_MODULATE4X
|
5368 WINED3DTEXOPCAPS_SELECTARG1
|
5369 WINED3DTEXOPCAPS_SELECTARG2
|
5370 WINED3DTEXOPCAPS_DISABLE
;
5372 if (GL_SUPPORT(ARB_TEXTURE_ENV_COMBINE
) ||
5373 GL_SUPPORT(EXT_TEXTURE_ENV_COMBINE
) ||
5374 GL_SUPPORT(NV_TEXTURE_ENV_COMBINE4
)) {
5375 pCaps
->TextureOpCaps
|= WINED3DTEXOPCAPS_BLENDDIFFUSEALPHA
|
5376 WINED3DTEXOPCAPS_BLENDTEXTUREALPHA
|
5377 WINED3DTEXOPCAPS_BLENDFACTORALPHA
|
5378 WINED3DTEXOPCAPS_BLENDCURRENTALPHA
|
5379 WINED3DTEXOPCAPS_LERP
|
5380 WINED3DTEXOPCAPS_SUBTRACT
;
5382 if (GL_SUPPORT(ATI_TEXTURE_ENV_COMBINE3
) ||
5383 GL_SUPPORT(NV_TEXTURE_ENV_COMBINE4
)) {
5384 pCaps
->TextureOpCaps
|= WINED3DTEXOPCAPS_ADDSMOOTH
|
5385 WINED3DTEXOPCAPS_MULTIPLYADD
|
5386 WINED3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR
|
5387 WINED3DTEXOPCAPS_MODULATECOLOR_ADDALPHA
|
5388 WINED3DTEXOPCAPS_BLENDTEXTUREALPHAPM
;
5390 if (GL_SUPPORT(ARB_TEXTURE_ENV_DOT3
))
5391 pCaps
->TextureOpCaps
|= WINED3DTEXOPCAPS_DOTPRODUCT3
;
5393 pCaps
->MaxTextureBlendStages
= GL_LIMITS(texture_stages
);
5394 pCaps
->MaxSimultaneousTextures
= GL_LIMITS(textures
);
5397 static HRESULT
ffp_fragment_alloc(IWineD3DDevice
*iface
) { return WINED3D_OK
; }
5398 static void ffp_fragment_free(IWineD3DDevice
*iface
) {}
5399 static BOOL
ffp_color_fixup_supported(struct color_fixup_desc fixup
)
5403 TRACE("Checking support for fixup:\n");
5404 dump_color_fixup_desc(fixup
);
5407 /* We only support identity conversions. */
5408 if (is_identity_fixup(fixup
))
5414 TRACE("[FAILED]\n");
5418 const struct fragment_pipeline ffp_fragment_pipeline
= {
5420 ffp_fragment_get_caps
,
5423 ffp_color_fixup_supported
,
5424 ffp_fragmentstate_template
,
5425 FALSE
/* we cannot disable projected textures. The vertex pipe has to do it */
5428 static unsigned int num_handlers(const APPLYSTATEFUNC
*funcs
)
5431 for(i
= 0; funcs
[i
]; i
++);
5435 static void multistate_apply_2(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
5436 stateblock
->wineD3DDevice
->multistate_funcs
[state
][0](state
, stateblock
, context
);
5437 stateblock
->wineD3DDevice
->multistate_funcs
[state
][1](state
, stateblock
, context
);
5440 static void multistate_apply_3(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, WineD3DContext
*context
) {
5441 stateblock
->wineD3DDevice
->multistate_funcs
[state
][0](state
, stateblock
, context
);
5442 stateblock
->wineD3DDevice
->multistate_funcs
[state
][1](state
, stateblock
, context
);
5443 stateblock
->wineD3DDevice
->multistate_funcs
[state
][2](state
, stateblock
, context
);
5446 HRESULT
compile_state_table(struct StateEntry
*StateTable
, APPLYSTATEFUNC
**dev_multistate_funcs
,
5447 const WineD3D_GL_Info
*gl_info
, const struct StateEntryTemplate
*vertex
,
5448 const struct fragment_pipeline
*fragment
, const struct StateEntryTemplate
*misc
)
5450 unsigned int i
, type
, handlers
;
5451 APPLYSTATEFUNC multistate_funcs
[STATE_HIGHEST
+ 1][3];
5452 const struct StateEntryTemplate
*cur
;
5453 BOOL set
[STATE_HIGHEST
+ 1];
5455 memset(multistate_funcs
, 0, sizeof(multistate_funcs
));
5457 for(i
= 0; i
< STATE_HIGHEST
+ 1; i
++) {
5458 StateTable
[i
].representative
= 0;
5459 StateTable
[i
].apply
= state_undefined
;
5462 for(type
= 0; type
< 3; type
++) {
5463 /* This switch decides the order in which the states are applied */
5465 case 0: cur
= misc
; break;
5466 case 1: cur
= fragment
->states
; break;
5467 case 2: cur
= vertex
; break;
5468 default: cur
= NULL
; /* Stupid compiler */
5472 /* GL extension filtering should not prevent multiple handlers being applied from different
5475 memset(set
, 0, sizeof(set
));
5477 for(i
= 0; cur
[i
].state
; i
++) {
5478 APPLYSTATEFUNC
*funcs_array
;
5480 /* Only use the first matching state with the available extension from one template.
5482 * {D3DRS_FOOBAR, {D3DRS_FOOBAR, func1}, XYZ_FANCY},
5483 * {D3DRS_FOOBAR, {D3DRS_FOOBAR, func2}, 0 }
5485 * if GL_XYZ_fancy is supported, ignore the 2nd line
5487 if(set
[cur
[i
].state
]) continue;
5488 /* Skip state lines depending on unsupported extensions */
5489 if(cur
[i
].extension
&& !GL_SUPPORT(cur
[i
].extension
)) continue;
5490 set
[cur
[i
].state
] = TRUE
;
5491 /* In some cases having an extension means that nothing has to be
5492 * done for a state, e.g. if GL_ARB_texture_non_power_of_two is
5493 * supported, the texture coordinate fixup can be ignored. If the
5494 * apply function is used, mark the state set(done above) to prevent
5495 * applying later lines, but do not record anything in the state
5498 if(!cur
[i
].content
.apply
) continue;
5500 handlers
= num_handlers(multistate_funcs
[cur
[i
].state
]);
5501 multistate_funcs
[cur
[i
].state
][handlers
] = cur
[i
].content
.apply
;
5504 StateTable
[cur
[i
].state
].apply
= cur
[i
].content
.apply
;
5507 StateTable
[cur
[i
].state
].apply
= multistate_apply_2
;
5508 dev_multistate_funcs
[cur
[i
].state
] = HeapAlloc(GetProcessHeap(),
5510 sizeof(**dev_multistate_funcs
) * 2);
5511 if (!dev_multistate_funcs
[cur
[i
].state
]) {
5515 dev_multistate_funcs
[cur
[i
].state
][0] = multistate_funcs
[cur
[i
].state
][0];
5516 dev_multistate_funcs
[cur
[i
].state
][1] = multistate_funcs
[cur
[i
].state
][1];
5519 StateTable
[cur
[i
].state
].apply
= multistate_apply_3
;
5520 funcs_array
= HeapReAlloc(GetProcessHeap(),
5522 dev_multistate_funcs
[cur
[i
].state
],
5523 sizeof(**dev_multistate_funcs
) * 3);
5528 dev_multistate_funcs
[cur
[i
].state
] = funcs_array
;
5529 dev_multistate_funcs
[cur
[i
].state
][2] = multistate_funcs
[cur
[i
].state
][2];
5532 ERR("Unexpected amount of state handlers for state %u: %u\n",
5533 cur
[i
].state
, handlers
+ 1);
5536 if(StateTable
[cur
[i
].state
].representative
&&
5537 StateTable
[cur
[i
].state
].representative
!= cur
[i
].content
.representative
) {
5538 FIXME("State %u has different representatives in different pipeline parts\n",
5541 StateTable
[cur
[i
].state
].representative
= cur
[i
].content
.representative
;
5548 for (i
= 0; i
<= STATE_HIGHEST
; ++i
) {
5549 HeapFree(GetProcessHeap(), 0, dev_multistate_funcs
[i
]);
5552 memset(dev_multistate_funcs
, 0, (STATE_HIGHEST
+ 1)*sizeof(*dev_multistate_funcs
));
5554 return E_OUTOFMEMORY
;
5556 #undef GLINFO_LOCATION