blob: c8a315034a752e7555197fcbb43608f145586a40 [file] [log] [blame]
Stefan Dösingerc0268c72006-12-05 23:36:10 +01001/*
2 * Direct3D state management
3 *
Stefan Dösinger7fd246e2007-01-10 11:38:00 +01004 * Copyright 2002 Lionel Ulmer
5 * Copyright 2002-2005 Jason Edmeades
6 * Copyright 2003-2004 Raphael Junqueira
7 * Copyright 2004 Christian Costa
8 * Copyright 2005 Oliver Stieber
9 * Copyright 2006 Henri Verbeet
10 * Copyright 2006-2007 Stefan Dösinger for CodeWeavers
Stefan Dösingerc0268c72006-12-05 23:36:10 +010011 *
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
16 *
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 */
26
27#include "config.h"
28#include <stdio.h>
29#ifdef HAVE_FLOAT_H
30# include <float.h>
31#endif
32#include "wined3d_private.h"
33
34WINE_DEFAULT_DEBUG_CHANNEL(d3d);
Stefan Dösingerd5f18e62007-01-06 18:11:21 +010035WINE_DECLARE_DEBUG_CHANNEL(d3d_shader);
Stefan Dösingerc0268c72006-12-05 23:36:10 +010036
Stefan Dösingerac261722006-12-08 20:21:43 +010037#define GLINFO_LOCATION ((IWineD3DImpl *)(stateblock->wineD3DDevice->wineD3D))->gl_info
38
Stefan Dösingerc739c382007-02-12 19:18:22 +010039static void state_nogl(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger2a24e842006-12-06 13:22:12 +010040 /* Used for states which are not mapped to a gl state as-is, but used somehow different,
41 * e.g as a parameter for drawing, or which are unimplemented in windows d3d
42 */
43 if(STATE_IS_RENDER(state)) {
44 WINED3DRENDERSTATETYPE RenderState = state - STATE_RENDER(0);
45 TRACE("(%s,%d) no direct mapping to gl\n", debug_d3drenderstate(RenderState), stateblock->renderState[RenderState]);
46 } else {
47 /* Shouldn't have an unknown type here */
48 FIXME("%d no direct mapping to gl of state with unknown type\n", state);
49 }
50}
51
Stefan Dösingerc739c382007-02-12 19:18:22 +010052static void state_undefined(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger2a24e842006-12-06 13:22:12 +010053 /* Print a WARN, this allows the stateblock code to loop over all states to generate a display
54 * list without causing confusing terminal output. Deliberately no special debug name here
55 * because its undefined.
56 */
57 WARN("undefined state %d\n", state);
Stefan Dösingerc0268c72006-12-05 23:36:10 +010058}
59
Stefan Dösingerc739c382007-02-12 19:18:22 +010060static void state_fillmode(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
H. Verbeeta2fde7d2007-02-15 13:32:13 +010061 WINED3DFILLMODE Value = stateblock->renderState[WINED3DRS_FILLMODE];
Stefan Dösingerde963202006-12-05 23:45:35 +010062
63 switch(Value) {
H. Verbeeta2fde7d2007-02-15 13:32:13 +010064 case WINED3DFILL_POINT:
Stefan Dösingerde963202006-12-05 23:45:35 +010065 glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
66 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_POINT)");
67 break;
H. Verbeeta2fde7d2007-02-15 13:32:13 +010068 case WINED3DFILL_WIREFRAME:
Stefan Dösingerde963202006-12-05 23:45:35 +010069 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
70 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)");
71 break;
H. Verbeeta2fde7d2007-02-15 13:32:13 +010072 case WINED3DFILL_SOLID:
Stefan Dösingerde963202006-12-05 23:45:35 +010073 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
74 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)");
75 break;
76 default:
77 FIXME("Unrecognized WINED3DRS_FILLMODE value %d\n", Value);
78 }
79}
80
Stefan Dösingerc739c382007-02-12 19:18:22 +010081static void state_lighting(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger266fc772007-02-16 19:08:34 +010082 BOOL transformed;
Stefan Dösinger53e78892006-12-08 01:39:55 +010083
Stefan Dösinger266fc772007-02-16 19:08:34 +010084 /* Lighting is not enabled if transformed vertices are drawn
Stefan Dösingera0ff9822007-01-02 22:49:17 +010085 * but lighting does not affect the stream sources, so it is not grouped for performance reasons.
86 * This state reads the decoded vertex decl, so if it is dirty don't do anything. The
87 * vertex declaration appplying function calls this function for updating
Stefan Dösinger53e78892006-12-08 01:39:55 +010088 */
89
Stefan Dösinger380930d2007-02-12 19:18:31 +010090 if(isStateDirty(context, STATE_VDECL)) {
Stefan Dösingerfe6165d2007-01-10 11:37:03 +010091 return;
92 }
Stefan Dösingera0ff9822007-01-02 22:49:17 +010093
Stefan Dösinger266fc772007-02-16 19:08:34 +010094 transformed = ((stateblock->wineD3DDevice->strided_streams.u.s.position.lpData != NULL ||
95 stateblock->wineD3DDevice->strided_streams.u.s.position.VBO != 0) &&
96 stateblock->wineD3DDevice->strided_streams.u.s.position_transformed) ? TRUE : FALSE;
Stefan Dösingera0ff9822007-01-02 22:49:17 +010097
Stefan Dösinger266fc772007-02-16 19:08:34 +010098 if (stateblock->renderState[WINED3DRS_LIGHTING] && !transformed) {
Stefan Dösinger53e78892006-12-08 01:39:55 +010099 glEnable(GL_LIGHTING);
100 checkGLcall("glEnable GL_LIGHTING");
101 } else {
102 glDisable(GL_LIGHTING);
103 checkGLcall("glDisable GL_LIGHTING");
104 }
105}
106
Stefan Dösingerc739c382007-02-12 19:18:22 +0100107static void state_zenable(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger6886b232007-03-06 13:54:05 +0100108 /* No z test without depth stencil buffers */
109 if(stateblock->wineD3DDevice->stencilBufferTarget == NULL) {
110 glDisable(GL_DEPTH_TEST); /* This also disables z writing in gl */
111 checkGLcall("glDisable GL_DEPTH_TEST");
112 return;
113 }
114
Stefan Dösingerbb564dc2006-12-08 01:40:51 +0100115 switch ((WINED3DZBUFFERTYPE) stateblock->renderState[WINED3DRS_ZENABLE]) {
116 case WINED3DZB_FALSE:
117 glDisable(GL_DEPTH_TEST);
118 checkGLcall("glDisable GL_DEPTH_TEST");
119 break;
120 case WINED3DZB_TRUE:
121 glEnable(GL_DEPTH_TEST);
122 checkGLcall("glEnable GL_DEPTH_TEST");
123 break;
124 case WINED3DZB_USEW:
125 glEnable(GL_DEPTH_TEST);
126 checkGLcall("glEnable GL_DEPTH_TEST");
127 FIXME("W buffer is not well handled\n");
128 break;
129 default:
130 FIXME("Unrecognized D3DZBUFFERTYPE value %d\n", stateblock->renderState[WINED3DRS_ZENABLE]);
131 }
132}
133
Stefan Dösingerc739c382007-02-12 19:18:22 +0100134static void state_cullmode(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingere4b4c042006-12-08 01:41:43 +0100135 /* TODO: Put this into the offscreen / onscreen rendering block due to device->render_offscreen */
136
137 /* If we are culling "back faces with clockwise vertices" then
138 set front faces to be counter clockwise and enable culling
139 of back faces */
140 switch ((WINED3DCULL) stateblock->renderState[WINED3DRS_CULLMODE]) {
141 case WINED3DCULL_NONE:
142 glDisable(GL_CULL_FACE);
143 checkGLcall("glDisable GL_CULL_FACE");
144 break;
145 case WINED3DCULL_CW:
146 glEnable(GL_CULL_FACE);
147 checkGLcall("glEnable GL_CULL_FACE");
148 if (stateblock->wineD3DDevice->render_offscreen) {
149 glFrontFace(GL_CW);
150 checkGLcall("glFrontFace GL_CW");
151 } else {
152 glFrontFace(GL_CCW);
153 checkGLcall("glFrontFace GL_CCW");
154 }
155 glCullFace(GL_BACK);
156 break;
157 case WINED3DCULL_CCW:
158 glEnable(GL_CULL_FACE);
159 checkGLcall("glEnable GL_CULL_FACE");
160 if (stateblock->wineD3DDevice->render_offscreen) {
161 glFrontFace(GL_CCW);
162 checkGLcall("glFrontFace GL_CCW");
163 } else {
164 glFrontFace(GL_CW);
165 checkGLcall("glFrontFace GL_CW");
166 }
167 glCullFace(GL_BACK);
168 break;
169 default:
170 FIXME("Unrecognized/Unhandled WINED3DCULL value %d\n", stateblock->renderState[WINED3DRS_CULLMODE]);
171 }
172}
173
Stefan Dösingerc739c382007-02-12 19:18:22 +0100174static void state_shademode(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger68f10822006-12-08 01:42:16 +0100175 switch ((WINED3DSHADEMODE) stateblock->renderState[WINED3DRS_SHADEMODE]) {
176 case WINED3DSHADE_FLAT:
177 glShadeModel(GL_FLAT);
178 checkGLcall("glShadeModel(GL_FLAT)");
179 break;
180 case WINED3DSHADE_GOURAUD:
181 glShadeModel(GL_SMOOTH);
182 checkGLcall("glShadeModel(GL_SMOOTH)");
183 break;
184 case WINED3DSHADE_PHONG:
185 FIXME("WINED3DSHADE_PHONG isn't supported\n");
186 break;
187 default:
188 FIXME("Unrecognized/Unhandled WINED3DSHADEMODE value %d\n", stateblock->renderState[WINED3DRS_SHADEMODE]);
189 }
190}
191
Stefan Dösingerc739c382007-02-12 19:18:22 +0100192static void state_ditherenable(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingerbb622e82006-12-08 01:42:43 +0100193 if (stateblock->renderState[WINED3DRS_DITHERENABLE]) {
194 glEnable(GL_DITHER);
195 checkGLcall("glEnable GL_DITHER");
196 } else {
197 glDisable(GL_DITHER);
198 checkGLcall("glDisable GL_DITHER");
199 }
200}
201
Stefan Dösingerc739c382007-02-12 19:18:22 +0100202static void state_zwritenable(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger8879c7d2006-12-08 01:43:25 +0100203 /* TODO: Test if in d3d z writing is enabled even if ZENABLE is off. If yes,
204 * this has to be merged with ZENABLE and ZFUNC
205 */
206 if (stateblock->renderState[WINED3DRS_ZWRITEENABLE]) {
207 glDepthMask(1);
208 checkGLcall("glDepthMask(1)");
209 } else {
210 glDepthMask(0);
211 checkGLcall("glDepthMask(0)");
212 }
213}
214
Stefan Dösingerc739c382007-02-12 19:18:22 +0100215static void state_zfunc(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger2ac48e82006-12-08 01:44:55 +0100216 int glParm = CompareFunc(stateblock->renderState[WINED3DRS_ZFUNC]);
217
218 if(glParm) {
219 glDepthFunc(glParm);
220 checkGLcall("glDepthFunc");
221 }
222}
223
Stefan Dösingerc739c382007-02-12 19:18:22 +0100224static void state_ambient(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Alexandre Julliardbbfe1202006-12-29 11:35:57 +0100225 float col[4];
226 D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_AMBIENT], col);
Stefan Dösinger28cc3c82006-12-08 01:45:26 +0100227
Alexandre Julliardbbfe1202006-12-29 11:35:57 +0100228 TRACE("Setting ambient to (%f,%f,%f,%f)\n", col[0], col[1], col[2], col[3]);
229 glLightModelfv(GL_LIGHT_MODEL_AMBIENT, col);
Stefan Dösinger28cc3c82006-12-08 01:45:26 +0100230 checkGLcall("glLightModel for MODEL_AMBIENT");
231}
232
Stefan Dösingerc739c382007-02-12 19:18:22 +0100233static void state_blend(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger1f07e4a2006-12-08 01:51:11 +0100234 int srcBlend = GL_ZERO;
235 int dstBlend = GL_ZERO;
Stefan Dösinger1f07e4a2006-12-08 01:51:11 +0100236
237 /* GL_LINE_SMOOTH needs GL_BLEND to work, according to the red book, and special blending params */
Stefan Dösinger1f07e4a2006-12-08 01:51:11 +0100238 if (stateblock->renderState[WINED3DRS_ALPHABLENDENABLE] ||
239 stateblock->renderState[WINED3DRS_EDGEANTIALIAS] ||
Stefan Dösingerd6245402006-12-25 18:46:59 +0100240 stateblock->renderState[WINED3DRS_ANTIALIASEDLINEENABLE]) {
Stefan Dösinger1f07e4a2006-12-08 01:51:11 +0100241 glEnable(GL_BLEND);
242 checkGLcall("glEnable GL_BLEND");
243 } else {
244 glDisable(GL_BLEND);
245 checkGLcall("glDisable GL_BLEND");
246 /* Nothing more to do - get out */
247 return;
248 };
249
250 switch (stateblock->renderState[WINED3DRS_SRCBLEND]) {
251 case WINED3DBLEND_ZERO : srcBlend = GL_ZERO; break;
252 case WINED3DBLEND_ONE : srcBlend = GL_ONE; break;
253 case WINED3DBLEND_SRCCOLOR : srcBlend = GL_SRC_COLOR; break;
254 case WINED3DBLEND_INVSRCCOLOR : srcBlend = GL_ONE_MINUS_SRC_COLOR; break;
255 case WINED3DBLEND_SRCALPHA : srcBlend = GL_SRC_ALPHA; break;
256 case WINED3DBLEND_INVSRCALPHA : srcBlend = GL_ONE_MINUS_SRC_ALPHA; break;
257 case WINED3DBLEND_DESTALPHA : srcBlend = GL_DST_ALPHA; break;
258 case WINED3DBLEND_INVDESTALPHA : srcBlend = GL_ONE_MINUS_DST_ALPHA; break;
259 case WINED3DBLEND_DESTCOLOR : srcBlend = GL_DST_COLOR; break;
260 case WINED3DBLEND_INVDESTCOLOR : srcBlend = GL_ONE_MINUS_DST_COLOR; break;
261 case WINED3DBLEND_SRCALPHASAT : srcBlend = GL_SRC_ALPHA_SATURATE; break;
262
263 case WINED3DBLEND_BOTHSRCALPHA : srcBlend = GL_SRC_ALPHA;
264 dstBlend = GL_SRC_ALPHA;
265 break;
266
267 case WINED3DBLEND_BOTHINVSRCALPHA : srcBlend = GL_ONE_MINUS_SRC_ALPHA;
268 dstBlend = GL_ONE_MINUS_SRC_ALPHA;
269 break;
270
271 case WINED3DBLEND_BLENDFACTOR : srcBlend = GL_CONSTANT_COLOR; break;
272 case WINED3DBLEND_INVBLENDFACTOR : srcBlend = GL_ONE_MINUS_CONSTANT_COLOR; break;
273 default:
274 FIXME("Unrecognized src blend value %d\n", stateblock->renderState[WINED3DRS_SRCBLEND]);
275 }
276
277 switch (stateblock->renderState[WINED3DRS_DESTBLEND]) {
278 case WINED3DBLEND_ZERO : dstBlend = GL_ZERO; break;
279 case WINED3DBLEND_ONE : dstBlend = GL_ONE; break;
280 case WINED3DBLEND_SRCCOLOR : dstBlend = GL_SRC_COLOR; break;
281 case WINED3DBLEND_INVSRCCOLOR : dstBlend = GL_ONE_MINUS_SRC_COLOR; break;
282 case WINED3DBLEND_SRCALPHA : dstBlend = GL_SRC_ALPHA; break;
283 case WINED3DBLEND_INVSRCALPHA : dstBlend = GL_ONE_MINUS_SRC_ALPHA; break;
284 case WINED3DBLEND_DESTALPHA : dstBlend = GL_DST_ALPHA; break;
285 case WINED3DBLEND_INVDESTALPHA : dstBlend = GL_ONE_MINUS_DST_ALPHA; break;
286 case WINED3DBLEND_DESTCOLOR : dstBlend = GL_DST_COLOR; break;
287 case WINED3DBLEND_INVDESTCOLOR : dstBlend = GL_ONE_MINUS_DST_COLOR; break;
288 case WINED3DBLEND_SRCALPHASAT : dstBlend = GL_SRC_ALPHA_SATURATE; break;
289
290 case WINED3DBLEND_BOTHSRCALPHA : dstBlend = GL_SRC_ALPHA;
291 srcBlend = GL_SRC_ALPHA;
292 break;
293
294 case WINED3DBLEND_BOTHINVSRCALPHA : dstBlend = GL_ONE_MINUS_SRC_ALPHA;
295 srcBlend = GL_ONE_MINUS_SRC_ALPHA;
296 break;
297
H. Verbeeta2fde7d2007-02-15 13:32:13 +0100298 case WINED3DBLEND_BLENDFACTOR : dstBlend = GL_CONSTANT_COLOR; break;
299 case WINED3DBLEND_INVBLENDFACTOR : dstBlend = GL_ONE_MINUS_CONSTANT_COLOR; break;
Stefan Dösinger1f07e4a2006-12-08 01:51:11 +0100300 default:
301 FIXME("Unrecognized dst blend value %d\n", stateblock->renderState[WINED3DRS_DESTBLEND]);
302 }
303
304 if(stateblock->renderState[WINED3DRS_EDGEANTIALIAS] ||
305 stateblock->renderState[WINED3DRS_ANTIALIASEDLINEENABLE]) {
306 glEnable(GL_LINE_SMOOTH);
307 checkGLcall("glEnable(GL_LINE_SMOOTH)");
308 if(srcBlend != GL_SRC_ALPHA) {
309 FIXME("WINED3DRS_EDGEANTIALIAS enabled, but incompatible src blending param - what to do?\n");
310 srcBlend = GL_SRC_ALPHA;
311 }
312 if(dstBlend != GL_ONE_MINUS_SRC_ALPHA) {
313 FIXME("WINED3DRS_EDGEANTIALIAS enabled, but incompatible dst blending param - what to do?\n");
314 dstBlend = GL_ONE_MINUS_SRC_ALPHA;
315 }
316 } else {
317 glDisable(GL_LINE_SMOOTH);
318 checkGLcall("glDisable(GL_LINE_SMOOTH)");
319 }
320
321 TRACE("glBlendFunc src=%x, dst=%x\n", srcBlend, dstBlend);
322 glBlendFunc(srcBlend, dstBlend);
323 checkGLcall("glBlendFunc");
Stefan Dösingerd6245402006-12-25 18:46:59 +0100324}
325
Stefan Dösingerc739c382007-02-12 19:18:22 +0100326static void state_blendfactor(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingerd6245402006-12-25 18:46:59 +0100327 float col[4];
Stefan Dösinger1f07e4a2006-12-08 01:51:11 +0100328
329 TRACE("Setting BlendFactor to %d\n", stateblock->renderState[WINED3DRS_BLENDFACTOR]);
330 D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_BLENDFACTOR], col);
331 glBlendColor (col[0],col[1],col[2],col[3]);
332 checkGLcall("glBlendColor");
333}
334
Stefan Dösingerc739c382007-02-12 19:18:22 +0100335static void state_alpha(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingerc88efee2006-12-08 20:21:32 +0100336 int glParm = 0;
337 float ref;
338 BOOL enable_ckey = FALSE;
339
340 IWineD3DSurfaceImpl *surf;
341
342 /* Find out if the texture on the first stage has a ckey set
343 * The alpha state func reads the texture settings, even though alpha and texture are not grouped
344 * together. This is to avoid making a huge alpha+texture+texture stage+ckey block due to the hardly
345 * used WINED3DRS_COLORKEYENABLE state(which is d3d <= 3 only). The texture function will call alpha
346 * in case it finds some texture+colorkeyenable combination which needs extra care.
347 */
Stefan Dösingerd4c4e5d2007-02-15 03:05:54 +0100348 if(stateblock->textures[0] && stateblock->textureDimensions[0] == GL_TEXTURE_2D) {
Stefan Dösingerc88efee2006-12-08 20:21:32 +0100349 surf = (IWineD3DSurfaceImpl *) ((IWineD3DTextureImpl *)stateblock->textures[0])->surfaces[0];
Stefan Dösingerd4c4e5d2007-02-15 03:05:54 +0100350
Stefan Dösinger725057d2007-04-14 22:44:55 +0200351 if(surf->CKeyFlags & WINEDDSD_CKSRCBLT) {
Stefan Dösingerd4c4e5d2007-02-15 03:05:54 +0100352 const PixelFormatDesc *fmt = getFormatDescEntry(surf->resource.format);
353 /* The surface conversion does not do color keying conversion for surfaces that have an alpha
354 * channel on their own. Likewise, the alpha test shouldn't be set up for color keying if the
355 * surface has alpha bits
356 */
357 if(fmt->alphaMask == 0x00000000) {
358 enable_ckey = TRUE;
359 }
360 }
Stefan Dösingerc88efee2006-12-08 20:21:32 +0100361 }
362
Stefan Dösingerb3f96f42007-02-15 03:04:18 +0100363 if(enable_ckey || context->last_was_ckey) {
364 StateTable[STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP)].apply(STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), stateblock, context);
365 }
366 context->last_was_ckey = enable_ckey;
367
Stefan Dösingerc88efee2006-12-08 20:21:32 +0100368 if (stateblock->renderState[WINED3DRS_ALPHATESTENABLE] ||
369 (stateblock->renderState[WINED3DRS_COLORKEYENABLE] && enable_ckey)) {
370 glEnable(GL_ALPHA_TEST);
371 checkGLcall("glEnable GL_ALPHA_TEST");
372 } else {
373 glDisable(GL_ALPHA_TEST);
374 checkGLcall("glDisable GL_ALPHA_TEST");
375 /* Alpha test is disabled, don't bother setting the params - it will happen on the next
376 * enable call
377 */
378 return;
379 }
380
381 if(stateblock->renderState[WINED3DRS_COLORKEYENABLE] && enable_ckey) {
382 glParm = GL_NOTEQUAL;
383 ref = 0.0;
384 } else {
385 ref = ((float) stateblock->renderState[WINED3DRS_ALPHAREF]) / 255.0f;
386 glParm = CompareFunc(stateblock->renderState[WINED3DRS_ALPHAFUNC]);
387 }
388 if(glParm) {
Stefan Dösingerc88efee2006-12-08 20:21:32 +0100389 glAlphaFunc(glParm, ref);
390 checkGLcall("glAlphaFunc");
391 }
Stefan Dösingerc88efee2006-12-08 20:21:32 +0100392}
393
Stefan Dösingerc739c382007-02-12 19:18:22 +0100394static void state_clipping(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger89e999a2006-12-08 18:01:23 +0100395 DWORD enable = 0xFFFFFFFF;
396 DWORD disable = 0x00000000;
397
H. Verbeet30ee0712007-03-12 23:22:00 +0100398 if (use_vs(stateblock->wineD3DDevice)) {
Stefan Dösinger5afbfd02007-02-27 23:11:15 +0100399 /* The spec says that opengl clipping planes are disabled when using shaders. Direct3D planes aren't,
400 * so that is an issue. The MacOS ATI driver keeps clipping planes activated with shaders in some
401 * contitions I got sick of tracking down. The shader state handler disables all clip planes because
402 * of that - don't do anything here and keep them disabled
403 */
404 if(stateblock->renderState[WINED3DRS_CLIPPLANEENABLE]) {
405 static BOOL warned = FALSE;
406 if(!warned) {
407 FIXME("Clipping not supported with vertex shaders\n");
408 warned = TRUE;
409 }
410 }
411 return;
412 }
413
Stefan Dösinger89e999a2006-12-08 18:01:23 +0100414 /* TODO: Keep track of previously enabled clipplanes to avoid unneccessary resetting
415 * of already set values
416 */
417
418 /* If enabling / disabling all
419 * TODO: Is this correct? Doesn't D3DRS_CLIPPING disable clipping on the viewport frustrum?
420 */
421 if (stateblock->renderState[WINED3DRS_CLIPPING]) {
422 enable = stateblock->renderState[WINED3DRS_CLIPPLANEENABLE];
423 disable = ~stateblock->renderState[WINED3DRS_CLIPPLANEENABLE];
424 } else {
425 disable = 0xffffffff;
426 enable = 0x00;
427 }
428
429 if (enable & WINED3DCLIPPLANE0) { glEnable(GL_CLIP_PLANE0); checkGLcall("glEnable(clip plane 0)"); }
430 if (enable & WINED3DCLIPPLANE1) { glEnable(GL_CLIP_PLANE1); checkGLcall("glEnable(clip plane 1)"); }
431 if (enable & WINED3DCLIPPLANE2) { glEnable(GL_CLIP_PLANE2); checkGLcall("glEnable(clip plane 2)"); }
432 if (enable & WINED3DCLIPPLANE3) { glEnable(GL_CLIP_PLANE3); checkGLcall("glEnable(clip plane 3)"); }
433 if (enable & WINED3DCLIPPLANE4) { glEnable(GL_CLIP_PLANE4); checkGLcall("glEnable(clip plane 4)"); }
434 if (enable & WINED3DCLIPPLANE5) { glEnable(GL_CLIP_PLANE5); checkGLcall("glEnable(clip plane 5)"); }
435
436 if (disable & WINED3DCLIPPLANE0) { glDisable(GL_CLIP_PLANE0); checkGLcall("glDisable(clip plane 0)"); }
437 if (disable & WINED3DCLIPPLANE1) { glDisable(GL_CLIP_PLANE1); checkGLcall("glDisable(clip plane 1)"); }
438 if (disable & WINED3DCLIPPLANE2) { glDisable(GL_CLIP_PLANE2); checkGLcall("glDisable(clip plane 2)"); }
439 if (disable & WINED3DCLIPPLANE3) { glDisable(GL_CLIP_PLANE3); checkGLcall("glDisable(clip plane 3)"); }
440 if (disable & WINED3DCLIPPLANE4) { glDisable(GL_CLIP_PLANE4); checkGLcall("glDisable(clip plane 4)"); }
441 if (disable & WINED3DCLIPPLANE5) { glDisable(GL_CLIP_PLANE5); checkGLcall("glDisable(clip plane 5)"); }
442
443 /** update clipping status */
444 if (enable) {
445 stateblock->clip_status.ClipUnion = 0;
446 stateblock->clip_status.ClipIntersection = 0xFFFFFFFF;
447 } else {
448 stateblock->clip_status.ClipUnion = 0;
449 stateblock->clip_status.ClipIntersection = 0;
450 }
451}
452
Stefan Dösingerc739c382007-02-12 19:18:22 +0100453static void state_blendop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingerac261722006-12-08 20:21:43 +0100454 int glParm = GL_FUNC_ADD;
455
456 if(!GL_SUPPORT(EXT_BLEND_MINMAX)) {
457 WARN("Unsupported in local OpenGL implementation: glBlendEquation\n");
458 return;
459 }
460
461 switch ((WINED3DBLENDOP) stateblock->renderState[WINED3DRS_BLENDOP]) {
462 case WINED3DBLENDOP_ADD : glParm = GL_FUNC_ADD; break;
463 case WINED3DBLENDOP_SUBTRACT : glParm = GL_FUNC_SUBTRACT; break;
464 case WINED3DBLENDOP_REVSUBTRACT : glParm = GL_FUNC_REVERSE_SUBTRACT; break;
465 case WINED3DBLENDOP_MIN : glParm = GL_MIN; break;
466 case WINED3DBLENDOP_MAX : glParm = GL_MAX; break;
467 default:
468 FIXME("Unrecognized/Unhandled D3DBLENDOP value %d\n", stateblock->renderState[WINED3DRS_BLENDOP]);
469 }
470
471 TRACE("glBlendEquation(%x)\n", glParm);
472 GL_EXTCALL(glBlendEquation(glParm));
473 checkGLcall("glBlendEquation");
474}
475
Stefan Dösinger0772bb42006-12-08 18:38:30 +0100476static void
Stefan Dösingerc739c382007-02-12 19:18:22 +0100477state_specularenable(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger0772bb42006-12-08 18:38:30 +0100478 /* Originally this used glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR)
479 * and (GL_LIGHT_MODEL_COLOR_CONTROL,GL_SINGLE_COLOR) to swap between enabled/disabled
480 * specular color. This is wrong:
481 * Separate specular color means the specular colour is maintained separately, whereas
482 * single color means it is merged in. However in both cases they are being used to
483 * some extent.
484 * To disable specular color, set it explicitly to black and turn off GL_COLOR_SUM_EXT
485 * NOTE: If not supported don't give FIXMEs the impact is really minimal and very few people are
486 * running 1.4 yet!
487 *
488 *
489 * If register combiners are enabled, enabling / disabling GL_COLOR_SUM has no effect.
490 * Instead, we need to setup the FinalCombiner properly.
491 *
492 * The default setup for the FinalCombiner is:
493 *
494 * <variable> <input> <mapping> <usage>
495 * GL_VARIABLE_A_NV GL_FOG, GL_UNSIGNED_IDENTITY_NV GL_ALPHA
496 * GL_VARIABLE_B_NV GL_SPARE0_PLUS_SECONDARY_COLOR_NV GL_UNSIGNED_IDENTITY_NV GL_RGB
497 * GL_VARIABLE_C_NV GL_FOG GL_UNSIGNED_IDENTITY_NV GL_RGB
498 * GL_VARIABLE_D_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
499 * GL_VARIABLE_E_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
500 * GL_VARIABLE_F_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
501 * GL_VARIABLE_G_NV GL_SPARE0_NV GL_UNSIGNED_IDENTITY_NV GL_ALPHA
502 *
503 * That's pretty much fine as it is, except for variable B, which needs to take
504 * either GL_SPARE0_PLUS_SECONDARY_COLOR_NV or GL_SPARE0_NV, depending on
505 * whether WINED3DRS_SPECULARENABLE is enabled or not.
506 */
507
508 TRACE("Setting specular enable state\n");
509 /* TODO: Add to the material setting functions */
510 if (stateblock->renderState[WINED3DRS_SPECULARENABLE]) {
511 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float*) &stateblock->material.Specular);
512 checkGLcall("glMaterialfv");
513 if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
514 glEnable(GL_COLOR_SUM_EXT);
515 } else {
516 TRACE("Specular colors cannot be enabled in this version of opengl\n");
517 }
518 checkGLcall("glEnable(GL_COLOR_SUM)");
519
520 if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
521 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_SPARE0_PLUS_SECONDARY_COLOR_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB));
522 checkGLcall("glFinalCombinerInputNV()");
523 }
524 } else {
525 float black[4] = {0.0f, 0.0f, 0.0f, 0.0f};
526
527 /* for the case of enabled lighting: */
528 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, &black[0]);
529 checkGLcall("glMaterialfv");
530
531 /* for the case of disabled lighting: */
532 if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
533 glDisable(GL_COLOR_SUM_EXT);
534 } else {
535 TRACE("Specular colors cannot be disabled in this version of opengl\n");
536 }
537 checkGLcall("glDisable(GL_COLOR_SUM)");
538
539 if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
540 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB));
541 checkGLcall("glFinalCombinerInputNV()");
542 }
543 }
544}
545
Stefan Dösingerc739c382007-02-12 19:18:22 +0100546static void state_texfactor(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger287c6242006-12-08 18:37:17 +0100547 unsigned int i;
548
549 /* Note the texture color applies to all textures whereas
550 * GL_TEXTURE_ENV_COLOR applies to active only
551 */
Alexandre Julliardbbfe1202006-12-29 11:35:57 +0100552 float col[4];
553 D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_TEXTUREFACTOR], col);
Stefan Dösinger287c6242006-12-08 18:37:17 +0100554
555 if (!GL_SUPPORT(NV_REGISTER_COMBINERS)) {
556 /* And now the default texture color as well */
557 for (i = 0; i < GL_LIMITS(texture_stages); i++) {
558 /* Note the WINED3DRS value applies to all textures, but GL has one
559 * per texture, so apply it now ready to be used!
560 */
561 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
562 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + i));
563 checkGLcall("glActiveTextureARB");
564 } else if (i>0) {
565 FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
566 }
567
Alexandre Julliardbbfe1202006-12-29 11:35:57 +0100568 glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &col[0]);
Stefan Dösinger287c6242006-12-08 18:37:17 +0100569 checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);");
570 }
Stefan Dösinger666b5072006-12-19 23:26:39 +0100571 } else {
Alexandre Julliardbbfe1202006-12-29 11:35:57 +0100572 GL_EXTCALL(glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV, &col[0]));
Stefan Dösinger287c6242006-12-08 18:37:17 +0100573 }
574}
575
Stefan Dösinger0d9ae202006-12-08 18:39:45 +0100576static void
577renderstate_stencil_twosided(IWineD3DStateBlockImpl *stateblock, GLint face, GLint func, GLint ref, GLuint mask, GLint stencilFail, GLint depthFail, GLint stencilPass ) {
578#if 0 /* Don't use OpenGL 2.0 calls for now */
579 if(GL_EXTCALL(glStencilFuncSeparate) && GL_EXTCALL(glStencilOpSeparate)) {
580 GL_EXTCALL(glStencilFuncSeparate(face, func, ref, mask));
581 checkGLcall("glStencilFuncSeparate(...)");
582 GL_EXTCALL(glStencilOpSeparate(face, stencilFail, depthFail, stencilPass));
583 checkGLcall("glStencilOpSeparate(...)");
584 }
585 else
586#endif
587 if(GL_SUPPORT(EXT_STENCIL_TWO_SIDE)) {
588 glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT);
589 checkGLcall("glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT)");
590 GL_EXTCALL(glActiveStencilFaceEXT(face));
591 checkGLcall("glActiveStencilFaceEXT(...)");
592 glStencilFunc(func, ref, mask);
593 checkGLcall("glStencilFunc(...)");
594 glStencilOp(stencilFail, depthFail, stencilPass);
595 checkGLcall("glStencilOp(...)");
596 } else if(GL_SUPPORT(ATI_SEPARATE_STENCIL)) {
597 GL_EXTCALL(glStencilFuncSeparateATI(face, func, ref, mask));
598 checkGLcall("glStencilFuncSeparateATI(...)");
599 GL_EXTCALL(glStencilOpSeparateATI(face, stencilFail, depthFail, stencilPass));
600 checkGLcall("glStencilOpSeparateATI(...)");
601 } else {
602 ERR("Separate (two sided) stencil not supported on this version of opengl. Caps weren't honored?\n");
603 }
604}
605
606static void
Stefan Dösingerc739c382007-02-12 19:18:22 +0100607state_stencil(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger0d9ae202006-12-08 18:39:45 +0100608 DWORD onesided_enable = FALSE;
609 DWORD twosided_enable = FALSE;
610 GLint func = GL_ALWAYS;
611 GLint func_ccw = GL_ALWAYS;
612 GLint ref = 0;
613 GLuint mask = 0;
614 GLint stencilFail = GL_KEEP;
615 GLint depthFail = GL_KEEP;
616 GLint stencilPass = GL_KEEP;
617 GLint stencilFail_ccw = GL_KEEP;
618 GLint depthFail_ccw = GL_KEEP;
619 GLint stencilPass_ccw = GL_KEEP;
620
Stefan Dösinger6886b232007-03-06 13:54:05 +0100621 /* No stencil test without a stencil buffer */
622 if(stateblock->wineD3DDevice->stencilBufferTarget == NULL) {
623 glDisable(GL_STENCIL_TEST);
624 checkGLcall("glDisable GL_STENCIL_TEST");
625 return;
626 }
627
Stefan Dösinger0d9ae202006-12-08 18:39:45 +0100628 if( stateblock->set.renderState[WINED3DRS_STENCILENABLE] )
629 onesided_enable = stateblock->renderState[WINED3DRS_STENCILENABLE];
630 if( stateblock->set.renderState[WINED3DRS_TWOSIDEDSTENCILMODE] )
631 twosided_enable = stateblock->renderState[WINED3DRS_TWOSIDEDSTENCILMODE];
632 if( stateblock->set.renderState[WINED3DRS_STENCILFUNC] )
633 if( !( func = CompareFunc(stateblock->renderState[WINED3DRS_STENCILFUNC]) ) )
634 func = GL_ALWAYS;
635 if( stateblock->set.renderState[WINED3DRS_CCW_STENCILFUNC] )
636 if( !( func_ccw = CompareFunc(stateblock->renderState[WINED3DRS_CCW_STENCILFUNC]) ) )
637 func = GL_ALWAYS;
638 if( stateblock->set.renderState[WINED3DRS_STENCILREF] )
639 ref = stateblock->renderState[WINED3DRS_STENCILREF];
640 if( stateblock->set.renderState[WINED3DRS_STENCILMASK] )
641 mask = stateblock->renderState[WINED3DRS_STENCILMASK];
642 if( stateblock->set.renderState[WINED3DRS_STENCILFAIL] )
643 stencilFail = StencilOp(stateblock->renderState[WINED3DRS_STENCILFAIL]);
644 if( stateblock->set.renderState[WINED3DRS_STENCILZFAIL] )
645 depthFail = StencilOp(stateblock->renderState[WINED3DRS_STENCILZFAIL]);
646 if( stateblock->set.renderState[WINED3DRS_STENCILPASS] )
647 stencilPass = StencilOp(stateblock->renderState[WINED3DRS_STENCILPASS]);
648 if( stateblock->set.renderState[WINED3DRS_CCW_STENCILFAIL] )
649 stencilFail_ccw = StencilOp(stateblock->renderState[WINED3DRS_CCW_STENCILFAIL]);
650 if( stateblock->set.renderState[WINED3DRS_CCW_STENCILZFAIL] )
651 depthFail_ccw = StencilOp(stateblock->renderState[WINED3DRS_CCW_STENCILZFAIL]);
652 if( stateblock->set.renderState[WINED3DRS_CCW_STENCILPASS] )
653 stencilPass_ccw = StencilOp(stateblock->renderState[WINED3DRS_CCW_STENCILPASS]);
654
Michael Stefaniuc33af3c52007-01-09 23:42:26 +0100655 TRACE("(onesided %d, twosided %d, ref %x, mask %x, "
656 "GL_FRONT: func: %x, fail %x, zfail %x, zpass %x "
657 "GL_BACK: func: %x, fail %x, zfail %x, zpass %x )\n",
Stefan Dösinger0d9ae202006-12-08 18:39:45 +0100658 onesided_enable, twosided_enable, ref, mask,
659 func, stencilFail, depthFail, stencilPass,
660 func_ccw, stencilFail_ccw, depthFail_ccw, stencilPass_ccw);
661
662 if (twosided_enable) {
663 renderstate_stencil_twosided(stateblock, GL_FRONT, func, ref, mask, stencilFail, depthFail, stencilPass);
664 renderstate_stencil_twosided(stateblock, GL_BACK, func_ccw, ref, mask, stencilFail_ccw, depthFail_ccw, stencilPass_ccw);
665 } else {
666 if (onesided_enable) {
667 glEnable(GL_STENCIL_TEST);
668 checkGLcall("glEnable GL_STENCIL_TEST");
669 glStencilFunc(func, ref, mask);
670 checkGLcall("glStencilFunc(...)");
671 glStencilOp(stencilFail, depthFail, stencilPass);
672 checkGLcall("glStencilOp(...)");
673 } else {
674 glDisable(GL_STENCIL_TEST);
675 checkGLcall("glDisable GL_STENCIL_TEST");
676 }
677 }
678}
679
Stefan Dösingerc739c382007-02-12 19:18:22 +0100680static void state_stencilwrite(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger6886b232007-03-06 13:54:05 +0100681 if(stateblock->wineD3DDevice->stencilBufferTarget) {
682 glStencilMask(stateblock->renderState[WINED3DRS_STENCILWRITEMASK]);
683 } else {
684 glStencilMask(0);
685 }
Stefan Dösinger8d724312006-12-08 18:41:05 +0100686 checkGLcall("glStencilMask");
687}
688
Stefan Dösingerc739c382007-02-12 19:18:22 +0100689static void state_fog(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger61752732006-12-08 18:42:43 +0100690 /* TODO: Put this into the vertex type block once that is in the state table */
691 BOOL fogenable = stateblock->renderState[WINED3DRS_FOGENABLE];
Fabian Bieler7cedd562007-03-22 17:32:48 +0100692 BOOL is_ps3 = use_ps(stateblock->wineD3DDevice)
693 && ((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.hex_version >= WINED3DPS_VERSION(3,0);
Stefan Dösinger61752732006-12-08 18:42:43 +0100694 float fogstart, fogend;
695
696 union {
697 DWORD d;
698 float f;
699 } tmpvalue;
700
701 if (!fogenable) {
702 /* No fog? Disable it, and we're done :-) */
703 glDisable(GL_FOG);
704 checkGLcall("glDisable GL_FOG");
Fabian Bieler7cedd562007-03-22 17:32:48 +0100705 if( use_ps(stateblock->wineD3DDevice)
706 && ((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.hex_version < WINED3DPS_VERSION(3,0) ) {
707 /* disable fog in the pixel shader
708 * NOTE: For pixel shader, GL_FOG_START and GL_FOG_END don't hold fog start s and end e but
709 * -1/(e-s) and e/(e-s) respectively.
710 */
711 glFogf(GL_FOG_START, 0.0f);
712 checkGLcall("glFogf(GL_FOG_START, fogstart");
713 glFogf(GL_FOG_END, 1.0f);
714 checkGLcall("glFogf(GL_FOG_END, fogend");
715 }
Stefan Dösinger38d961a2007-02-25 23:58:14 +0100716 return;
Stefan Dösinger61752732006-12-08 18:42:43 +0100717 }
718
719 tmpvalue.d = stateblock->renderState[WINED3DRS_FOGSTART];
720 fogstart = tmpvalue.f;
721 tmpvalue.d = stateblock->renderState[WINED3DRS_FOGEND];
722 fogend = tmpvalue.f;
723
Stefan Dösinger4b445122007-03-14 18:04:56 +0100724 /* Fog Rules:
725 *
726 * With fixed function vertex processing, Direct3D knows 2 different fog input sources.
727 * It can use the Z value of the vertex, or the alpha component of the specular color.
728 * This depends on the fog vertex, fog table and the vertex declaration. If the Z value
729 * is used, fogstart, fogend and the equation type are used, otherwise linear fog with
730 * start = 255, end = 0 is used. Obviously the msdn is not very clear on that.
731 *
732 * FOGTABLEMODE != NONE:
733 * The Z value is used, with the equation specified, no matter what vertex type.
734 *
735 * FOGTABLEMODE == NONE, FOGVERTEXMODE != NONE, untransformed:
736 * Per vertex fog is calculated using the specified fog equation and the parameters
737 *
738 * FOGTABLEMODE == NONE, FOGVERTEXMODE != NONE, transformed, OR
739 * FOGTABLEMODE == NONE, FOGVERTEXMODE == NONE, untransformed:
740 * Linear fog with start = 255.0, end = 0.0, input comes from the specular color
741 *
Fabian Bieler7cedd562007-03-22 17:32:48 +0100742 *
743 * Rules for vertex fog with shaders:
744 *
745 * When mixing fixed function functionality with the programmable pipeline, D3D expects
746 * the fog computation to happen during transformation while openGL expects it to happen
747 * during rasterization. Also, prior to pixel shader 3.0 D3D handles fog blending after
748 * the pixel shader while openGL always expects the pixel shader to handle the blending.
749 * To solve this problem, WineD3D does:
750 * 1) implement a linear fog equation and fog blending at the end of every pre 3.0 pixel
751 * shader,
752 * and 2) disables the fog computation (in either the fixed function or programmable
753 * rasterizer) if using a vertex program.
754 *
755 *
756 * If a fogtablemode and a fogvertexmode are specified, table fog is applied (with or
757 * without shaders).
Stefan Dösinger4b445122007-03-14 18:04:56 +0100758 */
Fabian Bieler7cedd562007-03-22 17:32:48 +0100759
760 if( is_ps3 ) {
761 if( !use_vs(stateblock->wineD3DDevice)
762 && stateblock->renderState[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE ) {
763 FIXME("Implement vertex fog for pixel shader >= 3.0 and fixed function pipeline\n");
764 }
765 }
766
H. Verbeet30ee0712007-03-12 23:22:00 +0100767 if (use_vs(stateblock->wineD3DDevice)
768 && ((IWineD3DVertexShaderImpl *)stateblock->vertexShader)->usesFog) {
Fabian Bieler7cedd562007-03-22 17:32:48 +0100769 if( stateblock->renderState[WINED3DRS_FOGTABLEMODE] != WINED3DFOG_NONE ) {
770 if(!is_ps3) FIXME("Implement table fog for foggy vertex shader\n");
771 /* Disable fog */
772 fogenable = FALSE;
773 } else {
774 /* Set fog computation in the rasterizer to pass through the value (just blend it) */
775 glFogi(GL_FOG_MODE, GL_LINEAR);
776 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
Vitaliy Margolen51ee7f42007-02-25 18:03:00 -0700777 fogstart = 1.0;
778 fogend = 0.0;
779 }
Stefan Dösingere6c9a072007-02-12 19:18:27 +0100780 context->last_was_foggy_shader = TRUE;
Stefan Dösinger61752732006-12-08 18:42:43 +0100781 }
Fabian Bieler7cedd562007-03-22 17:32:48 +0100782 else if( use_ps(stateblock->wineD3DDevice) ) {
783 /* NOTE: For pixel shader, GL_FOG_START and GL_FOG_END don't hold fog start s and end e but
784 * -1/(e-s) and e/(e-s) respectively to simplify fog computation in the shader.
785 */
786 WINED3DFOGMODE mode;
787 context->last_was_foggy_shader = FALSE;
788
789 /* If both fogmodes are set use the table fog mode */
790 if(stateblock->renderState[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE)
791 mode = stateblock->renderState[WINED3DRS_FOGVERTEXMODE];
792 else
793 mode = stateblock->renderState[WINED3DRS_FOGTABLEMODE];
794
795 switch (mode) {
796 case WINED3DFOG_EXP:
797 case WINED3DFOG_EXP2:
798 if(!is_ps3) FIXME("Implement non linear fog for pixel shader < 3.0\n");
799 /* Disable fog */
800 fogenable = FALSE;
801 break;
802
803 case WINED3DFOG_LINEAR:
804 fogstart = -1.0f/(fogend-fogstart);
805 fogend *= -fogstart;
806 break;
807
808 case WINED3DFOG_NONE:
809 if(!is_ps3) FIXME("Implement software vertex fog for pixel shader < 3.0\n");
810 /* Disable fog */
811 fogenable = FALSE;
812 break;
813 default: FIXME("Unexpected WINED3DRS_FOGVERTEXMODE %d\n", stateblock->renderState[WINED3DRS_FOGVERTEXMODE]);
814 }
815 }
Stefan Dösinger61752732006-12-08 18:42:43 +0100816 /* DX 7 sdk: "If both render states(vertex and table fog) are set to valid modes,
817 * the system will apply only pixel(=table) fog effects."
818 */
H. Verbeeta2fde7d2007-02-15 13:32:13 +0100819 else if(stateblock->renderState[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE) {
Stefan Dösinger61752732006-12-08 18:42:43 +0100820 glHint(GL_FOG_HINT, GL_FASTEST);
821 checkGLcall("glHint(GL_FOG_HINT, GL_FASTEST)");
Stefan Dösingere6c9a072007-02-12 19:18:27 +0100822 context->last_was_foggy_shader = FALSE;
Stefan Dösinger20de2002007-01-02 22:47:10 +0100823
Stefan Dösinger61752732006-12-08 18:42:43 +0100824 switch (stateblock->renderState[WINED3DRS_FOGVERTEXMODE]) {
Stefan Dösinger4b445122007-03-14 18:04:56 +0100825 /* If processed vertices are used, fall through to the NONE case */
H. Verbeeta2fde7d2007-02-15 13:32:13 +0100826 case WINED3DFOG_EXP: {
Stefan Dösingere6c9a072007-02-12 19:18:27 +0100827 if(!context->last_was_rhw) {
Stefan Dösinger61752732006-12-08 18:42:43 +0100828 glFogi(GL_FOG_MODE, GL_EXP);
829 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP");
830 if(GL_SUPPORT(EXT_FOG_COORD)) {
831 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
832 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
833 }
834 break;
835 }
836 }
H. Verbeeta2fde7d2007-02-15 13:32:13 +0100837 case WINED3DFOG_EXP2: {
Stefan Dösingere6c9a072007-02-12 19:18:27 +0100838 if(!context->last_was_rhw) {
Stefan Dösinger61752732006-12-08 18:42:43 +0100839 glFogi(GL_FOG_MODE, GL_EXP2);
840 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2");
841 if(GL_SUPPORT(EXT_FOG_COORD)) {
842 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
843 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
844 }
845 break;
846 }
847 }
H. Verbeeta2fde7d2007-02-15 13:32:13 +0100848 case WINED3DFOG_LINEAR: {
Stefan Dösingere6c9a072007-02-12 19:18:27 +0100849 if(!context->last_was_rhw) {
Stefan Dösinger61752732006-12-08 18:42:43 +0100850 glFogi(GL_FOG_MODE, GL_LINEAR);
851 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR");
852 if(GL_SUPPORT(EXT_FOG_COORD)) {
853 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
854 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
855 }
856 break;
857 }
858 }
H. Verbeeta2fde7d2007-02-15 13:32:13 +0100859 case WINED3DFOG_NONE: {
Stefan Dösinger61752732006-12-08 18:42:43 +0100860 /* Both are none? According to msdn the alpha channel of the specular
861 * color contains a fog factor. Set it in drawStridedSlow.
862 * Same happens with Vertexfog on transformed vertices
863 */
864 if(GL_SUPPORT(EXT_FOG_COORD)) {
865 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);
866 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT)\n");
867 glFogi(GL_FOG_MODE, GL_LINEAR);
868 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
869 fogstart = 0xff;
870 fogend = 0x0;
871 } else {
872 /* Disable GL fog, handle this in software in drawStridedSlow */
873 fogenable = FALSE;
874 }
875 break;
876 }
877 default: FIXME("Unexpected WINED3DRS_FOGVERTEXMODE %d\n", stateblock->renderState[WINED3DRS_FOGVERTEXMODE]);
878 }
879 } else {
880 glHint(GL_FOG_HINT, GL_NICEST);
881 checkGLcall("glHint(GL_FOG_HINT, GL_NICEST)");
Stefan Dösingere6c9a072007-02-12 19:18:27 +0100882 context->last_was_foggy_shader = FALSE;
Stefan Dösinger20de2002007-01-02 22:47:10 +0100883
Stefan Dösinger61752732006-12-08 18:42:43 +0100884 switch (stateblock->renderState[WINED3DRS_FOGTABLEMODE]) {
H. Verbeeta2fde7d2007-02-15 13:32:13 +0100885 case WINED3DFOG_EXP:
Stefan Dösinger61752732006-12-08 18:42:43 +0100886 glFogi(GL_FOG_MODE, GL_EXP);
887 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP");
888 if(GL_SUPPORT(EXT_FOG_COORD)) {
889 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
890 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
891 }
892 break;
893
H. Verbeeta2fde7d2007-02-15 13:32:13 +0100894 case WINED3DFOG_EXP2:
Stefan Dösinger61752732006-12-08 18:42:43 +0100895 glFogi(GL_FOG_MODE, GL_EXP2);
896 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2");
897 if(GL_SUPPORT(EXT_FOG_COORD)) {
898 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
899 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
900 }
901 break;
902
H. Verbeeta2fde7d2007-02-15 13:32:13 +0100903 case WINED3DFOG_LINEAR:
Stefan Dösinger61752732006-12-08 18:42:43 +0100904 glFogi(GL_FOG_MODE, GL_LINEAR);
905 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR");
906 if(GL_SUPPORT(EXT_FOG_COORD)) {
907 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
908 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT");
909 }
910 break;
911
H. Verbeeta2fde7d2007-02-15 13:32:13 +0100912 case WINED3DFOG_NONE: /* Won't happen */
Stefan Dösinger61752732006-12-08 18:42:43 +0100913 default:
914 FIXME("Unexpected WINED3DRS_FOGTABLEMODE %d\n", stateblock->renderState[WINED3DRS_FOGTABLEMODE]);
915 }
916 }
917
918 if(fogenable) {
919 glEnable(GL_FOG);
920 checkGLcall("glEnable GL_FOG");
921
922 glFogfv(GL_FOG_START, &fogstart);
923 checkGLcall("glFogf(GL_FOG_START, fogstart");
924 TRACE("Fog Start == %f\n", fogstart);
925
926 glFogfv(GL_FOG_END, &fogend);
927 checkGLcall("glFogf(GL_FOG_END, fogend");
928 TRACE("Fog End == %f\n", fogend);
929 } else {
930 glDisable(GL_FOG);
931 checkGLcall("glDisable GL_FOG");
Fabian Bieler7cedd562007-03-22 17:32:48 +0100932 if( use_ps(stateblock->wineD3DDevice) ) {
933 /* disable fog in the pixel shader
934 * NOTE: For pixel shader, GL_FOG_START and GL_FOG_END don't hold fog start s and end e but
935 * -1/(e-s) and e/(e-s) respectively.
936 */
937 glFogf(GL_FOG_START, 0.0f);
938 checkGLcall("glFogf(GL_FOG_START, fogstart");
939 glFogf(GL_FOG_END, 1.0f);
940 checkGLcall("glFogf(GL_FOG_END, fogend");
941 }
Stefan Dösinger61752732006-12-08 18:42:43 +0100942 }
943
944 if (GL_SUPPORT(NV_FOG_DISTANCE)) {
945 glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_PLANE_ABSOLUTE_NV);
946 }
947}
948
Stefan Dösingerc739c382007-02-12 19:18:22 +0100949static void state_fogcolor(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Alexandre Julliardbbfe1202006-12-29 11:35:57 +0100950 float col[4];
951 D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_FOGCOLOR], col);
Alexandre Julliardbbfe1202006-12-29 11:35:57 +0100952 glFogfv(GL_FOG_COLOR, &col[0]);
Stefan Dösingeraf935a22006-12-08 18:52:30 +0100953 checkGLcall("glFog GL_FOG_COLOR");
954}
955
Stefan Dösingerc739c382007-02-12 19:18:22 +0100956static void state_fogdensity(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingere53c2a92006-12-10 16:34:45 +0100957 union {
958 DWORD d;
959 float f;
960 } tmpvalue;
961 tmpvalue.d = stateblock->renderState[WINED3DRS_FOGDENSITY];
962 glFogfv(GL_FOG_DENSITY, &tmpvalue.f);
963 checkGLcall("glFogf(GL_FOG_DENSITY, (float) Value)");
964}
965
Stefan Dösinger81a1dce2006-12-10 22:44:18 +0100966/* TODO: Merge with primitive type + init_materials()!! */
Stefan Dösingerc739c382007-02-12 19:18:22 +0100967static void state_colormat(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
H. Verbeetd429ff52007-01-17 21:41:35 +0100968 IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)stateblock->wineD3DDevice;
H. Verbeet612a74a2007-01-17 21:41:21 +0100969 GLenum Parm = 0;
H. Verbeetd429ff52007-01-17 21:41:35 +0100970 WineDirect3DStridedData *diffuse = &device->strided_streams.u.s.diffuse;
Stefan Dösinger9b492092007-01-10 11:26:12 +0100971 BOOL isDiffuseSupplied;
972
Francois Gouget536e7382007-02-14 16:22:07 +0100973 /* Depends on the decoded vertex declaration to read the existence of diffuse data.
Stefan Dösinger9b492092007-01-10 11:26:12 +0100974 * The vertex declaration will call this function if the fixed function pipeline is used.
975 */
Stefan Dösinger380930d2007-02-12 19:18:31 +0100976
977 if(isStateDirty(context, STATE_VDECL)) {
Stefan Dösinger9b492092007-01-10 11:26:12 +0100978 return;
979 }
980
981 isDiffuseSupplied = diffuse->lpData || diffuse->VBO;
Stefan Dösinger81a1dce2006-12-10 22:44:18 +0100982
H. Verbeet612a74a2007-01-17 21:41:21 +0100983 if (isDiffuseSupplied && stateblock->renderState[WINED3DRS_COLORVERTEX]) {
Stefan Dösinger81a1dce2006-12-10 22:44:18 +0100984 TRACE("diff %d, amb %d, emis %d, spec %d\n",
985 stateblock->renderState[WINED3DRS_DIFFUSEMATERIALSOURCE],
986 stateblock->renderState[WINED3DRS_AMBIENTMATERIALSOURCE],
987 stateblock->renderState[WINED3DRS_EMISSIVEMATERIALSOURCE],
988 stateblock->renderState[WINED3DRS_SPECULARMATERIALSOURCE]);
989
H. Verbeeta2fde7d2007-02-15 13:32:13 +0100990 if (stateblock->renderState[WINED3DRS_DIFFUSEMATERIALSOURCE] == WINED3DMCS_COLOR1) {
991 if (stateblock->renderState[WINED3DRS_AMBIENTMATERIALSOURCE] == WINED3DMCS_COLOR1) {
Stefan Dösinger81a1dce2006-12-10 22:44:18 +0100992 Parm = GL_AMBIENT_AND_DIFFUSE;
993 } else {
994 Parm = GL_DIFFUSE;
995 }
H. Verbeeta2fde7d2007-02-15 13:32:13 +0100996 } else if (stateblock->renderState[WINED3DRS_AMBIENTMATERIALSOURCE] == WINED3DMCS_COLOR1) {
Stefan Dösinger81a1dce2006-12-10 22:44:18 +0100997 Parm = GL_AMBIENT;
H. Verbeeta2fde7d2007-02-15 13:32:13 +0100998 } else if (stateblock->renderState[WINED3DRS_EMISSIVEMATERIALSOURCE] == WINED3DMCS_COLOR1) {
Stefan Dösinger81a1dce2006-12-10 22:44:18 +0100999 Parm = GL_EMISSION;
H. Verbeeta2fde7d2007-02-15 13:32:13 +01001000 } else if (stateblock->renderState[WINED3DRS_SPECULARMATERIALSOURCE] == WINED3DMCS_COLOR1) {
Stefan Dösinger81a1dce2006-12-10 22:44:18 +01001001 Parm = GL_SPECULAR;
Stefan Dösinger81a1dce2006-12-10 22:44:18 +01001002 }
Stefan Dösinger9b492092007-01-10 11:26:12 +01001003 }
Stefan Dösinger81a1dce2006-12-10 22:44:18 +01001004
H. Verbeetd429ff52007-01-17 21:41:35 +01001005 /* Nothing changed, return. */
Stefan Dösingere6c9a072007-02-12 19:18:27 +01001006 if (Parm == context->tracking_parm) return;
H. Verbeetd429ff52007-01-17 21:41:35 +01001007
H. Verbeet612a74a2007-01-17 21:41:21 +01001008 if(!Parm) {
Stefan Dösinger9b492092007-01-10 11:26:12 +01001009 glDisable(GL_COLOR_MATERIAL);
1010 checkGLcall("glDisable GL_COLOR_MATERIAL");
Stefan Dösinger81a1dce2006-12-10 22:44:18 +01001011 } else {
Stefan Dösinger9b492092007-01-10 11:26:12 +01001012 glColorMaterial(GL_FRONT_AND_BACK, Parm);
1013 checkGLcall("glColorMaterial(GL_FRONT_AND_BACK, Parm)");
1014 glEnable(GL_COLOR_MATERIAL);
1015 checkGLcall("glEnable(GL_COLOR_MATERIAL)");
Stefan Dösinger81a1dce2006-12-10 22:44:18 +01001016 }
H. Verbeetd429ff52007-01-17 21:41:35 +01001017
1018 /* Apparently calls to glMaterialfv are ignored for properties we're
1019 * tracking with glColorMaterial, so apply those here. */
Stefan Dösingere6c9a072007-02-12 19:18:27 +01001020 switch (context->tracking_parm) {
H. Verbeetd429ff52007-01-17 21:41:35 +01001021 case GL_AMBIENT_AND_DIFFUSE:
1022 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (float*)&device->updateStateBlock->material.Ambient);
1023 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, (float*)&device->updateStateBlock->material.Diffuse);
1024 checkGLcall("glMaterialfv");
1025 break;
1026
1027 case GL_DIFFUSE:
1028 glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, (float*)&device->updateStateBlock->material.Diffuse);
1029 checkGLcall("glMaterialfv");
1030 break;
1031
1032 case GL_AMBIENT:
1033 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (float*)&device->updateStateBlock->material.Ambient);
1034 checkGLcall("glMaterialfv");
1035 break;
1036
1037 case GL_EMISSION:
1038 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, (float*)&device->updateStateBlock->material.Emissive);
1039 checkGLcall("glMaterialfv");
1040 break;
1041
1042 case GL_SPECULAR:
1043 /* Only change material color if specular is enabled, otherwise it is set to black */
1044 if (device->stateBlock->renderState[WINED3DRS_SPECULARENABLE]) {
1045 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float*)&device->updateStateBlock->material.Specular);
1046 checkGLcall("glMaterialfv");
1047 } else {
1048 float black[4] = {0.0f, 0.0f, 0.0f, 0.0f};
1049 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, &black[0]);
1050 checkGLcall("glMaterialfv");
1051 }
1052 break;
1053 }
1054
Stefan Dösingere6c9a072007-02-12 19:18:27 +01001055 context->tracking_parm = Parm;
Stefan Dösinger81a1dce2006-12-10 22:44:18 +01001056}
1057
Stefan Dösingerc739c382007-02-12 19:18:22 +01001058static void state_linepattern(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger6a5d7df2006-12-10 23:20:01 +01001059 union {
1060 DWORD d;
1061 WINED3DLINEPATTERN lp;
1062 } tmppattern;
1063 tmppattern.d = stateblock->renderState[WINED3DRS_LINEPATTERN];
1064
1065 TRACE("Line pattern: repeat %d bits %x\n", tmppattern.lp.wRepeatFactor, tmppattern.lp.wLinePattern);
1066
1067 if (tmppattern.lp.wRepeatFactor) {
1068 glLineStipple(tmppattern.lp.wRepeatFactor, tmppattern.lp.wLinePattern);
1069 checkGLcall("glLineStipple(repeat, linepattern)");
1070 glEnable(GL_LINE_STIPPLE);
1071 checkGLcall("glEnable(GL_LINE_STIPPLE);");
1072 } else {
1073 glDisable(GL_LINE_STIPPLE);
1074 checkGLcall("glDisable(GL_LINE_STIPPLE);");
1075 }
1076}
1077
Stefan Dösingerc739c382007-02-12 19:18:22 +01001078static void state_zbias(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingerdd6f5a52006-12-10 23:19:57 +01001079 union {
1080 DWORD d;
1081 float f;
1082 } tmpvalue;
1083
1084 if (stateblock->renderState[WINED3DRS_ZBIAS]) {
1085 tmpvalue.d = stateblock->renderState[WINED3DRS_ZBIAS];
1086 TRACE("ZBias value %f\n", tmpvalue.f);
1087 glPolygonOffset(0, -tmpvalue.f);
1088 checkGLcall("glPolygonOffset(0, -Value)");
1089 glEnable(GL_POLYGON_OFFSET_FILL);
1090 checkGLcall("glEnable(GL_POLYGON_OFFSET_FILL);");
1091 glEnable(GL_POLYGON_OFFSET_LINE);
1092 checkGLcall("glEnable(GL_POLYGON_OFFSET_LINE);");
1093 glEnable(GL_POLYGON_OFFSET_POINT);
1094 checkGLcall("glEnable(GL_POLYGON_OFFSET_POINT);");
1095 } else {
1096 glDisable(GL_POLYGON_OFFSET_FILL);
1097 checkGLcall("glDisable(GL_POLYGON_OFFSET_FILL);");
1098 glDisable(GL_POLYGON_OFFSET_LINE);
1099 checkGLcall("glDisable(GL_POLYGON_OFFSET_LINE);");
1100 glDisable(GL_POLYGON_OFFSET_POINT);
1101 checkGLcall("glDisable(GL_POLYGON_OFFSET_POINT);");
1102 }
1103}
1104
Stefan Dösinger2ea57672006-12-10 23:20:05 +01001105
Stefan Dösingerc739c382007-02-12 19:18:22 +01001106static void state_normalize(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger2ea57672006-12-10 23:20:05 +01001107 if (stateblock->renderState[WINED3DRS_NORMALIZENORMALS]) {
1108 glEnable(GL_NORMALIZE);
1109 checkGLcall("glEnable(GL_NORMALIZE);");
1110 } else {
1111 glDisable(GL_NORMALIZE);
1112 checkGLcall("glDisable(GL_NORMALIZE);");
1113 }
1114}
1115
Stefan Dösingerc739c382007-02-12 19:18:22 +01001116static void state_psize(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger0ec7c8b2006-12-10 23:20:09 +01001117 union {
1118 DWORD d;
1119 float f;
1120 } tmpvalue;
1121
1122 /* FIXME: check that pointSize isn't outside glGetFloatv( GL_POINT_SIZE_MAX_ARB, &maxSize ); or -ve */
1123 tmpvalue.d = stateblock->renderState[WINED3DRS_POINTSIZE];
1124 TRACE("Set point size to %f\n", tmpvalue.f);
1125 glPointSize(tmpvalue.f);
1126 checkGLcall("glPointSize(...);");
1127}
1128
Stefan Dösingerc739c382007-02-12 19:18:22 +01001129static void state_psizemin(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger51b41d92006-12-10 23:20:12 +01001130 union {
1131 DWORD d;
1132 float f;
1133 } tmpvalue;
1134
Stefan Dösinger953f8d72007-01-10 11:32:07 +01001135 tmpvalue.d = stateblock->renderState[WINED3DRS_POINTSIZE_MIN];
Nick Burnsd9557152007-01-01 01:58:33 -08001136 if(GL_SUPPORT(ARB_POINT_PARAMETERS)) {
Nick Burnsd9557152007-01-01 01:58:33 -08001137 GL_EXTCALL(glPointParameterfARB)(GL_POINT_SIZE_MIN_ARB, tmpvalue.f);
1138 checkGLcall("glPointParameterfARB(...");
1139 }
1140 else if(GL_SUPPORT(EXT_POINT_PARAMETERS)) {
Stefan Dösinger51b41d92006-12-10 23:20:12 +01001141 GL_EXTCALL(glPointParameterfEXT)(GL_POINT_SIZE_MIN_EXT, tmpvalue.f);
1142 checkGLcall("glPointParameterfEXT(...);");
Stefan Dösinger953f8d72007-01-10 11:32:07 +01001143 } else if(tmpvalue.f != 1.0) {
1144 FIXME("WINED3DRS_POINTSIZE_MIN not supported on this opengl, value is %f\n", tmpvalue.f);
Stefan Dösinger51b41d92006-12-10 23:20:12 +01001145 }
1146}
1147
Stefan Dösingerc739c382007-02-12 19:18:22 +01001148static void state_psizemax(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger9a0e4b52006-12-10 23:20:15 +01001149 union {
1150 DWORD d;
1151 float f;
1152 } tmpvalue;
1153
Stefan Dösinger953f8d72007-01-10 11:32:07 +01001154 tmpvalue.d = stateblock->renderState[WINED3DRS_POINTSIZE_MAX];
Nick Burnsd9557152007-01-01 01:58:33 -08001155 if(GL_SUPPORT(ARB_POINT_PARAMETERS)) {
Nick Burnsd9557152007-01-01 01:58:33 -08001156 GL_EXTCALL(glPointParameterfARB)(GL_POINT_SIZE_MAX_ARB, tmpvalue.f);
1157 checkGLcall("glPointParameterfARB(...");
1158 }
1159 else if(GL_SUPPORT(EXT_POINT_PARAMETERS)) {
Stefan Dösinger9a0e4b52006-12-10 23:20:15 +01001160 GL_EXTCALL(glPointParameterfEXT)(GL_POINT_SIZE_MAX_EXT, tmpvalue.f);
1161 checkGLcall("glPointParameterfEXT(...);");
Stefan Dösinger953f8d72007-01-10 11:32:07 +01001162 } else if(tmpvalue.f != 64.0) {
1163 FIXME("WINED3DRS_POINTSIZE_MAX not supported on this opengl, value is %f\n", tmpvalue.f);
Stefan Dösinger9a0e4b52006-12-10 23:20:15 +01001164 }
1165}
1166
Stefan Dösingerc739c382007-02-12 19:18:22 +01001167static void state_pscale(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingercaa371a2006-12-10 23:20:19 +01001168 /* TODO: Group this with the viewport */
1169 /*
1170 * POINTSCALEENABLE controls how point size value is treated. If set to
1171 * true, the point size is scaled with respect to height of viewport.
1172 * When set to false point size is in pixels.
1173 *
1174 * http://msdn.microsoft.com/library/en-us/directx9_c/point_sprites.asp
1175 */
1176
1177 /* Default values */
1178 GLfloat att[3] = {1.0f, 0.0f, 0.0f};
1179
1180 /*
1181 * Minimum valid point size for OpenGL is 1.0f. For Direct3D it is 0.0f.
1182 * This means that OpenGL will clamp really small point sizes to 1.0f.
1183 * To correct for this we need to multiply by the scale factor when sizes
1184 * are less than 1.0f. scale_factor = 1.0f / point_size.
1185 */
1186 GLfloat pointSize = *((float*)&stateblock->renderState[WINED3DRS_POINTSIZE]);
1187 if(pointSize > 0.0f) {
1188 GLfloat scaleFactor;
1189
1190 if(pointSize < 1.0f) {
1191 scaleFactor = pointSize * pointSize;
1192 } else {
1193 scaleFactor = 1.0f;
1194 }
1195
1196 if(stateblock->renderState[WINED3DRS_POINTSCALEENABLE]) {
1197 att[0] = *((float*)&stateblock->renderState[WINED3DRS_POINTSCALE_A]) /
1198 (stateblock->viewport.Height * stateblock->viewport.Height * scaleFactor);
1199 att[1] = *((float*)&stateblock->renderState[WINED3DRS_POINTSCALE_B]) /
1200 (stateblock->viewport.Height * stateblock->viewport.Height * scaleFactor);
1201 att[2] = *((float*)&stateblock->renderState[WINED3DRS_POINTSCALE_C]) /
1202 (stateblock->viewport.Height * stateblock->viewport.Height * scaleFactor);
1203 }
1204 }
1205
1206 if(GL_SUPPORT(ARB_POINT_PARAMETERS)) {
1207 GL_EXTCALL(glPointParameterfvARB)(GL_POINT_DISTANCE_ATTENUATION_ARB, att);
1208 checkGLcall("glPointParameterfvARB(GL_DISTANCE_ATTENUATION_ARB, ...");
1209 }
1210 else if(GL_SUPPORT(EXT_POINT_PARAMETERS)) {
1211 GL_EXTCALL(glPointParameterfvEXT)(GL_DISTANCE_ATTENUATION_EXT, att);
1212 checkGLcall("glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, ...");
1213 } else {
1214 TRACE("POINT_PARAMETERS not supported in this version of opengl\n");
1215 }
1216}
1217
Stefan Dösingerc739c382007-02-12 19:18:22 +01001218static void state_colorwrite(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger4c64b862006-12-10 23:20:22 +01001219 DWORD Value = stateblock->renderState[WINED3DRS_COLORWRITEENABLE];
1220
1221 TRACE("Color mask: r(%d) g(%d) b(%d) a(%d)\n",
H. Verbeeta2fde7d2007-02-15 13:32:13 +01001222 Value & WINED3DCOLORWRITEENABLE_RED ? 1 : 0,
1223 Value & WINED3DCOLORWRITEENABLE_GREEN ? 1 : 0,
1224 Value & WINED3DCOLORWRITEENABLE_BLUE ? 1 : 0,
1225 Value & WINED3DCOLORWRITEENABLE_ALPHA ? 1 : 0);
1226 glColorMask(Value & WINED3DCOLORWRITEENABLE_RED ? GL_TRUE : GL_FALSE,
1227 Value & WINED3DCOLORWRITEENABLE_GREEN ? GL_TRUE : GL_FALSE,
1228 Value & WINED3DCOLORWRITEENABLE_BLUE ? GL_TRUE : GL_FALSE,
1229 Value & WINED3DCOLORWRITEENABLE_ALPHA ? GL_TRUE : GL_FALSE);
Stefan Dösinger4c64b862006-12-10 23:20:22 +01001230 checkGLcall("glColorMask(...)");
1231
1232 /* depends on WINED3DRS_COLORWRITEENABLE. */
1233 if(stateblock->renderState[WINED3DRS_COLORWRITEENABLE1] != 0x0000000F ||
1234 stateblock->renderState[WINED3DRS_COLORWRITEENABLE2] != 0x0000000F ||
1235 stateblock->renderState[WINED3DRS_COLORWRITEENABLE3] != 0x0000000F ) {
1236 ERR("(WINED3DRS_COLORWRITEENABLE1/2/3,%d,%d,%d) not yet implemented. Missing of cap D3DPMISCCAPS_INDEPENDENTWRITEMASKS wasn't honored?\n",
1237 stateblock->renderState[WINED3DRS_COLORWRITEENABLE1],
1238 stateblock->renderState[WINED3DRS_COLORWRITEENABLE2],
1239 stateblock->renderState[WINED3DRS_COLORWRITEENABLE3]);
1240 }
1241}
1242
Stefan Dösingerc739c382007-02-12 19:18:22 +01001243static void state_localviewer(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger580b9962006-12-10 23:20:26 +01001244 if(stateblock->renderState[WINED3DRS_LOCALVIEWER]) {
1245 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);
1246 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1)");
1247 } else {
1248 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 0);
1249 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 0)");
1250 }
1251}
1252
Stefan Dösingerc739c382007-02-12 19:18:22 +01001253static void state_lastpixel(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingerc5344702006-12-10 23:20:29 +01001254 if(stateblock->renderState[WINED3DRS_LASTPIXEL]) {
1255 TRACE("Last Pixel Drawing Enabled\n");
1256 } else {
Jan Zerebecki09e77912007-03-27 09:27:52 +02001257 static BOOL first = TRUE;
1258 if(first) {
1259 FIXME("Last Pixel Drawing Disabled, not handled yet\n");
1260 first = FALSE;
1261 } else {
1262 TRACE("Last Pixel Drawing Disabled, not handled yet\n");
1263 }
Stefan Dösingerc5344702006-12-10 23:20:29 +01001264 }
1265}
1266
Stefan Dösingerc739c382007-02-12 19:18:22 +01001267static void state_pointsprite(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Chris Robinsond8c67c32007-01-03 00:17:24 -08001268 unsigned int i;
1269 int val;
1270
Stefan Dösinger920225d2006-12-10 23:20:36 +01001271 /* TODO: NV_POINT_SPRITE */
1272 if (!GL_SUPPORT(ARB_POINT_SPRITE)) {
1273 TRACE("Point sprites not supported\n");
1274 return;
1275 }
1276
Stefan Dösinger920225d2006-12-10 23:20:36 +01001277 if (stateblock->renderState[WINED3DRS_POINTSPRITEENABLE]) {
Chris Robinsond8c67c32007-01-03 00:17:24 -08001278 val = GL_TRUE;
Stefan Dösinger920225d2006-12-10 23:20:36 +01001279 } else {
Chris Robinsond8c67c32007-01-03 00:17:24 -08001280 val = GL_FALSE;
1281 }
1282
H. Verbeet23cd4472007-03-12 23:21:44 +01001283 for (i = 0; i < GL_LIMITS(textures); i++) {
Chris Robinsond8c67c32007-01-03 00:17:24 -08001284 /* Note the WINED3DRS value applies to all textures, but GL has one
1285 * per texture, so apply it now ready to be used!
1286 */
1287 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
1288 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + i));
1289 checkGLcall("glActiveTextureARB");
1290 } else if (i==1) {
1291 FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
1292 break;
1293 }
1294
1295 glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, val);
1296 checkGLcall((val?"glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE)":
1297 "glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_FALSE)"));
Stefan Dösinger920225d2006-12-10 23:20:36 +01001298 }
1299}
1300
Stefan Dösingerc739c382007-02-12 19:18:22 +01001301static void state_wrap(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger81dce712006-12-10 23:20:45 +01001302 /**
1303 http://www.cosc.brocku.ca/Offerings/3P98/course/lectures/texture/
1304 http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/graphics/programmingguide/FixedFunction/Textures/texturewrapping.asp
1305 http://www.gamedev.net/reference/programming/features/rendererdll3/page2.asp
1306 Descussion that ways to turn on WRAPing to solve an opengl conversion problem.
1307 http://www.flipcode.org/cgi-bin/fcmsg.cgi?thread_show=10248
1308
1309 so far as I can tell, wrapping and texture-coordinate generate go hand in hand,
1310 */
1311 TRACE("Stub\n");
1312 if(stateblock->renderState[WINED3DRS_WRAP0] ||
1313 stateblock->renderState[WINED3DRS_WRAP1] ||
1314 stateblock->renderState[WINED3DRS_WRAP2] ||
1315 stateblock->renderState[WINED3DRS_WRAP3] ||
1316 stateblock->renderState[WINED3DRS_WRAP4] ||
1317 stateblock->renderState[WINED3DRS_WRAP5] ||
1318 stateblock->renderState[WINED3DRS_WRAP6] ||
1319 stateblock->renderState[WINED3DRS_WRAP7] ||
1320 stateblock->renderState[WINED3DRS_WRAP8] ||
1321 stateblock->renderState[WINED3DRS_WRAP9] ||
1322 stateblock->renderState[WINED3DRS_WRAP10] ||
1323 stateblock->renderState[WINED3DRS_WRAP11] ||
1324 stateblock->renderState[WINED3DRS_WRAP12] ||
1325 stateblock->renderState[WINED3DRS_WRAP13] ||
1326 stateblock->renderState[WINED3DRS_WRAP14] ||
1327 stateblock->renderState[WINED3DRS_WRAP15] ) {
Felix Nawothnig413b9b22007-04-03 23:38:21 +02001328 FIXME("(WINED3DRS_WRAP0) Texture wraping not yet supported\n");
Stefan Dösinger81dce712006-12-10 23:20:45 +01001329 }
1330}
1331
Stefan Dösingerc739c382007-02-12 19:18:22 +01001332static void state_multisampleaa(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger0c1aba52006-12-10 23:20:40 +01001333 if( GL_SUPPORT(ARB_MULTISAMPLE) ) {
1334 if(stateblock->renderState[WINED3DRS_MULTISAMPLEANTIALIAS]) {
1335 glEnable(GL_MULTISAMPLE_ARB);
1336 checkGLcall("glEnable(GL_MULTISAMPLE_ARB)");
1337 } else {
1338 glDisable(GL_MULTISAMPLE_ARB);
1339 checkGLcall("glDisable(GL_MULTISAMPLE_ARB)");
1340 }
1341 } else {
1342 if(stateblock->renderState[WINED3DRS_MULTISAMPLEANTIALIAS]) {
1343 ERR("Multisample antialiasing not supported by gl\n");
1344 }
1345 }
1346}
1347
Stefan Dösingerc739c382007-02-12 19:18:22 +01001348static void state_scissor(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingerd7e55c22006-12-10 23:20:48 +01001349 if(stateblock->renderState[WINED3DRS_SCISSORTESTENABLE]) {
1350 glEnable(GL_SCISSOR_TEST);
1351 checkGLcall("glEnable(GL_SCISSOR_TEST)");
1352 } else {
1353 glDisable(GL_SCISSOR_TEST);
1354 checkGLcall("glDisable(GL_SCISSOR_TEST)");
1355 }
1356}
1357
Stefan Dösingerc739c382007-02-12 19:18:22 +01001358static void state_depthbias(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger30cf5e42006-12-10 23:20:52 +01001359 union {
1360 DWORD d;
1361 float f;
1362 } tmpvalue;
1363
1364 if(stateblock->renderState[WINED3DRS_SLOPESCALEDEPTHBIAS] ||
1365 stateblock->renderState[WINED3DRS_DEPTHBIAS]) {
1366 tmpvalue.d = stateblock->renderState[WINED3DRS_SLOPESCALEDEPTHBIAS];
1367 glEnable(GL_POLYGON_OFFSET_FILL);
1368 checkGLcall("glEnable(GL_POLYGON_OFFSET_FILL)");
1369 glPolygonOffset(tmpvalue.f, *((float*)&stateblock->renderState[WINED3DRS_DEPTHBIAS]));
1370 checkGLcall("glPolygonOffset(...)");
1371 } else {
1372 glDisable(GL_POLYGON_OFFSET_FILL);
1373 checkGLcall("glDisable(GL_POLYGON_OFFSET_FILL)");
1374 }
1375}
1376
Stefan Dösingerc739c382007-02-12 19:18:22 +01001377static void state_perspective(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger312be462006-12-10 23:20:56 +01001378 if (stateblock->renderState[WINED3DRS_TEXTUREPERSPECTIVE]) {
1379 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
1380 checkGLcall("glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)");
1381 } else {
1382 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
1383 checkGLcall("glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST)");
1384 }
1385}
1386
Stefan Dösingerc739c382007-02-12 19:18:22 +01001387static void state_stippledalpha(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger2710be02006-12-10 23:20:59 +01001388 TRACE("Stub\n");
1389 if (stateblock->renderState[WINED3DRS_STIPPLEDALPHA])
Felix Nawothnig413b9b22007-04-03 23:38:21 +02001390 FIXME(" Stippled Alpha not supported yet.\n");
Stefan Dösinger2710be02006-12-10 23:20:59 +01001391}
1392
Stefan Dösingerc739c382007-02-12 19:18:22 +01001393static void state_antialias(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger55a5b4c2006-12-10 23:21:03 +01001394 TRACE("Stub\n");
1395 if (stateblock->renderState[WINED3DRS_ANTIALIAS])
Felix Nawothnig413b9b22007-04-03 23:38:21 +02001396 FIXME(" Antialias not supported yet.\n");
Stefan Dösinger55a5b4c2006-12-10 23:21:03 +01001397}
1398
Stefan Dösingerc739c382007-02-12 19:18:22 +01001399static void state_multisampmask(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingerd7b85492006-12-10 23:21:07 +01001400 TRACE("Stub\n");
1401 if (stateblock->renderState[WINED3DRS_MULTISAMPLEMASK] != 0xFFFFFFFF)
Felix Nawothnig413b9b22007-04-03 23:38:21 +02001402 FIXME("(WINED3DRS_MULTISAMPLEMASK,%d) not yet implemented\n", stateblock->renderState[WINED3DRS_MULTISAMPLEMASK]);
Stefan Dösingerd7b85492006-12-10 23:21:07 +01001403}
1404
Stefan Dösingerc739c382007-02-12 19:18:22 +01001405static void state_patchedgestyle(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingere498a162006-12-10 23:21:10 +01001406 TRACE("Stub\n");
H. Verbeeta2fde7d2007-02-15 13:32:13 +01001407 if (stateblock->renderState[WINED3DRS_PATCHEDGESTYLE] != WINED3DPATCHEDGE_DISCRETE)
Felix Nawothnig413b9b22007-04-03 23:38:21 +02001408 FIXME("(WINED3DRS_PATCHEDGESTYLE,%d) not yet implemented\n", stateblock->renderState[WINED3DRS_PATCHEDGESTYLE]);
Stefan Dösingere498a162006-12-10 23:21:10 +01001409}
1410
Stefan Dösingerc739c382007-02-12 19:18:22 +01001411static void state_patchsegments(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger81974702006-12-10 23:21:14 +01001412 union {
1413 DWORD d;
1414 float f;
1415 } tmpvalue;
1416 tmpvalue.f = 1.0f;
1417
1418 TRACE("Stub\n");
1419 if (stateblock->renderState[WINED3DRS_PATCHSEGMENTS] != tmpvalue.d)
Felix Nawothnig6760cca2007-03-28 20:37:10 +02001420 {
Felix Nawothnige3d3d182007-04-03 23:39:22 +02001421 static BOOL displayed = FALSE;
1422
Felix Nawothnig6760cca2007-03-28 20:37:10 +02001423 tmpvalue.d = stateblock->renderState[WINED3DRS_PATCHSEGMENTS];
Felix Nawothnige3d3d182007-04-03 23:39:22 +02001424 if(!displayed)
1425 FIXME("(WINED3DRS_PATCHSEGMENTS,%f) not yet implemented\n", tmpvalue.f);
1426
1427 displayed = TRUE;
Felix Nawothnig6760cca2007-03-28 20:37:10 +02001428 }
Stefan Dösinger81974702006-12-10 23:21:14 +01001429}
1430
Stefan Dösingerc739c382007-02-12 19:18:22 +01001431static void state_positiondegree(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger052197a2006-12-10 23:21:21 +01001432 TRACE("Stub\n");
H. Verbeeta2fde7d2007-02-15 13:32:13 +01001433 if (stateblock->renderState[WINED3DRS_POSITIONDEGREE] != WINED3DDEGREE_CUBIC)
Felix Nawothnig413b9b22007-04-03 23:38:21 +02001434 FIXME("(WINED3DRS_POSITIONDEGREE,%d) not yet implemented\n", stateblock->renderState[WINED3DRS_POSITIONDEGREE]);
Stefan Dösinger052197a2006-12-10 23:21:21 +01001435}
1436
Stefan Dösingerc739c382007-02-12 19:18:22 +01001437static void state_normaldegree(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger3bb41772006-12-10 23:21:25 +01001438 TRACE("Stub\n");
H. Verbeeta2fde7d2007-02-15 13:32:13 +01001439 if (stateblock->renderState[WINED3DRS_NORMALDEGREE] != WINED3DDEGREE_LINEAR)
Felix Nawothnig413b9b22007-04-03 23:38:21 +02001440 FIXME("(WINED3DRS_NORMALDEGREE,%d) not yet implemented\n", stateblock->renderState[WINED3DRS_NORMALDEGREE]);
Stefan Dösinger3bb41772006-12-10 23:21:25 +01001441}
1442
Stefan Dösingerc739c382007-02-12 19:18:22 +01001443static void state_tessellation(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingercd0d0a72006-12-10 23:21:27 +01001444 TRACE("Stub\n");
1445 if(stateblock->renderState[WINED3DRS_ENABLEADAPTIVETESSELLATION])
1446 FIXME("(WINED3DRS_ENABLEADAPTIVETESSELLATION,%d) not yet implemented\n", stateblock->renderState[WINED3DRS_ENABLEADAPTIVETESSELLATION]);
1447}
1448
Stefan Dösinger8a5bf912006-12-10 23:13:38 +01001449
Stefan Dösingerc739c382007-02-12 19:18:22 +01001450static void state_srgbwrite(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger8a5bf912006-12-10 23:13:38 +01001451 if(stateblock->renderState[WINED3DRS_SRGBWRITEENABLE])
Felix Nawothnig413b9b22007-04-03 23:38:21 +02001452 FIXME("Render state WINED3DRS_SRGBWRITEENABLE not yet implemented\n");
Stefan Dösinger8a5bf912006-12-10 23:13:38 +01001453}
1454
Stefan Dösingerc739c382007-02-12 19:18:22 +01001455static void state_seperateblend(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger92460b92006-12-10 23:14:36 +01001456 TRACE("Stub\n");
1457 if(stateblock->renderState[WINED3DRS_SEPARATEALPHABLENDENABLE])
1458 FIXME("(WINED3DRS_SEPARATEALPHABLENDENABLE,%d) not yet implemented\n", stateblock->renderState[WINED3DRS_SEPARATEALPHABLENDENABLE]);
1459}
1460
Stefan Dösingerc739c382007-02-12 19:18:22 +01001461static void state_wrapu(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingerff077ec2006-12-15 20:02:13 +01001462 if(stateblock->renderState[WINED3DRS_WRAPU]) {
1463 FIXME("Render state WINED3DRS_WRAPU not implemented yet\n");
1464 }
1465}
1466
Stefan Dösingerc739c382007-02-12 19:18:22 +01001467static void state_wrapv(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingerff077ec2006-12-15 20:02:13 +01001468 if(stateblock->renderState[WINED3DRS_WRAPV]) {
1469 FIXME("Render state WINED3DRS_WRAPV not implemented yet\n");
1470 }
1471}
1472
Stefan Dösingerc739c382007-02-12 19:18:22 +01001473static void state_monoenable(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingerff077ec2006-12-15 20:02:13 +01001474 if(stateblock->renderState[WINED3DRS_MONOENABLE]) {
1475 FIXME("Render state WINED3DRS_MONOENABLE not implemented yet\n");
1476 }
1477}
1478
Stefan Dösingerc739c382007-02-12 19:18:22 +01001479static void state_rop2(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingerff077ec2006-12-15 20:02:13 +01001480 if(stateblock->renderState[WINED3DRS_ROP2]) {
1481 FIXME("Render state WINED3DRS_ROP2 not implemented yet\n");
1482 }
1483}
1484
Stefan Dösingerc739c382007-02-12 19:18:22 +01001485static void state_planemask(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingerff077ec2006-12-15 20:02:13 +01001486 if(stateblock->renderState[WINED3DRS_PLANEMASK]) {
1487 FIXME("Render state WINED3DRS_PLANEMASK not implemented yet\n");
1488 }
1489}
1490
Stefan Dösingerc739c382007-02-12 19:18:22 +01001491static void state_subpixel(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingerff077ec2006-12-15 20:02:13 +01001492 if(stateblock->renderState[WINED3DRS_SUBPIXEL]) {
1493 FIXME("Render state WINED3DRS_SUBPIXEL not implemented yet\n");
1494 }
1495}
1496
Stefan Dösingerc739c382007-02-12 19:18:22 +01001497static void state_subpixelx(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingerff077ec2006-12-15 20:02:13 +01001498 if(stateblock->renderState[WINED3DRS_SUBPIXELX]) {
1499 FIXME("Render state WINED3DRS_SUBPIXELX not implemented yet\n");
1500 }
1501}
1502
Stefan Dösingerc739c382007-02-12 19:18:22 +01001503static void state_stippleenable(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingerff077ec2006-12-15 20:02:13 +01001504 if(stateblock->renderState[WINED3DRS_STIPPLEENABLE]) {
1505 FIXME("Render state WINED3DRS_STIPPLEENABLE not implemented yet\n");
1506 }
1507}
1508
Stefan Dösingerc739c382007-02-12 19:18:22 +01001509static void state_bordercolor(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingerff077ec2006-12-15 20:02:13 +01001510 if(stateblock->renderState[WINED3DRS_BORDERCOLOR]) {
1511 FIXME("Render state WINED3DRS_BORDERCOLOR not implemented yet\n");
1512 }
1513}
1514
Stefan Dösingerc739c382007-02-12 19:18:22 +01001515static void state_mipmaplodbias(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingerff077ec2006-12-15 20:02:13 +01001516 if(stateblock->renderState[WINED3DRS_MIPMAPLODBIAS]) {
1517 FIXME("Render state WINED3DRS_MIPMAPLODBIAS not implemented yet\n");
1518 }
1519}
1520
Stefan Dösingerc739c382007-02-12 19:18:22 +01001521static void state_anisotropy(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingerff077ec2006-12-15 20:02:13 +01001522 if(stateblock->renderState[WINED3DRS_ANISOTROPY]) {
1523 FIXME("Render state WINED3DRS_ANISOTROPY not implemented yet\n");
1524 }
1525}
1526
Stefan Dösingerc739c382007-02-12 19:18:22 +01001527static void state_flushbatch(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingerff077ec2006-12-15 20:02:13 +01001528 if(stateblock->renderState[WINED3DRS_FLUSHBATCH]) {
1529 FIXME("Render state WINED3DRS_FLUSHBATCH not implemented yet\n");
1530 }
1531}
1532
Stefan Dösingerc739c382007-02-12 19:18:22 +01001533static void state_translucentsi(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingerff077ec2006-12-15 20:02:13 +01001534 if(stateblock->renderState[WINED3DRS_TRANSLUCENTSORTINDEPENDENT]) {
1535 FIXME("Render state WINED3DRS_TRANSLUCENTSORTINDEPENDENT not implemented yet\n");
1536 }
1537}
1538
Stefan Dösingerc739c382007-02-12 19:18:22 +01001539static void state_extents(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingerff077ec2006-12-15 20:02:13 +01001540 if(stateblock->renderState[WINED3DRS_EXTENTS]) {
1541 FIXME("Render state WINED3DRS_EXTENTS not implemented yet\n");
1542 }
1543}
1544
Stefan Dösingerc739c382007-02-12 19:18:22 +01001545static void state_ckeyblend(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingerff077ec2006-12-15 20:02:13 +01001546 if(stateblock->renderState[WINED3DRS_COLORKEYBLENDENABLE]) {
1547 FIXME("Render state WINED3DRS_COLORKEYBLENDENABLE not implemented yet\n");
1548 }
1549}
1550
Stefan Dösinger762af472006-12-19 23:00:58 +01001551/* Activates the texture dimension according to the bound D3D texture.
1552 * Does not care for the colorop or correct gl texture unit(when using nvrc)
1553 * Requires the caller to activate the correct unit before
1554 */
1555static void activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock) {
1556 if(stateblock->textures[stage]) {
Stefan Dösinger762af472006-12-19 23:00:58 +01001557 switch(stateblock->textureDimensions[stage]) {
1558 case GL_TEXTURE_2D:
1559 glDisable(GL_TEXTURE_3D);
1560 checkGLcall("glDisable(GL_TEXTURE_3D)");
Felix Nawothnig335f9782007-03-28 19:17:51 +02001561 if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) {
1562 glDisable(GL_TEXTURE_CUBE_MAP_ARB);
1563 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
1564 }
Stefan Dösinger762af472006-12-19 23:00:58 +01001565 glEnable(GL_TEXTURE_2D);
1566 checkGLcall("glEnable(GL_TEXTURE_2D)");
1567 break;
1568 case GL_TEXTURE_3D:
Felix Nawothnig335f9782007-03-28 19:17:51 +02001569 if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) {
1570 glDisable(GL_TEXTURE_CUBE_MAP_ARB);
1571 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
1572 }
Stefan Dösinger762af472006-12-19 23:00:58 +01001573 glDisable(GL_TEXTURE_2D);
1574 checkGLcall("glDisable(GL_TEXTURE_2D)");
1575 glEnable(GL_TEXTURE_3D);
1576 checkGLcall("glEnable(GL_TEXTURE_3D)");
1577 break;
1578 case GL_TEXTURE_CUBE_MAP_ARB:
1579 glDisable(GL_TEXTURE_2D);
1580 checkGLcall("glDisable(GL_TEXTURE_2D)");
1581 glDisable(GL_TEXTURE_3D);
1582 checkGLcall("glDisable(GL_TEXTURE_3D)");
1583 glEnable(GL_TEXTURE_CUBE_MAP_ARB);
1584 checkGLcall("glEnable(GL_TEXTURE_CUBE_MAP_ARB)");
1585 break;
1586 }
1587 } else {
1588 glDisable(GL_TEXTURE_2D);
1589 checkGLcall("glDisable(GL_TEXTURE_2D)");
1590 glDisable(GL_TEXTURE_3D);
1591 checkGLcall("glDisable(GL_TEXTURE_3D)");
Felix Nawothnig335f9782007-03-28 19:17:51 +02001592 if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) {
1593 glDisable(GL_TEXTURE_CUBE_MAP_ARB);
1594 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
1595 }
Stefan Dösinger762af472006-12-19 23:00:58 +01001596 /* Binding textures is done by samplers. A dummy texture will be bound */
1597 }
1598}
1599
Stefan Dösingerc739c382007-02-12 19:18:22 +01001600static void tex_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger762af472006-12-19 23:00:58 +01001601 DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE;
H. Verbeet8c530332007-01-03 19:18:38 +01001602 DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[stage];
Stefan Dösinger762af472006-12-19 23:00:58 +01001603
1604 TRACE("Setting color op for stage %d\n", stage);
1605
1606 if (stateblock->pixelShader && stateblock->wineD3DDevice->ps_selected_mode != SHADER_NONE &&
1607 ((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.function) {
1608 /* Using a pixel shader? Don't care for anything here, the shader applying does it */
1609 return;
1610 }
1611
H. Verbeet8c530332007-01-03 19:18:38 +01001612 if (stage != mapped_stage) WARN("Using non 1:1 mapping: %d -> %d!\n", stage, mapped_stage);
1613
1614 if (mapped_stage != -1) {
1615 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
H. Verbeet23cd4472007-03-12 23:21:44 +01001616 if (mapped_stage >= GL_LIMITS(textures)) {
H. Verbeet8c530332007-01-03 19:18:38 +01001617 if (stateblock->textureState[stage][WINED3DTSS_COLOROP] != WINED3DTOP_DISABLE &&
1618 stateblock->textureState[stage][WINED3DTSS_COLOROP] != 0) {
1619 FIXME("Attempt to enable unsupported stage!\n");
1620 }
1621 return;
Stefan Dösinger762af472006-12-19 23:00:58 +01001622 }
H. Verbeet8c530332007-01-03 19:18:38 +01001623 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
1624 checkGLcall("glActiveTextureARB");
1625 } else if (stage > 0) {
1626 WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
Stefan Dösinger762af472006-12-19 23:00:58 +01001627 return;
1628 }
Stefan Dösinger762af472006-12-19 23:00:58 +01001629 }
1630
1631 if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
1632 if(stateblock->lowest_disabled_stage > 0) {
1633 glEnable(GL_REGISTER_COMBINERS_NV);
1634 GL_EXTCALL(glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, stateblock->lowest_disabled_stage));
1635 } else {
1636 glDisable(GL_REGISTER_COMBINERS_NV);
1637 }
1638 }
1639 if(stage >= stateblock->lowest_disabled_stage) {
1640 TRACE("Stage disabled\n");
H. Verbeet8c530332007-01-03 19:18:38 +01001641 if (mapped_stage != -1) {
1642 /* Disable everything here */
H. Verbeet8c530332007-01-03 19:18:38 +01001643 glDisable(GL_TEXTURE_2D);
1644 checkGLcall("glDisable(GL_TEXTURE_2D)");
1645 glDisable(GL_TEXTURE_3D);
1646 checkGLcall("glDisable(GL_TEXTURE_3D)");
Felix Nawothnig335f9782007-03-28 19:17:51 +02001647 if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) {
1648 glDisable(GL_TEXTURE_CUBE_MAP_ARB);
1649 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
1650 }
H. Verbeet8c530332007-01-03 19:18:38 +01001651 }
Stefan Dösinger762af472006-12-19 23:00:58 +01001652 /* All done */
1653 return;
1654 }
1655
Stefan Dösingerb07c48c2007-01-10 11:44:55 +01001656 /* The sampler will also activate the correct texture dimensions, so no need to do it here
1657 * if the sampler for this stage is dirty
1658 */
Stefan Dösinger380930d2007-02-12 19:18:31 +01001659 if(!isStateDirty(context, STATE_SAMPLER(stage))) {
Stefan Dösingerb07c48c2007-01-10 11:44:55 +01001660 if (mapped_stage != -1) activate_dimensions(stage, stateblock);
1661 }
Stefan Dösinger762af472006-12-19 23:00:58 +01001662
1663 /* Set the texture combiners */
1664 if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
1665 set_tex_op_nvrc((IWineD3DDevice *)stateblock->wineD3DDevice, FALSE, stage,
1666 stateblock->textureState[stage][WINED3DTSS_COLOROP],
1667 stateblock->textureState[stage][WINED3DTSS_COLORARG1],
1668 stateblock->textureState[stage][WINED3DTSS_COLORARG2],
1669 stateblock->textureState[stage][WINED3DTSS_COLORARG0],
H. Verbeet8c530332007-01-03 19:18:38 +01001670 mapped_stage);
Stefan Dösinger762af472006-12-19 23:00:58 +01001671 } else {
1672 set_tex_op((IWineD3DDevice *)stateblock->wineD3DDevice, FALSE, stage,
1673 stateblock->textureState[stage][WINED3DTSS_COLOROP],
1674 stateblock->textureState[stage][WINED3DTSS_COLORARG1],
1675 stateblock->textureState[stage][WINED3DTSS_COLORARG2],
1676 stateblock->textureState[stage][WINED3DTSS_COLORARG0]);
1677 }
1678}
1679
Stefan Dösingerc739c382007-02-12 19:18:22 +01001680static void tex_alphaop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingerbd6a6ad2006-12-19 23:03:37 +01001681 DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE;
H. Verbeetc7fad602007-01-03 19:18:44 +01001682 DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[stage];
Stefan Dösingerb3f96f42007-02-15 03:04:18 +01001683 DWORD op, arg1, arg2, arg0;
Stefan Dösingerbd6a6ad2006-12-19 23:03:37 +01001684
1685 TRACE("Setting alpha op for stage %d\n", stage);
1686 /* Do not care for enabled / disabled stages, just assign the settigns. colorop disables / enables required stuff */
H. Verbeetc7fad602007-01-03 19:18:44 +01001687 if (mapped_stage != -1) {
1688 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
H. Verbeet23cd4472007-03-12 23:21:44 +01001689 if (stage >= GL_LIMITS(textures)) {
H. Verbeetc7fad602007-01-03 19:18:44 +01001690 if (stateblock->textureState[stage][WINED3DTSS_COLOROP] != WINED3DTOP_DISABLE &&
1691 stateblock->textureState[stage][WINED3DTSS_COLOROP] != 0) {
1692 FIXME("Attempt to enable unsupported stage!\n");
1693 }
1694 return;
Stefan Dösingerbd6a6ad2006-12-19 23:03:37 +01001695 }
H. Verbeetc7fad602007-01-03 19:18:44 +01001696 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
1697 checkGLcall("glActiveTextureARB");
1698 } else if (stage > 0) {
1699 /* We can't do anything here */
1700 WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
Stefan Dösingerbd6a6ad2006-12-19 23:03:37 +01001701 return;
1702 }
Stefan Dösingerbd6a6ad2006-12-19 23:03:37 +01001703 }
1704
Stefan Dösingerb3f96f42007-02-15 03:04:18 +01001705 op = stateblock->textureState[stage][WINED3DTSS_ALPHAOP];
1706 arg1 = stateblock->textureState[stage][WINED3DTSS_ALPHAARG1];
1707 arg2 = stateblock->textureState[stage][WINED3DTSS_ALPHAARG2];
1708 arg0 = stateblock->textureState[stage][WINED3DTSS_ALPHAARG0];
1709
1710 if(stateblock->renderState[WINED3DRS_COLORKEYENABLE] && stage == 0 &&
1711 stateblock->textures[0] && stateblock->textureDimensions[0] == GL_TEXTURE_2D) {
1712 IWineD3DSurfaceImpl *surf = (IWineD3DSurfaceImpl *) ((IWineD3DTextureImpl *) stateblock->textures[0])->surfaces[0];
1713
Stefan Dösinger725057d2007-04-14 22:44:55 +02001714 if(surf->CKeyFlags & WINEDDSD_CKSRCBLT &&
Stefan Dösingerb3f96f42007-02-15 03:04:18 +01001715 getFormatDescEntry(surf->resource.format)->alphaMask == 0x00000000) {
1716
1717 /* Color keying needs to pass alpha values from the texture through to have the alpha test work properly.
1718 * On the other hand applications can still use texture combiners apparently. This code takes care that apps
1719 * cannot remove the texture's alpha channel entirely.
1720 *
1721 * The fixup is required for Prince of Persia 3D(prison bars), while Moto racer 2 requires D3DTOP_MODULATE to work
1722 * on color keyed surfaces.
1723 *
1724 * What to do with multitexturing? So far no app has been found that uses color keying with multitexturing
1725 */
1726 if(op == WINED3DTOP_DISABLE) op = WINED3DTOP_SELECTARG1;
1727 if(op == WINED3DTOP_SELECTARG1) arg1 = WINED3DTA_TEXTURE;
1728 else if(op == WINED3DTOP_SELECTARG2) arg2 = WINED3DTA_TEXTURE;
1729 }
1730 }
1731
Stefan Dösingerbd6a6ad2006-12-19 23:03:37 +01001732 TRACE("Setting alpha op for stage %d\n", stage);
1733 if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
1734 set_tex_op_nvrc((IWineD3DDevice *)stateblock->wineD3DDevice, TRUE, stage,
Stefan Dösingerb3f96f42007-02-15 03:04:18 +01001735 op, arg1, arg2, arg0,
H. Verbeetc7fad602007-01-03 19:18:44 +01001736 mapped_stage);
Stefan Dösingerbd6a6ad2006-12-19 23:03:37 +01001737 } else {
Stefan Dösingerb3f96f42007-02-15 03:04:18 +01001738 set_tex_op((IWineD3DDevice *)stateblock->wineD3DDevice, TRUE, stage,
1739 op, arg1, arg2, arg0);
Stefan Dösingerbd6a6ad2006-12-19 23:03:37 +01001740 }
1741}
1742
Stefan Dösingerc739c382007-02-12 19:18:22 +01001743static void transform_texture(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingerc10efb32007-01-01 23:53:59 +01001744 DWORD texUnit = state - STATE_TRANSFORM(WINED3DTS_TEXTURE0);
H. Verbeet23cd4472007-03-12 23:21:44 +01001745 DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[texUnit];
1746
1747 if (mapped_stage < 0) return;
Stefan Dösingerc10efb32007-01-01 23:53:59 +01001748
1749 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
H. Verbeet23cd4472007-03-12 23:21:44 +01001750 if(mapped_stage >= GL_LIMITS(textures)) {
Stefan Dösingerc10efb32007-01-01 23:53:59 +01001751 return;
1752 }
H. Verbeet23cd4472007-03-12 23:21:44 +01001753 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
Stefan Dösingerc10efb32007-01-01 23:53:59 +01001754 checkGLcall("glActiveTextureARB");
H. Verbeet23cd4472007-03-12 23:21:44 +01001755 } else if (mapped_stage > 0) {
Stefan Dösingerc10efb32007-01-01 23:53:59 +01001756 /* We can't do anything here */
1757 WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
1758 return;
1759 }
1760
1761 set_texture_matrix((float *)&stateblock->transforms[WINED3DTS_TEXTURE0 + texUnit].u.m[0][0],
1762 stateblock->textureState[texUnit][WINED3DTSS_TEXTURETRANSFORMFLAGS],
1763 (stateblock->textureState[texUnit][WINED3DTSS_TEXCOORDINDEX] & 0xFFFF0000) != WINED3DTSS_TCI_PASSTHRU);
1764
1765}
1766
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01001767static void loadVertexData(IWineD3DStateBlockImpl *stateblock, WineDirect3DVertexStridedData *sd);
1768
Stefan Dösingerc739c382007-02-12 19:18:22 +01001769static void tex_coordindex(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger4e531402006-12-19 23:04:16 +01001770 DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE;
H. Verbeetaced8de2007-01-03 19:18:51 +01001771 DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[stage];
1772
1773 if (mapped_stage == -1) {
1774 TRACE("No texture unit mapped to stage %d. Skipping texture coordinates.\n", stage);
1775 return;
1776 }
Stefan Dösinger4e531402006-12-19 23:04:16 +01001777
1778 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
H. Verbeet23cd4472007-03-12 23:21:44 +01001779 if(mapped_stage >= GL_LIMITS(samplers)) {
Stefan Dösinger4e531402006-12-19 23:04:16 +01001780 return;
1781 }
H. Verbeetaced8de2007-01-03 19:18:51 +01001782 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
Stefan Dösinger4e531402006-12-19 23:04:16 +01001783 checkGLcall("glActiveTextureARB");
1784 } else if (stage > 0) {
1785 /* We can't do anything here */
1786 WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
1787 return;
1788 }
1789
1790 /* Values 0-7 are indexes into the FVF tex coords - See comments in DrawPrimitive
1791 *
1792 * FIXME: From MSDN: The WINED3DTSS_TCI_* flags are mutually exclusive. If you include
1793 * one flag, you can still specify an index value, which the system uses to
1794 * determine the texture wrapping mode.
1795 * eg. SetTextureStageState( 0, WINED3DTSS_TEXCOORDINDEX, WINED3DTSS_TCI_CAMERASPACEPOSITION | 1 );
1796 * means use the vertex position (camera-space) as the input texture coordinates
1797 * for this texture stage, and the wrap mode set in the WINED3DRS_WRAP1 render
1798 * state. We do not (yet) support the WINED3DRENDERSTATE_WRAPx values, nor tie them up
1799 * to the TEXCOORDINDEX value
1800 */
1801
1802 /*
1803 * Be careful the value of the mask 0xF0000 come from d3d8types.h infos
1804 */
1805 switch (stateblock->textureState[stage][WINED3DTSS_TEXCOORDINDEX] & 0xFFFF0000) {
1806 case WINED3DTSS_TCI_PASSTHRU:
1807 /*Use the specified texture coordinates contained within the vertex format. This value resolves to zero.*/
1808 glDisable(GL_TEXTURE_GEN_S);
1809 glDisable(GL_TEXTURE_GEN_T);
1810 glDisable(GL_TEXTURE_GEN_R);
1811 glDisable(GL_TEXTURE_GEN_Q);
1812 checkGLcall("glDisable(GL_TEXTURE_GEN_S,T,R,Q)");
1813 break;
1814
1815 case WINED3DTSS_TCI_CAMERASPACEPOSITION:
1816 /* CameraSpacePosition means use the vertex position, transformed to camera space,
1817 * as the input texture coordinates for this stage's texture transformation. This
1818 * equates roughly to EYE_LINEAR
1819 */
1820 {
1821 float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
1822 float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
1823 float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
1824 float q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
1825 TRACE("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set eye plane\n");
1826
1827 glMatrixMode(GL_MODELVIEW);
1828 glPushMatrix();
1829 glLoadIdentity();
1830 glTexGenfv(GL_S, GL_EYE_PLANE, s_plane);
1831 glTexGenfv(GL_T, GL_EYE_PLANE, t_plane);
1832 glTexGenfv(GL_R, GL_EYE_PLANE, r_plane);
1833 glTexGenfv(GL_Q, GL_EYE_PLANE, q_plane);
1834 glPopMatrix();
1835
1836 TRACE("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set GL_TEXTURE_GEN_x and GL_x, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR\n");
1837 glEnable(GL_TEXTURE_GEN_S);
1838 checkGLcall("glEnable(GL_TEXTURE_GEN_S);");
1839 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
1840 checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)");
1841 glEnable(GL_TEXTURE_GEN_T);
1842 checkGLcall("glEnable(GL_TEXTURE_GEN_T);");
1843 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
1844 checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)");
1845 glEnable(GL_TEXTURE_GEN_R);
1846 checkGLcall("glEnable(GL_TEXTURE_GEN_R);");
1847 glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
1848 checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)");
1849 }
1850 break;
1851
1852 case WINED3DTSS_TCI_CAMERASPACENORMAL:
1853 {
1854 if (GL_SUPPORT(NV_TEXGEN_REFLECTION)) {
1855 float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
1856 float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
1857 float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
1858 float q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
1859 TRACE("WINED3DTSS_TCI_CAMERASPACENORMAL - Set eye plane\n");
1860
1861 glMatrixMode(GL_MODELVIEW);
1862 glPushMatrix();
1863 glLoadIdentity();
1864 glTexGenfv(GL_S, GL_EYE_PLANE, s_plane);
1865 glTexGenfv(GL_T, GL_EYE_PLANE, t_plane);
1866 glTexGenfv(GL_R, GL_EYE_PLANE, r_plane);
1867 glTexGenfv(GL_Q, GL_EYE_PLANE, q_plane);
1868 glPopMatrix();
1869
1870 glEnable(GL_TEXTURE_GEN_S);
1871 checkGLcall("glEnable(GL_TEXTURE_GEN_S);");
1872 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV);
1873 checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV)");
1874 glEnable(GL_TEXTURE_GEN_T);
1875 checkGLcall("glEnable(GL_TEXTURE_GEN_T);");
1876 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV);
1877 checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV)");
1878 glEnable(GL_TEXTURE_GEN_R);
1879 checkGLcall("glEnable(GL_TEXTURE_GEN_R);");
1880 glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV);
1881 checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_NV)");
1882 }
1883 }
1884 break;
1885
1886 case WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR:
1887 {
1888 if (GL_SUPPORT(NV_TEXGEN_REFLECTION)) {
1889 float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
1890 float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
1891 float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
1892 float q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
1893 TRACE("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Set eye plane\n");
1894
1895 glMatrixMode(GL_MODELVIEW);
1896 glPushMatrix();
1897 glLoadIdentity();
1898 glTexGenfv(GL_S, GL_EYE_PLANE, s_plane);
1899 glTexGenfv(GL_T, GL_EYE_PLANE, t_plane);
1900 glTexGenfv(GL_R, GL_EYE_PLANE, r_plane);
1901 glTexGenfv(GL_Q, GL_EYE_PLANE, q_plane);
1902 glPopMatrix();
1903
1904 glEnable(GL_TEXTURE_GEN_S);
1905 checkGLcall("glEnable(GL_TEXTURE_GEN_S);");
1906 glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV);
1907 checkGLcall("glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV)");
1908 glEnable(GL_TEXTURE_GEN_T);
1909 checkGLcall("glEnable(GL_TEXTURE_GEN_T);");
1910 glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV);
1911 checkGLcall("glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV)");
1912 glEnable(GL_TEXTURE_GEN_R);
1913 checkGLcall("glEnable(GL_TEXTURE_GEN_R);");
1914 glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV);
1915 checkGLcall("glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV)");
1916 }
1917 }
1918 break;
1919
1920 /* Unhandled types: */
1921 default:
1922 /* Todo: */
1923 /* ? disable GL_TEXTURE_GEN_n ? */
1924 glDisable(GL_TEXTURE_GEN_S);
1925 glDisable(GL_TEXTURE_GEN_T);
1926 glDisable(GL_TEXTURE_GEN_R);
1927 glDisable(GL_TEXTURE_GEN_Q);
1928 FIXME("Unhandled WINED3DTSS_TEXCOORDINDEX %x\n", stateblock->textureState[stage][WINED3DTSS_TEXCOORDINDEX]);
1929 break;
1930 }
Stefan Dösingerc10efb32007-01-01 23:53:59 +01001931
1932 /* Update the texture matrix */
Stefan Dösinger380930d2007-02-12 19:18:31 +01001933 if(!isStateDirty(context, STATE_TRANSFORM(WINED3DTS_TEXTURE0 + stage))) {
Stefan Dösingerc739c382007-02-12 19:18:22 +01001934 transform_texture(STATE_TRANSFORM(WINED3DTS_TEXTURE0 + stage), stateblock, context);
Stefan Dösingerc10efb32007-01-01 23:53:59 +01001935 }
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01001936
Stefan Dösinger380930d2007-02-12 19:18:31 +01001937 if(!isStateDirty(context, STATE_VDECL) && context->namedArraysLoaded) {
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01001938 /* Reload the arrays if we are using fixed function arrays to reflect the selected coord input
1939 * source. Call loadVertexData directly because there is no need to reparse the vertex declaration
1940 * and do all the things linked to it
1941 * TODO: Tidy that up to reload only the arrays of the changed unit
1942 */
1943 loadVertexData(stateblock, &stateblock->wineD3DDevice->strided_streams);
1944 }
Stefan Dösinger4e531402006-12-19 23:04:16 +01001945}
1946
Stefan Dösingerc739c382007-02-12 19:18:22 +01001947static void tex_bumpenvlscale(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger72a4f6e2006-12-19 23:05:08 +01001948 DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE;
1949 union {
1950 DWORD d;
1951 float f;
1952 } tmpvalue;
1953
1954 tmpvalue.d = stateblock->textureState[stage][WINED3DTSS_BUMPENVLSCALE];
1955 if(tmpvalue.f != 0.0) {
Felix Nawothnig413b9b22007-04-03 23:38:21 +02001956 FIXME("WINED3DTSS_BUMPENVLSCALE not supported yet\n");
Stefan Dösinger72a4f6e2006-12-19 23:05:08 +01001957 }
1958}
1959
Stefan Dösingerc739c382007-02-12 19:18:22 +01001960static void tex_bumpenvloffset(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger1021f642006-12-19 23:34:17 +01001961 DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE;
1962 union {
1963 DWORD d;
1964 float f;
1965 } tmpvalue;
1966
1967 tmpvalue.d = stateblock->textureState[stage][WINED3DTSS_BUMPENVLOFFSET];
1968 if(tmpvalue.f != 0.0) {
Felix Nawothnig413b9b22007-04-03 23:38:21 +02001969 FIXME("WINED3DTSS_BUMPENVLOFFSET not supported yet\n");
Stefan Dösinger1021f642006-12-19 23:34:17 +01001970 }
1971}
1972
Stefan Dösingerc739c382007-02-12 19:18:22 +01001973static void tex_resultarg(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger63a8c3c2006-12-19 23:11:21 +01001974 DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE;
1975
Stefan Dösinger60ea7602007-01-10 11:31:18 +01001976 if(stage >= GL_LIMITS(texture_stages)) {
1977 return;
1978 }
1979
H. Verbeeta2fde7d2007-02-15 13:32:13 +01001980 if(stateblock->textureState[stage][WINED3DTSS_RESULTARG] != WINED3DTA_CURRENT) {
Felix Nawothnig413b9b22007-04-03 23:38:21 +02001981 FIXME("WINED3DTSS_RESULTARG not supported yet\n");
Stefan Dösinger63a8c3c2006-12-19 23:11:21 +01001982 }
1983}
1984
Stefan Dösingerc739c382007-02-12 19:18:22 +01001985static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger666b5072006-12-19 23:26:39 +01001986 DWORD sampler = state - STATE_SAMPLER(0);
H. Verbeet7ae71a92007-01-03 19:18:59 +01001987 DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[sampler];
Stefan Dösinger197ec1c2007-01-02 00:07:55 +01001988 union {
1989 float f;
1990 DWORD d;
1991 } tmpvalue;
Stefan Dösinger666b5072006-12-19 23:26:39 +01001992
1993 TRACE("Sampler: %d\n", sampler);
1994 /* Enabling and disabling texture dimensions is done by texture stage state / pixel shader setup, this function
1995 * only has to bind textures and set the per texture states
1996 */
H. Verbeet7ae71a92007-01-03 19:18:59 +01001997
1998 if (mapped_stage == -1) {
1999 TRACE("No sampler mapped to stage %d. Returning.\n", sampler);
2000 return;
2001 }
2002
Stefan Dösinger666b5072006-12-19 23:26:39 +01002003 if (GL_SUPPORT(ARB_MULTITEXTURE)) {
H. Verbeet23cd4472007-03-12 23:21:44 +01002004 if (mapped_stage >= GL_LIMITS(samplers)) {
Stefan Dösinger666b5072006-12-19 23:26:39 +01002005 return;
2006 }
H. Verbeet7ae71a92007-01-03 19:18:59 +01002007 GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
Stefan Dösinger666b5072006-12-19 23:26:39 +01002008 checkGLcall("glActiveTextureARB");
2009 } else if (sampler > 0) {
2010 /* We can't do anything here */
2011 WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
2012 return;
2013 }
2014
2015 if(stateblock->textures[sampler]) {
Stefan Dösinger577f8db2007-01-06 18:43:08 +01002016 BOOL texIsPow2 = FALSE;
Stefan Dösingerc10efb32007-01-01 23:53:59 +01002017
Stefan Dösinger577f8db2007-01-06 18:43:08 +01002018 /* The fixed function np2 texture emulation uses the texture matrix to fix up the coordinates
2019 * IWineD3DBaseTexture::ApplyStateChanges multiplies the set matrix with a fixup matrix. Before the
2020 * scaling is reapplied or removed, the texture matrix has to be reapplied
2021 */
Stefan Dösingerb48dfb32007-02-13 20:21:48 +01002022 if(!GL_SUPPORT(ARB_TEXTURE_NON_POWER_OF_TWO) && sampler < MAX_TEXTURES) {
Stefan Dösinger577f8db2007-01-06 18:43:08 +01002023 if(stateblock->textureDimensions[sampler] == GL_TEXTURE_2D) {
2024 if(((IWineD3DTextureImpl *) stateblock->textures[sampler])->pow2scalingFactorX != 1.0 ||
2025 ((IWineD3DTextureImpl *) stateblock->textures[sampler])->pow2scalingFactorY != 1.0 ) {
2026 texIsPow2 = TRUE;
2027 }
2028 } else if(stateblock->textureDimensions[sampler] == GL_TEXTURE_CUBE_MAP_ARB) {
2029 if(((IWineD3DCubeTextureImpl *) stateblock->textures[sampler])->pow2scalingFactor != 1.0) {
2030 texIsPow2 = TRUE;
2031 }
2032 }
2033
Stefan Dösingere6c9a072007-02-12 19:18:27 +01002034 if(texIsPow2 || context->lastWasPow2Texture[sampler]) {
Stefan Dösingerc739c382007-02-12 19:18:22 +01002035 transform_texture(STATE_TRANSFORM(WINED3DTS_TEXTURE0 + stateblock->wineD3DDevice->texUnitMap[sampler]), stateblock, context);
Stefan Dösingere6c9a072007-02-12 19:18:27 +01002036 context->lastWasPow2Texture[sampler] = texIsPow2;
Stefan Dösinger577f8db2007-01-06 18:43:08 +01002037 }
Stefan Dösingerc10efb32007-01-01 23:53:59 +01002038 }
2039
Stefan Dösinger666b5072006-12-19 23:26:39 +01002040 IWineD3DBaseTexture_PreLoad((IWineD3DBaseTexture *) stateblock->textures[sampler]);
Stefan Dösinger666b5072006-12-19 23:26:39 +01002041 IWineD3DBaseTexture_ApplyStateChanges(stateblock->textures[sampler], stateblock->textureState[sampler], stateblock->samplerState[sampler]);
2042
Stefan Dösinger197ec1c2007-01-02 00:07:55 +01002043 if (GL_SUPPORT(EXT_TEXTURE_LOD_BIAS)) {
2044 tmpvalue.d = stateblock->samplerState[sampler][WINED3DSAMP_MIPMAPLODBIAS];
2045 glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT,
2046 GL_TEXTURE_LOD_BIAS_EXT,
2047 tmpvalue.f);
2048 checkGLcall("glTexEnvi GL_TEXTURE_LOD_BIAS_EXT ...");
2049 }
2050
Stefan Dösinger666b5072006-12-19 23:26:39 +01002051 if (stateblock->wineD3DDevice->ps_selected_mode != SHADER_NONE && stateblock->pixelShader &&
2052 ((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.function) {
2053 /* Using a pixel shader? Verify the sampler types */
2054
2055 /* Make sure that the texture dimensions are enabled. I don't have to disable the other
2056 * dimensions because the shader knows from which texture type to sample from. For the sake of
2057 * debugging all dimensions could be enabled and a texture with some ugly pink bound to the unused
2058 * dimensions. This should make wrong sampling sources visible :-)
2059 */
2060 glEnable(stateblock->textureDimensions[sampler]);
2061 checkGLcall("glEnable(stateblock->textureDimensions[sampler])");
2062 } else if(sampler < stateblock->lowest_disabled_stage) {
Stefan Dösinger380930d2007-02-12 19:18:31 +01002063 if(!isStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3DTSS_COLOROP))) {
Stefan Dösingerb07c48c2007-01-10 11:44:55 +01002064 activate_dimensions(sampler, stateblock);
2065 }
Stefan Dösinger666b5072006-12-19 23:26:39 +01002066
2067 if(stateblock->renderState[WINED3DRS_COLORKEYENABLE] && sampler == 0) {
Francois Gougetbbb2b7f2007-01-04 10:47:11 +01002068 /* If color keying is enabled update the alpha test, it depends on the existence
Stefan Dösinger666b5072006-12-19 23:26:39 +01002069 * of a color key in stage 0
2070 */
Stefan Dösingerc739c382007-02-12 19:18:22 +01002071 state_alpha(WINED3DRS_COLORKEYENABLE, stateblock, context);
Stefan Dösinger666b5072006-12-19 23:26:39 +01002072 }
2073 }
2074 } else if(sampler < GL_LIMITS(texture_stages)) {
2075 if(sampler < stateblock->lowest_disabled_stage) {
Stefan Dösingerb07c48c2007-01-10 11:44:55 +01002076 /* TODO: What should I do with pixel shaders here ??? */
Stefan Dösinger380930d2007-02-12 19:18:31 +01002077 if(!isStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3DTSS_COLOROP))) {
Stefan Dösingerb07c48c2007-01-10 11:44:55 +01002078 activate_dimensions(sampler, stateblock);
2079 }
Stefan Dösinger666b5072006-12-19 23:26:39 +01002080 } /* Otherwise tex_colorop disables the stage */
Felix Nawothnig18c9e5d2007-03-29 18:45:04 +02002081 glBindTexture(GL_TEXTURE_2D, stateblock->wineD3DDevice->dummyTextureName[sampler]);
2082 checkGLcall("glBindTexture(GL_TEXTURE_2D, stateblock->wineD3DDevice->dummyTextureName[sampler])");
Stefan Dösinger666b5072006-12-19 23:26:39 +01002083 }
2084}
2085
Stefan Dösingerc739c382007-02-12 19:18:22 +01002086static void shaderconstant(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger8e37fcd2007-01-06 18:17:27 +01002087 IWineD3DDeviceImpl *device = stateblock->wineD3DDevice;
2088
2089 /* Vertex and pixel shader states will call a shader upload, don't do anything as long one of them
2090 * has an update pending
2091 */
Stefan Dösinger380930d2007-02-12 19:18:31 +01002092 if(isStateDirty(context, STATE_VDECL) ||
2093 isStateDirty(context, STATE_PIXELSHADER)) {
Stefan Dösinger8e37fcd2007-01-06 18:17:27 +01002094 return;
2095 }
2096
H. Verbeet30ee0712007-03-12 23:22:00 +01002097 device->shader_backend->shader_load_constants((IWineD3DDevice *) device, use_ps(device), use_vs(device));
Stefan Dösinger8e37fcd2007-01-06 18:17:27 +01002098}
2099
Stefan Dösingerc739c382007-02-12 19:18:22 +01002100static void pixelshader(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
H. Verbeet30ee0712007-03-12 23:22:00 +01002101 IWineD3DDeviceImpl *device = stateblock->wineD3DDevice;
2102 BOOL use_pshader = use_ps(device);
2103 BOOL use_vshader = use_vs(device);
Fabian Bieler7cedd562007-03-22 17:32:48 +01002104 BOOL update_fog = FALSE;
Stefan Dösinger22e2a5a2006-12-19 23:22:19 +01002105 int i;
2106
H. Verbeet30ee0712007-03-12 23:22:00 +01002107 if (use_pshader) {
Stefan Dösingere6c9a072007-02-12 19:18:27 +01002108 if(!context->last_was_pshader) {
Stefan Dösinger22e2a5a2006-12-19 23:22:19 +01002109 /* Former draw without a pixel shader, some samplers
2110 * may be disabled because of WINED3DTSS_COLOROP = WINED3DTOP_DISABLE
2111 * make sure to enable them
2112 */
2113 for(i=0; i < MAX_SAMPLERS; i++) {
Stefan Dösinger380930d2007-02-12 19:18:31 +01002114 if(!isStateDirty(context, STATE_SAMPLER(i))) {
Stefan Dösingerc739c382007-02-12 19:18:22 +01002115 sampler(STATE_SAMPLER(i), stateblock, context);
Stefan Dösinger22e2a5a2006-12-19 23:22:19 +01002116 }
2117 }
Fabian Bieler7cedd562007-03-22 17:32:48 +01002118 update_fog = TRUE;
Stefan Dösinger22e2a5a2006-12-19 23:22:19 +01002119 } else {
2120 /* Otherwise all samplers were activated by the code above in earlier draws, or by sampler()
2121 * if a different texture was bound. I don't have to do anything.
2122 */
2123 }
2124
2125 /* Compile and bind the shader */
2126 IWineD3DPixelShader_CompileShader(stateblock->pixelShader);
Stefan Dösinger22e2a5a2006-12-19 23:22:19 +01002127 } else {
2128 /* Disabled the pixel shader - color ops weren't applied
2129 * while it was enabled, so re-apply them.
2130 */
2131 for(i=0; i < MAX_TEXTURES; i++) {
Stefan Dösinger380930d2007-02-12 19:18:31 +01002132 if(!isStateDirty(context, STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP))) {
Stefan Dösingerc739c382007-02-12 19:18:22 +01002133 tex_colorop(STATE_TEXTURESTAGE(i, WINED3DTSS_COLOROP), stateblock, context);
Stefan Dösinger22e2a5a2006-12-19 23:22:19 +01002134 }
2135 }
Fabian Bieler7cedd562007-03-22 17:32:48 +01002136 if(context->last_was_pshader)
2137 update_fog = TRUE;
H. Verbeet2a309f52007-02-13 19:53:20 +01002138 }
Stefan Dösinger22e2a5a2006-12-19 23:22:19 +01002139
H. Verbeet2a309f52007-02-13 19:53:20 +01002140 if(!isStateDirty(context, StateTable[STATE_VSHADER].representative)) {
H. Verbeet30ee0712007-03-12 23:22:00 +01002141 device->shader_backend->shader_select((IWineD3DDevice *)stateblock->wineD3DDevice, use_pshader, use_vshader);
Stefan Dösinger8e37fcd2007-01-06 18:17:27 +01002142
H. Verbeet30ee0712007-03-12 23:22:00 +01002143 if (!isStateDirty(context, STATE_VERTEXSHADERCONSTANT) && (use_vshader || use_pshader)) {
H. Verbeet2a309f52007-02-13 19:53:20 +01002144 shaderconstant(STATE_VERTEXSHADERCONSTANT, stateblock, context);
Stefan Dösinger799770b2007-01-06 18:14:12 +01002145 }
Stefan Dösinger22e2a5a2006-12-19 23:22:19 +01002146 }
H. Verbeet2a309f52007-02-13 19:53:20 +01002147
Fabian Bieler7cedd562007-03-22 17:32:48 +01002148 if(update_fog)
2149 state_fog(state, stateblock, context);
2150
H. Verbeet30ee0712007-03-12 23:22:00 +01002151 context->last_was_pshader = use_pshader;
Stefan Dösinger22e2a5a2006-12-19 23:22:19 +01002152}
2153
Stefan Dösingerefbd6d62007-02-15 02:57:49 +01002154static void tex_bumpenvmat(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger49a49fc2007-02-15 03:05:17 +01002155 DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE;
2156
2157 if(stateblock->pixelShader && stage != 0 &&
2158 ((IWineD3DPixelShaderImpl *) stateblock->pixelShader)->needsbumpmat == stage) {
2159 /* The pixel shader has to know the bump env matrix. Do a constants update if it isn't scheduled
2160 * anyway
2161 */
2162 if(!isStateDirty(context, STATE_PIXELSHADERCONSTANT) &&
2163 !isStateDirty(context, STATE_PIXELSHADER)) {
2164 shaderconstant(STATE_PIXELSHADERCONSTANT, stateblock, context);
2165 }
2166 }
Stefan Dösingerefbd6d62007-02-15 02:57:49 +01002167}
2168
Stefan Dösingerc739c382007-02-12 19:18:22 +01002169static void transform_world(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingere26e3ee2007-01-02 22:52:11 +01002170 /* This function is called by transform_view below if the view matrix was changed too
2171 *
2172 * Deliberately no check if the vertex declaration is dirty because the vdecl state
2173 * does not always update the world matrix, only on a switch between transformed
2174 * and untrannsformed draws. It *may* happen that the world matrix is set 2 times during one
2175 * draw, but that should be rather rare and cheaper in total.
Stefan Dösinger5fa0f7f2007-01-02 22:47:39 +01002176 */
Stefan Dösinger5fa0f7f2007-01-02 22:47:39 +01002177 glMatrixMode(GL_MODELVIEW);
2178 checkGLcall("glMatrixMode");
2179
Stefan Dösingere6c9a072007-02-12 19:18:27 +01002180 if(context->last_was_rhw) {
Stefan Dösingere26e3ee2007-01-02 22:52:11 +01002181 glLoadIdentity();
2182 checkGLcall("glLoadIdentity()");
Stefan Dösinger5fa0f7f2007-01-02 22:47:39 +01002183 } else {
Stefan Dösingere26e3ee2007-01-02 22:52:11 +01002184 /* In the general case, the view matrix is the identity matrix */
2185 if (stateblock->wineD3DDevice->view_ident) {
2186 glLoadMatrixf((float *) &stateblock->transforms[WINED3DTS_WORLDMATRIX(0)].u.m[0][0]);
2187 checkGLcall("glLoadMatrixf");
2188 } else {
2189 glLoadMatrixf((float *) &stateblock->transforms[WINED3DTS_VIEW].u.m[0][0]);
2190 checkGLcall("glLoadMatrixf");
2191 glMultMatrixf((float *) &stateblock->transforms[WINED3DTS_WORLDMATRIX(0)].u.m[0][0]);
2192 checkGLcall("glMultMatrixf");
2193 }
Stefan Dösinger5fa0f7f2007-01-02 22:47:39 +01002194 }
2195}
2196
Stefan Dösinger409aa732007-02-28 14:36:36 +01002197static void clipplane(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
2198 UINT index = state - STATE_CLIPPLANE(0);
2199
H. Verbeet3aaabf42007-03-02 14:58:40 +01002200 if(isStateDirty(context, STATE_TRANSFORM(WINED3DTS_VIEW)) || index >= GL_LIMITS(clipplanes)) {
Stefan Dösinger409aa732007-02-28 14:36:36 +01002201 return;
2202 }
2203
2204 /* Clip Plane settings are affected by the model view in OpenGL, the View transform in direct3d */
2205 glMatrixMode(GL_MODELVIEW);
2206 glPushMatrix();
2207 glLoadMatrixf((float *) &stateblock->transforms[WINED3DTS_VIEW].u.m[0][0]);
2208
2209 TRACE("Clipplane [%f,%f,%f,%f]\n",
2210 stateblock->clipplane[index][0],
2211 stateblock->clipplane[index][1],
2212 stateblock->clipplane[index][2],
2213 stateblock->clipplane[index][3]);
2214 glClipPlane(GL_CLIP_PLANE0 + index, stateblock->clipplane[index]);
2215 checkGLcall("glClipPlane");
2216
2217 glPopMatrix();
2218}
2219
Stefan Dösingerc739c382007-02-12 19:18:22 +01002220static void transform_view(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingerf5fafab2007-01-02 00:48:58 +01002221 unsigned int k;
2222
2223 /* If we are changing the View matrix, reset the light and clipping planes to the new view
2224 * NOTE: We have to reset the positions even if the light/plane is not currently
2225 * enabled, since the call to enable it will not reset the position.
2226 * NOTE2: Apparently texture transforms do NOT need reapplying
2227 */
2228
Stefan Dösingeracadf3f2007-02-14 17:46:54 +01002229 PLIGHTINFOEL *light = NULL;
Stefan Dösingerf5fafab2007-01-02 00:48:58 +01002230
2231 glMatrixMode(GL_MODELVIEW);
2232 checkGLcall("glMatrixMode(GL_MODELVIEW)");
Stefan Dösingerf5fafab2007-01-02 00:48:58 +01002233 glLoadMatrixf((float *)(float *) &stateblock->transforms[WINED3DTS_VIEW].u.m[0][0]);
2234 checkGLcall("glLoadMatrixf(...)");
2235
2236 /* Reset lights. TODO: Call light apply func */
Stefan Dösingeracadf3f2007-02-14 17:46:54 +01002237 for(k = 0; k < stateblock->wineD3DDevice->maxConcurrentLights; k++) {
2238 light = stateblock->activeLights[k];
2239 if(!light) continue;
2240 glLightfv(GL_LIGHT0 + light->glIndex, GL_POSITION, light->lightPosn);
Stefan Dösingerf5fafab2007-01-02 00:48:58 +01002241 checkGLcall("glLightfv posn");
Stefan Dösingeracadf3f2007-02-14 17:46:54 +01002242 glLightfv(GL_LIGHT0 + light->glIndex, GL_SPOT_DIRECTION, light->lightDirn);
Stefan Dösingerf5fafab2007-01-02 00:48:58 +01002243 checkGLcall("glLightfv dirn");
Stefan Dösingerf5fafab2007-01-02 00:48:58 +01002244 }
2245
Stefan Dösinger409aa732007-02-28 14:36:36 +01002246 /* Reset Clipping Planes */
Stefan Dösingerf5fafab2007-01-02 00:48:58 +01002247 for (k = 0; k < GL_LIMITS(clipplanes); k++) {
Stefan Dösinger409aa732007-02-28 14:36:36 +01002248 if(!isStateDirty(context, STATE_CLIPPLANE(k))) {
2249 clipplane(STATE_CLIPPLANE(k), stateblock, context);
2250 }
Stefan Dösingerf5fafab2007-01-02 00:48:58 +01002251 }
Stefan Dösinger20de2002007-01-02 22:47:10 +01002252
Stefan Dösingere6c9a072007-02-12 19:18:27 +01002253 if(context->last_was_rhw) {
Stefan Dösinger5fa0f7f2007-01-02 22:47:39 +01002254 glLoadIdentity();
2255 checkGLcall("glLoadIdentity()");
2256 /* No need to update the world matrix, the identity is fine */
2257 return;
2258 }
2259
2260 /* Call the world matrix state, this will apply the combined WORLD + VIEW matrix
2261 * No need to do it here if the state is scheduled for update.
2262 */
Stefan Dösinger380930d2007-02-12 19:18:31 +01002263 if(!isStateDirty(context, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)))) {
Stefan Dösingerc739c382007-02-12 19:18:22 +01002264 transform_world(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), stateblock, context);
Stefan Dösinger5fa0f7f2007-01-02 22:47:39 +01002265 }
Stefan Dösingerf5fafab2007-01-02 00:48:58 +01002266}
2267
Stefan Dösingerc739c382007-02-12 19:18:22 +01002268static void transform_worldex(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösingerfe6165d2007-01-10 11:37:03 +01002269 WARN("World matrix 1 - 255 not supported yet\n");
Stefan Dösingera710f722007-01-02 00:25:51 +01002270}
2271
Stefan Dösinger20de2002007-01-02 22:47:10 +01002272static const GLfloat invymat[16] = {
2273 1.0f, 0.0f, 0.0f, 0.0f,
2274 0.0f, -1.0f, 0.0f, 0.0f,
2275 0.0f, 0.0f, 1.0f, 0.0f,
2276 0.0f, 0.0f, 0.0f, 1.0f};
2277
Stefan Dösingerc739c382007-02-12 19:18:22 +01002278static void transform_projection(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger82bd0792007-01-02 22:50:38 +01002279 glMatrixMode(GL_PROJECTION);
2280 checkGLcall("glMatrixMode(GL_PROJECTION)");
2281 glLoadIdentity();
2282 checkGLcall("glLoadIdentity");
2283
Stefan Dösingere6c9a072007-02-12 19:18:27 +01002284 if(context->last_was_rhw) {
Stefan Dösinger82bd0792007-01-02 22:50:38 +01002285 double X, Y, height, width, minZ, maxZ;
2286
2287 X = stateblock->viewport.X;
2288 Y = stateblock->viewport.Y;
2289 height = stateblock->viewport.Height;
2290 width = stateblock->viewport.Width;
2291 minZ = stateblock->viewport.MinZ;
2292 maxZ = stateblock->viewport.MaxZ;
2293
2294 if(!stateblock->wineD3DDevice->untransformed) {
2295 /* Transformed vertices are supposed to bypass the whole transform pipeline including
2296 * frustum clipping. This can't be done in opengl, so this code adjusts the Z range to
2297 * suppress depth clipping. This can be done because it is an orthogonal projection and
2298 * the Z coordinate does not affect the size of the primitives
2299 */
2300 TRACE("Calling glOrtho with %f, %f, %f, %f\n", width, height, -minZ, -maxZ);
Stefan Dösinger2cdced82007-03-03 02:35:17 +01002301 if(stateblock->wineD3DDevice->render_offscreen) {
Stefan Dösingere0a271e2007-03-03 13:51:43 +01002302 glOrtho(X, X + width, -Y, -Y - height, -minZ, -maxZ);
Stefan Dösinger2cdced82007-03-03 02:35:17 +01002303 } else {
2304 glOrtho(X, X + width, Y + height, Y, -minZ, -maxZ);
2305 }
Stefan Dösinger82bd0792007-01-02 22:50:38 +01002306 } else {
2307 /* If the app mixes transformed and untransformed primitives we can't use the coordinate system
2308 * trick above because this would mess up transformed and untransformed Z order. Pass the z position
2309 * unmodified to opengl.
2310 *
2311 * If the app depends on mixed types and disabled clipping we're out of luck without a pipeline
2312 * replacement shader.
2313 */
2314 TRACE("Calling glOrtho with %f, %f, %f, %f\n", width, height, 1.0, -1.0);
Stefan Dösinger2cdced82007-03-03 02:35:17 +01002315 if(stateblock->wineD3DDevice->render_offscreen) {
Stefan Dösingere0a271e2007-03-03 13:51:43 +01002316 glOrtho(X, X + width, -Y, -Y - height, 1.0, -1.0);
Stefan Dösinger2cdced82007-03-03 02:35:17 +01002317 } else {
2318 glOrtho(X, X + width, Y + height, Y, 1.0, -1.0);
2319 }
Stefan Dösinger82bd0792007-01-02 22:50:38 +01002320 }
2321 checkGLcall("glOrtho");
2322
2323 /* Window Coord 0 is the middle of the first pixel, so translate by 3/8 pixels */
2324 glTranslatef(0.375, 0.375, 0);
2325 checkGLcall("glTranslatef(0.375, 0.375, 0)");
2326 /* D3D texture coordinates are flipped compared to OpenGL ones, so
2327 * render everything upside down when rendering offscreen. */
2328 if (stateblock->wineD3DDevice->render_offscreen) {
2329 glMultMatrixf(invymat);
2330 checkGLcall("glMultMatrixf(invymat)");
2331 }
2332 } else {
2333 /* The rule is that the window coordinate 0 does not correspond to the
2334 beginning of the first pixel, but the center of the first pixel.
2335 As a consequence if you want to correctly draw one line exactly from
2336 the left to the right end of the viewport (with all matrices set to
2337 be identity), the x coords of both ends of the line would be not
2338 -1 and 1 respectively but (-1-1/viewport_widh) and (1-1/viewport_width)
2339 instead. */
2340 glTranslatef(0.9 / stateblock->viewport.Width, -0.9 / stateblock->viewport.Height, 0);
2341 checkGLcall("glTranslatef (0.9 / width, -0.9 / height, 0)");
2342
2343 /* D3D texture coordinates are flipped compared to OpenGL ones, so
2344 * render everything upside down when rendering offscreen. */
2345 if (stateblock->wineD3DDevice->render_offscreen) {
2346 glMultMatrixf(invymat);
2347 checkGLcall("glMultMatrixf(invymat)");
2348 }
2349 glMultMatrixf((float *) &stateblock->transforms[WINED3DTS_PROJECTION].u.m[0][0]);
2350 checkGLcall("glLoadMatrixf");
2351 }
2352}
2353
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002354/* This should match any arrays loaded in loadVertexData.
2355 * stateblock impl is required for GL_SUPPORT
2356 * TODO: Only load / unload arrays if we have to.
2357 */
2358static inline void unloadVertexData(IWineD3DStateBlockImpl *stateblock) {
2359 int texture_idx;
2360
2361 glDisableClientState(GL_VERTEX_ARRAY);
2362 glDisableClientState(GL_NORMAL_ARRAY);
2363 glDisableClientState(GL_COLOR_ARRAY);
2364 if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
2365 glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
2366 }
2367 for (texture_idx = 0; texture_idx < GL_LIMITS(textures); ++texture_idx) {
2368 GL_EXTCALL(glClientActiveTextureARB(GL_TEXTURE0_ARB + texture_idx));
2369 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
2370 }
2371}
2372
2373/* This should match any arrays loaded in loadNumberedArrays
2374 * TODO: Only load / unload arrays if we have to.
2375 */
2376static inline void unloadNumberedArrays(IWineD3DStateBlockImpl *stateblock) {
2377 /* disable any attribs (this is the same for both GLSL and ARB modes) */
2378 GLint maxAttribs;
2379 int i;
2380
2381 /* Leave all the attribs disabled */
2382 glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB, &maxAttribs);
2383 /* MESA does not support it right not */
2384 if (glGetError() != GL_NO_ERROR)
2385 maxAttribs = 16;
2386 for (i = 0; i < maxAttribs; ++i) {
2387 GL_EXTCALL(glDisableVertexAttribArrayARB(i));
2388 checkGLcall("glDisableVertexAttribArrayARB(reg);");
2389 }
2390}
2391
2392static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock, WineDirect3DVertexStridedData *strided) {
2393 GLint curVBO = GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT) ? -1 : 0;
2394 int i;
Stefan Dösinger354fdae2007-01-17 00:06:34 +01002395 UINT *offset = stateblock->streamOffset;
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002396
Stefan Dösinger0feddcc2007-02-14 17:56:29 +01002397 /* Default to no instancing */
2398 stateblock->wineD3DDevice->instancedDraw = FALSE;
2399
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002400 for (i = 0; i < MAX_ATTRIBS; i++) {
2401
2402 if (!strided->u.input[i].lpData && !strided->u.input[i].VBO)
2403 continue;
2404
Stefan Dösinger0feddcc2007-02-14 17:56:29 +01002405 /* Do not load instance data. It will be specified using glTexCoord by drawprim */
H. Verbeet498f9c52007-02-14 23:30:16 +01002406 if(stateblock->streamFlags[strided->u.input[i].streamNo] & WINED3DSTREAMSOURCE_INSTANCEDATA) {
Stefan Dösinger0feddcc2007-02-14 17:56:29 +01002407 GL_EXTCALL(glDisableVertexAttribArrayARB(i));
2408 stateblock->wineD3DDevice->instancedDraw = TRUE;
2409 continue;
2410 }
2411
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002412 TRACE_(d3d_shader)("Loading array %u [VBO=%u]\n", i, strided->u.input[i].VBO);
2413
Stefan Dösinger93cd7ef2007-02-14 17:55:56 +01002414 if(strided->u.input[i].dwStride) {
2415 if(curVBO != strided->u.input[i].VBO) {
2416 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, strided->u.input[i].VBO));
2417 checkGLcall("glBindBufferARB");
2418 curVBO = strided->u.input[i].VBO;
2419 }
2420 GL_EXTCALL(glVertexAttribPointerARB(i,
2421 WINED3D_ATR_SIZE(strided->u.input[i].dwType),
2422 WINED3D_ATR_GLTYPE(strided->u.input[i].dwType),
2423 WINED3D_ATR_NORMALIZED(strided->u.input[i].dwType),
2424 strided->u.input[i].dwStride,
2425 strided->u.input[i].lpData + stateblock->loadBaseVertexIndex * strided->u.input[i].dwStride + offset[strided->u.input[i].streamNo]) );
2426 GL_EXTCALL(glEnableVertexAttribArrayARB(i));
2427 } else {
2428 /* Stride = 0 means always the same values. glVertexAttribPointerARB doesn't do that. Instead disable the pointer and
2429 * set up the attribute statically. But we have to figure out the system memory address.
2430 */
2431 BYTE *ptr = strided->u.input[i].lpData + offset[strided->u.input[i].streamNo];
2432 if(strided->u.input[i].VBO) {
2433 IWineD3DVertexBufferImpl *vb = (IWineD3DVertexBufferImpl *) stateblock->streamSource[strided->u.input[i].streamNo];
2434 ptr += (long) vb->resource.allocatedMemory;
2435 }
2436 GL_EXTCALL(glDisableVertexAttribArrayARB(i));
2437
2438 switch(strided->u.input[i].dwType) {
2439 case WINED3DDECLTYPE_FLOAT1:
2440 GL_EXTCALL(glVertexAttrib1fvARB(i, (float *) ptr));
2441 break;
2442 case WINED3DDECLTYPE_FLOAT2:
2443 GL_EXTCALL(glVertexAttrib2fvARB(i, (float *) ptr));
2444 break;
2445 case WINED3DDECLTYPE_FLOAT3:
2446 GL_EXTCALL(glVertexAttrib3fvARB(i, (float *) ptr));
2447 break;
2448 case WINED3DDECLTYPE_FLOAT4:
2449 GL_EXTCALL(glVertexAttrib4fvARB(i, (float *) ptr));
2450 break;
2451
2452 case WINED3DDECLTYPE_UBYTE4:
2453 GL_EXTCALL(glVertexAttrib4NubvARB(i, ptr));
2454 break;
2455 case WINED3DDECLTYPE_UBYTE4N:
2456 case WINED3DDECLTYPE_D3DCOLOR:
2457 GL_EXTCALL(glVertexAttrib4NubvARB(i, ptr));
2458 break;
2459
2460 case WINED3DDECLTYPE_SHORT2:
2461 GL_EXTCALL(glVertexAttrib4svARB(i, (GLshort *) ptr));
2462 break;
2463 case WINED3DDECLTYPE_SHORT4:
2464 GL_EXTCALL(glVertexAttrib4svARB(i, (GLshort *) ptr));
2465 break;
2466
2467 case WINED3DDECLTYPE_SHORT2N:
2468 {
2469 GLshort s[4] = {((short *) ptr)[0], ((short *) ptr)[1], 0, 1};
2470 GL_EXTCALL(glVertexAttrib4NsvARB(i, s));
2471 break;
2472 }
2473 case WINED3DDECLTYPE_USHORT2N:
2474 {
2475 GLushort s[4] = {((unsigned short *) ptr)[0], ((unsigned short *) ptr)[1], 0, 1};
2476 GL_EXTCALL(glVertexAttrib4NusvARB(i, s));
2477 break;
2478 }
2479 case WINED3DDECLTYPE_SHORT4N:
2480 GL_EXTCALL(glVertexAttrib4NsvARB(i, (GLshort *) ptr));
2481 break;
2482 case WINED3DDECLTYPE_USHORT4N:
2483 GL_EXTCALL(glVertexAttrib4NusvARB(i, (GLushort *) ptr));
2484 break;
2485
2486 case WINED3DDECLTYPE_UDEC3:
2487 FIXME("Unsure about WINED3DDECLTYPE_UDEC3\n");
Stefan Dösinger0feddcc2007-02-14 17:56:29 +01002488 /*glVertexAttrib3usvARB(i, (GLushort *) ptr); Does not exist */
Stefan Dösinger93cd7ef2007-02-14 17:55:56 +01002489 break;
2490 case WINED3DDECLTYPE_DEC3N:
2491 FIXME("Unsure about WINED3DDECLTYPE_DEC3N\n");
Stefan Dösinger0feddcc2007-02-14 17:56:29 +01002492 /*glVertexAttrib3NusvARB(i, (GLushort *) ptr); Does not exist */
Stefan Dösinger93cd7ef2007-02-14 17:55:56 +01002493 break;
2494
2495 case WINED3DDECLTYPE_FLOAT16_2:
2496 /* Are those 16 bit floats. C doesn't have a 16 bit float type. I could read the single bits and calculate a 4
2497 * byte float according to the IEEE standard
2498 */
2499 FIXME("Unsupported WINED3DDECLTYPE_FLOAT16_2\n");
2500 break;
2501 case WINED3DDECLTYPE_FLOAT16_4:
2502 FIXME("Unsupported WINED3DDECLTYPE_FLOAT16_4\n");
2503 break;
2504
2505 case WINED3DDECLTYPE_UNUSED:
2506 default:
2507 ERR("Unexpected declaration in stride 0 attributes\n");
2508 break;
2509
2510 }
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002511 }
Stefan Dösinger93cd7ef2007-02-14 17:55:56 +01002512 }
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002513}
2514
2515/* Used from 2 different functions, and too big to justify making it inlined */
2516static void loadVertexData(IWineD3DStateBlockImpl *stateblock, WineDirect3DVertexStridedData *sd) {
2517 unsigned int textureNo = 0;
Stefan Dösinger354fdae2007-01-17 00:06:34 +01002518 UINT *offset = stateblock->streamOffset;
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002519 GLint curVBO = GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT) ? -1 : 0;
Stefan Dösinger65c44702007-03-16 22:02:12 +01002520 unsigned int mapped_stage = 0;
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002521
2522 TRACE("Using fast vertex array code\n");
Stefan Dösinger0feddcc2007-02-14 17:56:29 +01002523
2524 /* This is fixed function pipeline only, and the fixed function pipeline doesn't do instancing */
2525 stateblock->wineD3DDevice->instancedDraw = FALSE;
2526
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002527 /* Blend Data ---------------------------------------------- */
2528 if( (sd->u.s.blendWeights.lpData) || (sd->u.s.blendWeights.VBO) ||
2529 (sd->u.s.blendMatrixIndices.lpData) || (sd->u.s.blendMatrixIndices.VBO) ) {
2530
2531
2532 if (GL_SUPPORT(ARB_VERTEX_BLEND)) {
2533
2534#if 1
2535 glEnableClientState(GL_WEIGHT_ARRAY_ARB);
2536 checkGLcall("glEnableClientState(GL_WEIGHT_ARRAY_ARB)");
2537#endif
2538
2539 TRACE("Blend %d %p %d\n", WINED3D_ATR_SIZE(sd->u.s.blendWeights.dwType),
Stefan Dösinger354fdae2007-01-17 00:06:34 +01002540 sd->u.s.blendWeights.lpData + stateblock->loadBaseVertexIndex * sd->u.s.blendWeights.dwStride, sd->u.s.blendWeights.dwStride + offset[sd->u.s.blendWeights.streamNo]);
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002541 /* FIXME("TODO\n");*/
2542 /* Note dwType == float3 or float4 == 2 or 3 */
2543
2544#if 0
2545 /* with this on, the normals appear to be being modified,
2546 but the vertices aren't being translated as they should be
2547 Maybe the world matrix aren't being setup properly? */
2548 glVertexBlendARB(WINED3D_ATR_SIZE(sd->u.s.blendWeights.dwType) + 1);
2549#endif
2550
2551
2552 VTRACE(("glWeightPointerARB(%d, GL_FLOAT, %d, %p)\n",
2553 WINED3D_ATR_SIZE(sd->u.s.blendWeights.dwType) ,
2554 sd->u.s.blendWeights.dwStride,
Stefan Dösinger354fdae2007-01-17 00:06:34 +01002555 sd->u.s.blendWeights.lpData + stateblock->loadBaseVertexIndex * sd->u.s.blendWeights.dwStride + offset[sd->u.s.blendWeights.streamNo]));
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002556
2557 if(curVBO != sd->u.s.blendWeights.VBO) {
2558 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, sd->u.s.blendWeights.VBO));
2559 checkGLcall("glBindBufferARB");
2560 curVBO = sd->u.s.blendWeights.VBO;
2561 }
2562
2563 GL_EXTCALL(glWeightPointerARB)(
2564 WINED3D_ATR_SIZE(sd->u.s.blendWeights.dwType),
2565 WINED3D_ATR_GLTYPE(sd->u.s.blendWeights.dwType),
2566 sd->u.s.blendWeights.dwStride,
Stefan Dösinger354fdae2007-01-17 00:06:34 +01002567 sd->u.s.blendWeights.lpData + stateblock->loadBaseVertexIndex * sd->u.s.blendWeights.dwStride + offset[sd->u.s.blendWeights.streamNo]);
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002568
2569 checkGLcall("glWeightPointerARB");
2570
2571 if((sd->u.s.blendMatrixIndices.lpData) || (sd->u.s.blendMatrixIndices.VBO)){
2572 static BOOL showfixme = TRUE;
2573 if(showfixme){
2574 FIXME("blendMatrixIndices support\n");
2575 showfixme = FALSE;
2576 }
2577 }
2578
2579 } else if (GL_SUPPORT(EXT_VERTEX_WEIGHTING)) {
2580 /* FIXME("TODO\n");*/
2581#if 0
2582
2583 GL_EXTCALL(glVertexWeightPointerEXT)(
2584 WINED3D_ATR_SIZE(sd->u.s.blendWeights.dwType),
2585 WINED3D_ATR_GLTYPE(sd->u.s.blendWeights.dwType),
2586 sd->u.s.blendWeights.dwStride,
Stefan Dösinger09ab8122007-01-06 18:19:55 +01002587 sd->u.s.blendWeights.lpData + stateblock->loadBaseVertexIndex * sd->u.s.blendWeights.dwStride);
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002588 checkGLcall("glVertexWeightPointerEXT(numBlends, ...)");
2589 glEnableClientState(GL_VERTEX_WEIGHT_ARRAY_EXT);
2590 checkGLcall("glEnableClientState(GL_VERTEX_WEIGHT_ARRAY_EXT)");
2591#endif
2592
2593 } else {
Stefan Dösinger762e2272007-02-16 19:15:15 +01002594 /* TODO: support blends in drawStridedSlow
2595 * No need to write a FIXME here, this is done after the general vertex decl decoding
2596 */
2597 WARN("unsupported blending in openGl\n");
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002598 }
2599 } else {
2600 if (GL_SUPPORT(ARB_VERTEX_BLEND)) {
2601#if 0 /* TODO: Vertex blending */
2602 glDisable(GL_VERTEX_BLEND_ARB);
2603#endif
2604 TRACE("ARB_VERTEX_BLEND\n");
2605 } else if (GL_SUPPORT(EXT_VERTEX_WEIGHTING)) {
2606 TRACE(" EXT_VERTEX_WEIGHTING\n");
2607 glDisableClientState(GL_VERTEX_WEIGHT_ARRAY_EXT);
2608 checkGLcall("glDisableClientState(GL_VERTEX_WEIGHT_ARRAY_EXT)");
2609
2610 }
2611 }
2612
2613#if 0 /* FOG ----------------------------------------------*/
2614 if (sd->u.s.fog.lpData || sd->u.s.fog.VBO) {
2615 /* TODO: fog*/
2616 if (GL_SUPPORT(EXT_FOG_COORD) {
2617 glEnableClientState(GL_FOG_COORDINATE_EXT);
2618 (GL_EXTCALL)(FogCoordPointerEXT)(
2619 WINED3D_ATR_GLTYPE(sd->u.s.fog.dwType),
2620 sd->u.s.fog.dwStride,
Stefan Dösinger09ab8122007-01-06 18:19:55 +01002621 sd->u.s.fog.lpData + stateblock->loadBaseVertexIndex * sd->u.s.fog.dwStride);
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002622 } else {
2623 /* don't bother falling back to 'slow' as we don't support software FOG yet. */
2624 /* FIXME: fixme once */
2625 TRACE("Hardware support for FOG is not avaiable, FOG disabled.\n");
2626 }
2627 } else {
2628 if (GL_SUPPRT(EXT_FOR_COORD) {
2629 /* make sure fog is disabled */
2630 glDisableClientState(GL_FOG_COORDINATE_EXT);
2631 }
2632 }
2633#endif
2634
2635#if 0 /* tangents ----------------------------------------------*/
2636 if (sd->u.s.tangent.lpData || sd->u.s.tangent.VBO ||
2637 sd->u.s.binormal.lpData || sd->u.s.binormal.VBO) {
2638 /* TODO: tangents*/
2639 if (GL_SUPPORT(EXT_COORDINATE_FRAME) {
2640 if (sd->u.s.tangent.lpData || sd->u.s.tangent.VBO) {
2641 glEnable(GL_TANGENT_ARRAY_EXT);
2642 (GL_EXTCALL)(TangentPointerEXT)(
2643 WINED3D_ATR_GLTYPE(sd->u.s.tangent.dwType),
2644 sd->u.s.tangent.dwStride,
Stefan Dösinger09ab8122007-01-06 18:19:55 +01002645 sd->u.s.tangent.lpData + stateblock->loadBaseVertexIndex * sd->u.s.tangent.dwStride);
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002646 } else {
2647 glDisable(GL_TANGENT_ARRAY_EXT);
2648 }
2649 if (sd->u.s.binormal.lpData || sd->u.s.binormal.VBO) {
2650 glEnable(GL_BINORMAL_ARRAY_EXT);
2651 (GL_EXTCALL)(BinormalPointerEXT)(
2652 WINED3D_ATR_GLTYPE(sd->u.s.binormal.dwType),
2653 sd->u.s.binormal.dwStride,
Stefan Dösinger09ab8122007-01-06 18:19:55 +01002654 sd->u.s.binormal.lpData + stateblock->loadBaseVertexIndex * sd->u.s.binormal.dwStride);
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002655 } else{
2656 glDisable(GL_BINORMAL_ARRAY_EXT);
2657 }
2658
2659 } else {
2660 /* don't bother falling back to 'slow' as we don't support software tangents and binormals yet . */
2661 /* FIXME: fixme once */
2662 TRACE("Hardware support for tangents and binormals is not avaiable, tangents and binormals disabled.\n");
2663 }
2664 } else {
2665 if (GL_SUPPORT(EXT_COORDINATE_FRAME) {
2666 /* make sure fog is disabled */
2667 glDisable(GL_TANGENT_ARRAY_EXT);
2668 glDisable(GL_BINORMAL_ARRAY_EXT);
2669 }
2670 }
2671#endif
2672
2673 /* Point Size ----------------------------------------------*/
2674 if (sd->u.s.pSize.lpData || sd->u.s.pSize.VBO) {
2675
2676 /* no such functionality in the fixed function GL pipeline */
2677 TRACE("Cannot change ptSize here in openGl\n");
2678 /* TODO: Implement this function in using shaders if they are available */
2679
2680 }
2681
2682 /* Vertex Pointers -----------------------------------------*/
2683 if (sd->u.s.position.lpData != NULL || sd->u.s.position.VBO != 0) {
2684 /* Note dwType == float3 or float4 == 2 or 3 */
2685 VTRACE(("glVertexPointer(%d, GL_FLOAT, %d, %p)\n",
2686 sd->u.s.position.dwStride,
2687 sd->u.s.position.dwType + 1,
2688 sd->u.s.position.lpData));
2689
2690 if(curVBO != sd->u.s.position.VBO) {
2691 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, sd->u.s.position.VBO));
2692 checkGLcall("glBindBufferARB");
2693 curVBO = sd->u.s.position.VBO;
2694 }
2695
2696 /* min(WINED3D_ATR_SIZE(position),3) to Disable RHW mode as 'w' coord
2697 handling for rhw mode should not impact screen position whereas in GL it does.
2698 This may result in very slightly distored textures in rhw mode, but
2699 a very minimal different. There's always the other option of
2700 fixing the view matrix to prevent w from having any effect
2701
2702 This only applies to user pointer sources, in VBOs the vertices are fixed up
2703 */
2704 if(sd->u.s.position.VBO == 0) {
2705 glVertexPointer(3 /* min(WINED3D_ATR_SIZE(sd->u.s.position.dwType),3) */,
2706 WINED3D_ATR_GLTYPE(sd->u.s.position.dwType),
Stefan Dösinger354fdae2007-01-17 00:06:34 +01002707 sd->u.s.position.dwStride, sd->u.s.position.lpData + stateblock->loadBaseVertexIndex * sd->u.s.position.dwStride + offset[sd->u.s.position.streamNo]);
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002708 } else {
2709 glVertexPointer(
2710 WINED3D_ATR_SIZE(sd->u.s.position.dwType),
2711 WINED3D_ATR_GLTYPE(sd->u.s.position.dwType),
Stefan Dösinger354fdae2007-01-17 00:06:34 +01002712 sd->u.s.position.dwStride, sd->u.s.position.lpData + stateblock->loadBaseVertexIndex * sd->u.s.position.dwStride + offset[sd->u.s.position.streamNo]);
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002713 }
2714 checkGLcall("glVertexPointer(...)");
2715 glEnableClientState(GL_VERTEX_ARRAY);
2716 checkGLcall("glEnableClientState(GL_VERTEX_ARRAY)");
2717
2718 } else {
2719 glDisableClientState(GL_VERTEX_ARRAY);
2720 checkGLcall("glDisableClientState(GL_VERTEX_ARRAY)");
2721 }
2722
2723 /* Normals -------------------------------------------------*/
2724 if (sd->u.s.normal.lpData || sd->u.s.normal.VBO) {
2725 /* Note dwType == float3 or float4 == 2 or 3 */
2726 VTRACE(("glNormalPointer(GL_FLOAT, %d, %p)\n",
2727 sd->u.s.normal.dwStride,
2728 sd->u.s.normal.lpData));
2729 if(curVBO != sd->u.s.normal.VBO) {
2730 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, sd->u.s.normal.VBO));
2731 checkGLcall("glBindBufferARB");
2732 curVBO = sd->u.s.normal.VBO;
2733 }
2734 glNormalPointer(
2735 WINED3D_ATR_GLTYPE(sd->u.s.normal.dwType),
2736 sd->u.s.normal.dwStride,
Stefan Dösinger354fdae2007-01-17 00:06:34 +01002737 sd->u.s.normal.lpData + stateblock->loadBaseVertexIndex * sd->u.s.normal.dwStride + offset[sd->u.s.normal.streamNo]);
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002738 checkGLcall("glNormalPointer(...)");
2739 glEnableClientState(GL_NORMAL_ARRAY);
2740 checkGLcall("glEnableClientState(GL_NORMAL_ARRAY)");
2741
2742 } else {
2743 glDisableClientState(GL_NORMAL_ARRAY);
2744 checkGLcall("glDisableClientState(GL_NORMAL_ARRAY)");
2745 glNormal3f(0, 0, 1);
2746 checkGLcall("glNormal3f(0, 0, 1)");
2747 }
2748
2749 /* Diffuse Colour --------------------------------------------*/
2750 /* WARNING: Data here MUST be in RGBA format, so cannot */
2751 /* go directly into fast mode from app pgm, because */
2752 /* directx requires data in BGRA format. */
2753 /* currently fixupVertices swizels the format, but this isn't */
2754 /* very practical when using VBOS */
2755 /* NOTE: Unless we write a vertex shader to swizel the colour */
2756 /* , or the user doesn't care and wants the speed advantage */
2757
2758 if (sd->u.s.diffuse.lpData || sd->u.s.diffuse.VBO) {
2759 /* Note dwType == float3 or float4 == 2 or 3 */
2760 VTRACE(("glColorPointer(4, GL_UNSIGNED_BYTE, %d, %p)\n",
2761 sd->u.s.diffuse.dwStride,
2762 sd->u.s.diffuse.lpData));
2763
2764 if(curVBO != sd->u.s.diffuse.VBO) {
2765 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, sd->u.s.diffuse.VBO));
2766 checkGLcall("glBindBufferARB");
2767 curVBO = sd->u.s.diffuse.VBO;
2768 }
2769 glColorPointer(4, GL_UNSIGNED_BYTE,
2770 sd->u.s.diffuse.dwStride,
Stefan Dösinger354fdae2007-01-17 00:06:34 +01002771 sd->u.s.diffuse.lpData + stateblock->loadBaseVertexIndex * sd->u.s.diffuse.dwStride + offset[sd->u.s.diffuse.streamNo]);
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002772 checkGLcall("glColorPointer(4, GL_UNSIGNED_BYTE, ...)");
2773 glEnableClientState(GL_COLOR_ARRAY);
2774 checkGLcall("glEnableClientState(GL_COLOR_ARRAY)");
2775
2776 } else {
2777 glDisableClientState(GL_COLOR_ARRAY);
2778 checkGLcall("glDisableClientState(GL_COLOR_ARRAY)");
2779 glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
2780 checkGLcall("glColor4f(1, 1, 1, 1)");
2781 }
2782
2783 /* Specular Colour ------------------------------------------*/
2784 if (sd->u.s.specular.lpData || sd->u.s.specular.VBO) {
2785 TRACE("setting specular colour\n");
2786 /* Note dwType == float3 or float4 == 2 or 3 */
2787 VTRACE(("glSecondaryColorPointer(4, GL_UNSIGNED_BYTE, %d, %p)\n",
2788 sd->u.s.specular.dwStride,
2789 sd->u.s.specular.lpData));
2790 if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
2791 if(curVBO != sd->u.s.specular.VBO) {
2792 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, sd->u.s.specular.VBO));
2793 checkGLcall("glBindBufferARB");
2794 curVBO = sd->u.s.specular.VBO;
2795 }
2796 GL_EXTCALL(glSecondaryColorPointerEXT)(4, GL_UNSIGNED_BYTE,
2797 sd->u.s.specular.dwStride,
Stefan Dösinger354fdae2007-01-17 00:06:34 +01002798 sd->u.s.specular.lpData + stateblock->loadBaseVertexIndex * sd->u.s.specular.dwStride + offset[sd->u.s.specular.streamNo]);
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002799 vcheckGLcall("glSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, ...)");
2800 glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
2801 vcheckGLcall("glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
2802 } else {
2803
2804 /* Missing specular color is not critical, no warnings */
2805 VTRACE(("Specular colour is not supported in this GL implementation\n"));
2806 }
2807
2808 } else {
2809 if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
2810
2811 glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
2812 checkGLcall("glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
2813 GL_EXTCALL(glSecondaryColor3fEXT)(0, 0, 0);
2814 checkGLcall("glSecondaryColor3fEXT(0, 0, 0)");
2815 } else {
2816
2817 /* Missing specular color is not critical, no warnings */
2818 VTRACE(("Specular colour is not supported in this GL implementation\n"));
2819 }
2820 }
2821
2822 /* Texture coords -------------------------------------------*/
2823
Stefan Dösinger65c44702007-03-16 22:02:12 +01002824 for (textureNo = 0; textureNo < GL_LIMITS(texture_stages); ++textureNo) {
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002825 /* The code below uses glClientActiveTexture and glMultiTexCoord* which are all part of the GL_ARB_multitexture extension. */
2826 /* Abort if we don't support the extension. */
2827 if (!GL_SUPPORT(ARB_MULTITEXTURE)) {
2828 FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
2829 continue;
2830 }
2831
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002832 if (stateblock->textures[textureNo] != NULL) {
2833 int coordIdx = stateblock->textureState[textureNo][WINED3DTSS_TEXCOORDINDEX];
2834
Stefan Dösinger65c44702007-03-16 22:02:12 +01002835 mapped_stage = stateblock->wineD3DDevice->texUnitMap[textureNo];
2836 /* The gl texture unit will never be -1 for a bound texture */
2837 GL_EXTCALL(glClientActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
2838 checkGLcall("glClientActiveTextureARB");
2839
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002840 if (coordIdx >= MAX_TEXTURES) {
2841 VTRACE(("tex: %d - Skip tex coords, as being system generated\n", textureNo));
2842 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
Stefan Dösinger65c44702007-03-16 22:02:12 +01002843 GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + mapped_stage, 0, 0, 0, 1));
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002844
2845 } else if (sd->u.s.texCoords[coordIdx].lpData == NULL && sd->u.s.texCoords[coordIdx].VBO == 0) {
2846 VTRACE(("Bound texture but no texture coordinates supplied, so skipping\n"));
2847 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
Stefan Dösinger65c44702007-03-16 22:02:12 +01002848 GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + mapped_stage, 0, 0, 0, 1));
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002849
2850 } else {
2851 TRACE("Setting up texture %u, idx %d, cordindx %u, data %p\n",
Stefan Dösinger65c44702007-03-16 22:02:12 +01002852 textureNo, mapped_stage, coordIdx, sd->u.s.texCoords[coordIdx].lpData);
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002853 if(curVBO != sd->u.s.texCoords[coordIdx].VBO) {
2854 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, sd->u.s.texCoords[coordIdx].VBO));
2855 checkGLcall("glBindBufferARB");
2856 curVBO = sd->u.s.texCoords[coordIdx].VBO;
2857 }
2858 /* The coords to supply depend completely on the fvf / vertex shader */
2859 glTexCoordPointer(
2860 WINED3D_ATR_SIZE(sd->u.s.texCoords[coordIdx].dwType),
2861 WINED3D_ATR_GLTYPE(sd->u.s.texCoords[coordIdx].dwType),
2862 sd->u.s.texCoords[coordIdx].dwStride,
Stefan Dösinger354fdae2007-01-17 00:06:34 +01002863 sd->u.s.texCoords[coordIdx].lpData + stateblock->loadBaseVertexIndex * sd->u.s.texCoords[coordIdx].dwStride + offset[sd->u.s.texCoords[coordIdx].streamNo]);
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002864 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
2865 }
2866 } else if (!GL_SUPPORT(NV_REGISTER_COMBINERS)) {
Stefan Dösinger5e405d32007-03-24 16:05:34 +01002867 GL_EXTCALL(glClientActiveTextureARB(GL_TEXTURE0_ARB + textureNo));
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002868 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
2869 GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + textureNo, 0, 0, 0, 1));
2870 }
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002871 }
2872 if (GL_SUPPORT(NV_REGISTER_COMBINERS)) {
Francois Gouget0081b432007-04-02 19:17:56 +02002873 /* The number of the mapped stages increases monotonically, so it's fine to use the last used one */
Stefan Dösinger65c44702007-03-16 22:02:12 +01002874 for (textureNo = mapped_stage + 1; textureNo < GL_LIMITS(textures); ++textureNo) {
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002875 GL_EXTCALL(glClientActiveTextureARB(GL_TEXTURE0_ARB + textureNo));
2876 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
2877 GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + textureNo, 0, 0, 0, 1));
2878 }
2879 }
2880}
2881
Stefan Huehner4d1d01f2007-03-12 16:50:54 +01002882static inline void drawPrimitiveTraceDataLocations(
Stefan Dösinger27bac242007-01-06 18:12:21 +01002883 WineDirect3DVertexStridedData *dataLocations) {
2884
2885 /* Dump out what parts we have supplied */
2886 TRACE("Strided Data:\n");
2887 TRACE_STRIDED((dataLocations), position);
2888 TRACE_STRIDED((dataLocations), blendWeights);
2889 TRACE_STRIDED((dataLocations), blendMatrixIndices);
2890 TRACE_STRIDED((dataLocations), normal);
2891 TRACE_STRIDED((dataLocations), pSize);
2892 TRACE_STRIDED((dataLocations), diffuse);
2893 TRACE_STRIDED((dataLocations), specular);
2894 TRACE_STRIDED((dataLocations), texCoords[0]);
2895 TRACE_STRIDED((dataLocations), texCoords[1]);
2896 TRACE_STRIDED((dataLocations), texCoords[2]);
2897 TRACE_STRIDED((dataLocations), texCoords[3]);
2898 TRACE_STRIDED((dataLocations), texCoords[4]);
2899 TRACE_STRIDED((dataLocations), texCoords[5]);
2900 TRACE_STRIDED((dataLocations), texCoords[6]);
2901 TRACE_STRIDED((dataLocations), texCoords[7]);
2902 TRACE_STRIDED((dataLocations), position2);
2903 TRACE_STRIDED((dataLocations), normal2);
2904 TRACE_STRIDED((dataLocations), tangent);
2905 TRACE_STRIDED((dataLocations), binormal);
2906 TRACE_STRIDED((dataLocations), tessFactor);
2907 TRACE_STRIDED((dataLocations), fog);
2908 TRACE_STRIDED((dataLocations), depth);
2909 TRACE_STRIDED((dataLocations), sample);
2910
2911 return;
2912}
2913
Stefan Dösinger51a98102007-01-04 00:13:15 +01002914/* Helper for vertexdeclaration() */
Stefan Dösingere6c9a072007-02-12 19:18:27 +01002915static inline void handleStreams(IWineD3DStateBlockImpl *stateblock, BOOL useVertexShaderFunction, WineD3DContext *context) {
Stefan Dösinger20de2002007-01-02 22:47:10 +01002916 IWineD3DDeviceImpl *device = stateblock->wineD3DDevice;
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002917 BOOL fixup = FALSE;
2918 WineDirect3DVertexStridedData *dataLocations = &device->strided_streams;
Stefan Dösinger20de2002007-01-02 22:47:10 +01002919
2920 if(device->up_strided) {
Stefan Dösinger438c1722007-01-02 21:31:08 +01002921 /* Note: this is a ddraw fixed-function code path */
2922 TRACE("================ Strided Input ===================\n");
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002923 memcpy(dataLocations, device->up_strided, sizeof(*dataLocations));
Stefan Dösinger27bac242007-01-06 18:12:21 +01002924
2925 if(TRACE_ON(d3d)) {
2926 drawPrimitiveTraceDataLocations(dataLocations);
2927 }
H. Verbeet6998d0d2007-03-12 23:22:16 +01002928 } else if (stateblock->vertexDecl) {
Stefan Dösinger438c1722007-01-02 21:31:08 +01002929 /* Note: This is a fixed function or shader codepath.
2930 * This means it must handle both types of strided data.
2931 * Shaders must go through here to zero the strided data, even if they
2932 * don't set any declaration at all
2933 */
2934 TRACE("================ Vertex Declaration ===================\n");
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002935 memset(dataLocations, 0, sizeof(*dataLocations));
H. Verbeet6998d0d2007-03-12 23:22:16 +01002936 primitiveDeclarationConvertToStridedData((IWineD3DDevice *) device,
2937 useVertexShaderFunction, dataLocations, &fixup);
Stefan Dösinger438c1722007-01-02 21:31:08 +01002938 } else {
2939 /* Note: This codepath is not reachable from d3d9 (see fvf->decl9 conversion)
2940 * It is reachable through d3d8, but only for fixed-function.
2941 * It will not work properly for shaders.
2942 */
2943 TRACE("================ FVF ===================\n");
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002944 memset(dataLocations, 0, sizeof(*dataLocations));
Stefan Dösingerfe6165d2007-01-10 11:37:03 +01002945 primitiveConvertToStridedData((IWineD3DDevice *) device, dataLocations, &fixup);
Stefan Dösinger27bac242007-01-06 18:12:21 +01002946 if(TRACE_ON(d3d)) {
2947 drawPrimitiveTraceDataLocations(dataLocations);
2948 }
Stefan Dösinger438c1722007-01-02 21:31:08 +01002949 }
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002950
H. Verbeet30ee0712007-03-12 23:22:00 +01002951 if (dataLocations->u.s.position_transformed) {
2952 useVertexShaderFunction = FALSE;
2953 }
2954
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002955 /* Unload the old arrays before loading the new ones to get old junk out */
Stefan Dösingere6c9a072007-02-12 19:18:27 +01002956 if(context->numberedArraysLoaded) {
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002957 unloadNumberedArrays(stateblock);
Stefan Dösingere6c9a072007-02-12 19:18:27 +01002958 context->numberedArraysLoaded = FALSE;
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002959 }
Stefan Dösingere6c9a072007-02-12 19:18:27 +01002960 if(context->namedArraysLoaded) {
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002961 unloadVertexData(stateblock);
Stefan Dösingere6c9a072007-02-12 19:18:27 +01002962 context->namedArraysLoaded = FALSE;
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002963 }
2964
2965 if(useVertexShaderFunction) {
2966 TRACE("Loading numbered arrays\n");
2967 loadNumberedArrays(stateblock, dataLocations);
2968 device->useDrawStridedSlow = FALSE;
Stefan Dösingere6c9a072007-02-12 19:18:27 +01002969 context->numberedArraysLoaded = TRUE;
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002970 } else if (fixup ||
2971 (dataLocations->u.s.pSize.lpData == NULL &&
2972 dataLocations->u.s.diffuse.lpData == NULL &&
2973 dataLocations->u.s.specular.lpData == NULL)) {
2974 /* Load the vertex data using named arrays */
2975 TRACE("Loading vertex data\n");
2976 loadVertexData(stateblock, dataLocations);
2977 device->useDrawStridedSlow = FALSE;
Stefan Dösingere6c9a072007-02-12 19:18:27 +01002978 context->namedArraysLoaded = TRUE;
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01002979 } else {
2980 TRACE("Not loading vertex data\n");
2981 device->useDrawStridedSlow = TRUE;
2982 }
Stefan Dösinger7e314012007-01-06 18:13:21 +01002983
2984/* Generate some fixme's if unsupported functionality is being used */
2985#define BUFFER_OR_DATA(_attribute) dataLocations->u.s._attribute.lpData
2986 /* TODO: Either support missing functionality in fixupVertices or by creating a shader to replace the pipeline. */
Stefan Dösinger762e2272007-02-16 19:15:15 +01002987 if (!useVertexShaderFunction &&
2988 stateblock->renderState[WINED3DRS_VERTEXBLEND] &&
2989 (BUFFER_OR_DATA(blendMatrixIndices) || BUFFER_OR_DATA(blendWeights))) {
2990 FIXME("Vertex Blending is not implemented yet %p %p\n",dataLocations->u.s.blendWeights.lpData,dataLocations->u.s.blendWeights.lpData);
2991 /* TODO: Implement it using GL_ARB_vertex_blend or software emulation in drawStridedSlow */
Stefan Dösinger7e314012007-01-06 18:13:21 +01002992 }
2993 if (!useVertexShaderFunction && (BUFFER_OR_DATA(position2) || BUFFER_OR_DATA(normal2))) {
2994 FIXME("Tweening is only valid with vertex shaders\n");
2995 }
2996 if (!useVertexShaderFunction && (BUFFER_OR_DATA(tangent) || BUFFER_OR_DATA(binormal))) {
2997 FIXME("Tangent and binormal bump mapping is only valid with vertex shaders\n");
2998 }
2999 if (!useVertexShaderFunction && (BUFFER_OR_DATA(tessFactor) || BUFFER_OR_DATA(fog) || BUFFER_OR_DATA(depth) || BUFFER_OR_DATA(sample))) {
3000 FIXME("Extended attributes are only valid with vertex shaders\n");
3001 }
3002#undef BUFFER_OR_DATA
Stefan Dösinger51a98102007-01-04 00:13:15 +01003003}
3004
Stefan Dösingerc739c382007-02-12 19:18:22 +01003005static void vertexdeclaration(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger51a98102007-01-04 00:13:15 +01003006 BOOL useVertexShaderFunction = FALSE, updateFog = FALSE;
H. Verbeet1636bc12007-02-13 19:53:11 +01003007 BOOL usePixelShaderFunction = stateblock->wineD3DDevice->ps_selected_mode != SHADER_NONE && stateblock->pixelShader
3008 && ((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.function;
Stefan Dösinger51a98102007-01-04 00:13:15 +01003009 BOOL transformed;
3010 /* Some stuff is in the device until we have per context tracking */
3011 IWineD3DDeviceImpl *device = stateblock->wineD3DDevice;
Stefan Dösingere6c9a072007-02-12 19:18:27 +01003012 BOOL wasrhw = context->last_was_rhw;
Stefan Dösinger51a98102007-01-04 00:13:15 +01003013
Stefan Dösinger51a98102007-01-04 00:13:15 +01003014 /* Shaders can be implemented using ARB_PROGRAM, GLSL, or software -
3015 * here simply check whether a shader was set, or the user disabled shaders
3016 */
3017 if (device->vs_selected_mode != SHADER_NONE && stateblock->vertexShader &&
3018 ((IWineD3DVertexShaderImpl *)stateblock->vertexShader)->baseShader.function != NULL) {
3019 useVertexShaderFunction = TRUE;
3020
Stefan Dösingere6c9a072007-02-12 19:18:27 +01003021 if(((IWineD3DVertexShaderImpl *)stateblock->vertexShader)->usesFog != context->last_was_foggy_shader) {
Stefan Dösinger51a98102007-01-04 00:13:15 +01003022 updateFog = TRUE;
3023 }
Stefan Dösingere6c9a072007-02-12 19:18:27 +01003024 } else if(context->last_was_foggy_shader) {
Stefan Dösinger51a98102007-01-04 00:13:15 +01003025 updateFog = TRUE;
3026 }
3027
Stefan Dösingere6c9a072007-02-12 19:18:27 +01003028 handleStreams(stateblock, useVertexShaderFunction, context);
Stefan Dösinger51a98102007-01-04 00:13:15 +01003029
H. Verbeet05d461a2007-03-12 23:22:06 +01003030 transformed = device->strided_streams.u.s.position_transformed;
H. Verbeet30ee0712007-03-12 23:22:00 +01003031 if (transformed) useVertexShaderFunction = FALSE;
Stefan Dösinger20de2002007-01-02 22:47:10 +01003032
Stefan Dösingere6c9a072007-02-12 19:18:27 +01003033 if(transformed != context->last_was_rhw && !useVertexShaderFunction) {
Stefan Dösinger20de2002007-01-02 22:47:10 +01003034 updateFog = TRUE;
3035 }
3036
Francois Gouget93494f22007-02-20 15:57:10 +01003037 /* Reapply lighting if it is not scheduled for reapplication already */
Stefan Dösinger380930d2007-02-12 19:18:31 +01003038 if(!isStateDirty(context, STATE_RENDER(WINED3DRS_LIGHTING))) {
Stefan Dösingerc739c382007-02-12 19:18:22 +01003039 state_lighting(STATE_RENDER(WINED3DRS_LIGHTING), stateblock, context);
Stefan Dösinger20de2002007-01-02 22:47:10 +01003040 }
3041
H. Verbeet30ee0712007-03-12 23:22:00 +01003042 if (transformed) {
Stefan Dösingere6c9a072007-02-12 19:18:27 +01003043 context->last_was_rhw = TRUE;
Stefan Dösinger20de2002007-01-02 22:47:10 +01003044 } else {
3045
3046 /* Untransformed, so relies on the view and projection matrices */
Stefan Dösingere6c9a072007-02-12 19:18:27 +01003047 context->last_was_rhw = FALSE;
Stefan Dösinger5fa0f7f2007-01-02 22:47:39 +01003048 /* This turns off the Z scale trick to 'disable' viewport frustum clipping in rhw mode*/
Stefan Dösinger20de2002007-01-02 22:47:10 +01003049 device->untransformed = TRUE;
3050
Stefan Dösingere26e3ee2007-01-02 22:52:11 +01003051 /* Todo for sw shaders: Vertex Shader output is already transformed, so set up identity matrices
3052 * Not needed as long as only hw shaders are supported
Stefan Dösinger5fa0f7f2007-01-02 22:47:39 +01003053 */
Stefan Dösinger20de2002007-01-02 22:47:10 +01003054
Stefan Dösingere26e3ee2007-01-02 22:52:11 +01003055 /* This sets the shader output position correction constants.
3056 * TODO: Move to the viewport state
3057 */
Stefan Dösinger20de2002007-01-02 22:47:10 +01003058 if (useVertexShaderFunction) {
3059 device->posFixup[1] = device->render_offscreen ? -1.0 : 1.0;
Stefan Dösinger20de2002007-01-02 22:47:10 +01003060 }
Stefan Dösinger20de2002007-01-02 22:47:10 +01003061 }
3062
Stefan Dösingere26e3ee2007-01-02 22:52:11 +01003063 /* Don't have to apply the matrices when vertex shaders are used. When vshaders are turned
3064 * off this function will be called again anyway to make sure they're properly set
Stefan Dösinger82bd0792007-01-02 22:50:38 +01003065 */
Stefan Dösingere26e3ee2007-01-02 22:52:11 +01003066 if(!useVertexShaderFunction) {
3067 /* TODO: Move this mainly to the viewport state and only apply when the vp has changed
3068 * or transformed / untransformed was switched
3069 */
Stefan Dösingere6c9a072007-02-12 19:18:27 +01003070 if(wasrhw != context->last_was_rhw &&
Stefan Dösinger380930d2007-02-12 19:18:31 +01003071 !isStateDirty(context, STATE_TRANSFORM(WINED3DTS_PROJECTION)) &&
3072 !isStateDirty(context, STATE_VIEWPORT)) {
Stefan Dösingerc739c382007-02-12 19:18:22 +01003073 transform_projection(STATE_TRANSFORM(WINED3DTS_PROJECTION), stateblock, context);
Stefan Dösingere26e3ee2007-01-02 22:52:11 +01003074 }
3075 /* World matrix needs reapplication here only if we're switching between rhw and non-rhw
3076 * mode.
3077 *
3078 * If a vertex shader is used, the world matrix changed and then vertex shader unbound
3079 * this check will fail and the matrix not applied again. This is OK because a simple
3080 * world matrix change reapplies the matrix - These checks here are only to satisfy the
3081 * needs of the vertex declaration.
3082 *
3083 * World and view matrix go into the same gl matrix, so only apply them when neither is
3084 * dirty
3085 */
3086 if(transformed != wasrhw &&
Stefan Dösinger380930d2007-02-12 19:18:31 +01003087 !isStateDirty(context, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0))) &&
3088 !isStateDirty(context, STATE_TRANSFORM(WINED3DTS_VIEW))) {
Stefan Dösingerc739c382007-02-12 19:18:22 +01003089 transform_world(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), stateblock, context);
Stefan Dösingere26e3ee2007-01-02 22:52:11 +01003090 }
Stefan Dösinger9b492092007-01-10 11:26:12 +01003091
Stefan Dösinger380930d2007-02-12 19:18:31 +01003092 if(!isStateDirty(context, STATE_RENDER(WINED3DRS_COLORVERTEX))) {
Stefan Dösingerc739c382007-02-12 19:18:22 +01003093 state_colormat(STATE_RENDER(WINED3DRS_COLORVERTEX), stateblock, context);
Stefan Dösinger9b492092007-01-10 11:26:12 +01003094 }
Stefan Dösinger5afbfd02007-02-27 23:11:15 +01003095
3096 if(context->last_was_vshader && !isStateDirty(context, STATE_RENDER(WINED3DRS_CLIPPLANEENABLE))) {
3097 state_clipping(STATE_RENDER(WINED3DRS_CLIPPLANEENABLE), stateblock, context);
3098 }
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01003099 } else {
3100 /* We compile the shader here because we need the vertex declaration
3101 * in order to determine if we need to do any swizzling for D3DCOLOR
3102 * registers. If the shader is already compiled this call will do nothing. */
3103 IWineD3DVertexShader_CompileShader(stateblock->vertexShader);
Stefan Dösinger5afbfd02007-02-27 23:11:15 +01003104
3105 if(!context->last_was_vshader) {
3106 int i;
3107 static BOOL warned = FALSE;
3108 /* Disable all clip planes to get defined results on all drivers. See comment in the
3109 * state_clipping state handler
3110 */
3111 for(i = 0; i < GL_LIMITS(clipplanes); i++) {
3112 glDisable(GL_CLIP_PLANE0 + i);
3113 checkGLcall("glDisable(GL_CLIP_PLANE0 + i)");
3114 }
3115
3116 if(!warned && stateblock->renderState[WINED3DRS_CLIPPLANEENABLE]) {
3117 FIXME("Clipping not supported with vertex shaders\n");
3118 warned = TRUE;
3119 }
3120 }
Stefan Dösinger8e37fcd2007-01-06 18:17:27 +01003121 }
Stefan Dösinger799770b2007-01-06 18:14:12 +01003122
H. Verbeet1636bc12007-02-13 19:53:11 +01003123 /* Vertex and pixel shaders are applied together for now, so let the last dirty state do the
3124 * application
3125 */
3126 if (!isStateDirty(context, STATE_PIXELSHADER)) {
3127 device->shader_backend->shader_select((IWineD3DDevice *)device, usePixelShaderFunction, useVertexShaderFunction);
Stefan Dösinger799770b2007-01-06 18:14:12 +01003128
H. Verbeet1636bc12007-02-13 19:53:11 +01003129 if (!isStateDirty(context, STATE_VERTEXSHADERCONSTANT) && (useVertexShaderFunction || usePixelShaderFunction)) {
3130 shaderconstant(STATE_VERTEXSHADERCONSTANT, stateblock, context);
Stefan Dösinger799770b2007-01-06 18:14:12 +01003131 }
Stefan Dösingerd5f18e62007-01-06 18:11:21 +01003132 }
Stefan Dösinger82bd0792007-01-02 22:50:38 +01003133
H. Verbeet1636bc12007-02-13 19:53:11 +01003134 context->last_was_vshader = useVertexShaderFunction;
3135
Stefan Dösinger20de2002007-01-02 22:47:10 +01003136 if(updateFog) {
Stefan Dösingerc739c382007-02-12 19:18:22 +01003137 state_fog(STATE_RENDER(WINED3DRS_FOGENABLE), stateblock, context);
Stefan Dösinger20de2002007-01-02 22:47:10 +01003138 }
Stefan Dösingeref1ebb62007-01-02 00:35:07 +01003139}
3140
Stefan Dösingerc739c382007-02-12 19:18:22 +01003141static void viewport(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
Stefan Dösinger0d700be2007-01-04 00:05:05 +01003142 glDepthRange(stateblock->viewport.MinZ, stateblock->viewport.MaxZ);
3143 checkGLcall("glDepthRange");
Stefan Dösinger81aeae32007-03-06 14:56:58 +01003144 /* Note: GL requires lower left, DirectX supplies upper left. This is reversed when using offscreen rendering
3145 */
3146 if(stateblock->wineD3DDevice->render_offscreen) {
3147 glViewport(stateblock->viewport.X,
3148 stateblock->viewport.Y,
3149 stateblock->viewport.Width, stateblock->viewport.Height);
3150 } else {
3151 glViewport(stateblock->viewport.X,
3152 (((IWineD3DSurfaceImpl *)stateblock->wineD3DDevice->render_targets[0])->currentDesc.Height - (stateblock->viewport.Y + stateblock->viewport.Height)),
3153 stateblock->viewport.Width, stateblock->viewport.Height);
3154 }
Stefan Dösinger0d700be2007-01-04 00:05:05 +01003155
3156 checkGLcall("glViewport");
3157
3158 stateblock->wineD3DDevice->posFixup[2] = 0.9 / stateblock->viewport.Width;
3159 stateblock->wineD3DDevice->posFixup[3] = -0.9 / stateblock->viewport.Height;
H. Verbeeta2fde7d2007-02-15 13:32:13 +01003160 if(!isStateDirty(context, STATE_TRANSFORM(WINED3DTS_PROJECTION))) {
3161 transform_projection(STATE_TRANSFORM(WINED3DTS_PROJECTION), stateblock, context);
Stefan Dösinger0d700be2007-01-04 00:05:05 +01003162 }
3163
3164}
3165
Stefan Dösinger174b6322007-02-14 17:48:52 +01003166static void light(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
3167 UINT Index = state - STATE_ACTIVELIGHT(0);
3168 PLIGHTINFOEL *lightInfo = stateblock->activeLights[Index];
3169
3170 if(!lightInfo) {
3171 glDisable(GL_LIGHT0 + Index);
3172 checkGLcall("glDisable(GL_LIGHT0 + Index)");
3173 } else {
3174 float quad_att;
3175 float colRGBA[] = {0.0, 0.0, 0.0, 0.0};
3176
3177 /* Light settings are affected by the model view in OpenGL, the View transform in direct3d*/
3178 glMatrixMode(GL_MODELVIEW);
3179 glPushMatrix();
3180 glLoadMatrixf((float *)&stateblock->transforms[WINED3DTS_VIEW].u.m[0][0]);
3181
3182 /* Diffuse: */
3183 colRGBA[0] = lightInfo->OriginalParms.Diffuse.r;
3184 colRGBA[1] = lightInfo->OriginalParms.Diffuse.g;
3185 colRGBA[2] = lightInfo->OriginalParms.Diffuse.b;
3186 colRGBA[3] = lightInfo->OriginalParms.Diffuse.a;
3187 glLightfv(GL_LIGHT0 + Index, GL_DIFFUSE, colRGBA);
3188 checkGLcall("glLightfv");
3189
3190 /* Specular */
3191 colRGBA[0] = lightInfo->OriginalParms.Specular.r;
3192 colRGBA[1] = lightInfo->OriginalParms.Specular.g;
3193 colRGBA[2] = lightInfo->OriginalParms.Specular.b;
3194 colRGBA[3] = lightInfo->OriginalParms.Specular.a;
3195 glLightfv(GL_LIGHT0 + Index, GL_SPECULAR, colRGBA);
3196 checkGLcall("glLightfv");
3197
3198 /* Ambient */
3199 colRGBA[0] = lightInfo->OriginalParms.Ambient.r;
3200 colRGBA[1] = lightInfo->OriginalParms.Ambient.g;
3201 colRGBA[2] = lightInfo->OriginalParms.Ambient.b;
3202 colRGBA[3] = lightInfo->OriginalParms.Ambient.a;
3203 glLightfv(GL_LIGHT0 + Index, GL_AMBIENT, colRGBA);
3204 checkGLcall("glLightfv");
3205
Stefan Dösinger174b6322007-02-14 17:48:52 +01003206 if ((lightInfo->OriginalParms.Range *lightInfo->OriginalParms.Range) >= FLT_MIN) {
3207 quad_att = 1.4/(lightInfo->OriginalParms.Range *lightInfo->OriginalParms.Range);
3208 } else {
3209 quad_att = 0; /* 0 or MAX? (0 seems to be ok) */
3210 }
3211
Stefan Dösinger76b7cac2007-02-20 22:43:13 +01003212 /* Do not assign attenuation values for lights that do not use them. D3D apps are free to pass any junk,
3213 * but gl drivers use them and may crash due to bad Attenuation values. Need for Speed most wanted sets
3214 * Attenuation0 to NaN and crashes in the gl lib
3215 */
Stefan Dösinger174b6322007-02-14 17:48:52 +01003216
3217 switch (lightInfo->OriginalParms.Type) {
3218 case WINED3DLIGHT_POINT:
3219 /* Position */
3220 glLightfv(GL_LIGHT0 + Index, GL_POSITION, &lightInfo->lightPosn[0]);
3221 checkGLcall("glLightfv");
3222 glLightf(GL_LIGHT0 + Index, GL_SPOT_CUTOFF, lightInfo->cutoff);
3223 checkGLcall("glLightf");
Stefan Dösinger76b7cac2007-02-20 22:43:13 +01003224 /* Attenuation - Are these right? guessing... */
3225 glLightf(GL_LIGHT0 + Index, GL_CONSTANT_ATTENUATION, lightInfo->OriginalParms.Attenuation0);
3226 checkGLcall("glLightf");
3227 glLightf(GL_LIGHT0 + Index, GL_LINEAR_ATTENUATION, lightInfo->OriginalParms.Attenuation1);
3228 checkGLcall("glLightf");
3229 if (quad_att < lightInfo->OriginalParms.Attenuation2) quad_att = lightInfo->OriginalParms.Attenuation2;
3230 glLightf(GL_LIGHT0 + Index, GL_QUADRATIC_ATTENUATION, quad_att);
3231 checkGLcall("glLightf");
Stefan Dösinger174b6322007-02-14 17:48:52 +01003232 /* FIXME: Range */
3233 break;
3234
3235 case WINED3DLIGHT_SPOT:
3236 /* Position */
3237 glLightfv(GL_LIGHT0 + Index, GL_POSITION, &lightInfo->lightPosn[0]);
3238 checkGLcall("glLightfv");
3239 /* Direction */
3240 glLightfv(GL_LIGHT0 + Index, GL_SPOT_DIRECTION, &lightInfo->lightDirn[0]);
3241 checkGLcall("glLightfv");
3242 glLightf(GL_LIGHT0 + Index, GL_SPOT_EXPONENT, lightInfo->exponent);
3243 checkGLcall("glLightf");
3244 glLightf(GL_LIGHT0 + Index, GL_SPOT_CUTOFF, lightInfo->cutoff);
3245 checkGLcall("glLightf");
Stefan Dösinger76b7cac2007-02-20 22:43:13 +01003246 /* Attenuation - Are these right? guessing... */
3247 glLightf(GL_LIGHT0 + Index, GL_CONSTANT_ATTENUATION, lightInfo->OriginalParms.Attenuation0);
3248 checkGLcall("glLightf");
3249 glLightf(GL_LIGHT0 + Index, GL_LINEAR_ATTENUATION, lightInfo->OriginalParms.Attenuation1);
3250 checkGLcall("glLightf");
3251 if (quad_att < lightInfo->OriginalParms.Attenuation2) quad_att = lightInfo->OriginalParms.Attenuation2;
3252 glLightf(GL_LIGHT0 + Index, GL_QUADRATIC_ATTENUATION, quad_att);
3253 checkGLcall("glLightf");
Stefan Dösinger174b6322007-02-14 17:48:52 +01003254 /* FIXME: Range */
3255 break;
3256
3257 case WINED3DLIGHT_DIRECTIONAL:
3258 /* Direction */
3259 glLightfv(GL_LIGHT0 + Index, GL_POSITION, &lightInfo->lightPosn[0]); /* Note gl uses w position of 0 for direction! */
3260 checkGLcall("glLightfv");
3261 glLightf(GL_LIGHT0 + Index, GL_SPOT_CUTOFF, lightInfo->cutoff);
3262 checkGLcall("glLightf");
3263 glLightf(GL_LIGHT0 + Index, GL_SPOT_EXPONENT, 0.0f);
3264 checkGLcall("glLightf");
3265 break;
3266
3267 default:
3268 FIXME("Unrecognized light type %d\n", lightInfo->OriginalParms.Type);
3269 }
3270
3271 /* Restore the modelview matrix */
3272 glPopMatrix();
3273
3274 glEnable(GL_LIGHT0 + Index);
3275 checkGLcall("glEnable(GL_LIGHT0 + Index)");
3276 }
3277
3278 return;
3279}
3280
Stefan Dösingerecfd4cb2007-02-19 15:25:16 +01003281static void scissorrect(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
3282 IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *) stateblock->wineD3DDevice->swapchains[0];
3283 RECT *pRect = &stateblock->scissorRect;
3284 RECT windowRect;
3285 UINT winHeight;
3286
3287 GetClientRect(swapchain->win_handle, &windowRect);
3288 /* Warning: glScissor uses window coordinates, not viewport coordinates, so our viewport correction does not apply
3289 * Warning2: Even in windowed mode the coords are relative to the window, not the screen
3290 */
3291 winHeight = windowRect.bottom - windowRect.top;
3292 TRACE("(%p) Setting new Scissor Rect to %d:%d-%d:%d\n", stateblock->wineD3DDevice, pRect->left, pRect->bottom - winHeight,
3293 pRect->right - pRect->left, pRect->bottom - pRect->top);
3294 glScissor(pRect->left, winHeight - pRect->bottom, pRect->right - pRect->left, pRect->bottom - pRect->top);
3295 checkGLcall("glScissor");
3296}
3297
Stefan Dösinger59ae2a52007-02-19 15:25:32 +01003298static void indexbuffer(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
3299 if(GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT)) {
3300 if(stateblock->streamIsUP || stateblock->pIndexData == NULL ) {
3301 GL_EXTCALL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0));
3302 } else {
3303 IWineD3DIndexBufferImpl *ib = (IWineD3DIndexBufferImpl *) stateblock->pIndexData;
3304 GL_EXTCALL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, ib->vbo));
3305 }
3306 }
3307}
3308
Stefan Dösingerc0268c72006-12-05 23:36:10 +01003309const struct StateEntry StateTable[] =
3310{
3311 /* State name representative, apply function */
Stefan Dösinger2a24e842006-12-06 13:22:12 +01003312 { /* 0, Undefined */ 0, state_undefined },
3313 { /* 1, WINED3DRS_TEXTUREHANDLE */ 0 /* Handled in ddraw */, state_undefined },
Stefan Dösinger55a5b4c2006-12-10 23:21:03 +01003314 { /* 2, WINED3DRS_ANTIALIAS */ STATE_RENDER(WINED3DRS_ANTIALIAS), state_antialias },
Stefan Dösinger2a24e842006-12-06 13:22:12 +01003315 { /* 3, WINED3DRS_TEXTUREADDRESS */ 0 /* Handled in ddraw */, state_undefined },
Stefan Dösinger312be462006-12-10 23:20:56 +01003316 { /* 4, WINED3DRS_TEXTUREPERSPECTIVE */ STATE_RENDER(WINED3DRS_TEXTUREPERSPECTIVE), state_perspective },
Stefan Dösingerff077ec2006-12-15 20:02:13 +01003317 { /* 5, WINED3DRS_WRAPU */ STATE_RENDER(WINED3DRS_WRAPU), state_wrapu },
3318 { /* 6, WINED3DRS_WRAPV */ STATE_RENDER(WINED3DRS_WRAPV), state_wrapv },
Stefan Dösingerbb564dc2006-12-08 01:40:51 +01003319 { /* 7, WINED3DRS_ZENABLE */ STATE_RENDER(WINED3DRS_ZENABLE), state_zenable },
Stefan Dösingerde963202006-12-05 23:45:35 +01003320 { /* 8, WINED3DRS_FILLMODE */ STATE_RENDER(WINED3DRS_FILLMODE), state_fillmode },
Stefan Dösinger68f10822006-12-08 01:42:16 +01003321 { /* 9, WINED3DRS_SHADEMODE */ STATE_RENDER(WINED3DRS_SHADEMODE), state_shademode },
Stefan Dösinger6a5d7df2006-12-10 23:20:01 +01003322 { /* 10, WINED3DRS_LINEPATTERN */ STATE_RENDER(WINED3DRS_LINEPATTERN), state_linepattern },
Stefan Dösingerff077ec2006-12-15 20:02:13 +01003323 { /* 11, WINED3DRS_MONOENABLE */ STATE_RENDER(WINED3DRS_MONOENABLE), state_monoenable },
3324 { /* 12, WINED3DRS_ROP2 */ STATE_RENDER(WINED3DRS_ROP2), state_rop2 },
3325 { /* 13, WINED3DRS_PLANEMASK */ STATE_RENDER(WINED3DRS_PLANEMASK), state_planemask },
Stefan Dösinger8879c7d2006-12-08 01:43:25 +01003326 { /* 14, WINED3DRS_ZWRITEENABLE */ STATE_RENDER(WINED3DRS_ZWRITEENABLE), state_zwritenable },
Stefan Dösingerc88efee2006-12-08 20:21:32 +01003327 { /* 15, WINED3DRS_ALPHATESTENABLE */ STATE_RENDER(WINED3DRS_ALPHATESTENABLE), state_alpha },
Stefan Dösingerc5344702006-12-10 23:20:29 +01003328 { /* 16, WINED3DRS_LASTPIXEL */ STATE_RENDER(WINED3DRS_LASTPIXEL), state_lastpixel },
Stefan Dösinger2a24e842006-12-06 13:22:12 +01003329 { /* 17, WINED3DRS_TEXTUREMAG */ 0 /* Handled in ddraw */, state_undefined },
3330 { /* 18, WINED3DRS_TEXTUREMIN */ 0 /* Handled in ddraw */, state_undefined },
Stefan Dösinger1f07e4a2006-12-08 01:51:11 +01003331 { /* 19, WINED3DRS_SRCBLEND */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), state_blend },
3332 { /* 20, WINED3DRS_DESTBLEND */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), state_blend },
Stefan Dösinger2a24e842006-12-06 13:22:12 +01003333 { /* 21, WINED3DRS_TEXTUREMAPBLEND */ 0 /* Handled in ddraw */, state_undefined },
Stefan Dösingere4b4c042006-12-08 01:41:43 +01003334 { /* 22, WINED3DRS_CULLMODE */ STATE_RENDER(WINED3DRS_CULLMODE), state_cullmode },
Stefan Dösinger2ac48e82006-12-08 01:44:55 +01003335 { /* 23, WINED3DRS_ZFUNC */ STATE_RENDER(WINED3DRS_ZFUNC), state_zfunc },
Stefan Dösingerc88efee2006-12-08 20:21:32 +01003336 { /* 24, WINED3DRS_ALPHAREF */ STATE_RENDER(WINED3DRS_ALPHATESTENABLE), state_alpha },
3337 { /* 25, WINED3DRS_ALPHAFUNC */ STATE_RENDER(WINED3DRS_ALPHATESTENABLE), state_alpha },
Stefan Dösingerbb622e82006-12-08 01:42:43 +01003338 { /* 26, WINED3DRS_DITHERENABLE */ STATE_RENDER(WINED3DRS_DITHERENABLE), state_ditherenable },
Stefan Dösinger1f07e4a2006-12-08 01:51:11 +01003339 { /* 27, WINED3DRS_ALPHABLENDENABLE */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), state_blend },
Stefan Dösinger61752732006-12-08 18:42:43 +01003340 { /* 28, WINED3DRS_FOGENABLE */ STATE_RENDER(WINED3DRS_FOGENABLE), state_fog },
Stefan Dösinger0772bb42006-12-08 18:38:30 +01003341 { /* 29, WINED3DRS_SPECULARENABLE */ STATE_RENDER(WINED3DRS_SPECULARENABLE), state_specularenable},
Stefan Dösinger2a24e842006-12-06 13:22:12 +01003342 { /* 30, WINED3DRS_ZVISIBLE */ 0 /* Not supported according to the msdn */, state_nogl },
Stefan Dösingerff077ec2006-12-15 20:02:13 +01003343 { /* 31, WINED3DRS_SUBPIXEL */ STATE_RENDER(WINED3DRS_SUBPIXEL), state_subpixel },
3344 { /* 32, WINED3DRS_SUBPIXELX */ STATE_RENDER(WINED3DRS_SUBPIXELX), state_subpixelx },
Stefan Dösinger2710be02006-12-10 23:20:59 +01003345 { /* 33, WINED3DRS_STIPPLEDALPHA */ STATE_RENDER(WINED3DRS_STIPPLEDALPHA), state_stippledalpha },
Stefan Dösingeraf935a22006-12-08 18:52:30 +01003346 { /* 34, WINED3DRS_FOGCOLOR */ STATE_RENDER(WINED3DRS_FOGCOLOR), state_fogcolor },
Stefan Dösinger61752732006-12-08 18:42:43 +01003347 { /* 35, WINED3DRS_FOGTABLEMODE */ STATE_RENDER(WINED3DRS_FOGENABLE), state_fog },
3348 { /* 36, WINED3DRS_FOGSTART */ STATE_RENDER(WINED3DRS_FOGENABLE), state_fog },
3349 { /* 37, WINED3DRS_FOGEND */ STATE_RENDER(WINED3DRS_FOGENABLE), state_fog },
Stefan Dösingere53c2a92006-12-10 16:34:45 +01003350 { /* 38, WINED3DRS_FOGDENSITY */ STATE_RENDER(WINED3DRS_FOGDENSITY), state_fogdensity },
Stefan Dösingerff077ec2006-12-15 20:02:13 +01003351 { /* 39, WINED3DRS_STIPPLEENABLE */ STATE_RENDER(WINED3DRS_STIPPLEENABLE), state_stippleenable },
Stefan Dösinger1f07e4a2006-12-08 01:51:11 +01003352 { /* 40, WINED3DRS_EDGEANTIALIAS */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), state_blend },
Stefan Dösingerc88efee2006-12-08 20:21:32 +01003353 { /* 41, WINED3DRS_COLORKEYENABLE */ STATE_RENDER(WINED3DRS_ALPHATESTENABLE), state_alpha },
Stefan Dösinger2a24e842006-12-06 13:22:12 +01003354 { /* 42, undefined */ 0, state_undefined },
Stefan Dösingerff077ec2006-12-15 20:02:13 +01003355 { /* 43, WINED3DRS_BORDERCOLOR */ STATE_RENDER(WINED3DRS_BORDERCOLOR), state_bordercolor },
Stefan Dösinger2a24e842006-12-06 13:22:12 +01003356 { /* 44, WINED3DRS_TEXTUREADDRESSU */ 0, /* Handled in ddraw */ state_undefined },
3357 { /* 45, WINED3DRS_TEXTUREADDRESSV */ 0, /* Handled in ddraw */ state_undefined },
Stefan Dösingerff077ec2006-12-15 20:02:13 +01003358 { /* 46, WINED3DRS_MIPMAPLODBIAS */ STATE_RENDER(WINED3DRS_MIPMAPLODBIAS), state_mipmaplodbias },
Stefan Dösingerdd6f5a52006-12-10 23:19:57 +01003359 { /* 47, WINED3DRS_ZBIAS */ STATE_RENDER(WINED3DRS_ZBIAS), state_zbias },
Stefan Dösingerf2602482006-12-08 20:03:27 +01003360 { /* 48, WINED3DRS_RANGEFOGENABLE */ 0, state_nogl },
Stefan Dösingerff077ec2006-12-15 20:02:13 +01003361 { /* 49, WINED3DRS_ANISOTROPY */ STATE_RENDER(WINED3DRS_ANISOTROPY), state_anisotropy },
3362 { /* 50, WINED3DRS_FLUSHBATCH */ STATE_RENDER(WINED3DRS_FLUSHBATCH), state_flushbatch },
3363 { /* 51, WINED3DRS_TRANSLUCENTSORTINDEPENDENT */ STATE_RENDER(WINED3DRS_TRANSLUCENTSORTINDEPENDENT), state_translucentsi },
Stefan Dösinger0d9ae202006-12-08 18:39:45 +01003364 { /* 52, WINED3DRS_STENCILENABLE */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
3365 { /* 53, WINED3DRS_STENCILFAIL */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
3366 { /* 54, WINED3DRS_STENCILZFAIL */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
3367 { /* 55, WINED3DRS_STENCILPASS */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
3368 { /* 56, WINED3DRS_STENCILFUNC */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
3369 { /* 57, WINED3DRS_STENCILREF */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
3370 { /* 58, WINED3DRS_STENCILMASK */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
Stefan Dösinger8d724312006-12-08 18:41:05 +01003371 { /* 59, WINED3DRS_STENCILWRITEMASK */ STATE_RENDER(WINED3DRS_STENCILWRITEMASK), state_stencilwrite },
Stefan Dösinger287c6242006-12-08 18:37:17 +01003372 { /* 60, WINED3DRS_TEXTUREFACTOR */ STATE_RENDER(WINED3DRS_TEXTUREFACTOR), state_texfactor },
Stefan Dösinger2a24e842006-12-06 13:22:12 +01003373 { /* 61, Undefined */ 0, state_undefined },
3374 { /* 62, Undefined */ 0, state_undefined },
3375 { /* 63, Undefined */ 0, state_undefined },
Stefan Dösingerf661a822006-12-17 17:21:30 +01003376 { /* 64, WINED3DRS_STIPPLEPATTERN00 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3377 { /* 65, WINED3DRS_STIPPLEPATTERN01 */ 0 /* Obsolete, should he handled by ddraw */, state_undefined },
3378 { /* 66, WINED3DRS_STIPPLEPATTERN02 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3379 { /* 67, WINED3DRS_STIPPLEPATTERN03 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3380 { /* 68, WINED3DRS_STIPPLEPATTERN04 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3381 { /* 69, WINED3DRS_STIPPLEPATTERN05 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3382 { /* 70, WINED3DRS_STIPPLEPATTERN06 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3383 { /* 71, WINED3DRS_STIPPLEPATTERN07 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3384 { /* 72, WINED3DRS_STIPPLEPATTERN08 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3385 { /* 73, WINED3DRS_STIPPLEPATTERN09 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3386 { /* 74, WINED3DRS_STIPPLEPATTERN10 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3387 { /* 75, WINED3DRS_STIPPLEPATTERN11 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3388 { /* 76, WINED3DRS_STIPPLEPATTERN12 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3389 { /* 77, WINED3DRS_STIPPLEPATTERN13 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3390 { /* 78, WINED3DRS_STIPPLEPATTERN14 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3391 { /* 79, WINED3DRS_STIPPLEPATTERN15 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3392 { /* 80, WINED3DRS_STIPPLEPATTERN16 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3393 { /* 81, WINED3DRS_STIPPLEPATTERN17 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3394 { /* 82, WINED3DRS_STIPPLEPATTERN18 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3395 { /* 83, WINED3DRS_STIPPLEPATTERN19 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3396 { /* 84, WINED3DRS_STIPPLEPATTERN20 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3397 { /* 85, WINED3DRS_STIPPLEPATTERN21 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3398 { /* 86, WINED3DRS_STIPPLEPATTERN22 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3399 { /* 87, WINED3DRS_STIPPLEPATTERN23 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3400 { /* 88, WINED3DRS_STIPPLEPATTERN24 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3401 { /* 89, WINED3DRS_STIPPLEPATTERN25 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3402 { /* 90, WINED3DRS_STIPPLEPATTERN26 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3403 { /* 91, WINED3DRS_STIPPLEPATTERN27 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3404 { /* 92, WINED3DRS_STIPPLEPATTERN28 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3405 { /* 93, WINED3DRS_STIPPLEPATTERN29 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3406 { /* 94, WINED3DRS_STIPPLEPATTERN30 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
3407 { /* 95, WINED3DRS_STIPPLEPATTERN31 */ 0 /* Obsolete, should be handled by ddraw */, state_undefined },
Stefan Dösinger2a24e842006-12-06 13:22:12 +01003408 { /* 96, Undefined */ 0, state_undefined },
3409 { /* 97, Undefined */ 0, state_undefined },
3410 { /* 98, Undefined */ 0, state_undefined },
3411 { /* 99, Undefined */ 0, state_undefined },
3412 { /*100, Undefined */ 0, state_undefined },
3413 { /*101, Undefined */ 0, state_undefined },
3414 { /*102, Undefined */ 0, state_undefined },
3415 { /*103, Undefined */ 0, state_undefined },
3416 { /*104, Undefined */ 0, state_undefined },
3417 { /*105, Undefined */ 0, state_undefined },
3418 { /*106, Undefined */ 0, state_undefined },
3419 { /*107, Undefined */ 0, state_undefined },
3420 { /*108, Undefined */ 0, state_undefined },
3421 { /*109, Undefined */ 0, state_undefined },
3422 { /*110, Undefined */ 0, state_undefined },
3423 { /*111, Undefined */ 0, state_undefined },
3424 { /*112, Undefined */ 0, state_undefined },
3425 { /*113, Undefined */ 0, state_undefined },
3426 { /*114, Undefined */ 0, state_undefined },
3427 { /*115, Undefined */ 0, state_undefined },
3428 { /*116, Undefined */ 0, state_undefined },
3429 { /*117, Undefined */ 0, state_undefined },
3430 { /*118, Undefined */ 0, state_undefined },
3431 { /*119, Undefined */ 0, state_undefined },
3432 { /*120, Undefined */ 0, state_undefined },
3433 { /*121, Undefined */ 0, state_undefined },
3434 { /*122, Undefined */ 0, state_undefined },
3435 { /*123, Undefined */ 0, state_undefined },
3436 { /*124, Undefined */ 0, state_undefined },
3437 { /*125, Undefined */ 0, state_undefined },
3438 { /*126, Undefined */ 0, state_undefined },
3439 { /*127, Undefined */ 0, state_undefined },
3440 /* Big hole ends */
Stefan Dösinger81dce712006-12-10 23:20:45 +01003441 { /*128, WINED3DRS_WRAP0 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
3442 { /*129, WINED3DRS_WRAP1 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
3443 { /*130, WINED3DRS_WRAP2 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
3444 { /*131, WINED3DRS_WRAP3 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
3445 { /*132, WINED3DRS_WRAP4 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
3446 { /*133, WINED3DRS_WRAP5 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
3447 { /*134, WINED3DRS_WRAP6 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
3448 { /*135, WINED3DRS_WRAP7 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
Stefan Dösinger89e999a2006-12-08 18:01:23 +01003449 { /*136, WINED3DRS_CLIPPING */ STATE_RENDER(WINED3DRS_CLIPPING), state_clipping },
Stefan Dösingera0ff9822007-01-02 22:49:17 +01003450 { /*137, WINED3DRS_LIGHTING */ STATE_RENDER(WINED3DRS_LIGHTING), state_lighting },
Stefan Dösingerff077ec2006-12-15 20:02:13 +01003451 { /*138, WINED3DRS_EXTENTS */ STATE_RENDER(WINED3DRS_EXTENTS), state_extents },
Stefan Dösinger28cc3c82006-12-08 01:45:26 +01003452 { /*139, WINED3DRS_AMBIENT */ STATE_RENDER(WINED3DRS_AMBIENT), state_ambient },
Stefan Dösinger61752732006-12-08 18:42:43 +01003453 { /*140, WINED3DRS_FOGVERTEXMODE */ STATE_RENDER(WINED3DRS_FOGENABLE), state_fog },
Stefan Dösinger81a1dce2006-12-10 22:44:18 +01003454 { /*141, WINED3DRS_COLORVERTEX */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat },
Stefan Dösinger580b9962006-12-10 23:20:26 +01003455 { /*142, WINED3DRS_LOCALVIEWER */ STATE_RENDER(WINED3DRS_LOCALVIEWER), state_localviewer },
Stefan Dösinger2ea57672006-12-10 23:20:05 +01003456 { /*143, WINED3DRS_NORMALIZENORMALS */ STATE_RENDER(WINED3DRS_NORMALIZENORMALS), state_normalize },
Stefan Dösingerff077ec2006-12-15 20:02:13 +01003457 { /*144, WINED3DRS_COLORKEYBLENDENABLE */ STATE_RENDER(WINED3DRS_COLORKEYBLENDENABLE), state_ckeyblend },
Stefan Dösinger81a1dce2006-12-10 22:44:18 +01003458 { /*145, WINED3DRS_DIFFUSEMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat },
3459 { /*146, WINED3DRS_SPECULARMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat },
3460 { /*147, WINED3DRS_AMBIENTMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat },
3461 { /*148, WINED3DRS_EMISSIVEMATERIALSOURCE */ STATE_RENDER(WINED3DRS_COLORVERTEX), state_colormat },
Stefan Dösinger2a24e842006-12-06 13:22:12 +01003462 { /*149, Undefined */ 0, state_undefined },
3463 { /*150, Undefined */ 0, state_undefined },
3464 { /*151, WINED3DRS_VERTEXBLEND */ 0, state_nogl },
Stefan Dösinger89e999a2006-12-08 18:01:23 +01003465 { /*152, WINED3DRS_CLIPPLANEENABLE */ STATE_RENDER(WINED3DRS_CLIPPING), state_clipping },
Stefan Dösinger2a24e842006-12-06 13:22:12 +01003466 { /*153, WINED3DRS_SOFTWAREVERTEXPROCESSING */ 0, state_nogl },
Stefan Dösinger0ec7c8b2006-12-10 23:20:09 +01003467 { /*154, WINED3DRS_POINTSIZE */ STATE_RENDER(WINED3DRS_POINTSIZE), state_psize },
Stefan Dösinger51b41d92006-12-10 23:20:12 +01003468 { /*155, WINED3DRS_POINTSIZE_MIN */ STATE_RENDER(WINED3DRS_POINTSIZE_MIN), state_psizemin },
Stefan Dösinger920225d2006-12-10 23:20:36 +01003469 { /*156, WINED3DRS_POINTSPRITEENABLE */ STATE_RENDER(WINED3DRS_POINTSPRITEENABLE), state_pointsprite },
Stefan Dösingercaa371a2006-12-10 23:20:19 +01003470 { /*157, WINED3DRS_POINTSCALEENABLE */ STATE_RENDER(WINED3DRS_POINTSCALEENABLE), state_pscale },
3471 { /*158, WINED3DRS_POINTSCALE_A */ STATE_RENDER(WINED3DRS_POINTSCALEENABLE), state_pscale },
3472 { /*159, WINED3DRS_POINTSCALE_B */ STATE_RENDER(WINED3DRS_POINTSCALEENABLE), state_pscale },
3473 { /*160, WINED3DRS_POINTSCALE_C */ STATE_RENDER(WINED3DRS_POINTSCALEENABLE), state_pscale },
Stefan Dösinger0c1aba52006-12-10 23:20:40 +01003474 { /*161, WINED3DRS_MULTISAMPLEANTIALIAS */ STATE_RENDER(WINED3DRS_MULTISAMPLEANTIALIAS), state_multisampleaa },
Stefan Dösingerd7b85492006-12-10 23:21:07 +01003475 { /*162, WINED3DRS_MULTISAMPLEMASK */ STATE_RENDER(WINED3DRS_MULTISAMPLEMASK), state_multisampmask },
Stefan Dösingerf154f542006-12-15 20:03:17 +01003476 { /*163, WINED3DRS_PATCHEDGESTYLE */ STATE_RENDER(WINED3DRS_PATCHEDGESTYLE), state_patchedgestyle},
Stefan Dösinger81974702006-12-10 23:21:14 +01003477 { /*164, WINED3DRS_PATCHSEGMENTS */ STATE_RENDER(WINED3DRS_PATCHSEGMENTS), state_patchsegments },
Stefan Dösingere25edbf2006-12-10 23:21:17 +01003478 { /*165, WINED3DRS_DEBUGMONITORTOKEN */ STATE_RENDER(WINED3DRS_DEBUGMONITORTOKEN), state_nogl },
Stefan Dösinger9a0e4b52006-12-10 23:20:15 +01003479 { /*166, WINED3DRS_POINTSIZE_MAX */ STATE_RENDER(WINED3DRS_POINTSIZE_MAX), state_psizemax },
Stefan Dösinger1328da02006-12-08 19:53:41 +01003480 { /*167, WINED3DRS_INDEXEDVERTEXBLENDENABLE */ 0, state_nogl },
Stefan Dösinger4c64b862006-12-10 23:20:22 +01003481 { /*168, WINED3DRS_COLORWRITEENABLE */ STATE_RENDER(WINED3DRS_COLORWRITEENABLE), state_colorwrite },
Stefan Dösinger2a24e842006-12-06 13:22:12 +01003482 { /*169, Undefined */ 0, state_undefined },
3483 { /*170, WINED3DRS_TWEENFACTOR */ 0, state_nogl },
Stefan Dösingerac261722006-12-08 20:21:43 +01003484 { /*171, WINED3DRS_BLENDOP */ STATE_RENDER(WINED3DRS_BLENDOP), state_blendop },
Stefan Dösinger052197a2006-12-10 23:21:21 +01003485 { /*172, WINED3DRS_POSITIONDEGREE */ STATE_RENDER(WINED3DRS_POSITIONDEGREE), state_positiondegree},
Stefan Dösinger3bb41772006-12-10 23:21:25 +01003486 { /*173, WINED3DRS_NORMALDEGREE */ STATE_RENDER(WINED3DRS_NORMALDEGREE), state_normaldegree },
Stefan Dösinger2a24e842006-12-06 13:22:12 +01003487 /*172, WINED3DRS_POSITIONORDER */ /* Value assigned to 2 state names */
3488 /*173, WINED3DRS_NORMALORDER */ /* Value assigned to 2 state names */
Stefan Dösingerd7e55c22006-12-10 23:20:48 +01003489 { /*174, WINED3DRS_SCISSORTESTENABLE */ STATE_RENDER(WINED3DRS_SCISSORTESTENABLE), state_scissor },
Stefan Dösinger30cf5e42006-12-10 23:20:52 +01003490 { /*175, WINED3DRS_SLOPESCALEDEPTHBIAS */ STATE_RENDER(WINED3DRS_DEPTHBIAS), state_depthbias },
Stefan Dösinger1f07e4a2006-12-08 01:51:11 +01003491 { /*176, WINED3DRS_ANTIALIASEDLINEENABLE */ STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), state_blend },
Stefan Dösinger2a24e842006-12-06 13:22:12 +01003492 { /*177, undefined */ 0, state_undefined },
Stefan Dösingercd0d0a72006-12-10 23:21:27 +01003493 { /*178, WINED3DRS_MINTESSELLATIONLEVEL */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation },
3494 { /*179, WINED3DRS_MAXTESSELLATIONLEVEL */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation },
3495 { /*180, WINED3DRS_ADAPTIVETESS_X */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation },
3496 { /*181, WINED3DRS_ADAPTIVETESS_Y */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation },
3497 { /*182, WINED3DRS_ADAPTIVETESS_Z */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation },
3498 { /*183, WINED3DRS_ADAPTIVETESS_W */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation },
3499 { /*184, WINED3DRS_ENABLEADAPTIVETESSELLATION */ STATE_RENDER(WINED3DRS_ENABLEADAPTIVETESSELLATION), state_tessellation },
Stefan Dösinger0d9ae202006-12-08 18:39:45 +01003500 { /*185, WINED3DRS_TWOSIDEDSTENCILMODE */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
3501 { /*186, WINED3DRS_CCW_STENCILFAIL */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
3502 { /*187, WINED3DRS_CCW_STENCILZFAIL */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
3503 { /*188, WINED3DRS_CCW_STENCILPASS */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
3504 { /*189, WINED3DRS_CCW_STENCILFUNC */ STATE_RENDER(WINED3DRS_STENCILENABLE), state_stencil },
Stefan Dösinger4c64b862006-12-10 23:20:22 +01003505 { /*190, WINED3DRS_COLORWRITEENABLE1 */ STATE_RENDER(WINED3DRS_COLORWRITEENABLE), state_colorwrite },
3506 { /*191, WINED3DRS_COLORWRITEENABLE2 */ STATE_RENDER(WINED3DRS_COLORWRITEENABLE), state_colorwrite },
3507 { /*192, WINED3DRS_COLORWRITEENABLE3 */ STATE_RENDER(WINED3DRS_COLORWRITEENABLE), state_colorwrite },
Stefan Dösingerd6245402006-12-25 18:46:59 +01003508 { /*193, WINED3DRS_BLENDFACTOR */ STATE_RENDER(WINED3DRS_BLENDFACTOR), state_blendfactor },
Stefan Dösinger8a5bf912006-12-10 23:13:38 +01003509 { /*194, WINED3DRS_SRGBWRITEENABLE */ STATE_RENDER(WINED3DRS_SRGBWRITEENABLE), state_srgbwrite },
Stefan Dösinger30cf5e42006-12-10 23:20:52 +01003510 { /*195, WINED3DRS_DEPTHBIAS */ STATE_RENDER(WINED3DRS_DEPTHBIAS), state_depthbias },
Stefan Dösinger2a24e842006-12-06 13:22:12 +01003511 { /*196, undefined */ 0, state_undefined },
3512 { /*197, undefined */ 0, state_undefined },
Stefan Dösinger81dce712006-12-10 23:20:45 +01003513 { /*198, WINED3DRS_WRAP8 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
3514 { /*199, WINED3DRS_WRAP9 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
3515 { /*200, WINED3DRS_WRAP10 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
3516 { /*201, WINED3DRS_WRAP11 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
3517 { /*202, WINED3DRS_WRAP12 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
3518 { /*203, WINED3DRS_WRAP13 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
3519 { /*204, WINED3DRS_WRAP14 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
3520 { /*205, WINED3DRS_WRAP15 */ STATE_RENDER(WINED3DRS_WRAP0), state_wrap },
Stefan Dösinger92460b92006-12-10 23:14:36 +01003521 { /*206, WINED3DRS_SEPARATEALPHABLENDENABLE */ STATE_RENDER(WINED3DRS_SEPARATEALPHABLENDENABLE), state_seperateblend },
3522 { /*207, WINED3DRS_SRCBLENDALPHA */ STATE_RENDER(WINED3DRS_SEPARATEALPHABLENDENABLE), state_seperateblend },
3523 { /*208, WINED3DRS_DESTBLENDALPHA */ STATE_RENDER(WINED3DRS_SEPARATEALPHABLENDENABLE), state_seperateblend },
3524 { /*209, WINED3DRS_BLENDOPALPHA */ STATE_RENDER(WINED3DRS_SEPARATEALPHABLENDENABLE), state_seperateblend },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003525 /* Texture stage states */
Stefan Dösinger762af472006-12-19 23:00:58 +01003526 { /*0, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop },
3527 { /*0, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop },
3528 { /*0, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop },
Stefan Dösingerbd6a6ad2006-12-19 23:03:37 +01003529 { /*0, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), tex_alphaop },
3530 { /*0, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), tex_alphaop },
3531 { /*0, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), tex_alphaop },
Stefan Dösingerefbd6d62007-02-15 02:57:49 +01003532 { /*0, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
3533 { /*0, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
3534 { /*0, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
3535 { /*0, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
Stefan Dösinger4e531402006-12-19 23:04:16 +01003536 { /*0, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(0, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003537 { /*0, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3538 { /*0, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3539 { /*0, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3540 { /*0, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3541 { /*0, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3542 { /*0, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3543 { /*0, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3544 { /*0, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3545 { /*0, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3546 { /*0, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
Stefan Dösinger72a4f6e2006-12-19 23:05:08 +01003547 { /*0, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
Stefan Dösinger1021f642006-12-19 23:34:17 +01003548 { /*0, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
Stefan Dösingerc10efb32007-01-01 23:53:59 +01003549 { /*0, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE0), transform_texture },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003550 { /*0, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
Stefan Dösinger762af472006-12-19 23:00:58 +01003551 { /*0, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop },
Stefan Dösingerbd6a6ad2006-12-19 23:03:37 +01003552 { /*0, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), tex_alphaop },
Stefan Dösinger63a8c3c2006-12-19 23:11:21 +01003553 { /*0, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(0, WINED3DTSS_RESULTARG), tex_resultarg },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003554 { /*0, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3555 { /*0, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3556 { /*0, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
Stefan Dösinger557b1fa2006-12-19 23:11:28 +01003557 { /*0, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003558
Stefan Dösinger762af472006-12-19 23:00:58 +01003559 { /*1, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), tex_colorop },
3560 { /*1, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), tex_colorop },
3561 { /*1, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), tex_colorop },
Stefan Dösingerbd6a6ad2006-12-19 23:03:37 +01003562 { /*1, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP), tex_alphaop },
3563 { /*1, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP), tex_alphaop },
3564 { /*1, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP), tex_alphaop },
Stefan Dösingerefbd6d62007-02-15 02:57:49 +01003565 { /*1, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
3566 { /*1, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
3567 { /*1, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
3568 { /*1, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
Stefan Dösinger4e531402006-12-19 23:04:16 +01003569 { /*1, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(1, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003570 { /*1, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3571 { /*1, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3572 { /*1, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3573 { /*1, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3574 { /*1, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3575 { /*1, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3576 { /*1, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3577 { /*1, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3578 { /*1, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3579 { /*1, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
Stefan Dösinger72a4f6e2006-12-19 23:05:08 +01003580 { /*1, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
Stefan Dösinger1021f642006-12-19 23:34:17 +01003581 { /*1, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
Stefan Dösingerc10efb32007-01-01 23:53:59 +01003582 { /*1, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE1), transform_texture },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003583 { /*1, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
Stefan Dösinger762af472006-12-19 23:00:58 +01003584 { /*1, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP), tex_colorop },
Stefan Dösingerbd6a6ad2006-12-19 23:03:37 +01003585 { /*1, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP), tex_alphaop },
Stefan Dösinger63a8c3c2006-12-19 23:11:21 +01003586 { /*1, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(1, WINED3DTSS_RESULTARG), tex_resultarg },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003587 { /*1, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3588 { /*1, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3589 { /*1, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
Stefan Dösinger557b1fa2006-12-19 23:11:28 +01003590 { /*1, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003591
Stefan Dösinger762af472006-12-19 23:00:58 +01003592 { /*2, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), tex_colorop },
3593 { /*2, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), tex_colorop },
3594 { /*2, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), tex_colorop },
Stefan Dösingerbd6a6ad2006-12-19 23:03:37 +01003595 { /*2, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP), tex_alphaop },
3596 { /*2, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP), tex_alphaop },
3597 { /*2, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP), tex_alphaop },
Stefan Dösingerefbd6d62007-02-15 02:57:49 +01003598 { /*2, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
3599 { /*2, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
3600 { /*2, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
3601 { /*2, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
Stefan Dösinger4e531402006-12-19 23:04:16 +01003602 { /*2, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(2, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003603 { /*2, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3604 { /*2, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3605 { /*2, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3606 { /*2, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3607 { /*2, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3608 { /*2, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3609 { /*2, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3610 { /*2, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3611 { /*2, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3612 { /*2, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
Stefan Dösinger72a4f6e2006-12-19 23:05:08 +01003613 { /*2, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
Stefan Dösinger1021f642006-12-19 23:34:17 +01003614 { /*2, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
Stefan Dösingerc10efb32007-01-01 23:53:59 +01003615 { /*2, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE2), transform_texture },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003616 { /*2, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
Stefan Dösinger762af472006-12-19 23:00:58 +01003617 { /*2, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP), tex_colorop },
Stefan Dösingerbd6a6ad2006-12-19 23:03:37 +01003618 { /*2, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP), tex_alphaop },
Stefan Dösinger63a8c3c2006-12-19 23:11:21 +01003619 { /*2, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(2, WINED3DTSS_RESULTARG), tex_resultarg },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003620 { /*2, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3621 { /*2, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3622 { /*2, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
Stefan Dösinger557b1fa2006-12-19 23:11:28 +01003623 { /*2, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003624
Stefan Dösinger762af472006-12-19 23:00:58 +01003625 { /*3, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), tex_colorop },
3626 { /*3, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), tex_colorop },
3627 { /*3, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), tex_colorop },
Stefan Dösingerbd6a6ad2006-12-19 23:03:37 +01003628 { /*3, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP), tex_alphaop },
3629 { /*3, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP), tex_alphaop },
3630 { /*3, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP), tex_alphaop },
Stefan Dösingerefbd6d62007-02-15 02:57:49 +01003631 { /*3, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
3632 { /*3, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
3633 { /*3, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
3634 { /*3, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
Stefan Dösinger4e531402006-12-19 23:04:16 +01003635 { /*3, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(3, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003636 { /*3, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3637 { /*3, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3638 { /*3, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3639 { /*3, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3640 { /*3, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3641 { /*3, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3642 { /*3, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3643 { /*3, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3644 { /*3, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3645 { /*3, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
Stefan Dösinger72a4f6e2006-12-19 23:05:08 +01003646 { /*3, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
Stefan Dösinger1021f642006-12-19 23:34:17 +01003647 { /*3, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
Stefan Dösingerc10efb32007-01-01 23:53:59 +01003648 { /*3, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE3), transform_texture },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003649 { /*3, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
Stefan Dösinger762af472006-12-19 23:00:58 +01003650 { /*3, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP), tex_colorop },
Stefan Dösingerbd6a6ad2006-12-19 23:03:37 +01003651 { /*3, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP), tex_alphaop },
Stefan Dösinger63a8c3c2006-12-19 23:11:21 +01003652 { /*3, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(3, WINED3DTSS_RESULTARG), tex_resultarg },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003653 { /*3, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3654 { /*3, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3655 { /*3, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
Stefan Dösinger557b1fa2006-12-19 23:11:28 +01003656 { /*3, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003657
Stefan Dösinger762af472006-12-19 23:00:58 +01003658 { /*4, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), tex_colorop },
3659 { /*4, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), tex_colorop },
3660 { /*4, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), tex_colorop },
Stefan Dösingerbd6a6ad2006-12-19 23:03:37 +01003661 { /*4, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP), tex_alphaop },
3662 { /*4, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP), tex_alphaop },
3663 { /*4, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP), tex_alphaop },
Stefan Dösingerefbd6d62007-02-15 02:57:49 +01003664 { /*4, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
3665 { /*4, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
3666 { /*4, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
3667 { /*4, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
Stefan Dösinger4e531402006-12-19 23:04:16 +01003668 { /*4, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(4, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003669 { /*4, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3670 { /*4, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3671 { /*4, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3672 { /*4, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3673 { /*4, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3674 { /*4, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3675 { /*4, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3676 { /*4, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3677 { /*4, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3678 { /*4, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
Stefan Dösinger72a4f6e2006-12-19 23:05:08 +01003679 { /*4, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
Stefan Dösinger1021f642006-12-19 23:34:17 +01003680 { /*4, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
Stefan Dösingerc10efb32007-01-01 23:53:59 +01003681 { /*4, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE4), transform_texture },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003682 { /*4, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
Stefan Dösinger762af472006-12-19 23:00:58 +01003683 { /*4, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP), tex_colorop },
Stefan Dösingerbd6a6ad2006-12-19 23:03:37 +01003684 { /*4, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP), tex_alphaop },
Stefan Dösinger63a8c3c2006-12-19 23:11:21 +01003685 { /*4, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(4, WINED3DTSS_RESULTARG), tex_resultarg },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003686 { /*4, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3687 { /*4, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3688 { /*4, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
Stefan Dösinger557b1fa2006-12-19 23:11:28 +01003689 { /*4, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003690
Stefan Dösinger762af472006-12-19 23:00:58 +01003691 { /*5, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), tex_colorop },
3692 { /*5, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), tex_colorop },
3693 { /*5, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), tex_colorop },
Stefan Dösingerbd6a6ad2006-12-19 23:03:37 +01003694 { /*5, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP), tex_alphaop },
3695 { /*5, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP), tex_alphaop },
3696 { /*5, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP), tex_alphaop },
Stefan Dösingerefbd6d62007-02-15 02:57:49 +01003697 { /*5, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
3698 { /*5, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
3699 { /*5, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
3700 { /*5, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
Stefan Dösinger4e531402006-12-19 23:04:16 +01003701 { /*5, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(5, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003702 { /*5, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3703 { /*5, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3704 { /*5, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3705 { /*5, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3706 { /*5, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3707 { /*5, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3708 { /*5, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3709 { /*5, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3710 { /*5, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3711 { /*5, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
Stefan Dösinger72a4f6e2006-12-19 23:05:08 +01003712 { /*5, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
Stefan Dösinger1021f642006-12-19 23:34:17 +01003713 { /*5, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
Stefan Dösingerc10efb32007-01-01 23:53:59 +01003714 { /*5, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE5), transform_texture },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003715 { /*5, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
Stefan Dösinger762af472006-12-19 23:00:58 +01003716 { /*5, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP), tex_colorop },
Stefan Dösingerbd6a6ad2006-12-19 23:03:37 +01003717 { /*5, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP), tex_alphaop },
Stefan Dösinger63a8c3c2006-12-19 23:11:21 +01003718 { /*5, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(5, WINED3DTSS_RESULTARG), tex_resultarg },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003719 { /*5, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3720 { /*5, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3721 { /*5, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
Stefan Dösinger557b1fa2006-12-19 23:11:28 +01003722 { /*5, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003723
Stefan Dösinger762af472006-12-19 23:00:58 +01003724 { /*6, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), tex_colorop },
3725 { /*6, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), tex_colorop },
3726 { /*6, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), tex_colorop },
Stefan Dösingerbd6a6ad2006-12-19 23:03:37 +01003727 { /*6, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP), tex_alphaop },
3728 { /*6, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP), tex_alphaop },
3729 { /*6, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP), tex_alphaop },
Stefan Dösingerefbd6d62007-02-15 02:57:49 +01003730 { /*6, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
3731 { /*6, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
3732 { /*6, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
3733 { /*6, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
Stefan Dösinger4e531402006-12-19 23:04:16 +01003734 { /*6, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(6, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003735 { /*6, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3736 { /*6, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3737 { /*6, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3738 { /*6, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3739 { /*6, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3740 { /*6, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3741 { /*6, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3742 { /*6, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3743 { /*6, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3744 { /*6, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
Stefan Dösinger72a4f6e2006-12-19 23:05:08 +01003745 { /*6, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
Stefan Dösinger1021f642006-12-19 23:34:17 +01003746 { /*6, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
Stefan Dösingerc10efb32007-01-01 23:53:59 +01003747 { /*6, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE6), transform_texture },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003748 { /*6, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
Stefan Dösinger762af472006-12-19 23:00:58 +01003749 { /*6, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP), tex_colorop },
Stefan Dösingerbd6a6ad2006-12-19 23:03:37 +01003750 { /*6, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP), tex_alphaop },
Stefan Dösinger63a8c3c2006-12-19 23:11:21 +01003751 { /*6, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(6, WINED3DTSS_RESULTARG), tex_resultarg },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003752 { /*6, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3753 { /*6, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3754 { /*6, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
Stefan Dösinger557b1fa2006-12-19 23:11:28 +01003755 { /*6, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003756
Stefan Dösinger762af472006-12-19 23:00:58 +01003757 { /*7, 01, WINED3DTSS_COLOROP */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), tex_colorop },
3758 { /*7, 02, WINED3DTSS_COLORARG1 */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), tex_colorop },
3759 { /*7, 03, WINED3DTSS_COLORARG2 */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), tex_colorop },
Stefan Dösingerbd6a6ad2006-12-19 23:03:37 +01003760 { /*7, 04, WINED3DTSS_ALPHAOP */ STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP), tex_alphaop },
3761 { /*7, 05, WINED3DTSS_ALPHAARG1 */ STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP), tex_alphaop },
3762 { /*7, 06, WINED3DTSS_ALPHAARG2 */ STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP), tex_alphaop },
Stefan Dösingerefbd6d62007-02-15 02:57:49 +01003763 { /*7, 07, WINED3DTSS_BUMPENVMAT00 */ STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
3764 { /*7, 08, WINED3DTSS_BUMPENVMAT01 */ STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
3765 { /*7, 09, WINED3DTSS_BUMPENVMAT10 */ STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
3766 { /*7, 10, WINED3DTSS_BUMPENVMAT11 */ STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00), tex_bumpenvmat },
Stefan Dösinger4e531402006-12-19 23:04:16 +01003767 { /*7, 11, WINED3DTSS_TEXCOORDINDEX */ STATE_TEXTURESTAGE(7, WINED3DTSS_TEXCOORDINDEX), tex_coordindex },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003768 { /*7, 12, WINED3DTSS_ADDRESS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3769 { /*7, 13, WINED3DTSS_ADDRESSU */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3770 { /*7, 14, WINED3DTSS_ADDRESSV */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3771 { /*7, 15, WINED3DTSS_BORDERCOLOR */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3772 { /*7, 16, WINED3DTSS_MAGFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3773 { /*7, 17, WINED3DTSS_MINFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3774 { /*7, 18, WINED3DTSS_MIPFILTER */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3775 { /*7, 19, WINED3DTSS_MIPMAPLODBIAS */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3776 { /*7, 20, WINED3DTSS_MAXMIPLEVEL */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3777 { /*7, 21, WINED3DTSS_MAXANISOTROPY */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
Stefan Dösinger72a4f6e2006-12-19 23:05:08 +01003778 { /*7, 22, WINED3DTSS_BUMPENVLSCALE */ STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLSCALE), tex_bumpenvlscale },
Stefan Dösinger1021f642006-12-19 23:34:17 +01003779 { /*7, 23, WINED3DTSS_BUMPENVLOFFSET */ STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLOFFSET), tex_bumpenvloffset },
Stefan Dösingerc10efb32007-01-01 23:53:59 +01003780 { /*7, 24, WINED3DTSS_TEXTURETRANSFORMFLAGS */ STATE_TRANSFORM(WINED3DTS_TEXTURE7), transform_texture },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003781 { /*7, 25, WINED3DTSS_ADDRESSW */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
Stefan Dösinger762af472006-12-19 23:00:58 +01003782 { /*7, 26, WINED3DTSS_COLORARG0 */ STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP), tex_colorop },
Stefan Dösingerbd6a6ad2006-12-19 23:03:37 +01003783 { /*7, 27, WINED3DTSS_ALPHAARG0 */ STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP), tex_alphaop },
Stefan Dösinger63a8c3c2006-12-19 23:11:21 +01003784 { /*7, 28, WINED3DTSS_RESULTARG */ STATE_TEXTURESTAGE(7, WINED3DTSS_RESULTARG), tex_resultarg },
Stefan Dösinger569a2fa2006-12-19 22:43:49 +01003785 { /*7, 29, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3786 { /*7, 30, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
3787 { /*7, 31, undefined */ 0 /* -> sampler state in ddraw / d3d8 */, state_undefined },
Stefan Dösinger557b1fa2006-12-19 23:11:28 +01003788 { /*7, 32, WINED3DTSS_CONSTANT */ 0 /* As long as we don't support D3DTA_CONSTANT */, state_nogl },
Stefan Dösinger2d1aeb42006-12-19 23:14:07 +01003789 /* Sampler states */
Stefan Dösinger666b5072006-12-19 23:26:39 +01003790 { /* 0, Sampler 0 */ STATE_SAMPLER(0), sampler },
3791 { /* 1, Sampler 1 */ STATE_SAMPLER(1), sampler },
3792 { /* 2, Sampler 2 */ STATE_SAMPLER(2), sampler },
3793 { /* 3, Sampler 3 */ STATE_SAMPLER(3), sampler },
3794 { /* 4, Sampler 3 */ STATE_SAMPLER(4), sampler },
3795 { /* 5, Sampler 5 */ STATE_SAMPLER(5), sampler },
3796 { /* 6, Sampler 6 */ STATE_SAMPLER(6), sampler },
3797 { /* 7, Sampler 7 */ STATE_SAMPLER(7), sampler },
3798 { /* 8, Sampler 8 */ STATE_SAMPLER(8), sampler },
3799 { /* 9, Sampler 9 */ STATE_SAMPLER(9), sampler },
3800 { /*10, Sampler 10 */ STATE_SAMPLER(10), sampler },
3801 { /*11, Sampler 11 */ STATE_SAMPLER(11), sampler },
3802 { /*12, Sampler 12 */ STATE_SAMPLER(12), sampler },
3803 { /*13, Sampler 13 */ STATE_SAMPLER(13), sampler },
3804 { /*14, Sampler 14 */ STATE_SAMPLER(14), sampler },
3805 { /*15, Sampler 15 */ STATE_SAMPLER(15), sampler },
Stefan Dösinger22e2a5a2006-12-19 23:22:19 +01003806 /* Pixel shader */
3807 { /* , Pixel Shader */ STATE_PIXELSHADER, pixelshader },
Stefan Dösingerb58715e2006-12-28 18:57:16 +01003808 /* Transform states follow */
3809 { /* 1, undefined */ 0, state_undefined },
Stefan Dösingerf5fafab2007-01-02 00:48:58 +01003810 { /* 2, WINED3DTS_VIEW */ STATE_TRANSFORM(WINED3DTS_VIEW), transform_view },
Stefan Dösinger82bd0792007-01-02 22:50:38 +01003811 { /* 3, WINED3DTS_PROJECTION */ STATE_TRANSFORM(WINED3DTS_PROJECTION), transform_projection},
Stefan Dösingerb58715e2006-12-28 18:57:16 +01003812 { /* 4, undefined */ 0, state_undefined },
3813 { /* 5, undefined */ 0, state_undefined },
3814 { /* 6, undefined */ 0, state_undefined },
3815 { /* 7, undefined */ 0, state_undefined },
3816 { /* 8, undefined */ 0, state_undefined },
3817 { /* 9, undefined */ 0, state_undefined },
3818 { /* 10, undefined */ 0, state_undefined },
3819 { /* 11, undefined */ 0, state_undefined },
3820 { /* 12, undefined */ 0, state_undefined },
3821 { /* 13, undefined */ 0, state_undefined },
3822 { /* 14, undefined */ 0, state_undefined },
3823 { /* 15, undefined */ 0, state_undefined },
Stefan Dösingerc10efb32007-01-01 23:53:59 +01003824 { /* 16, WINED3DTS_TEXTURE0 */ STATE_TRANSFORM(WINED3DTS_TEXTURE0), transform_texture },
3825 { /* 17, WINED3DTS_TEXTURE1 */ STATE_TRANSFORM(WINED3DTS_TEXTURE1), transform_texture },
3826 { /* 18, WINED3DTS_TEXTURE2 */ STATE_TRANSFORM(WINED3DTS_TEXTURE2), transform_texture },
3827 { /* 19, WINED3DTS_TEXTURE3 */ STATE_TRANSFORM(WINED3DTS_TEXTURE3), transform_texture },
3828 { /* 20, WINED3DTS_TEXTURE4 */ STATE_TRANSFORM(WINED3DTS_TEXTURE4), transform_texture },
3829 { /* 21, WINED3DTS_TEXTURE5 */ STATE_TRANSFORM(WINED3DTS_TEXTURE5), transform_texture },
3830 { /* 22, WINED3DTS_TEXTURE6 */ STATE_TRANSFORM(WINED3DTS_TEXTURE6), transform_texture },
3831 { /* 23, WINED3DTS_TEXTURE7 */ STATE_TRANSFORM(WINED3DTS_TEXTURE7), transform_texture },
Stefan Dösingerb58715e2006-12-28 18:57:16 +01003832 /* A huge gap between TEXTURE7 and WORLDMATRIX(0) :-( But entries are needed to catch then if a broken app sets them */
3833 { /* 24, undefined */ 0, state_undefined },
3834 { /* 25, undefined */ 0, state_undefined },
3835 { /* 26, undefined */ 0, state_undefined },
3836 { /* 27, undefined */ 0, state_undefined },
3837 { /* 28, undefined */ 0, state_undefined },
3838 { /* 29, undefined */ 0, state_undefined },
3839 { /* 30, undefined */ 0, state_undefined },
3840 { /* 31, undefined */ 0, state_undefined },
3841 { /* 32, undefined */ 0, state_undefined },
3842 { /* 33, undefined */ 0, state_undefined },
3843 { /* 34, undefined */ 0, state_undefined },
3844 { /* 35, undefined */ 0, state_undefined },
3845 { /* 36, undefined */ 0, state_undefined },
3846 { /* 37, undefined */ 0, state_undefined },
3847 { /* 38, undefined */ 0, state_undefined },
3848 { /* 39, undefined */ 0, state_undefined },
3849 { /* 40, undefined */ 0, state_undefined },
3850 { /* 41, undefined */ 0, state_undefined },
3851 { /* 42, undefined */ 0, state_undefined },
3852 { /* 43, undefined */ 0, state_undefined },
3853 { /* 44, undefined */ 0, state_undefined },
3854 { /* 45, undefined */ 0, state_undefined },
3855 { /* 46, undefined */ 0, state_undefined },
3856 { /* 47, undefined */ 0, state_undefined },
3857 { /* 48, undefined */ 0, state_undefined },
3858 { /* 49, undefined */ 0, state_undefined },
3859 { /* 50, undefined */ 0, state_undefined },
3860 { /* 51, undefined */ 0, state_undefined },
3861 { /* 52, undefined */ 0, state_undefined },
3862 { /* 53, undefined */ 0, state_undefined },
3863 { /* 54, undefined */ 0, state_undefined },
3864 { /* 55, undefined */ 0, state_undefined },
3865 { /* 56, undefined */ 0, state_undefined },
3866 { /* 57, undefined */ 0, state_undefined },
3867 { /* 58, undefined */ 0, state_undefined },
3868 { /* 59, undefined */ 0, state_undefined },
3869 { /* 60, undefined */ 0, state_undefined },
3870 { /* 61, undefined */ 0, state_undefined },
3871 { /* 62, undefined */ 0, state_undefined },
3872 { /* 63, undefined */ 0, state_undefined },
3873 { /* 64, undefined */ 0, state_undefined },
3874 { /* 65, undefined */ 0, state_undefined },
3875 { /* 66, undefined */ 0, state_undefined },
3876 { /* 67, undefined */ 0, state_undefined },
3877 { /* 68, undefined */ 0, state_undefined },
3878 { /* 69, undefined */ 0, state_undefined },
3879 { /* 70, undefined */ 0, state_undefined },
3880 { /* 71, undefined */ 0, state_undefined },
3881 { /* 72, undefined */ 0, state_undefined },
3882 { /* 73, undefined */ 0, state_undefined },
3883 { /* 74, undefined */ 0, state_undefined },
3884 { /* 75, undefined */ 0, state_undefined },
3885 { /* 76, undefined */ 0, state_undefined },
3886 { /* 77, undefined */ 0, state_undefined },
3887 { /* 78, undefined */ 0, state_undefined },
3888 { /* 79, undefined */ 0, state_undefined },
3889 { /* 80, undefined */ 0, state_undefined },
3890 { /* 81, undefined */ 0, state_undefined },
3891 { /* 82, undefined */ 0, state_undefined },
3892 { /* 83, undefined */ 0, state_undefined },
3893 { /* 84, undefined */ 0, state_undefined },
3894 { /* 85, undefined */ 0, state_undefined },
3895 { /* 86, undefined */ 0, state_undefined },
3896 { /* 87, undefined */ 0, state_undefined },
3897 { /* 88, undefined */ 0, state_undefined },
3898 { /* 89, undefined */ 0, state_undefined },
3899 { /* 90, undefined */ 0, state_undefined },
3900 { /* 91, undefined */ 0, state_undefined },
3901 { /* 92, undefined */ 0, state_undefined },
3902 { /* 93, undefined */ 0, state_undefined },
3903 { /* 94, undefined */ 0, state_undefined },
3904 { /* 95, undefined */ 0, state_undefined },
3905 { /* 96, undefined */ 0, state_undefined },
3906 { /* 97, undefined */ 0, state_undefined },
3907 { /* 98, undefined */ 0, state_undefined },
3908 { /* 99, undefined */ 0, state_undefined },
3909 { /*100, undefined */ 0, state_undefined },
3910 { /*101, undefined */ 0, state_undefined },
3911 { /*102, undefined */ 0, state_undefined },
3912 { /*103, undefined */ 0, state_undefined },
3913 { /*104, undefined */ 0, state_undefined },
3914 { /*105, undefined */ 0, state_undefined },
3915 { /*106, undefined */ 0, state_undefined },
3916 { /*107, undefined */ 0, state_undefined },
3917 { /*108, undefined */ 0, state_undefined },
3918 { /*109, undefined */ 0, state_undefined },
3919 { /*110, undefined */ 0, state_undefined },
3920 { /*111, undefined */ 0, state_undefined },
3921 { /*112, undefined */ 0, state_undefined },
3922 { /*113, undefined */ 0, state_undefined },
3923 { /*114, undefined */ 0, state_undefined },
3924 { /*115, undefined */ 0, state_undefined },
3925 { /*116, undefined */ 0, state_undefined },
3926 { /*117, undefined */ 0, state_undefined },
3927 { /*118, undefined */ 0, state_undefined },
3928 { /*119, undefined */ 0, state_undefined },
3929 { /*120, undefined */ 0, state_undefined },
3930 { /*121, undefined */ 0, state_undefined },
3931 { /*122, undefined */ 0, state_undefined },
3932 { /*123, undefined */ 0, state_undefined },
3933 { /*124, undefined */ 0, state_undefined },
3934 { /*125, undefined */ 0, state_undefined },
3935 { /*126, undefined */ 0, state_undefined },
3936 { /*127, undefined */ 0, state_undefined },
3937 { /*128, undefined */ 0, state_undefined },
3938 { /*129, undefined */ 0, state_undefined },
3939 { /*130, undefined */ 0, state_undefined },
3940 { /*131, undefined */ 0, state_undefined },
3941 { /*132, undefined */ 0, state_undefined },
3942 { /*133, undefined */ 0, state_undefined },
3943 { /*134, undefined */ 0, state_undefined },
3944 { /*135, undefined */ 0, state_undefined },
3945 { /*136, undefined */ 0, state_undefined },
3946 { /*137, undefined */ 0, state_undefined },
3947 { /*138, undefined */ 0, state_undefined },
3948 { /*139, undefined */ 0, state_undefined },
3949 { /*140, undefined */ 0, state_undefined },
3950 { /*141, undefined */ 0, state_undefined },
3951 { /*142, undefined */ 0, state_undefined },
3952 { /*143, undefined */ 0, state_undefined },
3953 { /*144, undefined */ 0, state_undefined },
3954 { /*145, undefined */ 0, state_undefined },
3955 { /*146, undefined */ 0, state_undefined },
3956 { /*147, undefined */ 0, state_undefined },
3957 { /*148, undefined */ 0, state_undefined },
3958 { /*149, undefined */ 0, state_undefined },
3959 { /*150, undefined */ 0, state_undefined },
3960 { /*151, undefined */ 0, state_undefined },
3961 { /*152, undefined */ 0, state_undefined },
3962 { /*153, undefined */ 0, state_undefined },
3963 { /*154, undefined */ 0, state_undefined },
3964 { /*155, undefined */ 0, state_undefined },
3965 { /*156, undefined */ 0, state_undefined },
3966 { /*157, undefined */ 0, state_undefined },
3967 { /*158, undefined */ 0, state_undefined },
3968 { /*159, undefined */ 0, state_undefined },
3969 { /*160, undefined */ 0, state_undefined },
3970 { /*161, undefined */ 0, state_undefined },
3971 { /*162, undefined */ 0, state_undefined },
3972 { /*163, undefined */ 0, state_undefined },
3973 { /*164, undefined */ 0, state_undefined },
3974 { /*165, undefined */ 0, state_undefined },
3975 { /*166, undefined */ 0, state_undefined },
3976 { /*167, undefined */ 0, state_undefined },
3977 { /*168, undefined */ 0, state_undefined },
3978 { /*169, undefined */ 0, state_undefined },
3979 { /*170, undefined */ 0, state_undefined },
3980 { /*171, undefined */ 0, state_undefined },
3981 { /*172, undefined */ 0, state_undefined },
3982 { /*173, undefined */ 0, state_undefined },
3983 { /*174, undefined */ 0, state_undefined },
3984 { /*175, undefined */ 0, state_undefined },
3985 { /*176, undefined */ 0, state_undefined },
3986 { /*177, undefined */ 0, state_undefined },
3987 { /*178, undefined */ 0, state_undefined },
3988 { /*179, undefined */ 0, state_undefined },
3989 { /*180, undefined */ 0, state_undefined },
3990 { /*181, undefined */ 0, state_undefined },
3991 { /*182, undefined */ 0, state_undefined },
3992 { /*183, undefined */ 0, state_undefined },
3993 { /*184, undefined */ 0, state_undefined },
3994 { /*185, undefined */ 0, state_undefined },
3995 { /*186, undefined */ 0, state_undefined },
3996 { /*187, undefined */ 0, state_undefined },
3997 { /*188, undefined */ 0, state_undefined },
3998 { /*189, undefined */ 0, state_undefined },
3999 { /*190, undefined */ 0, state_undefined },
4000 { /*191, undefined */ 0, state_undefined },
4001 { /*192, undefined */ 0, state_undefined },
4002 { /*193, undefined */ 0, state_undefined },
4003 { /*194, undefined */ 0, state_undefined },
4004 { /*195, undefined */ 0, state_undefined },
4005 { /*196, undefined */ 0, state_undefined },
4006 { /*197, undefined */ 0, state_undefined },
4007 { /*198, undefined */ 0, state_undefined },
4008 { /*199, undefined */ 0, state_undefined },
4009 { /*200, undefined */ 0, state_undefined },
4010 { /*201, undefined */ 0, state_undefined },
4011 { /*202, undefined */ 0, state_undefined },
4012 { /*203, undefined */ 0, state_undefined },
4013 { /*204, undefined */ 0, state_undefined },
4014 { /*205, undefined */ 0, state_undefined },
4015 { /*206, undefined */ 0, state_undefined },
4016 { /*207, undefined */ 0, state_undefined },
4017 { /*208, undefined */ 0, state_undefined },
4018 { /*209, undefined */ 0, state_undefined },
4019 { /*210, undefined */ 0, state_undefined },
4020 { /*211, undefined */ 0, state_undefined },
4021 { /*212, undefined */ 0, state_undefined },
4022 { /*213, undefined */ 0, state_undefined },
4023 { /*214, undefined */ 0, state_undefined },
4024 { /*215, undefined */ 0, state_undefined },
4025 { /*216, undefined */ 0, state_undefined },
4026 { /*217, undefined */ 0, state_undefined },
4027 { /*218, undefined */ 0, state_undefined },
4028 { /*219, undefined */ 0, state_undefined },
4029 { /*220, undefined */ 0, state_undefined },
4030 { /*221, undefined */ 0, state_undefined },
4031 { /*222, undefined */ 0, state_undefined },
4032 { /*223, undefined */ 0, state_undefined },
4033 { /*224, undefined */ 0, state_undefined },
4034 { /*225, undefined */ 0, state_undefined },
4035 { /*226, undefined */ 0, state_undefined },
4036 { /*227, undefined */ 0, state_undefined },
4037 { /*228, undefined */ 0, state_undefined },
4038 { /*229, undefined */ 0, state_undefined },
4039 { /*230, undefined */ 0, state_undefined },
4040 { /*231, undefined */ 0, state_undefined },
4041 { /*232, undefined */ 0, state_undefined },
4042 { /*233, undefined */ 0, state_undefined },
4043 { /*234, undefined */ 0, state_undefined },
4044 { /*235, undefined */ 0, state_undefined },
4045 { /*236, undefined */ 0, state_undefined },
4046 { /*237, undefined */ 0, state_undefined },
4047 { /*238, undefined */ 0, state_undefined },
4048 { /*239, undefined */ 0, state_undefined },
4049 { /*240, undefined */ 0, state_undefined },
4050 { /*241, undefined */ 0, state_undefined },
4051 { /*242, undefined */ 0, state_undefined },
4052 { /*243, undefined */ 0, state_undefined },
4053 { /*244, undefined */ 0, state_undefined },
4054 { /*245, undefined */ 0, state_undefined },
4055 { /*246, undefined */ 0, state_undefined },
4056 { /*247, undefined */ 0, state_undefined },
4057 { /*248, undefined */ 0, state_undefined },
4058 { /*249, undefined */ 0, state_undefined },
4059 { /*250, undefined */ 0, state_undefined },
4060 { /*251, undefined */ 0, state_undefined },
4061 { /*252, undefined */ 0, state_undefined },
4062 { /*253, undefined */ 0, state_undefined },
4063 { /*254, undefined */ 0, state_undefined },
4064 { /*255, undefined */ 0, state_undefined },
4065 /* End huge gap */
Stefan Dösinger5fa0f7f2007-01-02 22:47:39 +01004066 { /*256, WINED3DTS_WORLDMATRIX(0) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), transform_world },
Stefan Dösingera710f722007-01-02 00:25:51 +01004067 { /*257, WINED3DTS_WORLDMATRIX(1) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(1)), transform_worldex },
4068 { /*258, WINED3DTS_WORLDMATRIX(2) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(2)), transform_worldex },
4069 { /*259, WINED3DTS_WORLDMATRIX(3) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(3)), transform_worldex },
4070 { /*260, WINED3DTS_WORLDMATRIX(4) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(4)), transform_worldex },
4071 { /*261, WINED3DTS_WORLDMATRIX(5) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(5)), transform_worldex },
4072 { /*262, WINED3DTS_WORLDMATRIX(6) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(6)), transform_worldex },
4073 { /*263, WINED3DTS_WORLDMATRIX(7) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(7)), transform_worldex },
4074 { /*264, WINED3DTS_WORLDMATRIX(8) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(8)), transform_worldex },
4075 { /*265, WINED3DTS_WORLDMATRIX(9) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(9)), transform_worldex },
4076 { /*266, WINED3DTS_WORLDMATRIX(10) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(10)), transform_worldex },
4077 { /*267, WINED3DTS_WORLDMATRIX(11) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(11)), transform_worldex },
4078 { /*268, WINED3DTS_WORLDMATRIX(12) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(12)), transform_worldex },
4079 { /*269, WINED3DTS_WORLDMATRIX(13) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(13)), transform_worldex },
4080 { /*270, WINED3DTS_WORLDMATRIX(14) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(14)), transform_worldex },
4081 { /*271, WINED3DTS_WORLDMATRIX(15) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(15)), transform_worldex },
4082 { /*272, WINED3DTS_WORLDMATRIX(16) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(16)), transform_worldex },
4083 { /*273, WINED3DTS_WORLDMATRIX(17) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(17)), transform_worldex },
4084 { /*274, WINED3DTS_WORLDMATRIX(18) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(18)), transform_worldex },
4085 { /*275, WINED3DTS_WORLDMATRIX(19) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(19)), transform_worldex },
4086 { /*276, WINED3DTS_WORLDMATRIX(20) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(20)), transform_worldex },
4087 { /*277, WINED3DTS_WORLDMATRIX(21) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(21)), transform_worldex },
4088 { /*278, WINED3DTS_WORLDMATRIX(22) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(22)), transform_worldex },
4089 { /*279, WINED3DTS_WORLDMATRIX(23) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(23)), transform_worldex },
4090 { /*280, WINED3DTS_WORLDMATRIX(24) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(24)), transform_worldex },
4091 { /*281, WINED3DTS_WORLDMATRIX(25) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(25)), transform_worldex },
4092 { /*282, WINED3DTS_WORLDMATRIX(26) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(26)), transform_worldex },
4093 { /*283, WINED3DTS_WORLDMATRIX(27) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(27)), transform_worldex },
4094 { /*284, WINED3DTS_WORLDMATRIX(28) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(28)), transform_worldex },
4095 { /*285, WINED3DTS_WORLDMATRIX(29) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(29)), transform_worldex },
4096 { /*286, WINED3DTS_WORLDMATRIX(30) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(30)), transform_worldex },
4097 { /*287, WINED3DTS_WORLDMATRIX(31) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(31)), transform_worldex },
4098 { /*288, WINED3DTS_WORLDMATRIX(32) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(32)), transform_worldex },
4099 { /*289, WINED3DTS_WORLDMATRIX(33) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(33)), transform_worldex },
4100 { /*290, WINED3DTS_WORLDMATRIX(34) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(34)), transform_worldex },
4101 { /*291, WINED3DTS_WORLDMATRIX(35) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(35)), transform_worldex },
4102 { /*292, WINED3DTS_WORLDMATRIX(36) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(36)), transform_worldex },
4103 { /*293, WINED3DTS_WORLDMATRIX(37) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(37)), transform_worldex },
4104 { /*294, WINED3DTS_WORLDMATRIX(38) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(38)), transform_worldex },
4105 { /*295, WINED3DTS_WORLDMATRIX(39) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(39)), transform_worldex },
4106 { /*296, WINED3DTS_WORLDMATRIX(40) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(40)), transform_worldex },
4107 { /*297, WINED3DTS_WORLDMATRIX(41) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(41)), transform_worldex },
4108 { /*298, WINED3DTS_WORLDMATRIX(42) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(42)), transform_worldex },
4109 { /*299, WINED3DTS_WORLDMATRIX(43) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(43)), transform_worldex },
4110 { /*300, WINED3DTS_WORLDMATRIX(44) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(44)), transform_worldex },
4111 { /*301, WINED3DTS_WORLDMATRIX(45) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(45)), transform_worldex },
4112 { /*302, WINED3DTS_WORLDMATRIX(46) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(46)), transform_worldex },
4113 { /*303, WINED3DTS_WORLDMATRIX(47) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(47)), transform_worldex },
4114 { /*304, WINED3DTS_WORLDMATRIX(48) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(48)), transform_worldex },
4115 { /*305, WINED3DTS_WORLDMATRIX(49) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(49)), transform_worldex },
4116 { /*306, WINED3DTS_WORLDMATRIX(50) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(50)), transform_worldex },
4117 { /*307, WINED3DTS_WORLDMATRIX(51) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(51)), transform_worldex },
4118 { /*308, WINED3DTS_WORLDMATRIX(52) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(52)), transform_worldex },
4119 { /*309, WINED3DTS_WORLDMATRIX(53) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(53)), transform_worldex },
4120 { /*310, WINED3DTS_WORLDMATRIX(54) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(54)), transform_worldex },
4121 { /*311, WINED3DTS_WORLDMATRIX(55) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(55)), transform_worldex },
4122 { /*312, WINED3DTS_WORLDMATRIX(56) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(56)), transform_worldex },
4123 { /*313, WINED3DTS_WORLDMATRIX(57) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(57)), transform_worldex },
4124 { /*314, WINED3DTS_WORLDMATRIX(58) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(58)), transform_worldex },
4125 { /*315, WINED3DTS_WORLDMATRIX(59) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(59)), transform_worldex },
4126 { /*316, WINED3DTS_WORLDMATRIX(60) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(60)), transform_worldex },
4127 { /*317, WINED3DTS_WORLDMATRIX(61) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(61)), transform_worldex },
4128 { /*318, WINED3DTS_WORLDMATRIX(62) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(62)), transform_worldex },
4129 { /*319, WINED3DTS_WORLDMATRIX(63) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(63)), transform_worldex },
4130 { /*320, WINED3DTS_WORLDMATRIX(64) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(64)), transform_worldex },
4131 { /*321, WINED3DTS_WORLDMATRIX(65) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(65)), transform_worldex },
4132 { /*322, WINED3DTS_WORLDMATRIX(66) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(66)), transform_worldex },
4133 { /*323, WINED3DTS_WORLDMATRIX(67) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(67)), transform_worldex },
4134 { /*324, WINED3DTS_WORLDMATRIX(68) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(68)), transform_worldex },
4135 { /*325, WINED3DTS_WORLDMATRIX(68) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(69)), transform_worldex },
4136 { /*326, WINED3DTS_WORLDMATRIX(70) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(70)), transform_worldex },
4137 { /*327, WINED3DTS_WORLDMATRIX(71) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(71)), transform_worldex },
4138 { /*328, WINED3DTS_WORLDMATRIX(72) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(72)), transform_worldex },
4139 { /*329, WINED3DTS_WORLDMATRIX(73) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(73)), transform_worldex },
4140 { /*330, WINED3DTS_WORLDMATRIX(74) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(74)), transform_worldex },
4141 { /*331, WINED3DTS_WORLDMATRIX(75) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(75)), transform_worldex },
4142 { /*332, WINED3DTS_WORLDMATRIX(76) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(76)), transform_worldex },
4143 { /*333, WINED3DTS_WORLDMATRIX(77) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(77)), transform_worldex },
4144 { /*334, WINED3DTS_WORLDMATRIX(78) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(78)), transform_worldex },
4145 { /*335, WINED3DTS_WORLDMATRIX(79) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(79)), transform_worldex },
4146 { /*336, WINED3DTS_WORLDMATRIX(80) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(80)), transform_worldex },
4147 { /*337, WINED3DTS_WORLDMATRIX(81) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(81)), transform_worldex },
4148 { /*338, WINED3DTS_WORLDMATRIX(82) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(82)), transform_worldex },
4149 { /*339, WINED3DTS_WORLDMATRIX(83) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(83)), transform_worldex },
4150 { /*340, WINED3DTS_WORLDMATRIX(84) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(84)), transform_worldex },
4151 { /*341, WINED3DTS_WORLDMATRIX(85) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(85)), transform_worldex },
4152 { /*341, WINED3DTS_WORLDMATRIX(86) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(86)), transform_worldex },
4153 { /*343, WINED3DTS_WORLDMATRIX(87) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(87)), transform_worldex },
4154 { /*344, WINED3DTS_WORLDMATRIX(88) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(88)), transform_worldex },
4155 { /*345, WINED3DTS_WORLDMATRIX(89) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(89)), transform_worldex },
4156 { /*346, WINED3DTS_WORLDMATRIX(90) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(90)), transform_worldex },
4157 { /*347, WINED3DTS_WORLDMATRIX(91) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(91)), transform_worldex },
4158 { /*348, WINED3DTS_WORLDMATRIX(92) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(92)), transform_worldex },
4159 { /*349, WINED3DTS_WORLDMATRIX(93) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(93)), transform_worldex },
4160 { /*350, WINED3DTS_WORLDMATRIX(94) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(94)), transform_worldex },
4161 { /*351, WINED3DTS_WORLDMATRIX(95) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(95)), transform_worldex },
4162 { /*352, WINED3DTS_WORLDMATRIX(96) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(96)), transform_worldex },
4163 { /*353, WINED3DTS_WORLDMATRIX(97) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(97)), transform_worldex },
4164 { /*354, WINED3DTS_WORLDMATRIX(98) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(98)), transform_worldex },
4165 { /*355, WINED3DTS_WORLDMATRIX(99) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(99)), transform_worldex },
4166 { /*356, WINED3DTS_WORLDMATRIX(100) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(100)), transform_worldex },
4167 { /*357, WINED3DTS_WORLDMATRIX(101) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(101)), transform_worldex },
4168 { /*358, WINED3DTS_WORLDMATRIX(102) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(102)), transform_worldex },
4169 { /*359, WINED3DTS_WORLDMATRIX(103) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(103)), transform_worldex },
4170 { /*360, WINED3DTS_WORLDMATRIX(104) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(104)), transform_worldex },
4171 { /*361, WINED3DTS_WORLDMATRIX(105) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(105)), transform_worldex },
4172 { /*362, WINED3DTS_WORLDMATRIX(106) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(106)), transform_worldex },
4173 { /*363, WINED3DTS_WORLDMATRIX(107) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(107)), transform_worldex },
4174 { /*364, WINED3DTS_WORLDMATRIX(108) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(108)), transform_worldex },
4175 { /*365, WINED3DTS_WORLDMATRIX(109) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(109)), transform_worldex },
4176 { /*366, WINED3DTS_WORLDMATRIX(110) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(110)), transform_worldex },
4177 { /*367, WINED3DTS_WORLDMATRIX(111) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(111)), transform_worldex },
4178 { /*368, WINED3DTS_WORLDMATRIX(112) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(112)), transform_worldex },
4179 { /*369, WINED3DTS_WORLDMATRIX(113) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(113)), transform_worldex },
4180 { /*370, WINED3DTS_WORLDMATRIX(114) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(114)), transform_worldex },
4181 { /*371, WINED3DTS_WORLDMATRIX(115) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(115)), transform_worldex },
4182 { /*372, WINED3DTS_WORLDMATRIX(116) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(116)), transform_worldex },
4183 { /*373, WINED3DTS_WORLDMATRIX(117) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(117)), transform_worldex },
4184 { /*374, WINED3DTS_WORLDMATRIX(118) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(118)), transform_worldex },
4185 { /*375, WINED3DTS_WORLDMATRIX(119) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(119)), transform_worldex },
4186 { /*376, WINED3DTS_WORLDMATRIX(120) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(120)), transform_worldex },
4187 { /*377, WINED3DTS_WORLDMATRIX(121) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(121)), transform_worldex },
4188 { /*378, WINED3DTS_WORLDMATRIX(122) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(122)), transform_worldex },
4189 { /*379, WINED3DTS_WORLDMATRIX(123) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(123)), transform_worldex },
4190 { /*380, WINED3DTS_WORLDMATRIX(124) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(124)), transform_worldex },
4191 { /*381, WINED3DTS_WORLDMATRIX(125) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(125)), transform_worldex },
4192 { /*382, WINED3DTS_WORLDMATRIX(126) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(126)), transform_worldex },
4193 { /*383, WINED3DTS_WORLDMATRIX(127) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(127)), transform_worldex },
4194 { /*384, WINED3DTS_WORLDMATRIX(128) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(128)), transform_worldex },
4195 { /*385, WINED3DTS_WORLDMATRIX(129) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(129)), transform_worldex },
4196 { /*386, WINED3DTS_WORLDMATRIX(130) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(130)), transform_worldex },
4197 { /*387, WINED3DTS_WORLDMATRIX(131) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(131)), transform_worldex },
4198 { /*388, WINED3DTS_WORLDMATRIX(132) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(132)), transform_worldex },
4199 { /*389, WINED3DTS_WORLDMATRIX(133) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(133)), transform_worldex },
4200 { /*390, WINED3DTS_WORLDMATRIX(134) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(134)), transform_worldex },
4201 { /*391, WINED3DTS_WORLDMATRIX(135) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(135)), transform_worldex },
4202 { /*392, WINED3DTS_WORLDMATRIX(136) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(136)), transform_worldex },
4203 { /*393, WINED3DTS_WORLDMATRIX(137) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(137)), transform_worldex },
4204 { /*394, WINED3DTS_WORLDMATRIX(138) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(138)), transform_worldex },
4205 { /*395, WINED3DTS_WORLDMATRIX(139) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(139)), transform_worldex },
4206 { /*396, WINED3DTS_WORLDMATRIX(140) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(140)), transform_worldex },
4207 { /*397, WINED3DTS_WORLDMATRIX(141) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(141)), transform_worldex },
4208 { /*398, WINED3DTS_WORLDMATRIX(142) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(142)), transform_worldex },
4209 { /*399, WINED3DTS_WORLDMATRIX(143) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(143)), transform_worldex },
4210 { /*400, WINED3DTS_WORLDMATRIX(144) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(144)), transform_worldex },
4211 { /*401, WINED3DTS_WORLDMATRIX(145) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(145)), transform_worldex },
4212 { /*402, WINED3DTS_WORLDMATRIX(146) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(146)), transform_worldex },
4213 { /*403, WINED3DTS_WORLDMATRIX(147) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(147)), transform_worldex },
4214 { /*404, WINED3DTS_WORLDMATRIX(148) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(148)), transform_worldex },
4215 { /*405, WINED3DTS_WORLDMATRIX(149) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(149)), transform_worldex },
4216 { /*406, WINED3DTS_WORLDMATRIX(150) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(150)), transform_worldex },
4217 { /*407, WINED3DTS_WORLDMATRIX(151) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(151)), transform_worldex },
4218 { /*408, WINED3DTS_WORLDMATRIX(152) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(152)), transform_worldex },
4219 { /*409, WINED3DTS_WORLDMATRIX(153) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(153)), transform_worldex },
4220 { /*410, WINED3DTS_WORLDMATRIX(154) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(154)), transform_worldex },
4221 { /*411, WINED3DTS_WORLDMATRIX(155) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(155)), transform_worldex },
4222 { /*412, WINED3DTS_WORLDMATRIX(156) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(156)), transform_worldex },
4223 { /*413, WINED3DTS_WORLDMATRIX(157) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(157)), transform_worldex },
4224 { /*414, WINED3DTS_WORLDMATRIX(158) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(158)), transform_worldex },
4225 { /*415, WINED3DTS_WORLDMATRIX(159) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(159)), transform_worldex },
4226 { /*416, WINED3DTS_WORLDMATRIX(160) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(160)), transform_worldex },
4227 { /*417, WINED3DTS_WORLDMATRIX(161) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(161)), transform_worldex },
4228 { /*418, WINED3DTS_WORLDMATRIX(162) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(162)), transform_worldex },
4229 { /*419, WINED3DTS_WORLDMATRIX(163) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(163)), transform_worldex },
4230 { /*420, WINED3DTS_WORLDMATRIX(164) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(164)), transform_worldex },
4231 { /*421, WINED3DTS_WORLDMATRIX(165) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(165)), transform_worldex },
4232 { /*422, WINED3DTS_WORLDMATRIX(166) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(166)), transform_worldex },
4233 { /*423, WINED3DTS_WORLDMATRIX(167) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(167)), transform_worldex },
4234 { /*424, WINED3DTS_WORLDMATRIX(168) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(168)), transform_worldex },
4235 { /*425, WINED3DTS_WORLDMATRIX(168) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(169)), transform_worldex },
4236 { /*426, WINED3DTS_WORLDMATRIX(170) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(170)), transform_worldex },
4237 { /*427, WINED3DTS_WORLDMATRIX(171) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(171)), transform_worldex },
4238 { /*428, WINED3DTS_WORLDMATRIX(172) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(172)), transform_worldex },
4239 { /*429, WINED3DTS_WORLDMATRIX(173) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(173)), transform_worldex },
4240 { /*430, WINED3DTS_WORLDMATRIX(174) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(174)), transform_worldex },
4241 { /*431, WINED3DTS_WORLDMATRIX(175) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(175)), transform_worldex },
4242 { /*432, WINED3DTS_WORLDMATRIX(176) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(176)), transform_worldex },
4243 { /*433, WINED3DTS_WORLDMATRIX(177) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(177)), transform_worldex },
4244 { /*434, WINED3DTS_WORLDMATRIX(178) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(178)), transform_worldex },
4245 { /*435, WINED3DTS_WORLDMATRIX(179) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(179)), transform_worldex },
4246 { /*436, WINED3DTS_WORLDMATRIX(180) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(180)), transform_worldex },
4247 { /*437, WINED3DTS_WORLDMATRIX(181) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(181)), transform_worldex },
4248 { /*438, WINED3DTS_WORLDMATRIX(182) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(182)), transform_worldex },
4249 { /*439, WINED3DTS_WORLDMATRIX(183) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(183)), transform_worldex },
4250 { /*440, WINED3DTS_WORLDMATRIX(184) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(184)), transform_worldex },
4251 { /*441, WINED3DTS_WORLDMATRIX(185) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(185)), transform_worldex },
4252 { /*441, WINED3DTS_WORLDMATRIX(186) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(186)), transform_worldex },
4253 { /*443, WINED3DTS_WORLDMATRIX(187) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(187)), transform_worldex },
4254 { /*444, WINED3DTS_WORLDMATRIX(188) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(188)), transform_worldex },
4255 { /*445, WINED3DTS_WORLDMATRIX(189) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(189)), transform_worldex },
4256 { /*446, WINED3DTS_WORLDMATRIX(190) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(190)), transform_worldex },
4257 { /*447, WINED3DTS_WORLDMATRIX(191) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(191)), transform_worldex },
4258 { /*448, WINED3DTS_WORLDMATRIX(192) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(192)), transform_worldex },
4259 { /*449, WINED3DTS_WORLDMATRIX(193) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(193)), transform_worldex },
4260 { /*450, WINED3DTS_WORLDMATRIX(194) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(194)), transform_worldex },
4261 { /*451, WINED3DTS_WORLDMATRIX(195) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(195)), transform_worldex },
4262 { /*452, WINED3DTS_WORLDMATRIX(196) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(196)), transform_worldex },
4263 { /*453, WINED3DTS_WORLDMATRIX(197) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(197)), transform_worldex },
4264 { /*454, WINED3DTS_WORLDMATRIX(198) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(198)), transform_worldex },
4265 { /*455, WINED3DTS_WORLDMATRIX(199) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(199)), transform_worldex },
4266 { /*356, WINED3DTS_WORLDMATRIX(200) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(200)), transform_worldex },
4267 { /*457, WINED3DTS_WORLDMATRIX(201) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(201)), transform_worldex },
4268 { /*458, WINED3DTS_WORLDMATRIX(202) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(202)), transform_worldex },
4269 { /*459, WINED3DTS_WORLDMATRIX(203) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(203)), transform_worldex },
4270 { /*460, WINED3DTS_WORLDMATRIX(204) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(204)), transform_worldex },
4271 { /*461, WINED3DTS_WORLDMATRIX(205) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(205)), transform_worldex },
4272 { /*462, WINED3DTS_WORLDMATRIX(206) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(206)), transform_worldex },
4273 { /*463, WINED3DTS_WORLDMATRIX(207) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(207)), transform_worldex },
4274 { /*464, WINED3DTS_WORLDMATRIX(208) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(208)), transform_worldex },
4275 { /*465, WINED3DTS_WORLDMATRIX(209) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(209)), transform_worldex },
4276 { /*466, WINED3DTS_WORLDMATRIX(210) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(210)), transform_worldex },
4277 { /*467, WINED3DTS_WORLDMATRIX(211) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(211)), transform_worldex },
4278 { /*468, WINED3DTS_WORLDMATRIX(212) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(212)), transform_worldex },
4279 { /*469, WINED3DTS_WORLDMATRIX(213) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(213)), transform_worldex },
4280 { /*470, WINED3DTS_WORLDMATRIX(214) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(214)), transform_worldex },
4281 { /*471, WINED3DTS_WORLDMATRIX(215) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(215)), transform_worldex },
4282 { /*472, WINED3DTS_WORLDMATRIX(216) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(216)), transform_worldex },
4283 { /*473, WINED3DTS_WORLDMATRIX(217) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(217)), transform_worldex },
4284 { /*474, WINED3DTS_WORLDMATRIX(218) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(218)), transform_worldex },
4285 { /*475, WINED3DTS_WORLDMATRIX(219) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(219)), transform_worldex },
4286 { /*476, WINED3DTS_WORLDMATRIX(220) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(220)), transform_worldex },
4287 { /*477, WINED3DTS_WORLDMATRIX(221) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(221)), transform_worldex },
4288 { /*478, WINED3DTS_WORLDMATRIX(222) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(222)), transform_worldex },
4289 { /*479, WINED3DTS_WORLDMATRIX(223) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(223)), transform_worldex },
4290 { /*480, WINED3DTS_WORLDMATRIX(224) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(224)), transform_worldex },
4291 { /*481, WINED3DTS_WORLDMATRIX(225) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(225)), transform_worldex },
4292 { /*482, WINED3DTS_WORLDMATRIX(226) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(226)), transform_worldex },
4293 { /*483, WINED3DTS_WORLDMATRIX(227) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(227)), transform_worldex },
4294 { /*484, WINED3DTS_WORLDMATRIX(228) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(228)), transform_worldex },
4295 { /*485, WINED3DTS_WORLDMATRIX(229) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(229)), transform_worldex },
4296 { /*486, WINED3DTS_WORLDMATRIX(230) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(230)), transform_worldex },
4297 { /*487, WINED3DTS_WORLDMATRIX(231) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(231)), transform_worldex },
4298 { /*488, WINED3DTS_WORLDMATRIX(232) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(232)), transform_worldex },
4299 { /*489, WINED3DTS_WORLDMATRIX(233) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(233)), transform_worldex },
4300 { /*490, WINED3DTS_WORLDMATRIX(234) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(234)), transform_worldex },
4301 { /*491, WINED3DTS_WORLDMATRIX(235) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(235)), transform_worldex },
4302 { /*492, WINED3DTS_WORLDMATRIX(236) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(236)), transform_worldex },
4303 { /*493, WINED3DTS_WORLDMATRIX(237) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(237)), transform_worldex },
4304 { /*494, WINED3DTS_WORLDMATRIX(238) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(238)), transform_worldex },
4305 { /*495, WINED3DTS_WORLDMATRIX(239) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(239)), transform_worldex },
4306 { /*496, WINED3DTS_WORLDMATRIX(240) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(240)), transform_worldex },
4307 { /*497, WINED3DTS_WORLDMATRIX(241) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(241)), transform_worldex },
4308 { /*498, WINED3DTS_WORLDMATRIX(242) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(242)), transform_worldex },
4309 { /*499, WINED3DTS_WORLDMATRIX(243) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(243)), transform_worldex },
4310 { /*500, WINED3DTS_WORLDMATRIX(244) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(244)), transform_worldex },
4311 { /*501, WINED3DTS_WORLDMATRIX(245) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(245)), transform_worldex },
4312 { /*502, WINED3DTS_WORLDMATRIX(246) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(246)), transform_worldex },
4313 { /*503, WINED3DTS_WORLDMATRIX(247) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(247)), transform_worldex },
4314 { /*504, WINED3DTS_WORLDMATRIX(248) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(248)), transform_worldex },
4315 { /*505, WINED3DTS_WORLDMATRIX(249) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(249)), transform_worldex },
4316 { /*506, WINED3DTS_WORLDMATRIX(250) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(250)), transform_worldex },
4317 { /*507, WINED3DTS_WORLDMATRIX(251) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(251)), transform_worldex },
4318 { /*508, WINED3DTS_WORLDMATRIX(252) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(252)), transform_worldex },
4319 { /*509, WINED3DTS_WORLDMATRIX(253) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(253)), transform_worldex },
4320 { /*510, WINED3DTS_WORLDMATRIX(254) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(254)), transform_worldex },
4321 { /*511, WINED3DTS_WORLDMATRIX(255) */ STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(255)), transform_worldex },
Stefan Dösingeref1ebb62007-01-02 00:35:07 +01004322 /* Various Vertex states follow */
4323 { /* , STATE_STREAMSRC */ STATE_VDECL, vertexdeclaration },
Stefan Dösinger59ae2a52007-02-19 15:25:32 +01004324 { /* , STATE_INDEXBUFFER */ STATE_INDEXBUFFER, indexbuffer },
Stefan Dösingeref1ebb62007-01-02 00:35:07 +01004325 { /* , STATE_VDECL */ STATE_VDECL, vertexdeclaration },
4326 { /* , STATE_VSHADER */ STATE_VDECL, vertexdeclaration },
Stefan Dösinger0d700be2007-01-04 00:05:05 +01004327 { /* , STATE_VIEWPORT */ STATE_VIEWPORT, viewport },
Stefan Dösinger8e37fcd2007-01-06 18:17:27 +01004328 { /* , STATE_VERTEXSHADERCONSTANT */ STATE_VERTEXSHADERCONSTANT, shaderconstant },
4329 { /* , STATE_PIXELSHADERCONSTANT */ STATE_VERTEXSHADERCONSTANT, shaderconstant },
Stefan Dösinger174b6322007-02-14 17:48:52 +01004330 /* Lights */
4331 { /* , STATE_ACTIVELIGHT(0) */ STATE_ACTIVELIGHT(0), light },
4332 { /* , STATE_ACTIVELIGHT(1) */ STATE_ACTIVELIGHT(1), light },
4333 { /* , STATE_ACTIVELIGHT(2) */ STATE_ACTIVELIGHT(2), light },
4334 { /* , STATE_ACTIVELIGHT(3) */ STATE_ACTIVELIGHT(3), light },
4335 { /* , STATE_ACTIVELIGHT(4) */ STATE_ACTIVELIGHT(4), light },
4336 { /* , STATE_ACTIVELIGHT(5) */ STATE_ACTIVELIGHT(5), light },
4337 { /* , STATE_ACTIVELIGHT(6) */ STATE_ACTIVELIGHT(6), light },
4338 { /* , STATE_ACTIVELIGHT(7) */ STATE_ACTIVELIGHT(7), light },
Stefan Dösingerecfd4cb2007-02-19 15:25:16 +01004339
Stefan Dösinger409aa732007-02-28 14:36:36 +01004340 { /* Scissor rect */ STATE_SCISSORRECT, scissorrect },
4341 /* Clip planes */
4342 { /* STATE_CLIPPLANE(0) */ STATE_CLIPPLANE(0), clipplane },
4343 { /* STATE_CLIPPLANE(1) */ STATE_CLIPPLANE(1), clipplane },
4344 { /* STATE_CLIPPLANE(2) */ STATE_CLIPPLANE(2), clipplane },
4345 { /* STATE_CLIPPLANE(3) */ STATE_CLIPPLANE(3), clipplane },
4346 { /* STATE_CLIPPLANE(4) */ STATE_CLIPPLANE(4), clipplane },
4347 { /* STATE_CLIPPLANE(5) */ STATE_CLIPPLANE(5), clipplane },
4348 { /* STATE_CLIPPLANE(6) */ STATE_CLIPPLANE(6), clipplane },
4349 { /* STATE_CLIPPLANE(7) */ STATE_CLIPPLANE(7), clipplane },
4350 { /* STATE_CLIPPLANE(8) */ STATE_CLIPPLANE(8), clipplane },
4351 { /* STATE_CLIPPLANE(9) */ STATE_CLIPPLANE(9), clipplane },
4352 { /* STATE_CLIPPLANE(10) */ STATE_CLIPPLANE(10), clipplane },
4353 { /* STATE_CLIPPLANE(11) */ STATE_CLIPPLANE(11), clipplane },
4354 { /* STATE_CLIPPLANE(12) */ STATE_CLIPPLANE(12), clipplane },
4355 { /* STATE_CLIPPLANE(13) */ STATE_CLIPPLANE(13), clipplane },
4356 { /* STATE_CLIPPLANE(14) */ STATE_CLIPPLANE(14), clipplane },
4357 { /* STATE_CLIPPLANE(15) */ STATE_CLIPPLANE(15), clipplane },
4358 { /* STATE_CLIPPLANE(16) */ STATE_CLIPPLANE(16), clipplane },
4359 { /* STATE_CLIPPLANE(17) */ STATE_CLIPPLANE(17), clipplane },
4360 { /* STATE_CLIPPLANE(18) */ STATE_CLIPPLANE(18), clipplane },
4361 { /* STATE_CLIPPLANE(19) */ STATE_CLIPPLANE(19), clipplane },
4362 { /* STATE_CLIPPLANE(20) */ STATE_CLIPPLANE(20), clipplane },
4363 { /* STATE_CLIPPLANE(21) */ STATE_CLIPPLANE(21), clipplane },
4364 { /* STATE_CLIPPLANE(22) */ STATE_CLIPPLANE(22), clipplane },
4365 { /* STATE_CLIPPLANE(23) */ STATE_CLIPPLANE(23), clipplane },
4366 { /* STATE_CLIPPLANE(24) */ STATE_CLIPPLANE(24), clipplane },
4367 { /* STATE_CLIPPLANE(25) */ STATE_CLIPPLANE(25), clipplane },
4368 { /* STATE_CLIPPLANE(26) */ STATE_CLIPPLANE(26), clipplane },
4369 { /* STATE_CLIPPLANE(27) */ STATE_CLIPPLANE(27), clipplane },
4370 { /* STATE_CLIPPLANE(28) */ STATE_CLIPPLANE(28), clipplane },
4371 { /* STATE_CLIPPLANE(29) */ STATE_CLIPPLANE(29), clipplane },
4372 { /* STATE_CLIPPLANE(30) */ STATE_CLIPPLANE(30), clipplane },
4373 { /* STATE_CLIPPLANE(31) */ STATE_CLIPPLANE(31), clipplane },
Stefan Dösingerc0268c72006-12-05 23:36:10 +01004374};