2 * Direct3D state management
4 * Copyright 2002 Lionel Ulmer
5 * Copyright 2002-2005 Jason Edmeades
6 * Copyright 2003-2004 Raphael Junqueira
7 * Copyright 2004 Christian Costa
8 * Copyright 2005 Oliver Stieber
9 * Copyright 2006 Henri Verbeet
10 * Copyright 2006-2008 Stefan Dösinger for CodeWeavers
11 * Copyright 2009 Henri Verbeet for CodeWeavers
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 2.1 of the License, or (at your option) any later version.
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this library; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
33 #include "wined3d_private.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(d3d
);
36 WINE_DECLARE_DEBUG_CHANNEL(d3d_shader
);
38 #define GLINFO_LOCATION (*context->gl_info)
40 /* GL locking for state handlers is done by the caller. */
42 static void state_blendop(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
);
44 static void state_nogl(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
46 /* Used for states which are not mapped to a gl state as-is, but used somehow different,
47 * e.g as a parameter for drawing, or which are unimplemented in windows d3d
49 if(STATE_IS_RENDER(state
)) {
50 WINED3DRENDERSTATETYPE RenderState
= state
- STATE_RENDER(0);
51 TRACE("(%s,%d) no direct mapping to gl\n", debug_d3drenderstate(RenderState
), stateblock
->renderState
[RenderState
]);
53 /* Shouldn't have an unknown type here */
54 FIXME("%d no direct mapping to gl of state with unknown type\n", state
);
58 static void state_undefined(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
60 ERR("Undefined state.\n");
63 static void state_fillmode(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*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
, struct wined3d_context
*context
)
87 /* Lighting is not enabled if transformed vertices are drawn
88 * but lighting does not affect the stream sources, so it is not grouped for performance reasons.
89 * This state reads the decoded vertex declaration, so if it is dirty don't do anything. The
90 * vertex declaration applying function calls this function for updating
93 if(isStateDirty(context
, STATE_VDECL
)) {
97 if (stateblock
->renderState
[WINED3DRS_LIGHTING
]
98 && !stateblock
->device
->strided_streams
.position_transformed
)
100 glEnable(GL_LIGHTING
);
101 checkGLcall("glEnable GL_LIGHTING");
103 glDisable(GL_LIGHTING
);
104 checkGLcall("glDisable GL_LIGHTING");
108 static void state_zenable(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
110 /* No z test without depth stencil buffers */
111 if (!stateblock
->device
->stencilBufferTarget
)
113 TRACE("No Z buffer - disabling depth test\n");
114 glDisable(GL_DEPTH_TEST
); /* This also disables z writing in gl */
115 checkGLcall("glDisable GL_DEPTH_TEST");
119 switch ((WINED3DZBUFFERTYPE
) stateblock
->renderState
[WINED3DRS_ZENABLE
]) {
120 case WINED3DZB_FALSE
:
121 glDisable(GL_DEPTH_TEST
);
122 checkGLcall("glDisable GL_DEPTH_TEST");
125 glEnable(GL_DEPTH_TEST
);
126 checkGLcall("glEnable GL_DEPTH_TEST");
129 glEnable(GL_DEPTH_TEST
);
130 checkGLcall("glEnable GL_DEPTH_TEST");
131 FIXME("W buffer is not well handled\n");
134 FIXME("Unrecognized D3DZBUFFERTYPE value %d\n", stateblock
->renderState
[WINED3DRS_ZENABLE
]);
138 static void state_cullmode(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
140 /* glFrontFace() is set in context.c at context init and on an offscreen / onscreen rendering
143 switch ((WINED3DCULL
) stateblock
->renderState
[WINED3DRS_CULLMODE
]) {
144 case WINED3DCULL_NONE
:
145 glDisable(GL_CULL_FACE
);
146 checkGLcall("glDisable GL_CULL_FACE");
149 glEnable(GL_CULL_FACE
);
150 checkGLcall("glEnable GL_CULL_FACE");
151 glCullFace(GL_FRONT
);
152 checkGLcall("glCullFace(GL_FRONT)");
154 case WINED3DCULL_CCW
:
155 glEnable(GL_CULL_FACE
);
156 checkGLcall("glEnable GL_CULL_FACE");
158 checkGLcall("glCullFace(GL_BACK)");
161 FIXME("Unrecognized/Unhandled WINED3DCULL value %d\n", stateblock
->renderState
[WINED3DRS_CULLMODE
]);
165 static void state_shademode(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
167 switch ((WINED3DSHADEMODE
) stateblock
->renderState
[WINED3DRS_SHADEMODE
]) {
168 case WINED3DSHADE_FLAT
:
169 glShadeModel(GL_FLAT
);
170 checkGLcall("glShadeModel(GL_FLAT)");
172 case WINED3DSHADE_GOURAUD
:
173 glShadeModel(GL_SMOOTH
);
174 checkGLcall("glShadeModel(GL_SMOOTH)");
176 case WINED3DSHADE_PHONG
:
177 FIXME("WINED3DSHADE_PHONG isn't supported\n");
180 FIXME("Unrecognized/Unhandled WINED3DSHADEMODE value %d\n", stateblock
->renderState
[WINED3DRS_SHADEMODE
]);
184 static void state_ditherenable(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
186 if (stateblock
->renderState
[WINED3DRS_DITHERENABLE
]) {
188 checkGLcall("glEnable GL_DITHER");
190 glDisable(GL_DITHER
);
191 checkGLcall("glDisable GL_DITHER");
195 static void state_zwritenable(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
197 /* TODO: Test if in d3d z writing is enabled even if ZENABLE is off. If yes,
198 * this has to be merged with ZENABLE and ZFUNC
200 if (stateblock
->renderState
[WINED3DRS_ZWRITEENABLE
]) {
202 checkGLcall("glDepthMask(1)");
205 checkGLcall("glDepthMask(0)");
209 static void state_zfunc(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
211 int glParm
= CompareFunc(stateblock
->renderState
[WINED3DRS_ZFUNC
]);
214 if(glParm
== GL_EQUAL
|| glParm
== GL_NOTEQUAL
) {
215 static BOOL once
= FALSE
;
216 /* There are a few issues with this: First, our inability to
217 * select a proper Z depth, most of the time we're stuck with
218 * D24S8, even if the app selects D32 or D16. There seem to be
219 * some other precision problems which have to be debugged to
220 * make NOTEQUAL and EQUAL work properly
224 FIXME("D3DCMP_NOTEQUAL and D3DCMP_EQUAL do not work correctly yet\n");
229 checkGLcall("glDepthFunc");
233 static void state_ambient(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
236 D3DCOLORTOGLFLOAT4(stateblock
->renderState
[WINED3DRS_AMBIENT
], col
);
238 TRACE("Setting ambient to (%f,%f,%f,%f)\n", col
[0], col
[1], col
[2], col
[3]);
239 glLightModelfv(GL_LIGHT_MODEL_AMBIENT
, col
);
240 checkGLcall("glLightModel for MODEL_AMBIENT");
243 static void state_blend(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
245 IWineD3DSurfaceImpl
*target
= (IWineD3DSurfaceImpl
*)stateblock
->device
->render_targets
[0];
246 int srcBlend
= GL_ZERO
;
247 int dstBlend
= GL_ZERO
;
249 /* GL_LINE_SMOOTH needs GL_BLEND to work, according to the red book, and special blending params */
250 if (stateblock
->renderState
[WINED3DRS_ALPHABLENDENABLE
] ||
251 stateblock
->renderState
[WINED3DRS_EDGEANTIALIAS
] ||
252 stateblock
->renderState
[WINED3DRS_ANTIALIASEDLINEENABLE
]) {
254 /* Disable blending in all cases even without pixelshaders. With blending on we could face a big performance penalty.
255 * The d3d9 visual test confirms the behavior. */
256 if (context
->render_offscreen
257 && !(target
->resource
.format_desc
->Flags
& WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
))
260 checkGLcall("glDisable GL_BLEND");
264 checkGLcall("glEnable GL_BLEND");
268 checkGLcall("glDisable GL_BLEND");
269 /* Nothing more to do - get out */
273 switch (stateblock
->renderState
[WINED3DRS_DESTBLEND
]) {
274 case WINED3DBLEND_ZERO
: dstBlend
= GL_ZERO
; break;
275 case WINED3DBLEND_ONE
: dstBlend
= GL_ONE
; break;
276 case WINED3DBLEND_SRCCOLOR
: dstBlend
= GL_SRC_COLOR
; break;
277 case WINED3DBLEND_INVSRCCOLOR
: dstBlend
= GL_ONE_MINUS_SRC_COLOR
; break;
278 case WINED3DBLEND_SRCALPHA
: dstBlend
= GL_SRC_ALPHA
; break;
279 case WINED3DBLEND_INVSRCALPHA
: dstBlend
= GL_ONE_MINUS_SRC_ALPHA
; break;
280 case WINED3DBLEND_DESTCOLOR
: dstBlend
= GL_DST_COLOR
; break;
281 case WINED3DBLEND_INVDESTCOLOR
: dstBlend
= GL_ONE_MINUS_DST_COLOR
; break;
283 /* To compensate the lack of format switching with backbuffer offscreen rendering,
284 * and with onscreen rendering, we modify the alpha test parameters for (INV)DESTALPHA
285 * if the render target doesn't support alpha blending. A nonexistent alpha channel
286 * returns 1.0, so D3DBLEND_DESTALPHA is GL_ONE, and D3DBLEND_INVDESTALPHA is GL_ZERO
288 case WINED3DBLEND_DESTALPHA
:
289 dstBlend
= target
->resource
.format_desc
->alpha_mask
? GL_DST_ALPHA
: GL_ONE
;
291 case WINED3DBLEND_INVDESTALPHA
:
292 dstBlend
= target
->resource
.format_desc
->alpha_mask
? GL_ONE_MINUS_DST_ALPHA
: GL_ZERO
;
295 case WINED3DBLEND_SRCALPHASAT
:
296 dstBlend
= GL_SRC_ALPHA_SATURATE
;
297 WARN("Application uses SRCALPHASAT as dest blend factor, expect problems\n");
300 /* WINED3DBLEND_BOTHSRCALPHA and WINED3DBLEND_BOTHINVSRCALPHA are legacy source blending
301 * values which are still valid up to d3d9. They should not occur as dest blend values
303 case WINED3DBLEND_BOTHSRCALPHA
: dstBlend
= GL_SRC_ALPHA
;
304 srcBlend
= GL_SRC_ALPHA
;
305 FIXME("WINED3DRS_DESTBLEND = WINED3DBLEND_BOTHSRCALPHA, what to do?\n");
308 case WINED3DBLEND_BOTHINVSRCALPHA
: dstBlend
= GL_ONE_MINUS_SRC_ALPHA
;
309 srcBlend
= GL_ONE_MINUS_SRC_ALPHA
;
310 FIXME("WINED3DRS_DESTBLEND = WINED3DBLEND_BOTHINVSRCALPHA, what to do?\n");
313 case WINED3DBLEND_BLENDFACTOR
: dstBlend
= GL_CONSTANT_COLOR
; break;
314 case WINED3DBLEND_INVBLENDFACTOR
: dstBlend
= GL_ONE_MINUS_CONSTANT_COLOR
; break;
316 FIXME("Unrecognized dst blend value %d\n", stateblock
->renderState
[WINED3DRS_DESTBLEND
]);
319 switch (stateblock
->renderState
[WINED3DRS_SRCBLEND
]) {
320 case WINED3DBLEND_ZERO
: srcBlend
= GL_ZERO
; break;
321 case WINED3DBLEND_ONE
: srcBlend
= GL_ONE
; break;
322 case WINED3DBLEND_SRCCOLOR
: srcBlend
= GL_SRC_COLOR
; break;
323 case WINED3DBLEND_INVSRCCOLOR
: srcBlend
= GL_ONE_MINUS_SRC_COLOR
; break;
324 case WINED3DBLEND_SRCALPHA
: srcBlend
= GL_SRC_ALPHA
; break;
325 case WINED3DBLEND_INVSRCALPHA
: srcBlend
= GL_ONE_MINUS_SRC_ALPHA
; break;
326 case WINED3DBLEND_DESTCOLOR
: srcBlend
= GL_DST_COLOR
; break;
327 case WINED3DBLEND_INVDESTCOLOR
: srcBlend
= GL_ONE_MINUS_DST_COLOR
; break;
328 case WINED3DBLEND_SRCALPHASAT
: srcBlend
= GL_SRC_ALPHA_SATURATE
; break;
330 case WINED3DBLEND_DESTALPHA
:
331 srcBlend
= target
->resource
.format_desc
->alpha_mask
? GL_DST_ALPHA
: GL_ONE
;
333 case WINED3DBLEND_INVDESTALPHA
:
334 srcBlend
= target
->resource
.format_desc
->alpha_mask
? GL_ONE_MINUS_DST_ALPHA
: GL_ZERO
;
337 case WINED3DBLEND_BOTHSRCALPHA
: srcBlend
= GL_SRC_ALPHA
;
338 dstBlend
= GL_ONE_MINUS_SRC_ALPHA
;
341 case WINED3DBLEND_BOTHINVSRCALPHA
: srcBlend
= GL_ONE_MINUS_SRC_ALPHA
;
342 dstBlend
= GL_SRC_ALPHA
;
345 case WINED3DBLEND_BLENDFACTOR
: srcBlend
= GL_CONSTANT_COLOR
; break;
346 case WINED3DBLEND_INVBLENDFACTOR
: srcBlend
= GL_ONE_MINUS_CONSTANT_COLOR
; break;
348 FIXME("Unrecognized src blend value %d\n", stateblock
->renderState
[WINED3DRS_SRCBLEND
]);
351 if(stateblock
->renderState
[WINED3DRS_EDGEANTIALIAS
] ||
352 stateblock
->renderState
[WINED3DRS_ANTIALIASEDLINEENABLE
]) {
353 glEnable(GL_LINE_SMOOTH
);
354 checkGLcall("glEnable(GL_LINE_SMOOTH)");
355 if(srcBlend
!= GL_SRC_ALPHA
) {
356 WARN("WINED3DRS_EDGEANTIALIAS enabled, but unexpected src blending param\n");
358 if(dstBlend
!= GL_ONE_MINUS_SRC_ALPHA
&& dstBlend
!= GL_ONE
) {
359 WARN("WINED3DRS_EDGEANTIALIAS enabled, but unexpected dst blending param\n");
362 glDisable(GL_LINE_SMOOTH
);
363 checkGLcall("glDisable(GL_LINE_SMOOTH)");
366 /* Re-apply BLENDOP(ALPHA) because of a possible SEPARATEALPHABLENDENABLE change */
367 if(!isStateDirty(context
, STATE_RENDER(WINED3DRS_BLENDOP
))) {
368 state_blendop(STATE_RENDER(WINED3DRS_BLENDOPALPHA
), stateblock
, context
);
371 if(stateblock
->renderState
[WINED3DRS_SEPARATEALPHABLENDENABLE
]) {
372 int srcBlendAlpha
= GL_ZERO
;
373 int dstBlendAlpha
= GL_ZERO
;
375 /* Separate alpha blending requires GL_EXT_blend_function_separate, so make sure it is around */
376 if (!context
->gl_info
->supported
[EXT_BLEND_FUNC_SEPARATE
])
378 WARN("Unsupported in local OpenGL implementation: glBlendFuncSeparateEXT\n");
382 switch (stateblock
->renderState
[WINED3DRS_DESTBLENDALPHA
]) {
383 case WINED3DBLEND_ZERO
: dstBlendAlpha
= GL_ZERO
; break;
384 case WINED3DBLEND_ONE
: dstBlendAlpha
= GL_ONE
; break;
385 case WINED3DBLEND_SRCCOLOR
: dstBlendAlpha
= GL_SRC_COLOR
; break;
386 case WINED3DBLEND_INVSRCCOLOR
: dstBlendAlpha
= GL_ONE_MINUS_SRC_COLOR
; break;
387 case WINED3DBLEND_SRCALPHA
: dstBlendAlpha
= GL_SRC_ALPHA
; break;
388 case WINED3DBLEND_INVSRCALPHA
: dstBlendAlpha
= GL_ONE_MINUS_SRC_ALPHA
; break;
389 case WINED3DBLEND_DESTCOLOR
: dstBlendAlpha
= GL_DST_COLOR
; break;
390 case WINED3DBLEND_INVDESTCOLOR
: dstBlendAlpha
= GL_ONE_MINUS_DST_COLOR
; break;
391 case WINED3DBLEND_DESTALPHA
: dstBlendAlpha
= GL_DST_ALPHA
; break;
392 case WINED3DBLEND_INVDESTALPHA
: dstBlendAlpha
= GL_DST_ALPHA
; break;
393 case WINED3DBLEND_SRCALPHASAT
:
394 dstBlend
= GL_SRC_ALPHA_SATURATE
;
395 WARN("Application uses SRCALPHASAT as dest blend factor, expect problems\n");
397 /* WINED3DBLEND_BOTHSRCALPHA and WINED3DBLEND_BOTHINVSRCALPHA are legacy source blending
398 * values which are still valid up to d3d9. They should not occur as dest blend values
400 case WINED3DBLEND_BOTHSRCALPHA
:
401 dstBlendAlpha
= GL_SRC_ALPHA
;
402 srcBlendAlpha
= GL_SRC_ALPHA
;
403 FIXME("WINED3DRS_DESTBLENDALPHA = WINED3DBLEND_BOTHSRCALPHA, what to do?\n");
405 case WINED3DBLEND_BOTHINVSRCALPHA
:
406 dstBlendAlpha
= GL_ONE_MINUS_SRC_ALPHA
;
407 srcBlendAlpha
= GL_ONE_MINUS_SRC_ALPHA
;
408 FIXME("WINED3DRS_DESTBLENDALPHA = WINED3DBLEND_BOTHINVSRCALPHA, what to do?\n");
410 case WINED3DBLEND_BLENDFACTOR
: dstBlendAlpha
= GL_CONSTANT_COLOR
; break;
411 case WINED3DBLEND_INVBLENDFACTOR
: dstBlendAlpha
= GL_ONE_MINUS_CONSTANT_COLOR
; break;
413 FIXME("Unrecognized dst blend alpha value %d\n", stateblock
->renderState
[WINED3DRS_DESTBLENDALPHA
]);
416 switch (stateblock
->renderState
[WINED3DRS_SRCBLENDALPHA
]) {
417 case WINED3DBLEND_ZERO
: srcBlendAlpha
= GL_ZERO
; break;
418 case WINED3DBLEND_ONE
: srcBlendAlpha
= GL_ONE
; break;
419 case WINED3DBLEND_SRCCOLOR
: srcBlendAlpha
= GL_SRC_COLOR
; break;
420 case WINED3DBLEND_INVSRCCOLOR
: srcBlendAlpha
= GL_ONE_MINUS_SRC_COLOR
; break;
421 case WINED3DBLEND_SRCALPHA
: srcBlendAlpha
= GL_SRC_ALPHA
; break;
422 case WINED3DBLEND_INVSRCALPHA
: srcBlendAlpha
= GL_ONE_MINUS_SRC_ALPHA
; break;
423 case WINED3DBLEND_DESTCOLOR
: srcBlendAlpha
= GL_DST_COLOR
; break;
424 case WINED3DBLEND_INVDESTCOLOR
: srcBlendAlpha
= GL_ONE_MINUS_DST_COLOR
; break;
425 case WINED3DBLEND_SRCALPHASAT
: srcBlendAlpha
= GL_SRC_ALPHA_SATURATE
; break;
426 case WINED3DBLEND_DESTALPHA
: srcBlendAlpha
= GL_DST_ALPHA
; break;
427 case WINED3DBLEND_INVDESTALPHA
: srcBlendAlpha
= GL_DST_ALPHA
; break;
428 case WINED3DBLEND_BOTHSRCALPHA
:
429 srcBlendAlpha
= GL_SRC_ALPHA
;
430 dstBlendAlpha
= GL_ONE_MINUS_SRC_ALPHA
;
432 case WINED3DBLEND_BOTHINVSRCALPHA
:
433 srcBlendAlpha
= GL_ONE_MINUS_SRC_ALPHA
;
434 dstBlendAlpha
= GL_SRC_ALPHA
;
436 case WINED3DBLEND_BLENDFACTOR
: srcBlendAlpha
= GL_CONSTANT_COLOR
; break;
437 case WINED3DBLEND_INVBLENDFACTOR
: srcBlendAlpha
= GL_ONE_MINUS_CONSTANT_COLOR
; break;
439 FIXME("Unrecognized src blend alpha value %d\n", stateblock
->renderState
[WINED3DRS_SRCBLENDALPHA
]);
442 GL_EXTCALL(glBlendFuncSeparateEXT(srcBlend
, dstBlend
, srcBlendAlpha
, dstBlendAlpha
));
443 checkGLcall("glBlendFuncSeparateEXT");
445 TRACE("glBlendFunc src=%x, dst=%x\n", srcBlend
, dstBlend
);
446 glBlendFunc(srcBlend
, dstBlend
);
447 checkGLcall("glBlendFunc");
450 /* colorkey fixup for stage 0 alphaop depends on WINED3DRS_ALPHABLENDENABLE state,
451 so it may need updating */
452 if (stateblock
->renderState
[WINED3DRS_COLORKEYENABLE
])
454 const struct StateEntry
*StateTable
= stateblock
->device
->StateTable
;
455 StateTable
[STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
)].apply(STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), stateblock
, context
);
459 static void state_blendfactor_w(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
461 WARN("Unsupported in local OpenGL implementation: glBlendColorEXT\n");
464 static void state_blendfactor(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
468 TRACE("Setting BlendFactor to %d\n", stateblock
->renderState
[WINED3DRS_BLENDFACTOR
]);
469 D3DCOLORTOGLFLOAT4(stateblock
->renderState
[WINED3DRS_BLENDFACTOR
], col
);
470 GL_EXTCALL(glBlendColorEXT (col
[0],col
[1],col
[2],col
[3]));
471 checkGLcall("glBlendColor");
474 static void state_alpha(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
478 BOOL enable_ckey
= FALSE
;
480 TRACE("state %#x, stateblock %p, context %p\n", state
, stateblock
, context
);
482 /* Find out if the texture on the first stage has a ckey set
483 * The alpha state func reads the texture settings, even though alpha and texture are not grouped
484 * together. This is to avoid making a huge alpha+texture+texture stage+ckey block due to the hardly
485 * used WINED3DRS_COLORKEYENABLE state(which is d3d <= 3 only). The texture function will call alpha
486 * in case it finds some texture+colorkeyenable combination which needs extra care.
488 if (stateblock
->textures
[0])
490 UINT texture_dimensions
= IWineD3DBaseTexture_GetTextureDimensions(stateblock
->textures
[0]);
492 if (texture_dimensions
== GL_TEXTURE_2D
|| texture_dimensions
== GL_TEXTURE_RECTANGLE_ARB
)
494 IWineD3DSurfaceImpl
*surf
;
496 surf
= (IWineD3DSurfaceImpl
*) ((IWineD3DTextureImpl
*)stateblock
->textures
[0])->surfaces
[0];
498 if (surf
->CKeyFlags
& WINEDDSD_CKSRCBLT
)
500 /* The surface conversion does not do color keying conversion for surfaces that have an alpha
501 * channel on their own. Likewise, the alpha test shouldn't be set up for color keying if the
502 * surface has alpha bits */
503 if (!surf
->resource
.format_desc
->alpha_mask
) enable_ckey
= TRUE
;
508 if (enable_ckey
|| context
->last_was_ckey
)
510 const struct StateEntry
*StateTable
= stateblock
->device
->StateTable
;
511 StateTable
[STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
)].apply(STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), stateblock
, context
);
513 context
->last_was_ckey
= enable_ckey
;
515 if (stateblock
->renderState
[WINED3DRS_ALPHATESTENABLE
] ||
516 (stateblock
->renderState
[WINED3DRS_COLORKEYENABLE
] && enable_ckey
)) {
517 glEnable(GL_ALPHA_TEST
);
518 checkGLcall("glEnable GL_ALPHA_TEST");
520 glDisable(GL_ALPHA_TEST
);
521 checkGLcall("glDisable GL_ALPHA_TEST");
522 /* Alpha test is disabled, don't bother setting the params - it will happen on the next
528 if(stateblock
->renderState
[WINED3DRS_COLORKEYENABLE
] && enable_ckey
) {
529 glParm
= GL_NOTEQUAL
;
532 ref
= ((float) stateblock
->renderState
[WINED3DRS_ALPHAREF
]) / 255.0f
;
533 glParm
= CompareFunc(stateblock
->renderState
[WINED3DRS_ALPHAFUNC
]);
536 glAlphaFunc(glParm
, ref
);
537 checkGLcall("glAlphaFunc");
541 static void state_clipping(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
543 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
544 DWORD enable
= 0xFFFFFFFF;
545 DWORD disable
= 0x00000000;
547 if (!stateblock
->device
->vs_clipping
&& use_vs(stateblock
))
549 /* The spec says that opengl clipping planes are disabled when using shaders. Direct3D planes aren't,
550 * so that is an issue. The MacOS ATI driver keeps clipping planes activated with shaders in some
551 * conditions I got sick of tracking down. The shader state handler disables all clip planes because
552 * of that - don't do anything here and keep them disabled
554 if(stateblock
->renderState
[WINED3DRS_CLIPPLANEENABLE
]) {
555 static BOOL warned
= FALSE
;
557 FIXME("Clipping not supported with vertex shaders\n");
564 /* TODO: Keep track of previously enabled clipplanes to avoid unnecessary resetting
565 * of already set values
568 /* If enabling / disabling all
569 * TODO: Is this correct? Doesn't D3DRS_CLIPPING disable clipping on the viewport frustrum?
571 if (stateblock
->renderState
[WINED3DRS_CLIPPING
]) {
572 enable
= stateblock
->renderState
[WINED3DRS_CLIPPLANEENABLE
];
573 disable
= ~stateblock
->renderState
[WINED3DRS_CLIPPLANEENABLE
];
574 if (gl_info
->supported
[ARB_DEPTH_CLAMP
])
576 glDisable(GL_DEPTH_CLAMP
);
577 checkGLcall("glDisable(GL_DEPTH_CLAMP)");
580 disable
= 0xffffffff;
582 if (gl_info
->supported
[ARB_DEPTH_CLAMP
])
584 glEnable(GL_DEPTH_CLAMP
);
585 checkGLcall("glEnable(GL_DEPTH_CLAMP)");
589 if (enable
& WINED3DCLIPPLANE0
) { glEnable(GL_CLIP_PLANE0
); checkGLcall("glEnable(clip plane 0)"); }
590 if (enable
& WINED3DCLIPPLANE1
) { glEnable(GL_CLIP_PLANE1
); checkGLcall("glEnable(clip plane 1)"); }
591 if (enable
& WINED3DCLIPPLANE2
) { glEnable(GL_CLIP_PLANE2
); checkGLcall("glEnable(clip plane 2)"); }
592 if (enable
& WINED3DCLIPPLANE3
) { glEnable(GL_CLIP_PLANE3
); checkGLcall("glEnable(clip plane 3)"); }
593 if (enable
& WINED3DCLIPPLANE4
) { glEnable(GL_CLIP_PLANE4
); checkGLcall("glEnable(clip plane 4)"); }
594 if (enable
& WINED3DCLIPPLANE5
) { glEnable(GL_CLIP_PLANE5
); checkGLcall("glEnable(clip plane 5)"); }
596 if (disable
& WINED3DCLIPPLANE0
) { glDisable(GL_CLIP_PLANE0
); checkGLcall("glDisable(clip plane 0)"); }
597 if (disable
& WINED3DCLIPPLANE1
) { glDisable(GL_CLIP_PLANE1
); checkGLcall("glDisable(clip plane 1)"); }
598 if (disable
& WINED3DCLIPPLANE2
) { glDisable(GL_CLIP_PLANE2
); checkGLcall("glDisable(clip plane 2)"); }
599 if (disable
& WINED3DCLIPPLANE3
) { glDisable(GL_CLIP_PLANE3
); checkGLcall("glDisable(clip plane 3)"); }
600 if (disable
& WINED3DCLIPPLANE4
) { glDisable(GL_CLIP_PLANE4
); checkGLcall("glDisable(clip plane 4)"); }
601 if (disable
& WINED3DCLIPPLANE5
) { glDisable(GL_CLIP_PLANE5
); checkGLcall("glDisable(clip plane 5)"); }
603 /** update clipping status */
605 stateblock
->clip_status
.ClipUnion
= 0;
606 stateblock
->clip_status
.ClipIntersection
= 0xFFFFFFFF;
608 stateblock
->clip_status
.ClipUnion
= 0;
609 stateblock
->clip_status
.ClipIntersection
= 0;
613 static void state_blendop_w(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
615 WARN("Unsupported in local OpenGL implementation: glBlendEquation\n");
618 static void state_blendop(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
620 int blendEquation
= GL_FUNC_ADD
;
621 int blendEquationAlpha
= GL_FUNC_ADD
;
623 /* BLENDOPALPHA requires GL_EXT_blend_equation_separate, so make sure it is around */
624 if (stateblock
->renderState
[WINED3DRS_BLENDOPALPHA
]
625 && !context
->gl_info
->supported
[EXT_BLEND_EQUATION_SEPARATE
])
627 WARN("Unsupported in local OpenGL implementation: glBlendEquationSeparateEXT\n");
631 switch ((WINED3DBLENDOP
) stateblock
->renderState
[WINED3DRS_BLENDOP
]) {
632 case WINED3DBLENDOP_ADD
: blendEquation
= GL_FUNC_ADD
; break;
633 case WINED3DBLENDOP_SUBTRACT
: blendEquation
= GL_FUNC_SUBTRACT
; break;
634 case WINED3DBLENDOP_REVSUBTRACT
: blendEquation
= GL_FUNC_REVERSE_SUBTRACT
; break;
635 case WINED3DBLENDOP_MIN
: blendEquation
= GL_MIN
; break;
636 case WINED3DBLENDOP_MAX
: blendEquation
= GL_MAX
; break;
638 FIXME("Unrecognized/Unhandled D3DBLENDOP value %d\n", stateblock
->renderState
[WINED3DRS_BLENDOP
]);
641 switch ((WINED3DBLENDOP
) stateblock
->renderState
[WINED3DRS_BLENDOPALPHA
]) {
642 case WINED3DBLENDOP_ADD
: blendEquationAlpha
= GL_FUNC_ADD
; break;
643 case WINED3DBLENDOP_SUBTRACT
: blendEquationAlpha
= GL_FUNC_SUBTRACT
; break;
644 case WINED3DBLENDOP_REVSUBTRACT
: blendEquationAlpha
= GL_FUNC_REVERSE_SUBTRACT
; break;
645 case WINED3DBLENDOP_MIN
: blendEquationAlpha
= GL_MIN
; break;
646 case WINED3DBLENDOP_MAX
: blendEquationAlpha
= GL_MAX
; break;
648 FIXME("Unrecognized/Unhandled D3DBLENDOP value %d\n", stateblock
->renderState
[WINED3DRS_BLENDOPALPHA
]);
651 if(stateblock
->renderState
[WINED3DRS_SEPARATEALPHABLENDENABLE
]) {
652 TRACE("glBlendEquationSeparateEXT(%x, %x)\n", blendEquation
, blendEquationAlpha
);
653 GL_EXTCALL(glBlendEquationSeparateEXT(blendEquation
, blendEquationAlpha
));
654 checkGLcall("glBlendEquationSeparateEXT");
656 TRACE("glBlendEquation(%x)\n", blendEquation
);
657 GL_EXTCALL(glBlendEquationEXT(blendEquation
));
658 checkGLcall("glBlendEquation");
662 static void state_specularenable(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
664 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
665 /* Originally this used glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR)
666 * and (GL_LIGHT_MODEL_COLOR_CONTROL,GL_SINGLE_COLOR) to swap between enabled/disabled
667 * specular color. This is wrong:
668 * Separate specular color means the specular colour is maintained separately, whereas
669 * single color means it is merged in. However in both cases they are being used to
671 * To disable specular color, set it explicitly to black and turn off GL_COLOR_SUM_EXT
672 * NOTE: If not supported don't give FIXMEs the impact is really minimal and very few people are
676 * If register combiners are enabled, enabling / disabling GL_COLOR_SUM has no effect.
677 * Instead, we need to setup the FinalCombiner properly.
679 * The default setup for the FinalCombiner is:
681 * <variable> <input> <mapping> <usage>
682 * GL_VARIABLE_A_NV GL_FOG, GL_UNSIGNED_IDENTITY_NV GL_ALPHA
683 * GL_VARIABLE_B_NV GL_SPARE0_PLUS_SECONDARY_COLOR_NV GL_UNSIGNED_IDENTITY_NV GL_RGB
684 * GL_VARIABLE_C_NV GL_FOG GL_UNSIGNED_IDENTITY_NV GL_RGB
685 * GL_VARIABLE_D_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
686 * GL_VARIABLE_E_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
687 * GL_VARIABLE_F_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
688 * GL_VARIABLE_G_NV GL_SPARE0_NV GL_UNSIGNED_IDENTITY_NV GL_ALPHA
690 * That's pretty much fine as it is, except for variable B, which needs to take
691 * either GL_SPARE0_PLUS_SECONDARY_COLOR_NV or GL_SPARE0_NV, depending on
692 * whether WINED3DRS_SPECULARENABLE is enabled or not.
695 TRACE("Setting specular enable state and materials\n");
696 if (stateblock
->renderState
[WINED3DRS_SPECULARENABLE
]) {
697 glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, (float*) &stateblock
->material
.Specular
);
698 checkGLcall("glMaterialfv");
700 if (stateblock
->material
.Power
> gl_info
->limits
.shininess
)
702 /* glMaterialf man page says that the material says that GL_SHININESS must be between 0.0
703 * and 128.0, although in d3d neither -1 nor 129 produce an error. GL_NV_max_light_exponent
704 * allows bigger values. If the extension is supported, gl_info->limits.shininess contains the
705 * value reported by the extension, otherwise 128. For values > gl_info->limits.shininess clamp
706 * them, it should be safe to do so without major visual distortions.
708 WARN("Material power = %f, limit %f\n", stateblock
->material
.Power
, gl_info
->limits
.shininess
);
709 glMaterialf(GL_FRONT_AND_BACK
, GL_SHININESS
, gl_info
->limits
.shininess
);
711 glMaterialf(GL_FRONT_AND_BACK
, GL_SHININESS
, stateblock
->material
.Power
);
713 checkGLcall("glMaterialf(GL_SHININESS)");
715 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
717 glEnable(GL_COLOR_SUM_EXT
);
721 TRACE("Specular colors cannot be enabled in this version of opengl\n");
723 checkGLcall("glEnable(GL_COLOR_SUM)");
725 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
727 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV
, GL_SPARE0_PLUS_SECONDARY_COLOR_NV
, GL_UNSIGNED_IDENTITY_NV
, GL_RGB
));
728 checkGLcall("glFinalCombinerInputNV()");
731 static const GLfloat black
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
733 /* for the case of enabled lighting: */
734 glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, &black
[0]);
735 checkGLcall("glMaterialfv");
737 /* for the case of disabled lighting: */
738 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
740 glDisable(GL_COLOR_SUM_EXT
);
744 TRACE("Specular colors cannot be disabled in this version of opengl\n");
746 checkGLcall("glDisable(GL_COLOR_SUM)");
748 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
750 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV
, GL_SPARE0_NV
, GL_UNSIGNED_IDENTITY_NV
, GL_RGB
));
751 checkGLcall("glFinalCombinerInputNV()");
755 TRACE("(%p) : Diffuse {%.8e, %.8e, %.8e, %.8e}\n", stateblock
->device
,
756 stateblock
->material
.Diffuse
.r
, stateblock
->material
.Diffuse
.g
,
757 stateblock
->material
.Diffuse
.b
, stateblock
->material
.Diffuse
.a
);
758 TRACE("(%p) : Ambient {%.8e, %.8e, %.8e, %.8e}\n", stateblock
->device
,
759 stateblock
->material
.Ambient
.r
, stateblock
->material
.Ambient
.g
,
760 stateblock
->material
.Ambient
.b
, stateblock
->material
.Ambient
.a
);
761 TRACE("(%p) : Specular {%.8e, %.8e, %.8e, %.8e}\n", stateblock
->device
,
762 stateblock
->material
.Specular
.r
, stateblock
->material
.Specular
.g
,
763 stateblock
->material
.Specular
.b
, stateblock
->material
.Specular
.a
);
764 TRACE("(%p) : Emissive {%.8e, %.8e, %.8e, %.8e}\n", stateblock
->device
,
765 stateblock
->material
.Emissive
.r
, stateblock
->material
.Emissive
.g
,
766 stateblock
->material
.Emissive
.b
, stateblock
->material
.Emissive
.a
);
768 glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float*) &stateblock
->material
.Ambient
);
769 checkGLcall("glMaterialfv(GL_AMBIENT)");
770 glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float*) &stateblock
->material
.Diffuse
);
771 checkGLcall("glMaterialfv(GL_DIFFUSE)");
772 glMaterialfv(GL_FRONT_AND_BACK
, GL_EMISSION
, (float*) &stateblock
->material
.Emissive
);
773 checkGLcall("glMaterialfv(GL_EMISSION)");
776 static void state_texfactor(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
780 /* Note the texture color applies to all textures whereas
781 * GL_TEXTURE_ENV_COLOR applies to active only
784 D3DCOLORTOGLFLOAT4(stateblock
->renderState
[WINED3DRS_TEXTUREFACTOR
], col
);
786 /* And now the default texture color as well */
787 for (i
= 0; i
< context
->gl_info
->limits
.texture_stages
; ++i
)
789 /* Note the WINED3DRS value applies to all textures, but GL has one
790 * per texture, so apply it now ready to be used!
792 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB
+ i
));
793 checkGLcall("glActiveTextureARB");
795 glTexEnvfv(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_COLOR
, &col
[0]);
796 checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);");
800 static void renderstate_stencil_twosided(struct wined3d_context
*context
, GLint face
,
801 GLint func
, GLint ref
, GLuint mask
, GLint stencilFail
, GLint depthFail
, GLint stencilPass
)
803 glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT
);
804 checkGLcall("glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT)");
805 GL_EXTCALL(glActiveStencilFaceEXT(face
));
806 checkGLcall("glActiveStencilFaceEXT(...)");
807 glStencilFunc(func
, ref
, mask
);
808 checkGLcall("glStencilFunc(...)");
809 glStencilOp(stencilFail
, depthFail
, stencilPass
);
810 checkGLcall("glStencilOp(...)");
813 static void state_stencil(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
815 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
816 DWORD onesided_enable
= FALSE
;
817 DWORD twosided_enable
= FALSE
;
818 GLint func
= GL_ALWAYS
;
819 GLint func_ccw
= GL_ALWAYS
;
822 GLint stencilFail
= GL_KEEP
;
823 GLint depthFail
= GL_KEEP
;
824 GLint stencilPass
= GL_KEEP
;
825 GLint stencilFail_ccw
= GL_KEEP
;
826 GLint depthFail_ccw
= GL_KEEP
;
827 GLint stencilPass_ccw
= GL_KEEP
;
829 /* No stencil test without a stencil buffer. */
830 if (!stateblock
->device
->stencilBufferTarget
)
832 glDisable(GL_STENCIL_TEST
);
833 checkGLcall("glDisable GL_STENCIL_TEST");
837 onesided_enable
= stateblock
->renderState
[WINED3DRS_STENCILENABLE
];
838 twosided_enable
= stateblock
->renderState
[WINED3DRS_TWOSIDEDSTENCILMODE
];
839 if( !( func
= CompareFunc(stateblock
->renderState
[WINED3DRS_STENCILFUNC
]) ) )
841 if( !( func_ccw
= CompareFunc(stateblock
->renderState
[WINED3DRS_CCW_STENCILFUNC
]) ) )
842 func_ccw
= GL_ALWAYS
;
843 ref
= stateblock
->renderState
[WINED3DRS_STENCILREF
];
844 mask
= stateblock
->renderState
[WINED3DRS_STENCILMASK
];
845 stencilFail
= StencilOp(stateblock
->renderState
[WINED3DRS_STENCILFAIL
]);
846 depthFail
= StencilOp(stateblock
->renderState
[WINED3DRS_STENCILZFAIL
]);
847 stencilPass
= StencilOp(stateblock
->renderState
[WINED3DRS_STENCILPASS
]);
848 stencilFail_ccw
= StencilOp(stateblock
->renderState
[WINED3DRS_CCW_STENCILFAIL
]);
849 depthFail_ccw
= StencilOp(stateblock
->renderState
[WINED3DRS_CCW_STENCILZFAIL
]);
850 stencilPass_ccw
= StencilOp(stateblock
->renderState
[WINED3DRS_CCW_STENCILPASS
]);
852 TRACE("(onesided %d, twosided %d, ref %x, mask %x, "
853 "GL_FRONT: func: %x, fail %x, zfail %x, zpass %x "
854 "GL_BACK: func: %x, fail %x, zfail %x, zpass %x )\n",
855 onesided_enable
, twosided_enable
, ref
, mask
,
856 func
, stencilFail
, depthFail
, stencilPass
,
857 func_ccw
, stencilFail_ccw
, depthFail_ccw
, stencilPass_ccw
);
859 if (twosided_enable
&& onesided_enable
) {
860 glEnable(GL_STENCIL_TEST
);
861 checkGLcall("glEnable GL_STENCIL_TEST");
863 if (gl_info
->supported
[EXT_STENCIL_TWO_SIDE
])
865 /* Apply back first, then front. This function calls glActiveStencilFaceEXT,
866 * which has an effect on the code below too. If we apply the front face
867 * afterwards, we are sure that the active stencil face is set to front,
868 * and other stencil functions which do not use two sided stencil do not have
871 renderstate_stencil_twosided(context
, GL_BACK
,
872 func_ccw
, ref
, mask
, stencilFail_ccw
, depthFail_ccw
, stencilPass_ccw
);
873 renderstate_stencil_twosided(context
, GL_FRONT
,
874 func
, ref
, mask
, stencilFail
, depthFail
, stencilPass
);
876 else if (gl_info
->supported
[ATI_SEPARATE_STENCIL
])
878 GL_EXTCALL(glStencilFuncSeparateATI(func
, func_ccw
, ref
, mask
));
879 checkGLcall("glStencilFuncSeparateATI(...)");
880 GL_EXTCALL(glStencilOpSeparateATI(GL_FRONT
, stencilFail
, depthFail
, stencilPass
));
881 checkGLcall("glStencilOpSeparateATI(GL_FRONT, ...)");
882 GL_EXTCALL(glStencilOpSeparateATI(GL_BACK
, stencilFail_ccw
, depthFail_ccw
, stencilPass_ccw
));
883 checkGLcall("glStencilOpSeparateATI(GL_BACK, ...)");
885 ERR("Separate (two sided) stencil not supported on this version of opengl. Caps weren't honored?\n");
888 else if(onesided_enable
)
890 if (gl_info
->supported
[EXT_STENCIL_TWO_SIDE
])
892 glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT
);
893 checkGLcall("glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT)");
896 /* This code disables the ATI extension as well, since the standard stencil functions are equal
897 * to calling the ATI functions with GL_FRONT_AND_BACK as face parameter
899 glEnable(GL_STENCIL_TEST
);
900 checkGLcall("glEnable GL_STENCIL_TEST");
901 glStencilFunc(func
, ref
, mask
);
902 checkGLcall("glStencilFunc(...)");
903 glStencilOp(stencilFail
, depthFail
, stencilPass
);
904 checkGLcall("glStencilOp(...)");
906 glDisable(GL_STENCIL_TEST
);
907 checkGLcall("glDisable GL_STENCIL_TEST");
911 static void state_stencilwrite2s(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
913 DWORD mask
= stateblock
->device
->stencilBufferTarget
? stateblock
->renderState
[WINED3DRS_STENCILWRITEMASK
] : 0;
915 GL_EXTCALL(glActiveStencilFaceEXT(GL_BACK
));
916 checkGLcall("glActiveStencilFaceEXT(GL_BACK)");
918 checkGLcall("glStencilMask");
919 GL_EXTCALL(glActiveStencilFaceEXT(GL_FRONT
));
920 checkGLcall("glActiveStencilFaceEXT(GL_FRONT)");
924 static void state_stencilwrite(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
926 DWORD mask
= stateblock
->device
->stencilBufferTarget
? stateblock
->renderState
[WINED3DRS_STENCILWRITEMASK
] : 0;
929 checkGLcall("glStencilMask");
932 static void state_fog_vertexpart(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
935 TRACE("state %#x, stateblock %p, context %p\n", state
, stateblock
, context
);
937 if (!stateblock
->renderState
[WINED3DRS_FOGENABLE
]) return;
939 /* Table fog on: Never use fog coords, and use per-fragment fog */
940 if(stateblock
->renderState
[WINED3DRS_FOGTABLEMODE
] != WINED3DFOG_NONE
) {
941 glHint(GL_FOG_HINT
, GL_NICEST
);
942 if(context
->fog_coord
) {
943 glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FRAGMENT_DEPTH_EXT
);
944 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT)");
945 context
->fog_coord
= FALSE
;
950 /* Otherwise use per-vertex fog in any case */
951 glHint(GL_FOG_HINT
, GL_FASTEST
);
953 if(stateblock
->renderState
[WINED3DRS_FOGVERTEXMODE
] == WINED3DFOG_NONE
|| context
->last_was_rhw
) {
954 /* No fog at all, or transformed vertices: Use fog coord */
955 if(!context
->fog_coord
) {
956 glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FOG_COORDINATE_EXT
);
957 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT)");
958 context
->fog_coord
= TRUE
;
961 /* Otherwise, use the fragment depth */
962 if(context
->fog_coord
) {
963 glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FRAGMENT_DEPTH_EXT
);
964 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT)");
965 context
->fog_coord
= FALSE
;
970 void state_fogstartend(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
972 float fogstart
, fogend
;
978 switch(context
->fog_source
) {
984 case FOGSOURCE_COORD
:
990 tmpvalue
.d
= stateblock
->renderState
[WINED3DRS_FOGSTART
];
991 fogstart
= tmpvalue
.f
;
992 tmpvalue
.d
= stateblock
->renderState
[WINED3DRS_FOGEND
];
994 /* In GL, fogstart == fogend disables fog, in D3D everything's fogged.*/
995 if(fogstart
== fogend
) {
996 fogstart
= -1.0f
/ 0.0f
;
1002 /* This should not happen.context->fog_source is set in wined3d, not the app.
1003 * Still this is needed to make the compiler happy
1005 ERR("Unexpected fog coordinate source\n");
1010 glFogf(GL_FOG_START
, fogstart
);
1011 checkGLcall("glFogf(GL_FOG_START, fogstart)");
1012 TRACE("Fog Start == %f\n", fogstart
);
1014 glFogf(GL_FOG_END
, fogend
);
1015 checkGLcall("glFogf(GL_FOG_END, fogend)");
1016 TRACE("Fog End == %f\n", fogend
);
1019 void state_fog_fragpart(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1021 enum fogsource new_source
;
1023 TRACE("state %#x, stateblock %p, context %p\n", state
, stateblock
, context
);
1025 if (!stateblock
->renderState
[WINED3DRS_FOGENABLE
]) {
1026 /* No fog? Disable it, and we're done :-) */
1027 glDisableWINE(GL_FOG
);
1028 checkGLcall("glDisable GL_FOG");
1034 * With fixed function vertex processing, Direct3D knows 2 different fog input sources.
1035 * It can use the Z value of the vertex, or the alpha component of the specular color.
1036 * This depends on the fog vertex, fog table and the vertex declaration. If the Z value
1037 * is used, fogstart, fogend and the equation type are used, otherwise linear fog with
1038 * start = 255, end = 0 is used. Obviously the msdn is not very clear on that.
1040 * FOGTABLEMODE != NONE:
1041 * The Z value is used, with the equation specified, no matter what vertex type.
1043 * FOGTABLEMODE == NONE, FOGVERTEXMODE != NONE, untransformed:
1044 * Per vertex fog is calculated using the specified fog equation and the parameters
1046 * FOGTABLEMODE == NONE, FOGVERTEXMODE != NONE, transformed, OR
1047 * FOGTABLEMODE == NONE, FOGVERTEXMODE == NONE, untransformed:
1048 * Linear fog with start = 255.0, end = 0.0, input comes from the specular color
1051 * Rules for vertex fog with shaders:
1053 * When mixing fixed function functionality with the programmable pipeline, D3D expects
1054 * the fog computation to happen during transformation while openGL expects it to happen
1055 * during rasterization. Also, prior to pixel shader 3.0 D3D handles fog blending after
1056 * the pixel shader while openGL always expects the pixel shader to handle the blending.
1057 * To solve this problem, WineD3D does:
1058 * 1) implement a linear fog equation and fog blending at the end of every pre 3.0 pixel
1060 * and 2) disables the fog computation (in either the fixed function or programmable
1061 * rasterizer) if using a vertex program.
1063 * D3D shaders can provide an explicit fog coordinate. This fog coordinate is used with
1064 * D3DRS_FOGTABLEMODE==D3DFOG_NONE. The FOGVERTEXMODE is ignored, d3d always uses linear
1065 * fog with start=1.0 and end=0.0 in this case. This is similar to fog coordinates in
1066 * the specular color, a vertex shader counts as pretransformed geometry in this case.
1067 * There are some GL differences between specular fog coords and vertex shaders though.
1069 * With table fog the vertex shader fog coordinate is ignored.
1071 * If a fogtablemode and a fogvertexmode are specified, table fog is applied (with or
1075 /* DX 7 sdk: "If both render states(vertex and table fog) are set to valid modes,
1076 * the system will apply only pixel(=table) fog effects."
1078 if(stateblock
->renderState
[WINED3DRS_FOGTABLEMODE
] == WINED3DFOG_NONE
) {
1079 if(use_vs(stateblock
)) {
1080 glFogi(GL_FOG_MODE
, GL_LINEAR
);
1081 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1082 new_source
= FOGSOURCE_VS
;
1084 switch (stateblock
->renderState
[WINED3DRS_FOGVERTEXMODE
]) {
1085 /* If processed vertices are used, fall through to the NONE case */
1086 case WINED3DFOG_EXP
:
1087 if(!context
->last_was_rhw
) {
1088 glFogi(GL_FOG_MODE
, GL_EXP
);
1089 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP)");
1090 new_source
= FOGSOURCE_FFP
;
1095 case WINED3DFOG_EXP2
:
1096 if(!context
->last_was_rhw
) {
1097 glFogi(GL_FOG_MODE
, GL_EXP2
);
1098 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2)");
1099 new_source
= FOGSOURCE_FFP
;
1104 case WINED3DFOG_LINEAR
:
1105 if(!context
->last_was_rhw
) {
1106 glFogi(GL_FOG_MODE
, GL_LINEAR
);
1107 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1108 new_source
= FOGSOURCE_FFP
;
1113 case WINED3DFOG_NONE
:
1114 /* Both are none? According to msdn the alpha channel of the specular
1115 * color contains a fog factor. Set it in drawStridedSlow.
1116 * Same happens with Vertexfog on transformed vertices
1118 new_source
= FOGSOURCE_COORD
;
1119 glFogi(GL_FOG_MODE
, GL_LINEAR
);
1120 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1124 FIXME("Unexpected WINED3DRS_FOGVERTEXMODE %d\n", stateblock
->renderState
[WINED3DRS_FOGVERTEXMODE
]);
1125 new_source
= FOGSOURCE_FFP
; /* Make the compiler happy */
1129 new_source
= FOGSOURCE_FFP
;
1131 switch (stateblock
->renderState
[WINED3DRS_FOGTABLEMODE
]) {
1132 case WINED3DFOG_EXP
:
1133 glFogi(GL_FOG_MODE
, GL_EXP
);
1134 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP)");
1137 case WINED3DFOG_EXP2
:
1138 glFogi(GL_FOG_MODE
, GL_EXP2
);
1139 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2)");
1142 case WINED3DFOG_LINEAR
:
1143 glFogi(GL_FOG_MODE
, GL_LINEAR
);
1144 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1147 case WINED3DFOG_NONE
: /* Won't happen */
1149 FIXME("Unexpected WINED3DRS_FOGTABLEMODE %d\n", stateblock
->renderState
[WINED3DRS_FOGTABLEMODE
]);
1153 glEnableWINE(GL_FOG
);
1154 checkGLcall("glEnable GL_FOG");
1155 if(new_source
!= context
->fog_source
) {
1156 context
->fog_source
= new_source
;
1157 state_fogstartend(STATE_RENDER(WINED3DRS_FOGSTART
), stateblock
, context
);
1161 static void state_rangefog_w(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1163 if(stateblock
->renderState
[WINED3DRS_RANGEFOGENABLE
]) {
1164 WARN("Range fog enabled, but not supported by this opengl implementation\n");
1168 static void state_rangefog(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1170 if(stateblock
->renderState
[WINED3DRS_RANGEFOGENABLE
]) {
1171 glFogi(GL_FOG_DISTANCE_MODE_NV
, GL_EYE_RADIAL_NV
);
1172 checkGLcall("glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_RADIAL_NV)");
1174 glFogi(GL_FOG_DISTANCE_MODE_NV
, GL_EYE_PLANE_ABSOLUTE_NV
);
1175 checkGLcall("glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_PLANE_ABSOLUTE_NV)");
1179 void state_fogcolor(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1182 D3DCOLORTOGLFLOAT4(stateblock
->renderState
[WINED3DRS_FOGCOLOR
], col
);
1183 glFogfv(GL_FOG_COLOR
, &col
[0]);
1184 checkGLcall("glFog GL_FOG_COLOR");
1187 void state_fogdensity(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1193 tmpvalue
.d
= stateblock
->renderState
[WINED3DRS_FOGDENSITY
];
1194 glFogfv(GL_FOG_DENSITY
, &tmpvalue
.f
);
1195 checkGLcall("glFogf(GL_FOG_DENSITY, (float) Value)");
1198 static void state_colormat(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1200 IWineD3DDeviceImpl
*device
= stateblock
->device
;
1203 /* Depends on the decoded vertex declaration to read the existence of diffuse data.
1204 * The vertex declaration will call this function if the fixed function pipeline is used.
1207 if(isStateDirty(context
, STATE_VDECL
)) {
1211 context
->num_untracked_materials
= 0;
1212 if ((device
->strided_streams
.use_map
& (1 << WINED3D_FFP_DIFFUSE
))
1213 && stateblock
->renderState
[WINED3DRS_COLORVERTEX
])
1215 TRACE("diff %d, amb %d, emis %d, spec %d\n",
1216 stateblock
->renderState
[WINED3DRS_DIFFUSEMATERIALSOURCE
],
1217 stateblock
->renderState
[WINED3DRS_AMBIENTMATERIALSOURCE
],
1218 stateblock
->renderState
[WINED3DRS_EMISSIVEMATERIALSOURCE
],
1219 stateblock
->renderState
[WINED3DRS_SPECULARMATERIALSOURCE
]);
1221 if (stateblock
->renderState
[WINED3DRS_DIFFUSEMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1222 if (stateblock
->renderState
[WINED3DRS_AMBIENTMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1223 Parm
= GL_AMBIENT_AND_DIFFUSE
;
1227 if(stateblock
->renderState
[WINED3DRS_EMISSIVEMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1228 context
->untracked_materials
[context
->num_untracked_materials
] = GL_EMISSION
;
1229 context
->num_untracked_materials
++;
1231 if(stateblock
->renderState
[WINED3DRS_SPECULARMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1232 context
->untracked_materials
[context
->num_untracked_materials
] = GL_SPECULAR
;
1233 context
->num_untracked_materials
++;
1235 } else if (stateblock
->renderState
[WINED3DRS_AMBIENTMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1237 if(stateblock
->renderState
[WINED3DRS_EMISSIVEMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1238 context
->untracked_materials
[context
->num_untracked_materials
] = GL_EMISSION
;
1239 context
->num_untracked_materials
++;
1241 if(stateblock
->renderState
[WINED3DRS_SPECULARMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1242 context
->untracked_materials
[context
->num_untracked_materials
] = GL_SPECULAR
;
1243 context
->num_untracked_materials
++;
1245 } else if (stateblock
->renderState
[WINED3DRS_EMISSIVEMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1247 if(stateblock
->renderState
[WINED3DRS_SPECULARMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1248 context
->untracked_materials
[context
->num_untracked_materials
] = GL_SPECULAR
;
1249 context
->num_untracked_materials
++;
1251 } else if (stateblock
->renderState
[WINED3DRS_SPECULARMATERIALSOURCE
] == WINED3DMCS_COLOR1
) {
1256 /* Nothing changed, return. */
1257 if (Parm
== context
->tracking_parm
) return;
1260 glDisable(GL_COLOR_MATERIAL
);
1261 checkGLcall("glDisable GL_COLOR_MATERIAL");
1263 glColorMaterial(GL_FRONT_AND_BACK
, Parm
);
1264 checkGLcall("glColorMaterial(GL_FRONT_AND_BACK, Parm)");
1265 glEnable(GL_COLOR_MATERIAL
);
1266 checkGLcall("glEnable(GL_COLOR_MATERIAL)");
1269 /* Apparently calls to glMaterialfv are ignored for properties we're
1270 * tracking with glColorMaterial, so apply those here. */
1271 switch (context
->tracking_parm
) {
1272 case GL_AMBIENT_AND_DIFFUSE
:
1273 glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float*)&device
->updateStateBlock
->material
.Ambient
);
1274 glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float*)&device
->updateStateBlock
->material
.Diffuse
);
1275 checkGLcall("glMaterialfv");
1279 glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float*)&device
->updateStateBlock
->material
.Diffuse
);
1280 checkGLcall("glMaterialfv");
1284 glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float*)&device
->updateStateBlock
->material
.Ambient
);
1285 checkGLcall("glMaterialfv");
1289 glMaterialfv(GL_FRONT_AND_BACK
, GL_EMISSION
, (float*)&device
->updateStateBlock
->material
.Emissive
);
1290 checkGLcall("glMaterialfv");
1294 /* Only change material color if specular is enabled, otherwise it is set to black */
1295 if (device
->stateBlock
->renderState
[WINED3DRS_SPECULARENABLE
]) {
1296 glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, (float*)&device
->updateStateBlock
->material
.Specular
);
1297 checkGLcall("glMaterialfv");
1299 static const GLfloat black
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
1300 glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, &black
[0]);
1301 checkGLcall("glMaterialfv");
1306 context
->tracking_parm
= Parm
;
1309 static void state_linepattern(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1313 WINED3DLINEPATTERN lp
;
1315 tmppattern
.d
= stateblock
->renderState
[WINED3DRS_LINEPATTERN
];
1317 TRACE("Line pattern: repeat %d bits %x\n", tmppattern
.lp
.wRepeatFactor
, tmppattern
.lp
.wLinePattern
);
1319 if (tmppattern
.lp
.wRepeatFactor
) {
1320 glLineStipple(tmppattern
.lp
.wRepeatFactor
, tmppattern
.lp
.wLinePattern
);
1321 checkGLcall("glLineStipple(repeat, linepattern)");
1322 glEnable(GL_LINE_STIPPLE
);
1323 checkGLcall("glEnable(GL_LINE_STIPPLE);");
1325 glDisable(GL_LINE_STIPPLE
);
1326 checkGLcall("glDisable(GL_LINE_STIPPLE);");
1330 static void state_zbias(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1337 if (stateblock
->renderState
[WINED3DRS_ZBIAS
]) {
1338 tmpvalue
.d
= stateblock
->renderState
[WINED3DRS_ZBIAS
];
1339 TRACE("ZBias value %f\n", tmpvalue
.f
);
1340 glPolygonOffset(0, -tmpvalue
.f
);
1341 checkGLcall("glPolygonOffset(0, -Value)");
1342 glEnable(GL_POLYGON_OFFSET_FILL
);
1343 checkGLcall("glEnable(GL_POLYGON_OFFSET_FILL);");
1344 glEnable(GL_POLYGON_OFFSET_LINE
);
1345 checkGLcall("glEnable(GL_POLYGON_OFFSET_LINE);");
1346 glEnable(GL_POLYGON_OFFSET_POINT
);
1347 checkGLcall("glEnable(GL_POLYGON_OFFSET_POINT);");
1349 glDisable(GL_POLYGON_OFFSET_FILL
);
1350 checkGLcall("glDisable(GL_POLYGON_OFFSET_FILL);");
1351 glDisable(GL_POLYGON_OFFSET_LINE
);
1352 checkGLcall("glDisable(GL_POLYGON_OFFSET_LINE);");
1353 glDisable(GL_POLYGON_OFFSET_POINT
);
1354 checkGLcall("glDisable(GL_POLYGON_OFFSET_POINT);");
1359 static void state_normalize(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1361 if(isStateDirty(context
, STATE_VDECL
)) {
1364 /* Without vertex normals, we set the current normal to 0/0/0 to remove the diffuse factor
1365 * from the opengl lighting equation, as d3d does. Normalization of 0/0/0 can lead to a division
1366 * by zero and is not properly defined in opengl, so avoid it
1368 if (stateblock
->renderState
[WINED3DRS_NORMALIZENORMALS
]
1369 && (stateblock
->device
->strided_streams
.use_map
& (1 << WINED3D_FFP_NORMAL
)))
1371 glEnable(GL_NORMALIZE
);
1372 checkGLcall("glEnable(GL_NORMALIZE);");
1374 glDisable(GL_NORMALIZE
);
1375 checkGLcall("glDisable(GL_NORMALIZE);");
1379 static void state_psizemin_w(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1386 tmpvalue
.d
= stateblock
->renderState
[WINED3DRS_POINTSIZE_MIN
];
1387 if (tmpvalue
.f
!= 1.0f
)
1389 FIXME("WINED3DRS_POINTSIZE_MIN not supported on this opengl, value is %f\n", tmpvalue
.f
);
1391 tmpvalue
.d
= stateblock
->renderState
[WINED3DRS_POINTSIZE_MAX
];
1392 if (tmpvalue
.f
!= 64.0f
)
1394 FIXME("WINED3DRS_POINTSIZE_MAX not supported on this opengl, value is %f\n", tmpvalue
.f
);
1399 static void state_psizemin_ext(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1406 min
.d
= stateblock
->renderState
[WINED3DRS_POINTSIZE_MIN
];
1407 max
.d
= stateblock
->renderState
[WINED3DRS_POINTSIZE_MAX
];
1409 /* Max point size trumps min point size */
1414 GL_EXTCALL(glPointParameterfEXT
)(GL_POINT_SIZE_MIN_EXT
, min
.f
);
1415 checkGLcall("glPointParameterfEXT(...)");
1416 GL_EXTCALL(glPointParameterfEXT
)(GL_POINT_SIZE_MAX_EXT
, max
.f
);
1417 checkGLcall("glPointParameterfEXT(...)");
1420 static void state_psizemin_arb(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1427 min
.d
= stateblock
->renderState
[WINED3DRS_POINTSIZE_MIN
];
1428 max
.d
= stateblock
->renderState
[WINED3DRS_POINTSIZE_MAX
];
1430 /* Max point size trumps min point size */
1435 GL_EXTCALL(glPointParameterfARB
)(GL_POINT_SIZE_MIN_ARB
, min
.f
);
1436 checkGLcall("glPointParameterfARB(...)");
1437 GL_EXTCALL(glPointParameterfARB
)(GL_POINT_SIZE_MAX_ARB
, max
.f
);
1438 checkGLcall("glPointParameterfARB(...)");
1441 static void state_pscale(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1443 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1444 /* TODO: Group this with the viewport */
1446 * POINTSCALEENABLE controls how point size value is treated. If set to
1447 * true, the point size is scaled with respect to height of viewport.
1448 * When set to false point size is in pixels.
1451 /* Default values */
1452 GLfloat att
[3] = {1.0f
, 0.0f
, 0.0f
};
1456 } pointSize
, A
, B
, C
;
1458 pointSize
.d
= stateblock
->renderState
[WINED3DRS_POINTSIZE
];
1459 A
.d
= stateblock
->renderState
[WINED3DRS_POINTSCALE_A
];
1460 B
.d
= stateblock
->renderState
[WINED3DRS_POINTSCALE_B
];
1461 C
.d
= stateblock
->renderState
[WINED3DRS_POINTSCALE_C
];
1463 if(stateblock
->renderState
[WINED3DRS_POINTSCALEENABLE
]) {
1464 GLfloat scaleFactor
;
1465 float h
= stateblock
->viewport
.Height
;
1467 if (pointSize
.f
< gl_info
->limits
.pointsize_min
)
1469 /* Minimum valid point size for OpenGL is driver specific. For Direct3D it is
1470 * 0.0f. This means that OpenGL will clamp really small point sizes to the
1471 * driver minimum. To correct for this we need to multiply by the scale factor when sizes
1472 * are less than 1.0f. scale_factor = 1.0f / point_size.
1474 scaleFactor
= pointSize
.f
/ gl_info
->limits
.pointsize_min
;
1475 /* Clamp the point size, don't rely on the driver to do it. MacOS says min point size
1476 * is 1.0, but then accepts points below that and draws too small points
1478 pointSize
.f
= gl_info
->limits
.pointsize_min
;
1480 else if(pointSize
.f
> gl_info
->limits
.pointsize_max
)
1482 /* gl already scales the input to glPointSize,
1483 * d3d scales the result after the point size scale.
1484 * If the point size is bigger than the max size, use the
1485 * scaling to scale it bigger, and set the gl point size to max
1487 scaleFactor
= pointSize
.f
/ gl_info
->limits
.pointsize_max
;
1488 TRACE("scale: %f\n", scaleFactor
);
1489 pointSize
.f
= gl_info
->limits
.pointsize_max
;
1493 scaleFactor
= pow(h
* scaleFactor
, 2);
1495 att
[0] = A
.f
/ scaleFactor
;
1496 att
[1] = B
.f
/ scaleFactor
;
1497 att
[2] = C
.f
/ scaleFactor
;
1500 if (gl_info
->supported
[ARB_POINT_PARAMETERS
])
1502 GL_EXTCALL(glPointParameterfvARB
)(GL_POINT_DISTANCE_ATTENUATION_ARB
, att
);
1503 checkGLcall("glPointParameterfvARB(GL_DISTANCE_ATTENUATION_ARB, ...)");
1505 else if (gl_info
->supported
[EXT_POINT_PARAMETERS
])
1507 GL_EXTCALL(glPointParameterfvEXT
)(GL_DISTANCE_ATTENUATION_EXT
, att
);
1508 checkGLcall("glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, ...)");
1509 } else if(stateblock
->renderState
[WINED3DRS_POINTSCALEENABLE
]) {
1510 WARN("POINT_PARAMETERS not supported in this version of opengl\n");
1513 glPointSize(pointSize
.f
);
1514 checkGLcall("glPointSize(...);");
1517 static void state_debug_monitor(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1519 WARN("token: %#x\n", stateblock
->renderState
[WINED3DRS_DEBUGMONITORTOKEN
]);
1522 static void state_colorwrite(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1524 DWORD Value
= stateblock
->renderState
[WINED3DRS_COLORWRITEENABLE
];
1526 TRACE("Color mask: r(%d) g(%d) b(%d) a(%d)\n",
1527 Value
& WINED3DCOLORWRITEENABLE_RED
? 1 : 0,
1528 Value
& WINED3DCOLORWRITEENABLE_GREEN
? 1 : 0,
1529 Value
& WINED3DCOLORWRITEENABLE_BLUE
? 1 : 0,
1530 Value
& WINED3DCOLORWRITEENABLE_ALPHA
? 1 : 0);
1531 glColorMask(Value
& WINED3DCOLORWRITEENABLE_RED
? GL_TRUE
: GL_FALSE
,
1532 Value
& WINED3DCOLORWRITEENABLE_GREEN
? GL_TRUE
: GL_FALSE
,
1533 Value
& WINED3DCOLORWRITEENABLE_BLUE
? GL_TRUE
: GL_FALSE
,
1534 Value
& WINED3DCOLORWRITEENABLE_ALPHA
? GL_TRUE
: GL_FALSE
);
1535 checkGLcall("glColorMask(...)");
1537 /* depends on WINED3DRS_COLORWRITEENABLE. */
1538 if(stateblock
->renderState
[WINED3DRS_COLORWRITEENABLE1
] != 0x0000000F ||
1539 stateblock
->renderState
[WINED3DRS_COLORWRITEENABLE2
] != 0x0000000F ||
1540 stateblock
->renderState
[WINED3DRS_COLORWRITEENABLE3
] != 0x0000000F ) {
1541 ERR("(WINED3DRS_COLORWRITEENABLE1/2/3,%d,%d,%d) not yet implemented. Missing of cap D3DPMISCCAPS_INDEPENDENTWRITEMASKS wasn't honored?\n",
1542 stateblock
->renderState
[WINED3DRS_COLORWRITEENABLE1
],
1543 stateblock
->renderState
[WINED3DRS_COLORWRITEENABLE2
],
1544 stateblock
->renderState
[WINED3DRS_COLORWRITEENABLE3
]);
1548 static void state_localviewer(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1550 if(stateblock
->renderState
[WINED3DRS_LOCALVIEWER
]) {
1551 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER
, 1);
1552 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1)");
1554 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER
, 0);
1555 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 0)");
1559 static void state_lastpixel(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1561 if(stateblock
->renderState
[WINED3DRS_LASTPIXEL
]) {
1562 TRACE("Last Pixel Drawing Enabled\n");
1566 FIXME("Last Pixel Drawing Disabled, not handled yet\n");
1569 TRACE("Last Pixel Drawing Disabled, not handled yet\n");
1574 static void state_pointsprite_w(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1578 /* TODO: NV_POINT_SPRITE */
1579 if (!warned
&& stateblock
->renderState
[WINED3DRS_POINTSPRITEENABLE
]) {
1580 /* A FIXME, not a WARN because point sprites should be software emulated if not supported by HW */
1581 FIXME("Point sprites not supported\n");
1586 static void state_pointsprite(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1588 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1590 if (stateblock
->renderState
[WINED3DRS_POINTSPRITEENABLE
])
1594 if (gl_info
->limits
.point_sprite_units
< gl_info
->limits
.textures
&& !warned
)
1596 if (use_ps(stateblock
) || stateblock
->lowest_disabled_stage
> gl_info
->limits
.point_sprite_units
)
1598 FIXME("The app uses point sprite texture coordinates on more units than supported by the driver\n");
1603 glEnable(GL_POINT_SPRITE_ARB
);
1604 checkGLcall("glEnable(GL_POINT_SPRITE_ARB)");
1606 glDisable(GL_POINT_SPRITE_ARB
);
1607 checkGLcall("glDisable(GL_POINT_SPRITE_ARB)");
1611 static void state_wrap(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1614 http://www.cosc.brocku.ca/Offerings/3P98/course/lectures/texture/
1615 http://www.gamedev.net/reference/programming/features/rendererdll3/page2.asp
1616 Discussion on the ways to turn on WRAPing to solve an OpenGL conversion problem.
1617 http://www.flipcode.org/cgi-bin/fcmsg.cgi?thread_show=10248
1619 so far as I can tell, wrapping and texture-coordinate generate go hand in hand,
1622 if(stateblock
->renderState
[WINED3DRS_WRAP0
] ||
1623 stateblock
->renderState
[WINED3DRS_WRAP1
] ||
1624 stateblock
->renderState
[WINED3DRS_WRAP2
] ||
1625 stateblock
->renderState
[WINED3DRS_WRAP3
] ||
1626 stateblock
->renderState
[WINED3DRS_WRAP4
] ||
1627 stateblock
->renderState
[WINED3DRS_WRAP5
] ||
1628 stateblock
->renderState
[WINED3DRS_WRAP6
] ||
1629 stateblock
->renderState
[WINED3DRS_WRAP7
] ||
1630 stateblock
->renderState
[WINED3DRS_WRAP8
] ||
1631 stateblock
->renderState
[WINED3DRS_WRAP9
] ||
1632 stateblock
->renderState
[WINED3DRS_WRAP10
] ||
1633 stateblock
->renderState
[WINED3DRS_WRAP11
] ||
1634 stateblock
->renderState
[WINED3DRS_WRAP12
] ||
1635 stateblock
->renderState
[WINED3DRS_WRAP13
] ||
1636 stateblock
->renderState
[WINED3DRS_WRAP14
] ||
1637 stateblock
->renderState
[WINED3DRS_WRAP15
] ) {
1638 FIXME("(WINED3DRS_WRAP0) Texture wrapping not yet supported\n");
1642 static void state_msaa_w(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1644 if(stateblock
->renderState
[WINED3DRS_MULTISAMPLEANTIALIAS
]) {
1645 WARN("Multisample antialiasing not supported by gl\n");
1649 static void state_msaa(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1651 if(stateblock
->renderState
[WINED3DRS_MULTISAMPLEANTIALIAS
]) {
1652 glEnable(GL_MULTISAMPLE_ARB
);
1653 checkGLcall("glEnable(GL_MULTISAMPLE_ARB)");
1655 glDisable(GL_MULTISAMPLE_ARB
);
1656 checkGLcall("glDisable(GL_MULTISAMPLE_ARB)");
1660 static void state_scissor(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1662 if(stateblock
->renderState
[WINED3DRS_SCISSORTESTENABLE
]) {
1663 glEnable(GL_SCISSOR_TEST
);
1664 checkGLcall("glEnable(GL_SCISSOR_TEST)");
1666 glDisable(GL_SCISSOR_TEST
);
1667 checkGLcall("glDisable(GL_SCISSOR_TEST)");
1671 /* The Direct3D depth bias is specified in normalized depth coordinates. In
1672 * OpenGL the bias is specified in units of "the smallest value that is
1673 * guaranteed to produce a resolvable offset for a given implementation". To
1674 * convert from D3D to GL we need to divide the D3D depth bias by that value.
1675 * There's no practical way to retrieve that value from a given GL
1676 * implementation, but the D3D application has essentially the same problem,
1677 * which makes a guess of 1e-6f seem reasonable here. Note that
1678 * SLOPESCALEDEPTHBIAS is a scaling factor for the depth slope, and doesn't
1679 * need to be scaled. */
1680 static void state_depthbias(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1682 if (stateblock
->renderState
[WINED3DRS_SLOPESCALEDEPTHBIAS
]
1683 || stateblock
->renderState
[WINED3DRS_DEPTHBIAS
])
1689 } scale_bias
, const_bias
;
1691 scale_bias
.d
= stateblock
->renderState
[WINED3DRS_SLOPESCALEDEPTHBIAS
];
1692 const_bias
.d
= stateblock
->renderState
[WINED3DRS_DEPTHBIAS
];
1694 glEnable(GL_POLYGON_OFFSET_FILL
);
1695 checkGLcall("glEnable(GL_POLYGON_OFFSET_FILL)");
1697 glPolygonOffset(scale_bias
.f
, const_bias
.f
* 1e6f
);
1698 checkGLcall("glPolygonOffset(...)");
1700 glDisable(GL_POLYGON_OFFSET_FILL
);
1701 checkGLcall("glDisable(GL_POLYGON_OFFSET_FILL)");
1705 static void state_perspective(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1707 if (stateblock
->renderState
[WINED3DRS_TEXTUREPERSPECTIVE
]) {
1708 glHint(GL_PERSPECTIVE_CORRECTION_HINT
, GL_NICEST
);
1709 checkGLcall("glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)");
1711 glHint(GL_PERSPECTIVE_CORRECTION_HINT
, GL_FASTEST
);
1712 checkGLcall("glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST)");
1716 static void state_stippledalpha(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1719 if (stateblock
->renderState
[WINED3DRS_STIPPLEDALPHA
])
1720 FIXME(" Stippled Alpha not supported yet.\n");
1723 static void state_antialias(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1726 if (stateblock
->renderState
[WINED3DRS_ANTIALIAS
])
1727 FIXME(" Antialias not supported yet.\n");
1730 static void state_multisampmask(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1733 if (stateblock
->renderState
[WINED3DRS_MULTISAMPLEMASK
] != 0xFFFFFFFF)
1734 FIXME("(WINED3DRS_MULTISAMPLEMASK,%d) not yet implemented\n", stateblock
->renderState
[WINED3DRS_MULTISAMPLEMASK
]);
1737 static void state_patchedgestyle(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1740 if (stateblock
->renderState
[WINED3DRS_PATCHEDGESTYLE
] != WINED3DPATCHEDGE_DISCRETE
)
1741 FIXME("(WINED3DRS_PATCHEDGESTYLE,%d) not yet implemented\n", stateblock
->renderState
[WINED3DRS_PATCHEDGESTYLE
]);
1744 static void state_patchsegments(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1753 if (stateblock
->renderState
[WINED3DRS_PATCHSEGMENTS
] != tmpvalue
.d
)
1755 static BOOL displayed
= FALSE
;
1757 tmpvalue
.d
= stateblock
->renderState
[WINED3DRS_PATCHSEGMENTS
];
1759 FIXME("(WINED3DRS_PATCHSEGMENTS,%f) not yet implemented\n", tmpvalue
.f
);
1765 static void state_positiondegree(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1768 if (stateblock
->renderState
[WINED3DRS_POSITIONDEGREE
] != WINED3DDEGREE_CUBIC
)
1769 FIXME("(WINED3DRS_POSITIONDEGREE,%d) not yet implemented\n", stateblock
->renderState
[WINED3DRS_POSITIONDEGREE
]);
1772 static void state_normaldegree(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1775 if (stateblock
->renderState
[WINED3DRS_NORMALDEGREE
] != WINED3DDEGREE_LINEAR
)
1776 FIXME("(WINED3DRS_NORMALDEGREE,%d) not yet implemented\n", stateblock
->renderState
[WINED3DRS_NORMALDEGREE
]);
1779 static void state_tessellation(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1782 if(stateblock
->renderState
[WINED3DRS_ENABLEADAPTIVETESSELLATION
])
1783 FIXME("(WINED3DRS_ENABLEADAPTIVETESSELLATION,%d) not yet implemented\n", stateblock
->renderState
[WINED3DRS_ENABLEADAPTIVETESSELLATION
]);
1786 static void state_wrapu(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1788 if(stateblock
->renderState
[WINED3DRS_WRAPU
]) {
1789 FIXME("Render state WINED3DRS_WRAPU not implemented yet\n");
1793 static void state_wrapv(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1795 if(stateblock
->renderState
[WINED3DRS_WRAPV
]) {
1796 FIXME("Render state WINED3DRS_WRAPV not implemented yet\n");
1800 static void state_monoenable(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1802 if(stateblock
->renderState
[WINED3DRS_MONOENABLE
]) {
1803 FIXME("Render state WINED3DRS_MONOENABLE not implemented yet\n");
1807 static void state_rop2(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1809 if(stateblock
->renderState
[WINED3DRS_ROP2
]) {
1810 FIXME("Render state WINED3DRS_ROP2 not implemented yet\n");
1814 static void state_planemask(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1816 if(stateblock
->renderState
[WINED3DRS_PLANEMASK
]) {
1817 FIXME("Render state WINED3DRS_PLANEMASK not implemented yet\n");
1821 static void state_subpixel(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1823 if(stateblock
->renderState
[WINED3DRS_SUBPIXEL
]) {
1824 FIXME("Render state WINED3DRS_SUBPIXEL not implemented yet\n");
1828 static void state_subpixelx(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1830 if(stateblock
->renderState
[WINED3DRS_SUBPIXELX
]) {
1831 FIXME("Render state WINED3DRS_SUBPIXELX not implemented yet\n");
1835 static void state_stippleenable(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1837 if(stateblock
->renderState
[WINED3DRS_STIPPLEENABLE
]) {
1838 FIXME("Render state WINED3DRS_STIPPLEENABLE not implemented yet\n");
1842 static void state_bordercolor(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1844 if(stateblock
->renderState
[WINED3DRS_BORDERCOLOR
]) {
1845 FIXME("Render state WINED3DRS_BORDERCOLOR not implemented yet\n");
1849 static void state_mipmaplodbias(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1851 if(stateblock
->renderState
[WINED3DRS_MIPMAPLODBIAS
]) {
1852 FIXME("Render state WINED3DRS_MIPMAPLODBIAS not implemented yet\n");
1856 static void state_anisotropy(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1858 if(stateblock
->renderState
[WINED3DRS_ANISOTROPY
]) {
1859 FIXME("Render state WINED3DRS_ANISOTROPY not implemented yet\n");
1863 static void state_flushbatch(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1865 if(stateblock
->renderState
[WINED3DRS_FLUSHBATCH
]) {
1866 FIXME("Render state WINED3DRS_FLUSHBATCH not implemented yet\n");
1870 static void state_translucentsi(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1872 if(stateblock
->renderState
[WINED3DRS_TRANSLUCENTSORTINDEPENDENT
]) {
1873 FIXME("Render state WINED3DRS_TRANSLUCENTSORTINDEPENDENT not implemented yet\n");
1877 static void state_extents(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1879 if(stateblock
->renderState
[WINED3DRS_EXTENTS
]) {
1880 FIXME("Render state WINED3DRS_EXTENTS not implemented yet\n");
1884 static void state_ckeyblend(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1886 if(stateblock
->renderState
[WINED3DRS_COLORKEYBLENDENABLE
]) {
1887 FIXME("Render state WINED3DRS_COLORKEYBLENDENABLE not implemented yet\n");
1891 static void state_swvp(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
1893 if (stateblock
->renderState
[WINED3DRS_SOFTWAREVERTEXPROCESSING
])
1895 FIXME("Software vertex processing not implemented.\n");
1899 /* Set texture operations up - The following avoids lots of ifdefs in this routine!*/
1900 #if defined (GL_VERSION_1_3)
1901 # define useext(A) A
1902 #elif defined (GL_EXT_texture_env_combine)
1903 # define useext(A) A##_EXT
1904 #elif defined (GL_ARB_texture_env_combine)
1905 # define useext(A) A##_ARB
1908 static void get_src_and_opr(DWORD arg
, BOOL is_alpha
, GLenum
* source
, GLenum
* operand
) {
1909 /* The WINED3DTA_ALPHAREPLICATE flag specifies the alpha component of the
1910 * input should be used for all input components. The WINED3DTA_COMPLEMENT
1911 * flag specifies the complement of the input should be used. */
1912 BOOL from_alpha
= is_alpha
|| arg
& WINED3DTA_ALPHAREPLICATE
;
1913 BOOL complement
= arg
& WINED3DTA_COMPLEMENT
;
1915 /* Calculate the operand */
1917 if (from_alpha
) *operand
= GL_ONE_MINUS_SRC_ALPHA
;
1918 else *operand
= GL_ONE_MINUS_SRC_COLOR
;
1920 if (from_alpha
) *operand
= GL_SRC_ALPHA
;
1921 else *operand
= GL_SRC_COLOR
;
1924 /* Calculate the source */
1925 switch (arg
& WINED3DTA_SELECTMASK
) {
1926 case WINED3DTA_CURRENT
: *source
= GL_PREVIOUS_EXT
; break;
1927 case WINED3DTA_DIFFUSE
: *source
= GL_PRIMARY_COLOR_EXT
; break;
1928 case WINED3DTA_TEXTURE
: *source
= GL_TEXTURE
; break;
1929 case WINED3DTA_TFACTOR
: *source
= GL_CONSTANT_EXT
; break;
1930 case WINED3DTA_SPECULAR
:
1932 * According to the GL_ARB_texture_env_combine specs, SPECULAR is
1933 * 'Secondary color' and isn't supported until base GL supports it
1934 * There is no concept of temp registers as far as I can tell
1936 FIXME("Unhandled texture arg WINED3DTA_SPECULAR\n");
1937 *source
= GL_TEXTURE
;
1940 FIXME("Unrecognized texture arg %#x\n", arg
);
1941 *source
= GL_TEXTURE
;
1946 /* Setup the texture operations texture stage states */
1947 static void set_tex_op(const struct wined3d_context
*context
, IWineD3DDevice
*iface
,
1948 BOOL isAlpha
, int Stage
, WINED3DTEXTUREOP op
, DWORD arg1
, DWORD arg2
, DWORD arg3
)
1950 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1951 GLenum src1
, src2
, src3
;
1952 GLenum opr1
, opr2
, opr3
;
1954 GLenum src0_target
, src1_target
, src2_target
;
1955 GLenum opr0_target
, opr1_target
, opr2_target
;
1957 GLenum opr
=0, invopr
, src3_target
, opr3_target
;
1958 BOOL Handled
= FALSE
;
1959 IWineD3DDeviceImpl
*This
= (IWineD3DDeviceImpl
*)iface
;
1961 TRACE("Alpha?(%d), Stage:%d Op(%s), a1(%d), a2(%d), a3(%d)\n", isAlpha
, Stage
, debug_d3dtop(op
), arg1
, arg2
, arg3
);
1963 /* This is called by a state handler which has the gl lock held and a context for the thread */
1965 /* Note: Operations usually involve two ars, src0 and src1 and are operations of
1966 the form (a1 <operation> a2). However, some of the more complex operations
1967 take 3 parameters. Instead of the (sensible) addition of a3, Microsoft added
1968 in a third parameter called a0. Therefore these are operations of the form
1969 a0 <operation> a1 <operation> a2, i.e., the new parameter goes to the front.
1971 However, below we treat the new (a0) parameter as src2/opr2, so in the actual
1972 functions below, expect their syntax to differ slightly to those listed in the
1973 manuals, i.e., replace arg1 with arg3, arg2 with arg1 and arg3 with arg2
1974 This affects WINED3DTOP_MULTIPLYADD and WINED3DTOP_LERP */
1977 comb_target
= useext(GL_COMBINE_ALPHA
);
1978 src0_target
= useext(GL_SOURCE0_ALPHA
);
1979 src1_target
= useext(GL_SOURCE1_ALPHA
);
1980 src2_target
= useext(GL_SOURCE2_ALPHA
);
1981 opr0_target
= useext(GL_OPERAND0_ALPHA
);
1982 opr1_target
= useext(GL_OPERAND1_ALPHA
);
1983 opr2_target
= useext(GL_OPERAND2_ALPHA
);
1984 scal_target
= GL_ALPHA_SCALE
;
1987 comb_target
= useext(GL_COMBINE_RGB
);
1988 src0_target
= useext(GL_SOURCE0_RGB
);
1989 src1_target
= useext(GL_SOURCE1_RGB
);
1990 src2_target
= useext(GL_SOURCE2_RGB
);
1991 opr0_target
= useext(GL_OPERAND0_RGB
);
1992 opr1_target
= useext(GL_OPERAND1_RGB
);
1993 opr2_target
= useext(GL_OPERAND2_RGB
);
1994 scal_target
= useext(GL_RGB_SCALE
);
1997 /* If a texture stage references an invalid texture unit the stage just
1998 * passes through the result from the previous stage */
1999 if (is_invalid_op(This
, Stage
, op
, arg1
, arg2
, arg3
)) {
2000 arg1
= WINED3DTA_CURRENT
;
2001 op
= WINED3DTOP_SELECTARG1
;
2004 if (isAlpha
&& This
->stateBlock
->textures
[Stage
] == NULL
&& arg1
== WINED3DTA_TEXTURE
) {
2005 get_src_and_opr(WINED3DTA_DIFFUSE
, isAlpha
, &src1
, &opr1
);
2007 get_src_and_opr(arg1
, isAlpha
, &src1
, &opr1
);
2009 get_src_and_opr(arg2
, isAlpha
, &src2
, &opr2
);
2010 get_src_and_opr(arg3
, isAlpha
, &src3
, &opr3
);
2012 TRACE("ct(%x), 1:(%x,%x), 2:(%x,%x), 3:(%x,%x)\n", comb_target
, src1
, opr1
, src2
, opr2
, src3
, opr3
);
2014 Handled
= TRUE
; /* Assume will be handled */
2016 /* Other texture operations require special extensions: */
2017 if (gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
2021 invopr
= GL_ONE_MINUS_SRC_ALPHA
;
2022 src3_target
= GL_SOURCE3_ALPHA_NV
;
2023 opr3_target
= GL_OPERAND3_ALPHA_NV
;
2026 invopr
= GL_ONE_MINUS_SRC_COLOR
;
2027 src3_target
= GL_SOURCE3_RGB_NV
;
2028 opr3_target
= GL_OPERAND3_RGB_NV
;
2031 case WINED3DTOP_DISABLE
: /* Only for alpha */
2032 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2033 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2034 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_PREVIOUS_EXT
);
2035 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2036 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_SRC_ALPHA
);
2037 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2038 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2039 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2040 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2041 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2042 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2043 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_ZERO");
2044 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2045 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2046 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2047 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2048 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2049 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2051 case WINED3DTOP_SELECTARG1
: /* = a1 * 1 + 0 * 0 */
2052 case WINED3DTOP_SELECTARG2
: /* = a2 * 1 + 0 * 0 */
2053 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2054 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2055 if (op
== WINED3DTOP_SELECTARG1
) {
2056 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2057 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2058 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2059 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2061 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src2
);
2062 checkGLcall("GL_TEXTURE_ENV, src0_target, src2");
2063 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr2
);
2064 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr2");
2066 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2067 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2068 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2069 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2070 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2071 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_ZERO");
2072 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2073 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2074 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2075 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2076 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2077 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2080 case WINED3DTOP_MODULATE
:
2081 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2082 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2083 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2084 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2085 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2086 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2087 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2088 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2089 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2090 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2091 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2092 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2093 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2094 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2095 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2096 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2097 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2098 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2099 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2100 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2102 case WINED3DTOP_MODULATE2X
:
2103 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2104 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2105 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2106 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2107 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2108 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2109 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2110 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2111 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2112 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2113 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2114 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2115 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2116 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2117 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2118 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2119 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2120 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2121 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2122 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2124 case WINED3DTOP_MODULATE4X
:
2125 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2126 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2127 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2128 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2129 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2130 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2131 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2132 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2133 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2134 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2135 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2136 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2137 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2138 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2139 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2140 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2141 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2142 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2143 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 4);
2144 checkGLcall("GL_TEXTURE_ENV, scal_target, 4");
2147 case WINED3DTOP_ADD
:
2148 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2149 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2150 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2151 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2152 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2153 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2154 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2155 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2156 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2157 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2158 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2159 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2160 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2161 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2162 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2163 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2164 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2165 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2166 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2167 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2170 case WINED3DTOP_ADDSIGNED
:
2171 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_ADD_SIGNED
));
2172 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_ADD_SIGNED)");
2173 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2174 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2175 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2176 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2177 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2178 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2179 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2180 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2181 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2182 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2183 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2184 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2185 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2186 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2187 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2188 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2189 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2190 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2193 case WINED3DTOP_ADDSIGNED2X
:
2194 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_ADD_SIGNED
));
2195 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_ADD_SIGNED)");
2196 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2197 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2198 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2199 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2200 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2201 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2202 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2203 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2204 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2205 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2206 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2207 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2208 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2209 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2210 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2211 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2212 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2213 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2216 case WINED3DTOP_ADDSMOOTH
:
2217 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2218 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2219 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2220 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2221 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2222 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2223 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2224 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2225 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2226 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2227 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2228 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2229 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2230 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2231 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
2232 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2234 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2235 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2236 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2237 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2239 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2240 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2241 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2242 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2245 case WINED3DTOP_BLENDDIFFUSEALPHA
:
2246 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2247 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2248 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2249 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2250 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2251 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2252 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, useext(GL_PRIMARY_COLOR
));
2253 checkGLcall("GL_TEXTURE_ENV, src1_target, useext(GL_PRIMARY_COLOR)");
2254 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2255 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2256 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2257 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2258 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2259 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2260 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, useext(GL_PRIMARY_COLOR
));
2261 checkGLcall("GL_TEXTURE_ENV, src3_target, useext(GL_PRIMARY_COLOR)");
2262 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2263 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2264 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2265 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2267 case WINED3DTOP_BLENDTEXTUREALPHA
:
2268 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2269 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2270 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2271 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2272 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2273 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2274 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_TEXTURE
);
2275 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_TEXTURE");
2276 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2277 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2278 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2279 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2280 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2281 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2282 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_TEXTURE
);
2283 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_TEXTURE");
2284 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2285 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2286 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2287 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2289 case WINED3DTOP_BLENDFACTORALPHA
:
2290 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2291 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2292 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2293 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2294 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2295 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2296 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, useext(GL_CONSTANT
));
2297 checkGLcall("GL_TEXTURE_ENV, src1_target, useext(GL_CONSTANT)");
2298 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2299 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2300 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2301 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2302 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2303 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2304 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, useext(GL_CONSTANT
));
2305 checkGLcall("GL_TEXTURE_ENV, src3_target, useext(GL_CONSTANT)");
2306 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2307 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2308 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2309 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2311 case WINED3DTOP_BLENDTEXTUREALPHAPM
:
2312 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2313 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2314 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2315 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2316 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2317 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2318 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2319 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2320 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2321 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2322 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2323 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2324 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2325 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2326 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_TEXTURE
);
2327 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_TEXTURE");
2328 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2329 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2330 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2331 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2333 case WINED3DTOP_MODULATEALPHA_ADDCOLOR
:
2334 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2335 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2336 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
); /* a0 = src1/opr1 */
2337 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2338 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2339 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1"); /* a1 = 1 (see docs) */
2340 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2341 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2342 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2343 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2344 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
); /* a2 = arg2 */
2345 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2346 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2347 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2"); /* a3 = src1 alpha */
2348 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
2349 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2351 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2352 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2354 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2355 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2356 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2357 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2359 case WINED3DTOP_MODULATECOLOR_ADDALPHA
:
2360 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2361 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2362 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2363 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2364 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2365 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2366 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2367 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2368 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2369 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2370 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
2371 checkGLcall("GL_TEXTURE_ENV, src2_target, src1");
2373 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2374 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2376 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2377 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2378 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2379 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2380 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2381 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2382 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2383 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2385 case WINED3DTOP_MODULATEINVALPHA_ADDCOLOR
:
2386 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2387 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2388 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2389 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2390 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2391 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2392 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2393 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2394 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2395 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2396 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2397 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2398 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2399 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2400 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
2401 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2403 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2404 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2405 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2406 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2408 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2409 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2410 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2411 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2413 case WINED3DTOP_MODULATEINVCOLOR_ADDALPHA
:
2414 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2415 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2416 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2417 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2419 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2420 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2421 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2422 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2424 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2425 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2426 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2427 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2428 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2429 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2430 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
2431 checkGLcall("GL_TEXTURE_ENV, src2_target, src1");
2433 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2434 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2436 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2437 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2438 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2439 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2440 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2441 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2442 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2443 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2445 case WINED3DTOP_MULTIPLYADD
:
2446 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2447 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2448 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src3
);
2449 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2450 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr3
);
2451 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2452 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2453 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2454 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2455 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2456 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
2457 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2458 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr1
);
2459 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2460 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src2
);
2461 checkGLcall("GL_TEXTURE_ENV, src3_target, src3");
2462 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr2
);
2463 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr3");
2464 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2465 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2468 case WINED3DTOP_BUMPENVMAP
:
2472 case WINED3DTOP_BUMPENVMAPLUMINANCE
:
2473 FIXME("Implement bump environment mapping in GL_NV_texture_env_combine4 path\n");
2479 glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_COMBINE4_NV
);
2480 checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV");
2484 } /* GL_NV_texture_env_combine4 */
2486 Handled
= TRUE
; /* Again, assume handled */
2488 case WINED3DTOP_DISABLE
: /* Only for alpha */
2489 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
2490 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2491 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_PREVIOUS_EXT
);
2492 checkGLcall("GL_TEXTURE_ENV, src0_target, GL_PREVIOUS_EXT");
2493 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_SRC_ALPHA
);
2494 checkGLcall("GL_TEXTURE_ENV, opr0_target, GL_SRC_ALPHA");
2495 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2496 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2498 case WINED3DTOP_SELECTARG1
:
2499 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
2500 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2501 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2502 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2503 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2504 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2505 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2506 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2508 case WINED3DTOP_SELECTARG2
:
2509 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
2510 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2511 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src2
);
2512 checkGLcall("GL_TEXTURE_ENV, src0_target, src2");
2513 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr2
);
2514 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr2");
2515 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2516 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2518 case WINED3DTOP_MODULATE
:
2519 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
2520 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2521 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2522 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2523 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2524 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2525 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2526 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2527 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2528 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2529 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2530 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2532 case WINED3DTOP_MODULATE2X
:
2533 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
2534 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2535 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2536 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2537 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2538 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2539 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2540 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2541 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2542 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2543 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2544 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2546 case WINED3DTOP_MODULATE4X
:
2547 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
2548 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
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
, scal_target
, 4);
2558 checkGLcall("GL_TEXTURE_ENV, scal_target, 4");
2560 case WINED3DTOP_ADD
:
2561 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2562 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2563 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2564 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2565 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2566 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2567 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2568 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2569 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2570 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2571 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2572 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2574 case WINED3DTOP_ADDSIGNED
:
2575 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_ADD_SIGNED
));
2576 checkGLcall("GL_TEXTURE_ENV, comb_target, useext((GL_ADD_SIGNED)");
2577 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2578 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2579 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2580 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2581 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2582 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2583 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2584 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2585 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2586 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2588 case WINED3DTOP_ADDSIGNED2X
:
2589 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_ADD_SIGNED
));
2590 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_ADD_SIGNED)");
2591 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2592 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2593 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2594 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2595 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2596 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2597 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2598 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2599 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2600 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2602 case WINED3DTOP_SUBTRACT
:
2603 if (gl_info
->supported
[ARB_TEXTURE_ENV_COMBINE
])
2605 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_SUBTRACT
);
2606 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_SUBTRACT)");
2607 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2608 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2609 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2610 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2611 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2612 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2613 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2614 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2615 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2616 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2618 FIXME("This version of opengl does not support GL_SUBTRACT\n");
2622 case WINED3DTOP_BLENDDIFFUSEALPHA
:
2623 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_INTERPOLATE
));
2624 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_INTERPOLATE)");
2625 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2626 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2627 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2628 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2629 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2630 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2631 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2632 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2633 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, useext(GL_PRIMARY_COLOR
));
2634 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_PRIMARY_COLOR");
2635 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2636 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2637 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2638 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2640 case WINED3DTOP_BLENDTEXTUREALPHA
:
2641 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_INTERPOLATE
));
2642 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_INTERPOLATE)");
2643 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2644 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2645 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2646 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2647 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2648 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2649 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2650 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2651 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_TEXTURE
);
2652 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_TEXTURE");
2653 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2654 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2655 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2656 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2658 case WINED3DTOP_BLENDFACTORALPHA
:
2659 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_INTERPOLATE
));
2660 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_INTERPOLATE)");
2661 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2662 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2663 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2664 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2665 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2666 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2667 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2668 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2669 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, useext(GL_CONSTANT
));
2670 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_CONSTANT");
2671 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2672 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2673 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2674 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2676 case WINED3DTOP_BLENDCURRENTALPHA
:
2677 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_INTERPOLATE
));
2678 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_INTERPOLATE)");
2679 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2680 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2681 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2682 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2683 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2684 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2685 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2686 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2687 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, useext(GL_PREVIOUS
));
2688 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_PREVIOUS");
2689 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2690 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2691 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2692 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2694 case WINED3DTOP_DOTPRODUCT3
:
2695 if (gl_info
->supported
[ARB_TEXTURE_ENV_DOT3
])
2697 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_DOT3_RGBA_ARB
);
2698 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_ARB");
2700 else if (gl_info
->supported
[EXT_TEXTURE_ENV_DOT3
])
2702 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_DOT3_RGBA_EXT
);
2703 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_EXT");
2705 FIXME("This version of opengl does not support GL_DOT3\n");
2707 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2708 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2709 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2710 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2711 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2712 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2713 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2714 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2715 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2716 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2718 case WINED3DTOP_LERP
:
2719 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, useext(GL_INTERPOLATE
));
2720 checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_INTERPOLATE)");
2721 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2722 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2723 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2724 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2725 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2726 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2727 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2728 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2729 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src3
);
2730 checkGLcall("GL_TEXTURE_ENV, src2_target, src3");
2731 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr3
);
2732 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr3");
2733 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2734 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2736 case WINED3DTOP_ADDSMOOTH
:
2737 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2739 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2740 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2741 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2742 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2744 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2745 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2746 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2747 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2749 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2750 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2751 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2752 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2753 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2754 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2755 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2756 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2757 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2758 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2759 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2760 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2764 case WINED3DTOP_BLENDTEXTUREALPHAPM
:
2765 if (gl_info
->supported
[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
, GL_TEXTURE
);
2770 checkGLcall("GL_TEXTURE_ENV, src0_target, GL_TEXTURE");
2771 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_ONE_MINUS_SRC_ALPHA
);
2772 checkGLcall("GL_TEXTURE_ENV, opr0_target, GL_ONE_MINUS_SRC_APHA");
2773 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2774 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2775 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2776 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
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_MODULATEALPHA_ADDCOLOR
:
2787 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2789 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2790 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2791 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2792 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2794 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2795 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2796 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2797 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2799 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2800 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2801 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2802 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2803 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2804 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2805 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2806 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2807 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2808 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2809 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2810 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2814 case WINED3DTOP_MODULATECOLOR_ADDALPHA
:
2815 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2817 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2818 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2819 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2820 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2821 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2822 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2823 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2824 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2826 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2827 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2828 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2829 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2831 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr
);
2832 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr");
2833 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2834 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2835 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2836 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2837 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2838 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2842 case WINED3DTOP_MODULATEINVALPHA_ADDCOLOR
:
2843 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2845 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2846 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2847 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2848 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2850 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2851 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2852 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2853 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2855 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2856 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2857 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2858 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2859 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2860 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2861 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2862 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2863 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2864 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2865 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2866 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2870 case WINED3DTOP_MODULATEINVCOLOR_ADDALPHA
:
2871 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2873 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2874 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2875 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2876 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2878 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2879 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2880 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2881 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2883 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2884 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2885 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2886 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2888 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2889 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2890 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2891 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2893 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr
);
2894 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr");
2895 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2896 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2897 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2898 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2899 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2900 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2904 case WINED3DTOP_MULTIPLYADD
:
2905 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2907 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2908 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2909 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2910 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2911 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2912 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2913 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src3
);
2914 checkGLcall("GL_TEXTURE_ENV, src1_target, src3");
2915 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr3
);
2916 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr3");
2917 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2918 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2919 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2920 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2921 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2922 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2926 case WINED3DTOP_BUMPENVMAPLUMINANCE
:
2927 case WINED3DTOP_BUMPENVMAP
:
2928 if (gl_info
->supported
[NV_TEXTURE_SHADER2
])
2930 /* Technically texture shader support without register combiners is possible, but not expected to occur
2931 * on real world cards, so for now a fixme should be enough
2933 FIXME("Implement bump mapping with GL_NV_texture_shader in non register combiner path\n");
2940 BOOL combineOK
= TRUE
;
2941 if (gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
2946 op2
= This
->stateBlock
->textureState
[Stage
][WINED3DTSS_COLOROP
];
2948 op2
= This
->stateBlock
->textureState
[Stage
][WINED3DTSS_ALPHAOP
];
2951 /* Note: If COMBINE4 in effect can't go back to combine! */
2953 case WINED3DTOP_ADDSMOOTH
:
2954 case WINED3DTOP_BLENDTEXTUREALPHAPM
:
2955 case WINED3DTOP_MODULATEALPHA_ADDCOLOR
:
2956 case WINED3DTOP_MODULATECOLOR_ADDALPHA
:
2957 case WINED3DTOP_MODULATEINVALPHA_ADDCOLOR
:
2958 case WINED3DTOP_MODULATEINVCOLOR_ADDALPHA
:
2959 case WINED3DTOP_MULTIPLYADD
:
2960 /* Ignore those implemented in both cases */
2962 case WINED3DTOP_SELECTARG1
:
2963 case WINED3DTOP_SELECTARG2
:
2968 FIXME("Can't use COMBINE4 and COMBINE together, thisop=%s, otherop=%s, isAlpha(%d)\n", debug_d3dtop(op
), debug_d3dtop(op2
), isAlpha
);
2975 glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, useext(GL_COMBINE
));
2976 checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, useext(GL_COMBINE)");
2982 /* After all the extensions, if still unhandled, report fixme */
2983 FIXME("Unhandled texture operation %s\n", debug_d3dtop(op
));
2987 static void tex_colorop(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
2989 DWORD stage
= (state
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
2990 BOOL tex_used
= stateblock
->device
->fixed_function_usage_map
& (1 << stage
);
2991 DWORD mapped_stage
= stateblock
->device
->texUnitMap
[stage
];
2992 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
2994 TRACE("Setting color op for stage %d\n", stage
);
2996 /* Using a pixel shader? Don't care for anything here, the shader applying does it */
2997 if (use_ps(stateblock
)) return;
2999 if (stage
!= mapped_stage
) WARN("Using non 1:1 mapping: %d -> %d!\n", stage
, mapped_stage
);
3001 if (mapped_stage
!= WINED3D_UNMAPPED_STAGE
)
3003 if (tex_used
&& mapped_stage
>= gl_info
->limits
.textures
)
3005 FIXME("Attempt to enable unsupported stage!\n");
3008 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
3009 checkGLcall("glActiveTextureARB");
3012 if(stage
>= stateblock
->lowest_disabled_stage
) {
3013 TRACE("Stage disabled\n");
3014 if (mapped_stage
!= WINED3D_UNMAPPED_STAGE
)
3016 /* Disable everything here */
3017 glDisable(GL_TEXTURE_2D
);
3018 checkGLcall("glDisable(GL_TEXTURE_2D)");
3019 glDisable(GL_TEXTURE_3D
);
3020 checkGLcall("glDisable(GL_TEXTURE_3D)");
3021 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
3023 glDisable(GL_TEXTURE_CUBE_MAP_ARB
);
3024 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
3026 if (gl_info
->supported
[ARB_TEXTURE_RECTANGLE
])
3028 glDisable(GL_TEXTURE_RECTANGLE_ARB
);
3029 checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)");
3036 /* The sampler will also activate the correct texture dimensions, so no need to do it here
3037 * if the sampler for this stage is dirty
3039 if(!isStateDirty(context
, STATE_SAMPLER(stage
))) {
3040 if (tex_used
) texture_activate_dimensions(stage
, stateblock
, context
);
3043 set_tex_op(context
, (IWineD3DDevice
*)stateblock
->device
, FALSE
, stage
,
3044 stateblock
->textureState
[stage
][WINED3DTSS_COLOROP
],
3045 stateblock
->textureState
[stage
][WINED3DTSS_COLORARG1
],
3046 stateblock
->textureState
[stage
][WINED3DTSS_COLORARG2
],
3047 stateblock
->textureState
[stage
][WINED3DTSS_COLORARG0
]);
3050 void tex_alphaop(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
3052 DWORD stage
= (state
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3053 BOOL tex_used
= stateblock
->device
->fixed_function_usage_map
& (1 << stage
);
3054 DWORD mapped_stage
= stateblock
->device
->texUnitMap
[stage
];
3055 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3056 DWORD op
, arg1
, arg2
, arg0
;
3058 TRACE("Setting alpha op for stage %d\n", stage
);
3059 /* Do not care for enabled / disabled stages, just assign the settings. colorop disables / enables required stuff */
3060 if (mapped_stage
!= WINED3D_UNMAPPED_STAGE
)
3062 if (tex_used
&& mapped_stage
>= gl_info
->limits
.textures
)
3064 FIXME("Attempt to enable unsupported stage!\n");
3067 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
3068 checkGLcall("glActiveTextureARB");
3071 op
= stateblock
->textureState
[stage
][WINED3DTSS_ALPHAOP
];
3072 arg1
= stateblock
->textureState
[stage
][WINED3DTSS_ALPHAARG1
];
3073 arg2
= stateblock
->textureState
[stage
][WINED3DTSS_ALPHAARG2
];
3074 arg0
= stateblock
->textureState
[stage
][WINED3DTSS_ALPHAARG0
];
3076 if (stateblock
->renderState
[WINED3DRS_COLORKEYENABLE
] && stage
== 0 && stateblock
->textures
[0])
3078 UINT texture_dimensions
= IWineD3DBaseTexture_GetTextureDimensions(stateblock
->textures
[0]);
3080 if (texture_dimensions
== GL_TEXTURE_2D
|| texture_dimensions
== GL_TEXTURE_RECTANGLE_ARB
)
3082 IWineD3DSurfaceImpl
*surf
;
3084 surf
= (IWineD3DSurfaceImpl
*) ((IWineD3DTextureImpl
*) stateblock
->textures
[0])->surfaces
[0];
3086 if (surf
->CKeyFlags
& WINEDDSD_CKSRCBLT
&& !surf
->resource
.format_desc
->alpha_mask
)
3088 /* Color keying needs to pass alpha values from the texture through to have the alpha test work
3089 * properly. On the other hand applications can still use texture combiners apparently. This code
3090 * takes care that apps cannot remove the texture's alpha channel entirely.
3092 * The fixup is required for Prince of Persia 3D(prison bars), while Moto racer 2 requires
3093 * D3DTOP_MODULATE to work on color keyed surfaces. Aliens vs Predator 1 uses color keyed textures
3094 * and alpha component of diffuse color to draw things like translucent text and perform other
3097 * Aliens vs Predator 1 relies on diffuse alpha having an effect, so it cannot be ignored. To
3098 * provide the behavior expected by the game, while emulating the colorkey, diffuse alpha must be
3099 * modulated with texture alpha. OTOH, Moto racer 2 at some points sets alphaop/alphaarg to
3100 * SELECTARG/CURRENT, yet puts garbage in diffuse alpha (zeroes). This works on native, because the
3101 * game disables alpha test and alpha blending. Alpha test is overwritten by wine's for purposes of
3102 * color-keying though, so this will lead to missing geometry if texture alpha is modulated (pixels
3103 * fail alpha test). To get around this, ALPHABLENDENABLE state is checked: if the app enables alpha
3104 * blending, it can be expected to provide meaningful values in diffuse alpha, so it should be
3105 * modulated with texture alpha; otherwise, selecting diffuse alpha is ignored in favour of texture
3108 * What to do with multitexturing? So far no app has been found that uses color keying with
3110 if (op
== WINED3DTOP_DISABLE
)
3112 arg1
= WINED3DTA_TEXTURE
;
3113 op
= WINED3DTOP_SELECTARG1
;
3115 else if(op
== WINED3DTOP_SELECTARG1
&& arg1
!= WINED3DTA_TEXTURE
)
3117 if (stateblock
->renderState
[WINED3DRS_ALPHABLENDENABLE
])
3119 arg2
= WINED3DTA_TEXTURE
;
3120 op
= WINED3DTOP_MODULATE
;
3122 else arg1
= WINED3DTA_TEXTURE
;
3124 else if(op
== WINED3DTOP_SELECTARG2
&& arg2
!= WINED3DTA_TEXTURE
)
3126 if (stateblock
->renderState
[WINED3DRS_ALPHABLENDENABLE
])
3128 arg1
= WINED3DTA_TEXTURE
;
3129 op
= WINED3DTOP_MODULATE
;
3131 else arg2
= WINED3DTA_TEXTURE
;
3137 /* tex_alphaop is shared between the ffp and nvrc because the difference only comes down to
3138 * this if block here, and the other code(color keying, texture unit selection) are the same
3140 TRACE("Setting alpha op for stage %d\n", stage
);
3141 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
3143 set_tex_op_nvrc((IWineD3DDevice
*)stateblock
->device
, TRUE
, stage
, op
, arg1
, arg2
, arg0
,
3144 mapped_stage
, stateblock
->textureState
[stage
][WINED3DTSS_RESULTARG
]);
3148 set_tex_op(context
, (IWineD3DDevice
*)stateblock
->device
, TRUE
, stage
, op
, arg1
, arg2
, arg0
);
3152 static void transform_texture(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
3154 DWORD texUnit
= (state
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3155 DWORD mapped_stage
= stateblock
->device
->texUnitMap
[texUnit
];
3159 /* Ignore this when a vertex shader is used, or if the streams aren't sorted out yet */
3160 if (use_vs(stateblock
) || isStateDirty(context
, STATE_VDECL
))
3162 TRACE("Using a vertex shader, or stream sources not sorted out yet, skipping\n");
3166 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
) return;
3167 if (mapped_stage
>= context
->gl_info
->limits
.textures
) return;
3169 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
3170 checkGLcall("glActiveTextureARB");
3171 generated
= (stateblock
->textureState
[texUnit
][WINED3DTSS_TEXCOORDINDEX
] & 0xFFFF0000) != WINED3DTSS_TCI_PASSTHRU
;
3172 coordIdx
= min(stateblock
->textureState
[texUnit
][WINED3DTSS_TEXCOORDINDEX
& 0x0000FFFF], MAX_TEXTURES
- 1);
3174 set_texture_matrix(&stateblock
->transforms
[WINED3DTS_TEXTURE0
+ texUnit
].u
.m
[0][0],
3175 stateblock
->textureState
[texUnit
][WINED3DTSS_TEXTURETRANSFORMFLAGS
], generated
, context
->last_was_rhw
,
3176 stateblock
->device
->strided_streams
.use_map
& (1 << (WINED3D_FFP_TEXCOORD0
+ coordIdx
))
3177 ? stateblock
->device
->strided_streams
.elements
[WINED3D_FFP_TEXCOORD0
+ coordIdx
].format_desc
->format
3178 : WINED3DFMT_UNKNOWN
,
3179 stateblock
->device
->frag_pipe
->ffp_proj_control
);
3181 /* The sampler applying function calls us if this changes */
3182 if ((context
->lastWasPow2Texture
& (1 << texUnit
)) && stateblock
->textures
[texUnit
])
3185 FIXME("Non-power2 texture being used with generated texture coords\n");
3187 /* NP2 texcoord fixup is implemented for pixelshaders so only enable the
3188 fixed-function-pipeline fixup via pow2Matrix when no PS is used. */
3189 if (!use_ps(stateblock
)) {
3190 TRACE("Non power two matrix multiply fixup\n");
3191 glMultMatrixf(((IWineD3DTextureImpl
*) stateblock
->textures
[texUnit
])->baseTexture
.pow2Matrix
);
3196 static void unloadTexCoords(const struct wined3d_context
*context
)
3198 unsigned int texture_idx
;
3200 for (texture_idx
= 0; texture_idx
< context
->gl_info
->limits
.texture_stages
; ++texture_idx
)
3202 GL_EXTCALL(glClientActiveTextureARB(GL_TEXTURE0_ARB
+ texture_idx
));
3203 glDisableClientState(GL_TEXTURE_COORD_ARRAY
);
3207 static void loadTexCoords(const struct wined3d_context
*context
, IWineD3DStateBlockImpl
*stateblock
,
3208 const struct wined3d_stream_info
*si
, GLuint
*curVBO
)
3210 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3211 const UINT
*offset
= stateblock
->streamOffset
;
3212 unsigned int mapped_stage
= 0;
3213 unsigned int textureNo
= 0;
3215 for (textureNo
= 0; textureNo
< gl_info
->limits
.texture_stages
; ++textureNo
)
3217 int coordIdx
= stateblock
->textureState
[textureNo
][WINED3DTSS_TEXCOORDINDEX
];
3219 mapped_stage
= stateblock
->device
->texUnitMap
[textureNo
];
3220 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
) continue;
3222 if (coordIdx
< MAX_TEXTURES
&& (si
->use_map
& (1 << (WINED3D_FFP_TEXCOORD0
+ coordIdx
))))
3224 const struct wined3d_stream_info_element
*e
= &si
->elements
[WINED3D_FFP_TEXCOORD0
+ coordIdx
];
3226 TRACE("Setting up texture %u, idx %d, cordindx %u, data %p\n",
3227 textureNo
, mapped_stage
, coordIdx
, e
->data
);
3229 if (*curVBO
!= e
->buffer_object
)
3231 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, e
->buffer_object
));
3232 checkGLcall("glBindBufferARB");
3233 *curVBO
= e
->buffer_object
;
3236 GL_EXTCALL(glClientActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
3237 checkGLcall("glClientActiveTextureARB");
3239 /* The coords to supply depend completely on the fvf / vertex shader */
3240 glTexCoordPointer(e
->format_desc
->gl_vtx_format
, e
->format_desc
->gl_vtx_type
, e
->stride
,
3241 e
->data
+ stateblock
->loadBaseVertexIndex
* e
->stride
+ offset
[e
->stream_idx
]);
3242 glEnableClientState(GL_TEXTURE_COORD_ARRAY
);
3244 GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB
+ mapped_stage
, 0, 0, 0, 1));
3247 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
3249 /* The number of the mapped stages increases monotonically, so it's fine to use the last used one. */
3250 for (textureNo
= mapped_stage
+ 1; textureNo
< gl_info
->limits
.textures
; ++textureNo
)
3252 GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB
+ textureNo
, 0, 0, 0, 1));
3256 checkGLcall("loadTexCoords");
3259 static void tex_coordindex(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
3261 DWORD stage
= (state
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3262 DWORD mapped_stage
= stateblock
->device
->texUnitMap
[stage
];
3263 static const GLfloat s_plane
[] = { 1.0f
, 0.0f
, 0.0f
, 0.0f
};
3264 static const GLfloat t_plane
[] = { 0.0f
, 1.0f
, 0.0f
, 0.0f
};
3265 static const GLfloat r_plane
[] = { 0.0f
, 0.0f
, 1.0f
, 0.0f
};
3266 static const GLfloat q_plane
[] = { 0.0f
, 0.0f
, 0.0f
, 1.0f
};
3267 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3269 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
)
3271 TRACE("No texture unit mapped to stage %d. Skipping texture coordinates.\n", stage
);
3275 if (mapped_stage
>= gl_info
->limits
.fragment_samplers
)
3277 WARN("stage %u not mapped to a valid texture unit (%u)\n", stage
, mapped_stage
);
3280 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
3281 checkGLcall("glActiveTextureARB");
3283 /* Values 0-7 are indexes into the FVF tex coords - See comments in DrawPrimitive
3285 * FIXME: When using generated texture coordinates, the index value is used to specify the wrapping mode.
3286 * eg. SetTextureStageState( 0, WINED3DTSS_TEXCOORDINDEX, WINED3DTSS_TCI_CAMERASPACEPOSITION | 1 );
3287 * means use the vertex position (camera-space) as the input texture coordinates
3288 * for this texture stage, and the wrap mode set in the WINED3DRS_WRAP1 render
3289 * state. We do not (yet) support the WINED3DRENDERSTATE_WRAPx values, nor tie them up
3290 * to the TEXCOORDINDEX value
3292 switch (stateblock
->textureState
[stage
][WINED3DTSS_TEXCOORDINDEX
] & 0xffff0000)
3294 case WINED3DTSS_TCI_PASSTHRU
:
3295 /* Use the specified texture coordinates contained within the
3296 * vertex format. This value resolves to zero. */
3297 glDisable(GL_TEXTURE_GEN_S
);
3298 glDisable(GL_TEXTURE_GEN_T
);
3299 glDisable(GL_TEXTURE_GEN_R
);
3300 glDisable(GL_TEXTURE_GEN_Q
);
3301 checkGLcall("WINED3DTSS_TCI_PASSTHRU - Disable texgen.");
3304 case WINED3DTSS_TCI_CAMERASPACEPOSITION
:
3305 /* CameraSpacePosition means use the vertex position, transformed to camera space,
3306 * as the input texture coordinates for this stage's texture transformation. This
3307 * equates roughly to EYE_LINEAR */
3309 glMatrixMode(GL_MODELVIEW
);
3312 glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
3313 glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
3314 glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
3315 glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
3317 checkGLcall("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set eye plane.");
3319 glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
3320 glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
3321 glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
3322 checkGLcall("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set texgen mode.");
3324 glEnable(GL_TEXTURE_GEN_S
);
3325 glEnable(GL_TEXTURE_GEN_T
);
3326 glEnable(GL_TEXTURE_GEN_R
);
3327 checkGLcall("WINED3DTSS_TCI_CAMERASPACEPOSITION - Enable texgen.");
3331 case WINED3DTSS_TCI_CAMERASPACENORMAL
:
3332 /* Note that NV_TEXGEN_REFLECTION support is implied when
3333 * ARB_TEXTURE_CUBE_MAP is supported */
3334 if (!gl_info
->supported
[NV_TEXGEN_REFLECTION
])
3336 FIXME("WINED3DTSS_TCI_CAMERASPACENORMAL not supported.\n");
3340 glMatrixMode(GL_MODELVIEW
);
3343 glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
3344 glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
3345 glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
3346 glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
3348 checkGLcall("WINED3DTSS_TCI_CAMERASPACENORMAL - Set eye plane.");
3350 glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
3351 glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
3352 glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
3353 checkGLcall("WINED3DTSS_TCI_CAMERASPACENORMAL - Set texgen mode.");
3355 glEnable(GL_TEXTURE_GEN_S
);
3356 glEnable(GL_TEXTURE_GEN_T
);
3357 glEnable(GL_TEXTURE_GEN_R
);
3358 checkGLcall("WINED3DTSS_TCI_CAMERASPACENORMAL - Enable texgen.");
3362 case WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR
:
3363 /* Note that NV_TEXGEN_REFLECTION support is implied when
3364 * ARB_TEXTURE_CUBE_MAP is supported */
3365 if (!gl_info
->supported
[NV_TEXGEN_REFLECTION
])
3367 FIXME("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR not supported.\n");
3371 glMatrixMode(GL_MODELVIEW
);
3374 glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
3375 glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
3376 glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
3377 glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
3379 checkGLcall("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Set eye plane.");
3381 glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
3382 glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
3383 glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
3384 checkGLcall("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Set texgen mode.");
3386 glEnable(GL_TEXTURE_GEN_S
);
3387 glEnable(GL_TEXTURE_GEN_T
);
3388 glEnable(GL_TEXTURE_GEN_R
);
3389 checkGLcall("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Enable texgen.");
3393 case WINED3DTSS_TCI_SPHEREMAP
:
3394 glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_SPHERE_MAP
);
3395 glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_SPHERE_MAP
);
3396 checkGLcall("WINED3DTSS_TCI_SPHEREMAP - Set texgen mode.");
3398 glEnable(GL_TEXTURE_GEN_S
);
3399 glEnable(GL_TEXTURE_GEN_T
);
3400 glDisable(GL_TEXTURE_GEN_R
);
3401 checkGLcall("WINED3DTSS_TCI_SPHEREMAP - Enable texgen.");
3406 FIXME("Unhandled WINED3DTSS_TEXCOORDINDEX %#x\n",
3407 stateblock
->textureState
[stage
][WINED3DTSS_TEXCOORDINDEX
]);
3408 glDisable(GL_TEXTURE_GEN_S
);
3409 glDisable(GL_TEXTURE_GEN_T
);
3410 glDisable(GL_TEXTURE_GEN_R
);
3411 glDisable(GL_TEXTURE_GEN_Q
);
3412 checkGLcall("Disable texgen.");
3417 /* Update the texture matrix */
3418 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_TEXTURE0
+ stage
))) {
3419 transform_texture(STATE_TEXTURESTAGE(stage
, WINED3DTSS_TEXTURETRANSFORMFLAGS
), stateblock
, context
);
3422 if(!isStateDirty(context
, STATE_VDECL
) && context
->namedArraysLoaded
) {
3423 /* Reload the arrays if we are using fixed function arrays to reflect the selected coord input
3424 * source. Call loadTexCoords directly because there is no need to reparse the vertex declaration
3425 * and do all the things linked to it
3426 * TODO: Tidy that up to reload only the arrays of the changed unit
3428 GLuint curVBO
= gl_info
->supported
[ARB_VERTEX_BUFFER_OBJECT
] ? ~0U : 0;
3430 unloadTexCoords(context
);
3431 loadTexCoords(context
, stateblock
, &stateblock
->device
->strided_streams
, &curVBO
);
3435 static void shaderconstant(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
3437 IWineD3DDeviceImpl
*device
= stateblock
->device
;
3439 /* Vertex and pixel shader states will call a shader upload, don't do anything as long one of them
3440 * has an update pending
3442 if(isStateDirty(context
, STATE_VDECL
) ||
3443 isStateDirty(context
, STATE_PIXELSHADER
)) {
3447 device
->shader_backend
->shader_load_constants(context
, use_ps(stateblock
), use_vs(stateblock
));
3450 static void tex_bumpenvlscale(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
3452 DWORD stage
= (state
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3454 if (stateblock
->pixelShader
&& stage
!= 0
3455 && (((IWineD3DPixelShaderImpl
*)stateblock
->pixelShader
)->baseShader
.reg_maps
.luminanceparams
& (1 << stage
)))
3457 /* The pixel shader has to know the luminance scale. Do a constants update if it
3458 * isn't scheduled anyway
3460 if(!isStateDirty(context
, STATE_PIXELSHADERCONSTANT
) &&
3461 !isStateDirty(context
, STATE_PIXELSHADER
)) {
3462 shaderconstant(STATE_PIXELSHADERCONSTANT
, stateblock
, context
);
3467 static void sampler_texmatrix(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
3469 const DWORD sampler
= state
- STATE_SAMPLER(0);
3470 IWineD3DBaseTexture
*texture
= stateblock
->textures
[sampler
];
3472 TRACE("state %#x, stateblock %p, context %p\n", state
, stateblock
, context
);
3474 if(!texture
) return;
3475 /* The fixed function np2 texture emulation uses the texture matrix to fix up the coordinates
3476 * basetexture_apply_state_changes() multiplies the set matrix with a fixup matrix. Before the
3477 * scaling is reapplied or removed, the texture matrix has to be reapplied
3479 * The mapped stage is already active because the sampler() function below, which is part of the
3482 if(sampler
< MAX_TEXTURES
) {
3483 const BOOL texIsPow2
= !((IWineD3DBaseTextureImpl
*)texture
)->baseTexture
.pow2Matrix_identity
;
3485 if (texIsPow2
|| (context
->lastWasPow2Texture
& (1 << sampler
)))
3487 if (texIsPow2
) context
->lastWasPow2Texture
|= 1 << sampler
;
3488 else context
->lastWasPow2Texture
&= ~(1 << sampler
);
3489 transform_texture(STATE_TEXTURESTAGE(stateblock
->device
->texUnitMap
[sampler
],
3490 WINED3DTSS_TEXTURETRANSFORMFLAGS
), stateblock
, context
);
3495 static void sampler(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
3497 DWORD sampler
= state
- STATE_SAMPLER(0);
3498 DWORD mapped_stage
= stateblock
->device
->texUnitMap
[sampler
];
3499 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3505 TRACE("Sampler: %d\n", sampler
);
3506 /* Enabling and disabling texture dimensions is done by texture stage state / pixel shader setup, this function
3507 * only has to bind textures and set the per texture states
3510 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
)
3512 TRACE("No sampler mapped to stage %d. Returning.\n", sampler
);
3516 if (mapped_stage
>= gl_info
->limits
.combined_samplers
)
3520 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
3521 checkGLcall("glActiveTextureARB");
3523 if(stateblock
->textures
[sampler
]) {
3524 BOOL srgb
= stateblock
->samplerState
[sampler
][WINED3DSAMP_SRGBTEXTURE
];
3525 IWineD3DBaseTextureImpl
*tex_impl
= (IWineD3DBaseTextureImpl
*) stateblock
->textures
[sampler
];
3526 tex_impl
->baseTexture
.internal_preload(stateblock
->textures
[sampler
], srgb
? SRGB_SRGB
: SRGB_RGB
);
3527 IWineD3DBaseTexture_BindTexture(stateblock
->textures
[sampler
], srgb
);
3528 basetexture_apply_state_changes(stateblock
->textures
[sampler
],
3529 stateblock
->textureState
[sampler
], stateblock
->samplerState
[sampler
], gl_info
);
3531 if (gl_info
->supported
[EXT_TEXTURE_LOD_BIAS
])
3533 tmpvalue
.d
= stateblock
->samplerState
[sampler
][WINED3DSAMP_MIPMAPLODBIAS
];
3534 glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT
,
3535 GL_TEXTURE_LOD_BIAS_EXT
,
3537 checkGLcall("glTexEnvi(GL_TEXTURE_LOD_BIAS_EXT, ...)");
3540 if (!use_ps(stateblock
) && sampler
< stateblock
->lowest_disabled_stage
)
3542 if(stateblock
->renderState
[WINED3DRS_COLORKEYENABLE
] && sampler
== 0) {
3543 /* If color keying is enabled update the alpha test, it depends on the existence
3544 * of a color key in stage 0
3546 state_alpha(WINED3DRS_COLORKEYENABLE
, stateblock
, context
);
3550 /* Trigger shader constant reloading (for NP2 texcoord fixup) */
3551 if (!tex_impl
->baseTexture
.pow2Matrix_identity
)
3553 IWineD3DDeviceImpl
*d3ddevice
= stateblock
->device
;
3554 d3ddevice
->shader_backend
->shader_load_np2fixup_constants(
3555 (IWineD3DDevice
*)d3ddevice
, use_ps(stateblock
), use_vs(stateblock
));
3558 else if (mapped_stage
< gl_info
->limits
.textures
)
3560 if(sampler
< stateblock
->lowest_disabled_stage
) {
3561 /* TODO: What should I do with pixel shaders here ??? */
3562 if(stateblock
->renderState
[WINED3DRS_COLORKEYENABLE
] && sampler
== 0) {
3563 /* If color keying is enabled update the alpha test, it depends on the existence
3564 * of a color key in stage 0
3566 state_alpha(WINED3DRS_COLORKEYENABLE
, stateblock
, context
);
3568 } /* Otherwise tex_colorop disables the stage */
3569 glBindTexture(GL_TEXTURE_2D
, stateblock
->device
->dummyTextureName
[sampler
]);
3570 checkGLcall("glBindTexture(GL_TEXTURE_2D, stateblock->device->dummyTextureName[sampler])");
3574 void apply_pixelshader(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
3576 IWineD3DDeviceImpl
*device
= stateblock
->device
;
3577 BOOL use_pshader
= use_ps(stateblock
);
3578 BOOL use_vshader
= use_vs(stateblock
);
3582 if(!context
->last_was_pshader
) {
3583 /* Former draw without a pixel shader, some samplers
3584 * may be disabled because of WINED3DTSS_COLOROP = WINED3DTOP_DISABLE
3585 * make sure to enable them
3587 for(i
=0; i
< MAX_FRAGMENT_SAMPLERS
; i
++) {
3588 if(!isStateDirty(context
, STATE_SAMPLER(i
))) {
3589 sampler(STATE_SAMPLER(i
), stateblock
, context
);
3592 context
->last_was_pshader
= TRUE
;
3594 /* Otherwise all samplers were activated by the code above in earlier draws, or by sampler()
3595 * if a different texture was bound. I don't have to do anything.
3599 /* Disabled the pixel shader - color ops weren't applied
3600 * while it was enabled, so re-apply them.
3602 for(i
=0; i
< MAX_TEXTURES
; i
++) {
3603 if(!isStateDirty(context
, STATE_TEXTURESTAGE(i
, WINED3DTSS_COLOROP
))) {
3604 device
->StateTable
[STATE_TEXTURESTAGE(i
, WINED3DTSS_COLOROP
)].apply
3605 (STATE_TEXTURESTAGE(i
, WINED3DTSS_COLOROP
), stateblock
, context
);
3608 context
->last_was_pshader
= FALSE
;
3611 if(!isStateDirty(context
, device
->StateTable
[STATE_VSHADER
].representative
)) {
3612 device
->shader_backend
->shader_select(context
, use_pshader
, use_vshader
);
3614 if (!isStateDirty(context
, STATE_VERTEXSHADERCONSTANT
) && (use_vshader
|| use_pshader
)) {
3615 shaderconstant(STATE_VERTEXSHADERCONSTANT
, stateblock
, context
);
3620 static void shader_bumpenvmat(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
3622 DWORD stage
= (state
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3623 if (stateblock
->pixelShader
&& stage
!= 0
3624 && (((IWineD3DPixelShaderImpl
*)stateblock
->pixelShader
)->baseShader
.reg_maps
.bumpmat
& (1 << stage
)))
3626 /* The pixel shader has to know the bump env matrix. Do a constants update if it isn't scheduled
3629 if(!isStateDirty(context
, STATE_PIXELSHADERCONSTANT
) &&
3630 !isStateDirty(context
, STATE_PIXELSHADER
)) {
3631 shaderconstant(STATE_PIXELSHADERCONSTANT
, stateblock
, context
);
3636 static void transform_world(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
3638 /* This function is called by transform_view below if the view matrix was changed too
3640 * Deliberately no check if the vertex declaration is dirty because the vdecl state
3641 * does not always update the world matrix, only on a switch between transformed
3642 * and untransformed draws. It *may* happen that the world matrix is set 2 times during one
3643 * draw, but that should be rather rare and cheaper in total.
3645 glMatrixMode(GL_MODELVIEW
);
3646 checkGLcall("glMatrixMode");
3648 if(context
->last_was_rhw
) {
3650 checkGLcall("glLoadIdentity()");
3652 /* In the general case, the view matrix is the identity matrix */
3653 if (stateblock
->device
->view_ident
)
3655 glLoadMatrixf(&stateblock
->transforms
[WINED3DTS_WORLDMATRIX(0)].u
.m
[0][0]);
3656 checkGLcall("glLoadMatrixf");
3660 glLoadMatrixf(&stateblock
->transforms
[WINED3DTS_VIEW
].u
.m
[0][0]);
3661 checkGLcall("glLoadMatrixf");
3662 glMultMatrixf(&stateblock
->transforms
[WINED3DTS_WORLDMATRIX(0)].u
.m
[0][0]);
3663 checkGLcall("glMultMatrixf");
3668 static void clipplane(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
3670 UINT index
= state
- STATE_CLIPPLANE(0);
3672 if (isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_VIEW
)) || index
>= context
->gl_info
->limits
.clipplanes
)
3677 /* Clip Plane settings are affected by the model view in OpenGL, the View transform in direct3d */
3678 if(!use_vs(stateblock
)) {
3679 glMatrixMode(GL_MODELVIEW
);
3681 glLoadMatrixf(&stateblock
->transforms
[WINED3DTS_VIEW
].u
.m
[0][0]);
3683 /* with vertex shaders, clip planes are not transformed in direct3d,
3684 * in OpenGL they are still transformed by the model view.
3685 * Use this to swap the y coordinate if necessary
3687 glMatrixMode(GL_MODELVIEW
);
3690 if (context
->render_offscreen
) glScalef(1.0f
, -1.0f
, 1.0f
);
3693 TRACE("Clipplane [%f,%f,%f,%f]\n",
3694 stateblock
->clipplane
[index
][0],
3695 stateblock
->clipplane
[index
][1],
3696 stateblock
->clipplane
[index
][2],
3697 stateblock
->clipplane
[index
][3]);
3698 glClipPlane(GL_CLIP_PLANE0
+ index
, stateblock
->clipplane
[index
]);
3699 checkGLcall("glClipPlane");
3704 static void transform_worldex(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
3706 UINT matrix
= state
- STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0));
3708 TRACE("Setting world matrix %d\n", matrix
);
3710 if (matrix
>= context
->gl_info
->limits
.blends
)
3712 WARN("Unsupported blend matrix set\n");
3714 } else if(isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_VIEW
))) {
3718 /* GL_MODELVIEW0_ARB: 0x1700
3719 * GL_MODELVIEW1_ARB: 0x850a
3720 * GL_MODELVIEW2_ARB: 0x8722
3721 * GL_MODELVIEW3_ARB: 0x8723
3723 * GL_MODELVIEW31_ARB: 0x873F
3725 if(matrix
== 1) glMat
= GL_MODELVIEW1_ARB
;
3726 else glMat
= GL_MODELVIEW2_ARB
- 2 + matrix
;
3728 glMatrixMode(glMat
);
3729 checkGLcall("glMatrixMode(glMat)");
3731 /* World matrix 0 is multiplied with the view matrix because d3d uses 3 matrices while gl uses only 2. To avoid
3732 * weighting the view matrix incorrectly it has to be multiplied into every gl modelview matrix
3734 if (stateblock
->device
->view_ident
)
3736 glLoadMatrixf(&stateblock
->transforms
[WINED3DTS_WORLDMATRIX(matrix
)].u
.m
[0][0]);
3737 checkGLcall("glLoadMatrixf");
3741 glLoadMatrixf(&stateblock
->transforms
[WINED3DTS_VIEW
].u
.m
[0][0]);
3742 checkGLcall("glLoadMatrixf");
3743 glMultMatrixf(&stateblock
->transforms
[WINED3DTS_WORLDMATRIX(matrix
)].u
.m
[0][0]);
3744 checkGLcall("glMultMatrixf");
3748 static void state_vertexblend_w(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
3750 static BOOL once
= FALSE
;
3752 switch(stateblock
->renderState
[WINED3DRS_VERTEXBLEND
]) {
3753 case WINED3DVBF_1WEIGHTS
:
3754 case WINED3DVBF_2WEIGHTS
:
3755 case WINED3DVBF_3WEIGHTS
:
3758 /* TODO: Implement vertex blending in drawStridedSlow */
3759 FIXME("Vertex blending enabled, but not supported by hardware\n");
3763 case WINED3DVBF_TWEENING
:
3764 WARN("Tweening not supported yet\n");
3768 static void state_vertexblend(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
3770 WINED3DVERTEXBLENDFLAGS val
= stateblock
->renderState
[WINED3DRS_VERTEXBLEND
];
3773 case WINED3DVBF_1WEIGHTS
:
3774 case WINED3DVBF_2WEIGHTS
:
3775 case WINED3DVBF_3WEIGHTS
:
3776 glEnable(GL_VERTEX_BLEND_ARB
);
3777 checkGLcall("glEnable(GL_VERTEX_BLEND_ARB)");
3779 /* D3D adds one more matrix which has weight (1 - sum(weights)). This is enabled at context
3780 * creation with enabling GL_WEIGHT_SUM_UNITY_ARB.
3782 GL_EXTCALL(glVertexBlendARB(stateblock
->renderState
[WINED3DRS_VERTEXBLEND
] + 1));
3784 if (!stateblock
->device
->vertexBlendUsed
)
3787 for (i
= 1; i
< context
->gl_info
->limits
.blends
; ++i
)
3789 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(i
))))
3791 transform_worldex(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(i
)), stateblock
, context
);
3794 stateblock
->device
->vertexBlendUsed
= TRUE
;
3798 case WINED3DVBF_DISABLE
:
3799 case WINED3DVBF_0WEIGHTS
: /* for Indexed vertex blending - not supported */
3800 glDisable(GL_VERTEX_BLEND_ARB
);
3801 checkGLcall("glDisable(GL_VERTEX_BLEND_ARB)");
3804 case WINED3DVBF_TWEENING
:
3805 /* Just set the vertex weight for weight 0, enable vertex blending and hope the app doesn't have
3806 * vertex weights in the vertices?
3807 * For now we don't report that as supported, so a warn should suffice
3809 WARN("Tweening not supported yet\n");
3814 static void transform_view(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
3816 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3817 const struct wined3d_light_info
*light
= NULL
;
3820 /* If we are changing the View matrix, reset the light and clipping planes to the new view
3821 * NOTE: We have to reset the positions even if the light/plane is not currently
3822 * enabled, since the call to enable it will not reset the position.
3823 * NOTE2: Apparently texture transforms do NOT need reapplying
3826 glMatrixMode(GL_MODELVIEW
);
3827 checkGLcall("glMatrixMode(GL_MODELVIEW)");
3828 glLoadMatrixf(&stateblock
->transforms
[WINED3DTS_VIEW
].u
.m
[0][0]);
3829 checkGLcall("glLoadMatrixf(...)");
3831 /* Reset lights. TODO: Call light apply func */
3832 for (k
= 0; k
< stateblock
->device
->maxConcurrentLights
; ++k
)
3834 light
= stateblock
->activeLights
[k
];
3835 if(!light
) continue;
3836 glLightfv(GL_LIGHT0
+ light
->glIndex
, GL_POSITION
, light
->lightPosn
);
3837 checkGLcall("glLightfv posn");
3838 glLightfv(GL_LIGHT0
+ light
->glIndex
, GL_SPOT_DIRECTION
, light
->lightDirn
);
3839 checkGLcall("glLightfv dirn");
3842 /* Reset Clipping Planes */
3843 for (k
= 0; k
< gl_info
->limits
.clipplanes
; ++k
)
3845 if(!isStateDirty(context
, STATE_CLIPPLANE(k
))) {
3846 clipplane(STATE_CLIPPLANE(k
), stateblock
, context
);
3850 if(context
->last_was_rhw
) {
3852 checkGLcall("glLoadIdentity()");
3853 /* No need to update the world matrix, the identity is fine */
3857 /* Call the world matrix state, this will apply the combined WORLD + VIEW matrix
3858 * No need to do it here if the state is scheduled for update.
3860 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)))) {
3861 transform_world(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), stateblock
, context
);
3864 /* Avoid looping over a number of matrices if the app never used the functionality */
3865 if (stateblock
->device
->vertexBlendUsed
)
3867 for (k
= 1; k
< gl_info
->limits
.blends
; ++k
)
3869 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(k
)))) {
3870 transform_worldex(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(k
)), stateblock
, context
);
3876 static void transform_projection(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
3878 glMatrixMode(GL_PROJECTION
);
3879 checkGLcall("glMatrixMode(GL_PROJECTION)");
3881 checkGLcall("glLoadIdentity");
3883 if(context
->last_was_rhw
) {
3884 double X
, Y
, height
, width
, minZ
, maxZ
;
3886 X
= stateblock
->viewport
.X
;
3887 Y
= stateblock
->viewport
.Y
;
3888 height
= stateblock
->viewport
.Height
;
3889 width
= stateblock
->viewport
.Width
;
3890 minZ
= stateblock
->viewport
.MinZ
;
3891 maxZ
= stateblock
->viewport
.MaxZ
;
3893 if (!stateblock
->device
->untransformed
)
3895 /* Transformed vertices are supposed to bypass the whole transform pipeline including
3896 * frustum clipping. This can't be done in opengl, so this code adjusts the Z range to
3897 * suppress depth clipping. This can be done because it is an orthogonal projection and
3898 * the Z coordinate does not affect the size of the primitives. Half Life 1 and Prince of
3899 * Persia 3D need this.
3901 * Note that using minZ and maxZ here doesn't entirely fix the problem, since view frustum
3902 * clipping is still enabled, but it seems to fix it for all apps tested so far. A minor
3903 * problem can be witnessed in half-life 1 engine based games, the weapon is clipped close
3906 * Also note that this breaks z comparison against z values filled in with clear,
3907 * but no app depending on that and disabled clipping has been found yet. Comparing
3908 * primitives against themselves works, so the Z buffer is still intact for normal hidden
3911 * We could disable clipping entirely by setting the near to infinity and far to -infinity,
3912 * but this would break Z buffer operation. Raising the range to something less than
3913 * infinity would help a bit at the cost of Z precision, but it wouldn't eliminate the
3916 TRACE("Calling glOrtho with %f, %f, %f, %f\n", width
, height
, -minZ
, -maxZ
);
3917 if (context
->render_offscreen
)
3919 glOrtho(X
, X
+ width
, -Y
, -Y
- height
, -minZ
, -maxZ
);
3921 glOrtho(X
, X
+ width
, Y
+ height
, Y
, -minZ
, -maxZ
);
3924 /* If the app mixes transformed and untransformed primitives we can't use the coordinate system
3925 * trick above because this would mess up transformed and untransformed Z order. Pass the z position
3926 * unmodified to opengl.
3928 * If the app depends on mixed types and disabled clipping we're out of luck without a pipeline
3929 * replacement shader.
3931 TRACE("Calling glOrtho with %f, %f, %f, %f\n", width
, height
, 1.0, -1.0);
3932 if (context
->render_offscreen
)
3934 glOrtho(X
, X
+ width
, -Y
, -Y
- height
, 0.0, -1.0);
3936 glOrtho(X
, X
+ width
, Y
+ height
, Y
, 0.0, -1.0);
3939 checkGLcall("glOrtho");
3941 /* Window Coord 0 is the middle of the first pixel, so translate by 1/2 pixels */
3942 glTranslatef(63.0f
/ 128.0f
, 63.0f
/ 128.0f
, 0.0f
);
3943 checkGLcall("glTranslatef(63.0f / 128.0f, 63.0f / 128.0f, 0.0f)");
3945 /* D3D texture coordinates are flipped compared to OpenGL ones, so
3946 * render everything upside down when rendering offscreen. */
3947 if (context
->render_offscreen
)
3949 glScalef(1.0f
, -1.0f
, 1.0f
);
3950 checkGLcall("glScalef");
3953 /* The rule is that the window coordinate 0 does not correspond to the
3954 beginning of the first pixel, but the center of the first pixel.
3955 As a consequence if you want to correctly draw one line exactly from
3956 the left to the right end of the viewport (with all matrices set to
3957 be identity), the x coords of both ends of the line would be not
3958 -1 and 1 respectively but (-1-1/viewport_widh) and (1-1/viewport_width)
3961 1.0 / Width is used because the coord range goes from -1.0 to 1.0, then we
3962 divide by the Width/Height, so we need the half range(1.0) to translate by
3965 The other fun is that d3d's output z range after the transformation is [0;1],
3966 but opengl's is [-1;1]. Since the z buffer is in range [0;1] for both, gl
3967 scales [-1;1] to [0;1]. This would mean that we end up in [0.5;1] and loose a lot
3968 of Z buffer precision and the clear values do not match in the z test. Thus scale
3969 [0;1] to [-1;1], so when gl undoes that we utilize the full z range
3973 * Careful with the order of operations here, we're essentially working backwards:
3975 * y = (y - 1/h) * flip;
3979 * glTranslatef(0.0, 0.0, -1.0);
3980 * glScalef(1.0, 1.0, 2.0);
3982 * glScalef(1.0, flip, 1.0);
3983 * glTranslatef(1/w, -1/h, 0.0);
3985 * This is equivalent to:
3986 * glTranslatef(1/w, -flip/h, -1.0)
3987 * glScalef(1.0, flip, 2.0);
3990 /* Translate by slightly less than a half pixel to force a top-left
3991 * filling convention. We want the difference to be large enough that
3992 * it doesn't get lost due to rounding inside the driver, but small
3993 * enough to prevent it from interfering with any anti-aliasing. */
3994 GLfloat xoffset
= (63.0f
/ 64.0f
) / stateblock
->viewport
.Width
;
3995 GLfloat yoffset
= -(63.0f
/ 64.0f
) / stateblock
->viewport
.Height
;
3997 if (context
->render_offscreen
)
3999 /* D3D texture coordinates are flipped compared to OpenGL ones, so
4000 * render everything upside down when rendering offscreen. */
4001 glTranslatef(xoffset
, -yoffset
, -1.0f
);
4002 checkGLcall("glTranslatef(xoffset, -yoffset, -1.0f)");
4003 glScalef(1.0f
, -1.0f
, 2.0f
);
4005 glTranslatef(xoffset
, yoffset
, -1.0f
);
4006 checkGLcall("glTranslatef(xoffset, yoffset, -1.0f)");
4007 glScalef(1.0f
, 1.0f
, 2.0f
);
4009 checkGLcall("glScalef");
4011 glMultMatrixf(&stateblock
->transforms
[WINED3DTS_PROJECTION
].u
.m
[0][0]);
4012 checkGLcall("glLoadMatrixf");
4016 /* This should match any arrays loaded in loadVertexData.
4017 * TODO: Only load / unload arrays if we have to.
4019 static inline void unloadVertexData(const struct wined3d_context
*context
)
4021 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4023 glDisableClientState(GL_VERTEX_ARRAY
);
4024 glDisableClientState(GL_NORMAL_ARRAY
);
4025 glDisableClientState(GL_COLOR_ARRAY
);
4026 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
4028 glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT
);
4030 if (gl_info
->supported
[ARB_VERTEX_BLEND
])
4032 glDisableClientState(GL_WEIGHT_ARRAY_ARB
);
4034 unloadTexCoords(context
);
4037 static inline void unload_numbered_array(IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
, int i
)
4039 GL_EXTCALL(glDisableVertexAttribArrayARB(i
));
4040 checkGLcall("glDisableVertexAttribArrayARB(reg)");
4042 context
->numbered_array_mask
&= ~(1 << i
);
4045 /* This should match any arrays loaded in loadNumberedArrays
4046 * TODO: Only load / unload arrays if we have to.
4048 static inline void unloadNumberedArrays(IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
4050 /* disable any attribs (this is the same for both GLSL and ARB modes) */
4051 GLint maxAttribs
= 16;
4054 /* Leave all the attribs disabled */
4055 glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB
, &maxAttribs
);
4056 /* MESA does not support it right not */
4057 if (glGetError() != GL_NO_ERROR
)
4059 for (i
= 0; i
< maxAttribs
; ++i
) {
4060 unload_numbered_array(stateblock
, context
, i
);
4064 static inline void loadNumberedArrays(IWineD3DStateBlockImpl
*stateblock
,
4065 const struct wined3d_stream_info
*stream_info
, struct wined3d_context
*context
)
4067 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4068 GLuint curVBO
= gl_info
->supported
[ARB_VERTEX_BUFFER_OBJECT
] ? ~0U : 0;
4070 const UINT
*offset
= stateblock
->streamOffset
;
4071 struct wined3d_buffer
*vb
;
4072 DWORD_PTR shift_index
;
4074 /* Default to no instancing */
4075 stateblock
->device
->instancedDraw
= FALSE
;
4077 for (i
= 0; i
< MAX_ATTRIBS
; i
++) {
4078 if (!(stream_info
->use_map
& (1 << i
)))
4080 if (context
->numbered_array_mask
& (1 << i
)) unload_numbered_array(stateblock
, context
, i
);
4084 /* Do not load instance data. It will be specified using glTexCoord by drawprim */
4085 if (stateblock
->streamFlags
[stream_info
->elements
[i
].stream_idx
] & WINED3DSTREAMSOURCE_INSTANCEDATA
)
4087 if (context
->numbered_array_mask
& (1 << i
)) unload_numbered_array(stateblock
, context
, i
);
4088 stateblock
->device
->instancedDraw
= TRUE
;
4092 TRACE_(d3d_shader
)("Loading array %u [VBO=%u]\n", i
, stream_info
->elements
[i
].buffer_object
);
4094 if (stream_info
->elements
[i
].stride
)
4096 if (curVBO
!= stream_info
->elements
[i
].buffer_object
)
4098 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, stream_info
->elements
[i
].buffer_object
));
4099 checkGLcall("glBindBufferARB");
4100 curVBO
= stream_info
->elements
[i
].buffer_object
;
4102 vb
= (struct wined3d_buffer
*)stateblock
->streamSource
[stream_info
->elements
[i
].stream_idx
];
4103 /* Use the VBO to find out if a vertex buffer exists, not the vb pointer. vb can point to a
4104 * user pointer data blob. In that case curVBO will be 0. If there is a vertex buffer but no
4105 * vbo we won't be load converted attributes anyway
4107 if (curVBO
&& vb
->conversion_shift
)
4109 TRACE("Loading attribute from shifted buffer\n");
4110 TRACE("Attrib %d has original stride %d, new stride %d\n",
4111 i
, stream_info
->elements
[i
].stride
, vb
->conversion_stride
);
4112 TRACE("Original offset %p, additional offset 0x%08x\n",
4113 stream_info
->elements
[i
].data
, vb
->conversion_shift
[(DWORD_PTR
)stream_info
->elements
[i
].data
]);
4114 TRACE("Opengl type %#x\n", stream_info
->elements
[i
].format_desc
->gl_vtx_type
);
4115 shift_index
= ((DWORD_PTR
)stream_info
->elements
[i
].data
+ offset
[stream_info
->elements
[i
].stream_idx
]);
4116 shift_index
= shift_index
% stream_info
->elements
[i
].stride
;
4117 GL_EXTCALL(glVertexAttribPointerARB(i
, stream_info
->elements
[i
].format_desc
->gl_vtx_format
,
4118 stream_info
->elements
[i
].format_desc
->gl_vtx_type
,
4119 stream_info
->elements
[i
].format_desc
->gl_normalized
,
4120 vb
->conversion_stride
, stream_info
->elements
[i
].data
+ vb
->conversion_shift
[shift_index
]
4121 + stateblock
->loadBaseVertexIndex
* stream_info
->elements
[i
].stride
4122 + offset
[stream_info
->elements
[i
].stream_idx
]));
4125 GL_EXTCALL(glVertexAttribPointerARB(i
, stream_info
->elements
[i
].format_desc
->gl_vtx_format
,
4126 stream_info
->elements
[i
].format_desc
->gl_vtx_type
,
4127 stream_info
->elements
[i
].format_desc
->gl_normalized
,
4128 stream_info
->elements
[i
].stride
, stream_info
->elements
[i
].data
4129 + stateblock
->loadBaseVertexIndex
* stream_info
->elements
[i
].stride
4130 + offset
[stream_info
->elements
[i
].stream_idx
]));
4133 if (!(context
->numbered_array_mask
& (1 << i
)))
4135 GL_EXTCALL(glEnableVertexAttribArrayARB(i
));
4136 context
->numbered_array_mask
|= (1 << i
);
4139 /* Stride = 0 means always the same values. glVertexAttribPointerARB doesn't do that. Instead disable the pointer and
4140 * set up the attribute statically. But we have to figure out the system memory address.
4142 const BYTE
*ptr
= stream_info
->elements
[i
].data
+ offset
[stream_info
->elements
[i
].stream_idx
];
4143 if (stream_info
->elements
[i
].buffer_object
)
4145 vb
= (struct wined3d_buffer
*)stateblock
->streamSource
[stream_info
->elements
[i
].stream_idx
];
4146 ptr
+= (long) buffer_get_sysmem(vb
);
4149 if (context
->numbered_array_mask
& (1 << i
)) unload_numbered_array(stateblock
, context
, i
);
4151 switch (stream_info
->elements
[i
].format_desc
->format
)
4153 case WINED3DFMT_R32_FLOAT
:
4154 GL_EXTCALL(glVertexAttrib1fvARB(i
, (const GLfloat
*)ptr
));
4156 case WINED3DFMT_R32G32_FLOAT
:
4157 GL_EXTCALL(glVertexAttrib2fvARB(i
, (const GLfloat
*)ptr
));
4159 case WINED3DFMT_R32G32B32_FLOAT
:
4160 GL_EXTCALL(glVertexAttrib3fvARB(i
, (const GLfloat
*)ptr
));
4162 case WINED3DFMT_R32G32B32A32_FLOAT
:
4163 GL_EXTCALL(glVertexAttrib4fvARB(i
, (const GLfloat
*)ptr
));
4166 case WINED3DFMT_R8G8B8A8_UINT
:
4167 GL_EXTCALL(glVertexAttrib4NubvARB(i
, ptr
));
4169 case WINED3DFMT_B8G8R8A8_UNORM
:
4170 if (gl_info
->supported
[EXT_VERTEX_ARRAY_BGRA
])
4172 const DWORD
*src
= (const DWORD
*)ptr
;
4173 DWORD c
= *src
& 0xff00ff00;
4174 c
|= (*src
& 0xff0000) >> 16;
4175 c
|= (*src
& 0xff) << 16;
4176 GL_EXTCALL(glVertexAttrib4NubvARB(i
, (GLubyte
*)&c
));
4179 /* else fallthrough */
4180 case WINED3DFMT_R8G8B8A8_UNORM
:
4181 GL_EXTCALL(glVertexAttrib4NubvARB(i
, ptr
));
4184 case WINED3DFMT_R16G16_SINT
:
4185 GL_EXTCALL(glVertexAttrib4svARB(i
, (const GLshort
*)ptr
));
4187 case WINED3DFMT_R16G16B16A16_SINT
:
4188 GL_EXTCALL(glVertexAttrib4svARB(i
, (const GLshort
*)ptr
));
4191 case WINED3DFMT_R16G16_SNORM
:
4193 const GLshort s
[4] = {((const GLshort
*)ptr
)[0], ((const GLshort
*)ptr
)[1], 0, 1};
4194 GL_EXTCALL(glVertexAttrib4NsvARB(i
, s
));
4197 case WINED3DFMT_R16G16_UNORM
:
4199 const GLushort s
[4] = {((const GLushort
*)ptr
)[0], ((const GLushort
*)ptr
)[1], 0, 1};
4200 GL_EXTCALL(glVertexAttrib4NusvARB(i
, s
));
4203 case WINED3DFMT_R16G16B16A16_SNORM
:
4204 GL_EXTCALL(glVertexAttrib4NsvARB(i
, (const GLshort
*)ptr
));
4206 case WINED3DFMT_R16G16B16A16_UNORM
:
4207 GL_EXTCALL(glVertexAttrib4NusvARB(i
, (const GLushort
*)ptr
));
4210 case WINED3DFMT_R10G10B10A2_UINT
:
4211 FIXME("Unsure about WINED3DDECLTYPE_UDEC3\n");
4212 /*glVertexAttrib3usvARB(i, (const GLushort *)ptr); Does not exist */
4214 case WINED3DFMT_R10G10B10A2_SNORM
:
4215 FIXME("Unsure about WINED3DDECLTYPE_DEC3N\n");
4216 /*glVertexAttrib3NusvARB(i, (const GLushort *)ptr); Does not exist */
4219 case WINED3DFMT_R16G16_FLOAT
:
4220 /* Are those 16 bit floats. C doesn't have a 16 bit float type. I could read the single bits and calculate a 4
4221 * byte float according to the IEEE standard
4223 FIXME("Unsupported WINED3DDECLTYPE_FLOAT16_2\n");
4225 case WINED3DFMT_R16G16B16A16_FLOAT
:
4226 FIXME("Unsupported WINED3DDECLTYPE_FLOAT16_4\n");
4230 ERR("Unexpected declaration in stride 0 attributes\n");
4236 checkGLcall("Loading numbered arrays");
4239 /* Used from 2 different functions, and too big to justify making it inlined */
4240 static void loadVertexData(const struct wined3d_context
*context
, IWineD3DStateBlockImpl
*stateblock
,
4241 const struct wined3d_stream_info
*si
)
4243 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4244 const UINT
*offset
= stateblock
->streamOffset
;
4245 GLuint curVBO
= gl_info
->supported
[ARB_VERTEX_BUFFER_OBJECT
] ? ~0U : 0;
4246 const struct wined3d_stream_info_element
*e
;
4248 TRACE("Using fast vertex array code\n");
4250 /* This is fixed function pipeline only, and the fixed function pipeline doesn't do instancing */
4251 stateblock
->device
->instancedDraw
= FALSE
;
4253 /* Blend Data ---------------------------------------------- */
4254 if ((si
->use_map
& (1 << WINED3D_FFP_BLENDWEIGHT
))
4255 || si
->use_map
& (1 << WINED3D_FFP_BLENDINDICES
))
4257 e
= &si
->elements
[WINED3D_FFP_BLENDWEIGHT
];
4259 if (gl_info
->supported
[ARB_VERTEX_BLEND
])
4261 TRACE("Blend %d %p %d\n", e
->format_desc
->component_count
,
4262 e
->data
+ stateblock
->loadBaseVertexIndex
* e
->stride
, e
->stride
+ offset
[e
->stream_idx
]);
4264 glEnableClientState(GL_WEIGHT_ARRAY_ARB
);
4265 checkGLcall("glEnableClientState(GL_WEIGHT_ARRAY_ARB)");
4267 GL_EXTCALL(glVertexBlendARB(e
->format_desc
->component_count
+ 1));
4269 VTRACE(("glWeightPointerARB(%d, GL_FLOAT, %d, %p)\n",
4270 WINED3D_ATR_FORMAT(sd
->u
.s
.blendWeights
.dwType
) ,
4271 sd
->u
.s
.blendWeights
.dwStride
,
4272 sd
->u
.s
.blendWeights
.lpData
+ stateblock
->loadBaseVertexIndex
* sd
->u
.s
.blendWeights
.dwStride
+ offset
[sd
->u
.s
.blendWeights
.streamNo
]));
4274 if (curVBO
!= e
->buffer_object
)
4276 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, e
->buffer_object
));
4277 checkGLcall("glBindBufferARB");
4278 curVBO
= e
->buffer_object
;
4281 GL_EXTCALL(glWeightPointerARB
)(e
->format_desc
->gl_vtx_format
, e
->format_desc
->gl_vtx_type
, e
->stride
,
4282 e
->data
+ stateblock
->loadBaseVertexIndex
* e
->stride
+ offset
[e
->stream_idx
]);
4284 checkGLcall("glWeightPointerARB");
4286 if (si
->use_map
& (1 << WINED3D_FFP_BLENDINDICES
))
4291 FIXME("blendMatrixIndices support\n");
4296 /* TODO: support blends in drawStridedSlow
4297 * No need to write a FIXME here, this is done after the general vertex decl decoding
4299 WARN("unsupported blending in openGl\n");
4304 if (gl_info
->supported
[ARB_VERTEX_BLEND
])
4306 static const GLbyte one
= 1;
4307 GL_EXTCALL(glWeightbvARB(1, &one
));
4308 checkGLcall("glWeightivARB(gl_info->max_blends, weights)");
4312 /* Point Size ----------------------------------------------*/
4313 if (si
->use_map
& (1 << WINED3D_FFP_PSIZE
))
4315 /* no such functionality in the fixed function GL pipeline */
4316 TRACE("Cannot change ptSize here in openGl\n");
4317 /* TODO: Implement this function in using shaders if they are available */
4320 /* Vertex Pointers -----------------------------------------*/
4321 if (si
->use_map
& (1 << WINED3D_FFP_POSITION
))
4323 VTRACE(("glVertexPointer(%d, GL_FLOAT, %d, %p)\n", e
->stride
, e
->size
, e
->data
));
4325 e
= &si
->elements
[WINED3D_FFP_POSITION
];
4326 if (curVBO
!= e
->buffer_object
)
4328 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, e
->buffer_object
));
4329 checkGLcall("glBindBufferARB");
4330 curVBO
= e
->buffer_object
;
4333 /* min(WINED3D_ATR_FORMAT(position),3) to Disable RHW mode as 'w' coord
4334 handling for rhw mode should not impact screen position whereas in GL it does.
4335 This may result in very slightly distorted textures in rhw mode.
4336 There's always the other option of fixing the view matrix to
4337 prevent w from having any effect.
4339 This only applies to user pointer sources, in VBOs the vertices are fixed up
4341 if (!e
->buffer_object
)
4343 glVertexPointer(3 /* min(e->format_desc->gl_vtx_format, 3) */, e
->format_desc
->gl_vtx_type
, e
->stride
,
4344 e
->data
+ stateblock
->loadBaseVertexIndex
* e
->stride
+ offset
[e
->stream_idx
]);
4346 glVertexPointer(e
->format_desc
->gl_vtx_format
, e
->format_desc
->gl_vtx_type
, e
->stride
,
4347 e
->data
+ stateblock
->loadBaseVertexIndex
* e
->stride
+ offset
[e
->stream_idx
]);
4349 checkGLcall("glVertexPointer(...)");
4350 glEnableClientState(GL_VERTEX_ARRAY
);
4351 checkGLcall("glEnableClientState(GL_VERTEX_ARRAY)");
4354 /* Normals -------------------------------------------------*/
4355 if (si
->use_map
& (1 << WINED3D_FFP_NORMAL
))
4357 VTRACE(("glNormalPointer(GL_FLOAT, %d, %p)\n", e
->stride
, e
->data
));
4359 e
= &si
->elements
[WINED3D_FFP_NORMAL
];
4360 if (curVBO
!= e
->buffer_object
)
4362 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, e
->buffer_object
));
4363 checkGLcall("glBindBufferARB");
4364 curVBO
= e
->buffer_object
;
4366 glNormalPointer(e
->format_desc
->gl_vtx_type
, e
->stride
,
4367 e
->data
+ stateblock
->loadBaseVertexIndex
* e
->stride
+ offset
[e
->stream_idx
]);
4368 checkGLcall("glNormalPointer(...)");
4369 glEnableClientState(GL_NORMAL_ARRAY
);
4370 checkGLcall("glEnableClientState(GL_NORMAL_ARRAY)");
4373 glNormal3f(0, 0, 0);
4374 checkGLcall("glNormal3f(0, 0, 0)");
4377 /* Diffuse Colour --------------------------------------------*/
4378 /* WARNING: Data here MUST be in RGBA format, so cannot */
4379 /* go directly into fast mode from app pgm, because */
4380 /* directx requires data in BGRA format. */
4381 /* currently fixupVertices swizzles the format, but this isn't*/
4382 /* very practical when using VBOs */
4383 /* NOTE: Unless we write a vertex shader to swizzle the colour*/
4384 /* , or the user doesn't care and wants the speed advantage */
4386 if (si
->use_map
& (1 << WINED3D_FFP_DIFFUSE
))
4388 VTRACE(("glColorPointer(4, GL_UNSIGNED_BYTE, %d, %p)\n", e
->stride
, e
->data
));
4390 e
= &si
->elements
[WINED3D_FFP_DIFFUSE
];
4391 if (curVBO
!= e
->buffer_object
)
4393 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, e
->buffer_object
));
4394 checkGLcall("glBindBufferARB");
4395 curVBO
= e
->buffer_object
;
4398 glColorPointer(e
->format_desc
->gl_vtx_format
, e
->format_desc
->gl_vtx_type
, e
->stride
,
4399 e
->data
+ stateblock
->loadBaseVertexIndex
* e
->stride
+ offset
[e
->stream_idx
]);
4400 checkGLcall("glColorPointer(4, GL_UNSIGNED_BYTE, ...)");
4401 glEnableClientState(GL_COLOR_ARRAY
);
4402 checkGLcall("glEnableClientState(GL_COLOR_ARRAY)");
4405 glColor4f(1.0f
, 1.0f
, 1.0f
, 1.0f
);
4406 checkGLcall("glColor4f(1, 1, 1, 1)");
4409 /* Specular Colour ------------------------------------------*/
4410 if (si
->use_map
& (1 << WINED3D_FFP_SPECULAR
))
4412 TRACE("setting specular colour\n");
4413 VTRACE(("glSecondaryColorPointer(4, GL_UNSIGNED_BYTE, %d, %p)\n", e
->stride
, e
->data
));
4415 e
= &si
->elements
[WINED3D_FFP_SPECULAR
];
4416 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
4418 GLenum type
= e
->format_desc
->gl_vtx_type
;
4419 GLint format
= e
->format_desc
->gl_vtx_format
;
4421 if (curVBO
!= e
->buffer_object
)
4423 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, e
->buffer_object
));
4424 checkGLcall("glBindBufferARB");
4425 curVBO
= e
->buffer_object
;
4428 if (format
!= 4 || (gl_info
->quirks
& WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA
))
4430 /* Usually specular colors only allow 3 components, since they have no alpha. In D3D, the specular alpha
4431 * contains the fog coordinate, which is passed to GL with GL_EXT_fog_coord. However, the fixed function
4432 * vertex pipeline can pass the specular alpha through, and pixel shaders can read it. So it GL accepts
4433 * 4 component secondary colors use it
4435 GL_EXTCALL(glSecondaryColorPointerEXT
)(format
, type
,
4436 e
->stride
, e
->data
+ stateblock
->loadBaseVertexIndex
* e
->stride
+ offset
[e
->stream_idx
]);
4437 checkGLcall("glSecondaryColorPointerEXT(format, type, ...)");
4443 case GL_UNSIGNED_BYTE
:
4444 GL_EXTCALL(glSecondaryColorPointerEXT
)(3, GL_UNSIGNED_BYTE
,
4445 e
->stride
, e
->data
+ stateblock
->loadBaseVertexIndex
* e
->stride
+ offset
[e
->stream_idx
]);
4446 checkGLcall("glSecondaryColorPointerEXT(3, GL_UNSIGNED_BYTE, ...)");
4450 FIXME("Add 4 component specular color pointers for type %x\n", type
);
4451 /* Make sure that the right color component is dropped */
4452 GL_EXTCALL(glSecondaryColorPointerEXT
)(3, type
,
4453 e
->stride
, e
->data
+ stateblock
->loadBaseVertexIndex
* e
->stride
+ offset
[e
->stream_idx
]);
4454 checkGLcall("glSecondaryColorPointerEXT(3, type, ...)");
4457 glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT
);
4458 checkGLcall("glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
4461 /* Missing specular color is not critical, no warnings */
4462 VTRACE(("Specular colour is not supported in this GL implementation\n"));
4467 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
4469 GL_EXTCALL(glSecondaryColor3fEXT
)(0, 0, 0);
4470 checkGLcall("glSecondaryColor3fEXT(0, 0, 0)");
4473 /* Missing specular color is not critical, no warnings */
4474 VTRACE(("Specular colour is not supported in this GL implementation\n"));
4478 /* Texture coords -------------------------------------------*/
4479 loadTexCoords(context
, stateblock
, si
, &curVBO
);
4482 static inline void drawPrimitiveTraceDataLocations(const struct wined3d_stream_info
*dataLocations
)
4484 /* Dump out what parts we have supplied */
4485 TRACE("Strided Data:\n");
4486 TRACE_STRIDED((dataLocations
), WINED3D_FFP_POSITION
);
4487 TRACE_STRIDED((dataLocations
), WINED3D_FFP_BLENDWEIGHT
);
4488 TRACE_STRIDED((dataLocations
), WINED3D_FFP_BLENDINDICES
);
4489 TRACE_STRIDED((dataLocations
), WINED3D_FFP_NORMAL
);
4490 TRACE_STRIDED((dataLocations
), WINED3D_FFP_PSIZE
);
4491 TRACE_STRIDED((dataLocations
), WINED3D_FFP_DIFFUSE
);
4492 TRACE_STRIDED((dataLocations
), WINED3D_FFP_SPECULAR
);
4493 TRACE_STRIDED((dataLocations
), WINED3D_FFP_TEXCOORD0
);
4494 TRACE_STRIDED((dataLocations
), WINED3D_FFP_TEXCOORD1
);
4495 TRACE_STRIDED((dataLocations
), WINED3D_FFP_TEXCOORD2
);
4496 TRACE_STRIDED((dataLocations
), WINED3D_FFP_TEXCOORD3
);
4497 TRACE_STRIDED((dataLocations
), WINED3D_FFP_TEXCOORD4
);
4498 TRACE_STRIDED((dataLocations
), WINED3D_FFP_TEXCOORD5
);
4499 TRACE_STRIDED((dataLocations
), WINED3D_FFP_TEXCOORD6
);
4500 TRACE_STRIDED((dataLocations
), WINED3D_FFP_TEXCOORD7
);
4503 static void streamsrc(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
4505 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4506 IWineD3DDeviceImpl
*device
= stateblock
->device
;
4508 struct wined3d_stream_info
*dataLocations
= &device
->strided_streams
;
4509 BOOL useVertexShaderFunction
;
4510 BOOL load_numbered
= FALSE
;
4511 BOOL load_named
= FALSE
;
4513 useVertexShaderFunction
= (device
->vs_selected_mode
!= SHADER_NONE
&& stateblock
->vertexShader
) ? TRUE
: FALSE
;
4515 if(device
->up_strided
) {
4516 /* Note: this is a ddraw fixed-function code path */
4517 TRACE("================ Strided Input ===================\n");
4518 device_stream_info_from_strided(gl_info
, device
->up_strided
, dataLocations
);
4521 drawPrimitiveTraceDataLocations(dataLocations
);
4524 /* Note: This is a fixed function or shader codepath.
4525 * This means it must handle both types of strided data.
4526 * Shaders must go through here to zero the strided data, even if they
4527 * don't set any declaration at all
4529 TRACE("================ Vertex Declaration ===================\n");
4530 device_stream_info_from_declaration(device
, useVertexShaderFunction
, dataLocations
, &fixup
);
4533 if (dataLocations
->position_transformed
) useVertexShaderFunction
= FALSE
;
4535 if(useVertexShaderFunction
) {
4536 if(((IWineD3DVertexDeclarationImpl
*) stateblock
->vertexDecl
)->half_float_conv_needed
&& !fixup
) {
4537 TRACE("Using drawStridedSlow with vertex shaders for FLOAT16 conversion\n");
4538 device
->useDrawStridedSlow
= TRUE
;
4540 load_numbered
= TRUE
;
4541 device
->useDrawStridedSlow
= FALSE
;
4546 WORD slow_mask
= (1 << WINED3D_FFP_PSIZE
);
4547 slow_mask
|= -!gl_info
->supported
[EXT_VERTEX_ARRAY_BGRA
]
4548 & ((1 << WINED3D_FFP_DIFFUSE
) | (1 << WINED3D_FFP_SPECULAR
));
4550 if (fixup
|| (!dataLocations
->position_transformed
4551 && !(dataLocations
->use_map
& slow_mask
)))
4553 /* Load the vertex data using named arrays */
4555 device
->useDrawStridedSlow
= FALSE
;
4559 TRACE("Not loading vertex data\n");
4560 device
->useDrawStridedSlow
= TRUE
;
4564 if (context
->numberedArraysLoaded
&& !load_numbered
)
4566 unloadNumberedArrays(stateblock
, context
);
4567 context
->numberedArraysLoaded
= FALSE
;
4568 context
->numbered_array_mask
= 0;
4570 else if (context
->namedArraysLoaded
)
4572 unloadVertexData(context
);
4573 context
->namedArraysLoaded
= FALSE
;
4578 TRACE("Loading numbered arrays\n");
4579 loadNumberedArrays(stateblock
, dataLocations
, context
);
4580 context
->numberedArraysLoaded
= TRUE
;
4582 else if (load_named
)
4584 TRACE("Loading vertex data\n");
4585 loadVertexData(context
, stateblock
, dataLocations
);
4586 context
->namedArraysLoaded
= TRUE
;
4590 static void vertexdeclaration(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
4592 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4593 BOOL updateFog
= FALSE
;
4594 BOOL useVertexShaderFunction
= use_vs(stateblock
);
4595 BOOL usePixelShaderFunction
= use_ps(stateblock
);
4596 IWineD3DDeviceImpl
*device
= stateblock
->device
;
4598 BOOL wasrhw
= context
->last_was_rhw
;
4601 transformed
= device
->strided_streams
.position_transformed
;
4602 if(transformed
!= context
->last_was_rhw
&& !useVertexShaderFunction
) {
4606 /* Reapply lighting if it is not scheduled for reapplication already */
4607 if(!isStateDirty(context
, STATE_RENDER(WINED3DRS_LIGHTING
))) {
4608 state_lighting(STATE_RENDER(WINED3DRS_LIGHTING
), stateblock
, context
);
4612 context
->last_was_rhw
= TRUE
;
4615 /* Untransformed, so relies on the view and projection matrices */
4616 context
->last_was_rhw
= FALSE
;
4617 /* This turns off the Z scale trick to 'disable' viewport frustum clipping in rhw mode*/
4618 device
->untransformed
= TRUE
;
4620 /* Todo for sw shaders: Vertex Shader output is already transformed, so set up identity matrices
4621 * Not needed as long as only hw shaders are supported
4624 /* This sets the shader output position correction constants.
4625 * TODO: Move to the viewport state
4627 if (useVertexShaderFunction
)
4629 GLfloat yoffset
= -(63.0f
/ 64.0f
) / stateblock
->viewport
.Height
;
4630 device
->posFixup
[1] = context
->render_offscreen
? -1.0f
: 1.0f
;
4631 device
->posFixup
[3] = device
->posFixup
[1] * yoffset
;
4635 /* Don't have to apply the matrices when vertex shaders are used. When vshaders are turned
4636 * off this function will be called again anyway to make sure they're properly set
4638 if(!useVertexShaderFunction
) {
4639 /* TODO: Move this mainly to the viewport state and only apply when the vp has changed
4640 * or transformed / untransformed was switched
4642 if(wasrhw
!= context
->last_was_rhw
&&
4643 !isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_PROJECTION
)) &&
4644 !isStateDirty(context
, STATE_VIEWPORT
)) {
4645 transform_projection(STATE_TRANSFORM(WINED3DTS_PROJECTION
), stateblock
, context
);
4647 /* World matrix needs reapplication here only if we're switching between rhw and non-rhw
4650 * If a vertex shader is used, the world matrix changed and then vertex shader unbound
4651 * this check will fail and the matrix not applied again. This is OK because a simple
4652 * world matrix change reapplies the matrix - These checks here are only to satisfy the
4653 * needs of the vertex declaration.
4655 * World and view matrix go into the same gl matrix, so only apply them when neither is
4658 if(transformed
!= wasrhw
&&
4659 !isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0))) &&
4660 !isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_VIEW
))) {
4661 transform_world(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), stateblock
, context
);
4664 if(!isStateDirty(context
, STATE_RENDER(WINED3DRS_COLORVERTEX
))) {
4665 state_colormat(STATE_RENDER(WINED3DRS_COLORVERTEX
), stateblock
, context
);
4668 if(context
->last_was_vshader
) {
4670 if(!device
->vs_clipping
&& !isStateDirty(context
, STATE_RENDER(WINED3DRS_CLIPPLANEENABLE
))) {
4671 state_clipping(STATE_RENDER(WINED3DRS_CLIPPLANEENABLE
), stateblock
, context
);
4673 for (i
= 0; i
< gl_info
->limits
.clipplanes
; ++i
)
4675 clipplane(STATE_CLIPPLANE(i
), stateblock
, context
);
4678 if(!isStateDirty(context
, STATE_RENDER(WINED3DRS_NORMALIZENORMALS
))) {
4679 state_normalize(STATE_RENDER(WINED3DRS_NORMALIZENORMALS
), stateblock
, context
);
4682 if(!context
->last_was_vshader
) {
4683 static BOOL warned
= FALSE
;
4684 if(!device
->vs_clipping
) {
4685 /* Disable all clip planes to get defined results on all drivers. See comment in the
4686 * state_clipping state handler
4688 for (i
= 0; i
< gl_info
->limits
.clipplanes
; ++i
)
4690 glDisable(GL_CLIP_PLANE0
+ i
);
4691 checkGLcall("glDisable(GL_CLIP_PLANE0 + i)");
4694 if(!warned
&& stateblock
->renderState
[WINED3DRS_CLIPPLANEENABLE
]) {
4695 FIXME("Clipping not supported with vertex shaders\n");
4700 /* Apply the transform matrices when switching from rhw drawing to vertex shaders. Vertex
4701 * shaders themselves do not need it, but the matrices are not reapplied automatically when
4702 * switching back from vertex shaders to fixed function processing. So make sure we leave the
4703 * fixed function vertex processing states back in a sane state before switching to shaders
4705 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_PROJECTION
))) {
4706 transform_projection(STATE_TRANSFORM(WINED3DTS_PROJECTION
), stateblock
, context
);
4708 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)))) {
4709 transform_world(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), stateblock
, context
);
4714 /* Vertex shader clipping ignores the view matrix. Update all clipplanes
4715 * (Note: ARB shaders can read the clip planes for clipping emulation even if
4716 * device->vs_clipping is false.
4718 for (i
= 0; i
< gl_info
->limits
.clipplanes
; ++i
)
4720 clipplane(STATE_CLIPPLANE(i
), stateblock
, context
);
4725 /* Vertex and pixel shaders are applied together for now, so let the last dirty state do the
4728 if (!isStateDirty(context
, STATE_PIXELSHADER
)) {
4729 device
->shader_backend
->shader_select(context
, usePixelShaderFunction
, useVertexShaderFunction
);
4731 if (!isStateDirty(context
, STATE_VERTEXSHADERCONSTANT
) && (useVertexShaderFunction
|| usePixelShaderFunction
)) {
4732 shaderconstant(STATE_VERTEXSHADERCONSTANT
, stateblock
, context
);
4736 context
->last_was_vshader
= useVertexShaderFunction
;
4739 device
->StateTable
[STATE_RENDER(WINED3DRS_FOGVERTEXMODE
)].apply(STATE_RENDER(WINED3DRS_FOGVERTEXMODE
), stateblock
, context
);
4741 if(!useVertexShaderFunction
) {
4743 for(i
= 0; i
< MAX_TEXTURES
; i
++) {
4744 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_TEXTURE0
+ i
))) {
4745 transform_texture(STATE_TEXTURESTAGE(i
, WINED3DTSS_TEXTURETRANSFORMFLAGS
), stateblock
, context
);
4751 static void viewport_miscpart(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
4753 IWineD3DSurfaceImpl
*target
= (IWineD3DSurfaceImpl
*)stateblock
->device
->render_targets
[0];
4755 WINED3DVIEWPORT vp
= stateblock
->viewport
;
4757 if(vp
.Width
> target
->currentDesc
.Width
) vp
.Width
= target
->currentDesc
.Width
;
4758 if(vp
.Height
> target
->currentDesc
.Height
) vp
.Height
= target
->currentDesc
.Height
;
4760 glDepthRange(vp
.MinZ
, vp
.MaxZ
);
4761 checkGLcall("glDepthRange");
4762 /* Note: GL requires lower left, DirectX supplies upper left. This is reversed when using offscreen rendering
4764 if (context
->render_offscreen
)
4766 glViewport(vp
.X
, vp
.Y
, vp
.Width
, vp
.Height
);
4768 target
->get_drawable_size(context
, &width
, &height
);
4771 (height
- (vp
.Y
+ vp
.Height
)),
4772 vp
.Width
, vp
.Height
);
4775 checkGLcall("glViewport");
4778 static void viewport_vertexpart(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
4780 GLfloat yoffset
= -(63.0f
/ 64.0f
) / stateblock
->viewport
.Height
;
4782 stateblock
->device
->posFixup
[2] = (63.0f
/ 64.0f
) / stateblock
->viewport
.Width
;
4783 stateblock
->device
->posFixup
[3] = stateblock
->device
->posFixup
[1] * yoffset
;
4785 if(!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_PROJECTION
))) {
4786 transform_projection(STATE_TRANSFORM(WINED3DTS_PROJECTION
), stateblock
, context
);
4788 if(!isStateDirty(context
, STATE_RENDER(WINED3DRS_POINTSCALEENABLE
))) {
4789 state_pscale(STATE_RENDER(WINED3DRS_POINTSCALEENABLE
), stateblock
, context
);
4793 static void light(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
4795 UINT Index
= state
- STATE_ACTIVELIGHT(0);
4796 const struct wined3d_light_info
*lightInfo
= stateblock
->activeLights
[Index
];
4799 glDisable(GL_LIGHT0
+ Index
);
4800 checkGLcall("glDisable(GL_LIGHT0 + Index)");
4803 float colRGBA
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
4805 /* Light settings are affected by the model view in OpenGL, the View transform in direct3d*/
4806 glMatrixMode(GL_MODELVIEW
);
4808 glLoadMatrixf(&stateblock
->transforms
[WINED3DTS_VIEW
].u
.m
[0][0]);
4811 colRGBA
[0] = lightInfo
->OriginalParms
.Diffuse
.r
;
4812 colRGBA
[1] = lightInfo
->OriginalParms
.Diffuse
.g
;
4813 colRGBA
[2] = lightInfo
->OriginalParms
.Diffuse
.b
;
4814 colRGBA
[3] = lightInfo
->OriginalParms
.Diffuse
.a
;
4815 glLightfv(GL_LIGHT0
+ Index
, GL_DIFFUSE
, colRGBA
);
4816 checkGLcall("glLightfv");
4819 colRGBA
[0] = lightInfo
->OriginalParms
.Specular
.r
;
4820 colRGBA
[1] = lightInfo
->OriginalParms
.Specular
.g
;
4821 colRGBA
[2] = lightInfo
->OriginalParms
.Specular
.b
;
4822 colRGBA
[3] = lightInfo
->OriginalParms
.Specular
.a
;
4823 glLightfv(GL_LIGHT0
+ Index
, GL_SPECULAR
, colRGBA
);
4824 checkGLcall("glLightfv");
4827 colRGBA
[0] = lightInfo
->OriginalParms
.Ambient
.r
;
4828 colRGBA
[1] = lightInfo
->OriginalParms
.Ambient
.g
;
4829 colRGBA
[2] = lightInfo
->OriginalParms
.Ambient
.b
;
4830 colRGBA
[3] = lightInfo
->OriginalParms
.Ambient
.a
;
4831 glLightfv(GL_LIGHT0
+ Index
, GL_AMBIENT
, colRGBA
);
4832 checkGLcall("glLightfv");
4834 if ((lightInfo
->OriginalParms
.Range
*lightInfo
->OriginalParms
.Range
) >= FLT_MIN
) {
4835 quad_att
= 1.4f
/(lightInfo
->OriginalParms
.Range
*lightInfo
->OriginalParms
.Range
);
4837 quad_att
= 0.0f
; /* 0 or MAX? (0 seems to be ok) */
4840 /* Do not assign attenuation values for lights that do not use them. D3D apps are free to pass any junk,
4841 * but gl drivers use them and may crash due to bad Attenuation values. Need for Speed most wanted sets
4842 * Attenuation0 to NaN and crashes in the gl lib
4845 switch (lightInfo
->OriginalParms
.Type
) {
4846 case WINED3DLIGHT_POINT
:
4848 glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->lightPosn
[0]);
4849 checkGLcall("glLightfv");
4850 glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
4851 checkGLcall("glLightf");
4852 /* Attenuation - Are these right? guessing... */
4853 glLightf(GL_LIGHT0
+ Index
, GL_CONSTANT_ATTENUATION
, lightInfo
->OriginalParms
.Attenuation0
);
4854 checkGLcall("glLightf");
4855 glLightf(GL_LIGHT0
+ Index
, GL_LINEAR_ATTENUATION
, lightInfo
->OriginalParms
.Attenuation1
);
4856 checkGLcall("glLightf");
4857 if (quad_att
< lightInfo
->OriginalParms
.Attenuation2
) quad_att
= lightInfo
->OriginalParms
.Attenuation2
;
4858 glLightf(GL_LIGHT0
+ Index
, GL_QUADRATIC_ATTENUATION
, quad_att
);
4859 checkGLcall("glLightf");
4863 case WINED3DLIGHT_SPOT
:
4865 glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->lightPosn
[0]);
4866 checkGLcall("glLightfv");
4868 glLightfv(GL_LIGHT0
+ Index
, GL_SPOT_DIRECTION
, &lightInfo
->lightDirn
[0]);
4869 checkGLcall("glLightfv");
4870 glLightf(GL_LIGHT0
+ Index
, GL_SPOT_EXPONENT
, lightInfo
->exponent
);
4871 checkGLcall("glLightf");
4872 glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
4873 checkGLcall("glLightf");
4874 /* Attenuation - Are these right? guessing... */
4875 glLightf(GL_LIGHT0
+ Index
, GL_CONSTANT_ATTENUATION
, lightInfo
->OriginalParms
.Attenuation0
);
4876 checkGLcall("glLightf");
4877 glLightf(GL_LIGHT0
+ Index
, GL_LINEAR_ATTENUATION
, lightInfo
->OriginalParms
.Attenuation1
);
4878 checkGLcall("glLightf");
4879 if (quad_att
< lightInfo
->OriginalParms
.Attenuation2
) quad_att
= lightInfo
->OriginalParms
.Attenuation2
;
4880 glLightf(GL_LIGHT0
+ Index
, GL_QUADRATIC_ATTENUATION
, quad_att
);
4881 checkGLcall("glLightf");
4885 case WINED3DLIGHT_DIRECTIONAL
:
4887 glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->lightPosn
[0]); /* Note gl uses w position of 0 for direction! */
4888 checkGLcall("glLightfv");
4889 glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
4890 checkGLcall("glLightf");
4891 glLightf(GL_LIGHT0
+ Index
, GL_SPOT_EXPONENT
, 0.0f
);
4892 checkGLcall("glLightf");
4896 FIXME("Unrecognized light type %d\n", lightInfo
->OriginalParms
.Type
);
4899 /* Restore the modelview matrix */
4902 glEnable(GL_LIGHT0
+ Index
);
4903 checkGLcall("glEnable(GL_LIGHT0 + Index)");
4907 static void scissorrect(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
4909 IWineD3DSurfaceImpl
*target
= (IWineD3DSurfaceImpl
*)stateblock
->device
->render_targets
[0];
4910 RECT
*pRect
= &stateblock
->scissorRect
;
4914 target
->get_drawable_size(context
, &width
, &height
);
4915 /* Warning: glScissor uses window coordinates, not viewport coordinates, so our viewport correction does not apply
4916 * Warning2: Even in windowed mode the coords are relative to the window, not the screen
4918 TRACE("(%p) Setting new Scissor Rect to %d:%d-%d:%d\n", stateblock
->device
, pRect
->left
, pRect
->bottom
- height
,
4919 pRect
->right
- pRect
->left
, pRect
->bottom
- pRect
->top
);
4921 if (context
->render_offscreen
)
4923 glScissor(pRect
->left
, pRect
->top
, pRect
->right
- pRect
->left
, pRect
->bottom
- pRect
->top
);
4925 glScissor(pRect
->left
, height
- pRect
->bottom
, pRect
->right
- pRect
->left
, pRect
->bottom
- pRect
->top
);
4927 checkGLcall("glScissor");
4930 static void indexbuffer(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
4932 if(stateblock
->streamIsUP
|| stateblock
->pIndexData
== NULL
) {
4933 GL_EXTCALL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB
, 0));
4935 struct wined3d_buffer
*ib
= (struct wined3d_buffer
*) stateblock
->pIndexData
;
4936 GL_EXTCALL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB
, ib
->buffer_object
));
4940 static void frontface(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
4942 if (context
->render_offscreen
)
4944 glFrontFace(GL_CCW
);
4945 checkGLcall("glFrontFace(GL_CCW)");
4948 checkGLcall("glFrontFace(GL_CW)");
4952 const struct StateEntryTemplate misc_state_template
[] = {
4953 { STATE_RENDER(WINED3DRS_SRCBLEND
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
}, WINED3D_GL_EXT_NONE
},
4954 { STATE_RENDER(WINED3DRS_DESTBLEND
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
}, WINED3D_GL_EXT_NONE
},
4955 { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
}, WINED3D_GL_EXT_NONE
},
4956 { STATE_RENDER(WINED3DRS_EDGEANTIALIAS
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
}, WINED3D_GL_EXT_NONE
},
4957 { STATE_RENDER(WINED3DRS_ANTIALIASEDLINEENABLE
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
}, WINED3D_GL_EXT_NONE
},
4958 { STATE_RENDER(WINED3DRS_SEPARATEALPHABLENDENABLE
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
}, WINED3D_GL_EXT_NONE
},
4959 { STATE_RENDER(WINED3DRS_SRCBLENDALPHA
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
}, WINED3D_GL_EXT_NONE
},
4960 { STATE_RENDER(WINED3DRS_DESTBLENDALPHA
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
}, WINED3D_GL_EXT_NONE
},
4961 { STATE_RENDER(WINED3DRS_DESTBLENDALPHA
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
}, WINED3D_GL_EXT_NONE
},
4962 { STATE_RENDER(WINED3DRS_BLENDOPALPHA
), { STATE_RENDER(WINED3DRS_ALPHABLENDENABLE
), state_blend
}, WINED3D_GL_EXT_NONE
},
4963 { STATE_STREAMSRC
, { STATE_VDECL
, streamsrc
}, WINED3D_GL_EXT_NONE
},
4964 { STATE_VDECL
, { STATE_VDECL
, streamsrc
}, WINED3D_GL_EXT_NONE
},
4965 { STATE_FRONTFACE
, { STATE_FRONTFACE
, frontface
}, WINED3D_GL_EXT_NONE
},
4966 { STATE_SCISSORRECT
, { STATE_SCISSORRECT
, scissorrect
}, WINED3D_GL_EXT_NONE
},
4967 /* TODO: Move shader constant loading to vertex and fragment pipeline repectively, as soon as the pshader and
4968 * vshader loadings are untied from each other
4970 { STATE_VERTEXSHADERCONSTANT
, { STATE_VERTEXSHADERCONSTANT
, shaderconstant
}, WINED3D_GL_EXT_NONE
},
4971 { STATE_PIXELSHADERCONSTANT
, { STATE_VERTEXSHADERCONSTANT
, shaderconstant
}, WINED3D_GL_EXT_NONE
},
4972 { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4973 { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4974 { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4975 { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4976 { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4977 { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4978 { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4979 { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4980 { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4981 { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4982 { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4983 { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4984 { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4985 { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4986 { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4987 { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4988 { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4989 { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4990 { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4991 { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4992 { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4993 { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4994 { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4995 { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4996 { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4997 { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4998 { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4999 { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
5000 { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
5001 { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
5002 { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
5003 { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
5004 { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
5005 { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
5006 { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
5007 { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
5008 { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
5009 { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
5010 { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
5011 { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
5012 { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
5013 { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
5014 { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
5015 { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
5016 { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
5017 { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
5018 { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
5019 { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
5021 { STATE_VIEWPORT
, { STATE_VIEWPORT
, viewport_miscpart
}, WINED3D_GL_EXT_NONE
},
5022 { STATE_INDEXBUFFER
, { STATE_INDEXBUFFER
, indexbuffer
}, ARB_VERTEX_BUFFER_OBJECT
},
5023 { STATE_RENDER(WINED3DRS_ANTIALIAS
), { STATE_RENDER(WINED3DRS_ANTIALIAS
), state_antialias
}, WINED3D_GL_EXT_NONE
},
5024 { STATE_RENDER(WINED3DRS_TEXTUREPERSPECTIVE
), { STATE_RENDER(WINED3DRS_TEXTUREPERSPECTIVE
), state_perspective
}, WINED3D_GL_EXT_NONE
},
5025 { STATE_RENDER(WINED3DRS_ZENABLE
), { STATE_RENDER(WINED3DRS_ZENABLE
), state_zenable
}, WINED3D_GL_EXT_NONE
},
5026 { STATE_RENDER(WINED3DRS_WRAPU
), { STATE_RENDER(WINED3DRS_WRAPU
), state_wrapu
}, WINED3D_GL_EXT_NONE
},
5027 { STATE_RENDER(WINED3DRS_WRAPV
), { STATE_RENDER(WINED3DRS_WRAPV
), state_wrapv
}, WINED3D_GL_EXT_NONE
},
5028 { STATE_RENDER(WINED3DRS_FILLMODE
), { STATE_RENDER(WINED3DRS_FILLMODE
), state_fillmode
}, WINED3D_GL_EXT_NONE
},
5029 { STATE_RENDER(WINED3DRS_SHADEMODE
), { STATE_RENDER(WINED3DRS_SHADEMODE
), state_shademode
}, WINED3D_GL_EXT_NONE
},
5030 { STATE_RENDER(WINED3DRS_LINEPATTERN
), { STATE_RENDER(WINED3DRS_LINEPATTERN
), state_linepattern
}, WINED3D_GL_EXT_NONE
},
5031 { STATE_RENDER(WINED3DRS_MONOENABLE
), { STATE_RENDER(WINED3DRS_MONOENABLE
), state_monoenable
}, WINED3D_GL_EXT_NONE
},
5032 { STATE_RENDER(WINED3DRS_ROP2
), { STATE_RENDER(WINED3DRS_ROP2
), state_rop2
}, WINED3D_GL_EXT_NONE
},
5033 { STATE_RENDER(WINED3DRS_PLANEMASK
), { STATE_RENDER(WINED3DRS_PLANEMASK
), state_planemask
}, WINED3D_GL_EXT_NONE
},
5034 { STATE_RENDER(WINED3DRS_ZWRITEENABLE
), { STATE_RENDER(WINED3DRS_ZWRITEENABLE
), state_zwritenable
}, WINED3D_GL_EXT_NONE
},
5035 { STATE_RENDER(WINED3DRS_ALPHATESTENABLE
), { STATE_RENDER(WINED3DRS_ALPHATESTENABLE
), state_alpha
}, WINED3D_GL_EXT_NONE
},
5036 { STATE_RENDER(WINED3DRS_ALPHAREF
), { STATE_RENDER(WINED3DRS_ALPHATESTENABLE
), state_alpha
}, WINED3D_GL_EXT_NONE
},
5037 { STATE_RENDER(WINED3DRS_ALPHAFUNC
), { STATE_RENDER(WINED3DRS_ALPHATESTENABLE
), state_alpha
}, WINED3D_GL_EXT_NONE
},
5038 { STATE_RENDER(WINED3DRS_COLORKEYENABLE
), { STATE_RENDER(WINED3DRS_ALPHATESTENABLE
), state_alpha
}, WINED3D_GL_EXT_NONE
},
5039 { STATE_RENDER(WINED3DRS_LASTPIXEL
), { STATE_RENDER(WINED3DRS_LASTPIXEL
), state_lastpixel
}, WINED3D_GL_EXT_NONE
},
5040 { STATE_RENDER(WINED3DRS_CULLMODE
), { STATE_RENDER(WINED3DRS_CULLMODE
), state_cullmode
}, WINED3D_GL_EXT_NONE
},
5041 { STATE_RENDER(WINED3DRS_ZFUNC
), { STATE_RENDER(WINED3DRS_ZFUNC
), state_zfunc
}, WINED3D_GL_EXT_NONE
},
5042 { STATE_RENDER(WINED3DRS_DITHERENABLE
), { STATE_RENDER(WINED3DRS_DITHERENABLE
), state_ditherenable
}, WINED3D_GL_EXT_NONE
},
5043 { STATE_RENDER(WINED3DRS_SUBPIXEL
), { STATE_RENDER(WINED3DRS_SUBPIXEL
), state_subpixel
}, WINED3D_GL_EXT_NONE
},
5044 { STATE_RENDER(WINED3DRS_SUBPIXELX
), { STATE_RENDER(WINED3DRS_SUBPIXELX
), state_subpixelx
}, WINED3D_GL_EXT_NONE
},
5045 { STATE_RENDER(WINED3DRS_STIPPLEDALPHA
), { STATE_RENDER(WINED3DRS_STIPPLEDALPHA
), state_stippledalpha
}, WINED3D_GL_EXT_NONE
},
5046 { STATE_RENDER(WINED3DRS_ZBIAS
), { STATE_RENDER(WINED3DRS_ZBIAS
), state_zbias
}, WINED3D_GL_EXT_NONE
},
5047 { STATE_RENDER(WINED3DRS_STIPPLEENABLE
), { STATE_RENDER(WINED3DRS_STIPPLEENABLE
), state_stippleenable
}, WINED3D_GL_EXT_NONE
},
5048 { STATE_RENDER(WINED3DRS_MIPMAPLODBIAS
), { STATE_RENDER(WINED3DRS_MIPMAPLODBIAS
), state_mipmaplodbias
}, WINED3D_GL_EXT_NONE
},
5049 { STATE_RENDER(WINED3DRS_ANISOTROPY
), { STATE_RENDER(WINED3DRS_ANISOTROPY
), state_anisotropy
}, WINED3D_GL_EXT_NONE
},
5050 { STATE_RENDER(WINED3DRS_FLUSHBATCH
), { STATE_RENDER(WINED3DRS_FLUSHBATCH
), state_flushbatch
}, WINED3D_GL_EXT_NONE
},
5051 { STATE_RENDER(WINED3DRS_TRANSLUCENTSORTINDEPENDENT
), { STATE_RENDER(WINED3DRS_TRANSLUCENTSORTINDEPENDENT
), state_translucentsi
}, WINED3D_GL_EXT_NONE
},
5052 { STATE_RENDER(WINED3DRS_STENCILENABLE
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
}, WINED3D_GL_EXT_NONE
},
5053 { STATE_RENDER(WINED3DRS_STENCILFAIL
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
}, WINED3D_GL_EXT_NONE
},
5054 { STATE_RENDER(WINED3DRS_STENCILZFAIL
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
}, WINED3D_GL_EXT_NONE
},
5055 { STATE_RENDER(WINED3DRS_STENCILPASS
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
}, WINED3D_GL_EXT_NONE
},
5056 { STATE_RENDER(WINED3DRS_STENCILFUNC
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
}, WINED3D_GL_EXT_NONE
},
5057 { STATE_RENDER(WINED3DRS_STENCILREF
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
}, WINED3D_GL_EXT_NONE
},
5058 { STATE_RENDER(WINED3DRS_STENCILMASK
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
}, WINED3D_GL_EXT_NONE
},
5059 { STATE_RENDER(WINED3DRS_STENCILWRITEMASK
), { STATE_RENDER(WINED3DRS_STENCILWRITEMASK
), state_stencilwrite2s
}, EXT_STENCIL_TWO_SIDE
},
5060 { STATE_RENDER(WINED3DRS_STENCILWRITEMASK
), { STATE_RENDER(WINED3DRS_STENCILWRITEMASK
), state_stencilwrite
}, WINED3D_GL_EXT_NONE
},
5061 { STATE_RENDER(WINED3DRS_TWOSIDEDSTENCILMODE
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
}, WINED3D_GL_EXT_NONE
},
5062 { STATE_RENDER(WINED3DRS_CCW_STENCILFAIL
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
}, WINED3D_GL_EXT_NONE
},
5063 { STATE_RENDER(WINED3DRS_CCW_STENCILZFAIL
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
}, WINED3D_GL_EXT_NONE
},
5064 { STATE_RENDER(WINED3DRS_CCW_STENCILPASS
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
}, WINED3D_GL_EXT_NONE
},
5065 { STATE_RENDER(WINED3DRS_CCW_STENCILFUNC
), { STATE_RENDER(WINED3DRS_STENCILENABLE
), state_stencil
}, WINED3D_GL_EXT_NONE
},
5066 { STATE_RENDER(WINED3DRS_WRAP0
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, WINED3D_GL_EXT_NONE
},
5067 { STATE_RENDER(WINED3DRS_WRAP1
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, WINED3D_GL_EXT_NONE
},
5068 { STATE_RENDER(WINED3DRS_WRAP2
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, WINED3D_GL_EXT_NONE
},
5069 { STATE_RENDER(WINED3DRS_WRAP3
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, WINED3D_GL_EXT_NONE
},
5070 { STATE_RENDER(WINED3DRS_WRAP4
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, WINED3D_GL_EXT_NONE
},
5071 { STATE_RENDER(WINED3DRS_WRAP5
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, WINED3D_GL_EXT_NONE
},
5072 { STATE_RENDER(WINED3DRS_WRAP6
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, WINED3D_GL_EXT_NONE
},
5073 { STATE_RENDER(WINED3DRS_WRAP7
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, WINED3D_GL_EXT_NONE
},
5074 { STATE_RENDER(WINED3DRS_WRAP8
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, WINED3D_GL_EXT_NONE
},
5075 { STATE_RENDER(WINED3DRS_WRAP9
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, WINED3D_GL_EXT_NONE
},
5076 { STATE_RENDER(WINED3DRS_WRAP10
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, WINED3D_GL_EXT_NONE
},
5077 { STATE_RENDER(WINED3DRS_WRAP11
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, WINED3D_GL_EXT_NONE
},
5078 { STATE_RENDER(WINED3DRS_WRAP12
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, WINED3D_GL_EXT_NONE
},
5079 { STATE_RENDER(WINED3DRS_WRAP13
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, WINED3D_GL_EXT_NONE
},
5080 { STATE_RENDER(WINED3DRS_WRAP14
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, WINED3D_GL_EXT_NONE
},
5081 { STATE_RENDER(WINED3DRS_WRAP15
), { STATE_RENDER(WINED3DRS_WRAP0
), state_wrap
}, WINED3D_GL_EXT_NONE
},
5082 { STATE_RENDER(WINED3DRS_EXTENTS
), { STATE_RENDER(WINED3DRS_EXTENTS
), state_extents
}, WINED3D_GL_EXT_NONE
},
5083 { STATE_RENDER(WINED3DRS_COLORKEYBLENDENABLE
), { STATE_RENDER(WINED3DRS_COLORKEYBLENDENABLE
), state_ckeyblend
}, WINED3D_GL_EXT_NONE
},
5084 { STATE_RENDER(WINED3DRS_SOFTWAREVERTEXPROCESSING
), { STATE_RENDER(WINED3DRS_SOFTWAREVERTEXPROCESSING
), state_swvp
}, WINED3D_GL_EXT_NONE
},
5085 { STATE_RENDER(WINED3DRS_PATCHEDGESTYLE
), { STATE_RENDER(WINED3DRS_PATCHEDGESTYLE
), state_patchedgestyle
}, WINED3D_GL_EXT_NONE
},
5086 { STATE_RENDER(WINED3DRS_PATCHSEGMENTS
), { STATE_RENDER(WINED3DRS_PATCHSEGMENTS
), state_patchsegments
}, WINED3D_GL_EXT_NONE
},
5087 { STATE_RENDER(WINED3DRS_POSITIONDEGREE
), { STATE_RENDER(WINED3DRS_POSITIONDEGREE
), state_positiondegree
}, WINED3D_GL_EXT_NONE
},
5088 { STATE_RENDER(WINED3DRS_NORMALDEGREE
), { STATE_RENDER(WINED3DRS_NORMALDEGREE
), state_normaldegree
}, WINED3D_GL_EXT_NONE
},
5089 { STATE_RENDER(WINED3DRS_MINTESSELLATIONLEVEL
), { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), state_tessellation
}, WINED3D_GL_EXT_NONE
},
5090 { STATE_RENDER(WINED3DRS_MAXTESSELLATIONLEVEL
), { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), state_tessellation
}, WINED3D_GL_EXT_NONE
},
5091 { STATE_RENDER(WINED3DRS_ADAPTIVETESS_X
), { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), state_tessellation
}, WINED3D_GL_EXT_NONE
},
5092 { STATE_RENDER(WINED3DRS_ADAPTIVETESS_Y
), { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), state_tessellation
}, WINED3D_GL_EXT_NONE
},
5093 { STATE_RENDER(WINED3DRS_ADAPTIVETESS_Z
), { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), state_tessellation
}, WINED3D_GL_EXT_NONE
},
5094 { STATE_RENDER(WINED3DRS_ADAPTIVETESS_W
), { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), state_tessellation
}, WINED3D_GL_EXT_NONE
},
5095 { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), { STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION
), state_tessellation
}, WINED3D_GL_EXT_NONE
},
5096 { STATE_RENDER(WINED3DRS_MULTISAMPLEANTIALIAS
), { STATE_RENDER(WINED3DRS_MULTISAMPLEANTIALIAS
), state_msaa
}, ARB_MULTISAMPLE
},
5097 { STATE_RENDER(WINED3DRS_MULTISAMPLEANTIALIAS
), { STATE_RENDER(WINED3DRS_MULTISAMPLEANTIALIAS
), state_msaa_w
}, WINED3D_GL_EXT_NONE
},
5098 { STATE_RENDER(WINED3DRS_MULTISAMPLEMASK
), { STATE_RENDER(WINED3DRS_MULTISAMPLEMASK
), state_multisampmask
}, WINED3D_GL_EXT_NONE
},
5099 { STATE_RENDER(WINED3DRS_DEBUGMONITORTOKEN
), { STATE_RENDER(WINED3DRS_DEBUGMONITORTOKEN
), state_debug_monitor
}, WINED3D_GL_EXT_NONE
},
5100 { STATE_RENDER(WINED3DRS_COLORWRITEENABLE
), { STATE_RENDER(WINED3DRS_COLORWRITEENABLE
), state_colorwrite
}, WINED3D_GL_EXT_NONE
},
5101 { STATE_RENDER(WINED3DRS_BLENDOP
), { STATE_RENDER(WINED3DRS_BLENDOP
), state_blendop
}, EXT_BLEND_MINMAX
},
5102 { STATE_RENDER(WINED3DRS_BLENDOP
), { STATE_RENDER(WINED3DRS_BLENDOP
), state_blendop_w
}, WINED3D_GL_EXT_NONE
},
5103 { STATE_RENDER(WINED3DRS_SCISSORTESTENABLE
), { STATE_RENDER(WINED3DRS_SCISSORTESTENABLE
), state_scissor
}, WINED3D_GL_EXT_NONE
},
5104 { STATE_RENDER(WINED3DRS_SLOPESCALEDEPTHBIAS
), { STATE_RENDER(WINED3DRS_DEPTHBIAS
), state_depthbias
}, WINED3D_GL_EXT_NONE
},
5105 { STATE_RENDER(WINED3DRS_COLORWRITEENABLE1
), { STATE_RENDER(WINED3DRS_COLORWRITEENABLE
), state_colorwrite
}, WINED3D_GL_EXT_NONE
},
5106 { STATE_RENDER(WINED3DRS_COLORWRITEENABLE2
), { STATE_RENDER(WINED3DRS_COLORWRITEENABLE
), state_colorwrite
}, WINED3D_GL_EXT_NONE
},
5107 { STATE_RENDER(WINED3DRS_COLORWRITEENABLE3
), { STATE_RENDER(WINED3DRS_COLORWRITEENABLE
), state_colorwrite
}, WINED3D_GL_EXT_NONE
},
5108 { STATE_RENDER(WINED3DRS_BLENDFACTOR
), { STATE_RENDER(WINED3DRS_BLENDFACTOR
), state_blendfactor
}, EXT_BLEND_COLOR
},
5109 { STATE_RENDER(WINED3DRS_BLENDFACTOR
), { STATE_RENDER(WINED3DRS_BLENDFACTOR
), state_blendfactor_w
}, WINED3D_GL_EXT_NONE
},
5110 { STATE_RENDER(WINED3DRS_DEPTHBIAS
), { STATE_RENDER(WINED3DRS_DEPTHBIAS
), state_depthbias
}, WINED3D_GL_EXT_NONE
},
5112 { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler
}, WINED3D_GL_EXT_NONE
},
5113 { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler
}, WINED3D_GL_EXT_NONE
},
5114 { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler
}, WINED3D_GL_EXT_NONE
},
5115 { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler
}, WINED3D_GL_EXT_NONE
},
5116 { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler
}, WINED3D_GL_EXT_NONE
},
5117 { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler
}, WINED3D_GL_EXT_NONE
},
5118 { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler
}, WINED3D_GL_EXT_NONE
},
5119 { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler
}, WINED3D_GL_EXT_NONE
},
5120 { STATE_SAMPLER(8), { STATE_SAMPLER(8), sampler
}, WINED3D_GL_EXT_NONE
},
5121 { STATE_SAMPLER(9), { STATE_SAMPLER(9), sampler
}, WINED3D_GL_EXT_NONE
},
5122 { STATE_SAMPLER(10), { STATE_SAMPLER(10), sampler
}, WINED3D_GL_EXT_NONE
},
5123 { STATE_SAMPLER(11), { STATE_SAMPLER(11), sampler
}, WINED3D_GL_EXT_NONE
},
5124 { STATE_SAMPLER(12), { STATE_SAMPLER(12), sampler
}, WINED3D_GL_EXT_NONE
},
5125 { STATE_SAMPLER(13), { STATE_SAMPLER(13), sampler
}, WINED3D_GL_EXT_NONE
},
5126 { STATE_SAMPLER(14), { STATE_SAMPLER(14), sampler
}, WINED3D_GL_EXT_NONE
},
5127 { STATE_SAMPLER(15), { STATE_SAMPLER(15), sampler
}, WINED3D_GL_EXT_NONE
},
5128 { STATE_SAMPLER(16), /* Vertex sampler 0 */ { STATE_SAMPLER(16), sampler
}, WINED3D_GL_EXT_NONE
},
5129 { STATE_SAMPLER(17), /* Vertex sampler 1 */ { STATE_SAMPLER(17), sampler
}, WINED3D_GL_EXT_NONE
},
5130 { STATE_SAMPLER(18), /* Vertex sampler 2 */ { STATE_SAMPLER(18), sampler
}, WINED3D_GL_EXT_NONE
},
5131 { STATE_SAMPLER(19), /* Vertex sampler 3 */ { STATE_SAMPLER(19), sampler
}, WINED3D_GL_EXT_NONE
},
5132 {0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE
},
5135 const struct StateEntryTemplate ffp_vertexstate_template
[] = {
5136 { STATE_VDECL
, { STATE_VDECL
, vertexdeclaration
}, WINED3D_GL_EXT_NONE
},
5137 { STATE_VSHADER
, { STATE_VDECL
, vertexdeclaration
}, WINED3D_GL_EXT_NONE
},
5138 { STATE_MATERIAL
, { STATE_RENDER(WINED3DRS_SPECULARENABLE
), state_specularenable
}, WINED3D_GL_EXT_NONE
},
5139 { STATE_RENDER(WINED3DRS_SPECULARENABLE
), { STATE_RENDER(WINED3DRS_SPECULARENABLE
), state_specularenable
}, WINED3D_GL_EXT_NONE
},
5141 { STATE_CLIPPLANE(0), { STATE_CLIPPLANE(0), clipplane
}, WINED3D_GL_EXT_NONE
},
5142 { STATE_CLIPPLANE(1), { STATE_CLIPPLANE(1), clipplane
}, WINED3D_GL_EXT_NONE
},
5143 { STATE_CLIPPLANE(2), { STATE_CLIPPLANE(2), clipplane
}, WINED3D_GL_EXT_NONE
},
5144 { STATE_CLIPPLANE(3), { STATE_CLIPPLANE(3), clipplane
}, WINED3D_GL_EXT_NONE
},
5145 { STATE_CLIPPLANE(4), { STATE_CLIPPLANE(4), clipplane
}, WINED3D_GL_EXT_NONE
},
5146 { STATE_CLIPPLANE(5), { STATE_CLIPPLANE(5), clipplane
}, WINED3D_GL_EXT_NONE
},
5147 { STATE_CLIPPLANE(6), { STATE_CLIPPLANE(6), clipplane
}, WINED3D_GL_EXT_NONE
},
5148 { STATE_CLIPPLANE(7), { STATE_CLIPPLANE(7), clipplane
}, WINED3D_GL_EXT_NONE
},
5149 { STATE_CLIPPLANE(8), { STATE_CLIPPLANE(8), clipplane
}, WINED3D_GL_EXT_NONE
},
5150 { STATE_CLIPPLANE(9), { STATE_CLIPPLANE(9), clipplane
}, WINED3D_GL_EXT_NONE
},
5151 { STATE_CLIPPLANE(10), { STATE_CLIPPLANE(10), clipplane
}, WINED3D_GL_EXT_NONE
},
5152 { STATE_CLIPPLANE(11), { STATE_CLIPPLANE(11), clipplane
}, WINED3D_GL_EXT_NONE
},
5153 { STATE_CLIPPLANE(12), { STATE_CLIPPLANE(12), clipplane
}, WINED3D_GL_EXT_NONE
},
5154 { STATE_CLIPPLANE(13), { STATE_CLIPPLANE(13), clipplane
}, WINED3D_GL_EXT_NONE
},
5155 { STATE_CLIPPLANE(14), { STATE_CLIPPLANE(14), clipplane
}, WINED3D_GL_EXT_NONE
},
5156 { STATE_CLIPPLANE(15), { STATE_CLIPPLANE(15), clipplane
}, WINED3D_GL_EXT_NONE
},
5157 { STATE_CLIPPLANE(16), { STATE_CLIPPLANE(16), clipplane
}, WINED3D_GL_EXT_NONE
},
5158 { STATE_CLIPPLANE(17), { STATE_CLIPPLANE(17), clipplane
}, WINED3D_GL_EXT_NONE
},
5159 { STATE_CLIPPLANE(18), { STATE_CLIPPLANE(18), clipplane
}, WINED3D_GL_EXT_NONE
},
5160 { STATE_CLIPPLANE(19), { STATE_CLIPPLANE(19), clipplane
}, WINED3D_GL_EXT_NONE
},
5161 { STATE_CLIPPLANE(20), { STATE_CLIPPLANE(20), clipplane
}, WINED3D_GL_EXT_NONE
},
5162 { STATE_CLIPPLANE(21), { STATE_CLIPPLANE(21), clipplane
}, WINED3D_GL_EXT_NONE
},
5163 { STATE_CLIPPLANE(22), { STATE_CLIPPLANE(22), clipplane
}, WINED3D_GL_EXT_NONE
},
5164 { STATE_CLIPPLANE(23), { STATE_CLIPPLANE(23), clipplane
}, WINED3D_GL_EXT_NONE
},
5165 { STATE_CLIPPLANE(24), { STATE_CLIPPLANE(24), clipplane
}, WINED3D_GL_EXT_NONE
},
5166 { STATE_CLIPPLANE(25), { STATE_CLIPPLANE(25), clipplane
}, WINED3D_GL_EXT_NONE
},
5167 { STATE_CLIPPLANE(26), { STATE_CLIPPLANE(26), clipplane
}, WINED3D_GL_EXT_NONE
},
5168 { STATE_CLIPPLANE(27), { STATE_CLIPPLANE(27), clipplane
}, WINED3D_GL_EXT_NONE
},
5169 { STATE_CLIPPLANE(28), { STATE_CLIPPLANE(28), clipplane
}, WINED3D_GL_EXT_NONE
},
5170 { STATE_CLIPPLANE(29), { STATE_CLIPPLANE(29), clipplane
}, WINED3D_GL_EXT_NONE
},
5171 { STATE_CLIPPLANE(30), { STATE_CLIPPLANE(30), clipplane
}, WINED3D_GL_EXT_NONE
},
5172 { STATE_CLIPPLANE(31), { STATE_CLIPPLANE(31), clipplane
}, WINED3D_GL_EXT_NONE
},
5174 { STATE_ACTIVELIGHT(0), { STATE_ACTIVELIGHT(0), light
}, WINED3D_GL_EXT_NONE
},
5175 { STATE_ACTIVELIGHT(1), { STATE_ACTIVELIGHT(1), light
}, WINED3D_GL_EXT_NONE
},
5176 { STATE_ACTIVELIGHT(2), { STATE_ACTIVELIGHT(2), light
}, WINED3D_GL_EXT_NONE
},
5177 { STATE_ACTIVELIGHT(3), { STATE_ACTIVELIGHT(3), light
}, WINED3D_GL_EXT_NONE
},
5178 { STATE_ACTIVELIGHT(4), { STATE_ACTIVELIGHT(4), light
}, WINED3D_GL_EXT_NONE
},
5179 { STATE_ACTIVELIGHT(5), { STATE_ACTIVELIGHT(5), light
}, WINED3D_GL_EXT_NONE
},
5180 { STATE_ACTIVELIGHT(6), { STATE_ACTIVELIGHT(6), light
}, WINED3D_GL_EXT_NONE
},
5181 { STATE_ACTIVELIGHT(7), { STATE_ACTIVELIGHT(7), light
}, WINED3D_GL_EXT_NONE
},
5183 { STATE_VIEWPORT
, { STATE_VIEWPORT
, viewport_vertexpart
}, WINED3D_GL_EXT_NONE
},
5184 /* Transform states follow */
5185 { STATE_TRANSFORM(WINED3DTS_VIEW
), { STATE_TRANSFORM(WINED3DTS_VIEW
), transform_view
}, WINED3D_GL_EXT_NONE
},
5186 { STATE_TRANSFORM(WINED3DTS_PROJECTION
), { STATE_TRANSFORM(WINED3DTS_PROJECTION
), transform_projection
}, WINED3D_GL_EXT_NONE
},
5187 { STATE_TRANSFORM(WINED3DTS_TEXTURE0
), { STATE_TEXTURESTAGE(0,WINED3DTSS_TEXTURETRANSFORMFLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5188 { STATE_TRANSFORM(WINED3DTS_TEXTURE1
), { STATE_TEXTURESTAGE(1,WINED3DTSS_TEXTURETRANSFORMFLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5189 { STATE_TRANSFORM(WINED3DTS_TEXTURE2
), { STATE_TEXTURESTAGE(2,WINED3DTSS_TEXTURETRANSFORMFLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5190 { STATE_TRANSFORM(WINED3DTS_TEXTURE3
), { STATE_TEXTURESTAGE(3,WINED3DTSS_TEXTURETRANSFORMFLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5191 { STATE_TRANSFORM(WINED3DTS_TEXTURE4
), { STATE_TEXTURESTAGE(4,WINED3DTSS_TEXTURETRANSFORMFLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5192 { STATE_TRANSFORM(WINED3DTS_TEXTURE5
), { STATE_TEXTURESTAGE(5,WINED3DTSS_TEXTURETRANSFORMFLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5193 { STATE_TRANSFORM(WINED3DTS_TEXTURE6
), { STATE_TEXTURESTAGE(6,WINED3DTSS_TEXTURETRANSFORMFLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5194 { STATE_TRANSFORM(WINED3DTS_TEXTURE7
), { STATE_TEXTURESTAGE(7,WINED3DTSS_TEXTURETRANSFORMFLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5195 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 0)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 0)), transform_world
}, WINED3D_GL_EXT_NONE
},
5196 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 1)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 1)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5197 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 2)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 2)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5198 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 3)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 3)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5199 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 4)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 4)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5200 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 5)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 5)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5201 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 6)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 6)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5202 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 7)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 7)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5203 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 8)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 8)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5204 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 9)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 9)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5205 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 10)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 10)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5206 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 11)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 11)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5207 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 12)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 12)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5208 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 13)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 13)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5209 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 14)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 14)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5210 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 15)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 15)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5211 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 16)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 16)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5212 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 17)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 17)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5213 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 18)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 18)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5214 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 19)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 19)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5215 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 20)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 20)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5216 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 21)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 21)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5217 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 22)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 22)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5218 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 23)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 23)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5219 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 24)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 24)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5220 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 25)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 25)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5221 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 26)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 26)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5222 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 27)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 27)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5223 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 28)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 28)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5224 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 29)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 29)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5225 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 30)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 30)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5226 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 31)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 31)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5227 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 32)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 32)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5228 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 33)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 33)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5229 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 34)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 34)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5230 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 35)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 35)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5231 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 36)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 36)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5232 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 37)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 37)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5233 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 38)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 38)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5234 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 39)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 39)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5235 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 40)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 40)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5236 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 41)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 41)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5237 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 42)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 42)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5238 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 43)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 43)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5239 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 44)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 44)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5240 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 45)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 45)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5241 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 46)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 46)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5242 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 47)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 47)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5243 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 48)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 48)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5244 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 49)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 49)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5245 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 50)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 50)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5246 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 51)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 51)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5247 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 52)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 52)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5248 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 53)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 53)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5249 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 54)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 54)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5250 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 55)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 55)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5251 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 56)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 56)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5252 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 57)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 57)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5253 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 58)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 58)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5254 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 59)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 59)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5255 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 60)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 60)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5256 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 61)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 61)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5257 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 62)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 62)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5258 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 63)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 63)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5259 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 64)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 64)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5260 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 65)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 65)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5261 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 66)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 66)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5262 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 67)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 67)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5263 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 68)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 68)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5264 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 69)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 69)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5265 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 70)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 70)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5266 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 71)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 71)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5267 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 72)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 72)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5268 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 73)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 73)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5269 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 74)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 74)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5270 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 75)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 75)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5271 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 76)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 76)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5272 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 77)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 77)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5273 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 78)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 78)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5274 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 79)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 79)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5275 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 80)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 80)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5276 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 81)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 81)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5277 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 82)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 82)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5278 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 83)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 83)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5279 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 84)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 84)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5280 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 85)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 85)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5281 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 86)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 86)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5282 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 87)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 87)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5283 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 88)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 88)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5284 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 89)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 89)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5285 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 90)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 90)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5286 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 91)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 91)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5287 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 92)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 92)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5288 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 93)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 93)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5289 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 94)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 94)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5290 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 95)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 95)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5291 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 96)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 96)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5292 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 97)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 97)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5293 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 98)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 98)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5294 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 99)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 99)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5295 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(100)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(100)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5296 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(101)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(101)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5297 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(102)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(102)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5298 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(103)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(103)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5299 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(104)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(104)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5300 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(105)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(105)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5301 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(106)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(106)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5302 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(107)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(107)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5303 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(108)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(108)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5304 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(109)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(109)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5305 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(110)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(110)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5306 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(111)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(111)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5307 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(112)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(112)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5308 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(113)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(113)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5309 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(114)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(114)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5310 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(115)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(115)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5311 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(116)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(116)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5312 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(117)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(117)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5313 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(118)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(118)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5314 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(119)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(119)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5315 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(120)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(120)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5316 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(121)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(121)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5317 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(122)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(122)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5318 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(123)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(123)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5319 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(124)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(124)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5320 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(125)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(125)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5321 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(126)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(126)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5322 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(127)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(127)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5323 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(128)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(128)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5324 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(129)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(129)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5325 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(130)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(130)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5326 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(131)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(131)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5327 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(132)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(132)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5328 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(133)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(133)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5329 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(134)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(134)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5330 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(135)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(135)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5331 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(136)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(136)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5332 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(137)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(137)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5333 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(138)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(138)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5334 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(139)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(139)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5335 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(140)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(140)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5336 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(141)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(141)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5337 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(142)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(142)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5338 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(143)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(143)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5339 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(144)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(144)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5340 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(145)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(145)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5341 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(146)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(146)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5342 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(147)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(147)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5343 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(148)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(148)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5344 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(149)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(149)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5345 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(150)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(150)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5346 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(151)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(151)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5347 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(152)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(152)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5348 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(153)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(153)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5349 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(154)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(154)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5350 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(155)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(155)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5351 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(156)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(156)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5352 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(157)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(157)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5353 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(158)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(158)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5354 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(159)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(159)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5355 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(160)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(160)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5356 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(161)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(161)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5357 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(162)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(162)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5358 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(163)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(163)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5359 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(164)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(164)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5360 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(165)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(165)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5361 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(166)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(166)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5362 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(167)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(167)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5363 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(168)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(168)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5364 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(169)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(169)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5365 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(170)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(170)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5366 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(171)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(171)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5367 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(172)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(172)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5368 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(173)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(173)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5369 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(174)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(174)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5370 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(175)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(175)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5371 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(176)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(176)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5372 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(177)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(177)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5373 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(178)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(178)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5374 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(179)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(179)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5375 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(180)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(180)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5376 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(181)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(181)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5377 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(182)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(182)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5378 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(183)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(183)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5379 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(184)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(184)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5380 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(185)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(185)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5381 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(186)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(186)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5382 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(187)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(187)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5383 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(188)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(188)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5384 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(189)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(189)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5385 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(190)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(190)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5386 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(191)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(191)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5387 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(192)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(192)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5388 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(193)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(193)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5389 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(194)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(194)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5390 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(195)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(195)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5391 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(196)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(196)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5392 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(197)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(197)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5393 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(198)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(198)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5394 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(199)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(199)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5395 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(200)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(200)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5396 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(201)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(201)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5397 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(202)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(202)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5398 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(203)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(203)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5399 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(204)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(204)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5400 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(205)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(205)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5401 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(206)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(206)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5402 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(207)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(207)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5403 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(208)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(208)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5404 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(209)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(209)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5405 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(210)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(210)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5406 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(211)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(211)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5407 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(212)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(212)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5408 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(213)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(213)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5409 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(214)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(214)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5410 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(215)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(215)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5411 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(216)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(216)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5412 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(217)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(217)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5413 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(218)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(218)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5414 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(219)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(219)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5415 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(220)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(220)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5416 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(221)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(221)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5417 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(222)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(222)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5418 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(223)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(223)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5419 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(224)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(224)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5420 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(225)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(225)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5421 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(226)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(226)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5422 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(227)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(227)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5423 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(228)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(228)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5424 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(229)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(229)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5425 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(230)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(230)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5426 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(231)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(231)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5427 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(232)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(232)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5428 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(233)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(233)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5429 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(234)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(234)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5430 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(235)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(235)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5431 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(236)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(236)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5432 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(237)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(237)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5433 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(238)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(238)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5434 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(239)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(239)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5435 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(240)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(240)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5436 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(241)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(241)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5437 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(242)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(242)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5438 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(243)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(243)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5439 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(244)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(244)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5440 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(245)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(245)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5441 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(246)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(246)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5442 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(247)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(247)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5443 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(248)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(248)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5444 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(249)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(249)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5445 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(250)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(250)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5446 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(251)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(251)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5447 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(252)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(252)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5448 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(253)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(253)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5449 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(254)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(254)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5450 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(255)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(255)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5451 { STATE_TEXTURESTAGE(0,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(0,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, WINED3D_GL_EXT_NONE
},
5452 { STATE_TEXTURESTAGE(1,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(1,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, WINED3D_GL_EXT_NONE
},
5453 { STATE_TEXTURESTAGE(2,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(2,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, WINED3D_GL_EXT_NONE
},
5454 { STATE_TEXTURESTAGE(3,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(3,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, WINED3D_GL_EXT_NONE
},
5455 { STATE_TEXTURESTAGE(4,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(4,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, WINED3D_GL_EXT_NONE
},
5456 { STATE_TEXTURESTAGE(5,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(5,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, WINED3D_GL_EXT_NONE
},
5457 { STATE_TEXTURESTAGE(6,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(6,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, WINED3D_GL_EXT_NONE
},
5458 { STATE_TEXTURESTAGE(7,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(7,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, WINED3D_GL_EXT_NONE
},
5459 { STATE_TEXTURESTAGE(0, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(0, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5460 { STATE_TEXTURESTAGE(1, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(1, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5461 { STATE_TEXTURESTAGE(2, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(2, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5462 { STATE_TEXTURESTAGE(3, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(3, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5463 { STATE_TEXTURESTAGE(4, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(4, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5464 { STATE_TEXTURESTAGE(5, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(5, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5465 { STATE_TEXTURESTAGE(6, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(6, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5466 { STATE_TEXTURESTAGE(7, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(7, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5468 { STATE_RENDER(WINED3DRS_FOGENABLE
), { STATE_RENDER(WINED3DRS_FOGENABLE
), state_fog_vertexpart
}, WINED3D_GL_EXT_NONE
},
5469 { STATE_RENDER(WINED3DRS_FOGTABLEMODE
), { STATE_RENDER(WINED3DRS_FOGENABLE
), state_fog_vertexpart
}, WINED3D_GL_EXT_NONE
},
5470 { STATE_RENDER(WINED3DRS_FOGVERTEXMODE
), { STATE_RENDER(WINED3DRS_FOGENABLE
), state_fog_vertexpart
}, WINED3D_GL_EXT_NONE
},
5471 { STATE_RENDER(WINED3DRS_RANGEFOGENABLE
), { STATE_RENDER(WINED3DRS_RANGEFOGENABLE
), state_rangefog
}, NV_FOG_DISTANCE
},
5472 { STATE_RENDER(WINED3DRS_RANGEFOGENABLE
), { STATE_RENDER(WINED3DRS_RANGEFOGENABLE
), state_rangefog_w
}, WINED3D_GL_EXT_NONE
},
5473 { STATE_RENDER(WINED3DRS_CLIPPING
), { STATE_RENDER(WINED3DRS_CLIPPING
), state_clipping
}, WINED3D_GL_EXT_NONE
},
5474 { STATE_RENDER(WINED3DRS_CLIPPLANEENABLE
), { STATE_RENDER(WINED3DRS_CLIPPING
), state_clipping
}, WINED3D_GL_EXT_NONE
},
5475 { STATE_RENDER(WINED3DRS_LIGHTING
), { STATE_RENDER(WINED3DRS_LIGHTING
), state_lighting
}, WINED3D_GL_EXT_NONE
},
5476 { STATE_RENDER(WINED3DRS_AMBIENT
), { STATE_RENDER(WINED3DRS_AMBIENT
), state_ambient
}, WINED3D_GL_EXT_NONE
},
5477 { STATE_RENDER(WINED3DRS_COLORVERTEX
), { STATE_RENDER(WINED3DRS_COLORVERTEX
), state_colormat
}, WINED3D_GL_EXT_NONE
},
5478 { STATE_RENDER(WINED3DRS_LOCALVIEWER
), { STATE_RENDER(WINED3DRS_LOCALVIEWER
), state_localviewer
}, WINED3D_GL_EXT_NONE
},
5479 { STATE_RENDER(WINED3DRS_NORMALIZENORMALS
), { STATE_RENDER(WINED3DRS_NORMALIZENORMALS
), state_normalize
}, WINED3D_GL_EXT_NONE
},
5480 { STATE_RENDER(WINED3DRS_DIFFUSEMATERIALSOURCE
), { STATE_RENDER(WINED3DRS_COLORVERTEX
), state_colormat
}, WINED3D_GL_EXT_NONE
},
5481 { STATE_RENDER(WINED3DRS_SPECULARMATERIALSOURCE
), { STATE_RENDER(WINED3DRS_COLORVERTEX
), state_colormat
}, WINED3D_GL_EXT_NONE
},
5482 { STATE_RENDER(WINED3DRS_AMBIENTMATERIALSOURCE
), { STATE_RENDER(WINED3DRS_COLORVERTEX
), state_colormat
}, WINED3D_GL_EXT_NONE
},
5483 { STATE_RENDER(WINED3DRS_EMISSIVEMATERIALSOURCE
), { STATE_RENDER(WINED3DRS_COLORVERTEX
), state_colormat
}, WINED3D_GL_EXT_NONE
},
5484 { STATE_RENDER(WINED3DRS_VERTEXBLEND
), { STATE_RENDER(WINED3DRS_VERTEXBLEND
), state_vertexblend
}, ARB_VERTEX_BLEND
},
5485 { STATE_RENDER(WINED3DRS_VERTEXBLEND
), { STATE_RENDER(WINED3DRS_VERTEXBLEND
), state_vertexblend_w
}, WINED3D_GL_EXT_NONE
},
5486 { STATE_RENDER(WINED3DRS_POINTSIZE
), { STATE_RENDER(WINED3DRS_POINTSCALEENABLE
), state_pscale
}, WINED3D_GL_EXT_NONE
},
5487 { STATE_RENDER(WINED3DRS_POINTSIZE_MIN
), { STATE_RENDER(WINED3DRS_POINTSIZE_MIN
), state_psizemin_arb
}, ARB_POINT_PARAMETERS
},
5488 { STATE_RENDER(WINED3DRS_POINTSIZE_MIN
), { STATE_RENDER(WINED3DRS_POINTSIZE_MIN
), state_psizemin_ext
}, EXT_POINT_PARAMETERS
},
5489 { STATE_RENDER(WINED3DRS_POINTSIZE_MIN
), { STATE_RENDER(WINED3DRS_POINTSIZE_MIN
), state_psizemin_w
}, WINED3D_GL_EXT_NONE
},
5490 { STATE_RENDER(WINED3DRS_POINTSPRITEENABLE
), { STATE_RENDER(WINED3DRS_POINTSPRITEENABLE
), state_pointsprite
}, ARB_POINT_SPRITE
},
5491 { STATE_RENDER(WINED3DRS_POINTSPRITEENABLE
), { STATE_RENDER(WINED3DRS_POINTSPRITEENABLE
), state_pointsprite_w
}, WINED3D_GL_EXT_NONE
},
5492 { STATE_RENDER(WINED3DRS_POINTSCALEENABLE
), { STATE_RENDER(WINED3DRS_POINTSCALEENABLE
), state_pscale
}, WINED3D_GL_EXT_NONE
},
5493 { STATE_RENDER(WINED3DRS_POINTSCALE_A
), { STATE_RENDER(WINED3DRS_POINTSCALEENABLE
), state_pscale
}, WINED3D_GL_EXT_NONE
},
5494 { STATE_RENDER(WINED3DRS_POINTSCALE_B
), { STATE_RENDER(WINED3DRS_POINTSCALEENABLE
), state_pscale
}, WINED3D_GL_EXT_NONE
},
5495 { STATE_RENDER(WINED3DRS_POINTSCALE_C
), { STATE_RENDER(WINED3DRS_POINTSCALEENABLE
), state_pscale
}, WINED3D_GL_EXT_NONE
},
5496 { STATE_RENDER(WINED3DRS_POINTSIZE_MAX
), { STATE_RENDER(WINED3DRS_POINTSIZE_MIN
), state_psizemin_arb
}, ARB_POINT_PARAMETERS
},
5497 { STATE_RENDER(WINED3DRS_POINTSIZE_MAX
), { STATE_RENDER(WINED3DRS_POINTSIZE_MIN
), state_psizemin_ext
}, EXT_POINT_PARAMETERS
},
5498 { STATE_RENDER(WINED3DRS_POINTSIZE_MAX
), { STATE_RENDER(WINED3DRS_POINTSIZE_MIN
), state_psizemin_w
}, WINED3D_GL_EXT_NONE
},
5499 /* Samplers for NP2 texture matrix adjustions. They are not needed if GL_ARB_texture_non_power_of_two is supported,
5500 * so register a NULL state handler in that case to get the vertex part of sampler() skipped(VTF is handled in the misc states.
5501 * otherwise, register sampler_texmatrix, which takes care of updating the texture matrix
5503 { STATE_SAMPLER(0), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5504 { STATE_SAMPLER(0), { 0, NULL
}, WINE_NORMALIZED_TEXRECT
},
5505 { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5506 { STATE_SAMPLER(1), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5507 { STATE_SAMPLER(1), { 0, NULL
}, WINE_NORMALIZED_TEXRECT
},
5508 { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5509 { STATE_SAMPLER(2), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5510 { STATE_SAMPLER(2), { 0, NULL
}, WINE_NORMALIZED_TEXRECT
},
5511 { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5512 { STATE_SAMPLER(3), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5513 { STATE_SAMPLER(3), { 0, NULL
}, WINE_NORMALIZED_TEXRECT
},
5514 { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5515 { STATE_SAMPLER(4), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5516 { STATE_SAMPLER(4), { 0, NULL
}, WINE_NORMALIZED_TEXRECT
},
5517 { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5518 { STATE_SAMPLER(5), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5519 { STATE_SAMPLER(5), { 0, NULL
}, WINE_NORMALIZED_TEXRECT
},
5520 { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5521 { STATE_SAMPLER(6), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5522 { STATE_SAMPLER(6), { 0, NULL
}, WINE_NORMALIZED_TEXRECT
},
5523 { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5524 { STATE_SAMPLER(7), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5525 { STATE_SAMPLER(7), { 0, NULL
}, WINE_NORMALIZED_TEXRECT
},
5526 { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5527 {0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE
},
5530 static const struct StateEntryTemplate ffp_fragmentstate_template
[] = {
5531 { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5532 { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5533 { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5534 { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5535 { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5536 { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5537 { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5538 { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5539 { STATE_TEXTURESTAGE(0, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5540 { STATE_TEXTURESTAGE(0, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl
}, WINED3D_GL_EXT_NONE
},
5541 { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5542 { STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5543 { STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5544 { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5545 { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5546 { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5547 { STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5548 { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5549 { STATE_TEXTURESTAGE(1, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5550 { STATE_TEXTURESTAGE(1, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl
}, WINED3D_GL_EXT_NONE
},
5551 { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5552 { STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5553 { STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5554 { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5555 { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5556 { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5557 { STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5558 { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5559 { STATE_TEXTURESTAGE(2, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5560 { STATE_TEXTURESTAGE(2, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl
}, WINED3D_GL_EXT_NONE
},
5561 { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5562 { STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5563 { STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5564 { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5565 { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5566 { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5567 { STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5568 { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5569 { STATE_TEXTURESTAGE(3, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5570 { STATE_TEXTURESTAGE(3, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl
}, WINED3D_GL_EXT_NONE
},
5571 { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5572 { STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5573 { STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5574 { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5575 { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5576 { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5577 { STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5578 { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5579 { STATE_TEXTURESTAGE(4, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5580 { STATE_TEXTURESTAGE(4, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl
}, WINED3D_GL_EXT_NONE
},
5581 { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5582 { STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5583 { STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5584 { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5585 { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5586 { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5587 { STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5588 { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5589 { STATE_TEXTURESTAGE(5, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5590 { STATE_TEXTURESTAGE(5, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl
}, WINED3D_GL_EXT_NONE
},
5591 { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5592 { STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5593 { STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5594 { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5595 { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5596 { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5597 { STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5598 { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5599 { STATE_TEXTURESTAGE(6, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5600 { STATE_TEXTURESTAGE(6, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl
}, WINED3D_GL_EXT_NONE
},
5601 { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5602 { STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5603 { STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5604 { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5605 { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5606 { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5607 { STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5608 { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5609 { STATE_TEXTURESTAGE(7, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5610 { STATE_TEXTURESTAGE(7, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl
}, WINED3D_GL_EXT_NONE
},
5611 { STATE_PIXELSHADER
, { STATE_PIXELSHADER
, apply_pixelshader
}, WINED3D_GL_EXT_NONE
},
5612 { STATE_RENDER(WINED3DRS_SRGBWRITEENABLE
), { STATE_PIXELSHADER
, apply_pixelshader
}, WINED3D_GL_EXT_NONE
},
5613 { STATE_RENDER(WINED3DRS_BORDERCOLOR
), { STATE_RENDER(WINED3DRS_BORDERCOLOR
), state_bordercolor
}, WINED3D_GL_EXT_NONE
},
5614 { STATE_RENDER(WINED3DRS_TEXTUREFACTOR
), { STATE_RENDER(WINED3DRS_TEXTUREFACTOR
), state_texfactor
}, WINED3D_GL_EXT_NONE
},
5615 { STATE_RENDER(WINED3DRS_FOGCOLOR
), { STATE_RENDER(WINED3DRS_FOGCOLOR
), state_fogcolor
}, WINED3D_GL_EXT_NONE
},
5616 { STATE_RENDER(WINED3DRS_FOGDENSITY
), { STATE_RENDER(WINED3DRS_FOGDENSITY
), state_fogdensity
}, WINED3D_GL_EXT_NONE
},
5617 { STATE_RENDER(WINED3DRS_FOGENABLE
), { STATE_RENDER(WINED3DRS_FOGENABLE
), state_fog_fragpart
}, WINED3D_GL_EXT_NONE
},
5618 { STATE_RENDER(WINED3DRS_FOGTABLEMODE
), { STATE_RENDER(WINED3DRS_FOGENABLE
), state_fog_fragpart
}, WINED3D_GL_EXT_NONE
},
5619 { STATE_RENDER(WINED3DRS_FOGVERTEXMODE
), { STATE_RENDER(WINED3DRS_FOGENABLE
), state_fog_fragpart
}, WINED3D_GL_EXT_NONE
},
5620 { STATE_RENDER(WINED3DRS_FOGSTART
), { STATE_RENDER(WINED3DRS_FOGSTART
), state_fogstartend
}, WINED3D_GL_EXT_NONE
},
5621 { STATE_RENDER(WINED3DRS_FOGEND
), { STATE_RENDER(WINED3DRS_FOGSTART
), state_fogstartend
}, WINED3D_GL_EXT_NONE
},
5622 { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5623 { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5624 { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5625 { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5626 { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5627 { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5628 { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5629 { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5630 {0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE
},
5632 #undef GLINFO_LOCATION
5634 /* Context activation is done by the caller. */
5635 static void ffp_enable(IWineD3DDevice
*iface
, BOOL enable
) { }
5637 static void ffp_fragment_get_caps(WINED3DDEVTYPE devtype
,
5638 const struct wined3d_gl_info
*gl_info
, struct fragment_caps
*pCaps
)
5640 pCaps
->TextureOpCaps
= WINED3DTEXOPCAPS_ADD
|
5641 WINED3DTEXOPCAPS_ADDSIGNED
|
5642 WINED3DTEXOPCAPS_ADDSIGNED2X
|
5643 WINED3DTEXOPCAPS_MODULATE
|
5644 WINED3DTEXOPCAPS_MODULATE2X
|
5645 WINED3DTEXOPCAPS_MODULATE4X
|
5646 WINED3DTEXOPCAPS_SELECTARG1
|
5647 WINED3DTEXOPCAPS_SELECTARG2
|
5648 WINED3DTEXOPCAPS_DISABLE
;
5650 if (gl_info
->supported
[ARB_TEXTURE_ENV_COMBINE
]
5651 || gl_info
->supported
[EXT_TEXTURE_ENV_COMBINE
]
5652 || gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
5654 pCaps
->TextureOpCaps
|= WINED3DTEXOPCAPS_BLENDDIFFUSEALPHA
|
5655 WINED3DTEXOPCAPS_BLENDTEXTUREALPHA
|
5656 WINED3DTEXOPCAPS_BLENDFACTORALPHA
|
5657 WINED3DTEXOPCAPS_BLENDCURRENTALPHA
|
5658 WINED3DTEXOPCAPS_LERP
|
5659 WINED3DTEXOPCAPS_SUBTRACT
;
5661 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
]
5662 || gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
5664 pCaps
->TextureOpCaps
|= WINED3DTEXOPCAPS_ADDSMOOTH
|
5665 WINED3DTEXOPCAPS_MULTIPLYADD
|
5666 WINED3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR
|
5667 WINED3DTEXOPCAPS_MODULATECOLOR_ADDALPHA
|
5668 WINED3DTEXOPCAPS_BLENDTEXTUREALPHAPM
;
5670 if (gl_info
->supported
[ARB_TEXTURE_ENV_DOT3
])
5671 pCaps
->TextureOpCaps
|= WINED3DTEXOPCAPS_DOTPRODUCT3
;
5673 pCaps
->MaxTextureBlendStages
= gl_info
->limits
.texture_stages
;
5674 pCaps
->MaxSimultaneousTextures
= gl_info
->limits
.textures
;
5677 static HRESULT
ffp_fragment_alloc(IWineD3DDevice
*iface
) { return WINED3D_OK
; }
5678 static void ffp_fragment_free(IWineD3DDevice
*iface
) {}
5679 static BOOL
ffp_color_fixup_supported(struct color_fixup_desc fixup
)
5683 TRACE("Checking support for fixup:\n");
5684 dump_color_fixup_desc(fixup
);
5687 /* We only support identity conversions. */
5688 if (is_identity_fixup(fixup
))
5694 TRACE("[FAILED]\n");
5698 const struct fragment_pipeline ffp_fragment_pipeline
= {
5700 ffp_fragment_get_caps
,
5703 ffp_color_fixup_supported
,
5704 ffp_fragmentstate_template
,
5705 FALSE
/* we cannot disable projected textures. The vertex pipe has to do it */
5708 static unsigned int num_handlers(const APPLYSTATEFUNC
*funcs
)
5711 for(i
= 0; funcs
[i
]; i
++);
5715 static void multistate_apply_2(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
5717 stateblock
->device
->multistate_funcs
[state
][0](state
, stateblock
, context
);
5718 stateblock
->device
->multistate_funcs
[state
][1](state
, stateblock
, context
);
5721 static void multistate_apply_3(DWORD state
, IWineD3DStateBlockImpl
*stateblock
, struct wined3d_context
*context
)
5723 stateblock
->device
->multistate_funcs
[state
][0](state
, stateblock
, context
);
5724 stateblock
->device
->multistate_funcs
[state
][1](state
, stateblock
, context
);
5725 stateblock
->device
->multistate_funcs
[state
][2](state
, stateblock
, context
);
5728 HRESULT
compile_state_table(struct StateEntry
*StateTable
, APPLYSTATEFUNC
**dev_multistate_funcs
,
5729 const struct wined3d_gl_info
*gl_info
, const struct StateEntryTemplate
*vertex
,
5730 const struct fragment_pipeline
*fragment
, const struct StateEntryTemplate
*misc
)
5732 unsigned int i
, type
, handlers
;
5733 APPLYSTATEFUNC multistate_funcs
[STATE_HIGHEST
+ 1][3];
5734 const struct StateEntryTemplate
*cur
;
5735 BOOL set
[STATE_HIGHEST
+ 1];
5737 memset(multistate_funcs
, 0, sizeof(multistate_funcs
));
5739 for(i
= 0; i
< STATE_HIGHEST
+ 1; i
++) {
5740 StateTable
[i
].representative
= 0;
5741 StateTable
[i
].apply
= state_undefined
;
5744 for(type
= 0; type
< 3; type
++) {
5745 /* This switch decides the order in which the states are applied */
5747 case 0: cur
= misc
; break;
5748 case 1: cur
= fragment
->states
; break;
5749 case 2: cur
= vertex
; break;
5750 default: cur
= NULL
; /* Stupid compiler */
5754 /* GL extension filtering should not prevent multiple handlers being applied from different
5757 memset(set
, 0, sizeof(set
));
5759 for(i
= 0; cur
[i
].state
; i
++) {
5760 APPLYSTATEFUNC
*funcs_array
;
5762 /* Only use the first matching state with the available extension from one template.
5764 * {D3DRS_FOOBAR, {D3DRS_FOOBAR, func1}, XYZ_FANCY},
5765 * {D3DRS_FOOBAR, {D3DRS_FOOBAR, func2}, 0 }
5767 * if GL_XYZ_fancy is supported, ignore the 2nd line
5769 if(set
[cur
[i
].state
]) continue;
5770 /* Skip state lines depending on unsupported extensions */
5771 if (!gl_info
->supported
[cur
[i
].extension
]) continue;
5772 set
[cur
[i
].state
] = TRUE
;
5773 /* In some cases having an extension means that nothing has to be
5774 * done for a state, e.g. if GL_ARB_texture_non_power_of_two is
5775 * supported, the texture coordinate fixup can be ignored. If the
5776 * apply function is used, mark the state set(done above) to prevent
5777 * applying later lines, but do not record anything in the state
5780 if(!cur
[i
].content
.apply
) continue;
5782 handlers
= num_handlers(multistate_funcs
[cur
[i
].state
]);
5783 multistate_funcs
[cur
[i
].state
][handlers
] = cur
[i
].content
.apply
;
5786 StateTable
[cur
[i
].state
].apply
= cur
[i
].content
.apply
;
5789 StateTable
[cur
[i
].state
].apply
= multistate_apply_2
;
5790 dev_multistate_funcs
[cur
[i
].state
] = HeapAlloc(GetProcessHeap(),
5792 sizeof(**dev_multistate_funcs
) * 2);
5793 if (!dev_multistate_funcs
[cur
[i
].state
]) {
5797 dev_multistate_funcs
[cur
[i
].state
][0] = multistate_funcs
[cur
[i
].state
][0];
5798 dev_multistate_funcs
[cur
[i
].state
][1] = multistate_funcs
[cur
[i
].state
][1];
5801 StateTable
[cur
[i
].state
].apply
= multistate_apply_3
;
5802 funcs_array
= HeapReAlloc(GetProcessHeap(),
5804 dev_multistate_funcs
[cur
[i
].state
],
5805 sizeof(**dev_multistate_funcs
) * 3);
5810 dev_multistate_funcs
[cur
[i
].state
] = funcs_array
;
5811 dev_multistate_funcs
[cur
[i
].state
][2] = multistate_funcs
[cur
[i
].state
][2];
5814 ERR("Unexpected amount of state handlers for state %u: %u\n",
5815 cur
[i
].state
, handlers
+ 1);
5818 if(StateTable
[cur
[i
].state
].representative
&&
5819 StateTable
[cur
[i
].state
].representative
!= cur
[i
].content
.representative
) {
5820 FIXME("State %u has different representatives in different pipeline parts\n",
5823 StateTable
[cur
[i
].state
].representative
= cur
[i
].content
.representative
;
5830 for (i
= 0; i
<= STATE_HIGHEST
; ++i
) {
5831 HeapFree(GetProcessHeap(), 0, dev_multistate_funcs
[i
]);
5834 memset(dev_multistate_funcs
, 0, (STATE_HIGHEST
+ 1)*sizeof(*dev_multistate_funcs
));
5836 return E_OUTOFMEMORY
;