2 * Direct3D state management
4 * Copyright 2002 Lionel Ulmer
5 * Copyright 2002-2005 Jason Edmeades
6 * Copyright 2003-2004 Raphael Junqueira
7 * Copyright 2004 Christian Costa
8 * Copyright 2005 Oliver Stieber
9 * Copyright 2006 Henri Verbeet
10 * Copyright 2006-2008 Stefan Dösinger for CodeWeavers
11 * Copyright 2009-2011 Henri Verbeet for CodeWeavers
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 2.1 of the License, or (at your option) any later version.
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this library; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "wine/port.h"
36 #include "wined3d_private.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(d3d
);
39 WINE_DECLARE_DEBUG_CHANNEL(d3d_shader
);
41 /* Context activation for state handler is done by the caller. */
43 static void state_undefined(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
45 ERR("Undefined state.\n");
48 static void state_nop(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
50 TRACE("%s: nop in current pipe config.\n", debug_d3dstate(state_id
));
53 static void state_fillmode(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
55 enum wined3d_fill_mode mode
= state
->render_states
[WINED3D_RS_FILLMODE
];
56 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
60 case WINED3D_FILL_POINT
:
61 gl_info
->gl_ops
.gl
.p_glPolygonMode(GL_FRONT_AND_BACK
, GL_POINT
);
62 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_POINT)");
64 case WINED3D_FILL_WIREFRAME
:
65 gl_info
->gl_ops
.gl
.p_glPolygonMode(GL_FRONT_AND_BACK
, GL_LINE
);
66 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)");
68 case WINED3D_FILL_SOLID
:
69 gl_info
->gl_ops
.gl
.p_glPolygonMode(GL_FRONT_AND_BACK
, GL_FILL
);
70 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)");
73 FIXME("Unrecognized fill mode %#x.\n", mode
);
77 static void state_lighting(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
79 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
81 /* Lighting is not enabled if transformed vertices are drawn, but lighting
82 * does not affect the stream sources, so it is not grouped for
83 * performance reasons. This state reads the decoded vertex declaration,
84 * so if it is dirty don't do anything. The vertex declaration applying
85 * function calls this function for updating. */
86 if (isStateDirty(context
, STATE_VDECL
))
89 if (state
->render_states
[WINED3D_RS_LIGHTING
]
90 && !context
->stream_info
.position_transformed
)
92 gl_info
->gl_ops
.gl
.p_glEnable(GL_LIGHTING
);
93 checkGLcall("glEnable GL_LIGHTING");
97 gl_info
->gl_ops
.gl
.p_glDisable(GL_LIGHTING
);
98 checkGLcall("glDisable GL_LIGHTING");
102 static void state_zenable(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
104 enum wined3d_depth_buffer_type zenable
= state
->render_states
[WINED3D_RS_ZENABLE
];
105 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
107 /* No z test without depth stencil buffers */
108 if (!state
->fb
->depth_stencil
)
110 TRACE("No Z buffer - disabling depth test\n");
111 zenable
= WINED3D_ZB_FALSE
;
116 case WINED3D_ZB_FALSE
:
117 gl_info
->gl_ops
.gl
.p_glDisable(GL_DEPTH_TEST
);
118 checkGLcall("glDisable GL_DEPTH_TEST");
120 case WINED3D_ZB_TRUE
:
121 gl_info
->gl_ops
.gl
.p_glEnable(GL_DEPTH_TEST
);
122 checkGLcall("glEnable GL_DEPTH_TEST");
124 case WINED3D_ZB_USEW
:
125 gl_info
->gl_ops
.gl
.p_glEnable(GL_DEPTH_TEST
);
126 checkGLcall("glEnable GL_DEPTH_TEST");
127 FIXME("W buffer is not well handled\n");
130 FIXME("Unrecognized depth buffer type %#x.\n", zenable
);
134 if (context
->last_was_rhw
&& !isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
)))
135 transform_projection(context
, state
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
));
138 static void state_cullmode(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
140 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
142 /* glFrontFace() is set in context.c at context init and on an
143 * offscreen / onscreen rendering switch. */
144 switch (state
->render_states
[WINED3D_RS_CULLMODE
])
146 case WINED3D_CULL_NONE
:
147 gl_info
->gl_ops
.gl
.p_glDisable(GL_CULL_FACE
);
148 checkGLcall("glDisable GL_CULL_FACE");
150 case WINED3D_CULL_CW
:
151 gl_info
->gl_ops
.gl
.p_glEnable(GL_CULL_FACE
);
152 checkGLcall("glEnable GL_CULL_FACE");
153 gl_info
->gl_ops
.gl
.p_glCullFace(GL_FRONT
);
154 checkGLcall("glCullFace(GL_FRONT)");
156 case WINED3D_CULL_CCW
:
157 gl_info
->gl_ops
.gl
.p_glEnable(GL_CULL_FACE
);
158 checkGLcall("glEnable GL_CULL_FACE");
159 gl_info
->gl_ops
.gl
.p_glCullFace(GL_BACK
);
160 checkGLcall("glCullFace(GL_BACK)");
163 FIXME("Unrecognized cull mode %#x.\n",
164 state
->render_states
[WINED3D_RS_CULLMODE
]);
168 static void state_shademode(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
170 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
172 switch (state
->render_states
[WINED3D_RS_SHADEMODE
])
174 case WINED3D_SHADE_FLAT
:
175 gl_info
->gl_ops
.gl
.p_glShadeModel(GL_FLAT
);
176 checkGLcall("glShadeModel(GL_FLAT)");
178 case WINED3D_SHADE_GOURAUD
:
179 gl_info
->gl_ops
.gl
.p_glShadeModel(GL_SMOOTH
);
180 checkGLcall("glShadeModel(GL_SMOOTH)");
182 case WINED3D_SHADE_PHONG
:
183 FIXME("WINED3D_SHADE_PHONG isn't supported.\n");
186 FIXME("Unrecognized shade mode %#x.\n",
187 state
->render_states
[WINED3D_RS_SHADEMODE
]);
191 static void state_ditherenable(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
193 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
195 if (state
->render_states
[WINED3D_RS_DITHERENABLE
])
197 gl_info
->gl_ops
.gl
.p_glEnable(GL_DITHER
);
198 checkGLcall("glEnable GL_DITHER");
202 gl_info
->gl_ops
.gl
.p_glDisable(GL_DITHER
);
203 checkGLcall("glDisable GL_DITHER");
207 static void state_zwritenable(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
209 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
211 if (state
->render_states
[WINED3D_RS_ZWRITEENABLE
])
213 gl_info
->gl_ops
.gl
.p_glDepthMask(1);
214 checkGLcall("glDepthMask(1)");
218 gl_info
->gl_ops
.gl
.p_glDepthMask(0);
219 checkGLcall("glDepthMask(0)");
223 GLenum
wined3d_gl_compare_func(enum wined3d_cmp_func f
)
227 case WINED3D_CMP_NEVER
:
229 case WINED3D_CMP_LESS
:
231 case WINED3D_CMP_EQUAL
:
233 case WINED3D_CMP_LESSEQUAL
:
235 case WINED3D_CMP_GREATER
:
237 case WINED3D_CMP_NOTEQUAL
:
239 case WINED3D_CMP_GREATEREQUAL
:
241 case WINED3D_CMP_ALWAYS
:
244 FIXME("Unrecognized compare function %#x.\n", f
);
249 static void state_zfunc(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
251 GLenum depth_func
= wined3d_gl_compare_func(state
->render_states
[WINED3D_RS_ZFUNC
]);
252 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
254 if (!depth_func
) return;
256 gl_info
->gl_ops
.gl
.p_glDepthFunc(depth_func
);
257 checkGLcall("glDepthFunc");
260 void state_ambient(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
262 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
265 D3DCOLORTOGLFLOAT4(state
->render_states
[WINED3D_RS_AMBIENT
], col
);
266 TRACE("Setting ambient to (%f,%f,%f,%f)\n", col
[0], col
[1], col
[2], col
[3]);
267 gl_info
->gl_ops
.gl
.p_glLightModelfv(GL_LIGHT_MODEL_AMBIENT
, col
);
268 checkGLcall("glLightModel for MODEL_AMBIENT");
271 static void state_blendop_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
273 WARN("Unsupported in local OpenGL implementation: glBlendEquation\n");
276 static GLenum
gl_blend_op(enum wined3d_blend_op op
)
280 case WINED3D_BLEND_OP_ADD
:
281 return GL_FUNC_ADD_EXT
;
282 case WINED3D_BLEND_OP_SUBTRACT
:
283 return GL_FUNC_SUBTRACT_EXT
;
284 case WINED3D_BLEND_OP_REVSUBTRACT
:
285 return GL_FUNC_REVERSE_SUBTRACT_EXT
;
286 case WINED3D_BLEND_OP_MIN
:
288 case WINED3D_BLEND_OP_MAX
:
291 FIXME("Unhandled blend op %#x.\n", op
);
296 static void state_blendop(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
298 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
299 GLenum blend_equation_alpha
= GL_FUNC_ADD_EXT
;
300 GLenum blend_equation
= GL_FUNC_ADD_EXT
;
302 /* BLENDOPALPHA requires GL_EXT_blend_equation_separate, so make sure it is around */
303 if (state
->render_states
[WINED3D_RS_BLENDOPALPHA
]
304 && !gl_info
->supported
[EXT_BLEND_EQUATION_SEPARATE
])
306 WARN("Unsupported in local OpenGL implementation: glBlendEquationSeparate.\n");
310 blend_equation
= gl_blend_op(state
->render_states
[WINED3D_RS_BLENDOP
]);
311 blend_equation_alpha
= gl_blend_op(state
->render_states
[WINED3D_RS_BLENDOPALPHA
]);
312 TRACE("blend_equation %#x, blend_equation_alpha %#x.\n", blend_equation
, blend_equation_alpha
);
314 if (state
->render_states
[WINED3D_RS_SEPARATEALPHABLENDENABLE
])
316 GL_EXTCALL(glBlendEquationSeparate(blend_equation
, blend_equation_alpha
));
317 checkGLcall("glBlendEquationSeparate");
321 GL_EXTCALL(glBlendEquation(blend_equation
));
322 checkGLcall("glBlendEquation");
326 static GLenum
gl_blend_factor(enum wined3d_blend factor
, const struct wined3d_format
*dst_format
)
330 case WINED3D_BLEND_ZERO
:
332 case WINED3D_BLEND_ONE
:
334 case WINED3D_BLEND_SRCCOLOR
:
336 case WINED3D_BLEND_INVSRCCOLOR
:
337 return GL_ONE_MINUS_SRC_COLOR
;
338 case WINED3D_BLEND_SRCALPHA
:
340 case WINED3D_BLEND_INVSRCALPHA
:
341 return GL_ONE_MINUS_SRC_ALPHA
;
342 case WINED3D_BLEND_DESTCOLOR
:
344 case WINED3D_BLEND_INVDESTCOLOR
:
345 return GL_ONE_MINUS_DST_COLOR
;
346 /* To compensate for the lack of format switching with backbuffer
347 * offscreen rendering, and with onscreen rendering, we modify the
348 * alpha test parameters for (INV)DESTALPHA if the render target
349 * doesn't support alpha blending. A nonexistent alpha channel
350 * returns 1.0, so WINED3D_BLEND_DESTALPHA becomes GL_ONE, and
351 * WINED3D_BLEND_INVDESTALPHA becomes GL_ZERO. */
352 case WINED3D_BLEND_DESTALPHA
:
353 return dst_format
->alpha_size
? GL_DST_ALPHA
: GL_ONE
;
354 case WINED3D_BLEND_INVDESTALPHA
:
355 return dst_format
->alpha_size
? GL_ONE_MINUS_DST_ALPHA
: GL_ZERO
;
356 case WINED3D_BLEND_SRCALPHASAT
:
357 return GL_SRC_ALPHA_SATURATE
;
358 case WINED3D_BLEND_BLENDFACTOR
:
359 return GL_CONSTANT_COLOR_EXT
;
360 case WINED3D_BLEND_INVBLENDFACTOR
:
361 return GL_ONE_MINUS_CONSTANT_COLOR_EXT
;
363 FIXME("Unhandled blend factor %#x.\n", factor
);
368 static void state_blend(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
370 const struct wined3d_format
*rt_format
= state
->fb
->render_targets
[0]->format
;
371 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
372 GLenum srcBlend
, dstBlend
;
373 enum wined3d_blend d3d_blend
;
375 /* According to the red book, GL_LINE_SMOOTH needs GL_BLEND with specific
376 * blending parameters to work. */
377 if (state
->render_states
[WINED3D_RS_ALPHABLENDENABLE
]
378 || state
->render_states
[WINED3D_RS_EDGEANTIALIAS
]
379 || state
->render_states
[WINED3D_RS_ANTIALIASEDLINEENABLE
])
381 /* Disable blending in all cases even without pixelshaders.
382 * With blending on we could face a big performance penalty.
383 * The d3d9 visual test confirms the behavior. */
384 if (context
->render_offscreen
&& !(rt_format
->flags
& WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
))
386 gl_info
->gl_ops
.gl
.p_glDisable(GL_BLEND
);
387 checkGLcall("glDisable GL_BLEND");
392 gl_info
->gl_ops
.gl
.p_glEnable(GL_BLEND
);
393 checkGLcall("glEnable GL_BLEND");
398 gl_info
->gl_ops
.gl
.p_glDisable(GL_BLEND
);
399 checkGLcall("glDisable GL_BLEND");
400 /* Nothing more to do - get out */
404 /* WINED3D_BLEND_BOTHSRCALPHA and WINED3D_BLEND_BOTHINVSRCALPHA are legacy
405 * source blending values which are still valid up to d3d9. They should
406 * not occur as dest blend values. */
407 d3d_blend
= state
->render_states
[WINED3D_RS_SRCBLEND
];
408 if (d3d_blend
== WINED3D_BLEND_BOTHSRCALPHA
)
410 srcBlend
= GL_SRC_ALPHA
;
411 dstBlend
= GL_ONE_MINUS_SRC_ALPHA
;
413 else if (d3d_blend
== WINED3D_BLEND_BOTHINVSRCALPHA
)
415 srcBlend
= GL_ONE_MINUS_SRC_ALPHA
;
416 dstBlend
= GL_SRC_ALPHA
;
420 srcBlend
= gl_blend_factor(d3d_blend
, rt_format
);
421 dstBlend
= gl_blend_factor(state
->render_states
[WINED3D_RS_DESTBLEND
], rt_format
);
424 if (state
->render_states
[WINED3D_RS_EDGEANTIALIAS
]
425 || state
->render_states
[WINED3D_RS_ANTIALIASEDLINEENABLE
])
427 gl_info
->gl_ops
.gl
.p_glEnable(GL_LINE_SMOOTH
);
428 checkGLcall("glEnable(GL_LINE_SMOOTH)");
429 if (srcBlend
!= GL_SRC_ALPHA
)
430 WARN("WINED3D_RS_EDGEANTIALIAS enabled, but unexpected src blending param.\n");
431 if (dstBlend
!= GL_ONE_MINUS_SRC_ALPHA
&& dstBlend
!= GL_ONE
)
432 WARN("WINED3D_RS_EDGEANTIALIAS enabled, but unexpected dst blending param.\n");
436 gl_info
->gl_ops
.gl
.p_glDisable(GL_LINE_SMOOTH
);
437 checkGLcall("glDisable(GL_LINE_SMOOTH)");
440 /* Re-apply BLENDOP(ALPHA) because of a possible SEPARATEALPHABLENDENABLE change */
441 if (!isStateDirty(context
, STATE_RENDER(WINED3D_RS_BLENDOP
)))
442 state_blendop(context
, state
, STATE_RENDER(WINED3D_RS_BLENDOPALPHA
));
444 if (state
->render_states
[WINED3D_RS_SEPARATEALPHABLENDENABLE
])
446 GLenum srcBlendAlpha
, dstBlendAlpha
;
448 /* Separate alpha blending requires GL_EXT_blend_function_separate, so make sure it is around */
449 if (!context
->gl_info
->supported
[EXT_BLEND_FUNC_SEPARATE
])
451 WARN("Unsupported in local OpenGL implementation: glBlendFuncSeparate.\n");
455 /* WINED3D_BLEND_BOTHSRCALPHA and WINED3D_BLEND_BOTHINVSRCALPHA are legacy
456 * source blending values which are still valid up to d3d9. They should
457 * not occur as dest blend values. */
458 d3d_blend
= state
->render_states
[WINED3D_RS_SRCBLENDALPHA
];
459 if (d3d_blend
== WINED3D_BLEND_BOTHSRCALPHA
)
461 srcBlendAlpha
= GL_SRC_ALPHA
;
462 dstBlendAlpha
= GL_ONE_MINUS_SRC_ALPHA
;
464 else if (d3d_blend
== WINED3D_BLEND_BOTHINVSRCALPHA
)
466 srcBlendAlpha
= GL_ONE_MINUS_SRC_ALPHA
;
467 dstBlendAlpha
= GL_SRC_ALPHA
;
471 srcBlendAlpha
= gl_blend_factor(d3d_blend
, rt_format
);
472 dstBlendAlpha
= gl_blend_factor(state
->render_states
[WINED3D_RS_DESTBLENDALPHA
], rt_format
);
475 GL_EXTCALL(glBlendFuncSeparate(srcBlend
, dstBlend
, srcBlendAlpha
, dstBlendAlpha
));
476 checkGLcall("glBlendFuncSeparate");
480 TRACE("glBlendFunc src=%x, dst=%x\n", srcBlend
, dstBlend
);
481 gl_info
->gl_ops
.gl
.p_glBlendFunc(srcBlend
, dstBlend
);
482 checkGLcall("glBlendFunc");
485 /* Colorkey fixup for stage 0 alphaop depends on
486 * WINED3D_RS_ALPHABLENDENABLE state, so it may need updating. */
487 if (state
->render_states
[WINED3D_RS_COLORKEYENABLE
])
488 context_apply_state(context
, state
, STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
));
491 static void state_blendfactor_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
493 WARN("Unsupported in local OpenGL implementation: glBlendColor.\n");
496 static void state_blendfactor(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
498 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
501 TRACE("Setting blend factor to %#x.\n", state
->render_states
[WINED3D_RS_BLENDFACTOR
]);
503 D3DCOLORTOGLFLOAT4(state
->render_states
[WINED3D_RS_BLENDFACTOR
], col
);
504 GL_EXTCALL(glBlendColor(col
[0], col
[1], col
[2], col
[3]));
505 checkGLcall("glBlendColor");
508 static void state_alpha(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
510 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
513 BOOL enable_ckey
= FALSE
;
515 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
517 /* Find out if the texture on the first stage has a ckey set. The alpha
518 * state func reads the texture settings, even though alpha and texture
519 * are not grouped together. This is to avoid making a huge alpha +
520 * texture + texture stage + ckey block due to the hardly used
521 * WINED3D_RS_COLORKEYENABLE state(which is d3d <= 3 only). The texture
522 * function will call alpha in case it finds some texture + colorkeyenable
523 * combination which needs extra care. */
524 if (state
->textures
[0] && (state
->textures
[0]->color_key_flags
& WINED3D_CKEY_SRC_BLT
))
527 if (enable_ckey
|| context
->last_was_ckey
)
528 context_apply_state(context
, state
, STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
));
529 context
->last_was_ckey
= enable_ckey
;
531 if (state
->render_states
[WINED3D_RS_ALPHATESTENABLE
]
532 || (state
->render_states
[WINED3D_RS_COLORKEYENABLE
] && enable_ckey
))
534 gl_info
->gl_ops
.gl
.p_glEnable(GL_ALPHA_TEST
);
535 checkGLcall("glEnable GL_ALPHA_TEST");
539 gl_info
->gl_ops
.gl
.p_glDisable(GL_ALPHA_TEST
);
540 checkGLcall("glDisable GL_ALPHA_TEST");
541 /* Alpha test is disabled, don't bother setting the params - it will happen on the next
547 if (state
->render_states
[WINED3D_RS_COLORKEYENABLE
] && enable_ckey
)
549 glParm
= GL_NOTEQUAL
;
554 ref
= ((float)state
->render_states
[WINED3D_RS_ALPHAREF
]) / 255.0f
;
555 glParm
= wined3d_gl_compare_func(state
->render_states
[WINED3D_RS_ALPHAFUNC
]);
559 gl_info
->gl_ops
.gl
.p_glAlphaFunc(glParm
, ref
);
560 checkGLcall("glAlphaFunc");
564 void state_clipping(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
566 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
567 DWORD enable
= 0xffffffff;
568 DWORD disable
= 0x00000000;
570 if (use_vs(state
) && !context
->d3d_info
->vs_clipping
)
574 /* The OpenGL spec says that clipping planes are disabled when using
575 * shaders. Direct3D planes aren't, so that is an issue. The MacOS ATI
576 * driver keeps clipping planes activated with shaders in some
577 * conditions I got sick of tracking down. The shader state handler
578 * disables all clip planes because of that - don't do anything here
579 * and keep them disabled. */
580 if (state
->render_states
[WINED3D_RS_CLIPPLANEENABLE
] && !warned
++)
581 FIXME("Clipping not supported with vertex shaders\n");
585 /* glEnable(GL_CLIP_PLANEx) doesn't apply to (ARB backend) vertex shaders.
586 * The enabled / disabled planes are hardcoded into the shader. Update the
587 * shader to update the enabled clipplanes. In case of fixed function, we
588 * need to update the clipping field from ffp_vertex_settings. */
589 context
->shader_update_mask
|= 1 << WINED3D_SHADER_TYPE_VERTEX
;
591 /* TODO: Keep track of previously enabled clipplanes to avoid unnecessary resetting
592 * of already set values
595 /* If enabling / disabling all
596 * TODO: Is this correct? Doesn't D3DRS_CLIPPING disable clipping on the viewport frustrum?
598 if (state
->render_states
[WINED3D_RS_CLIPPING
])
600 enable
= state
->render_states
[WINED3D_RS_CLIPPLANEENABLE
];
601 disable
= ~state
->render_states
[WINED3D_RS_CLIPPLANEENABLE
];
605 disable
= 0xffffffff;
609 if (enable
& WINED3DCLIPPLANE0
) gl_info
->gl_ops
.gl
.p_glEnable(GL_CLIP_PLANE0
);
610 if (enable
& WINED3DCLIPPLANE1
) gl_info
->gl_ops
.gl
.p_glEnable(GL_CLIP_PLANE1
);
611 if (enable
& WINED3DCLIPPLANE2
) gl_info
->gl_ops
.gl
.p_glEnable(GL_CLIP_PLANE2
);
612 if (enable
& WINED3DCLIPPLANE3
) gl_info
->gl_ops
.gl
.p_glEnable(GL_CLIP_PLANE3
);
613 if (enable
& WINED3DCLIPPLANE4
) gl_info
->gl_ops
.gl
.p_glEnable(GL_CLIP_PLANE4
);
614 if (enable
& WINED3DCLIPPLANE5
) gl_info
->gl_ops
.gl
.p_glEnable(GL_CLIP_PLANE5
);
615 checkGLcall("clip plane enable");
617 if (disable
& WINED3DCLIPPLANE0
) gl_info
->gl_ops
.gl
.p_glDisable(GL_CLIP_PLANE0
);
618 if (disable
& WINED3DCLIPPLANE1
) gl_info
->gl_ops
.gl
.p_glDisable(GL_CLIP_PLANE1
);
619 if (disable
& WINED3DCLIPPLANE2
) gl_info
->gl_ops
.gl
.p_glDisable(GL_CLIP_PLANE2
);
620 if (disable
& WINED3DCLIPPLANE3
) gl_info
->gl_ops
.gl
.p_glDisable(GL_CLIP_PLANE3
);
621 if (disable
& WINED3DCLIPPLANE4
) gl_info
->gl_ops
.gl
.p_glDisable(GL_CLIP_PLANE4
);
622 if (disable
& WINED3DCLIPPLANE5
) gl_info
->gl_ops
.gl
.p_glDisable(GL_CLIP_PLANE5
);
623 checkGLcall("clip plane disable");
626 void state_specularenable(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
628 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
629 /* Originally this used glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR)
630 * and (GL_LIGHT_MODEL_COLOR_CONTROL,GL_SINGLE_COLOR) to swap between enabled/disabled
631 * specular color. This is wrong:
632 * Separate specular color means the specular colour is maintained separately, whereas
633 * single color means it is merged in. However in both cases they are being used to
635 * To disable specular color, set it explicitly to black and turn off GL_COLOR_SUM_EXT
636 * NOTE: If not supported don't give FIXMEs the impact is really minimal and very few people are
640 * If register combiners are enabled, enabling / disabling GL_COLOR_SUM has no effect.
641 * Instead, we need to setup the FinalCombiner properly.
643 * The default setup for the FinalCombiner is:
645 * <variable> <input> <mapping> <usage>
646 * GL_VARIABLE_A_NV GL_FOG, GL_UNSIGNED_IDENTITY_NV GL_ALPHA
647 * GL_VARIABLE_B_NV GL_SPARE0_PLUS_SECONDARY_COLOR_NV GL_UNSIGNED_IDENTITY_NV GL_RGB
648 * GL_VARIABLE_C_NV GL_FOG GL_UNSIGNED_IDENTITY_NV GL_RGB
649 * GL_VARIABLE_D_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
650 * GL_VARIABLE_E_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
651 * GL_VARIABLE_F_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
652 * GL_VARIABLE_G_NV GL_SPARE0_NV GL_UNSIGNED_IDENTITY_NV GL_ALPHA
654 * That's pretty much fine as it is, except for variable B, which needs to take
655 * either GL_SPARE0_PLUS_SECONDARY_COLOR_NV or GL_SPARE0_NV, depending on
656 * whether WINED3D_RS_SPECULARENABLE is enabled or not.
659 TRACE("Setting specular enable state and materials\n");
660 if (state
->render_states
[WINED3D_RS_SPECULARENABLE
])
662 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, (float *)&state
->material
.specular
);
663 checkGLcall("glMaterialfv");
665 if (state
->material
.power
> gl_info
->limits
.shininess
)
667 /* glMaterialf man page says that the material says that GL_SHININESS must be between 0.0
668 * and 128.0, although in d3d neither -1 nor 129 produce an error. GL_NV_max_light_exponent
669 * allows bigger values. If the extension is supported, gl_info->limits.shininess contains the
670 * value reported by the extension, otherwise 128. For values > gl_info->limits.shininess clamp
671 * them, it should be safe to do so without major visual distortions.
673 WARN("Material power = %.8e, limit %.8e\n", state
->material
.power
, gl_info
->limits
.shininess
);
674 gl_info
->gl_ops
.gl
.p_glMaterialf(GL_FRONT_AND_BACK
, GL_SHININESS
, gl_info
->limits
.shininess
);
678 gl_info
->gl_ops
.gl
.p_glMaterialf(GL_FRONT_AND_BACK
, GL_SHININESS
, state
->material
.power
);
680 checkGLcall("glMaterialf(GL_SHININESS)");
682 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
683 gl_info
->gl_ops
.gl
.p_glEnable(GL_COLOR_SUM_EXT
);
685 TRACE("Specular colors cannot be enabled in this version of opengl\n");
686 checkGLcall("glEnable(GL_COLOR_SUM)");
688 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
690 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV
, GL_SPARE0_PLUS_SECONDARY_COLOR_NV
, GL_UNSIGNED_IDENTITY_NV
, GL_RGB
));
691 checkGLcall("glFinalCombinerInputNV()");
694 static const GLfloat black
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
696 /* for the case of enabled lighting: */
697 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, &black
[0]);
698 checkGLcall("glMaterialfv");
700 /* for the case of disabled lighting: */
701 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
702 gl_info
->gl_ops
.gl
.p_glDisable(GL_COLOR_SUM_EXT
);
704 TRACE("Specular colors cannot be disabled in this version of opengl\n");
705 checkGLcall("glDisable(GL_COLOR_SUM)");
707 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
709 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV
, GL_SPARE0_NV
, GL_UNSIGNED_IDENTITY_NV
, GL_RGB
));
710 checkGLcall("glFinalCombinerInputNV()");
714 TRACE("diffuse {%.8e, %.8e, %.8e, %.8e}\n",
715 state
->material
.diffuse
.r
, state
->material
.diffuse
.g
,
716 state
->material
.diffuse
.b
, state
->material
.diffuse
.a
);
717 TRACE("ambient {%.8e, %.8e, %.8e, %.8e}\n",
718 state
->material
.ambient
.r
, state
->material
.ambient
.g
,
719 state
->material
.ambient
.b
, state
->material
.ambient
.a
);
720 TRACE("specular {%.8e, %.8e, %.8e, %.8e}\n",
721 state
->material
.specular
.r
, state
->material
.specular
.g
,
722 state
->material
.specular
.b
, state
->material
.specular
.a
);
723 TRACE("emissive {%.8e, %.8e, %.8e, %.8e}\n",
724 state
->material
.emissive
.r
, state
->material
.emissive
.g
,
725 state
->material
.emissive
.b
, state
->material
.emissive
.a
);
727 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float *)&state
->material
.ambient
);
728 checkGLcall("glMaterialfv(GL_AMBIENT)");
729 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float *)&state
->material
.diffuse
);
730 checkGLcall("glMaterialfv(GL_DIFFUSE)");
731 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_EMISSION
, (float *)&state
->material
.emissive
);
732 checkGLcall("glMaterialfv(GL_EMISSION)");
735 static void state_texfactor(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
737 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
740 /* Note the texture color applies to all textures whereas
741 * GL_TEXTURE_ENV_COLOR applies to active only. */
743 D3DCOLORTOGLFLOAT4(state
->render_states
[WINED3D_RS_TEXTUREFACTOR
], col
);
745 /* And now the default texture color as well */
746 for (i
= 0; i
< context
->d3d_info
->limits
.ffp_blend_stages
; ++i
)
748 /* Note the WINED3D_RS value applies to all textures, but GL has one
749 * per texture, so apply it now ready to be used! */
750 context_active_texture(context
, gl_info
, i
);
752 gl_info
->gl_ops
.gl
.p_glTexEnvfv(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_COLOR
, &col
[0]);
753 checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);");
757 static void renderstate_stencil_twosided(struct wined3d_context
*context
, GLint face
,
758 GLint func
, GLint ref
, GLuint mask
, GLint stencilFail
, GLint depthFail
, GLint stencilPass
)
760 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
762 gl_info
->gl_ops
.gl
.p_glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT
);
763 checkGLcall("glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT)");
764 GL_EXTCALL(glActiveStencilFaceEXT(face
));
765 checkGLcall("glActiveStencilFaceEXT(...)");
766 gl_info
->gl_ops
.gl
.p_glStencilFunc(func
, ref
, mask
);
767 checkGLcall("glStencilFunc(...)");
768 gl_info
->gl_ops
.gl
.p_glStencilOp(stencilFail
, depthFail
, stencilPass
);
769 checkGLcall("glStencilOp(...)");
772 static GLenum
gl_stencil_op(enum wined3d_stencil_op op
)
776 case WINED3D_STENCIL_OP_KEEP
:
778 case WINED3D_STENCIL_OP_ZERO
:
780 case WINED3D_STENCIL_OP_REPLACE
:
782 case WINED3D_STENCIL_OP_INCR_SAT
:
784 case WINED3D_STENCIL_OP_DECR_SAT
:
786 case WINED3D_STENCIL_OP_INVERT
:
788 case WINED3D_STENCIL_OP_INCR
:
789 return GL_INCR_WRAP_EXT
;
790 case WINED3D_STENCIL_OP_DECR
:
791 return GL_DECR_WRAP_EXT
;
793 FIXME("Unrecognized stencil op %#x.\n", op
);
798 static void state_stencil(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
800 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
801 DWORD onesided_enable
;
802 DWORD twosided_enable
;
808 GLint stencilFail_ccw
;
810 GLint stencilPass_ccw
;
814 /* No stencil test without a stencil buffer. */
815 if (!state
->fb
->depth_stencil
)
817 gl_info
->gl_ops
.gl
.p_glDisable(GL_STENCIL_TEST
);
818 checkGLcall("glDisable GL_STENCIL_TEST");
822 onesided_enable
= state
->render_states
[WINED3D_RS_STENCILENABLE
];
823 twosided_enable
= state
->render_states
[WINED3D_RS_TWOSIDEDSTENCILMODE
];
824 if (!(func
= wined3d_gl_compare_func(state
->render_states
[WINED3D_RS_STENCILFUNC
])))
826 if (!(func_ccw
= wined3d_gl_compare_func(state
->render_states
[WINED3D_RS_CCW_STENCILFUNC
])))
827 func_ccw
= GL_ALWAYS
;
828 ref
= state
->render_states
[WINED3D_RS_STENCILREF
];
829 mask
= state
->render_states
[WINED3D_RS_STENCILMASK
];
830 stencilFail
= gl_stencil_op(state
->render_states
[WINED3D_RS_STENCILFAIL
]);
831 depthFail
= gl_stencil_op(state
->render_states
[WINED3D_RS_STENCILZFAIL
]);
832 stencilPass
= gl_stencil_op(state
->render_states
[WINED3D_RS_STENCILPASS
]);
833 stencilFail_ccw
= gl_stencil_op(state
->render_states
[WINED3D_RS_CCW_STENCILFAIL
]);
834 depthFail_ccw
= gl_stencil_op(state
->render_states
[WINED3D_RS_CCW_STENCILZFAIL
]);
835 stencilPass_ccw
= gl_stencil_op(state
->render_states
[WINED3D_RS_CCW_STENCILPASS
]);
837 TRACE("(onesided %d, twosided %d, ref %x, mask %x, "
838 "GL_FRONT: func: %x, fail %x, zfail %x, zpass %x "
839 "GL_BACK: func: %x, fail %x, zfail %x, zpass %x )\n",
840 onesided_enable
, twosided_enable
, ref
, mask
,
841 func
, stencilFail
, depthFail
, stencilPass
,
842 func_ccw
, stencilFail_ccw
, depthFail_ccw
, stencilPass_ccw
);
844 if (twosided_enable
&& onesided_enable
)
846 gl_info
->gl_ops
.gl
.p_glEnable(GL_STENCIL_TEST
);
847 checkGLcall("glEnable GL_STENCIL_TEST");
849 if (gl_info
->supported
[WINED3D_GL_VERSION_2_0
])
851 GL_EXTCALL(glStencilFuncSeparate(GL_FRONT
, func
, ref
, mask
));
852 GL_EXTCALL(glStencilOpSeparate(GL_FRONT
, stencilFail
, depthFail
, stencilPass
));
853 GL_EXTCALL(glStencilFuncSeparate(GL_BACK
, func_ccw
, ref
, mask
));
854 GL_EXTCALL(glStencilOpSeparate(GL_BACK
, stencilFail_ccw
, depthFail_ccw
, stencilPass_ccw
));
855 checkGLcall("setting two sided stencil state");
857 else if (gl_info
->supported
[EXT_STENCIL_TWO_SIDE
])
859 /* Apply back first, then front. This function calls glActiveStencilFaceEXT,
860 * which has an effect on the code below too. If we apply the front face
861 * afterwards, we are sure that the active stencil face is set to front,
862 * and other stencil functions which do not use two sided stencil do not have
865 renderstate_stencil_twosided(context
, GL_BACK
,
866 func_ccw
, ref
, mask
, stencilFail_ccw
, depthFail_ccw
, stencilPass_ccw
);
867 renderstate_stencil_twosided(context
, GL_FRONT
,
868 func
, ref
, mask
, stencilFail
, depthFail
, stencilPass
);
870 else if (gl_info
->supported
[ATI_SEPARATE_STENCIL
])
872 GL_EXTCALL(glStencilFuncSeparateATI(func
, func_ccw
, ref
, mask
));
873 checkGLcall("glStencilFuncSeparateATI(...)");
874 GL_EXTCALL(glStencilOpSeparateATI(GL_FRONT
, stencilFail
, depthFail
, stencilPass
));
875 checkGLcall("glStencilOpSeparateATI(GL_FRONT, ...)");
876 GL_EXTCALL(glStencilOpSeparateATI(GL_BACK
, stencilFail_ccw
, depthFail_ccw
, stencilPass_ccw
));
877 checkGLcall("glStencilOpSeparateATI(GL_BACK, ...)");
881 ERR("Separate (two sided) stencil not supported on this version of opengl. Caps weren't honored?\n");
884 else if(onesided_enable
)
886 if (gl_info
->supported
[EXT_STENCIL_TWO_SIDE
])
888 gl_info
->gl_ops
.gl
.p_glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT
);
889 checkGLcall("glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT)");
892 /* This code disables the ATI extension as well, since the standard stencil functions are equal
893 * to calling the ATI functions with GL_FRONT_AND_BACK as face parameter
895 gl_info
->gl_ops
.gl
.p_glEnable(GL_STENCIL_TEST
);
896 checkGLcall("glEnable GL_STENCIL_TEST");
897 gl_info
->gl_ops
.gl
.p_glStencilFunc(func
, ref
, mask
);
898 checkGLcall("glStencilFunc(...)");
899 gl_info
->gl_ops
.gl
.p_glStencilOp(stencilFail
, depthFail
, stencilPass
);
900 checkGLcall("glStencilOp(...)");
904 gl_info
->gl_ops
.gl
.p_glDisable(GL_STENCIL_TEST
);
905 checkGLcall("glDisable GL_STENCIL_TEST");
909 static void state_stencilwrite2s(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
911 DWORD mask
= state
->fb
->depth_stencil
? state
->render_states
[WINED3D_RS_STENCILWRITEMASK
] : 0;
912 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
914 GL_EXTCALL(glActiveStencilFaceEXT(GL_BACK
));
915 checkGLcall("glActiveStencilFaceEXT(GL_BACK)");
916 gl_info
->gl_ops
.gl
.p_glStencilMask(mask
);
917 checkGLcall("glStencilMask");
918 GL_EXTCALL(glActiveStencilFaceEXT(GL_FRONT
));
919 checkGLcall("glActiveStencilFaceEXT(GL_FRONT)");
920 gl_info
->gl_ops
.gl
.p_glStencilMask(mask
);
923 static void state_stencilwrite(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
925 DWORD mask
= state
->fb
->depth_stencil
? state
->render_states
[WINED3D_RS_STENCILWRITEMASK
] : 0;
926 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
928 gl_info
->gl_ops
.gl
.p_glStencilMask(mask
);
929 checkGLcall("glStencilMask");
932 static void state_fog_vertexpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
934 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
936 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
938 if (!state
->render_states
[WINED3D_RS_FOGENABLE
])
941 /* Table fog on: Never use fog coords, and use per-fragment fog */
942 if (state
->render_states
[WINED3D_RS_FOGTABLEMODE
] != WINED3D_FOG_NONE
)
944 gl_info
->gl_ops
.gl
.p_glHint(GL_FOG_HINT
, GL_NICEST
);
945 if (context
->fog_coord
)
947 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FRAGMENT_DEPTH_EXT
);
948 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT)");
949 context
->fog_coord
= FALSE
;
952 /* Range fog is only used with per-vertex fog in d3d */
953 if (gl_info
->supported
[NV_FOG_DISTANCE
])
955 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_DISTANCE_MODE_NV
, GL_EYE_PLANE_ABSOLUTE_NV
);
956 checkGLcall("glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_PLANE_ABSOLUTE_NV)");
961 /* Otherwise use per-vertex fog in any case */
962 gl_info
->gl_ops
.gl
.p_glHint(GL_FOG_HINT
, GL_FASTEST
);
964 if (state
->render_states
[WINED3D_RS_FOGVERTEXMODE
] == WINED3D_FOG_NONE
|| context
->last_was_rhw
)
966 /* No fog at all, or transformed vertices: Use fog coord */
967 if (!context
->fog_coord
)
969 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FOG_COORDINATE_EXT
);
970 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT)");
971 context
->fog_coord
= TRUE
;
976 /* Otherwise, use the fragment depth */
977 if (context
->fog_coord
)
979 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FRAGMENT_DEPTH_EXT
);
980 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT)");
981 context
->fog_coord
= FALSE
;
984 if (state
->render_states
[WINED3D_RS_RANGEFOGENABLE
])
986 if (gl_info
->supported
[NV_FOG_DISTANCE
])
988 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_DISTANCE_MODE_NV
, GL_EYE_RADIAL_NV
);
989 checkGLcall("glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_RADIAL_NV)");
993 WARN("Range fog enabled, but not supported by this GL implementation.\n");
996 else if (gl_info
->supported
[NV_FOG_DISTANCE
])
998 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_DISTANCE_MODE_NV
, GL_EYE_PLANE_ABSOLUTE_NV
);
999 checkGLcall("glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_PLANE_ABSOLUTE_NV)");
1004 void state_fogstartend(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1006 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1007 float fogstart
, fogend
;
1013 switch(context
->fog_source
) {
1019 case FOGSOURCE_COORD
:
1025 tmpvalue
.d
= state
->render_states
[WINED3D_RS_FOGSTART
];
1026 fogstart
= tmpvalue
.f
;
1027 tmpvalue
.d
= state
->render_states
[WINED3D_RS_FOGEND
];
1028 fogend
= tmpvalue
.f
;
1029 /* Special handling for fogstart == fogend. In d3d with vertex
1030 * fog, everything is fogged. With table fog, everything with
1031 * fog_coord < fog_start is unfogged, and fog_coord > fog_start
1032 * is fogged. Windows drivers disagree when fog_coord == fog_start. */
1033 if (state
->render_states
[WINED3D_RS_FOGTABLEMODE
] == WINED3D_FOG_NONE
1034 && fogstart
== fogend
)
1036 fogstart
= -INFINITY
;
1042 /* This should not happen.context->fog_source is set in wined3d, not the app.
1043 * Still this is needed to make the compiler happy
1045 ERR("Unexpected fog coordinate source\n");
1050 gl_info
->gl_ops
.gl
.p_glFogf(GL_FOG_START
, fogstart
);
1051 checkGLcall("glFogf(GL_FOG_START, fogstart)");
1052 TRACE("Fog Start == %f\n", fogstart
);
1054 gl_info
->gl_ops
.gl
.p_glFogf(GL_FOG_END
, fogend
);
1055 checkGLcall("glFogf(GL_FOG_END, fogend)");
1056 TRACE("Fog End == %f\n", fogend
);
1059 void state_fog_fragpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1061 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1062 enum fogsource new_source
;
1063 DWORD fogstart
= state
->render_states
[WINED3D_RS_FOGSTART
];
1064 DWORD fogend
= state
->render_states
[WINED3D_RS_FOGEND
];
1066 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
1068 if (!state
->render_states
[WINED3D_RS_FOGENABLE
])
1070 /* No fog? Disable it, and we're done :-) */
1071 glDisableWINE(GL_FOG
);
1072 checkGLcall("glDisable GL_FOG");
1078 * With fixed function vertex processing, Direct3D knows 2 different fog input sources.
1079 * It can use the Z value of the vertex, or the alpha component of the specular color.
1080 * This depends on the fog vertex, fog table and the vertex declaration. If the Z value
1081 * is used, fogstart, fogend and the equation type are used, otherwise linear fog with
1082 * start = 255, end = 0 is used. Obviously the msdn is not very clear on that.
1084 * FOGTABLEMODE != NONE:
1085 * The Z value is used, with the equation specified, no matter what vertex type.
1087 * FOGTABLEMODE == NONE, FOGVERTEXMODE != NONE, untransformed:
1088 * Per vertex fog is calculated using the specified fog equation and the parameters
1090 * FOGTABLEMODE == NONE, FOGVERTEXMODE != NONE, transformed, OR
1091 * FOGTABLEMODE == NONE, FOGVERTEXMODE == NONE, untransformed:
1092 * Linear fog with start = 255.0, end = 0.0, input comes from the specular color
1095 * Rules for vertex fog with shaders:
1097 * When mixing fixed function functionality with the programmable pipeline, D3D expects
1098 * the fog computation to happen during transformation while openGL expects it to happen
1099 * during rasterization. Also, prior to pixel shader 3.0 D3D handles fog blending after
1100 * the pixel shader while openGL always expects the pixel shader to handle the blending.
1101 * To solve this problem, WineD3D does:
1102 * 1) implement a linear fog equation and fog blending at the end of every pre 3.0 pixel
1104 * and 2) disables the fog computation (in either the fixed function or programmable
1105 * rasterizer) if using a vertex program.
1107 * D3D shaders can provide an explicit fog coordinate. This fog coordinate is used with
1108 * D3DRS_FOGTABLEMODE==D3DFOG_NONE. The FOGVERTEXMODE is ignored, d3d always uses linear
1109 * fog with start=1.0 and end=0.0 in this case. This is similar to fog coordinates in
1110 * the specular color, a vertex shader counts as pretransformed geometry in this case.
1111 * There are some GL differences between specular fog coords and vertex shaders though.
1113 * With table fog the vertex shader fog coordinate is ignored.
1115 * If a fogtablemode and a fogvertexmode are specified, table fog is applied (with or
1119 /* DX 7 sdk: "If both render states(vertex and table fog) are set to valid modes,
1120 * the system will apply only pixel(=table) fog effects."
1122 if (state
->render_states
[WINED3D_RS_FOGTABLEMODE
] == WINED3D_FOG_NONE
)
1126 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_LINEAR
);
1127 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1128 new_source
= FOGSOURCE_VS
;
1132 switch (state
->render_states
[WINED3D_RS_FOGVERTEXMODE
])
1134 /* If processed vertices are used, fall through to the NONE case */
1135 case WINED3D_FOG_EXP
:
1136 if (!context
->last_was_rhw
)
1138 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_EXP
);
1139 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP)");
1140 new_source
= FOGSOURCE_FFP
;
1145 case WINED3D_FOG_EXP2
:
1146 if (!context
->last_was_rhw
)
1148 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_EXP2
);
1149 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2)");
1150 new_source
= FOGSOURCE_FFP
;
1155 case WINED3D_FOG_LINEAR
:
1156 if (!context
->last_was_rhw
)
1158 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_LINEAR
);
1159 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1160 new_source
= FOGSOURCE_FFP
;
1165 case WINED3D_FOG_NONE
:
1166 /* Both are none? According to msdn the alpha channel of the specular
1167 * color contains a fog factor. Set it in drawStridedSlow.
1168 * Same happens with Vertexfog on transformed vertices
1170 new_source
= FOGSOURCE_COORD
;
1171 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_LINEAR
);
1172 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1176 FIXME("Unexpected WINED3D_RS_FOGVERTEXMODE %#x.\n",
1177 state
->render_states
[WINED3D_RS_FOGVERTEXMODE
]);
1178 new_source
= FOGSOURCE_FFP
; /* Make the compiler happy */
1182 new_source
= FOGSOURCE_FFP
;
1184 switch (state
->render_states
[WINED3D_RS_FOGTABLEMODE
])
1186 case WINED3D_FOG_EXP
:
1187 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_EXP
);
1188 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP)");
1191 case WINED3D_FOG_EXP2
:
1192 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_EXP2
);
1193 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2)");
1196 case WINED3D_FOG_LINEAR
:
1197 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_LINEAR
);
1198 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1201 case WINED3D_FOG_NONE
: /* Won't happen */
1203 FIXME("Unexpected WINED3D_RS_FOGTABLEMODE %#x.\n",
1204 state
->render_states
[WINED3D_RS_FOGTABLEMODE
]);
1208 glEnableWINE(GL_FOG
);
1209 checkGLcall("glEnable GL_FOG");
1210 if (new_source
!= context
->fog_source
|| fogstart
== fogend
)
1212 context
->fog_source
= new_source
;
1213 state_fogstartend(context
, state
, STATE_RENDER(WINED3D_RS_FOGSTART
));
1217 void state_fogcolor(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1219 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1222 D3DCOLORTOGLFLOAT4(state
->render_states
[WINED3D_RS_FOGCOLOR
], col
);
1223 gl_info
->gl_ops
.gl
.p_glFogfv(GL_FOG_COLOR
, &col
[0]);
1224 checkGLcall("glFog GL_FOG_COLOR");
1227 void state_fogdensity(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1229 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1235 tmpvalue
.d
= state
->render_states
[WINED3D_RS_FOGDENSITY
];
1236 gl_info
->gl_ops
.gl
.p_glFogfv(GL_FOG_DENSITY
, &tmpvalue
.f
);
1237 checkGLcall("glFogf(GL_FOG_DENSITY, (float) Value)");
1240 static void state_colormat(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1242 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1245 /* Depends on the decoded vertex declaration to read the existence of diffuse data.
1246 * The vertex declaration will call this function if the fixed function pipeline is used.
1249 if(isStateDirty(context
, STATE_VDECL
)) {
1253 context
->num_untracked_materials
= 0;
1254 if ((context
->stream_info
.use_map
& (1 << WINED3D_FFP_DIFFUSE
))
1255 && state
->render_states
[WINED3D_RS_COLORVERTEX
])
1257 TRACE("diff %d, amb %d, emis %d, spec %d\n",
1258 state
->render_states
[WINED3D_RS_DIFFUSEMATERIALSOURCE
],
1259 state
->render_states
[WINED3D_RS_AMBIENTMATERIALSOURCE
],
1260 state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
],
1261 state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
]);
1263 if (state
->render_states
[WINED3D_RS_DIFFUSEMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1265 if (state
->render_states
[WINED3D_RS_AMBIENTMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1266 Parm
= GL_AMBIENT_AND_DIFFUSE
;
1269 if (state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1271 context
->untracked_materials
[context
->num_untracked_materials
] = GL_EMISSION
;
1272 context
->num_untracked_materials
++;
1274 if (state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1276 context
->untracked_materials
[context
->num_untracked_materials
] = GL_SPECULAR
;
1277 context
->num_untracked_materials
++;
1280 else if (state
->render_states
[WINED3D_RS_AMBIENTMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1283 if (state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1285 context
->untracked_materials
[context
->num_untracked_materials
] = GL_EMISSION
;
1286 context
->num_untracked_materials
++;
1288 if (state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1290 context
->untracked_materials
[context
->num_untracked_materials
] = GL_SPECULAR
;
1291 context
->num_untracked_materials
++;
1294 else if (state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1297 if (state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1299 context
->untracked_materials
[context
->num_untracked_materials
] = GL_SPECULAR
;
1300 context
->num_untracked_materials
++;
1303 else if (state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1309 /* Nothing changed, return. */
1310 if (Parm
== context
->tracking_parm
) return;
1314 gl_info
->gl_ops
.gl
.p_glDisable(GL_COLOR_MATERIAL
);
1315 checkGLcall("glDisable GL_COLOR_MATERIAL");
1319 gl_info
->gl_ops
.gl
.p_glColorMaterial(GL_FRONT_AND_BACK
, Parm
);
1320 checkGLcall("glColorMaterial(GL_FRONT_AND_BACK, Parm)");
1321 gl_info
->gl_ops
.gl
.p_glEnable(GL_COLOR_MATERIAL
);
1322 checkGLcall("glEnable(GL_COLOR_MATERIAL)");
1325 /* Apparently calls to glMaterialfv are ignored for properties we're
1326 * tracking with glColorMaterial, so apply those here. */
1327 switch (context
->tracking_parm
)
1329 case GL_AMBIENT_AND_DIFFUSE
:
1330 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float *)&state
->material
.ambient
);
1331 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float *)&state
->material
.diffuse
);
1332 checkGLcall("glMaterialfv");
1336 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float *)&state
->material
.diffuse
);
1337 checkGLcall("glMaterialfv");
1341 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float *)&state
->material
.ambient
);
1342 checkGLcall("glMaterialfv");
1346 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_EMISSION
, (float *)&state
->material
.emissive
);
1347 checkGLcall("glMaterialfv");
1351 /* Only change material color if specular is enabled, otherwise it is set to black */
1352 if (state
->render_states
[WINED3D_RS_SPECULARENABLE
])
1354 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, (float *)&state
->material
.specular
);
1355 checkGLcall("glMaterialfv");
1359 static const GLfloat black
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
1360 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, &black
[0]);
1361 checkGLcall("glMaterialfv");
1366 context
->tracking_parm
= Parm
;
1369 static void state_linepattern(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1371 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1375 struct wined3d_line_pattern lp
;
1377 tmppattern
.d
= state
->render_states
[WINED3D_RS_LINEPATTERN
];
1379 TRACE("Line pattern: repeat %d bits %x.\n", tmppattern
.lp
.repeat_factor
, tmppattern
.lp
.line_pattern
);
1381 if (tmppattern
.lp
.repeat_factor
)
1383 gl_info
->gl_ops
.gl
.p_glLineStipple(tmppattern
.lp
.repeat_factor
, tmppattern
.lp
.line_pattern
);
1384 checkGLcall("glLineStipple(repeat, linepattern)");
1385 gl_info
->gl_ops
.gl
.p_glEnable(GL_LINE_STIPPLE
);
1386 checkGLcall("glEnable(GL_LINE_STIPPLE);");
1390 gl_info
->gl_ops
.gl
.p_glDisable(GL_LINE_STIPPLE
);
1391 checkGLcall("glDisable(GL_LINE_STIPPLE);");
1395 static void state_normalize(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1397 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1399 if (isStateDirty(context
, STATE_VDECL
))
1402 /* Without vertex normals, we set the current normal to 0/0/0 to remove the diffuse factor
1403 * from the opengl lighting equation, as d3d does. Normalization of 0/0/0 can lead to a division
1404 * by zero and is not properly defined in opengl, so avoid it
1406 if (state
->render_states
[WINED3D_RS_NORMALIZENORMALS
]
1407 && (context
->stream_info
.use_map
& (1 << WINED3D_FFP_NORMAL
)))
1409 gl_info
->gl_ops
.gl
.p_glEnable(GL_NORMALIZE
);
1410 checkGLcall("glEnable(GL_NORMALIZE);");
1414 gl_info
->gl_ops
.gl
.p_glDisable(GL_NORMALIZE
);
1415 checkGLcall("glDisable(GL_NORMALIZE);");
1419 void state_psizemin_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1426 tmpvalue
.d
= state
->render_states
[WINED3D_RS_POINTSIZE_MIN
];
1427 if (tmpvalue
.f
!= 1.0f
)
1429 FIXME("WINED3D_RS_POINTSIZE_MIN not supported on this opengl, value is %f\n", tmpvalue
.f
);
1431 tmpvalue
.d
= state
->render_states
[WINED3D_RS_POINTSIZE_MAX
];
1432 if (tmpvalue
.f
!= 64.0f
)
1434 FIXME("WINED3D_RS_POINTSIZE_MAX not supported on this opengl, value is %f\n", tmpvalue
.f
);
1439 void state_psizemin_ext(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1441 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1448 min
.d
= state
->render_states
[WINED3D_RS_POINTSIZE_MIN
];
1449 max
.d
= state
->render_states
[WINED3D_RS_POINTSIZE_MAX
];
1451 /* Max point size trumps min point size */
1456 GL_EXTCALL(glPointParameterfEXT
)(GL_POINT_SIZE_MIN_EXT
, min
.f
);
1457 checkGLcall("glPointParameterfEXT(...)");
1458 GL_EXTCALL(glPointParameterfEXT
)(GL_POINT_SIZE_MAX_EXT
, max
.f
);
1459 checkGLcall("glPointParameterfEXT(...)");
1462 void state_psizemin_arb(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1464 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1471 min
.d
= state
->render_states
[WINED3D_RS_POINTSIZE_MIN
];
1472 max
.d
= state
->render_states
[WINED3D_RS_POINTSIZE_MAX
];
1474 /* Max point size trumps min point size */
1479 GL_EXTCALL(glPointParameterfARB
)(GL_POINT_SIZE_MIN_ARB
, min
.f
);
1480 checkGLcall("glPointParameterfARB(...)");
1481 GL_EXTCALL(glPointParameterfARB
)(GL_POINT_SIZE_MAX_ARB
, max
.f
);
1482 checkGLcall("glPointParameterfARB(...)");
1485 void state_pscale(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1487 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1488 /* TODO: Group this with the viewport */
1490 * POINTSCALEENABLE controls how point size value is treated. If set to
1491 * true, the point size is scaled with respect to height of viewport.
1492 * When set to false point size is in pixels.
1495 /* Default values */
1496 GLfloat att
[3] = {1.0f
, 0.0f
, 0.0f
};
1500 } pointSize
, A
, B
, C
;
1502 pointSize
.d
= state
->render_states
[WINED3D_RS_POINTSIZE
];
1503 A
.d
= state
->render_states
[WINED3D_RS_POINTSCALE_A
];
1504 B
.d
= state
->render_states
[WINED3D_RS_POINTSCALE_B
];
1505 C
.d
= state
->render_states
[WINED3D_RS_POINTSCALE_C
];
1507 if (state
->render_states
[WINED3D_RS_POINTSCALEENABLE
])
1509 DWORD h
= state
->viewport
.height
;
1510 GLfloat scaleFactor
;
1512 if (pointSize
.f
< gl_info
->limits
.pointsize_min
)
1514 /* Minimum valid point size for OpenGL is driver specific. For Direct3D it is
1515 * 0.0f. This means that OpenGL will clamp really small point sizes to the
1516 * driver minimum. To correct for this we need to multiply by the scale factor when sizes
1517 * are less than 1.0f. scale_factor = 1.0f / point_size.
1519 scaleFactor
= pointSize
.f
/ gl_info
->limits
.pointsize_min
;
1520 /* Clamp the point size, don't rely on the driver to do it. MacOS says min point size
1521 * is 1.0, but then accepts points below that and draws too small points
1523 pointSize
.f
= gl_info
->limits
.pointsize_min
;
1525 else if(pointSize
.f
> gl_info
->limits
.pointsize_max
)
1527 /* gl already scales the input to glPointSize,
1528 * d3d scales the result after the point size scale.
1529 * If the point size is bigger than the max size, use the
1530 * scaling to scale it bigger, and set the gl point size to max
1532 scaleFactor
= pointSize
.f
/ gl_info
->limits
.pointsize_max
;
1533 TRACE("scale: %f\n", scaleFactor
);
1534 pointSize
.f
= gl_info
->limits
.pointsize_max
;
1538 scaleFactor
= powf(h
* scaleFactor
, 2);
1540 att
[0] = A
.f
/ scaleFactor
;
1541 att
[1] = B
.f
/ scaleFactor
;
1542 att
[2] = C
.f
/ scaleFactor
;
1545 if (gl_info
->supported
[ARB_POINT_PARAMETERS
])
1547 GL_EXTCALL(glPointParameterfvARB
)(GL_POINT_DISTANCE_ATTENUATION_ARB
, att
);
1548 checkGLcall("glPointParameterfvARB(GL_DISTANCE_ATTENUATION_ARB, ...)");
1550 else if (gl_info
->supported
[EXT_POINT_PARAMETERS
])
1552 GL_EXTCALL(glPointParameterfvEXT
)(GL_DISTANCE_ATTENUATION_EXT
, att
);
1553 checkGLcall("glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, ...)");
1555 else if (state
->render_states
[WINED3D_RS_POINTSCALEENABLE
])
1557 WARN("POINT_PARAMETERS not supported in this version of opengl\n");
1560 gl_info
->gl_ops
.gl
.p_glPointSize(pointSize
.f
);
1561 checkGLcall("glPointSize(...);");
1564 static void state_debug_monitor(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1566 WARN("token: %#x.\n", state
->render_states
[WINED3D_RS_DEBUGMONITORTOKEN
]);
1569 static void state_colorwrite(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1571 DWORD mask0
= state
->render_states
[WINED3D_RS_COLORWRITEENABLE
];
1572 DWORD mask1
= state
->render_states
[WINED3D_RS_COLORWRITEENABLE1
];
1573 DWORD mask2
= state
->render_states
[WINED3D_RS_COLORWRITEENABLE2
];
1574 DWORD mask3
= state
->render_states
[WINED3D_RS_COLORWRITEENABLE3
];
1575 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1577 TRACE("Color mask: r(%d) g(%d) b(%d) a(%d)\n",
1578 mask0
& WINED3DCOLORWRITEENABLE_RED
? 1 : 0,
1579 mask0
& WINED3DCOLORWRITEENABLE_GREEN
? 1 : 0,
1580 mask0
& WINED3DCOLORWRITEENABLE_BLUE
? 1 : 0,
1581 mask0
& WINED3DCOLORWRITEENABLE_ALPHA
? 1 : 0);
1582 gl_info
->gl_ops
.gl
.p_glColorMask(mask0
& WINED3DCOLORWRITEENABLE_RED
? GL_TRUE
: GL_FALSE
,
1583 mask0
& WINED3DCOLORWRITEENABLE_GREEN
? GL_TRUE
: GL_FALSE
,
1584 mask0
& WINED3DCOLORWRITEENABLE_BLUE
? GL_TRUE
: GL_FALSE
,
1585 mask0
& WINED3DCOLORWRITEENABLE_ALPHA
? GL_TRUE
: GL_FALSE
);
1586 checkGLcall("glColorMask(...)");
1588 if (!((mask1
== mask0
&& mask2
== mask0
&& mask3
== mask0
)
1589 || (mask1
== 0xf && mask2
== 0xf && mask3
== 0xf)))
1591 FIXME("WINED3D_RS_COLORWRITEENABLE/1/2/3, %#x/%#x/%#x/%#x not yet implemented.\n",
1592 mask0
, mask1
, mask2
, mask3
);
1593 FIXME("Missing of cap D3DPMISCCAPS_INDEPENDENTWRITEMASKS wasn't honored?\n");
1597 static void set_color_mask(const struct wined3d_gl_info
*gl_info
, UINT index
, DWORD mask
)
1599 GL_EXTCALL(glColorMaski(index
,
1600 mask
& WINED3DCOLORWRITEENABLE_RED
? GL_TRUE
: GL_FALSE
,
1601 mask
& WINED3DCOLORWRITEENABLE_GREEN
? GL_TRUE
: GL_FALSE
,
1602 mask
& WINED3DCOLORWRITEENABLE_BLUE
? GL_TRUE
: GL_FALSE
,
1603 mask
& WINED3DCOLORWRITEENABLE_ALPHA
? GL_TRUE
: GL_FALSE
));
1604 checkGLcall("glColorMaski");
1607 static void state_colorwrite0(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1609 set_color_mask(context
->gl_info
, 0, state
->render_states
[WINED3D_RS_COLORWRITEENABLE
]);
1612 static void state_colorwrite1(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1614 set_color_mask(context
->gl_info
, 1, state
->render_states
[WINED3D_RS_COLORWRITEENABLE1
]);
1617 static void state_colorwrite2(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1619 set_color_mask(context
->gl_info
, 2, state
->render_states
[WINED3D_RS_COLORWRITEENABLE2
]);
1622 static void state_colorwrite3(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1624 set_color_mask(context
->gl_info
, 3, state
->render_states
[WINED3D_RS_COLORWRITEENABLE3
]);
1627 static void state_localviewer(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1629 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1631 if (state
->render_states
[WINED3D_RS_LOCALVIEWER
])
1633 gl_info
->gl_ops
.gl
.p_glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER
, 1);
1634 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1)");
1638 gl_info
->gl_ops
.gl
.p_glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER
, 0);
1639 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 0)");
1643 static void state_lastpixel(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1645 if (state
->render_states
[WINED3D_RS_LASTPIXEL
])
1647 TRACE("Last Pixel Drawing Enabled\n");
1653 FIXME("Last Pixel Drawing Disabled, not handled yet\n");
1656 TRACE("Last Pixel Drawing Disabled, not handled yet\n");
1661 void state_pointsprite_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1665 /* TODO: NV_POINT_SPRITE */
1666 if (!warned
&& state
->render_states
[WINED3D_RS_POINTSPRITEENABLE
])
1668 /* A FIXME, not a WARN because point sprites should be software emulated if not supported by HW */
1669 FIXME("Point sprites not supported\n");
1674 void state_pointsprite(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1676 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1678 if (state
->render_states
[WINED3D_RS_POINTSPRITEENABLE
])
1680 gl_info
->gl_ops
.gl
.p_glEnable(GL_POINT_SPRITE_ARB
);
1681 checkGLcall("glEnable(GL_POINT_SPRITE_ARB)");
1685 gl_info
->gl_ops
.gl
.p_glDisable(GL_POINT_SPRITE_ARB
);
1686 checkGLcall("glDisable(GL_POINT_SPRITE_ARB)");
1690 static void state_wrap(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1692 if (state
->render_states
[WINED3D_RS_WRAP0
]
1693 || state
->render_states
[WINED3D_RS_WRAP1
]
1694 || state
->render_states
[WINED3D_RS_WRAP2
]
1695 || state
->render_states
[WINED3D_RS_WRAP3
]
1696 || state
->render_states
[WINED3D_RS_WRAP4
]
1697 || state
->render_states
[WINED3D_RS_WRAP5
]
1698 || state
->render_states
[WINED3D_RS_WRAP6
]
1699 || state
->render_states
[WINED3D_RS_WRAP7
]
1700 || state
->render_states
[WINED3D_RS_WRAP8
]
1701 || state
->render_states
[WINED3D_RS_WRAP9
]
1702 || state
->render_states
[WINED3D_RS_WRAP10
]
1703 || state
->render_states
[WINED3D_RS_WRAP11
]
1704 || state
->render_states
[WINED3D_RS_WRAP12
]
1705 || state
->render_states
[WINED3D_RS_WRAP13
]
1706 || state
->render_states
[WINED3D_RS_WRAP14
]
1707 || state
->render_states
[WINED3D_RS_WRAP15
])
1708 FIXME("(WINED3D_RS_WRAP0) Texture wrapping not yet supported.\n");
1711 static void state_msaa_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1713 if (state
->render_states
[WINED3D_RS_MULTISAMPLEANTIALIAS
])
1714 WARN("Multisample antialiasing not supported by GL.\n");
1717 static void state_msaa(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1719 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1721 if (state
->render_states
[WINED3D_RS_MULTISAMPLEANTIALIAS
])
1723 gl_info
->gl_ops
.gl
.p_glEnable(GL_MULTISAMPLE_ARB
);
1724 checkGLcall("glEnable(GL_MULTISAMPLE_ARB)");
1728 gl_info
->gl_ops
.gl
.p_glDisable(GL_MULTISAMPLE_ARB
);
1729 checkGLcall("glDisable(GL_MULTISAMPLE_ARB)");
1733 static void state_scissor(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1735 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1737 if (state
->render_states
[WINED3D_RS_SCISSORTESTENABLE
])
1739 gl_info
->gl_ops
.gl
.p_glEnable(GL_SCISSOR_TEST
);
1740 checkGLcall("glEnable(GL_SCISSOR_TEST)");
1744 gl_info
->gl_ops
.gl
.p_glDisable(GL_SCISSOR_TEST
);
1745 checkGLcall("glDisable(GL_SCISSOR_TEST)");
1749 /* The Direct3D depth bias is specified in normalized depth coordinates. In
1750 * OpenGL the bias is specified in units of "the smallest value that is
1751 * guaranteed to produce a resolvable offset for a given implementation". To
1752 * convert from D3D to GL we need to divide the D3D depth bias by that value.
1753 * There's no practical way to retrieve that value from a given GL
1754 * implementation, but the D3D application has essentially the same problem,
1755 * which makes a guess of the depth buffer format's highest possible value a
1756 * reasonable guess. Note that SLOPESCALEDEPTHBIAS is a scaling factor for the
1757 * depth slope, and doesn't need to be scaled. */
1758 static void state_depthbias(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1760 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1762 if (state
->render_states
[WINED3D_RS_SLOPESCALEDEPTHBIAS
]
1763 || state
->render_states
[WINED3D_RS_DEPTHBIAS
])
1765 const struct wined3d_rendertarget_view
*depth
= state
->fb
->depth_stencil
;
1772 } scale_bias
, const_bias
;
1774 scale_bias
.d
= state
->render_states
[WINED3D_RS_SLOPESCALEDEPTHBIAS
];
1775 const_bias
.d
= state
->render_states
[WINED3D_RS_DEPTHBIAS
];
1777 gl_info
->gl_ops
.gl
.p_glEnable(GL_POLYGON_OFFSET_FILL
);
1778 checkGLcall("glEnable(GL_POLYGON_OFFSET_FILL)");
1780 if (context
->swapchain
->device
->wined3d
->flags
& WINED3D_LEGACY_DEPTH_BIAS
)
1782 float bias
= -(float)const_bias
.d
;
1783 gl_info
->gl_ops
.gl
.p_glPolygonOffset(bias
, bias
);
1784 checkGLcall("glPolygonOffset");
1790 const struct wined3d_format
*fmt
= depth
->format
;
1791 scale
= powf(2, fmt
->depth_size
) - 1;
1792 TRACE("Depth format %s, using depthbias scale of %.8e.\n",
1793 debug_d3dformat(fmt
->id
), scale
);
1797 /* The context manager will reapply this state on a depth stencil change */
1798 TRACE("No depth stencil, using depthbias scale of 0.0.\n");
1802 gl_info
->gl_ops
.gl
.p_glPolygonOffset(scale_bias
.f
, const_bias
.f
* scale
);
1803 checkGLcall("glPolygonOffset(...)");
1808 gl_info
->gl_ops
.gl
.p_glDisable(GL_POLYGON_OFFSET_FILL
);
1809 checkGLcall("glDisable(GL_POLYGON_OFFSET_FILL)");
1813 static void state_zvisible(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1815 if (state
->render_states
[WINED3D_RS_ZVISIBLE
])
1816 FIXME("WINED3D_RS_ZVISIBLE not implemented.\n");
1819 static void state_perspective(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1821 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1823 if (state
->render_states
[WINED3D_RS_TEXTUREPERSPECTIVE
])
1825 gl_info
->gl_ops
.gl
.p_glHint(GL_PERSPECTIVE_CORRECTION_HINT
, GL_NICEST
);
1826 checkGLcall("glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)");
1830 gl_info
->gl_ops
.gl
.p_glHint(GL_PERSPECTIVE_CORRECTION_HINT
, GL_FASTEST
);
1831 checkGLcall("glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST)");
1835 static void state_stippledalpha(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1837 if (state
->render_states
[WINED3D_RS_STIPPLEDALPHA
])
1838 FIXME("Stippled Alpha not supported yet.\n");
1841 static void state_antialias(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1843 if (state
->render_states
[WINED3D_RS_ANTIALIAS
])
1844 FIXME("Antialias not supported yet.\n");
1847 static void state_multisampmask(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1849 if (state
->render_states
[WINED3D_RS_MULTISAMPLEMASK
] != 0xffffffff)
1850 FIXME("WINED3D_RS_MULTISAMPLEMASK %#x not yet implemented.\n",
1851 state
->render_states
[WINED3D_RS_MULTISAMPLEMASK
]);
1854 static void state_patchedgestyle(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1856 if (state
->render_states
[WINED3D_RS_PATCHEDGESTYLE
] != WINED3D_PATCH_EDGE_DISCRETE
)
1857 FIXME("WINED3D_RS_PATCHEDGESTYLE %#x not yet implemented.\n",
1858 state
->render_states
[WINED3D_RS_PATCHEDGESTYLE
]);
1861 static void state_patchsegments(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1869 if (state
->render_states
[WINED3D_RS_PATCHSEGMENTS
] != tmpvalue
.d
)
1871 static BOOL displayed
= FALSE
;
1873 tmpvalue
.d
= state
->render_states
[WINED3D_RS_PATCHSEGMENTS
];
1875 FIXME("(WINED3D_RS_PATCHSEGMENTS,%f) not yet implemented\n", tmpvalue
.f
);
1881 static void state_positiondegree(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1883 if (state
->render_states
[WINED3D_RS_POSITIONDEGREE
] != WINED3D_DEGREE_CUBIC
)
1884 FIXME("WINED3D_RS_POSITIONDEGREE %#x not yet implemented.\n",
1885 state
->render_states
[WINED3D_RS_POSITIONDEGREE
]);
1888 static void state_normaldegree(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1890 if (state
->render_states
[WINED3D_RS_NORMALDEGREE
] != WINED3D_DEGREE_LINEAR
)
1891 FIXME("WINED3D_RS_NORMALDEGREE %#x not yet implemented.\n",
1892 state
->render_states
[WINED3D_RS_NORMALDEGREE
]);
1895 static void state_tessellation(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1897 if (state
->render_states
[WINED3D_RS_ENABLEADAPTIVETESSELLATION
])
1898 FIXME("WINED3D_RS_ENABLEADAPTIVETESSELLATION %#x not yet implemented.\n",
1899 state
->render_states
[WINED3D_RS_ENABLEADAPTIVETESSELLATION
]);
1902 static void state_nvdb(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1909 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1911 if (state
->render_states
[WINED3D_RS_ADAPTIVETESS_X
] == WINED3DFMT_NVDB
)
1913 zmin
.d
= state
->render_states
[WINED3D_RS_ADAPTIVETESS_Z
];
1914 zmax
.d
= state
->render_states
[WINED3D_RS_ADAPTIVETESS_W
];
1916 /* If zmin is larger than zmax INVALID_VALUE error is generated.
1917 * In d3d9 test is not performed in this case*/
1918 if (zmin
.f
<= zmax
.f
)
1920 gl_info
->gl_ops
.gl
.p_glEnable(GL_DEPTH_BOUNDS_TEST_EXT
);
1921 checkGLcall("glEnable(GL_DEPTH_BOUNDS_TEST_EXT)");
1922 GL_EXTCALL(glDepthBoundsEXT(zmin
.f
, zmax
.f
));
1923 checkGLcall("glDepthBoundsEXT(...)");
1927 gl_info
->gl_ops
.gl
.p_glDisable(GL_DEPTH_BOUNDS_TEST_EXT
);
1928 checkGLcall("glDisable(GL_DEPTH_BOUNDS_TEST_EXT)");
1933 gl_info
->gl_ops
.gl
.p_glDisable(GL_DEPTH_BOUNDS_TEST_EXT
);
1934 checkGLcall("glDisable(GL_DEPTH_BOUNDS_TEST_EXT)");
1937 state_tessellation(context
, state
, STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
));
1940 static void state_wrapu(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1942 if (state
->render_states
[WINED3D_RS_WRAPU
])
1943 FIXME("Render state WINED3D_RS_WRAPU not implemented yet.\n");
1946 static void state_wrapv(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1948 if (state
->render_states
[WINED3D_RS_WRAPV
])
1949 FIXME("Render state WINED3D_RS_WRAPV not implemented yet.\n");
1952 static void state_monoenable(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1954 if (state
->render_states
[WINED3D_RS_MONOENABLE
])
1955 FIXME("Render state WINED3D_RS_MONOENABLE not implemented yet.\n");
1958 static void state_rop2(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1960 if (state
->render_states
[WINED3D_RS_ROP2
])
1961 FIXME("Render state WINED3D_RS_ROP2 not implemented yet.\n");
1964 static void state_planemask(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1966 if (state
->render_states
[WINED3D_RS_PLANEMASK
])
1967 FIXME("Render state WINED3D_RS_PLANEMASK not implemented yet.\n");
1970 static void state_subpixel(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1972 if (state
->render_states
[WINED3D_RS_SUBPIXEL
])
1973 FIXME("Render state WINED3D_RS_SUBPIXEL not implemented yet.\n");
1976 static void state_subpixelx(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1978 if (state
->render_states
[WINED3D_RS_SUBPIXELX
])
1979 FIXME("Render state WINED3D_RS_SUBPIXELX not implemented yet.\n");
1982 static void state_stippleenable(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1984 if (state
->render_states
[WINED3D_RS_STIPPLEENABLE
])
1985 FIXME("Render state WINED3D_RS_STIPPLEENABLE not implemented yet.\n");
1988 static void state_mipmaplodbias(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1990 if (state
->render_states
[WINED3D_RS_MIPMAPLODBIAS
])
1991 FIXME("Render state WINED3D_RS_MIPMAPLODBIAS not implemented yet.\n");
1994 static void state_anisotropy(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1996 if (state
->render_states
[WINED3D_RS_ANISOTROPY
])
1997 FIXME("Render state WINED3D_RS_ANISOTROPY not implemented yet.\n");
2000 static void state_flushbatch(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
2002 if (state
->render_states
[WINED3D_RS_FLUSHBATCH
])
2003 FIXME("Render state WINED3D_RS_FLUSHBATCH not implemented yet.\n");
2006 static void state_translucentsi(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
2008 if (state
->render_states
[WINED3D_RS_TRANSLUCENTSORTINDEPENDENT
])
2009 FIXME("Render state WINED3D_RS_TRANSLUCENTSORTINDEPENDENT not implemented yet.\n");
2012 static void state_extents(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
2014 if (state
->render_states
[WINED3D_RS_EXTENTS
])
2015 FIXME("Render state WINED3D_RS_EXTENTS not implemented yet.\n");
2018 static void state_ckeyblend(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
2020 if (state
->render_states
[WINED3D_RS_COLORKEYBLENDENABLE
])
2021 FIXME("Render state WINED3D_RS_COLORKEYBLENDENABLE not implemented yet.\n");
2024 static void state_swvp(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
2026 if (state
->render_states
[WINED3D_RS_SOFTWAREVERTEXPROCESSING
])
2027 FIXME("Software vertex processing not implemented.\n");
2030 static void get_src_and_opr(DWORD arg
, BOOL is_alpha
, GLenum
* source
, GLenum
* operand
) {
2031 /* The WINED3DTA_ALPHAREPLICATE flag specifies the alpha component of the
2032 * input should be used for all input components. The WINED3DTA_COMPLEMENT
2033 * flag specifies the complement of the input should be used. */
2034 BOOL from_alpha
= is_alpha
|| arg
& WINED3DTA_ALPHAREPLICATE
;
2035 BOOL complement
= arg
& WINED3DTA_COMPLEMENT
;
2037 /* Calculate the operand */
2039 if (from_alpha
) *operand
= GL_ONE_MINUS_SRC_ALPHA
;
2040 else *operand
= GL_ONE_MINUS_SRC_COLOR
;
2042 if (from_alpha
) *operand
= GL_SRC_ALPHA
;
2043 else *operand
= GL_SRC_COLOR
;
2046 /* Calculate the source */
2047 switch (arg
& WINED3DTA_SELECTMASK
) {
2048 case WINED3DTA_CURRENT
: *source
= GL_PREVIOUS_EXT
; break;
2049 case WINED3DTA_DIFFUSE
: *source
= GL_PRIMARY_COLOR_EXT
; break;
2050 case WINED3DTA_TEXTURE
: *source
= GL_TEXTURE
; break;
2051 case WINED3DTA_TFACTOR
: *source
= GL_CONSTANT_EXT
; break;
2052 case WINED3DTA_SPECULAR
:
2054 * According to the GL_ARB_texture_env_combine specs, SPECULAR is
2055 * 'Secondary color' and isn't supported until base GL supports it
2056 * There is no concept of temp registers as far as I can tell
2058 FIXME("Unhandled texture arg WINED3DTA_SPECULAR\n");
2059 *source
= GL_TEXTURE
;
2062 FIXME("Unrecognized texture arg %#x\n", arg
);
2063 *source
= GL_TEXTURE
;
2068 /* Setup the texture operations texture stage states */
2069 static void set_tex_op(const struct wined3d_gl_info
*gl_info
, const struct wined3d_state
*state
,
2070 BOOL isAlpha
, int Stage
, enum wined3d_texture_op op
, DWORD arg1
, DWORD arg2
, DWORD arg3
)
2072 GLenum src1
, src2
, src3
;
2073 GLenum opr1
, opr2
, opr3
;
2075 GLenum src0_target
, src1_target
, src2_target
;
2076 GLenum opr0_target
, opr1_target
, opr2_target
;
2078 GLenum opr
=0, invopr
, src3_target
, opr3_target
;
2079 BOOL Handled
= FALSE
;
2081 TRACE("Alpha?(%d), Stage:%d Op(%s), a1(%d), a2(%d), a3(%d)\n", isAlpha
, Stage
, debug_d3dtop(op
), arg1
, arg2
, arg3
);
2083 /* Operations usually involve two args, src0 and src1 and are operations
2084 * of the form (a1 <operation> a2). However, some of the more complex
2085 * operations take 3 parameters. Instead of the (sensible) addition of a3,
2086 * Microsoft added in a third parameter called a0. Therefore these are
2087 * operations of the form a0 <operation> a1 <operation> a2. I.e., the new
2088 * parameter goes to the front.
2090 * However, below we treat the new (a0) parameter as src2/opr2, so in the
2091 * actual functions below, expect their syntax to differ slightly to those
2092 * listed in the manuals. I.e., replace arg1 with arg3, arg2 with arg1 and
2093 * arg3 with arg2. This affects WINED3DTOP_MULTIPLYADD and WINED3DTOP_LERP. */
2097 comb_target
= GL_COMBINE_ALPHA
;
2098 src0_target
= GL_SOURCE0_ALPHA
;
2099 src1_target
= GL_SOURCE1_ALPHA
;
2100 src2_target
= GL_SOURCE2_ALPHA
;
2101 opr0_target
= GL_OPERAND0_ALPHA
;
2102 opr1_target
= GL_OPERAND1_ALPHA
;
2103 opr2_target
= GL_OPERAND2_ALPHA
;
2104 scal_target
= GL_ALPHA_SCALE
;
2108 comb_target
= GL_COMBINE_RGB
;
2109 src0_target
= GL_SOURCE0_RGB
;
2110 src1_target
= GL_SOURCE1_RGB
;
2111 src2_target
= GL_SOURCE2_RGB
;
2112 opr0_target
= GL_OPERAND0_RGB
;
2113 opr1_target
= GL_OPERAND1_RGB
;
2114 opr2_target
= GL_OPERAND2_RGB
;
2115 scal_target
= GL_RGB_SCALE
;
2118 /* If a texture stage references an invalid texture unit the stage just
2119 * passes through the result from the previous stage */
2120 if (is_invalid_op(state
, Stage
, op
, arg1
, arg2
, arg3
))
2122 arg1
= WINED3DTA_CURRENT
;
2123 op
= WINED3D_TOP_SELECT_ARG1
;
2126 if (isAlpha
&& !state
->textures
[Stage
] && arg1
== WINED3DTA_TEXTURE
)
2128 get_src_and_opr(WINED3DTA_DIFFUSE
, isAlpha
, &src1
, &opr1
);
2130 get_src_and_opr(arg1
, isAlpha
, &src1
, &opr1
);
2132 get_src_and_opr(arg2
, isAlpha
, &src2
, &opr2
);
2133 get_src_and_opr(arg3
, isAlpha
, &src3
, &opr3
);
2135 TRACE("ct(%x), 1:(%x,%x), 2:(%x,%x), 3:(%x,%x)\n", comb_target
, src1
, opr1
, src2
, opr2
, src3
, opr3
);
2137 Handled
= TRUE
; /* Assume will be handled */
2139 /* Other texture operations require special extensions: */
2140 if (gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
2144 invopr
= GL_ONE_MINUS_SRC_ALPHA
;
2145 src3_target
= GL_SOURCE3_ALPHA_NV
;
2146 opr3_target
= GL_OPERAND3_ALPHA_NV
;
2149 invopr
= GL_ONE_MINUS_SRC_COLOR
;
2150 src3_target
= GL_SOURCE3_RGB_NV
;
2151 opr3_target
= GL_OPERAND3_RGB_NV
;
2155 case WINED3D_TOP_DISABLE
: /* Only for alpha */
2156 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2157 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2158 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_PREVIOUS_EXT
);
2159 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2160 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_SRC_ALPHA
);
2161 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2162 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2163 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2164 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2165 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2166 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2167 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_ZERO");
2168 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2169 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2170 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2171 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2172 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2173 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2176 case WINED3D_TOP_SELECT_ARG1
: /* = a1 * 1 + 0 * 0 */
2177 case WINED3D_TOP_SELECT_ARG2
: /* = a2 * 1 + 0 * 0 */
2178 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2179 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2180 if (op
== WINED3D_TOP_SELECT_ARG1
)
2182 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2183 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2184 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2185 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2189 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src2
);
2190 checkGLcall("GL_TEXTURE_ENV, src0_target, src2");
2191 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr2
);
2192 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr2");
2194 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2195 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2196 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2197 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2198 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2199 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_ZERO");
2200 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2201 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2202 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2203 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2204 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2205 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2208 case WINED3D_TOP_MODULATE
:
2209 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2210 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2211 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2212 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2213 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2214 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2215 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2216 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2217 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2218 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2219 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2220 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2221 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2222 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2223 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2224 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2225 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2226 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2227 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2228 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2230 case WINED3D_TOP_MODULATE_2X
:
2231 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2232 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2233 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2234 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2235 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2236 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2237 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2238 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2239 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2240 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2241 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2242 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2243 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2244 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2245 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2246 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2247 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2248 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2249 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2250 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2252 case WINED3D_TOP_MODULATE_4X
:
2253 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2254 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2255 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2256 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2257 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2258 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2259 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2260 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2261 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2262 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2263 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2264 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2265 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2266 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2267 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2268 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2269 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2270 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2271 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 4);
2272 checkGLcall("GL_TEXTURE_ENV, scal_target, 4");
2275 case WINED3D_TOP_ADD
:
2276 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2277 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2278 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2279 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2280 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2281 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2282 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2283 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2284 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2285 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2286 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2287 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2288 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2289 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2290 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2291 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2292 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2293 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2294 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2295 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2298 case WINED3D_TOP_ADD_SIGNED
:
2299 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD_SIGNED
);
2300 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2301 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2302 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2303 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2304 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2305 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2306 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2307 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2308 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2309 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2310 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2311 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2312 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2313 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2314 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2315 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2316 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2317 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2318 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2321 case WINED3D_TOP_ADD_SIGNED_2X
:
2322 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD_SIGNED
);
2323 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2324 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2325 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2326 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2327 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2328 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2329 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2330 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2331 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2332 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2333 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2334 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2335 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2336 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2337 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2338 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2339 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2340 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2341 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2344 case WINED3D_TOP_ADD_SMOOTH
:
2345 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2346 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2347 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2348 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2349 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2350 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2351 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2352 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2353 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2354 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2355 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2356 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2357 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2358 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2359 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
2360 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2362 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2363 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2364 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2365 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2367 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2368 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2369 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2370 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2373 case WINED3D_TOP_BLEND_DIFFUSE_ALPHA
:
2374 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2375 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2376 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2377 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2378 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2379 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2380 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_PRIMARY_COLOR
);
2381 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_PRIMARY_COLOR");
2382 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2383 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2384 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2385 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2386 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2387 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2388 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_PRIMARY_COLOR
);
2389 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_PRIMARY_COLOR");
2390 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2391 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2392 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2393 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2395 case WINED3D_TOP_BLEND_TEXTURE_ALPHA
:
2396 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2397 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2398 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2399 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2400 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2401 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2402 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_TEXTURE
);
2403 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_TEXTURE");
2404 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2405 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2406 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2407 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2408 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2409 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2410 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_TEXTURE
);
2411 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_TEXTURE");
2412 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2413 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2414 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2415 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2417 case WINED3D_TOP_BLEND_FACTOR_ALPHA
:
2418 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2419 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2420 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2421 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2422 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2423 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2424 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_CONSTANT
);
2425 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_CONSTANT");
2426 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2427 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2428 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2429 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2430 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2431 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2432 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_CONSTANT
);
2433 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_CONSTANT");
2434 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2435 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2436 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2437 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2439 case WINED3D_TOP_BLEND_TEXTURE_ALPHA_PM
:
2440 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2441 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2442 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2443 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2444 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2445 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2446 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2447 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2448 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2449 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2450 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2451 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2452 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2453 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2454 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_TEXTURE
);
2455 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_TEXTURE");
2456 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2457 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2458 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2459 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2461 case WINED3D_TOP_MODULATE_ALPHA_ADD_COLOR
:
2462 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2463 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2464 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
); /* a0 = src1/opr1 */
2465 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2466 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2467 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1"); /* a1 = 1 (see docs) */
2468 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2469 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2470 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2471 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2472 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
); /* a2 = arg2 */
2473 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2474 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2475 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2"); /* a3 = src1 alpha */
2476 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
2477 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2479 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2480 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2482 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2483 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2484 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2485 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2487 case WINED3D_TOP_MODULATE_COLOR_ADD_ALPHA
:
2488 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2489 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2490 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2491 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2492 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2493 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2494 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2495 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2496 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2497 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2498 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
2499 checkGLcall("GL_TEXTURE_ENV, src2_target, src1");
2501 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2502 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2504 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2505 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2506 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2507 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2508 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2509 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2510 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2511 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2513 case WINED3D_TOP_MODULATE_INVALPHA_ADD_COLOR
:
2514 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2515 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2516 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2517 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2518 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2519 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2520 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2521 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2522 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2523 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2524 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2525 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2526 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2527 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2528 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
2529 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2531 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2532 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2533 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2534 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2536 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2537 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2538 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2539 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2541 case WINED3D_TOP_MODULATE_INVCOLOR_ADD_ALPHA
:
2542 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2543 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2544 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2545 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2547 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2548 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2549 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2550 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2552 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2553 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2554 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2555 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2556 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2557 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2558 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
2559 checkGLcall("GL_TEXTURE_ENV, src2_target, src1");
2561 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2562 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2564 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2565 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2566 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2567 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2568 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2569 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2570 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2571 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2573 case WINED3D_TOP_MULTIPLY_ADD
:
2574 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2575 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2576 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src3
);
2577 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2578 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr3
);
2579 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2580 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2581 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2582 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2583 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2584 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
2585 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2586 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr1
);
2587 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2588 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src2
);
2589 checkGLcall("GL_TEXTURE_ENV, src3_target, src3");
2590 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr2
);
2591 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr3");
2592 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2593 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2596 case WINED3D_TOP_BUMPENVMAP
:
2597 case WINED3D_TOP_BUMPENVMAP_LUMINANCE
:
2598 FIXME("Implement bump environment mapping in GL_NV_texture_env_combine4 path\n");
2607 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_COMBINE4_NV
);
2608 checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV");
2612 } /* GL_NV_texture_env_combine4 */
2614 Handled
= TRUE
; /* Again, assume handled */
2616 case WINED3D_TOP_DISABLE
: /* Only for alpha */
2617 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
2618 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2619 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_PREVIOUS_EXT
);
2620 checkGLcall("GL_TEXTURE_ENV, src0_target, GL_PREVIOUS_EXT");
2621 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_SRC_ALPHA
);
2622 checkGLcall("GL_TEXTURE_ENV, opr0_target, GL_SRC_ALPHA");
2623 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2624 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2626 case WINED3D_TOP_SELECT_ARG1
:
2627 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
2628 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2629 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2630 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2631 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2632 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2633 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2634 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2636 case WINED3D_TOP_SELECT_ARG2
:
2637 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
2638 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2639 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src2
);
2640 checkGLcall("GL_TEXTURE_ENV, src0_target, src2");
2641 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr2
);
2642 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr2");
2643 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2644 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2646 case WINED3D_TOP_MODULATE
:
2647 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
2648 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2649 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2650 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2651 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2652 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2653 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2654 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2655 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2656 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2657 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2658 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2660 case WINED3D_TOP_MODULATE_2X
:
2661 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
2662 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2663 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2664 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2665 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2666 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2667 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2668 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2669 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2670 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2671 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2672 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2674 case WINED3D_TOP_MODULATE_4X
:
2675 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
2676 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2677 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2678 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2679 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2680 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2681 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2682 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2683 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2684 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2685 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 4);
2686 checkGLcall("GL_TEXTURE_ENV, scal_target, 4");
2688 case WINED3D_TOP_ADD
:
2689 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2690 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2691 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2692 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2693 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2694 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2695 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2696 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2697 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2698 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2699 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2700 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2702 case WINED3D_TOP_ADD_SIGNED
:
2703 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD_SIGNED
);
2704 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2705 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2706 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2707 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2708 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2709 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2710 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2711 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2712 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2713 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2714 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2716 case WINED3D_TOP_ADD_SIGNED_2X
:
2717 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD_SIGNED
);
2718 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2719 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2720 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2721 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2722 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2723 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2724 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2725 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2726 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2727 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2728 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2730 case WINED3D_TOP_SUBTRACT
:
2731 if (gl_info
->supported
[ARB_TEXTURE_ENV_COMBINE
])
2733 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_SUBTRACT
);
2734 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_SUBTRACT");
2735 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2736 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2737 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2738 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2739 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2740 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2741 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2742 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2743 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2744 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2746 FIXME("This version of opengl does not support GL_SUBTRACT\n");
2750 case WINED3D_TOP_BLEND_DIFFUSE_ALPHA
:
2751 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2752 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2753 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2754 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2755 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2756 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2757 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2758 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2759 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2760 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2761 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_PRIMARY_COLOR
);
2762 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_PRIMARY_COLOR");
2763 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2764 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2765 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2766 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2768 case WINED3D_TOP_BLEND_TEXTURE_ALPHA
:
2769 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2770 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2771 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2772 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2773 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2774 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2775 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2776 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2777 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2778 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2779 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_TEXTURE
);
2780 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_TEXTURE");
2781 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2782 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2783 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2784 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2786 case WINED3D_TOP_BLEND_FACTOR_ALPHA
:
2787 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2788 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2789 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2790 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2791 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2792 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2793 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2794 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2795 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2796 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2797 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_CONSTANT
);
2798 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_CONSTANT");
2799 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2800 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2801 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2802 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2804 case WINED3D_TOP_BLEND_CURRENT_ALPHA
:
2805 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2806 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2807 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2808 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2809 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2810 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2811 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2812 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2813 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2814 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2815 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_PREVIOUS
);
2816 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_PREVIOUS");
2817 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2818 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2819 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2820 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2822 case WINED3D_TOP_DOTPRODUCT3
:
2823 if (gl_info
->supported
[ARB_TEXTURE_ENV_DOT3
])
2825 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_DOT3_RGBA_ARB
);
2826 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_ARB");
2828 else if (gl_info
->supported
[EXT_TEXTURE_ENV_DOT3
])
2830 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_DOT3_RGBA_EXT
);
2831 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_EXT");
2833 FIXME("This version of opengl does not support GL_DOT3\n");
2835 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2836 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2837 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2838 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2839 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2840 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2841 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2842 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2843 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2844 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2846 case WINED3D_TOP_LERP
:
2847 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2848 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2849 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2850 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2851 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2852 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2853 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2854 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2855 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2856 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2857 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src3
);
2858 checkGLcall("GL_TEXTURE_ENV, src2_target, src3");
2859 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr3
);
2860 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr3");
2861 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2862 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2864 case WINED3D_TOP_ADD_SMOOTH
:
2865 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2867 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2868 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2869 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2870 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2872 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2873 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2874 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2875 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2877 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2878 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2879 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2880 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2881 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2882 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2883 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2884 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2885 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2886 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2887 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2888 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2892 case WINED3D_TOP_BLEND_TEXTURE_ALPHA_PM
:
2893 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2895 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2896 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2897 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_TEXTURE
);
2898 checkGLcall("GL_TEXTURE_ENV, src0_target, GL_TEXTURE");
2899 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_ONE_MINUS_SRC_ALPHA
);
2900 checkGLcall("GL_TEXTURE_ENV, opr0_target, GL_ONE_MINUS_SRC_APHA");
2901 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2902 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2903 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2904 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2905 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2906 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2907 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2908 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2909 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2910 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2914 case WINED3D_TOP_MODULATE_ALPHA_ADD_COLOR
:
2915 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2917 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2918 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2919 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2920 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2922 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2923 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2924 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2925 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2927 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2928 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2929 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2930 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2931 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2932 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2933 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2934 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2935 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2936 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2937 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2938 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2942 case WINED3D_TOP_MODULATE_COLOR_ADD_ALPHA
:
2943 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2945 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2946 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2947 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2948 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2949 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2950 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2951 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2952 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2954 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2955 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2956 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2957 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2959 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr
);
2960 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr");
2961 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2962 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2963 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2964 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2965 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2966 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2970 case WINED3D_TOP_MODULATE_INVALPHA_ADD_COLOR
:
2971 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2973 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2974 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2975 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2976 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2978 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2979 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2980 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2981 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2983 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2984 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2985 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2986 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2987 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2988 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2989 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2990 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2991 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2992 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2993 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2994 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2998 case WINED3D_TOP_MODULATE_INVCOLOR_ADD_ALPHA
:
2999 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
3001 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
3002 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
3003 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
3004 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
3006 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
3007 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
3008 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
3009 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
3011 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
3012 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
3013 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
3014 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
3016 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
3017 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
3018 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
3019 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
3021 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr
);
3022 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr");
3023 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
3024 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
3025 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
3026 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
3027 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
3028 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
3032 case WINED3D_TOP_MULTIPLY_ADD
:
3033 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
3035 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
3036 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
3037 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
3038 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
3039 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
3040 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
3041 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src3
);
3042 checkGLcall("GL_TEXTURE_ENV, src1_target, src3");
3043 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr3
);
3044 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr3");
3045 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
3046 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
3047 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
3048 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
3049 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
3050 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
3054 case WINED3D_TOP_BUMPENVMAP_LUMINANCE
:
3055 case WINED3D_TOP_BUMPENVMAP
:
3056 if (gl_info
->supported
[NV_TEXTURE_SHADER2
])
3058 /* Technically texture shader support without register combiners is possible, but not expected to occur
3059 * on real world cards, so for now a fixme should be enough
3061 FIXME("Implement bump mapping with GL_NV_texture_shader in non register combiner path\n");
3071 BOOL combineOK
= TRUE
;
3072 if (gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
3077 op2
= state
->texture_states
[Stage
][WINED3D_TSS_COLOR_OP
];
3079 op2
= state
->texture_states
[Stage
][WINED3D_TSS_ALPHA_OP
];
3081 /* Note: If COMBINE4 in effect can't go back to combine! */
3084 case WINED3D_TOP_ADD_SMOOTH
:
3085 case WINED3D_TOP_BLEND_TEXTURE_ALPHA_PM
:
3086 case WINED3D_TOP_MODULATE_ALPHA_ADD_COLOR
:
3087 case WINED3D_TOP_MODULATE_COLOR_ADD_ALPHA
:
3088 case WINED3D_TOP_MODULATE_INVALPHA_ADD_COLOR
:
3089 case WINED3D_TOP_MODULATE_INVCOLOR_ADD_ALPHA
:
3090 case WINED3D_TOP_MULTIPLY_ADD
:
3091 /* Ignore those implemented in both cases */
3094 case WINED3D_TOP_SELECT_ARG1
:
3095 case WINED3D_TOP_SELECT_ARG2
:
3100 FIXME("Can't use COMBINE4 and COMBINE together, thisop=%s, otherop=%s, isAlpha(%d)\n", debug_d3dtop(op
), debug_d3dtop(op2
), isAlpha
);
3108 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_COMBINE
);
3109 checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE");
3115 /* After all the extensions, if still unhandled, report fixme */
3116 FIXME("Unhandled texture operation %s\n", debug_d3dtop(op
));
3120 static void tex_colorop(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3122 DWORD stage
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3123 BOOL tex_used
= context
->fixed_function_usage_map
& (1 << stage
);
3124 DWORD mapped_stage
= context
->tex_unit_map
[stage
];
3125 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3127 TRACE("Setting color op for stage %d\n", stage
);
3129 /* Using a pixel shader? Don't care for anything here, the shader applying does it */
3130 if (use_ps(state
)) return;
3132 if (stage
!= mapped_stage
) WARN("Using non 1:1 mapping: %d -> %d!\n", stage
, mapped_stage
);
3134 if (mapped_stage
!= WINED3D_UNMAPPED_STAGE
)
3136 if (tex_used
&& mapped_stage
>= gl_info
->limits
.textures
)
3138 FIXME("Attempt to enable unsupported stage!\n");
3141 context_active_texture(context
, gl_info
, mapped_stage
);
3144 if (stage
>= context
->lowest_disabled_stage
)
3146 TRACE("Stage disabled\n");
3147 if (mapped_stage
!= WINED3D_UNMAPPED_STAGE
)
3149 /* Disable everything here */
3150 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_2D
);
3151 checkGLcall("glDisable(GL_TEXTURE_2D)");
3152 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_3D
);
3153 checkGLcall("glDisable(GL_TEXTURE_3D)");
3154 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
3156 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB
);
3157 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
3159 if (gl_info
->supported
[ARB_TEXTURE_RECTANGLE
])
3161 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_RECTANGLE_ARB
);
3162 checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)");
3169 /* The sampler will also activate the correct texture dimensions, so no
3170 * need to do it here if the sampler for this stage is dirty. */
3171 if (!isStateDirty(context
, STATE_SAMPLER(stage
)) && tex_used
)
3172 texture_activate_dimensions(state
->textures
[stage
], gl_info
);
3174 set_tex_op(gl_info
, state
, FALSE
, stage
,
3175 state
->texture_states
[stage
][WINED3D_TSS_COLOR_OP
],
3176 state
->texture_states
[stage
][WINED3D_TSS_COLOR_ARG1
],
3177 state
->texture_states
[stage
][WINED3D_TSS_COLOR_ARG2
],
3178 state
->texture_states
[stage
][WINED3D_TSS_COLOR_ARG0
]);
3181 void tex_alphaop(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3183 DWORD stage
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3184 BOOL tex_used
= context
->fixed_function_usage_map
& (1 << stage
);
3185 DWORD mapped_stage
= context
->tex_unit_map
[stage
];
3186 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3187 DWORD op
, arg1
, arg2
, arg0
;
3189 TRACE("Setting alpha op for stage %d\n", stage
);
3190 /* Do not care for enabled / disabled stages, just assign the settings. colorop disables / enables required stuff */
3191 if (mapped_stage
!= WINED3D_UNMAPPED_STAGE
)
3193 if (tex_used
&& mapped_stage
>= gl_info
->limits
.textures
)
3195 FIXME("Attempt to enable unsupported stage!\n");
3198 context_active_texture(context
, gl_info
, mapped_stage
);
3201 op
= state
->texture_states
[stage
][WINED3D_TSS_ALPHA_OP
];
3202 arg1
= state
->texture_states
[stage
][WINED3D_TSS_ALPHA_ARG1
];
3203 arg2
= state
->texture_states
[stage
][WINED3D_TSS_ALPHA_ARG2
];
3204 arg0
= state
->texture_states
[stage
][WINED3D_TSS_ALPHA_ARG0
];
3206 if (state
->render_states
[WINED3D_RS_COLORKEYENABLE
] && !stage
&& state
->textures
[0])
3208 struct wined3d_texture
*texture
= state
->textures
[0];
3209 GLenum texture_dimensions
= texture
->target
;
3211 if (texture_dimensions
== GL_TEXTURE_2D
|| texture_dimensions
== GL_TEXTURE_RECTANGLE_ARB
)
3213 if (texture
->color_key_flags
& WINED3D_CKEY_SRC_BLT
&& !texture
->resource
.format
->alpha_size
)
3215 /* Color keying needs to pass alpha values from the texture through to have the alpha test work
3216 * properly. On the other hand applications can still use texture combiners apparently. This code
3217 * takes care that apps cannot remove the texture's alpha channel entirely.
3219 * The fixup is required for Prince of Persia 3D(prison bars), while Moto racer 2 requires
3220 * D3DTOP_MODULATE to work on color keyed surfaces. Aliens vs Predator 1 uses color keyed textures
3221 * and alpha component of diffuse color to draw things like translucent text and perform other
3224 * Aliens vs Predator 1 relies on diffuse alpha having an effect, so it cannot be ignored. To
3225 * provide the behavior expected by the game, while emulating the colorkey, diffuse alpha must be
3226 * modulated with texture alpha. OTOH, Moto racer 2 at some points sets alphaop/alphaarg to
3227 * SELECTARG/CURRENT, yet puts garbage in diffuse alpha (zeroes). This works on native, because the
3228 * game disables alpha test and alpha blending. Alpha test is overwritten by wine's for purposes of
3229 * color-keying though, so this will lead to missing geometry if texture alpha is modulated (pixels
3230 * fail alpha test). To get around this, ALPHABLENDENABLE state is checked: if the app enables alpha
3231 * blending, it can be expected to provide meaningful values in diffuse alpha, so it should be
3232 * modulated with texture alpha; otherwise, selecting diffuse alpha is ignored in favour of texture
3235 * What to do with multitexturing? So far no app has been found that uses color keying with
3237 if (op
== WINED3D_TOP_DISABLE
)
3239 arg1
= WINED3DTA_TEXTURE
;
3240 op
= WINED3D_TOP_SELECT_ARG1
;
3242 else if (op
== WINED3D_TOP_SELECT_ARG1
&& arg1
!= WINED3DTA_TEXTURE
)
3244 if (state
->render_states
[WINED3D_RS_ALPHABLENDENABLE
])
3246 arg2
= WINED3DTA_TEXTURE
;
3247 op
= WINED3D_TOP_MODULATE
;
3249 else arg1
= WINED3DTA_TEXTURE
;
3251 else if (op
== WINED3D_TOP_SELECT_ARG2
&& arg2
!= WINED3DTA_TEXTURE
)
3253 if (state
->render_states
[WINED3D_RS_ALPHABLENDENABLE
])
3255 arg1
= WINED3DTA_TEXTURE
;
3256 op
= WINED3D_TOP_MODULATE
;
3258 else arg2
= WINED3DTA_TEXTURE
;
3264 /* tex_alphaop is shared between the ffp and nvrc because the difference only comes down to
3265 * this if block here, and the other code(color keying, texture unit selection) are the same
3267 TRACE("Setting alpha op for stage %d\n", stage
);
3268 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
3270 set_tex_op_nvrc(gl_info
, state
, TRUE
, stage
, op
, arg1
, arg2
, arg0
,
3271 mapped_stage
, state
->texture_states
[stage
][WINED3D_TSS_RESULT_ARG
]);
3275 set_tex_op(gl_info
, state
, TRUE
, stage
, op
, arg1
, arg2
, arg0
);
3279 void transform_texture(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3281 DWORD texUnit
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3282 const struct wined3d_device
*device
= context
->swapchain
->device
;
3283 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3284 DWORD mapped_stage
= context
->tex_unit_map
[texUnit
];
3288 /* Ignore this when a vertex shader is used, or if the streams aren't sorted out yet */
3289 if (use_vs(state
) || isStateDirty(context
, STATE_VDECL
))
3291 TRACE("Using a vertex shader, or stream sources not sorted out yet, skipping\n");
3295 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
) return;
3296 if (mapped_stage
>= gl_info
->limits
.textures
) return;
3298 context_active_texture(context
, gl_info
, mapped_stage
);
3299 generated
= (state
->texture_states
[texUnit
][WINED3D_TSS_TEXCOORD_INDEX
] & 0xffff0000) != WINED3DTSS_TCI_PASSTHRU
;
3300 coordIdx
= min(state
->texture_states
[texUnit
][WINED3D_TSS_TEXCOORD_INDEX
& 0x0000ffff], MAX_TEXTURES
- 1);
3302 set_texture_matrix(gl_info
, &state
->transforms
[WINED3D_TS_TEXTURE0
+ texUnit
].u
.m
[0][0],
3303 state
->texture_states
[texUnit
][WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
],
3304 generated
, context
->last_was_rhw
,
3305 context
->stream_info
.use_map
& (1 << (WINED3D_FFP_TEXCOORD0
+ coordIdx
))
3306 ? context
->stream_info
.elements
[WINED3D_FFP_TEXCOORD0
+ coordIdx
].format
->id
3307 : WINED3DFMT_UNKNOWN
,
3308 device
->shader_backend
->shader_has_ffp_proj_control(device
->shader_priv
));
3310 /* The sampler applying function calls us if this changes */
3311 if ((context
->lastWasPow2Texture
& (1 << texUnit
)) && state
->textures
[texUnit
])
3314 FIXME("Non-power2 texture being used with generated texture coords\n");
3316 /* NP2 texcoord fixup is implemented for pixelshaders so only enable the
3317 fixed-function-pipeline fixup via pow2Matrix when no PS is used. */
3320 TRACE("Non power two matrix multiply fixup\n");
3321 gl_info
->gl_ops
.gl
.p_glMultMatrixf(state
->textures
[texUnit
]->pow2_matrix
);
3326 static void unload_tex_coords(const struct wined3d_gl_info
*gl_info
)
3328 unsigned int texture_idx
;
3330 for (texture_idx
= 0; texture_idx
< gl_info
->limits
.texture_coords
; ++texture_idx
)
3332 GL_EXTCALL(glClientActiveTextureARB(GL_TEXTURE0_ARB
+ texture_idx
));
3333 gl_info
->gl_ops
.gl
.p_glDisableClientState(GL_TEXTURE_COORD_ARRAY
);
3337 static void load_tex_coords(const struct wined3d_context
*context
, const struct wined3d_stream_info
*si
,
3338 GLuint
*curVBO
, const struct wined3d_state
*state
)
3340 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3341 unsigned int mapped_stage
= 0;
3342 unsigned int textureNo
= 0;
3344 for (textureNo
= 0; textureNo
< context
->d3d_info
->limits
.ffp_blend_stages
; ++textureNo
)
3346 int coordIdx
= state
->texture_states
[textureNo
][WINED3D_TSS_TEXCOORD_INDEX
];
3348 mapped_stage
= context
->tex_unit_map
[textureNo
];
3349 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
) continue;
3351 if (mapped_stage
>= gl_info
->limits
.texture_coords
)
3353 FIXME("Attempted to load unsupported texture coordinate %u\n", mapped_stage
);
3357 if (coordIdx
< MAX_TEXTURES
&& (si
->use_map
& (1 << (WINED3D_FFP_TEXCOORD0
+ coordIdx
))))
3359 const struct wined3d_stream_info_element
*e
= &si
->elements
[WINED3D_FFP_TEXCOORD0
+ coordIdx
];
3361 TRACE("Setting up texture %u, idx %d, coordindx %u, data {%#x:%p}.\n",
3362 textureNo
, mapped_stage
, coordIdx
, e
->data
.buffer_object
, e
->data
.addr
);
3364 if (*curVBO
!= e
->data
.buffer_object
)
3366 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER
, e
->data
.buffer_object
));
3367 checkGLcall("glBindBuffer");
3368 *curVBO
= e
->data
.buffer_object
;
3371 GL_EXTCALL(glClientActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
3372 checkGLcall("glClientActiveTextureARB");
3374 /* The coords to supply depend completely on the fvf / vertex shader */
3375 gl_info
->gl_ops
.gl
.p_glTexCoordPointer(e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
3376 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
3377 gl_info
->gl_ops
.gl
.p_glEnableClientState(GL_TEXTURE_COORD_ARRAY
);
3381 GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB
+ mapped_stage
, 0, 0, 0, 1));
3384 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
3386 /* The number of the mapped stages increases monotonically, so it's fine to use the last used one. */
3387 for (textureNo
= mapped_stage
+ 1; textureNo
< gl_info
->limits
.textures
; ++textureNo
)
3389 GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB
+ textureNo
, 0, 0, 0, 1));
3393 checkGLcall("loadTexCoords");
3396 static void tex_coordindex(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3398 DWORD stage
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3399 static const GLfloat s_plane
[] = { 1.0f
, 0.0f
, 0.0f
, 0.0f
};
3400 static const GLfloat t_plane
[] = { 0.0f
, 1.0f
, 0.0f
, 0.0f
};
3401 static const GLfloat r_plane
[] = { 0.0f
, 0.0f
, 1.0f
, 0.0f
};
3402 static const GLfloat q_plane
[] = { 0.0f
, 0.0f
, 0.0f
, 1.0f
};
3403 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3404 DWORD mapped_stage
= context
->tex_unit_map
[stage
];
3406 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
)
3408 TRACE("No texture unit mapped to stage %d. Skipping texture coordinates.\n", stage
);
3412 if (mapped_stage
>= gl_info
->limits
.fragment_samplers
)
3414 WARN("stage %u not mapped to a valid texture unit (%u)\n", stage
, mapped_stage
);
3417 context_active_texture(context
, gl_info
, mapped_stage
);
3419 /* Values 0-7 are indexes into the FVF tex coords - See comments in DrawPrimitive
3421 * FIXME: When using generated texture coordinates, the index value is used to specify the wrapping mode.
3422 * eg. SetTextureStageState( 0, WINED3D_TSS_TEXCOORDINDEX, WINED3D_TSS_TCI_CAMERASPACEPOSITION | 1 );
3423 * means use the vertex position (camera-space) as the input texture coordinates
3424 * for this texture stage, and the wrap mode set in the WINED3D_RS_WRAP1 render
3425 * state. We do not (yet) support the WINED3DRENDERSTATE_WRAPx values, nor tie them up
3426 * to the TEXCOORDINDEX value
3428 switch (state
->texture_states
[stage
][WINED3D_TSS_TEXCOORD_INDEX
] & 0xffff0000)
3430 case WINED3DTSS_TCI_PASSTHRU
:
3431 /* Use the specified texture coordinates contained within the
3432 * vertex format. This value resolves to zero. */
3433 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_S
);
3434 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_T
);
3435 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_R
);
3436 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_Q
);
3437 checkGLcall("WINED3DTSS_TCI_PASSTHRU - Disable texgen.");
3440 case WINED3DTSS_TCI_CAMERASPACEPOSITION
:
3441 /* CameraSpacePosition means use the vertex position, transformed to camera space,
3442 * as the input texture coordinates for this stage's texture transformation. This
3443 * equates roughly to EYE_LINEAR */
3445 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3446 gl_info
->gl_ops
.gl
.p_glPushMatrix();
3447 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
3448 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
3449 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
3450 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
3451 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
3452 gl_info
->gl_ops
.gl
.p_glPopMatrix();
3453 checkGLcall("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set eye plane.");
3455 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
3456 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
3457 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
3458 checkGLcall("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set texgen mode.");
3460 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_S
);
3461 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_T
);
3462 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_R
);
3463 checkGLcall("WINED3DTSS_TCI_CAMERASPACEPOSITION - Enable texgen.");
3467 case WINED3DTSS_TCI_CAMERASPACENORMAL
:
3468 /* Note that NV_TEXGEN_REFLECTION support is implied when
3469 * ARB_TEXTURE_CUBE_MAP is supported */
3470 if (!gl_info
->supported
[NV_TEXGEN_REFLECTION
])
3472 FIXME("WINED3DTSS_TCI_CAMERASPACENORMAL not supported.\n");
3476 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3477 gl_info
->gl_ops
.gl
.p_glPushMatrix();
3478 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
3479 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
3480 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
3481 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
3482 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
3483 gl_info
->gl_ops
.gl
.p_glPopMatrix();
3484 checkGLcall("WINED3DTSS_TCI_CAMERASPACENORMAL - Set eye plane.");
3486 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
3487 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
3488 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
3489 checkGLcall("WINED3DTSS_TCI_CAMERASPACENORMAL - Set texgen mode.");
3491 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_S
);
3492 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_T
);
3493 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_R
);
3494 checkGLcall("WINED3DTSS_TCI_CAMERASPACENORMAL - Enable texgen.");
3498 case WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR
:
3499 /* Note that NV_TEXGEN_REFLECTION support is implied when
3500 * ARB_TEXTURE_CUBE_MAP is supported */
3501 if (!gl_info
->supported
[NV_TEXGEN_REFLECTION
])
3503 FIXME("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR not supported.\n");
3507 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3508 gl_info
->gl_ops
.gl
.p_glPushMatrix();
3509 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
3510 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
3511 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
3512 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
3513 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
3514 gl_info
->gl_ops
.gl
.p_glPopMatrix();
3515 checkGLcall("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Set eye plane.");
3517 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
3518 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
3519 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
3520 checkGLcall("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Set texgen mode.");
3522 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_S
);
3523 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_T
);
3524 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_R
);
3525 checkGLcall("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Enable texgen.");
3529 case WINED3DTSS_TCI_SPHEREMAP
:
3530 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_SPHERE_MAP
);
3531 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_SPHERE_MAP
);
3532 checkGLcall("WINED3DTSS_TCI_SPHEREMAP - Set texgen mode.");
3534 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_S
);
3535 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_T
);
3536 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_R
);
3537 checkGLcall("WINED3DTSS_TCI_SPHEREMAP - Enable texgen.");
3542 FIXME("Unhandled WINED3D_TSS_TEXCOORD_INDEX %#x.\n",
3543 state
->texture_states
[stage
][WINED3D_TSS_TEXCOORD_INDEX
]);
3544 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_S
);
3545 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_T
);
3546 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_R
);
3547 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_Q
);
3548 checkGLcall("Disable texgen.");
3553 /* Update the texture matrix. */
3554 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_TEXTURE0
+ stage
)))
3555 transform_texture(context
, state
, STATE_TEXTURESTAGE(stage
, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
));
3557 if (!isStateDirty(context
, STATE_VDECL
) && context
->namedArraysLoaded
)
3559 /* Reload the arrays if we are using fixed function arrays to reflect the selected coord input
3560 * source. Call loadTexCoords directly because there is no need to reparse the vertex declaration
3561 * and do all the things linked to it
3562 * TODO: Tidy that up to reload only the arrays of the changed unit
3564 GLuint curVBO
= gl_info
->supported
[ARB_VERTEX_BUFFER_OBJECT
] ? ~0U : 0;
3566 unload_tex_coords(gl_info
);
3567 load_tex_coords(context
, &context
->stream_info
, &curVBO
, state
);
3571 void sampler_texmatrix(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3573 const DWORD sampler
= state_id
- STATE_SAMPLER(0);
3574 const struct wined3d_texture
*texture
= state
->textures
[sampler
];
3576 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
3578 if(!texture
) return;
3579 /* The fixed function np2 texture emulation uses the texture matrix to fix up the coordinates
3580 * wined3d_texture_apply_state_changes() multiplies the set matrix with a fixup matrix. Before the
3581 * scaling is reapplied or removed, the texture matrix has to be reapplied
3583 * The mapped stage is already active because the sampler() function below, which is part of the
3586 if (sampler
< MAX_TEXTURES
)
3588 const BOOL texIsPow2
= !(texture
->flags
& WINED3D_TEXTURE_POW2_MAT_IDENT
);
3590 if (texIsPow2
|| (context
->lastWasPow2Texture
& (1 << sampler
)))
3593 context
->lastWasPow2Texture
|= 1 << sampler
;
3595 context
->lastWasPow2Texture
&= ~(1 << sampler
);
3597 transform_texture(context
, state
,
3598 STATE_TEXTURESTAGE(context
->tex_unit_map
[sampler
], WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
));
3603 static enum wined3d_texture_address
wined3d_texture_address_mode(const struct wined3d_texture
*texture
,
3604 enum wined3d_texture_address t
)
3606 if (t
< WINED3D_TADDRESS_WRAP
|| t
> WINED3D_TADDRESS_MIRROR_ONCE
)
3608 FIXME("Unrecognized or unsupported texture address mode %#x.\n", t
);
3609 return WINED3D_TADDRESS_WRAP
;
3612 /* Cubemaps are always set to clamp, regardless of the sampler state. */
3613 if (texture
->target
== GL_TEXTURE_CUBE_MAP_ARB
|| ((texture
->flags
& WINED3D_TEXTURE_COND_NP2
)
3614 && t
== WINED3D_TADDRESS_WRAP
))
3615 return WINED3D_TADDRESS_CLAMP
;
3620 static void wined3d_sampler_desc_from_sampler_states(struct wined3d_sampler_desc
*desc
,
3621 const struct wined3d_gl_info
*gl_info
, const DWORD
*sampler_states
, const struct wined3d_texture
*texture
)
3629 desc
->address_u
= wined3d_texture_address_mode(texture
, sampler_states
[WINED3D_SAMP_ADDRESS_U
]);
3630 desc
->address_v
= wined3d_texture_address_mode(texture
, sampler_states
[WINED3D_SAMP_ADDRESS_V
]);
3631 desc
->address_w
= wined3d_texture_address_mode(texture
, sampler_states
[WINED3D_SAMP_ADDRESS_W
]);
3632 D3DCOLORTOGLFLOAT4(sampler_states
[WINED3D_SAMP_BORDER_COLOR
], desc
->border_color
);
3633 if (sampler_states
[WINED3D_SAMP_MAG_FILTER
] > WINED3D_TEXF_ANISOTROPIC
)
3634 FIXME("Unrecognized or unsupported WINED3D_SAMP_MAG_FILTER %#x.\n",
3635 sampler_states
[WINED3D_SAMP_MAG_FILTER
]);
3636 desc
->mag_filter
= min(max(sampler_states
[WINED3D_SAMP_MAG_FILTER
], WINED3D_TEXF_POINT
), WINED3D_TEXF_LINEAR
);
3637 if (sampler_states
[WINED3D_SAMP_MIN_FILTER
] > WINED3D_TEXF_ANISOTROPIC
)
3638 FIXME("Unrecognized or unsupported WINED3D_SAMP_MIN_FILTER %#x.\n",
3639 sampler_states
[WINED3D_SAMP_MIN_FILTER
]);
3640 desc
->min_filter
= min(max(sampler_states
[WINED3D_SAMP_MIN_FILTER
], WINED3D_TEXF_POINT
), WINED3D_TEXF_LINEAR
);
3641 if (sampler_states
[WINED3D_SAMP_MIP_FILTER
] > WINED3D_TEXF_ANISOTROPIC
)
3642 FIXME("Unrecognized or unsupported WINED3D_SAMP_MIP_FILTER %#x.\n",
3643 sampler_states
[WINED3D_SAMP_MIP_FILTER
]);
3644 desc
->mip_filter
= min(max(sampler_states
[WINED3D_SAMP_MIP_FILTER
], WINED3D_TEXF_NONE
), WINED3D_TEXF_LINEAR
);
3645 lod_bias
.d
= sampler_states
[WINED3D_SAMP_MIPMAP_LOD_BIAS
];
3646 desc
->lod_bias
= lod_bias
.f
;
3647 desc
->min_lod
= -1000.0f
;
3648 desc
->max_lod
= 1000.0f
;
3649 desc
->max_anisotropy
= sampler_states
[WINED3D_SAMP_MAX_ANISOTROPY
];
3650 if ((sampler_states
[WINED3D_SAMP_MAG_FILTER
] != WINED3D_TEXF_ANISOTROPIC
3651 && sampler_states
[WINED3D_SAMP_MIN_FILTER
] != WINED3D_TEXF_ANISOTROPIC
3652 && sampler_states
[WINED3D_SAMP_MIP_FILTER
] != WINED3D_TEXF_ANISOTROPIC
)
3653 || (texture
->flags
& WINED3D_TEXTURE_COND_NP2
))
3654 desc
->max_anisotropy
= 1;
3655 desc
->compare
= texture
->resource
.format
->flags
& WINED3DFMT_FLAG_SHADOW
;
3656 desc
->comparison_func
= WINED3D_CMP_LESSEQUAL
;
3657 desc
->srgb_decode
= sampler_states
[WINED3D_SAMP_SRGB_TEXTURE
];
3659 if (!(texture
->resource
.format
->flags
& WINED3DFMT_FLAG_FILTERING
))
3661 desc
->mag_filter
= WINED3D_TEXF_POINT
;
3662 desc
->min_filter
= WINED3D_TEXF_POINT
;
3663 desc
->mip_filter
= WINED3D_TEXF_NONE
;
3666 if (texture
->flags
& WINED3D_TEXTURE_COND_NP2
)
3668 desc
->mip_filter
= WINED3D_TEXF_NONE
;
3669 if (gl_info
->supported
[WINED3D_GL_NORMALIZED_TEXRECT
])
3670 desc
->min_filter
= WINED3D_TEXF_POINT
;
3674 /* Enabling and disabling texture dimensions is done by texture stage state /
3675 * pixel shader setup, this function only has to bind textures and set the per
3676 * texture states. */
3677 static void sampler(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3679 DWORD sampler_idx
= state_id
- STATE_SAMPLER(0);
3680 DWORD mapped_stage
= context
->tex_unit_map
[sampler_idx
];
3681 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3683 TRACE("Sampler %u.\n", sampler_idx
);
3686 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
)
3688 TRACE("No sampler mapped to stage %u. Returning.\n", sampler_idx
);
3692 if (mapped_stage
>= gl_info
->limits
.combined_samplers
)
3696 context_active_texture(context
, gl_info
, mapped_stage
);
3698 if (state
->textures
[sampler_idx
])
3700 struct wined3d_texture
*texture
= state
->textures
[sampler_idx
];
3701 BOOL srgb
= state
->sampler_states
[sampler_idx
][WINED3D_SAMP_SRGB_TEXTURE
];
3702 const DWORD
*sampler_states
= state
->sampler_states
[sampler_idx
];
3703 struct wined3d_sampler_desc desc
;
3704 struct gl_texture
*gl_tex
;
3705 unsigned int base_level
;
3707 wined3d_sampler_desc_from_sampler_states(&desc
, gl_info
, sampler_states
, texture
);
3709 wined3d_texture_bind(texture
, context
, srgb
);
3710 if (!gl_info
->supported
[ARB_SAMPLER_OBJECTS
])
3712 wined3d_texture_apply_sampler_desc(texture
, &desc
, gl_info
);
3716 struct wined3d_device
*device
= context
->swapchain
->device
;
3717 struct wined3d_sampler
*sampler
;
3718 struct wine_rb_entry
*entry
;
3720 if ((entry
= wine_rb_get(&device
->samplers
, &desc
)))
3722 sampler
= WINE_RB_ENTRY_VALUE(entry
, struct wined3d_sampler
, entry
);
3726 if (FAILED(wined3d_sampler_create(device
, &desc
, NULL
, &sampler
)))
3728 ERR("Failed to create sampler.\n");
3733 if (wine_rb_put(&device
->samplers
, &desc
, &sampler
->entry
) == -1)
3734 ERR("Failed to insert sampler.\n");
3740 GL_EXTCALL(glBindSampler(sampler_idx
, sampler
->name
));
3741 checkGLcall("glBindSampler");
3745 if (texture
->flags
& WINED3D_TEXTURE_COND_NP2
)
3747 else if (desc
.mip_filter
== WINED3D_TEXF_NONE
)
3748 base_level
= texture
->lod
;
3750 base_level
= min(max(sampler_states
[WINED3D_SAMP_MAX_MIP_LEVEL
],
3751 texture
->lod
), texture
->level_count
- 1);
3753 gl_tex
= wined3d_texture_get_gl_texture(texture
, texture
->flags
& WINED3D_TEXTURE_IS_SRGB
);
3754 if (base_level
!= gl_tex
->base_level
)
3756 /* Note that WINED3D_SAMP_MAX_MIP_LEVEL specifies the largest mipmap
3757 * (default 0), while GL_TEXTURE_MAX_LEVEL specifies the smallest
3758 * mimap used (default 1000). So WINED3D_SAMP_MAX_MIP_LEVEL
3759 * corresponds to GL_TEXTURE_BASE_LEVEL. */
3760 gl_info
->gl_ops
.gl
.p_glTexParameteri(texture
->target
, GL_TEXTURE_BASE_LEVEL
, base_level
);
3761 gl_tex
->base_level
= base_level
;
3764 if (!use_ps(state
) && sampler_idx
< context
->lowest_disabled_stage
)
3766 if (state
->render_states
[WINED3D_RS_COLORKEYENABLE
] && !sampler_idx
)
3768 /* If color keying is enabled update the alpha test, it
3769 * depends on the existence of a color key in stage 0. */
3770 state_alpha(context
, state
, WINED3D_RS_COLORKEYENABLE
);
3774 /* Trigger shader constant reloading (for NP2 texcoord fixup) */
3775 if (!(texture
->flags
& WINED3D_TEXTURE_POW2_MAT_IDENT
))
3776 context
->constant_update_mask
|= WINED3D_SHADER_CONST_PS_NP2_FIXUP
;
3780 if (sampler_idx
< context
->lowest_disabled_stage
)
3782 /* TODO: What should I do with pixel shaders here ??? */
3783 if (state
->render_states
[WINED3D_RS_COLORKEYENABLE
] && !sampler_idx
)
3785 /* If color keying is enabled update the alpha test, it
3786 * depends on the existence of a color key in stage 0. */
3787 state_alpha(context
, state
, WINED3D_RS_COLORKEYENABLE
);
3789 } /* Otherwise tex_colorop disables the stage */
3790 context_bind_texture(context
, GL_NONE
, 0);
3794 void apply_pixelshader(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3800 if (!context
->last_was_pshader
)
3802 /* Former draw without a pixel shader, some samplers may be
3803 * disabled because of WINED3D_TSS_COLOR_OP = WINED3DTOP_DISABLE
3804 * make sure to enable them. */
3805 for (i
= 0; i
< MAX_FRAGMENT_SAMPLERS
; ++i
)
3807 if (!isStateDirty(context
, STATE_SAMPLER(i
)))
3808 sampler(context
, state
, STATE_SAMPLER(i
));
3810 context
->last_was_pshader
= TRUE
;
3814 /* Otherwise all samplers were activated by the code above in
3815 * earlier draws, or by sampler() if a different texture was
3816 * bound. I don't have to do anything. */
3821 /* Disabled the pixel shader - color ops weren't applied while it was
3822 * enabled, so re-apply them. */
3823 for (i
= 0; i
< context
->d3d_info
->limits
.ffp_blend_stages
; ++i
)
3825 if (!isStateDirty(context
, STATE_TEXTURESTAGE(i
, WINED3D_TSS_COLOR_OP
)))
3826 context_apply_state(context
, state
, STATE_TEXTURESTAGE(i
, WINED3D_TSS_COLOR_OP
));
3828 context
->last_was_pshader
= FALSE
;
3831 context
->shader_update_mask
|= 1 << WINED3D_SHADER_TYPE_PIXEL
;
3834 static void state_geometry_shader(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3836 context
->shader_update_mask
|= 1 << WINED3D_SHADER_TYPE_GEOMETRY
;
3839 static void shader_bumpenv(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3841 context
->constant_update_mask
|= WINED3D_SHADER_CONST_PS_BUMP_ENV
;
3844 void transform_world(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3846 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3848 /* This function is called by transform_view below if the view matrix was changed too
3850 * Deliberately no check if the vertex declaration is dirty because the vdecl state
3851 * does not always update the world matrix, only on a switch between transformed
3852 * and untransformed draws. It *may* happen that the world matrix is set 2 times during one
3853 * draw, but that should be rather rare and cheaper in total.
3855 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3856 checkGLcall("glMatrixMode");
3858 if (context
->last_was_rhw
)
3860 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
3861 checkGLcall("glLoadIdentity()");
3865 gl_info
->gl_ops
.gl
.p_glLoadMatrixf(&state
->transforms
[WINED3D_TS_VIEW
].u
.m
[0][0]);
3866 checkGLcall("glLoadMatrixf");
3867 gl_info
->gl_ops
.gl
.p_glMultMatrixf(&state
->transforms
[WINED3D_TS_WORLD_MATRIX(0)].u
.m
[0][0]);
3868 checkGLcall("glMultMatrixf");
3872 void clipplane(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3874 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3875 UINT index
= state_id
- STATE_CLIPPLANE(0);
3878 if (isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_VIEW
)) || index
>= gl_info
->limits
.clipplanes
)
3881 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3882 gl_info
->gl_ops
.gl
.p_glPushMatrix();
3884 /* Clip Plane settings are affected by the model view in OpenGL, the View transform in direct3d */
3886 gl_info
->gl_ops
.gl
.p_glLoadMatrixf(&state
->transforms
[WINED3D_TS_VIEW
].u
.m
[0][0]);
3888 /* With vertex shaders, clip planes are not transformed in Direct3D,
3889 * while in OpenGL they are still transformed by the model view matix. */
3890 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
3892 plane
[0] = state
->clip_planes
[index
].x
;
3893 plane
[1] = state
->clip_planes
[index
].y
;
3894 plane
[2] = state
->clip_planes
[index
].z
;
3895 plane
[3] = state
->clip_planes
[index
].w
;
3897 TRACE("Clipplane [%.8e, %.8e, %.8e, %.8e]\n",
3898 plane
[0], plane
[1], plane
[2], plane
[3]);
3899 gl_info
->gl_ops
.gl
.p_glClipPlane(GL_CLIP_PLANE0
+ index
, plane
);
3900 checkGLcall("glClipPlane");
3902 gl_info
->gl_ops
.gl
.p_glPopMatrix();
3905 static void transform_worldex(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3907 UINT matrix
= state_id
- STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0));
3908 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3911 TRACE("Setting world matrix %d\n", matrix
);
3913 if (matrix
>= gl_info
->limits
.blends
)
3915 WARN("Unsupported blend matrix set\n");
3919 if (isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_VIEW
)))
3922 /* GL_MODELVIEW0_ARB: 0x1700
3923 * GL_MODELVIEW1_ARB: 0x850a
3924 * GL_MODELVIEW2_ARB: 0x8722
3925 * GL_MODELVIEW3_ARB: 0x8723
3927 * GL_MODELVIEW31_ARB: 0x873f
3929 if(matrix
== 1) glMat
= GL_MODELVIEW1_ARB
;
3930 else glMat
= GL_MODELVIEW2_ARB
- 2 + matrix
;
3932 gl_info
->gl_ops
.gl
.p_glMatrixMode(glMat
);
3933 checkGLcall("glMatrixMode(glMat)");
3935 /* World matrix 0 is multiplied with the view matrix because d3d uses 3
3936 * matrices while gl uses only 2. To avoid weighting the view matrix
3937 * incorrectly it has to be multiplied into every GL modelview matrix. */
3938 gl_info
->gl_ops
.gl
.p_glLoadMatrixf(&state
->transforms
[WINED3D_TS_VIEW
].u
.m
[0][0]);
3939 checkGLcall("glLoadMatrixf");
3940 gl_info
->gl_ops
.gl
.p_glMultMatrixf(&state
->transforms
[WINED3D_TS_WORLD_MATRIX(matrix
)].u
.m
[0][0]);
3941 checkGLcall("glMultMatrixf");
3944 static void state_vertexblend_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3946 enum wined3d_vertex_blend_flags f
= state
->render_states
[WINED3D_RS_VERTEXBLEND
];
3947 static unsigned int once
;
3949 if (f
== WINED3D_VBF_DISABLE
)
3952 if (!once
++) FIXME("Vertex blend flags %#x not supported.\n", f
);
3953 else WARN("Vertex blend flags %#x not supported.\n", f
);
3956 static void state_vertexblend(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3958 enum wined3d_vertex_blend_flags val
= state
->render_states
[WINED3D_RS_VERTEXBLEND
];
3959 struct wined3d_device
*device
= context
->swapchain
->device
;
3960 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3961 static unsigned int once
;
3965 case WINED3D_VBF_1WEIGHTS
:
3966 case WINED3D_VBF_2WEIGHTS
:
3967 case WINED3D_VBF_3WEIGHTS
:
3968 gl_info
->gl_ops
.gl
.p_glEnable(GL_VERTEX_BLEND_ARB
);
3969 checkGLcall("glEnable(GL_VERTEX_BLEND_ARB)");
3971 /* D3D adds one more matrix which has weight (1 - sum(weights)).
3972 * This is enabled at context creation with enabling
3973 * GL_WEIGHT_SUM_UNITY_ARB. */
3974 GL_EXTCALL(glVertexBlendARB(state
->render_states
[WINED3D_RS_VERTEXBLEND
] + 1));
3976 if (!device
->vertexBlendUsed
)
3979 for (i
= 1; i
< gl_info
->limits
.blends
; ++i
)
3981 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(i
))))
3982 transform_worldex(context
, state
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(i
)));
3984 device
->vertexBlendUsed
= TRUE
;
3988 case WINED3D_VBF_TWEENING
:
3989 case WINED3D_VBF_0WEIGHTS
: /* Indexed vertex blending, not supported. */
3990 if (!once
++) FIXME("Vertex blend flags %#x not supported.\n", val
);
3991 else WARN("Vertex blend flags %#x not supported.\n", val
);
3993 case WINED3D_VBF_DISABLE
:
3994 gl_info
->gl_ops
.gl
.p_glDisable(GL_VERTEX_BLEND_ARB
);
3995 checkGLcall("glDisable(GL_VERTEX_BLEND_ARB)");
4000 void transform_view(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4002 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4003 const struct wined3d_light_info
*light
= NULL
;
4006 /* If we are changing the View matrix, reset the light and clipping planes to the new view
4007 * NOTE: We have to reset the positions even if the light/plane is not currently
4008 * enabled, since the call to enable it will not reset the position.
4009 * NOTE2: Apparently texture transforms do NOT need reapplying
4012 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
4013 checkGLcall("glMatrixMode(GL_MODELVIEW)");
4014 gl_info
->gl_ops
.gl
.p_glLoadMatrixf(&state
->transforms
[WINED3D_TS_VIEW
].u
.m
[0][0]);
4015 checkGLcall("glLoadMatrixf(...)");
4017 /* Reset lights. TODO: Call light apply func */
4018 for (k
= 0; k
< gl_info
->limits
.lights
; ++k
)
4020 if (!(light
= state
->lights
[k
]))
4022 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ light
->glIndex
, GL_POSITION
, light
->lightPosn
);
4023 checkGLcall("glLightfv posn");
4024 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ light
->glIndex
, GL_SPOT_DIRECTION
, light
->lightDirn
);
4025 checkGLcall("glLightfv dirn");
4028 /* Reset Clipping Planes */
4029 for (k
= 0; k
< gl_info
->limits
.clipplanes
; ++k
)
4031 if (!isStateDirty(context
, STATE_CLIPPLANE(k
)))
4032 clipplane(context
, state
, STATE_CLIPPLANE(k
));
4035 if (context
->last_was_rhw
)
4037 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
4038 checkGLcall("glLoadIdentity()");
4039 /* No need to update the world matrix, the identity is fine */
4043 /* Call the world matrix state, this will apply the combined WORLD + VIEW matrix
4044 * No need to do it here if the state is scheduled for update. */
4045 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0))))
4046 transform_world(context
, state
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0)));
4048 /* Avoid looping over a number of matrices if the app never used the functionality */
4049 if (context
->swapchain
->device
->vertexBlendUsed
)
4051 for (k
= 1; k
< gl_info
->limits
.blends
; ++k
)
4053 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(k
))))
4054 transform_worldex(context
, state
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(k
)));
4059 void transform_projection(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4061 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4063 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_PROJECTION
);
4064 checkGLcall("glMatrixMode(GL_PROJECTION)");
4066 /* There are a couple of additional things we have to take into account
4067 * here besides the projection transformation itself:
4068 * - We need to flip along the y-axis in case of offscreen rendering.
4069 * - OpenGL Z range is {-Wc,...,Wc} while D3D Z range is {0,...,Wc}.
4070 * - D3D coordinates refer to pixel centers while GL coordinates refer
4072 * - D3D has a top-left filling convention. We need to maintain this
4073 * even after the y-flip mentioned above.
4074 * In order to handle the last two points, we translate by
4075 * (63.0 / 128.0) / VPw and (63.0 / 128.0) / VPh. This is equivalent to
4076 * translating slightly less than half a pixel. We want the difference to
4077 * be large enough that it doesn't get lost due to rounding inside the
4078 * driver, but small enough to prevent it from interfering with any
4081 if (context
->last_was_rhw
)
4083 /* Transform D3D RHW coordinates to OpenGL clip coordinates. */
4084 double x
= state
->viewport
.x
;
4085 double y
= state
->viewport
.y
;
4086 double w
= state
->viewport
.width
;
4087 double h
= state
->viewport
.height
;
4088 double x_scale
= 2.0 / w
;
4089 double x_offset
= ((63.0 / 64.0) - (2.0 * x
) - w
) / w
;
4090 double y_scale
= context
->render_offscreen
? 2.0 / h
: 2.0 / -h
;
4091 double y_offset
= context
->render_offscreen
4092 ? ((63.0 / 64.0) - (2.0 * y
) - h
) / h
4093 : ((63.0 / 64.0) - (2.0 * y
) - h
) / -h
;
4094 enum wined3d_depth_buffer_type zenable
= state
->fb
->depth_stencil
?
4095 state
->render_states
[WINED3D_RS_ZENABLE
] : WINED3D_ZB_FALSE
;
4096 double z_scale
= zenable
? 2.0f
: 0.0f
;
4097 double z_offset
= zenable
? -1.0f
: 0.0f
;
4098 const GLdouble projection
[] =
4100 x_scale
, 0.0, 0.0, 0.0,
4101 0.0, y_scale
, 0.0, 0.0,
4102 0.0, 0.0, z_scale
, 0.0,
4103 x_offset
, y_offset
, z_offset
, 1.0,
4106 gl_info
->gl_ops
.gl
.p_glLoadMatrixd(projection
);
4107 checkGLcall("glLoadMatrixd");
4111 double y_scale
= context
->render_offscreen
? -1.0 : 1.0;
4112 double x_offset
= (63.0 / 64.0) / state
->viewport
.width
;
4113 double y_offset
= context
->render_offscreen
4114 ? (63.0 / 64.0) / state
->viewport
.height
4115 : -(63.0 / 64.0) / state
->viewport
.height
;
4116 const GLdouble projection
[] =
4119 0.0, y_scale
, 0.0, 0.0,
4121 x_offset
, y_offset
, -1.0, 1.0,
4124 gl_info
->gl_ops
.gl
.p_glLoadMatrixd(projection
);
4125 checkGLcall("glLoadMatrixd");
4127 gl_info
->gl_ops
.gl
.p_glMultMatrixf(&state
->transforms
[WINED3D_TS_PROJECTION
].u
.m
[0][0]);
4128 checkGLcall("glLoadMatrixf");
4132 /* This should match any arrays loaded in load_vertex_data.
4133 * TODO: Only load / unload arrays if we have to. */
4134 static void unload_vertex_data(const struct wined3d_gl_info
*gl_info
)
4136 gl_info
->gl_ops
.gl
.p_glDisableClientState(GL_VERTEX_ARRAY
);
4137 gl_info
->gl_ops
.gl
.p_glDisableClientState(GL_NORMAL_ARRAY
);
4138 gl_info
->gl_ops
.gl
.p_glDisableClientState(GL_COLOR_ARRAY
);
4139 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
4140 gl_info
->gl_ops
.gl
.p_glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT
);
4141 if (gl_info
->supported
[ARB_VERTEX_BLEND
])
4142 gl_info
->gl_ops
.gl
.p_glDisableClientState(GL_WEIGHT_ARRAY_ARB
);
4143 unload_tex_coords(gl_info
);
4146 static inline void unload_numbered_array(struct wined3d_context
*context
, int i
)
4148 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4150 GL_EXTCALL(glDisableVertexAttribArray(i
));
4151 checkGLcall("glDisableVertexAttribArray");
4152 if (gl_info
->supported
[ARB_INSTANCED_ARRAYS
])
4153 GL_EXTCALL(glVertexAttribDivisor(i
, 0));
4155 context
->numbered_array_mask
&= ~(1 << i
);
4158 /* This should match any arrays loaded in loadNumberedArrays
4159 * TODO: Only load / unload arrays if we have to. */
4160 static void unload_numbered_arrays(struct wined3d_context
*context
)
4162 /* disable any attribs (this is the same for both GLSL and ARB modes) */
4165 for (i
= 0; i
< context
->gl_info
->limits
.vertex_attribs
; ++i
) {
4166 unload_numbered_array(context
, i
);
4170 static void load_numbered_arrays(struct wined3d_context
*context
,
4171 const struct wined3d_stream_info
*stream_info
, const struct wined3d_state
*state
)
4173 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4174 GLuint curVBO
= gl_info
->supported
[ARB_VERTEX_BUFFER_OBJECT
] ? ~0U : 0;
4177 /* Default to no instancing */
4178 context
->instance_count
= 0;
4180 for (i
= 0; i
< MAX_ATTRIBS
; i
++)
4182 const struct wined3d_stream_state
*stream
;
4184 if (!(stream_info
->use_map
& (1 << i
)))
4186 if (context
->numbered_array_mask
& (1 << i
))
4187 unload_numbered_array(context
, i
);
4188 if (state
->shader
[WINED3D_SHADER_TYPE_VERTEX
]->reg_maps
.input_registers
& (1 << i
))
4189 GL_EXTCALL(glVertexAttrib4f(i
, 0.0f
, 0.0f
, 0.0f
, 0.0f
));
4193 stream
= &state
->streams
[stream_info
->elements
[i
].stream_idx
];
4195 if (stream
->flags
& WINED3DSTREAMSOURCE_INSTANCEDATA
)
4197 if (!context
->instance_count
)
4198 context
->instance_count
= state
->streams
[0].frequency
? state
->streams
[0].frequency
: 1;
4200 if (!gl_info
->supported
[ARB_INSTANCED_ARRAYS
])
4202 /* Unload instanced arrays, they will be loaded using
4203 * immediate mode instead. */
4204 if (context
->numbered_array_mask
& (1 << i
))
4205 unload_numbered_array(context
, i
);
4209 GL_EXTCALL(glVertexAttribDivisor(i
, 1));
4211 else if (gl_info
->supported
[ARB_INSTANCED_ARRAYS
])
4213 GL_EXTCALL(glVertexAttribDivisor(i
, 0));
4216 TRACE_(d3d_shader
)("Loading array %u [VBO=%u]\n", i
, stream_info
->elements
[i
].data
.buffer_object
);
4218 if (stream_info
->elements
[i
].stride
)
4220 if (curVBO
!= stream_info
->elements
[i
].data
.buffer_object
)
4222 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER
, stream_info
->elements
[i
].data
.buffer_object
));
4223 checkGLcall("glBindBuffer");
4224 curVBO
= stream_info
->elements
[i
].data
.buffer_object
;
4226 /* Use the VBO to find out if a vertex buffer exists, not the vb
4227 * pointer. vb can point to a user pointer data blob. In that case
4228 * curVBO will be 0. If there is a vertex buffer but no vbo we
4229 * won't be load converted attributes anyway. */
4230 GL_EXTCALL(glVertexAttribPointer(i
, stream_info
->elements
[i
].format
->gl_vtx_format
,
4231 stream_info
->elements
[i
].format
->gl_vtx_type
,
4232 stream_info
->elements
[i
].format
->gl_normalized
,
4233 stream_info
->elements
[i
].stride
, stream_info
->elements
[i
].data
.addr
4234 + state
->load_base_vertex_index
* stream_info
->elements
[i
].stride
));
4236 if (!(context
->numbered_array_mask
& (1 << i
)))
4238 GL_EXTCALL(glEnableVertexAttribArray(i
));
4239 context
->numbered_array_mask
|= (1 << i
);
4244 /* Stride = 0 means always the same values.
4245 * glVertexAttribPointer doesn't do that. Instead disable the
4246 * pointer and set up the attribute statically. But we have to
4247 * figure out the system memory address. */
4248 const BYTE
*ptr
= stream_info
->elements
[i
].data
.addr
;
4249 if (stream_info
->elements
[i
].data
.buffer_object
)
4251 ptr
+= (ULONG_PTR
)buffer_get_sysmem(stream
->buffer
, context
);
4254 if (context
->numbered_array_mask
& (1 << i
)) unload_numbered_array(context
, i
);
4256 switch (stream_info
->elements
[i
].format
->id
)
4258 case WINED3DFMT_R32_FLOAT
:
4259 GL_EXTCALL(glVertexAttrib1fv(i
, (const GLfloat
*)ptr
));
4261 case WINED3DFMT_R32G32_FLOAT
:
4262 GL_EXTCALL(glVertexAttrib2fv(i
, (const GLfloat
*)ptr
));
4264 case WINED3DFMT_R32G32B32_FLOAT
:
4265 GL_EXTCALL(glVertexAttrib3fv(i
, (const GLfloat
*)ptr
));
4267 case WINED3DFMT_R32G32B32A32_FLOAT
:
4268 GL_EXTCALL(glVertexAttrib4fv(i
, (const GLfloat
*)ptr
));
4271 case WINED3DFMT_R8G8B8A8_UINT
:
4272 GL_EXTCALL(glVertexAttrib4ubv(i
, ptr
));
4274 case WINED3DFMT_B8G8R8A8_UNORM
:
4275 if (gl_info
->supported
[ARB_VERTEX_ARRAY_BGRA
])
4277 const DWORD
*src
= (const DWORD
*)ptr
;
4278 DWORD c
= *src
& 0xff00ff00;
4279 c
|= (*src
& 0xff0000) >> 16;
4280 c
|= (*src
& 0xff) << 16;
4281 GL_EXTCALL(glVertexAttrib4Nubv(i
, (GLubyte
*)&c
));
4284 /* else fallthrough */
4285 case WINED3DFMT_R8G8B8A8_UNORM
:
4286 GL_EXTCALL(glVertexAttrib4Nubv(i
, ptr
));
4289 case WINED3DFMT_R16G16_SINT
:
4290 GL_EXTCALL(glVertexAttrib2sv(i
, (const GLshort
*)ptr
));
4292 case WINED3DFMT_R16G16B16A16_SINT
:
4293 GL_EXTCALL(glVertexAttrib4sv(i
, (const GLshort
*)ptr
));
4296 case WINED3DFMT_R16G16_SNORM
:
4298 const GLshort s
[4] = {((const GLshort
*)ptr
)[0], ((const GLshort
*)ptr
)[1], 0, 1};
4299 GL_EXTCALL(glVertexAttrib4Nsv(i
, s
));
4302 case WINED3DFMT_R16G16_UNORM
:
4304 const GLushort s
[4] = {((const GLushort
*)ptr
)[0], ((const GLushort
*)ptr
)[1], 0, 1};
4305 GL_EXTCALL(glVertexAttrib4Nusv(i
, s
));
4308 case WINED3DFMT_R16G16B16A16_SNORM
:
4309 GL_EXTCALL(glVertexAttrib4Nsv(i
, (const GLshort
*)ptr
));
4311 case WINED3DFMT_R16G16B16A16_UNORM
:
4312 GL_EXTCALL(glVertexAttrib4Nusv(i
, (const GLushort
*)ptr
));
4315 case WINED3DFMT_R10G10B10A2_UINT
:
4316 FIXME("Unsure about WINED3DDECLTYPE_UDEC3\n");
4317 /*glVertexAttrib3usvARB(i, (const GLushort *)ptr); Does not exist */
4319 case WINED3DFMT_R10G10B10A2_SNORM
:
4320 FIXME("Unsure about WINED3DDECLTYPE_DEC3N\n");
4321 /*glVertexAttrib3NusvARB(i, (const GLushort *)ptr); Does not exist */
4324 case WINED3DFMT_R16G16_FLOAT
:
4325 if (gl_info
->supported
[NV_HALF_FLOAT
] && gl_info
->supported
[NV_VERTEX_PROGRAM
])
4327 /* Not supported by GL_ARB_half_float_vertex. */
4328 GL_EXTCALL(glVertexAttrib2hvNV(i
, (const GLhalfNV
*)ptr
));
4332 float x
= float_16_to_32(((const unsigned short *)ptr
) + 0);
4333 float y
= float_16_to_32(((const unsigned short *)ptr
) + 1);
4334 GL_EXTCALL(glVertexAttrib2f(i
, x
, y
));
4337 case WINED3DFMT_R16G16B16A16_FLOAT
:
4338 if (gl_info
->supported
[NV_HALF_FLOAT
] && gl_info
->supported
[NV_VERTEX_PROGRAM
])
4340 /* Not supported by GL_ARB_half_float_vertex. */
4341 GL_EXTCALL(glVertexAttrib4hvNV(i
, (const GLhalfNV
*)ptr
));
4345 float x
= float_16_to_32(((const unsigned short *)ptr
) + 0);
4346 float y
= float_16_to_32(((const unsigned short *)ptr
) + 1);
4347 float z
= float_16_to_32(((const unsigned short *)ptr
) + 2);
4348 float w
= float_16_to_32(((const unsigned short *)ptr
) + 3);
4349 GL_EXTCALL(glVertexAttrib4f(i
, x
, y
, z
, w
));
4354 ERR("Unexpected declaration in stride 0 attributes\n");
4360 checkGLcall("Loading numbered arrays");
4363 static void load_vertex_data(struct wined3d_context
*context
,
4364 const struct wined3d_stream_info
*si
, const struct wined3d_state
*state
)
4366 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4367 GLuint curVBO
= gl_info
->supported
[ARB_VERTEX_BUFFER_OBJECT
] ? ~0U : 0;
4368 const struct wined3d_stream_info_element
*e
;
4370 TRACE("Using fast vertex array code\n");
4372 /* This is fixed function pipeline only, and the fixed function pipeline doesn't do instancing */
4373 context
->instance_count
= 0;
4375 /* Blend Data ---------------------------------------------- */
4376 if ((si
->use_map
& (1 << WINED3D_FFP_BLENDWEIGHT
))
4377 || si
->use_map
& (1 << WINED3D_FFP_BLENDINDICES
))
4379 e
= &si
->elements
[WINED3D_FFP_BLENDWEIGHT
];
4381 if (gl_info
->supported
[ARB_VERTEX_BLEND
])
4383 TRACE("Blend %u %p %u\n", e
->format
->component_count
,
4384 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
, e
->stride
);
4386 gl_info
->gl_ops
.gl
.p_glEnableClientState(GL_WEIGHT_ARRAY_ARB
);
4387 checkGLcall("glEnableClientState(GL_WEIGHT_ARRAY_ARB)");
4389 GL_EXTCALL(glVertexBlendARB(e
->format
->component_count
+ 1));
4391 if (curVBO
!= e
->data
.buffer_object
)
4393 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER
, e
->data
.buffer_object
));
4394 checkGLcall("glBindBuffer");
4395 curVBO
= e
->data
.buffer_object
;
4398 TRACE("glWeightPointerARB(%#x, %#x, %#x, %p);\n",
4399 e
->format
->gl_vtx_format
,
4400 e
->format
->gl_vtx_type
,
4402 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4403 GL_EXTCALL(glWeightPointerARB(e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
4404 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
));
4406 checkGLcall("glWeightPointerARB");
4408 if (si
->use_map
& (1 << WINED3D_FFP_BLENDINDICES
))
4413 FIXME("blendMatrixIndices support\n");
4418 /* TODO: support blends in drawStridedSlow
4419 * No need to write a FIXME here, this is done after the general vertex decl decoding
4421 WARN("unsupported blending in openGl\n");
4426 if (gl_info
->supported
[ARB_VERTEX_BLEND
])
4428 static const GLbyte one
= 1;
4429 GL_EXTCALL(glWeightbvARB(1, &one
));
4430 checkGLcall("glWeightbvARB(gl_info->max_blends, weights)");
4434 /* Point Size ----------------------------------------------*/
4435 if (si
->use_map
& (1 << WINED3D_FFP_PSIZE
))
4437 /* no such functionality in the fixed function GL pipeline */
4438 TRACE("Cannot change ptSize here in openGl\n");
4439 /* TODO: Implement this function in using shaders if they are available */
4442 /* Vertex Pointers -----------------------------------------*/
4443 if (si
->use_map
& (1 << WINED3D_FFP_POSITION
))
4445 e
= &si
->elements
[WINED3D_FFP_POSITION
];
4447 if (curVBO
!= e
->data
.buffer_object
)
4449 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER
, e
->data
.buffer_object
));
4450 checkGLcall("glBindBuffer");
4451 curVBO
= e
->data
.buffer_object
;
4454 TRACE("glVertexPointer(%#x, %#x, %#x, %p);\n",
4455 e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
4456 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4457 gl_info
->gl_ops
.gl
.p_glVertexPointer(e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
4458 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4459 checkGLcall("glVertexPointer(...)");
4460 gl_info
->gl_ops
.gl
.p_glEnableClientState(GL_VERTEX_ARRAY
);
4461 checkGLcall("glEnableClientState(GL_VERTEX_ARRAY)");
4464 /* Normals -------------------------------------------------*/
4465 if (si
->use_map
& (1 << WINED3D_FFP_NORMAL
))
4467 e
= &si
->elements
[WINED3D_FFP_NORMAL
];
4469 if (curVBO
!= e
->data
.buffer_object
)
4471 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER
, e
->data
.buffer_object
));
4472 checkGLcall("glBindBuffer");
4473 curVBO
= e
->data
.buffer_object
;
4476 TRACE("glNormalPointer(%#x, %#x, %p);\n", e
->format
->gl_vtx_type
, e
->stride
,
4477 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4478 gl_info
->gl_ops
.gl
.p_glNormalPointer(e
->format
->gl_vtx_type
, e
->stride
,
4479 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4480 checkGLcall("glNormalPointer(...)");
4481 gl_info
->gl_ops
.gl
.p_glEnableClientState(GL_NORMAL_ARRAY
);
4482 checkGLcall("glEnableClientState(GL_NORMAL_ARRAY)");
4487 gl_info
->gl_ops
.gl
.p_glNormal3f(0, 0, 0);
4488 checkGLcall("glNormal3f(0, 0, 0)");
4491 /* Diffuse Colour --------------------------------------------*/
4492 if (si
->use_map
& (1 << WINED3D_FFP_DIFFUSE
))
4494 e
= &si
->elements
[WINED3D_FFP_DIFFUSE
];
4496 if (curVBO
!= e
->data
.buffer_object
)
4498 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER
, e
->data
.buffer_object
));
4499 checkGLcall("glBindBuffer");
4500 curVBO
= e
->data
.buffer_object
;
4503 TRACE("glColorPointer(%#x, %#x %#x, %p);\n",
4504 e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
4505 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4506 gl_info
->gl_ops
.gl
.p_glColorPointer(e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
4507 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4508 checkGLcall("glColorPointer(4, GL_UNSIGNED_BYTE, ...)");
4509 gl_info
->gl_ops
.gl
.p_glEnableClientState(GL_COLOR_ARRAY
);
4510 checkGLcall("glEnableClientState(GL_COLOR_ARRAY)");
4515 gl_info
->gl_ops
.gl
.p_glColor4f(1.0f
, 1.0f
, 1.0f
, 1.0f
);
4516 checkGLcall("glColor4f(1, 1, 1, 1)");
4519 /* Specular Colour ------------------------------------------*/
4520 if (si
->use_map
& (1 << WINED3D_FFP_SPECULAR
))
4522 TRACE("setting specular colour\n");
4524 e
= &si
->elements
[WINED3D_FFP_SPECULAR
];
4526 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
4528 GLenum type
= e
->format
->gl_vtx_type
;
4529 GLint format
= e
->format
->gl_vtx_format
;
4531 if (curVBO
!= e
->data
.buffer_object
)
4533 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER
, e
->data
.buffer_object
));
4534 checkGLcall("glBindBuffer");
4535 curVBO
= e
->data
.buffer_object
;
4538 if (format
!= 4 || (gl_info
->quirks
& WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA
))
4540 /* Usually specular colors only allow 3 components, since they have no alpha. In D3D, the specular alpha
4541 * contains the fog coordinate, which is passed to GL with GL_EXT_fog_coord. However, the fixed function
4542 * vertex pipeline can pass the specular alpha through, and pixel shaders can read it. So it GL accepts
4543 * 4 component secondary colors use it
4545 TRACE("glSecondaryColorPointer(%#x, %#x, %#x, %p);\n", format
, type
, e
->stride
,
4546 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4547 GL_EXTCALL(glSecondaryColorPointerEXT(format
, type
, e
->stride
,
4548 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
));
4549 checkGLcall("glSecondaryColorPointerEXT(format, type, ...)");
4555 case GL_UNSIGNED_BYTE
:
4556 TRACE("glSecondaryColorPointer(3, GL_UNSIGNED_BYTE, %#x, %p);\n", e
->stride
,
4557 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4558 GL_EXTCALL(glSecondaryColorPointerEXT(3, GL_UNSIGNED_BYTE
, e
->stride
,
4559 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
));
4560 checkGLcall("glSecondaryColorPointerEXT(3, GL_UNSIGNED_BYTE, ...)");
4564 FIXME("Add 4 component specular color pointers for type %x\n", type
);
4565 /* Make sure that the right color component is dropped */
4566 TRACE("glSecondaryColorPointer(3, %#x, %#x, %p);\n", type
, e
->stride
,
4567 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4568 GL_EXTCALL(glSecondaryColorPointerEXT(3, type
, e
->stride
,
4569 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
));
4570 checkGLcall("glSecondaryColorPointerEXT(3, type, ...)");
4573 gl_info
->gl_ops
.gl
.p_glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT
);
4574 checkGLcall("glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
4578 WARN("Specular colour is not supported in this GL implementation.\n");
4583 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
4585 GL_EXTCALL(glSecondaryColor3fEXT
)(0, 0, 0);
4586 checkGLcall("glSecondaryColor3fEXT(0, 0, 0)");
4590 WARN("Specular colour is not supported in this GL implementation.\n");
4594 /* Texture coords -------------------------------------------*/
4595 load_tex_coords(context
, si
, &curVBO
, state
);
4598 static void streamsrc(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4600 BOOL load_numbered
= use_vs(state
) && !context
->use_immediate_mode_draw
;
4601 BOOL load_named
= !use_vs(state
) && !context
->use_immediate_mode_draw
;
4603 if (isStateDirty(context
, STATE_VDECL
)) return;
4604 if (context
->numberedArraysLoaded
&& !load_numbered
)
4606 unload_numbered_arrays(context
);
4607 context
->numberedArraysLoaded
= FALSE
;
4608 context
->numbered_array_mask
= 0;
4610 else if (context
->namedArraysLoaded
)
4612 unload_vertex_data(context
->gl_info
);
4613 context
->namedArraysLoaded
= FALSE
;
4618 TRACE("Loading numbered arrays\n");
4619 load_numbered_arrays(context
, &context
->stream_info
, state
);
4620 context
->numberedArraysLoaded
= TRUE
;
4622 else if (load_named
)
4624 TRACE("Loading vertex data\n");
4625 load_vertex_data(context
, &context
->stream_info
, state
);
4626 context
->namedArraysLoaded
= TRUE
;
4630 static void vdecl_miscpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4632 if (isStateDirty(context
, STATE_STREAMSRC
))
4634 streamsrc(context
, state
, STATE_STREAMSRC
);
4637 void vertexdeclaration(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4639 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4640 BOOL useVertexShaderFunction
= use_vs(state
);
4641 BOOL updateFog
= FALSE
;
4643 BOOL wasrhw
= context
->last_was_rhw
;
4646 transformed
= context
->stream_info
.position_transformed
;
4647 if (transformed
!= context
->last_was_rhw
&& !useVertexShaderFunction
)
4650 context
->last_was_rhw
= transformed
;
4652 /* Don't have to apply the matrices when vertex shaders are used. When
4653 * vshaders are turned off this function will be called again anyway to
4654 * make sure they're properly set. */
4655 if (!useVertexShaderFunction
)
4657 /* TODO: Move this mainly to the viewport state and only apply when
4658 * the vp has changed or transformed / untransformed was switched. */
4659 if (wasrhw
!= context
->last_was_rhw
4660 && !isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
))
4661 && !isStateDirty(context
, STATE_VIEWPORT
))
4662 transform_projection(context
, state
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
));
4663 /* World matrix needs reapplication here only if we're switching between rhw and non-rhw
4666 * If a vertex shader is used, the world matrix changed and then vertex shader unbound
4667 * this check will fail and the matrix not applied again. This is OK because a simple
4668 * world matrix change reapplies the matrix - These checks here are only to satisfy the
4669 * needs of the vertex declaration.
4671 * World and view matrix go into the same gl matrix, so only apply them when neither is
4674 if (transformed
!= wasrhw
&& !isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0)))
4675 && !isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_VIEW
)))
4676 transform_world(context
, state
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0)));
4677 if (!isStateDirty(context
, STATE_RENDER(WINED3D_RS_COLORVERTEX
)))
4678 context_apply_state(context
, state
, STATE_RENDER(WINED3D_RS_COLORVERTEX
));
4679 if (!isStateDirty(context
, STATE_RENDER(WINED3D_RS_LIGHTING
)))
4680 state_lighting(context
, state
, STATE_RENDER(WINED3D_RS_LIGHTING
));
4682 if (context
->last_was_vshader
)
4686 if (!context
->d3d_info
->vs_clipping
4687 && !isStateDirty(context
, STATE_RENDER(WINED3D_RS_CLIPPLANEENABLE
)))
4689 state_clipping(context
, state
, STATE_RENDER(WINED3D_RS_CLIPPLANEENABLE
));
4692 for (i
= 0; i
< gl_info
->limits
.clipplanes
; ++i
)
4694 clipplane(context
, state
, STATE_CLIPPLANE(i
));
4697 if (!isStateDirty(context
, STATE_RENDER(WINED3D_RS_NORMALIZENORMALS
)))
4698 state_normalize(context
, state
, STATE_RENDER(WINED3D_RS_NORMALIZENORMALS
));
4702 if(!context
->last_was_vshader
) {
4703 static BOOL warned
= FALSE
;
4704 if (!context
->d3d_info
->vs_clipping
)
4706 /* Disable all clip planes to get defined results on all drivers. See comment in the
4707 * state_clipping state handler
4709 for (i
= 0; i
< gl_info
->limits
.clipplanes
; ++i
)
4711 gl_info
->gl_ops
.gl
.p_glDisable(GL_CLIP_PLANE0
+ i
);
4712 checkGLcall("glDisable(GL_CLIP_PLANE0 + i)");
4715 if (!warned
&& state
->render_states
[WINED3D_RS_CLIPPLANEENABLE
])
4717 FIXME("Clipping not supported with vertex shaders\n");
4723 /* Apply the transform matrices when switching from rhw
4724 * drawing to vertex shaders. Vertex shaders themselves do
4725 * not need it, but the matrices are not reapplied
4726 * automatically when switching back from vertex shaders to
4727 * fixed function processing. So make sure we leave the fixed
4728 * function vertex processing states back in a sane state
4729 * before switching to shaders. */
4730 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
)))
4731 transform_projection(context
, state
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
));
4732 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0))))
4733 transform_world(context
, state
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0)));
4737 /* Vertex shader clipping ignores the view matrix. Update all clipplanes
4738 * (Note: ARB shaders can read the clip planes for clipping emulation even if
4739 * device->vs_clipping is false.
4741 for (i
= 0; i
< gl_info
->limits
.clipplanes
; ++i
)
4743 clipplane(context
, state
, STATE_CLIPPLANE(i
));
4748 context
->last_was_vshader
= useVertexShaderFunction
;
4749 context
->shader_update_mask
|= 1 << WINED3D_SHADER_TYPE_VERTEX
;
4752 context_apply_state(context
, state
, STATE_RENDER(WINED3D_RS_FOGVERTEXMODE
));
4754 if (!useVertexShaderFunction
)
4758 for (i
= 0; i
< MAX_TEXTURES
; ++i
)
4760 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_TEXTURE0
+ i
)))
4761 transform_texture(context
, state
, STATE_TEXTURESTAGE(i
, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
));
4764 if (use_ps(state
) && state
->shader
[WINED3D_SHADER_TYPE_PIXEL
]->reg_maps
.shader_version
.major
== 1
4765 && state
->shader
[WINED3D_SHADER_TYPE_PIXEL
]->reg_maps
.shader_version
.minor
<= 3)
4766 context
->shader_update_mask
|= 1 << WINED3D_SHADER_TYPE_PIXEL
;
4770 static void viewport_miscpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4772 const struct wined3d_rendertarget_view
*target
= state
->fb
->render_targets
[0];
4773 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4774 struct wined3d_viewport vp
= state
->viewport
;
4776 if (vp
.width
> target
->width
)
4777 vp
.width
= target
->width
;
4778 if (vp
.height
> target
->height
)
4779 vp
.height
= target
->height
;
4781 gl_info
->gl_ops
.gl
.p_glDepthRange(vp
.min_z
, vp
.max_z
);
4782 checkGLcall("glDepthRange");
4783 /* Note: GL requires lower left, DirectX supplies upper left. This is
4784 * reversed when using offscreen rendering. */
4785 if (context
->render_offscreen
)
4787 gl_info
->gl_ops
.gl
.p_glViewport(vp
.x
, vp
.y
, vp
.width
, vp
.height
);
4793 surface_get_drawable_size(wined3d_rendertarget_view_get_surface(target
), context
, &width
, &height
);
4794 gl_info
->gl_ops
.gl
.p_glViewport(vp
.x
, (height
- (vp
.y
+ vp
.height
)),
4795 vp
.width
, vp
.height
);
4797 checkGLcall("glViewport");
4800 void viewport_vertexpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4802 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
)))
4803 transform_projection(context
, state
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
));
4804 if (!isStateDirty(context
, STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
))
4805 && state
->render_states
[WINED3D_RS_POINTSCALEENABLE
])
4806 state_pscale(context
, state
, STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
));
4807 /* Update the position fixup. */
4808 context
->constant_update_mask
|= WINED3D_SHADER_CONST_VS_POS_FIXUP
;
4811 void light(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4813 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4814 UINT Index
= state_id
- STATE_ACTIVELIGHT(0);
4815 const struct wined3d_light_info
*lightInfo
= state
->lights
[Index
];
4819 gl_info
->gl_ops
.gl
.p_glDisable(GL_LIGHT0
+ Index
);
4820 checkGLcall("glDisable(GL_LIGHT0 + Index)");
4825 float colRGBA
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
4827 /* Light settings are affected by the model view in OpenGL, the View transform in direct3d*/
4828 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
4829 gl_info
->gl_ops
.gl
.p_glPushMatrix();
4830 gl_info
->gl_ops
.gl
.p_glLoadMatrixf(&state
->transforms
[WINED3D_TS_VIEW
].u
.m
[0][0]);
4833 colRGBA
[0] = lightInfo
->OriginalParms
.diffuse
.r
;
4834 colRGBA
[1] = lightInfo
->OriginalParms
.diffuse
.g
;
4835 colRGBA
[2] = lightInfo
->OriginalParms
.diffuse
.b
;
4836 colRGBA
[3] = lightInfo
->OriginalParms
.diffuse
.a
;
4837 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_DIFFUSE
, colRGBA
);
4838 checkGLcall("glLightfv");
4841 colRGBA
[0] = lightInfo
->OriginalParms
.specular
.r
;
4842 colRGBA
[1] = lightInfo
->OriginalParms
.specular
.g
;
4843 colRGBA
[2] = lightInfo
->OriginalParms
.specular
.b
;
4844 colRGBA
[3] = lightInfo
->OriginalParms
.specular
.a
;
4845 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_SPECULAR
, colRGBA
);
4846 checkGLcall("glLightfv");
4849 colRGBA
[0] = lightInfo
->OriginalParms
.ambient
.r
;
4850 colRGBA
[1] = lightInfo
->OriginalParms
.ambient
.g
;
4851 colRGBA
[2] = lightInfo
->OriginalParms
.ambient
.b
;
4852 colRGBA
[3] = lightInfo
->OriginalParms
.ambient
.a
;
4853 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_AMBIENT
, colRGBA
);
4854 checkGLcall("glLightfv");
4856 if ((lightInfo
->OriginalParms
.range
* lightInfo
->OriginalParms
.range
) >= FLT_MIN
)
4857 quad_att
= 1.4f
/ (lightInfo
->OriginalParms
.range
* lightInfo
->OriginalParms
.range
);
4859 quad_att
= 0.0f
; /* 0 or MAX? (0 seems to be ok) */
4861 /* Do not assign attenuation values for lights that do not use them. D3D apps are free to pass any junk,
4862 * but gl drivers use them and may crash due to bad Attenuation values. Need for Speed most wanted sets
4863 * Attenuation0 to NaN and crashes in the gl lib
4866 switch (lightInfo
->OriginalParms
.type
)
4868 case WINED3D_LIGHT_POINT
:
4870 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->lightPosn
[0]);
4871 checkGLcall("glLightfv");
4872 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
4873 checkGLcall("glLightf");
4874 /* Attenuation - Are these right? guessing... */
4875 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_CONSTANT_ATTENUATION
,
4876 lightInfo
->OriginalParms
.attenuation0
);
4877 checkGLcall("glLightf");
4878 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_LINEAR_ATTENUATION
,
4879 lightInfo
->OriginalParms
.attenuation1
);
4880 checkGLcall("glLightf");
4881 if (quad_att
< lightInfo
->OriginalParms
.attenuation2
)
4882 quad_att
= lightInfo
->OriginalParms
.attenuation2
;
4883 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_QUADRATIC_ATTENUATION
, quad_att
);
4884 checkGLcall("glLightf");
4888 case WINED3D_LIGHT_SPOT
:
4890 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->lightPosn
[0]);
4891 checkGLcall("glLightfv");
4893 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_SPOT_DIRECTION
, &lightInfo
->lightDirn
[0]);
4894 checkGLcall("glLightfv");
4895 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_SPOT_EXPONENT
, lightInfo
->exponent
);
4896 checkGLcall("glLightf");
4897 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
4898 checkGLcall("glLightf");
4899 /* Attenuation - Are these right? guessing... */
4900 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_CONSTANT_ATTENUATION
,
4901 lightInfo
->OriginalParms
.attenuation0
);
4902 checkGLcall("glLightf");
4903 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_LINEAR_ATTENUATION
,
4904 lightInfo
->OriginalParms
.attenuation1
);
4905 checkGLcall("glLightf");
4906 if (quad_att
< lightInfo
->OriginalParms
.attenuation2
)
4907 quad_att
= lightInfo
->OriginalParms
.attenuation2
;
4908 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_QUADRATIC_ATTENUATION
, quad_att
);
4909 checkGLcall("glLightf");
4913 case WINED3D_LIGHT_DIRECTIONAL
:
4915 /* Note GL uses w position of 0 for direction! */
4916 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->lightPosn
[0]);
4917 checkGLcall("glLightfv");
4918 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
4919 checkGLcall("glLightf");
4920 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_SPOT_EXPONENT
, 0.0f
);
4921 checkGLcall("glLightf");
4925 FIXME("Unrecognized light type %#x.\n", lightInfo
->OriginalParms
.type
);
4928 /* Restore the modelview matrix */
4929 gl_info
->gl_ops
.gl
.p_glPopMatrix();
4931 gl_info
->gl_ops
.gl
.p_glEnable(GL_LIGHT0
+ Index
);
4932 checkGLcall("glEnable(GL_LIGHT0 + Index)");
4936 static void scissorrect(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4938 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4939 const RECT
*r
= &state
->scissor_rect
;
4941 /* Warning: glScissor uses window coordinates, not viewport coordinates,
4942 * so our viewport correction does not apply. Warning2: Even in windowed
4943 * mode the coords are relative to the window, not the screen. */
4944 TRACE("Setting new scissor rect to %s.\n", wine_dbgstr_rect(r
));
4946 if (context
->render_offscreen
)
4948 gl_info
->gl_ops
.gl
.p_glScissor(r
->left
, r
->top
, r
->right
- r
->left
, r
->bottom
- r
->top
);
4952 const struct wined3d_rendertarget_view
*target
= state
->fb
->render_targets
[0];
4956 surface_get_drawable_size(wined3d_rendertarget_view_get_surface(target
), context
, &width
, &height
);
4957 gl_info
->gl_ops
.gl
.p_glScissor(r
->left
, height
- r
->bottom
, r
->right
- r
->left
, r
->bottom
- r
->top
);
4959 checkGLcall("glScissor");
4962 static void indexbuffer(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4964 const struct wined3d_stream_info
*stream_info
= &context
->stream_info
;
4965 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4967 if (!state
->index_buffer
|| !stream_info
->all_vbo
)
4969 GL_EXTCALL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER
, 0));
4973 struct wined3d_buffer
*ib
= state
->index_buffer
;
4974 GL_EXTCALL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER
, ib
->buffer_object
));
4978 static void frontface(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4980 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4982 if (context
->render_offscreen
)
4984 gl_info
->gl_ops
.gl
.p_glFrontFace(GL_CCW
);
4985 checkGLcall("glFrontFace(GL_CCW)");
4989 gl_info
->gl_ops
.gl
.p_glFrontFace(GL_CW
);
4990 checkGLcall("glFrontFace(GL_CW)");
4994 static void psorigin_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
5000 WARN("Point sprite coordinate origin switching not supported.\n");
5005 static void psorigin(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
5007 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
5008 GLint origin
= context
->render_offscreen
? GL_LOWER_LEFT
: GL_UPPER_LEFT
;
5010 GL_EXTCALL(glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN
, origin
));
5011 checkGLcall("glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, ...)");
5014 void state_srgbwrite(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
5016 const struct wined3d_format
*rt_format
= state
->fb
->render_targets
[0]->format
;
5017 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
5019 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
5021 if (state
->render_states
[WINED3D_RS_SRGBWRITEENABLE
]
5022 && rt_format
->flags
& WINED3DFMT_FLAG_SRGB_WRITE
)
5023 gl_info
->gl_ops
.gl
.p_glEnable(GL_FRAMEBUFFER_SRGB
);
5025 gl_info
->gl_ops
.gl
.p_glDisable(GL_FRAMEBUFFER_SRGB
);
5028 static void state_cb(const struct wined3d_gl_info
*gl_info
, const struct wined3d_state
*state
,
5029 enum wined3d_shader_type type
, unsigned int base
, unsigned int count
)
5031 struct wined3d_buffer
*buffer
;
5034 for (i
= 0; i
< count
; ++i
)
5036 buffer
= state
->cb
[type
][i
];
5037 GL_EXTCALL(glBindBufferBase(GL_UNIFORM_BUFFER
, base
+ i
, buffer
? buffer
->buffer_object
: 0));
5039 checkGLcall("glBindBufferBase");
5042 static void state_cb_vs(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
5044 const struct wined3d_gl_limits
*limits
= &context
->gl_info
->limits
;
5046 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
5048 state_cb(context
->gl_info
, state
, WINED3D_SHADER_TYPE_VERTEX
, 0, limits
->vertex_uniform_blocks
);
5051 static void state_cb_gs(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
5053 const struct wined3d_gl_limits
*limits
= &context
->gl_info
->limits
;
5055 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
5057 state_cb(context
->gl_info
, state
, WINED3D_SHADER_TYPE_GEOMETRY
,
5058 limits
->vertex_uniform_blocks
, limits
->geometry_uniform_blocks
);
5061 static void state_cb_ps(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
5063 const struct wined3d_gl_limits
*limits
= &context
->gl_info
->limits
;
5065 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
5067 state_cb(context
->gl_info
, state
, WINED3D_SHADER_TYPE_PIXEL
,
5068 limits
->vertex_uniform_blocks
+ limits
->geometry_uniform_blocks
, limits
->fragment_uniform_blocks
);
5071 static void state_cb_warn(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
5073 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
5075 WARN("Constant buffers (%s) no supported.\n", debug_d3dstate(state_id
));
5078 static void state_shader_resource_binding(struct wined3d_context
*context
,
5079 const struct wined3d_state
*state
, DWORD state_id
)
5081 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
5083 context
->update_shader_resource_bindings
= 1;
5086 const struct StateEntryTemplate misc_state_template
[] =
5088 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX
), state_cb_vs
, }, ARB_UNIFORM_BUFFER_OBJECT
},
5089 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX
), state_cb_warn
, }, WINED3D_GL_EXT_NONE
},
5090 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY
),{ STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY
),state_cb_gs
, }, ARB_UNIFORM_BUFFER_OBJECT
},
5091 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY
),{ STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY
),state_cb_warn
, }, WINED3D_GL_EXT_NONE
},
5092 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL
), state_cb_ps
, }, ARB_UNIFORM_BUFFER_OBJECT
},
5093 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL
), state_cb_warn
, }, WINED3D_GL_EXT_NONE
},
5094 { STATE_SHADER_RESOURCE_BINDING
, { STATE_SHADER_RESOURCE_BINDING
, state_shader_resource_binding
}, WINED3D_GL_EXT_NONE
},
5095 { STATE_RENDER(WINED3D_RS_SRCBLEND
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5096 { STATE_RENDER(WINED3D_RS_DESTBLEND
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5097 { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), state_blend
}, WINED3D_GL_EXT_NONE
},
5098 { STATE_RENDER(WINED3D_RS_EDGEANTIALIAS
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5099 { STATE_RENDER(WINED3D_RS_ANTIALIASEDLINEENABLE
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5100 { STATE_RENDER(WINED3D_RS_SEPARATEALPHABLENDENABLE
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5101 { STATE_RENDER(WINED3D_RS_SRCBLENDALPHA
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5102 { STATE_RENDER(WINED3D_RS_DESTBLENDALPHA
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5103 { STATE_RENDER(WINED3D_RS_DESTBLENDALPHA
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5104 { STATE_RENDER(WINED3D_RS_BLENDOPALPHA
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5105 { STATE_STREAMSRC
, { STATE_STREAMSRC
, streamsrc
}, WINED3D_GL_EXT_NONE
},
5106 { STATE_VDECL
, { STATE_VDECL
, vdecl_miscpart
}, WINED3D_GL_EXT_NONE
},
5107 { STATE_FRONTFACE
, { STATE_FRONTFACE
, frontface
}, WINED3D_GL_EXT_NONE
},
5108 { STATE_SCISSORRECT
, { STATE_SCISSORRECT
, scissorrect
}, WINED3D_GL_EXT_NONE
},
5109 { STATE_POINTSPRITECOORDORIGIN
, { STATE_POINTSPRITECOORDORIGIN
, psorigin
}, WINED3D_GL_VERSION_2_0
},
5110 { STATE_POINTSPRITECOORDORIGIN
, { STATE_POINTSPRITECOORDORIGIN
, psorigin_w
}, WINED3D_GL_EXT_NONE
},
5112 /* TODO: Move shader constant loading to vertex and fragment pipeline respectively, as soon as the pshader and
5113 * vshader loadings are untied from each other
5115 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5116 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5117 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5118 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5119 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5120 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5121 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5122 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5123 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5124 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5125 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5126 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5127 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5128 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5129 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5130 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5131 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5132 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5133 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5134 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5135 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5136 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5137 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5138 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5139 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5140 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5141 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5142 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5143 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5144 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5145 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5146 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5147 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5148 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
5149 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5150 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
5151 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5152 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
5153 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5154 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
5155 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5156 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
5157 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5158 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
5159 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5160 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
5161 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5162 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
5164 { STATE_VIEWPORT
, { STATE_VIEWPORT
, viewport_miscpart
}, WINED3D_GL_EXT_NONE
},
5165 { STATE_INDEXBUFFER
, { STATE_INDEXBUFFER
, indexbuffer
}, ARB_VERTEX_BUFFER_OBJECT
},
5166 { STATE_INDEXBUFFER
, { STATE_INDEXBUFFER
, state_nop
}, WINED3D_GL_EXT_NONE
},
5167 { STATE_RENDER(WINED3D_RS_ANTIALIAS
), { STATE_RENDER(WINED3D_RS_ANTIALIAS
), state_antialias
}, WINED3D_GL_EXT_NONE
},
5168 { STATE_RENDER(WINED3D_RS_TEXTUREPERSPECTIVE
), { STATE_RENDER(WINED3D_RS_TEXTUREPERSPECTIVE
), state_perspective
}, WINED3D_GL_EXT_NONE
},
5169 { STATE_RENDER(WINED3D_RS_ZENABLE
), { STATE_RENDER(WINED3D_RS_ZENABLE
), state_zenable
}, WINED3D_GL_EXT_NONE
},
5170 { STATE_RENDER(WINED3D_RS_WRAPU
), { STATE_RENDER(WINED3D_RS_WRAPU
), state_wrapu
}, WINED3D_GL_EXT_NONE
},
5171 { STATE_RENDER(WINED3D_RS_WRAPV
), { STATE_RENDER(WINED3D_RS_WRAPV
), state_wrapv
}, WINED3D_GL_EXT_NONE
},
5172 { STATE_RENDER(WINED3D_RS_FILLMODE
), { STATE_RENDER(WINED3D_RS_FILLMODE
), state_fillmode
}, WINED3D_GL_EXT_NONE
},
5173 { STATE_RENDER(WINED3D_RS_SHADEMODE
), { STATE_RENDER(WINED3D_RS_SHADEMODE
), state_shademode
}, WINED3D_GL_EXT_NONE
},
5174 { STATE_RENDER(WINED3D_RS_LINEPATTERN
), { STATE_RENDER(WINED3D_RS_LINEPATTERN
), state_linepattern
}, WINED3D_GL_EXT_NONE
},
5175 { STATE_RENDER(WINED3D_RS_MONOENABLE
), { STATE_RENDER(WINED3D_RS_MONOENABLE
), state_monoenable
}, WINED3D_GL_EXT_NONE
},
5176 { STATE_RENDER(WINED3D_RS_ROP2
), { STATE_RENDER(WINED3D_RS_ROP2
), state_rop2
}, WINED3D_GL_EXT_NONE
},
5177 { STATE_RENDER(WINED3D_RS_PLANEMASK
), { STATE_RENDER(WINED3D_RS_PLANEMASK
), state_planemask
}, WINED3D_GL_EXT_NONE
},
5178 { STATE_RENDER(WINED3D_RS_ZWRITEENABLE
), { STATE_RENDER(WINED3D_RS_ZWRITEENABLE
), state_zwritenable
}, WINED3D_GL_EXT_NONE
},
5179 { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), state_alpha
}, WINED3D_GL_EXT_NONE
},
5180 { STATE_RENDER(WINED3D_RS_ALPHAREF
), { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5181 { STATE_RENDER(WINED3D_RS_ALPHAFUNC
), { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5182 { STATE_RENDER(WINED3D_RS_COLORKEYENABLE
), { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5183 { STATE_RENDER(WINED3D_RS_LASTPIXEL
), { STATE_RENDER(WINED3D_RS_LASTPIXEL
), state_lastpixel
}, WINED3D_GL_EXT_NONE
},
5184 { STATE_RENDER(WINED3D_RS_CULLMODE
), { STATE_RENDER(WINED3D_RS_CULLMODE
), state_cullmode
}, WINED3D_GL_EXT_NONE
},
5185 { STATE_RENDER(WINED3D_RS_ZFUNC
), { STATE_RENDER(WINED3D_RS_ZFUNC
), state_zfunc
}, WINED3D_GL_EXT_NONE
},
5186 { STATE_RENDER(WINED3D_RS_DITHERENABLE
), { STATE_RENDER(WINED3D_RS_DITHERENABLE
), state_ditherenable
}, WINED3D_GL_EXT_NONE
},
5187 { STATE_RENDER(WINED3D_RS_SUBPIXEL
), { STATE_RENDER(WINED3D_RS_SUBPIXEL
), state_subpixel
}, WINED3D_GL_EXT_NONE
},
5188 { STATE_RENDER(WINED3D_RS_SUBPIXELX
), { STATE_RENDER(WINED3D_RS_SUBPIXELX
), state_subpixelx
}, WINED3D_GL_EXT_NONE
},
5189 { STATE_RENDER(WINED3D_RS_STIPPLEDALPHA
), { STATE_RENDER(WINED3D_RS_STIPPLEDALPHA
), state_stippledalpha
}, WINED3D_GL_EXT_NONE
},
5190 { STATE_RENDER(WINED3D_RS_STIPPLEENABLE
), { STATE_RENDER(WINED3D_RS_STIPPLEENABLE
), state_stippleenable
}, WINED3D_GL_EXT_NONE
},
5191 { STATE_RENDER(WINED3D_RS_MIPMAPLODBIAS
), { STATE_RENDER(WINED3D_RS_MIPMAPLODBIAS
), state_mipmaplodbias
}, WINED3D_GL_EXT_NONE
},
5192 { STATE_RENDER(WINED3D_RS_ANISOTROPY
), { STATE_RENDER(WINED3D_RS_ANISOTROPY
), state_anisotropy
}, WINED3D_GL_EXT_NONE
},
5193 { STATE_RENDER(WINED3D_RS_FLUSHBATCH
), { STATE_RENDER(WINED3D_RS_FLUSHBATCH
), state_flushbatch
}, WINED3D_GL_EXT_NONE
},
5194 { STATE_RENDER(WINED3D_RS_TRANSLUCENTSORTINDEPENDENT
),{ STATE_RENDER(WINED3D_RS_TRANSLUCENTSORTINDEPENDENT
),state_translucentsi
}, WINED3D_GL_EXT_NONE
},
5195 { STATE_RENDER(WINED3D_RS_STENCILENABLE
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), state_stencil
}, WINED3D_GL_EXT_NONE
},
5196 { STATE_RENDER(WINED3D_RS_STENCILFAIL
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5197 { STATE_RENDER(WINED3D_RS_STENCILZFAIL
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5198 { STATE_RENDER(WINED3D_RS_STENCILPASS
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5199 { STATE_RENDER(WINED3D_RS_STENCILFUNC
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5200 { STATE_RENDER(WINED3D_RS_STENCILREF
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5201 { STATE_RENDER(WINED3D_RS_STENCILMASK
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5202 { STATE_RENDER(WINED3D_RS_STENCILWRITEMASK
), { STATE_RENDER(WINED3D_RS_STENCILWRITEMASK
), state_stencilwrite2s
}, EXT_STENCIL_TWO_SIDE
},
5203 { STATE_RENDER(WINED3D_RS_STENCILWRITEMASK
), { STATE_RENDER(WINED3D_RS_STENCILWRITEMASK
), state_stencilwrite
}, WINED3D_GL_EXT_NONE
},
5204 { STATE_RENDER(WINED3D_RS_TWOSIDEDSTENCILMODE
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5205 { STATE_RENDER(WINED3D_RS_CCW_STENCILFAIL
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5206 { STATE_RENDER(WINED3D_RS_CCW_STENCILZFAIL
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5207 { STATE_RENDER(WINED3D_RS_CCW_STENCILPASS
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5208 { STATE_RENDER(WINED3D_RS_CCW_STENCILFUNC
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5209 { STATE_RENDER(WINED3D_RS_WRAP0
), { STATE_RENDER(WINED3D_RS_WRAP0
), state_wrap
}, WINED3D_GL_EXT_NONE
},
5210 { STATE_RENDER(WINED3D_RS_WRAP1
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5211 { STATE_RENDER(WINED3D_RS_WRAP2
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5212 { STATE_RENDER(WINED3D_RS_WRAP3
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5213 { STATE_RENDER(WINED3D_RS_WRAP4
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5214 { STATE_RENDER(WINED3D_RS_WRAP5
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5215 { STATE_RENDER(WINED3D_RS_WRAP6
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5216 { STATE_RENDER(WINED3D_RS_WRAP7
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5217 { STATE_RENDER(WINED3D_RS_WRAP8
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5218 { STATE_RENDER(WINED3D_RS_WRAP9
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5219 { STATE_RENDER(WINED3D_RS_WRAP10
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5220 { STATE_RENDER(WINED3D_RS_WRAP11
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5221 { STATE_RENDER(WINED3D_RS_WRAP12
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5222 { STATE_RENDER(WINED3D_RS_WRAP13
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5223 { STATE_RENDER(WINED3D_RS_WRAP14
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5224 { STATE_RENDER(WINED3D_RS_WRAP15
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5225 { STATE_RENDER(WINED3D_RS_EXTENTS
), { STATE_RENDER(WINED3D_RS_EXTENTS
), state_extents
}, WINED3D_GL_EXT_NONE
},
5226 { STATE_RENDER(WINED3D_RS_COLORKEYBLENDENABLE
), { STATE_RENDER(WINED3D_RS_COLORKEYBLENDENABLE
), state_ckeyblend
}, WINED3D_GL_EXT_NONE
},
5227 { STATE_RENDER(WINED3D_RS_SOFTWAREVERTEXPROCESSING
), { STATE_RENDER(WINED3D_RS_SOFTWAREVERTEXPROCESSING
), state_swvp
}, WINED3D_GL_EXT_NONE
},
5228 { STATE_RENDER(WINED3D_RS_PATCHEDGESTYLE
), { STATE_RENDER(WINED3D_RS_PATCHEDGESTYLE
), state_patchedgestyle
}, WINED3D_GL_EXT_NONE
},
5229 { STATE_RENDER(WINED3D_RS_PATCHSEGMENTS
), { STATE_RENDER(WINED3D_RS_PATCHSEGMENTS
), state_patchsegments
}, WINED3D_GL_EXT_NONE
},
5230 { STATE_RENDER(WINED3D_RS_POSITIONDEGREE
), { STATE_RENDER(WINED3D_RS_POSITIONDEGREE
), state_positiondegree
}, WINED3D_GL_EXT_NONE
},
5231 { STATE_RENDER(WINED3D_RS_NORMALDEGREE
), { STATE_RENDER(WINED3D_RS_NORMALDEGREE
), state_normaldegree
}, WINED3D_GL_EXT_NONE
},
5232 { STATE_RENDER(WINED3D_RS_MINTESSELLATIONLEVEL
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
5233 { STATE_RENDER(WINED3D_RS_MAXTESSELLATIONLEVEL
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
5234 { STATE_RENDER(WINED3D_RS_ADAPTIVETESS_X
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
5235 { STATE_RENDER(WINED3D_RS_ADAPTIVETESS_Y
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
5236 { STATE_RENDER(WINED3D_RS_ADAPTIVETESS_Z
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
5237 { STATE_RENDER(WINED3D_RS_ADAPTIVETESS_W
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
5238 { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),{ STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),state_nvdb
}, EXT_DEPTH_BOUNDS_TEST
},
5239 { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),{ STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),state_tessellation
}, WINED3D_GL_EXT_NONE
},
5240 { STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS
), { STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS
), state_msaa
}, ARB_MULTISAMPLE
},
5241 { STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS
), { STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS
), state_msaa_w
}, WINED3D_GL_EXT_NONE
},
5242 { STATE_RENDER(WINED3D_RS_MULTISAMPLEMASK
), { STATE_RENDER(WINED3D_RS_MULTISAMPLEMASK
), state_multisampmask
}, WINED3D_GL_EXT_NONE
},
5243 { STATE_RENDER(WINED3D_RS_DEBUGMONITORTOKEN
), { STATE_RENDER(WINED3D_RS_DEBUGMONITORTOKEN
), state_debug_monitor
}, WINED3D_GL_EXT_NONE
},
5244 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE
), state_colorwrite0
}, EXT_DRAW_BUFFERS2
},
5245 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE
), state_colorwrite
}, WINED3D_GL_EXT_NONE
},
5246 { STATE_RENDER(WINED3D_RS_BLENDOP
), { STATE_RENDER(WINED3D_RS_BLENDOP
), state_blendop
}, EXT_BLEND_MINMAX
},
5247 { STATE_RENDER(WINED3D_RS_BLENDOP
), { STATE_RENDER(WINED3D_RS_BLENDOP
), state_blendop_w
}, WINED3D_GL_EXT_NONE
},
5248 { STATE_RENDER(WINED3D_RS_SCISSORTESTENABLE
), { STATE_RENDER(WINED3D_RS_SCISSORTESTENABLE
), state_scissor
}, WINED3D_GL_EXT_NONE
},
5249 { STATE_RENDER(WINED3D_RS_SLOPESCALEDEPTHBIAS
), { STATE_RENDER(WINED3D_RS_DEPTHBIAS
), NULL
}, WINED3D_GL_EXT_NONE
},
5250 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1
), state_colorwrite1
}, EXT_DRAW_BUFFERS2
},
5251 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5252 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2
), state_colorwrite2
}, EXT_DRAW_BUFFERS2
},
5253 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5254 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3
), state_colorwrite3
}, EXT_DRAW_BUFFERS2
},
5255 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5256 { STATE_RENDER(WINED3D_RS_BLENDFACTOR
), { STATE_RENDER(WINED3D_RS_BLENDFACTOR
), state_blendfactor
}, EXT_BLEND_COLOR
},
5257 { STATE_RENDER(WINED3D_RS_BLENDFACTOR
), { STATE_RENDER(WINED3D_RS_BLENDFACTOR
), state_blendfactor_w
}, WINED3D_GL_EXT_NONE
},
5258 { STATE_RENDER(WINED3D_RS_DEPTHBIAS
), { STATE_RENDER(WINED3D_RS_DEPTHBIAS
), state_depthbias
}, WINED3D_GL_EXT_NONE
},
5259 { STATE_RENDER(WINED3D_RS_ZVISIBLE
), { STATE_RENDER(WINED3D_RS_ZVISIBLE
), state_zvisible
}, WINED3D_GL_EXT_NONE
},
5261 { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler
}, WINED3D_GL_EXT_NONE
},
5262 { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler
}, WINED3D_GL_EXT_NONE
},
5263 { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler
}, WINED3D_GL_EXT_NONE
},
5264 { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler
}, WINED3D_GL_EXT_NONE
},
5265 { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler
}, WINED3D_GL_EXT_NONE
},
5266 { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler
}, WINED3D_GL_EXT_NONE
},
5267 { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler
}, WINED3D_GL_EXT_NONE
},
5268 { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler
}, WINED3D_GL_EXT_NONE
},
5269 { STATE_SAMPLER(8), { STATE_SAMPLER(8), sampler
}, WINED3D_GL_EXT_NONE
},
5270 { STATE_SAMPLER(9), { STATE_SAMPLER(9), sampler
}, WINED3D_GL_EXT_NONE
},
5271 { STATE_SAMPLER(10), { STATE_SAMPLER(10), sampler
}, WINED3D_GL_EXT_NONE
},
5272 { STATE_SAMPLER(11), { STATE_SAMPLER(11), sampler
}, WINED3D_GL_EXT_NONE
},
5273 { STATE_SAMPLER(12), { STATE_SAMPLER(12), sampler
}, WINED3D_GL_EXT_NONE
},
5274 { STATE_SAMPLER(13), { STATE_SAMPLER(13), sampler
}, WINED3D_GL_EXT_NONE
},
5275 { STATE_SAMPLER(14), { STATE_SAMPLER(14), sampler
}, WINED3D_GL_EXT_NONE
},
5276 { STATE_SAMPLER(15), { STATE_SAMPLER(15), sampler
}, WINED3D_GL_EXT_NONE
},
5277 { STATE_SAMPLER(16), /* Vertex sampler 0 */ { STATE_SAMPLER(16), sampler
}, WINED3D_GL_EXT_NONE
},
5278 { STATE_SAMPLER(17), /* Vertex sampler 1 */ { STATE_SAMPLER(17), sampler
}, WINED3D_GL_EXT_NONE
},
5279 { STATE_SAMPLER(18), /* Vertex sampler 2 */ { STATE_SAMPLER(18), sampler
}, WINED3D_GL_EXT_NONE
},
5280 { STATE_SAMPLER(19), /* Vertex sampler 3 */ { STATE_SAMPLER(19), sampler
}, WINED3D_GL_EXT_NONE
},
5281 { STATE_BASEVERTEXINDEX
, { STATE_BASEVERTEXINDEX
, state_nop
, }, ARB_DRAW_ELEMENTS_BASE_VERTEX
},
5282 { STATE_BASEVERTEXINDEX
, { STATE_STREAMSRC
, NULL
, }, WINED3D_GL_EXT_NONE
},
5283 { STATE_FRAMEBUFFER
, { STATE_FRAMEBUFFER
, context_state_fb
}, WINED3D_GL_EXT_NONE
},
5284 { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
), context_state_drawbuf
},WINED3D_GL_EXT_NONE
},
5285 { STATE_SHADER(WINED3D_SHADER_TYPE_GEOMETRY
), { STATE_SHADER(WINED3D_SHADER_TYPE_GEOMETRY
), state_geometry_shader
}, WINED3D_GL_EXT_NONE
},
5286 {0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE
},
5289 static const struct StateEntryTemplate vp_ffp_states
[] =
5291 { STATE_VDECL
, { STATE_VDECL
, vertexdeclaration
}, WINED3D_GL_EXT_NONE
},
5292 { STATE_SHADER(WINED3D_SHADER_TYPE_VERTEX
), { STATE_VDECL
, NULL
}, WINED3D_GL_EXT_NONE
},
5293 { STATE_MATERIAL
, { STATE_RENDER(WINED3D_RS_SPECULARENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5294 { STATE_RENDER(WINED3D_RS_SPECULARENABLE
), { STATE_RENDER(WINED3D_RS_SPECULARENABLE
), state_specularenable
}, WINED3D_GL_EXT_NONE
},
5296 { STATE_CLIPPLANE(0), { STATE_CLIPPLANE(0), clipplane
}, WINED3D_GL_EXT_NONE
},
5297 { STATE_CLIPPLANE(1), { STATE_CLIPPLANE(1), clipplane
}, WINED3D_GL_EXT_NONE
},
5298 { STATE_CLIPPLANE(2), { STATE_CLIPPLANE(2), clipplane
}, WINED3D_GL_EXT_NONE
},
5299 { STATE_CLIPPLANE(3), { STATE_CLIPPLANE(3), clipplane
}, WINED3D_GL_EXT_NONE
},
5300 { STATE_CLIPPLANE(4), { STATE_CLIPPLANE(4), clipplane
}, WINED3D_GL_EXT_NONE
},
5301 { STATE_CLIPPLANE(5), { STATE_CLIPPLANE(5), clipplane
}, WINED3D_GL_EXT_NONE
},
5302 { STATE_CLIPPLANE(6), { STATE_CLIPPLANE(6), clipplane
}, WINED3D_GL_EXT_NONE
},
5303 { STATE_CLIPPLANE(7), { STATE_CLIPPLANE(7), clipplane
}, WINED3D_GL_EXT_NONE
},
5304 { STATE_CLIPPLANE(8), { STATE_CLIPPLANE(8), clipplane
}, WINED3D_GL_EXT_NONE
},
5305 { STATE_CLIPPLANE(9), { STATE_CLIPPLANE(9), clipplane
}, WINED3D_GL_EXT_NONE
},
5306 { STATE_CLIPPLANE(10), { STATE_CLIPPLANE(10), clipplane
}, WINED3D_GL_EXT_NONE
},
5307 { STATE_CLIPPLANE(11), { STATE_CLIPPLANE(11), clipplane
}, WINED3D_GL_EXT_NONE
},
5308 { STATE_CLIPPLANE(12), { STATE_CLIPPLANE(12), clipplane
}, WINED3D_GL_EXT_NONE
},
5309 { STATE_CLIPPLANE(13), { STATE_CLIPPLANE(13), clipplane
}, WINED3D_GL_EXT_NONE
},
5310 { STATE_CLIPPLANE(14), { STATE_CLIPPLANE(14), clipplane
}, WINED3D_GL_EXT_NONE
},
5311 { STATE_CLIPPLANE(15), { STATE_CLIPPLANE(15), clipplane
}, WINED3D_GL_EXT_NONE
},
5312 { STATE_CLIPPLANE(16), { STATE_CLIPPLANE(16), clipplane
}, WINED3D_GL_EXT_NONE
},
5313 { STATE_CLIPPLANE(17), { STATE_CLIPPLANE(17), clipplane
}, WINED3D_GL_EXT_NONE
},
5314 { STATE_CLIPPLANE(18), { STATE_CLIPPLANE(18), clipplane
}, WINED3D_GL_EXT_NONE
},
5315 { STATE_CLIPPLANE(19), { STATE_CLIPPLANE(19), clipplane
}, WINED3D_GL_EXT_NONE
},
5316 { STATE_CLIPPLANE(20), { STATE_CLIPPLANE(20), clipplane
}, WINED3D_GL_EXT_NONE
},
5317 { STATE_CLIPPLANE(21), { STATE_CLIPPLANE(21), clipplane
}, WINED3D_GL_EXT_NONE
},
5318 { STATE_CLIPPLANE(22), { STATE_CLIPPLANE(22), clipplane
}, WINED3D_GL_EXT_NONE
},
5319 { STATE_CLIPPLANE(23), { STATE_CLIPPLANE(23), clipplane
}, WINED3D_GL_EXT_NONE
},
5320 { STATE_CLIPPLANE(24), { STATE_CLIPPLANE(24), clipplane
}, WINED3D_GL_EXT_NONE
},
5321 { STATE_CLIPPLANE(25), { STATE_CLIPPLANE(25), clipplane
}, WINED3D_GL_EXT_NONE
},
5322 { STATE_CLIPPLANE(26), { STATE_CLIPPLANE(26), clipplane
}, WINED3D_GL_EXT_NONE
},
5323 { STATE_CLIPPLANE(27), { STATE_CLIPPLANE(27), clipplane
}, WINED3D_GL_EXT_NONE
},
5324 { STATE_CLIPPLANE(28), { STATE_CLIPPLANE(28), clipplane
}, WINED3D_GL_EXT_NONE
},
5325 { STATE_CLIPPLANE(29), { STATE_CLIPPLANE(29), clipplane
}, WINED3D_GL_EXT_NONE
},
5326 { STATE_CLIPPLANE(30), { STATE_CLIPPLANE(30), clipplane
}, WINED3D_GL_EXT_NONE
},
5327 { STATE_CLIPPLANE(31), { STATE_CLIPPLANE(31), clipplane
}, WINED3D_GL_EXT_NONE
},
5329 { STATE_LIGHT_TYPE
, { STATE_LIGHT_TYPE
, state_nop
}, WINED3D_GL_EXT_NONE
},
5330 { STATE_ACTIVELIGHT(0), { STATE_ACTIVELIGHT(0), light
}, WINED3D_GL_EXT_NONE
},
5331 { STATE_ACTIVELIGHT(1), { STATE_ACTIVELIGHT(1), light
}, WINED3D_GL_EXT_NONE
},
5332 { STATE_ACTIVELIGHT(2), { STATE_ACTIVELIGHT(2), light
}, WINED3D_GL_EXT_NONE
},
5333 { STATE_ACTIVELIGHT(3), { STATE_ACTIVELIGHT(3), light
}, WINED3D_GL_EXT_NONE
},
5334 { STATE_ACTIVELIGHT(4), { STATE_ACTIVELIGHT(4), light
}, WINED3D_GL_EXT_NONE
},
5335 { STATE_ACTIVELIGHT(5), { STATE_ACTIVELIGHT(5), light
}, WINED3D_GL_EXT_NONE
},
5336 { STATE_ACTIVELIGHT(6), { STATE_ACTIVELIGHT(6), light
}, WINED3D_GL_EXT_NONE
},
5337 { STATE_ACTIVELIGHT(7), { STATE_ACTIVELIGHT(7), light
}, WINED3D_GL_EXT_NONE
},
5339 { STATE_VIEWPORT
, { STATE_VIEWPORT
, viewport_vertexpart
}, WINED3D_GL_EXT_NONE
},
5340 /* Transform states follow */
5341 { STATE_TRANSFORM(WINED3D_TS_VIEW
), { STATE_TRANSFORM(WINED3D_TS_VIEW
), transform_view
}, WINED3D_GL_EXT_NONE
},
5342 { STATE_TRANSFORM(WINED3D_TS_PROJECTION
), { STATE_TRANSFORM(WINED3D_TS_PROJECTION
), transform_projection
}, WINED3D_GL_EXT_NONE
},
5343 { STATE_TRANSFORM(WINED3D_TS_TEXTURE0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5344 { STATE_TRANSFORM(WINED3D_TS_TEXTURE1
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5345 { STATE_TRANSFORM(WINED3D_TS_TEXTURE2
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5346 { STATE_TRANSFORM(WINED3D_TS_TEXTURE3
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5347 { STATE_TRANSFORM(WINED3D_TS_TEXTURE4
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5348 { STATE_TRANSFORM(WINED3D_TS_TEXTURE5
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5349 { STATE_TRANSFORM(WINED3D_TS_TEXTURE6
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5350 { STATE_TRANSFORM(WINED3D_TS_TEXTURE7
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5351 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 0)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 0)), transform_world
}, WINED3D_GL_EXT_NONE
},
5352 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 1)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 1)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5353 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 2)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 2)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5354 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 3)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 3)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5355 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 4)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 4)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5356 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 5)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 5)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5357 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 6)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 6)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5358 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 7)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 7)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5359 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 8)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 8)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5360 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 9)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 9)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5361 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 10)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 10)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5362 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 11)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 11)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5363 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 12)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 12)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5364 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 13)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 13)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5365 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 14)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 14)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5366 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 15)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 15)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5367 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 16)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 16)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5368 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 17)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 17)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5369 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 18)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 18)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5370 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 19)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 19)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5371 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 20)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 20)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5372 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 21)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 21)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5373 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 22)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 22)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5374 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 23)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 23)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5375 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 24)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 24)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5376 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 25)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 25)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5377 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 26)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 26)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5378 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 27)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 27)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5379 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 28)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 28)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5380 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 29)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 29)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5381 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 30)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 30)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5382 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 31)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 31)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5383 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 32)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 32)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5384 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 33)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 33)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5385 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 34)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 34)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5386 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 35)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 35)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5387 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 36)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 36)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5388 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 37)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 37)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5389 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 38)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 38)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5390 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 39)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 39)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5391 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 40)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 40)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5392 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 41)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 41)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5393 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 42)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 42)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5394 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 43)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 43)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5395 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 44)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 44)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5396 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 45)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 45)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5397 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 46)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 46)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5398 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 47)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 47)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5399 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 48)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 48)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5400 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 49)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 49)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5401 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 50)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 50)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5402 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 51)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 51)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5403 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 52)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 52)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5404 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 53)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 53)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5405 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 54)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 54)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5406 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 55)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 55)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5407 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 56)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 56)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5408 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 57)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 57)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5409 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 58)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 58)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5410 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 59)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 59)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5411 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 60)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 60)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5412 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 61)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 61)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5413 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 62)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 62)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5414 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 63)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 63)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5415 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 64)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 64)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5416 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 65)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 65)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5417 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 66)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 66)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5418 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 67)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 67)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5419 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 68)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 68)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5420 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 69)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 69)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5421 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 70)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 70)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5422 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 71)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 71)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5423 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 72)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 72)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5424 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 73)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 73)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5425 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 74)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 74)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5426 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 75)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 75)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5427 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 76)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 76)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5428 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 77)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 77)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5429 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 78)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 78)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5430 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 79)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 79)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5431 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 80)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 80)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5432 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 81)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 81)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5433 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 82)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 82)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5434 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 83)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 83)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5435 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 84)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 84)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5436 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 85)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 85)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5437 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 86)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 86)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5438 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 87)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 87)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5439 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 88)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 88)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5440 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 89)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 89)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5441 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 90)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 90)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5442 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 91)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 91)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5443 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 92)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 92)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5444 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 93)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 93)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5445 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 94)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 94)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5446 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 95)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 95)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5447 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 96)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 96)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5448 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 97)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 97)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5449 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 98)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 98)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5450 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 99)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 99)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5451 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(100)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(100)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5452 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(101)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(101)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5453 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(102)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(102)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5454 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(103)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(103)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5455 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(104)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(104)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5456 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(105)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(105)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5457 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(106)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(106)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5458 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(107)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(107)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5459 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(108)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(108)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5460 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(109)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(109)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5461 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(110)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(110)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5462 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(111)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(111)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5463 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(112)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(112)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5464 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(113)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(113)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5465 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(114)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(114)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5466 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(115)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(115)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5467 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(116)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(116)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5468 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(117)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(117)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5469 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(118)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(118)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5470 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(119)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(119)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5471 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(120)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(120)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5472 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(121)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(121)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5473 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(122)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(122)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5474 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(123)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(123)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5475 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(124)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(124)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5476 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(125)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(125)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5477 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(126)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(126)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5478 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(127)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(127)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5479 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(128)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(128)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5480 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(129)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(129)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5481 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(130)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(130)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5482 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(131)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(131)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5483 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(132)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(132)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5484 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(133)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(133)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5485 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(134)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(134)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5486 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(135)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(135)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5487 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(136)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(136)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5488 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(137)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(137)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5489 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(138)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(138)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5490 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(139)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(139)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5491 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(140)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(140)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5492 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(141)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(141)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5493 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(142)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(142)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5494 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(143)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(143)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5495 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(144)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(144)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5496 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(145)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(145)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5497 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(146)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(146)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5498 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(147)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(147)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5499 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(148)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(148)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5500 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(149)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(149)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5501 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(150)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(150)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5502 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(151)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(151)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5503 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(152)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(152)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5504 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(153)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(153)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5505 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(154)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(154)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5506 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(155)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(155)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5507 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(156)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(156)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5508 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(157)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(157)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5509 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(158)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(158)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5510 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(159)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(159)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5511 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(160)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(160)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5512 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(161)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(161)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5513 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(162)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(162)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5514 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(163)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(163)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5515 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(164)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(164)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5516 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(165)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(165)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5517 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(166)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(166)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5518 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(167)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(167)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5519 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(168)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(168)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5520 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(169)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(169)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5521 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(170)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(170)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5522 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(171)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(171)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5523 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(172)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(172)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5524 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(173)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(173)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5525 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(174)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(174)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5526 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(175)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(175)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5527 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(176)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(176)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5528 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(177)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(177)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5529 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(178)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(178)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5530 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(179)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(179)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5531 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(180)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(180)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5532 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(181)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(181)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5533 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(182)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(182)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5534 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(183)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(183)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5535 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(184)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(184)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5536 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(185)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(185)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5537 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(186)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(186)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5538 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(187)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(187)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5539 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(188)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(188)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5540 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(189)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(189)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5541 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(190)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(190)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5542 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(191)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(191)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5543 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(192)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(192)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5544 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(193)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(193)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5545 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(194)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(194)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5546 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(195)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(195)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5547 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(196)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(196)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5548 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(197)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(197)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5549 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(198)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(198)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5550 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(199)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(199)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5551 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(200)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(200)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5552 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(201)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(201)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5553 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(202)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(202)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5554 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(203)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(203)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5555 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(204)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(204)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5556 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(205)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(205)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5557 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(206)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(206)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5558 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(207)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(207)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5559 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(208)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(208)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5560 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(209)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(209)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5561 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(210)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(210)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5562 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(211)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(211)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5563 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(212)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(212)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5564 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(213)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(213)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5565 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(214)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(214)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5566 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(215)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(215)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5567 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(216)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(216)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5568 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(217)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(217)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5569 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(218)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(218)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5570 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(219)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(219)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5571 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(220)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(220)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5572 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(221)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(221)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5573 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(222)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(222)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5574 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(223)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(223)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5575 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(224)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(224)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5576 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(225)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(225)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5577 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(226)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(226)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5578 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(227)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(227)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5579 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(228)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(228)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5580 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(229)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(229)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5581 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(230)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(230)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5582 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(231)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(231)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5583 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(232)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(232)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5584 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(233)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(233)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5585 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(234)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(234)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5586 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(235)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(235)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5587 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(236)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(236)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5588 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(237)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(237)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5589 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(238)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(238)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5590 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(239)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(239)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5591 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(240)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(240)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5592 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(241)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(241)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5593 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(242)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(242)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5594 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(243)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(243)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5595 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(244)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(244)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5596 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(245)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(245)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5597 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(246)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(246)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5598 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(247)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(247)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5599 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(248)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(248)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5600 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(249)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(249)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5601 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(250)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(250)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5602 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(251)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(251)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5603 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(252)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(252)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5604 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(253)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(253)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5605 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(254)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(254)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5606 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5607 { STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5608 { STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5609 { STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5610 { STATE_TEXTURESTAGE(3, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(3, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5611 { STATE_TEXTURESTAGE(4, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(4, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5612 { STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5613 { STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5614 { STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5615 { STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5616 { STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5617 { STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5618 { STATE_TEXTURESTAGE(3, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5619 { STATE_TEXTURESTAGE(4, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5620 { STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5621 { STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5622 { STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5624 { STATE_RENDER(WINED3D_RS_FOGENABLE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), state_fog_vertexpart
}, WINED3D_GL_EXT_NONE
},
5625 { STATE_RENDER(WINED3D_RS_FOGTABLEMODE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5626 { STATE_RENDER(WINED3D_RS_FOGVERTEXMODE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5627 { STATE_RENDER(WINED3D_RS_RANGEFOGENABLE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5628 { STATE_RENDER(WINED3D_RS_CLIPPING
), { STATE_RENDER(WINED3D_RS_CLIPPING
), state_clipping
}, WINED3D_GL_EXT_NONE
},
5629 { STATE_RENDER(WINED3D_RS_CLIPPLANEENABLE
), { STATE_RENDER(WINED3D_RS_CLIPPING
), NULL
}, WINED3D_GL_EXT_NONE
},
5630 { STATE_RENDER(WINED3D_RS_LIGHTING
), { STATE_RENDER(WINED3D_RS_LIGHTING
), state_lighting
}, WINED3D_GL_EXT_NONE
},
5631 { STATE_RENDER(WINED3D_RS_AMBIENT
), { STATE_RENDER(WINED3D_RS_AMBIENT
), state_ambient
}, WINED3D_GL_EXT_NONE
},
5632 { STATE_RENDER(WINED3D_RS_COLORVERTEX
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), state_colormat
}, WINED3D_GL_EXT_NONE
},
5633 { STATE_RENDER(WINED3D_RS_LOCALVIEWER
), { STATE_RENDER(WINED3D_RS_LOCALVIEWER
), state_localviewer
}, WINED3D_GL_EXT_NONE
},
5634 { STATE_RENDER(WINED3D_RS_NORMALIZENORMALS
), { STATE_RENDER(WINED3D_RS_NORMALIZENORMALS
), state_normalize
}, WINED3D_GL_EXT_NONE
},
5635 { STATE_RENDER(WINED3D_RS_DIFFUSEMATERIALSOURCE
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), NULL
}, WINED3D_GL_EXT_NONE
},
5636 { STATE_RENDER(WINED3D_RS_SPECULARMATERIALSOURCE
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), NULL
}, WINED3D_GL_EXT_NONE
},
5637 { STATE_RENDER(WINED3D_RS_AMBIENTMATERIALSOURCE
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), NULL
}, WINED3D_GL_EXT_NONE
},
5638 { STATE_RENDER(WINED3D_RS_EMISSIVEMATERIALSOURCE
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), NULL
}, WINED3D_GL_EXT_NONE
},
5639 { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), state_vertexblend
}, ARB_VERTEX_BLEND
},
5640 { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), state_vertexblend_w
}, WINED3D_GL_EXT_NONE
},
5641 { STATE_RENDER(WINED3D_RS_POINTSIZE
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5642 { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), state_psizemin_arb
}, ARB_POINT_PARAMETERS
},
5643 { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), state_psizemin_ext
}, EXT_POINT_PARAMETERS
},
5644 { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), state_psizemin_w
}, WINED3D_GL_EXT_NONE
},
5645 { STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE
), { STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE
), state_pointsprite
}, ARB_POINT_SPRITE
},
5646 { STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE
), { STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE
), state_pointsprite_w
}, WINED3D_GL_EXT_NONE
},
5647 { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), state_pscale
}, WINED3D_GL_EXT_NONE
},
5648 { STATE_RENDER(WINED3D_RS_POINTSCALE_A
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5649 { STATE_RENDER(WINED3D_RS_POINTSCALE_B
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5650 { STATE_RENDER(WINED3D_RS_POINTSCALE_C
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5651 { STATE_RENDER(WINED3D_RS_POINTSIZE_MAX
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), NULL
}, ARB_POINT_PARAMETERS
},
5652 { STATE_RENDER(WINED3D_RS_POINTSIZE_MAX
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), NULL
}, EXT_POINT_PARAMETERS
},
5653 { STATE_RENDER(WINED3D_RS_POINTSIZE_MAX
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), NULL
}, WINED3D_GL_EXT_NONE
},
5654 { STATE_RENDER(WINED3D_RS_TWEENFACTOR
), { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), NULL
}, WINED3D_GL_EXT_NONE
},
5655 { STATE_RENDER(WINED3D_RS_INDEXEDVERTEXBLENDENABLE
), { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), NULL
}, WINED3D_GL_EXT_NONE
},
5657 /* Samplers for NP2 texture matrix adjustions. They are not needed if GL_ARB_texture_non_power_of_two is supported,
5658 * so register a NULL state handler in that case to get the vertex part of sampler() skipped(VTF is handled in the misc states.
5659 * otherwise, register sampler_texmatrix, which takes care of updating the texture matrix
5661 { STATE_SAMPLER(0), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5662 { STATE_SAMPLER(0), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5663 { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5664 { STATE_SAMPLER(1), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5665 { STATE_SAMPLER(1), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5666 { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5667 { STATE_SAMPLER(2), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5668 { STATE_SAMPLER(2), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5669 { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5670 { STATE_SAMPLER(3), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5671 { STATE_SAMPLER(3), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5672 { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5673 { STATE_SAMPLER(4), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5674 { STATE_SAMPLER(4), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5675 { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5676 { STATE_SAMPLER(5), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5677 { STATE_SAMPLER(5), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5678 { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5679 { STATE_SAMPLER(6), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5680 { STATE_SAMPLER(6), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5681 { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5682 { STATE_SAMPLER(7), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5683 { STATE_SAMPLER(7), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5684 { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5685 { STATE_POINT_SIZE_ENABLE
, { STATE_POINT_SIZE_ENABLE
, state_nop
}, WINED3D_GL_EXT_NONE
},
5686 {0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE
},
5689 static const struct StateEntryTemplate ffp_fragmentstate_template
[] = {
5690 { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5691 { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5692 { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5693 { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5694 { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5695 { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5696 { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5697 { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5698 { STATE_TEXTURESTAGE(0, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5699 { STATE_TEXTURESTAGE(0, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5700 { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5701 { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5702 { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5703 { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5704 { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5705 { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5706 { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5707 { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5708 { STATE_TEXTURESTAGE(1, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5709 { STATE_TEXTURESTAGE(1, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5710 { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5711 { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5712 { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5713 { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5714 { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5715 { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5716 { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5717 { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5718 { STATE_TEXTURESTAGE(2, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5719 { STATE_TEXTURESTAGE(2, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5720 { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5721 { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5722 { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5723 { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5724 { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5725 { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5726 { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5727 { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5728 { STATE_TEXTURESTAGE(3, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5729 { STATE_TEXTURESTAGE(3, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5730 { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5731 { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5732 { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5733 { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5734 { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5735 { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5736 { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5737 { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5738 { STATE_TEXTURESTAGE(4, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5739 { STATE_TEXTURESTAGE(4, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5740 { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5741 { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5742 { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5743 { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5744 { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5745 { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5746 { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5747 { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5748 { STATE_TEXTURESTAGE(5, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5749 { STATE_TEXTURESTAGE(5, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5750 { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5751 { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5752 { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5753 { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5754 { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5755 { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5756 { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5757 { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5758 { STATE_TEXTURESTAGE(6, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5759 { STATE_TEXTURESTAGE(6, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5760 { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5761 { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5762 { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5763 { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5764 { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5765 { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5766 { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5767 { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5768 { STATE_TEXTURESTAGE(7, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5769 { STATE_TEXTURESTAGE(7, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5770 { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
), apply_pixelshader
}, WINED3D_GL_EXT_NONE
},
5771 { STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE
), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
), NULL
}, WINED3D_GL_EXT_NONE
},
5772 { STATE_RENDER(WINED3D_RS_TEXTUREFACTOR
), { STATE_RENDER(WINED3D_RS_TEXTUREFACTOR
), state_texfactor
}, WINED3D_GL_EXT_NONE
},
5773 { STATE_RENDER(WINED3D_RS_FOGCOLOR
), { STATE_RENDER(WINED3D_RS_FOGCOLOR
), state_fogcolor
}, WINED3D_GL_EXT_NONE
},
5774 { STATE_RENDER(WINED3D_RS_FOGDENSITY
), { STATE_RENDER(WINED3D_RS_FOGDENSITY
), state_fogdensity
}, WINED3D_GL_EXT_NONE
},
5775 { STATE_RENDER(WINED3D_RS_FOGENABLE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), state_fog_fragpart
}, WINED3D_GL_EXT_NONE
},
5776 { STATE_RENDER(WINED3D_RS_FOGTABLEMODE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5777 { STATE_RENDER(WINED3D_RS_FOGVERTEXMODE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5778 { STATE_RENDER(WINED3D_RS_FOGSTART
), { STATE_RENDER(WINED3D_RS_FOGSTART
), state_fogstartend
}, WINED3D_GL_EXT_NONE
},
5779 { STATE_RENDER(WINED3D_RS_FOGEND
), { STATE_RENDER(WINED3D_RS_FOGSTART
), NULL
}, WINED3D_GL_EXT_NONE
},
5780 { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5781 { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5782 { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5783 { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5784 { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5785 { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5786 { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5787 { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5788 {0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE
},
5791 /* Context activation is done by the caller. */
5792 static void ffp_enable(const struct wined3d_gl_info
*gl_info
, BOOL enable
) {}
5794 static void *ffp_alloc(const struct wined3d_shader_backend_ops
*shader_backend
, void *shader_priv
)
5799 static void ffp_free(struct wined3d_device
*device
) {}
5801 static void vp_ffp_get_caps(const struct wined3d_gl_info
*gl_info
, struct wined3d_vertex_caps
*caps
)
5803 caps
->xyzrhw
= FALSE
;
5804 caps
->max_active_lights
= gl_info
->limits
.lights
;
5805 caps
->max_vertex_blend_matrices
= gl_info
->limits
.blends
;
5806 caps
->max_vertex_blend_matrix_index
= 0;
5807 caps
->vertex_processing_caps
= WINED3DVTXPCAPS_DIRECTIONALLIGHTS
5808 | WINED3DVTXPCAPS_MATERIALSOURCE7
5809 | WINED3DVTXPCAPS_POSITIONALLIGHTS
5810 | WINED3DVTXPCAPS_LOCALVIEWER
5811 | WINED3DVTXPCAPS_VERTEXFOG
5812 | WINED3DVTXPCAPS_TEXGEN
5813 | WINED3DVTXPCAPS_TEXGEN_SPHEREMAP
;
5814 caps
->fvf_caps
= WINED3DFVFCAPS_PSIZE
| 0x0008; /* 8 texture coords */
5815 caps
->max_user_clip_planes
= gl_info
->limits
.clipplanes
;
5816 caps
->raster_caps
= 0;
5817 if (gl_info
->supported
[NV_FOG_DISTANCE
])
5818 caps
->raster_caps
|= WINED3DPRASTERCAPS_FOGRANGE
;
5821 const struct wined3d_vertex_pipe_ops ffp_vertex_pipe
=
5830 static void ffp_fragment_get_caps(const struct wined3d_gl_info
*gl_info
, struct fragment_caps
*caps
)
5832 caps
->wined3d_caps
= 0;
5833 caps
->PrimitiveMiscCaps
= 0;
5834 caps
->TextureOpCaps
= WINED3DTEXOPCAPS_ADD
5835 | WINED3DTEXOPCAPS_ADDSIGNED
5836 | WINED3DTEXOPCAPS_ADDSIGNED2X
5837 | WINED3DTEXOPCAPS_MODULATE
5838 | WINED3DTEXOPCAPS_MODULATE2X
5839 | WINED3DTEXOPCAPS_MODULATE4X
5840 | WINED3DTEXOPCAPS_SELECTARG1
5841 | WINED3DTEXOPCAPS_SELECTARG2
5842 | WINED3DTEXOPCAPS_DISABLE
;
5844 if (gl_info
->supported
[ARB_TEXTURE_ENV_COMBINE
]
5845 || gl_info
->supported
[EXT_TEXTURE_ENV_COMBINE
]
5846 || gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
5848 caps
->TextureOpCaps
|= WINED3DTEXOPCAPS_BLENDDIFFUSEALPHA
5849 | WINED3DTEXOPCAPS_BLENDTEXTUREALPHA
5850 | WINED3DTEXOPCAPS_BLENDFACTORALPHA
5851 | WINED3DTEXOPCAPS_BLENDCURRENTALPHA
5852 | WINED3DTEXOPCAPS_LERP
5853 | WINED3DTEXOPCAPS_SUBTRACT
;
5855 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
]
5856 || gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
5858 caps
->TextureOpCaps
|= WINED3DTEXOPCAPS_ADDSMOOTH
5859 | WINED3DTEXOPCAPS_MULTIPLYADD
5860 | WINED3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR
5861 | WINED3DTEXOPCAPS_MODULATECOLOR_ADDALPHA
5862 | WINED3DTEXOPCAPS_BLENDTEXTUREALPHAPM
;
5864 if (gl_info
->supported
[ARB_TEXTURE_ENV_DOT3
])
5865 caps
->TextureOpCaps
|= WINED3DTEXOPCAPS_DOTPRODUCT3
;
5867 caps
->MaxTextureBlendStages
= gl_info
->limits
.textures
;
5868 caps
->MaxSimultaneousTextures
= gl_info
->limits
.textures
;
5871 static BOOL
ffp_color_fixup_supported(struct color_fixup_desc fixup
)
5875 TRACE("Checking support for fixup:\n");
5876 dump_color_fixup_desc(fixup
);
5879 /* We only support identity conversions. */
5880 if (is_identity_fixup(fixup
))
5886 TRACE("[FAILED]\n");
5890 const struct fragment_pipeline ffp_fragment_pipeline
= {
5892 ffp_fragment_get_caps
,
5895 ffp_color_fixup_supported
,
5896 ffp_fragmentstate_template
,
5899 static void none_enable(const struct wined3d_gl_info
*gl_info
, BOOL enable
) {}
5901 static void *none_alloc(const struct wined3d_shader_backend_ops
*shader_backend
, void *shader_priv
)
5906 static void none_free(struct wined3d_device
*device
) {}
5908 static void vp_none_get_caps(const struct wined3d_gl_info
*gl_info
, struct wined3d_vertex_caps
*caps
)
5910 memset(caps
, 0, sizeof(*caps
));
5913 const struct wined3d_vertex_pipe_ops none_vertex_pipe
=
5922 static void fp_none_get_caps(const struct wined3d_gl_info
*gl_info
, struct fragment_caps
*caps
)
5924 memset(caps
, 0, sizeof(*caps
));
5927 static BOOL
fp_none_color_fixup_supported(struct color_fixup_desc fixup
)
5929 return is_identity_fixup(fixup
);
5932 const struct fragment_pipeline none_fragment_pipe
=
5938 fp_none_color_fixup_supported
,
5942 static unsigned int num_handlers(const APPLYSTATEFUNC
*funcs
)
5945 for(i
= 0; funcs
[i
]; i
++);
5949 static void multistate_apply_2(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
5951 context
->swapchain
->device
->multistate_funcs
[state_id
][0](context
, state
, state_id
);
5952 context
->swapchain
->device
->multistate_funcs
[state_id
][1](context
, state
, state_id
);
5955 static void multistate_apply_3(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
5957 context
->swapchain
->device
->multistate_funcs
[state_id
][0](context
, state
, state_id
);
5958 context
->swapchain
->device
->multistate_funcs
[state_id
][1](context
, state
, state_id
);
5959 context
->swapchain
->device
->multistate_funcs
[state_id
][2](context
, state
, state_id
);
5962 static void prune_invalid_states(struct StateEntry
*state_table
, const struct wined3d_gl_info
*gl_info
,
5963 const struct wined3d_d3d_info
*d3d_info
)
5965 unsigned int start
, last
, i
;
5967 start
= STATE_TEXTURESTAGE(d3d_info
->limits
.ffp_blend_stages
, 0);
5968 last
= STATE_TEXTURESTAGE(MAX_TEXTURES
- 1, WINED3D_HIGHEST_TEXTURE_STATE
);
5969 for (i
= start
; i
<= last
; ++i
)
5971 state_table
[i
].representative
= 0;
5972 state_table
[i
].apply
= state_undefined
;
5975 start
= STATE_TRANSFORM(WINED3D_TS_TEXTURE0
+ d3d_info
->limits
.ffp_blend_stages
);
5976 last
= STATE_TRANSFORM(WINED3D_TS_TEXTURE0
+ MAX_TEXTURES
- 1);
5977 for (i
= start
; i
<= last
; ++i
)
5979 state_table
[i
].representative
= 0;
5980 state_table
[i
].apply
= state_undefined
;
5983 start
= STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(gl_info
->limits
.blends
));
5984 last
= STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255));
5985 for (i
= start
; i
<= last
; ++i
)
5987 state_table
[i
].representative
= 0;
5988 state_table
[i
].apply
= state_undefined
;
5992 static void validate_state_table(struct StateEntry
*state_table
)
6014 static const DWORD simple_states
[] =
6020 STATE_SHADER(WINED3D_SHADER_TYPE_VERTEX
),
6021 STATE_SHADER(WINED3D_SHADER_TYPE_GEOMETRY
),
6022 STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
),
6023 STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX
),
6024 STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY
),
6025 STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL
),
6026 STATE_SHADER_RESOURCE_BINDING
,
6031 STATE_POINTSPRITECOORDORIGIN
,
6032 STATE_BASEVERTEXINDEX
,
6034 STATE_POINT_SIZE_ENABLE
,
6036 unsigned int i
, current
;
6038 for (i
= STATE_RENDER(1), current
= 0; i
<= STATE_RENDER(WINEHIGHEST_RENDER_STATE
); ++i
)
6040 if (!rs_holes
[current
].first
|| i
< STATE_RENDER(rs_holes
[current
].first
))
6042 if (!state_table
[i
].representative
)
6043 ERR("State %s (%#x) should have a representative.\n", debug_d3dstate(i
), i
);
6045 else if (state_table
[i
].representative
)
6046 ERR("State %s (%#x) shouldn't have a representative.\n", debug_d3dstate(i
), i
);
6048 if (i
== STATE_RENDER(rs_holes
[current
].last
)) ++current
;
6051 for (i
= 0; i
< sizeof(simple_states
) / sizeof(*simple_states
); ++i
)
6053 if (!state_table
[simple_states
[i
]].representative
)
6054 ERR("State %s (%#x) should have a representative.\n",
6055 debug_d3dstate(simple_states
[i
]), simple_states
[i
]);
6058 for (i
= 0; i
< STATE_HIGHEST
+ 1; ++i
)
6060 DWORD rep
= state_table
[i
].representative
;
6063 if (state_table
[rep
].representative
!= rep
)
6065 ERR("State %s (%#x) has invalid representative %s (%#x).\n",
6066 debug_d3dstate(i
), i
, debug_d3dstate(rep
), rep
);
6067 state_table
[i
].representative
= 0;
6072 if (state_table
[i
].apply
)
6073 ERR("State %s (%#x) has both a handler and representative.\n", debug_d3dstate(i
), i
);
6075 else if (!state_table
[i
].apply
)
6077 ERR("Self representing state %s (%#x) has no handler.\n", debug_d3dstate(i
), i
);
6083 HRESULT
compile_state_table(struct StateEntry
*StateTable
, APPLYSTATEFUNC
**dev_multistate_funcs
,
6084 const struct wined3d_gl_info
*gl_info
, const struct wined3d_d3d_info
*d3d_info
,
6085 const struct wined3d_vertex_pipe_ops
*vertex
, const struct fragment_pipeline
*fragment
,
6086 const struct StateEntryTemplate
*misc
)
6088 unsigned int i
, type
, handlers
;
6089 APPLYSTATEFUNC multistate_funcs
[STATE_HIGHEST
+ 1][3];
6090 const struct StateEntryTemplate
*cur
;
6091 BOOL set
[STATE_HIGHEST
+ 1];
6093 memset(multistate_funcs
, 0, sizeof(multistate_funcs
));
6095 for(i
= 0; i
< STATE_HIGHEST
+ 1; i
++) {
6096 StateTable
[i
].representative
= 0;
6097 StateTable
[i
].apply
= state_undefined
;
6100 for(type
= 0; type
< 3; type
++) {
6101 /* This switch decides the order in which the states are applied */
6103 case 0: cur
= misc
; break;
6104 case 1: cur
= fragment
->states
; break;
6105 case 2: cur
= vertex
->vp_states
; break;
6106 default: cur
= NULL
; /* Stupid compiler */
6110 /* GL extension filtering should not prevent multiple handlers being applied from different
6113 memset(set
, 0, sizeof(set
));
6115 for(i
= 0; cur
[i
].state
; i
++) {
6116 APPLYSTATEFUNC
*funcs_array
;
6118 /* Only use the first matching state with the available extension from one template.
6120 * {D3DRS_FOOBAR, {D3DRS_FOOBAR, func1}, XYZ_FANCY},
6121 * {D3DRS_FOOBAR, {D3DRS_FOOBAR, func2}, 0 }
6123 * if GL_XYZ_fancy is supported, ignore the 2nd line
6125 if(set
[cur
[i
].state
]) continue;
6126 /* Skip state lines depending on unsupported extensions */
6127 if (!gl_info
->supported
[cur
[i
].extension
]) continue;
6128 set
[cur
[i
].state
] = TRUE
;
6129 /* In some cases having an extension means that nothing has to be
6130 * done for a state, e.g. if GL_ARB_texture_non_power_of_two is
6131 * supported, the texture coordinate fixup can be ignored. If the
6132 * apply function is used, mark the state set(done above) to prevent
6133 * applying later lines, but do not record anything in the state
6136 if (!cur
[i
].content
.representative
) continue;
6138 handlers
= num_handlers(multistate_funcs
[cur
[i
].state
]);
6139 multistate_funcs
[cur
[i
].state
][handlers
] = cur
[i
].content
.apply
;
6142 StateTable
[cur
[i
].state
].apply
= cur
[i
].content
.apply
;
6145 StateTable
[cur
[i
].state
].apply
= multistate_apply_2
;
6146 dev_multistate_funcs
[cur
[i
].state
] = HeapAlloc(GetProcessHeap(),
6148 sizeof(**dev_multistate_funcs
) * 2);
6149 if (!dev_multistate_funcs
[cur
[i
].state
]) {
6153 dev_multistate_funcs
[cur
[i
].state
][0] = multistate_funcs
[cur
[i
].state
][0];
6154 dev_multistate_funcs
[cur
[i
].state
][1] = multistate_funcs
[cur
[i
].state
][1];
6157 StateTable
[cur
[i
].state
].apply
= multistate_apply_3
;
6158 funcs_array
= HeapReAlloc(GetProcessHeap(),
6160 dev_multistate_funcs
[cur
[i
].state
],
6161 sizeof(**dev_multistate_funcs
) * 3);
6166 dev_multistate_funcs
[cur
[i
].state
] = funcs_array
;
6167 dev_multistate_funcs
[cur
[i
].state
][2] = multistate_funcs
[cur
[i
].state
][2];
6170 ERR("Unexpected amount of state handlers for state %u: %u\n",
6171 cur
[i
].state
, handlers
+ 1);
6174 if (StateTable
[cur
[i
].state
].representative
6175 && StateTable
[cur
[i
].state
].representative
!= cur
[i
].content
.representative
)
6177 FIXME("State %s (%#x) has different representatives in different pipeline parts.\n",
6178 debug_d3dstate(cur
[i
].state
), cur
[i
].state
);
6180 StateTable
[cur
[i
].state
].representative
= cur
[i
].content
.representative
;
6184 prune_invalid_states(StateTable
, gl_info
, d3d_info
);
6185 validate_state_table(StateTable
);
6190 for (i
= 0; i
<= STATE_HIGHEST
; ++i
) {
6191 HeapFree(GetProcessHeap(), 0, dev_multistate_funcs
[i
]);
6194 memset(dev_multistate_funcs
, 0, (STATE_HIGHEST
+ 1)*sizeof(*dev_multistate_funcs
));
6196 return E_OUTOFMEMORY
;