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
);
40 ULONG CDECL
wined3d_blend_state_incref(struct wined3d_blend_state
*state
)
42 ULONG refcount
= InterlockedIncrement(&state
->refcount
);
44 TRACE("%p increasing refcount to %u.\n", state
, refcount
);
49 static void wined3d_blend_state_destroy_object(void *object
)
51 TRACE("object %p.\n", object
);
56 ULONG CDECL
wined3d_blend_state_decref(struct wined3d_blend_state
*state
)
58 ULONG refcount
= InterlockedDecrement(&state
->refcount
);
59 struct wined3d_device
*device
= state
->device
;
61 TRACE("%p decreasing refcount to %u.\n", state
, refcount
);
65 state
->parent_ops
->wined3d_object_destroyed(state
->parent
);
66 wined3d_cs_destroy_object(device
->cs
, wined3d_blend_state_destroy_object
, state
);
72 void * CDECL
wined3d_blend_state_get_parent(const struct wined3d_blend_state
*state
)
74 TRACE("state %p.\n", state
);
79 static BOOL
is_dual_source(enum wined3d_blend state
)
81 return state
>= WINED3D_BLEND_SRC1COLOR
&& state
<= WINED3D_BLEND_INVSRC1ALPHA
;
84 HRESULT CDECL
wined3d_blend_state_create(struct wined3d_device
*device
,
85 const struct wined3d_blend_state_desc
*desc
, void *parent
,
86 const struct wined3d_parent_ops
*parent_ops
, struct wined3d_blend_state
**state
)
88 struct wined3d_blend_state
*object
;
90 TRACE("device %p, desc %p, parent %p, parent_ops %p, state %p.\n",
91 device
, desc
, parent
, parent_ops
, state
);
93 if (!(object
= heap_alloc_zero(sizeof(*object
))))
98 object
->parent
= parent
;
99 object
->parent_ops
= parent_ops
;
100 object
->device
= device
;
102 object
->dual_source
= desc
->rt
[0].enable
103 && (is_dual_source(desc
->rt
[0].src
)
104 || is_dual_source(desc
->rt
[0].dst
)
105 || is_dual_source(desc
->rt
[0].src_alpha
)
106 || is_dual_source(desc
->rt
[0].dst_alpha
));
108 TRACE("Created blend state %p.\n", object
);
114 ULONG CDECL
wined3d_depth_stencil_state_incref(struct wined3d_depth_stencil_state
*state
)
116 ULONG refcount
= InterlockedIncrement(&state
->refcount
);
118 TRACE("%p increasing refcount to %u.\n", state
, refcount
);
123 static void wined3d_depth_stencil_state_destroy_object(void *object
)
125 TRACE("object %p.\n", object
);
130 ULONG CDECL
wined3d_depth_stencil_state_decref(struct wined3d_depth_stencil_state
*state
)
132 ULONG refcount
= InterlockedDecrement(&state
->refcount
);
133 struct wined3d_device
*device
= state
->device
;
135 TRACE("%p decreasing refcount to %u.\n", state
, refcount
);
139 state
->parent_ops
->wined3d_object_destroyed(state
->parent
);
140 wined3d_cs_destroy_object(device
->cs
, wined3d_depth_stencil_state_destroy_object
, state
);
146 void * CDECL
wined3d_depth_stencil_state_get_parent(const struct wined3d_depth_stencil_state
*state
)
148 TRACE("state %p.\n", state
);
150 return state
->parent
;
153 HRESULT CDECL
wined3d_depth_stencil_state_create(struct wined3d_device
*device
,
154 const struct wined3d_depth_stencil_state_desc
*desc
, void *parent
,
155 const struct wined3d_parent_ops
*parent_ops
, struct wined3d_depth_stencil_state
**state
)
157 struct wined3d_depth_stencil_state
*object
;
159 TRACE("device %p, desc %p, parent %p, parent_ops %p, state %p.\n",
160 device
, desc
, parent
, parent_ops
, state
);
162 if (!(object
= heap_alloc_zero(sizeof(*object
))))
163 return E_OUTOFMEMORY
;
165 object
->refcount
= 1;
166 object
->desc
= *desc
;
167 object
->parent
= parent
;
168 object
->parent_ops
= parent_ops
;
169 object
->device
= device
;
171 TRACE("Created depth/stencil state %p.\n", object
);
177 ULONG CDECL
wined3d_rasterizer_state_incref(struct wined3d_rasterizer_state
*state
)
179 ULONG refcount
= InterlockedIncrement(&state
->refcount
);
181 TRACE("%p increasing refcount to %u.\n", state
, refcount
);
186 static void wined3d_rasterizer_state_destroy_object(void *object
)
188 TRACE("object %p.\n", object
);
193 ULONG CDECL
wined3d_rasterizer_state_decref(struct wined3d_rasterizer_state
*state
)
195 ULONG refcount
= InterlockedDecrement(&state
->refcount
);
196 struct wined3d_device
*device
= state
->device
;
198 TRACE("%p decreasing refcount to %u.\n", state
, refcount
);
202 state
->parent_ops
->wined3d_object_destroyed(state
->parent
);
203 wined3d_cs_destroy_object(device
->cs
, wined3d_rasterizer_state_destroy_object
, state
);
209 void * CDECL
wined3d_rasterizer_state_get_parent(const struct wined3d_rasterizer_state
*state
)
211 TRACE("rasterizer_state %p.\n", state
);
213 return state
->parent
;
216 HRESULT CDECL
wined3d_rasterizer_state_create(struct wined3d_device
*device
,
217 const struct wined3d_rasterizer_state_desc
*desc
, void *parent
,
218 const struct wined3d_parent_ops
*parent_ops
, struct wined3d_rasterizer_state
**state
)
220 struct wined3d_rasterizer_state
*object
;
222 TRACE("device %p, desc %p, parent %p, parent_ops %p, state %p.\n",
223 device
, desc
, parent
, parent_ops
, state
);
225 if (!(object
= heap_alloc_zero(sizeof(*object
))))
226 return E_OUTOFMEMORY
;
228 object
->refcount
= 1;
229 object
->desc
= *desc
;
230 object
->parent
= parent
;
231 object
->parent_ops
= parent_ops
;
232 object
->device
= device
;
234 TRACE("Created rasterizer state %p.\n", object
);
240 /* Context activation for state handler is done by the caller. */
242 static void state_undefined(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
244 ERR("Undefined state %s (%#x).\n", debug_d3dstate(state_id
), state_id
);
247 void state_nop(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
249 TRACE("%s: nop in current pipe config.\n", debug_d3dstate(state_id
));
252 static void fillmode(const struct wined3d_rasterizer_state
*r
, const struct wined3d_gl_info
*gl_info
)
254 enum wined3d_fill_mode mode
= r
? r
->desc
.fill_mode
: WINED3D_FILL_SOLID
;
258 case WINED3D_FILL_POINT
:
259 gl_info
->gl_ops
.gl
.p_glPolygonMode(GL_FRONT_AND_BACK
, GL_POINT
);
260 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_POINT)");
262 case WINED3D_FILL_WIREFRAME
:
263 gl_info
->gl_ops
.gl
.p_glPolygonMode(GL_FRONT_AND_BACK
, GL_LINE
);
264 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)");
266 case WINED3D_FILL_SOLID
:
267 gl_info
->gl_ops
.gl
.p_glPolygonMode(GL_FRONT_AND_BACK
, GL_FILL
);
268 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)");
271 FIXME("Unrecognized fill mode %#x.\n", mode
);
275 static void state_lighting(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
277 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
279 /* Lighting is not enabled if transformed vertices are drawn, but lighting
280 * does not affect the stream sources, so it is not grouped for
281 * performance reasons. */
283 if (state
->render_states
[WINED3D_RS_LIGHTING
]
284 && !context
->stream_info
.position_transformed
)
286 gl_info
->gl_ops
.gl
.p_glEnable(GL_LIGHTING
);
287 checkGLcall("glEnable GL_LIGHTING");
291 gl_info
->gl_ops
.gl
.p_glDisable(GL_LIGHTING
);
292 checkGLcall("glDisable GL_LIGHTING");
296 static void cullmode(const struct wined3d_rasterizer_state
*r
, const struct wined3d_gl_info
*gl_info
)
298 enum wined3d_cull mode
= r
? r
->desc
.cull_mode
: WINED3D_CULL_BACK
;
300 /* glFrontFace() is set in context.c at context init and on an
301 * offscreen / onscreen rendering switch. */
304 case WINED3D_CULL_NONE
:
305 gl_info
->gl_ops
.gl
.p_glDisable(GL_CULL_FACE
);
306 checkGLcall("glDisable GL_CULL_FACE");
308 case WINED3D_CULL_FRONT
:
309 gl_info
->gl_ops
.gl
.p_glEnable(GL_CULL_FACE
);
310 checkGLcall("glEnable GL_CULL_FACE");
311 gl_info
->gl_ops
.gl
.p_glCullFace(GL_FRONT
);
312 checkGLcall("glCullFace(GL_FRONT)");
314 case WINED3D_CULL_BACK
:
315 gl_info
->gl_ops
.gl
.p_glEnable(GL_CULL_FACE
);
316 checkGLcall("glEnable GL_CULL_FACE");
317 gl_info
->gl_ops
.gl
.p_glCullFace(GL_BACK
);
318 checkGLcall("glCullFace(GL_BACK)");
321 FIXME("Unrecognized cull mode %#x.\n", mode
);
325 void state_shademode(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
327 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
329 switch (state
->render_states
[WINED3D_RS_SHADEMODE
])
331 case WINED3D_SHADE_FLAT
:
332 gl_info
->gl_ops
.gl
.p_glShadeModel(GL_FLAT
);
333 checkGLcall("glShadeModel(GL_FLAT)");
335 case WINED3D_SHADE_GOURAUD
:
336 /* WINED3D_SHADE_PHONG in practice is the same as WINED3D_SHADE_GOURAUD
338 case WINED3D_SHADE_PHONG
:
339 gl_info
->gl_ops
.gl
.p_glShadeModel(GL_SMOOTH
);
340 checkGLcall("glShadeModel(GL_SMOOTH)");
343 FIXME("Unrecognized shade mode %#x.\n",
344 state
->render_states
[WINED3D_RS_SHADEMODE
]);
348 static void state_ditherenable(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
350 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
352 if (state
->render_states
[WINED3D_RS_DITHERENABLE
])
354 gl_info
->gl_ops
.gl
.p_glEnable(GL_DITHER
);
355 checkGLcall("glEnable GL_DITHER");
359 gl_info
->gl_ops
.gl
.p_glDisable(GL_DITHER
);
360 checkGLcall("glDisable GL_DITHER");
364 GLenum
wined3d_gl_compare_func(enum wined3d_cmp_func f
)
368 case WINED3D_CMP_NEVER
:
370 case WINED3D_CMP_LESS
:
372 case WINED3D_CMP_EQUAL
:
374 case WINED3D_CMP_LESSEQUAL
:
376 case WINED3D_CMP_GREATER
:
378 case WINED3D_CMP_NOTEQUAL
:
380 case WINED3D_CMP_GREATEREQUAL
:
382 case WINED3D_CMP_ALWAYS
:
386 WARN("Unrecognized compare function %#x.\n", f
);
388 FIXME("Unrecognized compare function %#x.\n", f
);
393 static void state_ambient(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
395 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
396 struct wined3d_color color
;
398 wined3d_color_from_d3dcolor(&color
, state
->render_states
[WINED3D_RS_AMBIENT
]);
399 TRACE("Setting ambient to %s.\n", debug_color(&color
));
400 gl_info
->gl_ops
.gl
.p_glLightModelfv(GL_LIGHT_MODEL_AMBIENT
, &color
.r
);
401 checkGLcall("glLightModel for MODEL_AMBIENT");
404 static GLenum
gl_blend_op(const struct wined3d_gl_info
*gl_info
, enum wined3d_blend_op op
)
408 case WINED3D_BLEND_OP_ADD
:
410 case WINED3D_BLEND_OP_SUBTRACT
:
411 return gl_info
->supported
[EXT_BLEND_SUBTRACT
] ? GL_FUNC_SUBTRACT
: GL_FUNC_ADD
;
412 case WINED3D_BLEND_OP_REVSUBTRACT
:
413 return gl_info
->supported
[EXT_BLEND_SUBTRACT
] ? GL_FUNC_REVERSE_SUBTRACT
: GL_FUNC_ADD
;
414 case WINED3D_BLEND_OP_MIN
:
415 return gl_info
->supported
[EXT_BLEND_MINMAX
] ? GL_MIN
: GL_FUNC_ADD
;
416 case WINED3D_BLEND_OP_MAX
:
417 return gl_info
->supported
[EXT_BLEND_MINMAX
] ? GL_MAX
: GL_FUNC_ADD
;
420 WARN("Unhandled blend op %#x.\n", op
);
422 FIXME("Unhandled blend op %#x.\n", op
);
427 static void blendop(const struct wined3d_state
*state
, const struct wined3d_gl_info
*gl_info
)
429 const struct wined3d_blend_state
*b
= state
->blend_state
;
430 GLenum blend_equation_alpha
= GL_FUNC_ADD_EXT
;
431 GLenum blend_equation
= GL_FUNC_ADD_EXT
;
433 if (!gl_info
->supported
[WINED3D_GL_BLEND_EQUATION
])
435 WARN("Unsupported in local OpenGL implementation: glBlendEquation.\n");
439 /* BLENDOPALPHA requires GL_EXT_blend_equation_separate, so make sure it is around */
440 if (b
->desc
.rt
[0].op_alpha
&& !gl_info
->supported
[EXT_BLEND_EQUATION_SEPARATE
])
442 WARN("Unsupported in local OpenGL implementation: glBlendEquationSeparate.\n");
446 blend_equation
= gl_blend_op(gl_info
, b
->desc
.rt
[0].op
);
447 blend_equation_alpha
= gl_blend_op(gl_info
, b
->desc
.rt
[0].op_alpha
);
448 TRACE("blend_equation %#x, blend_equation_alpha %#x.\n", blend_equation
, blend_equation_alpha
);
450 if (b
->desc
.rt
[0].op
!= b
->desc
.rt
[0].op_alpha
)
452 GL_EXTCALL(glBlendEquationSeparate(blend_equation
, blend_equation_alpha
));
453 checkGLcall("glBlendEquationSeparate");
457 GL_EXTCALL(glBlendEquation(blend_equation
));
458 checkGLcall("glBlendEquation");
462 static GLenum
gl_blend_factor(enum wined3d_blend factor
, const struct wined3d_format
*dst_format
)
466 case WINED3D_BLEND_ZERO
:
468 case WINED3D_BLEND_ONE
:
470 case WINED3D_BLEND_SRCCOLOR
:
472 case WINED3D_BLEND_INVSRCCOLOR
:
473 return GL_ONE_MINUS_SRC_COLOR
;
474 case WINED3D_BLEND_SRCALPHA
:
476 case WINED3D_BLEND_INVSRCALPHA
:
477 return GL_ONE_MINUS_SRC_ALPHA
;
478 case WINED3D_BLEND_DESTCOLOR
:
480 case WINED3D_BLEND_INVDESTCOLOR
:
481 return GL_ONE_MINUS_DST_COLOR
;
482 /* To compensate for the lack of format switching with backbuffer
483 * offscreen rendering, and with onscreen rendering, we modify the
484 * alpha test parameters for (INV)DESTALPHA if the render target
485 * doesn't support alpha blending. A nonexistent alpha channel
486 * returns 1.0, so WINED3D_BLEND_DESTALPHA becomes GL_ONE, and
487 * WINED3D_BLEND_INVDESTALPHA becomes GL_ZERO. */
488 case WINED3D_BLEND_DESTALPHA
:
489 return dst_format
->alpha_size
? GL_DST_ALPHA
: GL_ONE
;
490 case WINED3D_BLEND_INVDESTALPHA
:
491 return dst_format
->alpha_size
? GL_ONE_MINUS_DST_ALPHA
: GL_ZERO
;
492 case WINED3D_BLEND_SRCALPHASAT
:
493 return GL_SRC_ALPHA_SATURATE
;
494 case WINED3D_BLEND_BLENDFACTOR
:
495 return GL_CONSTANT_COLOR_EXT
;
496 case WINED3D_BLEND_INVBLENDFACTOR
:
497 return GL_ONE_MINUS_CONSTANT_COLOR_EXT
;
498 case WINED3D_BLEND_SRC1COLOR
:
499 return GL_SRC1_COLOR
;
500 case WINED3D_BLEND_INVSRC1COLOR
:
501 return GL_ONE_MINUS_SRC1_COLOR
;
502 case WINED3D_BLEND_SRC1ALPHA
:
503 return GL_SRC1_ALPHA
;
504 case WINED3D_BLEND_INVSRC1ALPHA
:
505 return GL_ONE_MINUS_SRC1_ALPHA
;
508 WARN("Unhandled blend factor %#x.\n", factor
);
510 FIXME("Unhandled blend factor %#x.\n", factor
);
515 static void gl_blend_from_d3d(GLenum
*src_blend
, GLenum
*dst_blend
,
516 enum wined3d_blend d3d_src_blend
, enum wined3d_blend d3d_dst_blend
,
517 const struct wined3d_format
*rt_format
)
519 /* WINED3D_BLEND_BOTHSRCALPHA and WINED3D_BLEND_BOTHINVSRCALPHA are legacy
520 * source blending values which are still valid up to d3d9. They should
521 * not occur as dest blend values. */
522 if (d3d_src_blend
== WINED3D_BLEND_BOTHSRCALPHA
)
524 *src_blend
= GL_SRC_ALPHA
;
525 *dst_blend
= GL_ONE_MINUS_SRC_ALPHA
;
527 else if (d3d_src_blend
== WINED3D_BLEND_BOTHINVSRCALPHA
)
529 *src_blend
= GL_ONE_MINUS_SRC_ALPHA
;
530 *dst_blend
= GL_SRC_ALPHA
;
534 *src_blend
= gl_blend_factor(d3d_src_blend
, rt_format
);
535 *dst_blend
= gl_blend_factor(d3d_dst_blend
, rt_format
);
539 static void state_blend_factor_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
541 WARN("Unsupported in local OpenGL implementation: glBlendColor.\n");
544 static void state_blend_factor(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
546 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
547 const struct wined3d_color
*factor
= &state
->blend_factor
;
549 TRACE("Setting blend factor to %s.\n", debug_color(factor
));
551 GL_EXTCALL(glBlendColor(factor
->r
, factor
->g
, factor
->b
, factor
->a
));
552 checkGLcall("glBlendColor");
555 static BOOL
is_blend_enabled(struct wined3d_context
*context
, const struct wined3d_state
*state
, UINT index
)
557 const struct wined3d_blend_state
*b
= state
->blend_state
;
559 if (!state
->fb
.render_targets
[index
])
562 if (!b
->desc
.rt
[index
].enable
)
565 /* Disable blending in all cases even without pixel shaders.
566 * With blending on we could face a big performance penalty.
567 * The d3d9 visual test confirms the behavior. */
568 if (context
->render_offscreen
569 && !(state
->fb
.render_targets
[index
]->format_flags
& WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
))
575 static void blend(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
577 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
578 const struct wined3d_blend_state
*b
= state
->blend_state
;
579 const struct wined3d_format
*rt_format
;
580 GLenum src_blend
, dst_blend
;
583 if (gl_info
->supported
[ARB_MULTISAMPLE
])
585 if (b
&& b
->desc
.alpha_to_coverage
)
586 gl_info
->gl_ops
.gl
.p_glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE
);
588 gl_info
->gl_ops
.gl
.p_glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE
);
589 checkGLcall("glEnable GL_SAMPLE_ALPHA_TO_COVERAGE");
592 if (b
&& b
->desc
.independent
)
593 WARN("Independent blend is not supported by this GL implementation.\n");
595 mask
= b
? b
->desc
.rt
[0].writemask
: 0xf;
597 gl_info
->gl_ops
.gl
.p_glColorMask(mask
& WINED3DCOLORWRITEENABLE_RED
? GL_TRUE
: GL_FALSE
,
598 mask
& WINED3DCOLORWRITEENABLE_GREEN
? GL_TRUE
: GL_FALSE
,
599 mask
& WINED3DCOLORWRITEENABLE_BLUE
? GL_TRUE
: GL_FALSE
,
600 mask
& WINED3DCOLORWRITEENABLE_ALPHA
? GL_TRUE
: GL_FALSE
);
601 checkGLcall("glColorMask");
603 if (!b
|| !is_blend_enabled(context
, state
, 0))
605 gl_info
->gl_ops
.gl
.p_glDisable(GL_BLEND
);
606 checkGLcall("glDisable GL_BLEND");
610 gl_info
->gl_ops
.gl
.p_glEnable(GL_BLEND
);
611 checkGLcall("glEnable GL_BLEND");
613 rt_format
= state
->fb
.render_targets
[0]->format
;
615 gl_blend_from_d3d(&src_blend
, &dst_blend
, b
->desc
.rt
[0].src
, b
->desc
.rt
[0].dst
, rt_format
);
617 blendop(state
, gl_info
);
619 if (b
->desc
.rt
[0].src
!= b
->desc
.rt
[0].src_alpha
|| b
->desc
.rt
[0].dst
!= b
->desc
.rt
[0].dst_alpha
)
621 GLenum src_blend_alpha
, dst_blend_alpha
;
623 /* Separate alpha blending requires GL_EXT_blend_function_separate, so make sure it is around */
624 if (!gl_info
->supported
[EXT_BLEND_FUNC_SEPARATE
])
626 WARN("Unsupported in local OpenGL implementation: glBlendFuncSeparate.\n");
630 gl_blend_from_d3d(&src_blend_alpha
, &dst_blend_alpha
, b
->desc
.rt
[0].src_alpha
, b
->desc
.rt
[0].dst_alpha
, rt_format
);
632 GL_EXTCALL(glBlendFuncSeparate(src_blend
, dst_blend
, src_blend_alpha
, dst_blend_alpha
));
633 checkGLcall("glBlendFuncSeparate");
637 TRACE("glBlendFunc src=%x, dst=%x.\n", src_blend
, dst_blend
);
638 gl_info
->gl_ops
.gl
.p_glBlendFunc(src_blend
, dst_blend
);
639 checkGLcall("glBlendFunc");
642 /* Colorkey fixup for stage 0 alphaop depends on blend state, so it may need
644 if (state
->render_states
[WINED3D_RS_COLORKEYENABLE
])
645 context_apply_state(context
, state
, STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
));
648 static void set_color_mask(const struct wined3d_gl_info
*gl_info
, UINT index
, DWORD mask
)
650 GL_EXTCALL(glColorMaski(index
,
651 mask
& WINED3DCOLORWRITEENABLE_RED
? GL_TRUE
: GL_FALSE
,
652 mask
& WINED3DCOLORWRITEENABLE_GREEN
? GL_TRUE
: GL_FALSE
,
653 mask
& WINED3DCOLORWRITEENABLE_BLUE
? GL_TRUE
: GL_FALSE
,
654 mask
& WINED3DCOLORWRITEENABLE_ALPHA
? GL_TRUE
: GL_FALSE
));
655 checkGLcall("glColorMaski");
658 static void blend_db2(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
660 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
661 GLenum src_blend
, dst_blend
, src_blend_alpha
, dst_blend_alpha
;
662 const struct wined3d_blend_state
*b
= state
->blend_state
;
663 const struct wined3d_format
*rt_format
;
664 BOOL dual_source
= b
&& b
->dual_source
;
667 if (b
&& b
->desc
.alpha_to_coverage
)
668 gl_info
->gl_ops
.gl
.p_glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE
);
670 gl_info
->gl_ops
.gl
.p_glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE
);
671 checkGLcall("glEnable GL_SAMPLE_ALPHA_TO_COVERAGE");
673 if (context
->last_was_dual_source_blend
!= dual_source
)
675 /* Dual source blending changes the location of the output varyings. */
676 context
->shader_update_mask
|= 1u << WINED3D_SHADER_TYPE_PIXEL
;
677 context
->last_was_dual_source_blend
= dual_source
;
680 if (!b
|| !b
->desc
.independent
)
682 blend(context
, state
, state_id
);
686 rt_format
= state
->fb
.render_targets
[0]->format
;
687 gl_blend_from_d3d(&src_blend
, &dst_blend
, b
->desc
.rt
[0].src
, b
->desc
.rt
[0].dst
, rt_format
);
688 gl_blend_from_d3d(&src_blend_alpha
, &dst_blend_alpha
, b
->desc
.rt
[0].src_alpha
, b
->desc
.rt
[0].dst_alpha
, rt_format
);
690 GL_EXTCALL(glBlendFuncSeparate(src_blend
, dst_blend
, src_blend_alpha
, dst_blend_alpha
));
691 checkGLcall("glBlendFuncSeparate");
693 GL_EXTCALL(glBlendEquationSeparate(gl_blend_op(gl_info
, b
->desc
.rt
[0].op
),
694 gl_blend_op(gl_info
, b
->desc
.rt
[0].op_alpha
)));
695 checkGLcall("glBlendEquationSeparate");
697 for (i
= 0; i
< WINED3D_MAX_RENDER_TARGETS
; ++i
)
699 set_color_mask(gl_info
, i
, b
->desc
.rt
[i
].writemask
);
701 if (!is_blend_enabled(context
, state
, i
))
703 GL_EXTCALL(glDisablei(GL_BLEND
, i
));
704 checkGLcall("glDisablei GL_BLEND");
708 GL_EXTCALL(glEnablei(GL_BLEND
, i
));
709 checkGLcall("glEnablei GL_BLEND");
711 if (b
->desc
.rt
[i
].src
!= b
->desc
.rt
[0].src
712 || b
->desc
.rt
[i
].dst
!= b
->desc
.rt
[0].dst
713 || b
->desc
.rt
[i
].op
!= b
->desc
.rt
[0].op
714 || b
->desc
.rt
[i
].src_alpha
!= b
->desc
.rt
[0].src_alpha
715 || b
->desc
.rt
[i
].dst_alpha
!= b
->desc
.rt
[0].dst_alpha
716 || b
->desc
.rt
[i
].op_alpha
!= b
->desc
.rt
[0].op_alpha
)
717 WARN("Independent blend equations and blend functions are not supported by this GL implementation.\n");
720 /* Colorkey fixup for stage 0 alphaop depends on blend state, so it may need
722 if (state
->render_states
[WINED3D_RS_COLORKEYENABLE
])
723 context_apply_state(context
, state
, STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
));
726 static void blend_dbb(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
728 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
729 const struct wined3d_blend_state
*b
= state
->blend_state
;
730 BOOL dual_source
= b
&& b
->dual_source
;
733 if (b
&& b
->desc
.alpha_to_coverage
)
734 gl_info
->gl_ops
.gl
.p_glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE
);
736 gl_info
->gl_ops
.gl
.p_glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE
);
737 checkGLcall("glEnable GL_SAMPLE_ALPHA_TO_COVERAGE");
739 if (context
->last_was_dual_source_blend
!= dual_source
)
741 /* Dual source blending changes the location of the output varyings. */
742 context
->shader_update_mask
|= 1u << WINED3D_SHADER_TYPE_PIXEL
;
743 context
->last_was_dual_source_blend
= dual_source
;
746 if (!b
|| !b
->desc
.independent
)
748 blend(context
, state
, state_id
);
752 for (i
= 0; i
< WINED3D_MAX_RENDER_TARGETS
; ++i
)
754 GLenum src_blend
, dst_blend
, src_blend_alpha
, dst_blend_alpha
;
755 const struct wined3d_format
*rt_format
;
757 set_color_mask(gl_info
, i
, b
->desc
.rt
[i
].writemask
);
759 if (!is_blend_enabled(context
, state
, i
))
761 GL_EXTCALL(glDisablei(GL_BLEND
, i
));
762 checkGLcall("glDisablei GL_BLEND");
766 GL_EXTCALL(glEnablei(GL_BLEND
, i
));
767 checkGLcall("glEnablei GL_BLEND");
769 rt_format
= state
->fb
.render_targets
[i
]->format
;
770 gl_blend_from_d3d(&src_blend
, &dst_blend
, b
->desc
.rt
[i
].src
, b
->desc
.rt
[i
].dst
, rt_format
);
771 gl_blend_from_d3d(&src_blend_alpha
, &dst_blend_alpha
,
772 b
->desc
.rt
[i
].src_alpha
, b
->desc
.rt
[i
].dst_alpha
, rt_format
);
774 GL_EXTCALL(glBlendFuncSeparatei(i
, src_blend
, dst_blend
, src_blend_alpha
, dst_blend_alpha
));
775 checkGLcall("glBlendFuncSeparatei");
777 GL_EXTCALL(glBlendEquationSeparatei(i
, gl_blend_op(gl_info
, b
->desc
.rt
[i
].op
),
778 gl_blend_op(gl_info
, b
->desc
.rt
[i
].op_alpha
)));
779 checkGLcall("glBlendEquationSeparatei");
782 /* Colorkey fixup for stage 0 alphaop depends on blend state, so it may need
784 if (state
->render_states
[WINED3D_RS_COLORKEYENABLE
])
785 context_apply_state(context
, state
, STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
));
788 void state_alpha_test(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
790 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
793 BOOL enable_ckey
= FALSE
;
795 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
797 /* Find out if the texture on the first stage has a ckey set. The alpha
798 * state func reads the texture settings, even though alpha and texture
799 * are not grouped together. This is to avoid making a huge alpha +
800 * texture + texture stage + ckey block due to the hardly used
801 * WINED3D_RS_COLORKEYENABLE state(which is d3d <= 3 only). The texture
802 * function will call alpha in case it finds some texture + colorkeyenable
803 * combination which needs extra care. */
804 if (state
->textures
[0] && (state
->textures
[0]->async
.color_key_flags
& WINED3D_CKEY_SRC_BLT
))
807 if (enable_ckey
|| context
->last_was_ckey
)
808 context_apply_state(context
, state
, STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
));
809 context
->last_was_ckey
= enable_ckey
;
811 if (state
->render_states
[WINED3D_RS_ALPHATESTENABLE
]
812 || (state
->render_states
[WINED3D_RS_COLORKEYENABLE
] && enable_ckey
))
814 gl_info
->gl_ops
.gl
.p_glEnable(GL_ALPHA_TEST
);
815 checkGLcall("glEnable GL_ALPHA_TEST");
819 gl_info
->gl_ops
.gl
.p_glDisable(GL_ALPHA_TEST
);
820 checkGLcall("glDisable GL_ALPHA_TEST");
821 /* Alpha test is disabled, don't bother setting the params - it will happen on the next
827 if (state
->render_states
[WINED3D_RS_COLORKEYENABLE
] && enable_ckey
)
829 glParm
= GL_NOTEQUAL
;
834 ref
= wined3d_alpha_ref(state
);
835 glParm
= wined3d_gl_compare_func(state
->render_states
[WINED3D_RS_ALPHAFUNC
]);
839 gl_info
->gl_ops
.gl
.p_glAlphaFunc(glParm
, ref
);
840 checkGLcall("glAlphaFunc");
844 void state_clipping(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
846 struct wined3d_context_gl
*context_gl
= wined3d_context_gl(context
);
847 uint32_t enable_mask
;
849 if (use_vs(state
) && !context
->d3d_info
->vs_clipping
)
853 /* The OpenGL spec says that clipping planes are disabled when using
854 * shaders. Direct3D planes aren't, so that is an issue. The MacOS ATI
855 * driver keeps clipping planes activated with shaders in some
856 * conditions I got sick of tracking down. The shader state handler
857 * disables all clip planes because of that - don't do anything here
858 * and keep them disabled. */
859 if (state
->render_states
[WINED3D_RS_CLIPPLANEENABLE
] && !warned
++)
860 FIXME("Clipping not supported with vertex shaders.\n");
864 /* glEnable(GL_CLIP_PLANEx) doesn't apply to (ARB backend) vertex shaders.
865 * The enabled / disabled planes are hardcoded into the shader. Update the
866 * shader to update the enabled clipplanes. In case of fixed function, we
867 * need to update the clipping field from ffp_vertex_settings. */
868 context
->shader_update_mask
|= 1u << WINED3D_SHADER_TYPE_VERTEX
;
870 /* If enabling / disabling all
871 * TODO: Is this correct? Doesn't D3DRS_CLIPPING disable clipping on the viewport frustrum?
873 enable_mask
= state
->render_states
[WINED3D_RS_CLIPPING
] ?
874 state
->render_states
[WINED3D_RS_CLIPPLANEENABLE
] : 0;
875 wined3d_context_gl_enable_clip_distances(context_gl
, enable_mask
);
878 static void state_specularenable(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
880 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
882 /* Originally this used glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR)
883 * and (GL_LIGHT_MODEL_COLOR_CONTROL,GL_SINGLE_COLOR) to swap between enabled/disabled
884 * specular color. This is wrong:
885 * Separate specular color means the specular colour is maintained separately, whereas
886 * single color means it is merged in. However in both cases they are being used to
888 * To disable specular color, set it explicitly to black and turn off GL_COLOR_SUM_EXT
889 * NOTE: If not supported don't give FIXMEs the impact is really minimal and very few people are
893 * If register combiners are enabled, enabling / disabling GL_COLOR_SUM has no effect.
894 * Instead, we need to setup the FinalCombiner properly.
896 * The default setup for the FinalCombiner is:
898 * <variable> <input> <mapping> <usage>
899 * GL_VARIABLE_A_NV GL_FOG, GL_UNSIGNED_IDENTITY_NV GL_ALPHA
900 * GL_VARIABLE_B_NV GL_SPARE0_PLUS_SECONDARY_COLOR_NV GL_UNSIGNED_IDENTITY_NV GL_RGB
901 * GL_VARIABLE_C_NV GL_FOG GL_UNSIGNED_IDENTITY_NV GL_RGB
902 * GL_VARIABLE_D_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
903 * GL_VARIABLE_E_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
904 * GL_VARIABLE_F_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
905 * GL_VARIABLE_G_NV GL_SPARE0_NV GL_UNSIGNED_IDENTITY_NV GL_ALPHA
907 * That's pretty much fine as it is, except for variable B, which needs to take
908 * either GL_SPARE0_PLUS_SECONDARY_COLOR_NV or GL_SPARE0_NV, depending on
909 * whether WINED3D_RS_SPECULARENABLE is enabled or not.
912 TRACE("Setting specular enable state and materials\n");
913 if (state
->render_states
[WINED3D_RS_SPECULARENABLE
])
915 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, (float *)&state
->material
.specular
);
916 checkGLcall("glMaterialfv");
918 if (state
->material
.power
> gl_info
->limits
.shininess
)
920 /* glMaterialf man page says that the material says that GL_SHININESS must be between 0.0
921 * and 128.0, although in d3d neither -1 nor 129 produce an error. GL_NV_max_light_exponent
922 * allows bigger values. If the extension is supported, gl_info->limits.shininess contains the
923 * value reported by the extension, otherwise 128. For values > gl_info->limits.shininess clamp
924 * them, it should be safe to do so without major visual distortions.
926 WARN("Material power = %.8e, limit %.8e\n", state
->material
.power
, gl_info
->limits
.shininess
);
927 gl_info
->gl_ops
.gl
.p_glMaterialf(GL_FRONT_AND_BACK
, GL_SHININESS
, gl_info
->limits
.shininess
);
931 gl_info
->gl_ops
.gl
.p_glMaterialf(GL_FRONT_AND_BACK
, GL_SHININESS
, state
->material
.power
);
933 checkGLcall("glMaterialf(GL_SHININESS)");
935 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
936 gl_info
->gl_ops
.gl
.p_glEnable(GL_COLOR_SUM_EXT
);
938 TRACE("Specular colors cannot be enabled in this version of opengl\n");
939 checkGLcall("glEnable(GL_COLOR_SUM)");
941 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
943 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV
, GL_SPARE0_PLUS_SECONDARY_COLOR_NV
, GL_UNSIGNED_IDENTITY_NV
, GL_RGB
));
944 checkGLcall("glFinalCombinerInputNV()");
947 static const GLfloat black
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
949 /* for the case of enabled lighting: */
950 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, &black
[0]);
951 checkGLcall("glMaterialfv");
953 /* for the case of disabled lighting: */
954 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
955 gl_info
->gl_ops
.gl
.p_glDisable(GL_COLOR_SUM_EXT
);
957 TRACE("Specular colors cannot be disabled in this version of opengl\n");
958 checkGLcall("glDisable(GL_COLOR_SUM)");
960 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
962 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV
, GL_SPARE0_NV
, GL_UNSIGNED_IDENTITY_NV
, GL_RGB
));
963 checkGLcall("glFinalCombinerInputNV()");
967 TRACE("diffuse %s\n", debug_color(&state
->material
.diffuse
));
968 TRACE("ambient %s\n", debug_color(&state
->material
.ambient
));
969 TRACE("specular %s\n", debug_color(&state
->material
.specular
));
970 TRACE("emissive %s\n", debug_color(&state
->material
.emissive
));
972 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float *)&state
->material
.ambient
);
973 checkGLcall("glMaterialfv(GL_AMBIENT)");
974 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float *)&state
->material
.diffuse
);
975 checkGLcall("glMaterialfv(GL_DIFFUSE)");
976 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_EMISSION
, (float *)&state
->material
.emissive
);
977 checkGLcall("glMaterialfv(GL_EMISSION)");
980 static void state_texfactor(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
982 struct wined3d_context_gl
*context_gl
= wined3d_context_gl(context
);
983 const struct wined3d_gl_info
*gl_info
= context_gl
->gl_info
;
984 struct wined3d_color color
;
987 /* Note the texture color applies to all textures whereas
988 * GL_TEXTURE_ENV_COLOR applies to active only. */
989 wined3d_color_from_d3dcolor(&color
, state
->render_states
[WINED3D_RS_TEXTUREFACTOR
]);
991 /* And now the default texture color as well */
992 for (i
= 0; i
< context
->d3d_info
->limits
.ffp_blend_stages
; ++i
)
994 /* Note the WINED3D_RS value applies to all textures, but GL has one
995 * per texture, so apply it now ready to be used! */
996 wined3d_context_gl_active_texture(context_gl
, gl_info
, i
);
998 gl_info
->gl_ops
.gl
.p_glTexEnvfv(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_COLOR
, &color
.r
);
999 checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);");
1003 static void renderstate_stencil_twosided(struct wined3d_context
*context
, GLint face
,
1004 GLint func
, GLint ref
, GLuint mask
, GLint stencilFail
, GLint depthFail
, GLint stencilPass
)
1006 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1008 gl_info
->gl_ops
.gl
.p_glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT
);
1009 checkGLcall("glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT)");
1010 GL_EXTCALL(glActiveStencilFaceEXT(face
));
1011 checkGLcall("glActiveStencilFaceEXT(...)");
1012 gl_info
->gl_ops
.gl
.p_glStencilFunc(func
, ref
, mask
);
1013 checkGLcall("glStencilFunc(...)");
1014 gl_info
->gl_ops
.gl
.p_glStencilOp(stencilFail
, depthFail
, stencilPass
);
1015 checkGLcall("glStencilOp(...)");
1018 static GLenum
gl_stencil_op(enum wined3d_stencil_op op
)
1022 case WINED3D_STENCIL_OP_KEEP
:
1024 case WINED3D_STENCIL_OP_ZERO
:
1026 case WINED3D_STENCIL_OP_REPLACE
:
1028 case WINED3D_STENCIL_OP_INCR_SAT
:
1030 case WINED3D_STENCIL_OP_DECR_SAT
:
1032 case WINED3D_STENCIL_OP_INVERT
:
1034 case WINED3D_STENCIL_OP_INCR
:
1035 return GL_INCR_WRAP
;
1036 case WINED3D_STENCIL_OP_DECR
:
1037 return GL_DECR_WRAP
;
1040 WARN("Unrecognized stencil op %#x.\n", op
);
1042 FIXME("Unrecognized stencil op %#x.\n", op
);
1047 static void state_stencil(struct wined3d_context
*context
, const struct wined3d_state
*state
)
1049 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1050 const struct wined3d_depth_stencil_state
*d
= state
->depth_stencil_state
;
1056 GLint stencilFail_back
;
1058 GLint stencilPass_back
;
1060 GLint depthFail_back
;
1062 /* No stencil test without a stencil buffer. */
1063 if (!state
->fb
.depth_stencil
|| !d
|| !d
->desc
.stencil
)
1065 gl_info
->gl_ops
.gl
.p_glDisable(GL_STENCIL_TEST
);
1066 checkGLcall("glDisable GL_STENCIL_TEST");
1070 if (!(func
= wined3d_gl_compare_func(d
->desc
.front
.func
)))
1072 if (!(func_back
= wined3d_gl_compare_func(d
->desc
.back
.func
)))
1073 func_back
= GL_ALWAYS
;
1074 mask
= d
->desc
.stencil_read_mask
;
1075 ref
= state
->stencil_ref
& ((1 << state
->fb
.depth_stencil
->format
->stencil_size
) - 1);
1076 stencilFail
= gl_stencil_op(d
->desc
.front
.fail_op
);
1077 depthFail
= gl_stencil_op(d
->desc
.front
.depth_fail_op
);
1078 stencilPass
= gl_stencil_op(d
->desc
.front
.pass_op
);
1079 stencilFail_back
= gl_stencil_op(d
->desc
.back
.fail_op
);
1080 depthFail_back
= gl_stencil_op(d
->desc
.back
.depth_fail_op
);
1081 stencilPass_back
= gl_stencil_op(d
->desc
.back
.pass_op
);
1083 TRACE("(ref %x, mask %x, "
1084 "GL_FRONT: func: %x, fail %x, zfail %x, zpass %x "
1085 "GL_BACK: func: %x, fail %x, zfail %x, zpass %x)\n",
1087 func
, stencilFail
, depthFail
, stencilPass
,
1088 func_back
, stencilFail_back
, depthFail_back
, stencilPass_back
);
1090 if (memcmp(&d
->desc
.front
, &d
->desc
.back
, sizeof(d
->desc
.front
)))
1092 gl_info
->gl_ops
.gl
.p_glEnable(GL_STENCIL_TEST
);
1093 checkGLcall("glEnable GL_STENCIL_TEST");
1095 if (gl_info
->supported
[WINED3D_GL_VERSION_2_0
])
1097 GL_EXTCALL(glStencilFuncSeparate(GL_FRONT
, func
, ref
, mask
));
1098 GL_EXTCALL(glStencilOpSeparate(GL_FRONT
, stencilFail
, depthFail
, stencilPass
));
1099 GL_EXTCALL(glStencilFuncSeparate(GL_BACK
, func_back
, ref
, mask
));
1100 GL_EXTCALL(glStencilOpSeparate(GL_BACK
, stencilFail_back
, depthFail_back
, stencilPass_back
));
1101 checkGLcall("setting two sided stencil state");
1103 else if (gl_info
->supported
[EXT_STENCIL_TWO_SIDE
])
1105 /* Apply back first, then front. This function calls glActiveStencilFaceEXT,
1106 * which has an effect on the code below too. If we apply the front face
1107 * afterwards, we are sure that the active stencil face is set to front,
1108 * and other stencil functions which do not use two sided stencil do not have
1111 renderstate_stencil_twosided(context
, GL_BACK
,
1112 func_back
, ref
, mask
, stencilFail_back
, depthFail_back
, stencilPass_back
);
1113 renderstate_stencil_twosided(context
, GL_FRONT
,
1114 func
, ref
, mask
, stencilFail
, depthFail
, stencilPass
);
1116 else if (gl_info
->supported
[ATI_SEPARATE_STENCIL
])
1118 GL_EXTCALL(glStencilFuncSeparateATI(func
, func_back
, ref
, mask
));
1119 checkGLcall("glStencilFuncSeparateATI(...)");
1120 GL_EXTCALL(glStencilOpSeparateATI(GL_FRONT
, stencilFail
, depthFail
, stencilPass
));
1121 checkGLcall("glStencilOpSeparateATI(GL_FRONT, ...)");
1122 GL_EXTCALL(glStencilOpSeparateATI(GL_BACK
, stencilFail_back
, depthFail_back
, stencilPass_back
));
1123 checkGLcall("glStencilOpSeparateATI(GL_BACK, ...)");
1127 FIXME("Separate (two sided) stencil not supported on this version of OpenGL. Caps weren't honored?\n");
1132 if (gl_info
->supported
[EXT_STENCIL_TWO_SIDE
])
1134 gl_info
->gl_ops
.gl
.p_glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT
);
1135 checkGLcall("glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT)");
1138 /* This code disables the ATI extension as well, since the standard stencil functions are equal
1139 * to calling the ATI functions with GL_FRONT_AND_BACK as face parameter
1141 gl_info
->gl_ops
.gl
.p_glEnable(GL_STENCIL_TEST
);
1142 checkGLcall("glEnable GL_STENCIL_TEST");
1143 gl_info
->gl_ops
.gl
.p_glStencilFunc(func
, ref
, mask
);
1144 checkGLcall("glStencilFunc(...)");
1145 gl_info
->gl_ops
.gl
.p_glStencilOp(stencilFail
, depthFail
, stencilPass
);
1146 checkGLcall("glStencilOp(...)");
1150 static void depth(struct wined3d_context
*context
, const struct wined3d_state
*state
)
1152 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1153 const struct wined3d_depth_stencil_state
*d
= state
->depth_stencil_state
;
1154 BOOL enable_depth
= d
? d
->desc
.depth
: TRUE
;
1155 GLenum depth_func
= GL_LESS
;
1157 if (!state
->fb
.depth_stencil
)
1159 TRACE("No depth/stencil buffer is attached; disabling depth test.\n");
1160 enable_depth
= FALSE
;
1165 gl_info
->gl_ops
.gl
.p_glEnable(GL_DEPTH_TEST
);
1166 checkGLcall("glEnable GL_DEPTH_TEST");
1170 gl_info
->gl_ops
.gl
.p_glDisable(GL_DEPTH_TEST
);
1171 checkGLcall("glDisable GL_DEPTH_TEST");
1174 if (!d
|| d
->desc
.depth_write
)
1176 gl_info
->gl_ops
.gl
.p_glDepthMask(GL_TRUE
);
1177 checkGLcall("glDepthMask(GL_TRUE)");
1181 gl_info
->gl_ops
.gl
.p_glDepthMask(GL_FALSE
);
1182 checkGLcall("glDepthMask(GL_FALSE)");
1186 depth_func
= wined3d_gl_compare_func(d
->desc
.depth_func
);
1189 gl_info
->gl_ops
.gl
.p_glDepthFunc(depth_func
);
1190 checkGLcall("glDepthFunc");
1193 if (context
->last_was_rhw
&& !isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
)))
1194 context_apply_state(context
, state
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
));
1197 static void depth_stencil(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1199 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1200 const struct wined3d_depth_stencil_state
*d
= state
->depth_stencil_state
;
1201 GLuint stencil_write_mask
= 0;
1203 depth(context
, state
);
1204 state_stencil(context
, state
);
1206 if (state
->fb
.depth_stencil
)
1207 stencil_write_mask
= d
? d
->desc
.stencil_write_mask
: ~0u;
1209 gl_info
->gl_ops
.gl
.p_glStencilMask(stencil_write_mask
);
1210 checkGLcall("glStencilMask");
1213 static void depth_stencil_2s(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1215 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1216 const struct wined3d_depth_stencil_state
*d
= state
->depth_stencil_state
;
1217 GLuint stencil_write_mask
= 0;
1219 depth(context
, state
);
1220 state_stencil(context
, state
);
1222 if (state
->fb
.depth_stencil
)
1223 stencil_write_mask
= d
? d
->desc
.stencil_write_mask
: ~0u;
1225 GL_EXTCALL(glActiveStencilFaceEXT(GL_BACK
));
1226 checkGLcall("glActiveStencilFaceEXT(GL_BACK)");
1227 gl_info
->gl_ops
.gl
.p_glStencilMask(stencil_write_mask
);
1228 checkGLcall("glStencilMask");
1229 GL_EXTCALL(glActiveStencilFaceEXT(GL_FRONT
));
1230 checkGLcall("glActiveStencilFaceEXT(GL_FRONT)");
1231 gl_info
->gl_ops
.gl
.p_glStencilMask(stencil_write_mask
);
1234 static void state_fog_vertexpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1236 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1238 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
1240 if (!state
->render_states
[WINED3D_RS_FOGENABLE
])
1243 /* Table fog on: Never use fog coords, and use per-fragment fog */
1244 if (state
->render_states
[WINED3D_RS_FOGTABLEMODE
] != WINED3D_FOG_NONE
)
1246 gl_info
->gl_ops
.gl
.p_glHint(GL_FOG_HINT
, GL_NICEST
);
1247 if (context
->fog_coord
)
1249 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FRAGMENT_DEPTH_EXT
);
1250 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT)");
1251 context
->fog_coord
= FALSE
;
1254 /* Range fog is only used with per-vertex fog in d3d */
1255 if (gl_info
->supported
[NV_FOG_DISTANCE
])
1257 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_DISTANCE_MODE_NV
, GL_EYE_PLANE_ABSOLUTE_NV
);
1258 checkGLcall("glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_PLANE_ABSOLUTE_NV)");
1263 /* Otherwise use per-vertex fog in any case */
1264 gl_info
->gl_ops
.gl
.p_glHint(GL_FOG_HINT
, GL_FASTEST
);
1266 if (state
->render_states
[WINED3D_RS_FOGVERTEXMODE
] == WINED3D_FOG_NONE
|| context
->last_was_rhw
)
1268 /* No fog at all, or transformed vertices: Use fog coord */
1269 if (!context
->fog_coord
)
1271 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FOG_COORDINATE_EXT
);
1272 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT)");
1273 context
->fog_coord
= TRUE
;
1278 /* Otherwise, use the fragment depth */
1279 if (context
->fog_coord
)
1281 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FRAGMENT_DEPTH_EXT
);
1282 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT)");
1283 context
->fog_coord
= FALSE
;
1286 if (state
->render_states
[WINED3D_RS_RANGEFOGENABLE
])
1288 if (gl_info
->supported
[NV_FOG_DISTANCE
])
1290 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_DISTANCE_MODE_NV
, GL_EYE_RADIAL_NV
);
1291 checkGLcall("glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_RADIAL_NV)");
1295 WARN("Range fog enabled, but not supported by this GL implementation.\n");
1298 else if (gl_info
->supported
[NV_FOG_DISTANCE
])
1300 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_DISTANCE_MODE_NV
, GL_EYE_PLANE_ABSOLUTE_NV
);
1301 checkGLcall("glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_PLANE_ABSOLUTE_NV)");
1306 void state_fogstartend(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1308 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1309 float fogstart
, fogend
;
1311 get_fog_start_end(context
, state
, &fogstart
, &fogend
);
1313 gl_info
->gl_ops
.gl
.p_glFogf(GL_FOG_START
, fogstart
);
1314 checkGLcall("glFogf(GL_FOG_START, fogstart)");
1315 TRACE("Fog Start == %f\n", fogstart
);
1317 gl_info
->gl_ops
.gl
.p_glFogf(GL_FOG_END
, fogend
);
1318 checkGLcall("glFogf(GL_FOG_END, fogend)");
1319 TRACE("Fog End == %f\n", fogend
);
1322 void state_fog_fragpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1324 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1325 enum fogsource new_source
;
1326 DWORD fogstart
= state
->render_states
[WINED3D_RS_FOGSTART
];
1327 DWORD fogend
= state
->render_states
[WINED3D_RS_FOGEND
];
1329 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
1331 if (!state
->render_states
[WINED3D_RS_FOGENABLE
])
1333 /* No fog? Disable it, and we're done :-) */
1334 gl_info
->p_glDisableWINE(GL_FOG
);
1335 checkGLcall("glDisable GL_FOG");
1341 * With fixed function vertex processing, Direct3D knows 2 different fog input sources.
1342 * It can use the Z value of the vertex, or the alpha component of the specular color.
1343 * This depends on the fog vertex, fog table and the vertex declaration. If the Z value
1344 * is used, fogstart, fogend and the equation type are used, otherwise linear fog with
1345 * start = 255, end = 0 is used. Obviously the msdn is not very clear on that.
1347 * FOGTABLEMODE != NONE:
1348 * The Z value is used, with the equation specified, no matter what vertex type.
1350 * FOGTABLEMODE == NONE, FOGVERTEXMODE != NONE, untransformed:
1351 * Per vertex fog is calculated using the specified fog equation and the parameters
1353 * FOGTABLEMODE == NONE, FOGVERTEXMODE != NONE, transformed, OR
1354 * FOGTABLEMODE == NONE, FOGVERTEXMODE == NONE, untransformed:
1355 * Linear fog with start = 255.0, end = 0.0, input comes from the specular color
1358 * Rules for vertex fog with shaders:
1360 * When mixing fixed function functionality with the programmable pipeline, D3D expects
1361 * the fog computation to happen during transformation while openGL expects it to happen
1362 * during rasterization. Also, prior to pixel shader 3.0 D3D handles fog blending after
1363 * the pixel shader while openGL always expects the pixel shader to handle the blending.
1364 * To solve this problem, WineD3D does:
1365 * 1) implement a linear fog equation and fog blending at the end of every pre 3.0 pixel
1367 * and 2) disables the fog computation (in either the fixed function or programmable
1368 * rasterizer) if using a vertex program.
1370 * D3D shaders can provide an explicit fog coordinate. This fog coordinate is used with
1371 * D3DRS_FOGTABLEMODE==D3DFOG_NONE. The FOGVERTEXMODE is ignored, d3d always uses linear
1372 * fog with start=1.0 and end=0.0 in this case. This is similar to fog coordinates in
1373 * the specular color, a vertex shader counts as pretransformed geometry in this case.
1374 * There are some GL differences between specular fog coords and vertex shaders though.
1376 * With table fog the vertex shader fog coordinate is ignored.
1378 * If a fogtablemode and a fogvertexmode are specified, table fog is applied (with or
1382 /* DX 7 sdk: "If both render states(vertex and table fog) are set to valid modes,
1383 * the system will apply only pixel(=table) fog effects."
1385 if (state
->render_states
[WINED3D_RS_FOGTABLEMODE
] == WINED3D_FOG_NONE
)
1389 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_LINEAR
);
1390 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1391 new_source
= FOGSOURCE_VS
;
1395 switch (state
->render_states
[WINED3D_RS_FOGVERTEXMODE
])
1397 /* If processed vertices are used, fall through to the NONE case */
1398 case WINED3D_FOG_EXP
:
1399 if (!context
->last_was_rhw
)
1401 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_EXP
);
1402 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP)");
1403 new_source
= FOGSOURCE_FFP
;
1408 case WINED3D_FOG_EXP2
:
1409 if (!context
->last_was_rhw
)
1411 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_EXP2
);
1412 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2)");
1413 new_source
= FOGSOURCE_FFP
;
1418 case WINED3D_FOG_LINEAR
:
1419 if (!context
->last_was_rhw
)
1421 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_LINEAR
);
1422 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1423 new_source
= FOGSOURCE_FFP
;
1428 case WINED3D_FOG_NONE
:
1429 /* Both are none? According to msdn the alpha channel of
1430 * the specular colour contains a fog factor. Set it in
1431 * draw_primitive_immediate_mode(). Same happens with
1432 * vertex fog on transformed vertices. */
1433 new_source
= FOGSOURCE_COORD
;
1434 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_LINEAR
);
1435 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1439 FIXME("Unexpected WINED3D_RS_FOGVERTEXMODE %#x.\n",
1440 state
->render_states
[WINED3D_RS_FOGVERTEXMODE
]);
1441 new_source
= FOGSOURCE_FFP
; /* Make the compiler happy */
1445 new_source
= FOGSOURCE_FFP
;
1447 switch (state
->render_states
[WINED3D_RS_FOGTABLEMODE
])
1449 case WINED3D_FOG_EXP
:
1450 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_EXP
);
1451 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP)");
1454 case WINED3D_FOG_EXP2
:
1455 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_EXP2
);
1456 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2)");
1459 case WINED3D_FOG_LINEAR
:
1460 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_LINEAR
);
1461 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1464 case WINED3D_FOG_NONE
: /* Won't happen */
1466 FIXME("Unexpected WINED3D_RS_FOGTABLEMODE %#x.\n",
1467 state
->render_states
[WINED3D_RS_FOGTABLEMODE
]);
1471 gl_info
->p_glEnableWINE(GL_FOG
);
1472 checkGLcall("glEnable GL_FOG");
1473 if (new_source
!= context
->fog_source
|| fogstart
== fogend
)
1475 context
->fog_source
= new_source
;
1476 state_fogstartend(context
, state
, STATE_RENDER(WINED3D_RS_FOGSTART
));
1480 void state_fogcolor(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1482 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1483 struct wined3d_color color
;
1485 wined3d_color_from_d3dcolor(&color
, state
->render_states
[WINED3D_RS_FOGCOLOR
]);
1486 gl_info
->gl_ops
.gl
.p_glFogfv(GL_FOG_COLOR
, &color
.r
);
1487 checkGLcall("glFog GL_FOG_COLOR");
1490 void state_fogdensity(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1492 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1498 tmpvalue
.d
= state
->render_states
[WINED3D_RS_FOGDENSITY
];
1499 gl_info
->gl_ops
.gl
.p_glFogfv(GL_FOG_DENSITY
, &tmpvalue
.f
);
1500 checkGLcall("glFogf(GL_FOG_DENSITY, (float) Value)");
1503 static void state_colormat(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1505 struct wined3d_context_gl
*context_gl
= wined3d_context_gl(context
);
1506 const struct wined3d_gl_info
*gl_info
= context_gl
->gl_info
;
1509 context_gl
->untracked_material_count
= 0;
1510 if ((context_gl
->c
.stream_info
.use_map
& (1u << WINED3D_FFP_DIFFUSE
))
1511 && state
->render_states
[WINED3D_RS_COLORVERTEX
])
1513 TRACE("diff %d, amb %d, emis %d, spec %d\n",
1514 state
->render_states
[WINED3D_RS_DIFFUSEMATERIALSOURCE
],
1515 state
->render_states
[WINED3D_RS_AMBIENTMATERIALSOURCE
],
1516 state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
],
1517 state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
]);
1519 if (state
->render_states
[WINED3D_RS_DIFFUSEMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1521 if (state
->render_states
[WINED3D_RS_AMBIENTMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1522 Parm
= GL_AMBIENT_AND_DIFFUSE
;
1525 if (state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1526 context_gl
->untracked_materials
[context_gl
->untracked_material_count
++] = GL_EMISSION
;
1527 if (state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1528 context_gl
->untracked_materials
[context_gl
->untracked_material_count
++] = GL_SPECULAR
;
1530 else if (state
->render_states
[WINED3D_RS_AMBIENTMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1533 if (state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1534 context_gl
->untracked_materials
[context_gl
->untracked_material_count
++] = GL_EMISSION
;
1535 if (state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1536 context_gl
->untracked_materials
[context_gl
->untracked_material_count
++] = GL_SPECULAR
;
1538 else if (state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1541 if (state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1542 context_gl
->untracked_materials
[context_gl
->untracked_material_count
++] = GL_SPECULAR
;
1544 else if (state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1550 /* Nothing changed, return. */
1551 if (Parm
== context_gl
->tracking_parm
)
1556 gl_info
->gl_ops
.gl
.p_glDisable(GL_COLOR_MATERIAL
);
1557 checkGLcall("glDisable GL_COLOR_MATERIAL");
1561 gl_info
->gl_ops
.gl
.p_glColorMaterial(GL_FRONT_AND_BACK
, Parm
);
1562 checkGLcall("glColorMaterial(GL_FRONT_AND_BACK, Parm)");
1563 gl_info
->gl_ops
.gl
.p_glEnable(GL_COLOR_MATERIAL
);
1564 checkGLcall("glEnable(GL_COLOR_MATERIAL)");
1567 /* Apparently calls to glMaterialfv are ignored for properties we're
1568 * tracking with glColorMaterial, so apply those here. */
1569 switch (context_gl
->tracking_parm
)
1571 case GL_AMBIENT_AND_DIFFUSE
:
1572 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float *)&state
->material
.ambient
);
1573 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float *)&state
->material
.diffuse
);
1574 checkGLcall("glMaterialfv");
1578 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float *)&state
->material
.diffuse
);
1579 checkGLcall("glMaterialfv");
1583 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float *)&state
->material
.ambient
);
1584 checkGLcall("glMaterialfv");
1588 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_EMISSION
, (float *)&state
->material
.emissive
);
1589 checkGLcall("glMaterialfv");
1593 /* Only change material color if specular is enabled, otherwise it is set to black */
1594 if (state
->render_states
[WINED3D_RS_SPECULARENABLE
])
1596 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, (float *)&state
->material
.specular
);
1597 checkGLcall("glMaterialfv");
1601 static const GLfloat black
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
1602 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, &black
[0]);
1603 checkGLcall("glMaterialfv");
1608 context_gl
->tracking_parm
= Parm
;
1611 static void state_linepattern(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1613 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1617 struct wined3d_line_pattern lp
;
1619 tmppattern
.d
= state
->render_states
[WINED3D_RS_LINEPATTERN
];
1621 TRACE("Line pattern: repeat %d bits %x.\n", tmppattern
.lp
.repeat_factor
, tmppattern
.lp
.line_pattern
);
1623 if (tmppattern
.lp
.repeat_factor
)
1625 gl_info
->gl_ops
.gl
.p_glLineStipple(tmppattern
.lp
.repeat_factor
, tmppattern
.lp
.line_pattern
);
1626 checkGLcall("glLineStipple(repeat, linepattern)");
1627 gl_info
->gl_ops
.gl
.p_glEnable(GL_LINE_STIPPLE
);
1628 checkGLcall("glEnable(GL_LINE_STIPPLE);");
1632 gl_info
->gl_ops
.gl
.p_glDisable(GL_LINE_STIPPLE
);
1633 checkGLcall("glDisable(GL_LINE_STIPPLE);");
1637 static void state_linepattern_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1639 static unsigned int once
;
1642 FIXME("Setting line patterns is not supported in OpenGL core contexts.\n");
1645 static void state_normalize(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1647 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1649 /* Without vertex normals, we set the current normal to 0/0/0 to remove the diffuse factor
1650 * from the opengl lighting equation, as d3d does. Normalization of 0/0/0 can lead to a division
1651 * by zero and is not properly defined in opengl, so avoid it
1653 if (state
->render_states
[WINED3D_RS_NORMALIZENORMALS
]
1654 && (context
->stream_info
.use_map
& (1u << WINED3D_FFP_NORMAL
)))
1656 gl_info
->gl_ops
.gl
.p_glEnable(GL_NORMALIZE
);
1657 checkGLcall("glEnable(GL_NORMALIZE);");
1661 gl_info
->gl_ops
.gl
.p_glDisable(GL_NORMALIZE
);
1662 checkGLcall("glDisable(GL_NORMALIZE);");
1666 static void state_psizemin_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1670 get_pointsize_minmax(context
, state
, &min
, &max
);
1673 FIXME("WINED3D_RS_POINTSIZE_MIN value %.8e not supported on this OpenGL implementation.\n", min
);
1675 FIXME("WINED3D_RS_POINTSIZE_MAX value %.8e not supported on this OpenGL implementation.\n", max
);
1678 static void state_psizemin_ext(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1680 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1683 get_pointsize_minmax(context
, state
, &min
, &max
);
1685 GL_EXTCALL(glPointParameterfEXT
)(GL_POINT_SIZE_MIN_EXT
, min
);
1686 checkGLcall("glPointParameterfEXT(...)");
1687 GL_EXTCALL(glPointParameterfEXT
)(GL_POINT_SIZE_MAX_EXT
, max
);
1688 checkGLcall("glPointParameterfEXT(...)");
1691 static void state_psizemin_arb(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1693 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1696 get_pointsize_minmax(context
, state
, &min
, &max
);
1698 GL_EXTCALL(glPointParameterfARB
)(GL_POINT_SIZE_MIN_ARB
, min
);
1699 checkGLcall("glPointParameterfARB(...)");
1700 GL_EXTCALL(glPointParameterfARB
)(GL_POINT_SIZE_MAX_ARB
, max
);
1701 checkGLcall("glPointParameterfARB(...)");
1704 static void state_pscale(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1706 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1710 get_pointsize(context
, state
, &pointsize
, att
);
1712 if (gl_info
->supported
[ARB_POINT_PARAMETERS
])
1714 GL_EXTCALL(glPointParameterfvARB
)(GL_POINT_DISTANCE_ATTENUATION_ARB
, att
);
1715 checkGLcall("glPointParameterfvARB(GL_DISTANCE_ATTENUATION_ARB, ...)");
1717 else if (gl_info
->supported
[EXT_POINT_PARAMETERS
])
1719 GL_EXTCALL(glPointParameterfvEXT
)(GL_DISTANCE_ATTENUATION_EXT
, att
);
1720 checkGLcall("glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, ...)");
1722 else if (state
->render_states
[WINED3D_RS_POINTSCALEENABLE
])
1724 WARN("POINT_PARAMETERS not supported in this version of opengl\n");
1727 gl_info
->gl_ops
.gl
.p_glPointSize(max(pointsize
, FLT_MIN
));
1728 checkGLcall("glPointSize(...);");
1731 static void state_debug_monitor(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1733 WARN("token: %#x.\n", state
->render_states
[WINED3D_RS_DEBUGMONITORTOKEN
]);
1736 static void state_localviewer(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1738 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1740 if (state
->render_states
[WINED3D_RS_LOCALVIEWER
])
1742 gl_info
->gl_ops
.gl
.p_glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER
, 1);
1743 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1)");
1747 gl_info
->gl_ops
.gl
.p_glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER
, 0);
1748 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 0)");
1752 static void state_lastpixel(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1754 if (state
->render_states
[WINED3D_RS_LASTPIXEL
])
1756 TRACE("Last Pixel Drawing Enabled\n");
1762 FIXME("Last Pixel Drawing Disabled, not handled yet\n");
1765 TRACE("Last Pixel Drawing Disabled, not handled yet\n");
1770 void state_pointsprite_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1774 /* TODO: NV_POINT_SPRITE */
1775 if (!warned
&& state
->render_states
[WINED3D_RS_POINTSPRITEENABLE
])
1777 /* A FIXME, not a WARN because point sprites should be software emulated if not supported by HW */
1778 FIXME("Point sprites not supported\n");
1783 void state_pointsprite(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1785 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1787 if (state
->render_states
[WINED3D_RS_POINTSPRITEENABLE
])
1789 gl_info
->gl_ops
.gl
.p_glEnable(GL_POINT_SPRITE_ARB
);
1790 checkGLcall("glEnable(GL_POINT_SPRITE_ARB)");
1794 gl_info
->gl_ops
.gl
.p_glDisable(GL_POINT_SPRITE_ARB
);
1795 checkGLcall("glDisable(GL_POINT_SPRITE_ARB)");
1799 static void state_wrap(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1801 static unsigned int once
;
1803 if ((state
->render_states
[WINED3D_RS_WRAP0
]
1804 || state
->render_states
[WINED3D_RS_WRAP1
]
1805 || state
->render_states
[WINED3D_RS_WRAP2
]
1806 || state
->render_states
[WINED3D_RS_WRAP3
]
1807 || state
->render_states
[WINED3D_RS_WRAP4
]
1808 || state
->render_states
[WINED3D_RS_WRAP5
]
1809 || state
->render_states
[WINED3D_RS_WRAP6
]
1810 || state
->render_states
[WINED3D_RS_WRAP7
]
1811 || state
->render_states
[WINED3D_RS_WRAP8
]
1812 || state
->render_states
[WINED3D_RS_WRAP9
]
1813 || state
->render_states
[WINED3D_RS_WRAP10
]
1814 || state
->render_states
[WINED3D_RS_WRAP11
]
1815 || state
->render_states
[WINED3D_RS_WRAP12
]
1816 || state
->render_states
[WINED3D_RS_WRAP13
]
1817 || state
->render_states
[WINED3D_RS_WRAP14
]
1818 || state
->render_states
[WINED3D_RS_WRAP15
])
1820 FIXME("(WINED3D_RS_WRAP0) Texture wrapping not yet supported.\n");
1823 static void state_msaa_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1825 if (state
->render_states
[WINED3D_RS_MULTISAMPLEANTIALIAS
])
1826 WARN("Multisample antialiasing not supported by GL.\n");
1829 static void state_msaa(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1831 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1833 if (state
->render_states
[WINED3D_RS_MULTISAMPLEANTIALIAS
])
1835 gl_info
->gl_ops
.gl
.p_glEnable(GL_MULTISAMPLE_ARB
);
1836 checkGLcall("glEnable(GL_MULTISAMPLE_ARB)");
1840 gl_info
->gl_ops
.gl
.p_glDisable(GL_MULTISAMPLE_ARB
);
1841 checkGLcall("glDisable(GL_MULTISAMPLE_ARB)");
1845 static void line_antialias(const struct wined3d_rasterizer_state
*r
, const struct wined3d_gl_info
*gl_info
)
1847 if (r
&& r
->desc
.line_antialias
)
1849 gl_info
->gl_ops
.gl
.p_glEnable(GL_LINE_SMOOTH
);
1850 checkGLcall("glEnable(GL_LINE_SMOOTH)");
1854 gl_info
->gl_ops
.gl
.p_glDisable(GL_LINE_SMOOTH
);
1855 checkGLcall("glDisable(GL_LINE_SMOOTH)");
1859 static void scissor(const struct wined3d_rasterizer_state
*r
, const struct wined3d_gl_info
*gl_info
)
1861 if (r
&& r
->desc
.scissor
)
1863 gl_info
->gl_ops
.gl
.p_glEnable(GL_SCISSOR_TEST
);
1864 checkGLcall("glEnable(GL_SCISSOR_TEST)");
1868 gl_info
->gl_ops
.gl
.p_glDisable(GL_SCISSOR_TEST
);
1869 checkGLcall("glDisable(GL_SCISSOR_TEST)");
1873 /* The Direct3D depth bias is specified in normalized depth coordinates. In
1874 * OpenGL the bias is specified in units of "the smallest value that is
1875 * guaranteed to produce a resolvable offset for a given implementation". To
1876 * convert from D3D to GL we need to divide the D3D depth bias by that value.
1877 * We try to detect the value from GL with test draws. On most drivers (r300g,
1878 * 600g, Nvidia, i965 on Mesa) the value is 2^23 for fixed point depth buffers,
1879 * for r200 and i965 on OSX it is 2^24, for r500 on OSX it is 2^22. For floating
1880 * point buffers it is 2^22, 2^23 or 2^24 depending on the GPU. The value does
1881 * not depend on the depth buffer precision on any driver.
1883 * Two games that are picky regarding depth bias are Mass Effect 2 (flickering
1884 * decals) and F.E.A.R and F.E.A.R. 2 (semi-transparent guns).
1886 * Note that SLOPESCALEDEPTHBIAS is a scaling factor for the depth slope, and
1887 * doesn't need to be scaled to account for GL vs D3D differences. */
1888 static void depthbias(struct wined3d_context
*context
, const struct wined3d_state
*state
)
1890 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1891 const struct wined3d_rasterizer_state
*r
= state
->rasterizer_state
;
1892 float scale_bias
= r
? r
->desc
.scale_bias
: 0.0f
;
1899 const_bias
.f
= r
? r
->desc
.depth_bias
: 0.0f
;
1901 if (scale_bias
|| const_bias
.f
)
1903 const struct wined3d_rendertarget_view
*depth
= state
->fb
.depth_stencil
;
1904 float factor
, units
, scale
, clamp
;
1906 clamp
= r
? r
->desc
.depth_bias_clamp
: 0.0f
;
1908 if (context
->d3d_info
->wined3d_creation_flags
& WINED3D_LEGACY_DEPTH_BIAS
)
1910 factor
= units
= -(float)const_bias
.d
;
1916 scale
= depth
->format
->depth_bias_scale
;
1918 TRACE("Depth format %s, using depthbias scale of %.8e.\n",
1919 debug_d3dformat(depth
->format
->id
), scale
);
1923 /* The context manager will reapply this state on a depth stencil change */
1924 TRACE("No depth stencil, using depth bias scale of 0.0.\n");
1928 factor
= scale_bias
;
1929 units
= const_bias
.f
* scale
;
1932 gl_info
->gl_ops
.gl
.p_glEnable(GL_POLYGON_OFFSET_FILL
);
1933 if (gl_info
->supported
[ARB_POLYGON_OFFSET_CLAMP
])
1935 gl_info
->gl_ops
.ext
.p_glPolygonOffsetClamp(factor
, units
, clamp
);
1940 WARN("Ignoring depth bias clamp %.8e.\n", clamp
);
1941 gl_info
->gl_ops
.gl
.p_glPolygonOffset(factor
, units
);
1946 gl_info
->gl_ops
.gl
.p_glDisable(GL_POLYGON_OFFSET_FILL
);
1949 checkGLcall("depth bias");
1952 static void state_zvisible(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1954 if (state
->render_states
[WINED3D_RS_ZVISIBLE
])
1955 FIXME("WINED3D_RS_ZVISIBLE not implemented.\n");
1958 static void state_stippledalpha(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1960 if (state
->render_states
[WINED3D_RS_STIPPLEDALPHA
])
1961 FIXME("Stippled Alpha not supported yet.\n");
1964 static void state_antialias(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1966 if (state
->render_states
[WINED3D_RS_ANTIALIAS
])
1967 FIXME("Antialias not supported yet.\n");
1970 static void state_sample_mask(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1972 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1973 unsigned int sample_mask
= state
->sample_mask
;
1975 TRACE("Setting sample mask to %#x.\n", sample_mask
);
1976 if (sample_mask
!= 0xffffffff)
1978 gl_info
->gl_ops
.gl
.p_glEnable(GL_SAMPLE_MASK
);
1979 checkGLcall("glEnable GL_SAMPLE_MASK");
1980 GL_EXTCALL(glSampleMaski(0, sample_mask
));
1981 checkGLcall("glSampleMaski");
1985 gl_info
->gl_ops
.gl
.p_glDisable(GL_SAMPLE_MASK
);
1986 checkGLcall("glDisable GL_SAMPLE_MASK");
1990 static void state_sample_mask_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1992 WARN("Unsupported in local OpenGL implementation: glSampleMaski.\n");
1995 static void state_patchedgestyle(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1997 if (state
->render_states
[WINED3D_RS_PATCHEDGESTYLE
] != WINED3D_PATCH_EDGE_DISCRETE
)
1998 FIXME("WINED3D_RS_PATCHEDGESTYLE %#x not yet implemented.\n",
1999 state
->render_states
[WINED3D_RS_PATCHEDGESTYLE
]);
2002 static void state_patchsegments(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
2010 if (state
->render_states
[WINED3D_RS_PATCHSEGMENTS
] != tmpvalue
.d
)
2012 static BOOL displayed
= FALSE
;
2014 tmpvalue
.d
= state
->render_states
[WINED3D_RS_PATCHSEGMENTS
];
2016 FIXME("(WINED3D_RS_PATCHSEGMENTS,%f) not yet implemented\n", tmpvalue
.f
);
2022 static void state_positiondegree(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
2024 if (state
->render_states
[WINED3D_RS_POSITIONDEGREE
] != WINED3D_DEGREE_CUBIC
)
2025 FIXME("WINED3D_RS_POSITIONDEGREE %#x not yet implemented.\n",
2026 state
->render_states
[WINED3D_RS_POSITIONDEGREE
]);
2029 static void state_normaldegree(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
2031 if (state
->render_states
[WINED3D_RS_NORMALDEGREE
] != WINED3D_DEGREE_LINEAR
)
2032 FIXME("WINED3D_RS_NORMALDEGREE %#x not yet implemented.\n",
2033 state
->render_states
[WINED3D_RS_NORMALDEGREE
]);
2036 static void state_tessellation(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
2038 if (state
->render_states
[WINED3D_RS_ENABLEADAPTIVETESSELLATION
])
2039 FIXME("WINED3D_RS_ENABLEADAPTIVETESSELLATION %#x not yet implemented.\n",
2040 state
->render_states
[WINED3D_RS_ENABLEADAPTIVETESSELLATION
]);
2043 static void state_nvdb(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
2045 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
2052 if (state
->render_states
[WINED3D_RS_ADAPTIVETESS_X
] == WINED3DFMT_NVDB
)
2054 zmin
.d
= state
->render_states
[WINED3D_RS_ADAPTIVETESS_Z
];
2055 zmax
.d
= state
->render_states
[WINED3D_RS_ADAPTIVETESS_W
];
2057 /* If zmin is larger than zmax INVALID_VALUE error is generated.
2058 * In d3d9 test is not performed in this case*/
2059 if (zmin
.f
<= zmax
.f
)
2061 gl_info
->gl_ops
.gl
.p_glEnable(GL_DEPTH_BOUNDS_TEST_EXT
);
2062 checkGLcall("glEnable(GL_DEPTH_BOUNDS_TEST_EXT)");
2063 GL_EXTCALL(glDepthBoundsEXT(zmin
.f
, zmax
.f
));
2064 checkGLcall("glDepthBoundsEXT(...)");
2068 gl_info
->gl_ops
.gl
.p_glDisable(GL_DEPTH_BOUNDS_TEST_EXT
);
2069 checkGLcall("glDisable(GL_DEPTH_BOUNDS_TEST_EXT)");
2074 gl_info
->gl_ops
.gl
.p_glDisable(GL_DEPTH_BOUNDS_TEST_EXT
);
2075 checkGLcall("glDisable(GL_DEPTH_BOUNDS_TEST_EXT)");
2078 state_tessellation(context
, state
, STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
));
2081 static void state_wrapu(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
2083 if (state
->render_states
[WINED3D_RS_WRAPU
])
2084 FIXME("Render state WINED3D_RS_WRAPU not implemented yet.\n");
2087 static void state_wrapv(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
2089 if (state
->render_states
[WINED3D_RS_WRAPV
])
2090 FIXME("Render state WINED3D_RS_WRAPV not implemented yet.\n");
2093 static void state_monoenable(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
2095 if (state
->render_states
[WINED3D_RS_MONOENABLE
])
2096 FIXME("Render state WINED3D_RS_MONOENABLE not implemented yet.\n");
2099 static void state_rop2(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
2101 if (state
->render_states
[WINED3D_RS_ROP2
])
2102 FIXME("Render state WINED3D_RS_ROP2 not implemented yet.\n");
2105 static void state_planemask(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
2107 if (state
->render_states
[WINED3D_RS_PLANEMASK
])
2108 FIXME("Render state WINED3D_RS_PLANEMASK not implemented yet.\n");
2111 static void state_subpixel(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
2113 if (state
->render_states
[WINED3D_RS_SUBPIXEL
])
2114 FIXME("Render state WINED3D_RS_SUBPIXEL not implemented yet.\n");
2117 static void state_subpixelx(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
2119 if (state
->render_states
[WINED3D_RS_SUBPIXELX
])
2120 FIXME("Render state WINED3D_RS_SUBPIXELX not implemented yet.\n");
2123 static void state_stippleenable(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
2125 if (state
->render_states
[WINED3D_RS_STIPPLEENABLE
])
2126 FIXME("Render state WINED3D_RS_STIPPLEENABLE not implemented yet.\n");
2129 static void state_mipmaplodbias(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
2131 if (state
->render_states
[WINED3D_RS_MIPMAPLODBIAS
])
2132 FIXME("Render state WINED3D_RS_MIPMAPLODBIAS not implemented yet.\n");
2135 static void state_anisotropy(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
2137 if (state
->render_states
[WINED3D_RS_ANISOTROPY
])
2138 FIXME("Render state WINED3D_RS_ANISOTROPY not implemented yet.\n");
2141 static void state_flushbatch(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
2143 if (state
->render_states
[WINED3D_RS_FLUSHBATCH
])
2144 FIXME("Render state WINED3D_RS_FLUSHBATCH not implemented yet.\n");
2147 static void state_translucentsi(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
2149 if (state
->render_states
[WINED3D_RS_TRANSLUCENTSORTINDEPENDENT
])
2150 FIXME("Render state WINED3D_RS_TRANSLUCENTSORTINDEPENDENT not implemented yet.\n");
2153 static void state_extents(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
2155 if (state
->render_states
[WINED3D_RS_EXTENTS
])
2156 FIXME("Render state WINED3D_RS_EXTENTS not implemented yet.\n");
2159 static void state_ckeyblend(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
2161 if (state
->render_states
[WINED3D_RS_COLORKEYBLENDENABLE
])
2162 FIXME("Render state WINED3D_RS_COLORKEYBLENDENABLE not implemented yet.\n");
2165 static void state_swvp(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
2168 if (state
->render_states
[WINED3D_RS_SOFTWAREVERTEXPROCESSING
])
2171 FIXME("Software vertex processing not implemented.\n");
2175 static void get_src_and_opr(DWORD arg
, BOOL is_alpha
, GLenum
* source
, GLenum
* operand
) {
2176 /* The WINED3DTA_ALPHAREPLICATE flag specifies the alpha component of the
2177 * input should be used for all input components. The WINED3DTA_COMPLEMENT
2178 * flag specifies the complement of the input should be used. */
2179 BOOL from_alpha
= is_alpha
|| arg
& WINED3DTA_ALPHAREPLICATE
;
2180 BOOL complement
= arg
& WINED3DTA_COMPLEMENT
;
2182 /* Calculate the operand */
2184 if (from_alpha
) *operand
= GL_ONE_MINUS_SRC_ALPHA
;
2185 else *operand
= GL_ONE_MINUS_SRC_COLOR
;
2187 if (from_alpha
) *operand
= GL_SRC_ALPHA
;
2188 else *operand
= GL_SRC_COLOR
;
2191 /* Calculate the source */
2192 switch (arg
& WINED3DTA_SELECTMASK
) {
2193 case WINED3DTA_CURRENT
: *source
= GL_PREVIOUS_EXT
; break;
2194 case WINED3DTA_DIFFUSE
: *source
= GL_PRIMARY_COLOR_EXT
; break;
2195 case WINED3DTA_TEXTURE
: *source
= GL_TEXTURE
; break;
2196 case WINED3DTA_TFACTOR
: *source
= GL_CONSTANT_EXT
; break;
2197 case WINED3DTA_SPECULAR
:
2199 * According to the GL_ARB_texture_env_combine specs, SPECULAR is
2200 * 'Secondary color' and isn't supported until base GL supports it
2201 * There is no concept of temp registers as far as I can tell
2203 FIXME("Unhandled texture arg WINED3DTA_SPECULAR\n");
2204 *source
= GL_TEXTURE
;
2207 FIXME("Unrecognized texture arg %#x\n", arg
);
2208 *source
= GL_TEXTURE
;
2213 /* Setup the texture operations texture stage states */
2214 static void set_tex_op(const struct wined3d_gl_info
*gl_info
, const struct wined3d_state
*state
,
2215 BOOL isAlpha
, int Stage
, enum wined3d_texture_op op
, DWORD arg1
, DWORD arg2
, DWORD arg3
)
2217 GLenum src1
, src2
, src3
;
2218 GLenum opr1
, opr2
, opr3
;
2220 GLenum src0_target
, src1_target
, src2_target
;
2221 GLenum opr0_target
, opr1_target
, opr2_target
;
2223 GLenum opr
=0, invopr
, src3_target
, opr3_target
;
2224 BOOL Handled
= FALSE
;
2226 TRACE("Alpha?(%d), Stage:%d Op(%s), a1(%d), a2(%d), a3(%d)\n", isAlpha
, Stage
, debug_d3dtop(op
), arg1
, arg2
, arg3
);
2228 /* Operations usually involve two args, src0 and src1 and are operations
2229 * of the form (a1 <operation> a2). However, some of the more complex
2230 * operations take 3 parameters. Instead of the (sensible) addition of a3,
2231 * Microsoft added in a third parameter called a0. Therefore these are
2232 * operations of the form a0 <operation> a1 <operation> a2. I.e., the new
2233 * parameter goes to the front.
2235 * However, below we treat the new (a0) parameter as src2/opr2, so in the
2236 * actual functions below, expect their syntax to differ slightly to those
2237 * listed in the manuals. I.e., replace arg1 with arg3, arg2 with arg1 and
2238 * arg3 with arg2. This affects WINED3DTOP_MULTIPLYADD and WINED3DTOP_LERP. */
2242 comb_target
= GL_COMBINE_ALPHA
;
2243 src0_target
= GL_SOURCE0_ALPHA
;
2244 src1_target
= GL_SOURCE1_ALPHA
;
2245 src2_target
= GL_SOURCE2_ALPHA
;
2246 opr0_target
= GL_OPERAND0_ALPHA
;
2247 opr1_target
= GL_OPERAND1_ALPHA
;
2248 opr2_target
= GL_OPERAND2_ALPHA
;
2249 scal_target
= GL_ALPHA_SCALE
;
2253 comb_target
= GL_COMBINE_RGB
;
2254 src0_target
= GL_SOURCE0_RGB
;
2255 src1_target
= GL_SOURCE1_RGB
;
2256 src2_target
= GL_SOURCE2_RGB
;
2257 opr0_target
= GL_OPERAND0_RGB
;
2258 opr1_target
= GL_OPERAND1_RGB
;
2259 opr2_target
= GL_OPERAND2_RGB
;
2260 scal_target
= GL_RGB_SCALE
;
2263 /* If a texture stage references an invalid texture unit the stage just
2264 * passes through the result from the previous stage */
2265 if (is_invalid_op(state
, Stage
, op
, arg1
, arg2
, arg3
))
2267 arg1
= WINED3DTA_CURRENT
;
2268 op
= WINED3D_TOP_SELECT_ARG1
;
2271 if (isAlpha
&& !state
->textures
[Stage
] && arg1
== WINED3DTA_TEXTURE
)
2273 get_src_and_opr(WINED3DTA_DIFFUSE
, isAlpha
, &src1
, &opr1
);
2275 get_src_and_opr(arg1
, isAlpha
, &src1
, &opr1
);
2277 get_src_and_opr(arg2
, isAlpha
, &src2
, &opr2
);
2278 get_src_and_opr(arg3
, isAlpha
, &src3
, &opr3
);
2280 TRACE("ct(%x), 1:(%x,%x), 2:(%x,%x), 3:(%x,%x)\n", comb_target
, src1
, opr1
, src2
, opr2
, src3
, opr3
);
2282 Handled
= TRUE
; /* Assume will be handled */
2284 /* Other texture operations require special extensions: */
2285 if (gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
2289 invopr
= GL_ONE_MINUS_SRC_ALPHA
;
2290 src3_target
= GL_SOURCE3_ALPHA_NV
;
2291 opr3_target
= GL_OPERAND3_ALPHA_NV
;
2294 invopr
= GL_ONE_MINUS_SRC_COLOR
;
2295 src3_target
= GL_SOURCE3_RGB_NV
;
2296 opr3_target
= GL_OPERAND3_RGB_NV
;
2300 case WINED3D_TOP_DISABLE
: /* Only for alpha */
2301 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2302 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2303 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_PREVIOUS_EXT
);
2304 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2305 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_SRC_ALPHA
);
2306 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2307 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2308 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2309 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2310 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2311 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2312 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_ZERO");
2313 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2314 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2315 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2316 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2317 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2318 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2321 case WINED3D_TOP_SELECT_ARG1
: /* = a1 * 1 + 0 * 0 */
2322 case WINED3D_TOP_SELECT_ARG2
: /* = a2 * 1 + 0 * 0 */
2323 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2324 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2325 if (op
== WINED3D_TOP_SELECT_ARG1
)
2327 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2328 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2329 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2330 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2334 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src2
);
2335 checkGLcall("GL_TEXTURE_ENV, src0_target, src2");
2336 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr2
);
2337 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr2");
2339 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2340 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2341 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2342 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2343 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2344 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_ZERO");
2345 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2346 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2347 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2348 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2349 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2350 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2353 case WINED3D_TOP_MODULATE
:
2354 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2355 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2356 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2357 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2358 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2359 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2360 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2361 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2362 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2363 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2364 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2365 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2366 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2367 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2368 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2369 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2370 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2371 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2372 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2373 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2375 case WINED3D_TOP_MODULATE_2X
:
2376 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2377 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2378 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2379 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2380 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2381 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2382 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2383 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2384 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2385 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2386 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2387 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2388 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2389 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2390 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2391 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2392 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2393 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2394 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2395 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2397 case WINED3D_TOP_MODULATE_4X
:
2398 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2399 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2400 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2401 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2402 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2403 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2404 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2405 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2406 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2407 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2408 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2409 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2410 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2411 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2412 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2413 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2414 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2415 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2416 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 4);
2417 checkGLcall("GL_TEXTURE_ENV, scal_target, 4");
2420 case WINED3D_TOP_ADD
:
2421 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2422 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2423 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2424 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2425 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2426 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2427 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2428 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2429 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2430 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2431 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2432 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2433 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2434 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2435 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2436 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2437 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2438 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2439 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2440 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2443 case WINED3D_TOP_ADD_SIGNED
:
2444 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD_SIGNED
);
2445 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2446 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2447 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2448 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2449 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2450 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2451 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2452 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2453 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2454 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2455 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2456 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2457 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2458 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2459 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2460 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2461 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2462 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2463 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2466 case WINED3D_TOP_ADD_SIGNED_2X
:
2467 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD_SIGNED
);
2468 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2469 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2470 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2471 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2472 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2473 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2474 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2475 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2476 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2477 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2478 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2479 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2480 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2481 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2482 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2483 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2484 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2485 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2486 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2489 case WINED3D_TOP_ADD_SMOOTH
:
2490 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2491 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2492 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2493 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2494 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2495 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2496 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2497 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2498 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2499 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2500 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2501 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2502 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2503 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2504 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
2505 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2507 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2508 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2509 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2510 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2512 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2513 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2514 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2515 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2518 case WINED3D_TOP_BLEND_DIFFUSE_ALPHA
:
2519 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2520 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2521 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2522 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2523 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2524 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2525 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_PRIMARY_COLOR
);
2526 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_PRIMARY_COLOR");
2527 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2528 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2529 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2530 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2531 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2532 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2533 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_PRIMARY_COLOR
);
2534 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_PRIMARY_COLOR");
2535 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2536 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2537 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2538 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2540 case WINED3D_TOP_BLEND_TEXTURE_ALPHA
:
2541 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2542 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2543 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2544 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2545 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2546 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2547 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_TEXTURE
);
2548 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_TEXTURE");
2549 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2550 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2551 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2552 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2553 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2554 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2555 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_TEXTURE
);
2556 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_TEXTURE");
2557 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2558 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2559 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2560 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2562 case WINED3D_TOP_BLEND_FACTOR_ALPHA
:
2563 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2564 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2565 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2566 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2567 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2568 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2569 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_CONSTANT
);
2570 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_CONSTANT");
2571 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2572 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2573 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2574 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2575 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2576 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2577 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_CONSTANT
);
2578 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_CONSTANT");
2579 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2580 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2581 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2582 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2584 case WINED3D_TOP_BLEND_TEXTURE_ALPHA_PM
:
2585 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2586 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2587 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2588 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2589 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2590 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2591 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2592 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2593 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2594 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2595 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2596 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2597 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2598 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2599 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_TEXTURE
);
2600 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_TEXTURE");
2601 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2602 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2603 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2604 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2606 case WINED3D_TOP_MODULATE_ALPHA_ADD_COLOR
:
2607 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2608 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2609 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
); /* a0 = src1/opr1 */
2610 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2611 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2612 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1"); /* a1 = 1 (see docs) */
2613 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2614 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2615 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2616 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2617 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
); /* a2 = arg2 */
2618 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2619 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2620 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2"); /* a3 = src1 alpha */
2621 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
2622 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2624 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2625 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2627 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2628 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2629 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2630 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2632 case WINED3D_TOP_MODULATE_COLOR_ADD_ALPHA
:
2633 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2634 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2635 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2636 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2637 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2638 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2639 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2640 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2641 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2642 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2643 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
2644 checkGLcall("GL_TEXTURE_ENV, src2_target, src1");
2646 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2647 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2649 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2650 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2651 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2652 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2653 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2654 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2655 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2656 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2658 case WINED3D_TOP_MODULATE_INVALPHA_ADD_COLOR
:
2659 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2660 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2661 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2662 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2663 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2664 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2665 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2666 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2667 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2668 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2669 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2670 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2671 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2672 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2673 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
2674 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2676 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2677 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2678 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2679 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2681 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2682 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2683 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2684 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2686 case WINED3D_TOP_MODULATE_INVCOLOR_ADD_ALPHA
:
2687 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2688 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2689 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2690 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2692 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2693 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2694 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2695 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2697 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2698 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2699 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2700 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2701 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2702 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2703 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
2704 checkGLcall("GL_TEXTURE_ENV, src2_target, src1");
2706 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2707 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2709 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2710 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2711 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2712 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2713 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2714 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2715 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2716 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2718 case WINED3D_TOP_MULTIPLY_ADD
:
2719 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2720 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2721 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src3
);
2722 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2723 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr3
);
2724 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2725 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2726 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2727 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2728 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2729 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
2730 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2731 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr1
);
2732 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2733 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src2
);
2734 checkGLcall("GL_TEXTURE_ENV, src3_target, src3");
2735 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr2
);
2736 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr3");
2737 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2738 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2741 case WINED3D_TOP_BUMPENVMAP
:
2742 case WINED3D_TOP_BUMPENVMAP_LUMINANCE
:
2743 FIXME("Implement bump environment mapping in GL_NV_texture_env_combine4 path\n");
2752 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_COMBINE4_NV
);
2753 checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV");
2757 } /* GL_NV_texture_env_combine4 */
2759 Handled
= TRUE
; /* Again, assume handled */
2761 case WINED3D_TOP_DISABLE
: /* Only for alpha */
2762 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
2763 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2764 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_PREVIOUS_EXT
);
2765 checkGLcall("GL_TEXTURE_ENV, src0_target, GL_PREVIOUS_EXT");
2766 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_SRC_ALPHA
);
2767 checkGLcall("GL_TEXTURE_ENV, opr0_target, GL_SRC_ALPHA");
2768 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2769 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2771 case WINED3D_TOP_SELECT_ARG1
:
2772 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
2773 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2774 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2775 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2776 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2777 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2778 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2779 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2781 case WINED3D_TOP_SELECT_ARG2
:
2782 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
2783 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2784 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src2
);
2785 checkGLcall("GL_TEXTURE_ENV, src0_target, src2");
2786 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr2
);
2787 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr2");
2788 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2789 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2791 case WINED3D_TOP_MODULATE
:
2792 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
2793 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2794 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2795 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2796 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2797 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2798 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2799 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2800 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2801 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2802 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2803 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2805 case WINED3D_TOP_MODULATE_2X
:
2806 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
2807 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2808 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2809 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2810 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2811 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2812 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2813 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2814 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2815 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2816 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2817 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2819 case WINED3D_TOP_MODULATE_4X
:
2820 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
2821 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2822 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2823 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2824 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2825 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2826 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2827 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2828 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2829 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2830 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 4);
2831 checkGLcall("GL_TEXTURE_ENV, scal_target, 4");
2833 case WINED3D_TOP_ADD
:
2834 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2835 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2836 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2837 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2838 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2839 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2840 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2841 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2842 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2843 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2844 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2845 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2847 case WINED3D_TOP_ADD_SIGNED
:
2848 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD_SIGNED
);
2849 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2850 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2851 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2852 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2853 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2854 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2855 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2856 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2857 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2858 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2859 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2861 case WINED3D_TOP_ADD_SIGNED_2X
:
2862 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD_SIGNED
);
2863 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2864 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2865 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2866 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2867 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2868 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2869 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2870 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2871 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2872 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2873 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2875 case WINED3D_TOP_SUBTRACT
:
2876 if (gl_info
->supported
[ARB_TEXTURE_ENV_COMBINE
])
2878 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_SUBTRACT
);
2879 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_SUBTRACT");
2880 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2881 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2882 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2883 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2884 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2885 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2886 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2887 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2888 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2889 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2891 FIXME("This version of opengl does not support GL_SUBTRACT\n");
2895 case WINED3D_TOP_BLEND_DIFFUSE_ALPHA
:
2896 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2897 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2898 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2899 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2900 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2901 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2902 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2903 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2904 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2905 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2906 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_PRIMARY_COLOR
);
2907 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_PRIMARY_COLOR");
2908 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2909 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2910 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2911 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2913 case WINED3D_TOP_BLEND_TEXTURE_ALPHA
:
2914 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2915 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2916 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2917 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2918 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2919 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2920 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2921 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2922 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2923 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2924 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_TEXTURE
);
2925 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_TEXTURE");
2926 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2927 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2928 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2929 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2931 case WINED3D_TOP_BLEND_FACTOR_ALPHA
:
2932 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2933 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2934 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2935 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2936 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2937 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2938 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2939 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2940 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2941 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2942 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_CONSTANT
);
2943 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_CONSTANT");
2944 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2945 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2946 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2947 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2949 case WINED3D_TOP_BLEND_CURRENT_ALPHA
:
2950 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2951 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2952 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2953 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2954 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2955 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2956 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2957 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2958 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2959 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2960 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_PREVIOUS
);
2961 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_PREVIOUS");
2962 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2963 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2964 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2965 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2967 case WINED3D_TOP_DOTPRODUCT3
:
2968 if (gl_info
->supported
[ARB_TEXTURE_ENV_DOT3
])
2970 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_DOT3_RGBA_ARB
);
2971 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_ARB");
2973 else if (gl_info
->supported
[EXT_TEXTURE_ENV_DOT3
])
2975 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_DOT3_RGBA_EXT
);
2976 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_EXT");
2978 FIXME("This version of opengl does not support GL_DOT3\n");
2980 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2981 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2982 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2983 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2984 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2985 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2986 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2987 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2988 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2989 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2991 case WINED3D_TOP_LERP
:
2992 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2993 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2994 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2995 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2996 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2997 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2998 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2999 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
3000 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
3001 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
3002 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src3
);
3003 checkGLcall("GL_TEXTURE_ENV, src2_target, src3");
3004 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr3
);
3005 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr3");
3006 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
3007 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
3009 case WINED3D_TOP_ADD_SMOOTH
:
3010 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
3012 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
3013 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
3014 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
3015 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
3017 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
3018 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
3019 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
3020 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
3022 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
3023 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
3024 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
3025 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
3026 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
3027 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
3028 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
3029 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
3030 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
3031 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
3032 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
3033 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
3037 case WINED3D_TOP_BLEND_TEXTURE_ALPHA_PM
:
3038 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
3040 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
3041 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
3042 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_TEXTURE
);
3043 checkGLcall("GL_TEXTURE_ENV, src0_target, GL_TEXTURE");
3044 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_ONE_MINUS_SRC_ALPHA
);
3045 checkGLcall("GL_TEXTURE_ENV, opr0_target, GL_ONE_MINUS_SRC_APHA");
3046 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
3047 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
3048 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
3049 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
3050 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
3051 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
3052 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
3053 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
3054 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
3055 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
3059 case WINED3D_TOP_MODULATE_ALPHA_ADD_COLOR
:
3060 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
3062 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
3063 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
3064 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
3065 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
3067 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
3068 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
3069 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
3070 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
3072 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
3073 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
3074 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
3075 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
3076 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
3077 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
3078 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
3079 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
3080 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
3081 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
3082 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
3083 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
3087 case WINED3D_TOP_MODULATE_COLOR_ADD_ALPHA
:
3088 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
3090 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
3091 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
3092 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
3093 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
3094 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
3095 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
3096 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
3097 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
3099 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
3100 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
3101 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
3102 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
3104 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr
);
3105 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr");
3106 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
3107 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
3108 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
3109 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
3110 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
3111 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
3115 case WINED3D_TOP_MODULATE_INVALPHA_ADD_COLOR
:
3116 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
3118 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
3119 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
3120 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
3121 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
3123 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
3124 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
3125 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
3126 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
3128 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
3129 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
3130 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
3131 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
3132 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
3133 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
3134 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
3135 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
3136 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
3137 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
3138 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
3139 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
3143 case WINED3D_TOP_MODULATE_INVCOLOR_ADD_ALPHA
:
3144 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
3146 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
3147 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
3148 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
3149 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
3151 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
3152 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
3153 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
3154 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
3156 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
3157 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
3158 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
3159 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
3161 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
3162 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
3163 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
3164 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
3166 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr
);
3167 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr");
3168 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
3169 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
3170 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
3171 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
3172 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
3173 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
3177 case WINED3D_TOP_MULTIPLY_ADD
:
3178 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
3180 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
3181 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
3182 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
3183 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
3184 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
3185 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
3186 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src3
);
3187 checkGLcall("GL_TEXTURE_ENV, src1_target, src3");
3188 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr3
);
3189 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr3");
3190 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
3191 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
3192 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
3193 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
3194 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
3195 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
3199 case WINED3D_TOP_BUMPENVMAP_LUMINANCE
:
3200 case WINED3D_TOP_BUMPENVMAP
:
3201 if (gl_info
->supported
[NV_TEXTURE_SHADER2
])
3203 /* Technically texture shader support without register combiners is possible, but not expected to occur
3204 * on real world cards, so for now a fixme should be enough
3206 FIXME("Implement bump mapping with GL_NV_texture_shader in non register combiner path\n");
3216 BOOL combineOK
= TRUE
;
3217 if (gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
3222 op2
= state
->texture_states
[Stage
][WINED3D_TSS_COLOR_OP
];
3224 op2
= state
->texture_states
[Stage
][WINED3D_TSS_ALPHA_OP
];
3226 /* Note: If COMBINE4 in effect can't go back to combine! */
3229 case WINED3D_TOP_ADD_SMOOTH
:
3230 case WINED3D_TOP_BLEND_TEXTURE_ALPHA_PM
:
3231 case WINED3D_TOP_MODULATE_ALPHA_ADD_COLOR
:
3232 case WINED3D_TOP_MODULATE_COLOR_ADD_ALPHA
:
3233 case WINED3D_TOP_MODULATE_INVALPHA_ADD_COLOR
:
3234 case WINED3D_TOP_MODULATE_INVCOLOR_ADD_ALPHA
:
3235 case WINED3D_TOP_MULTIPLY_ADD
:
3236 /* Ignore those implemented in both cases */
3239 case WINED3D_TOP_SELECT_ARG1
:
3240 case WINED3D_TOP_SELECT_ARG2
:
3245 FIXME("Can't use COMBINE4 and COMBINE together, thisop=%s, otherop=%s, isAlpha(%d)\n", debug_d3dtop(op
), debug_d3dtop(op2
), isAlpha
);
3253 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_COMBINE
);
3254 checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE");
3260 /* After all the extensions, if still unhandled, report fixme */
3261 FIXME("Unhandled texture operation %s\n", debug_d3dtop(op
));
3265 static void tex_colorop(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3267 unsigned int stage
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3268 struct wined3d_context_gl
*context_gl
= wined3d_context_gl(context
);
3269 BOOL tex_used
= context
->fixed_function_usage_map
& (1u << stage
);
3270 unsigned int mapped_stage
= context_gl
->tex_unit_map
[stage
];
3271 const struct wined3d_gl_info
*gl_info
= context_gl
->gl_info
;
3273 TRACE("Setting color op for stage %d\n", stage
);
3275 /* Using a pixel shader? Don't care for anything here, the shader applying does it */
3276 if (use_ps(state
)) return;
3278 if (stage
!= mapped_stage
) WARN("Using non 1:1 mapping: %d -> %d!\n", stage
, mapped_stage
);
3280 if (mapped_stage
!= WINED3D_UNMAPPED_STAGE
)
3282 if (tex_used
&& mapped_stage
>= gl_info
->limits
.textures
)
3284 FIXME("Attempt to enable unsupported stage!\n");
3287 wined3d_context_gl_active_texture(context_gl
, gl_info
, mapped_stage
);
3290 if (stage
>= context
->lowest_disabled_stage
)
3292 TRACE("Stage disabled\n");
3293 if (mapped_stage
!= WINED3D_UNMAPPED_STAGE
)
3295 /* Disable everything here */
3296 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_2D
);
3297 checkGLcall("glDisable(GL_TEXTURE_2D)");
3298 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_3D
);
3299 checkGLcall("glDisable(GL_TEXTURE_3D)");
3300 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
3302 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB
);
3303 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
3305 if (gl_info
->supported
[ARB_TEXTURE_RECTANGLE
])
3307 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_RECTANGLE_ARB
);
3308 checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)");
3315 /* The sampler will also activate the correct texture dimensions, so no
3316 * need to do it here if the sampler for this stage is dirty. */
3317 if (!isStateDirty(context
, STATE_SAMPLER(stage
)) && tex_used
)
3318 texture_activate_dimensions(state
->textures
[stage
], gl_info
);
3320 set_tex_op(gl_info
, state
, FALSE
, stage
,
3321 state
->texture_states
[stage
][WINED3D_TSS_COLOR_OP
],
3322 state
->texture_states
[stage
][WINED3D_TSS_COLOR_ARG1
],
3323 state
->texture_states
[stage
][WINED3D_TSS_COLOR_ARG2
],
3324 state
->texture_states
[stage
][WINED3D_TSS_COLOR_ARG0
]);
3327 void tex_alphaop(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3329 unsigned int stage
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3330 struct wined3d_context_gl
*context_gl
= wined3d_context_gl(context
);
3331 BOOL tex_used
= context
->fixed_function_usage_map
& (1u << stage
);
3332 const struct wined3d_gl_info
*gl_info
= context_gl
->gl_info
;
3333 unsigned int mapped_stage
= context_gl
->tex_unit_map
[stage
];
3334 DWORD op
, arg1
, arg2
, arg0
;
3336 TRACE("Setting alpha op for stage %d\n", stage
);
3337 /* Do not care for enabled / disabled stages, just assign the settings. colorop disables / enables required stuff */
3338 if (mapped_stage
!= WINED3D_UNMAPPED_STAGE
)
3340 if (tex_used
&& mapped_stage
>= gl_info
->limits
.textures
)
3342 FIXME("Attempt to enable unsupported stage!\n");
3345 wined3d_context_gl_active_texture(context_gl
, gl_info
, mapped_stage
);
3348 op
= state
->texture_states
[stage
][WINED3D_TSS_ALPHA_OP
];
3349 arg1
= state
->texture_states
[stage
][WINED3D_TSS_ALPHA_ARG1
];
3350 arg2
= state
->texture_states
[stage
][WINED3D_TSS_ALPHA_ARG2
];
3351 arg0
= state
->texture_states
[stage
][WINED3D_TSS_ALPHA_ARG0
];
3353 if (state
->render_states
[WINED3D_RS_COLORKEYENABLE
] && !stage
&& state
->textures
[0])
3355 struct wined3d_texture_gl
*texture_gl
= wined3d_texture_gl(state
->textures
[0]);
3356 GLenum texture_dimensions
= texture_gl
->target
;
3358 if (texture_dimensions
== GL_TEXTURE_2D
|| texture_dimensions
== GL_TEXTURE_RECTANGLE_ARB
)
3360 if (texture_gl
->t
.async
.color_key_flags
& WINED3D_CKEY_SRC_BLT
3361 && !texture_gl
->t
.resource
.format
->alpha_size
)
3363 /* Color keying needs to pass alpha values from the texture through to have the alpha test work
3364 * properly. On the other hand applications can still use texture combiners apparently. This code
3365 * takes care that apps cannot remove the texture's alpha channel entirely.
3367 * The fixup is required for Prince of Persia 3D(prison bars), while Moto racer 2 requires
3368 * D3DTOP_MODULATE to work on color keyed surfaces. Aliens vs Predator 1 uses color keyed textures
3369 * and alpha component of diffuse color to draw things like translucent text and perform other
3372 * Aliens vs Predator 1 relies on diffuse alpha having an effect, so it cannot be ignored. To
3373 * provide the behavior expected by the game, while emulating the colorkey, diffuse alpha must be
3374 * modulated with texture alpha. OTOH, Moto racer 2 at some points sets alphaop/alphaarg to
3375 * SELECTARG/CURRENT, yet puts garbage in diffuse alpha (zeroes). This works on native, because the
3376 * game disables alpha test and alpha blending. Alpha test is overwritten by wine's for purposes of
3377 * color-keying though, so this will lead to missing geometry if texture alpha is modulated (pixels
3378 * fail alpha test). To get around this, blend state is checked: if the app enables alpha blending,
3379 * it can be expected to provide meaningful values in diffuse alpha, so it should be modulated with
3380 * texture alpha; otherwise, selecting diffuse alpha is ignored in favour of texture alpha.
3382 * What to do with multitexturing? So far no app has been found that uses color keying with
3384 if (op
== WINED3D_TOP_DISABLE
)
3386 arg1
= WINED3DTA_TEXTURE
;
3387 op
= WINED3D_TOP_SELECT_ARG1
;
3389 else if (op
== WINED3D_TOP_SELECT_ARG1
&& arg1
!= WINED3DTA_TEXTURE
)
3391 if (state
->blend_state
&& state
->blend_state
->desc
.rt
[0].enable
)
3393 arg2
= WINED3DTA_TEXTURE
;
3394 op
= WINED3D_TOP_MODULATE
;
3396 else arg1
= WINED3DTA_TEXTURE
;
3398 else if (op
== WINED3D_TOP_SELECT_ARG2
&& arg2
!= WINED3DTA_TEXTURE
)
3400 if (state
->blend_state
&& state
->blend_state
->desc
.rt
[0].enable
)
3402 arg1
= WINED3DTA_TEXTURE
;
3403 op
= WINED3D_TOP_MODULATE
;
3405 else arg2
= WINED3DTA_TEXTURE
;
3411 /* tex_alphaop is shared between the ffp and nvrc because the difference only comes down to
3412 * this if block here, and the other code(color keying, texture unit selection) are the same
3414 TRACE("Setting alpha op for stage %d\n", stage
);
3415 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
3417 set_tex_op_nvrc(gl_info
, state
, TRUE
, stage
, op
, arg1
, arg2
, arg0
,
3418 mapped_stage
, state
->texture_states
[stage
][WINED3D_TSS_RESULT_ARG
]);
3422 set_tex_op(gl_info
, state
, TRUE
, stage
, op
, arg1
, arg2
, arg0
);
3426 static void transform_texture(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3428 unsigned int tex
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3429 struct wined3d_context_gl
*context_gl
= wined3d_context_gl(context
);
3430 const struct wined3d_gl_info
*gl_info
= context_gl
->gl_info
;
3431 unsigned int mapped_stage
= context_gl
->tex_unit_map
[tex
];
3432 struct wined3d_matrix mat
;
3436 TRACE("Using a vertex shader, skipping.\n");
3440 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
) return;
3441 if (mapped_stage
>= gl_info
->limits
.textures
) return;
3443 wined3d_context_gl_active_texture(context_gl
, gl_info
, mapped_stage
);
3444 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_TEXTURE
);
3445 checkGLcall("glMatrixMode(GL_TEXTURE)");
3447 get_texture_matrix(context
, state
, mapped_stage
, &mat
);
3449 gl_info
->gl_ops
.gl
.p_glLoadMatrixf(&mat
._11
);
3450 checkGLcall("glLoadMatrixf");
3453 static void tex_coordindex(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3455 unsigned int stage
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3456 struct wined3d_context_gl
*context_gl
= wined3d_context_gl(context
);
3457 const struct wined3d_gl_info
*gl_info
= context_gl
->gl_info
;
3458 unsigned int mapped_stage
= context_gl
->tex_unit_map
[stage
];
3460 static const GLfloat s_plane
[] = { 1.0f
, 0.0f
, 0.0f
, 0.0f
};
3461 static const GLfloat t_plane
[] = { 0.0f
, 1.0f
, 0.0f
, 0.0f
};
3462 static const GLfloat r_plane
[] = { 0.0f
, 0.0f
, 1.0f
, 0.0f
};
3463 static const GLfloat q_plane
[] = { 0.0f
, 0.0f
, 0.0f
, 1.0f
};
3465 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
)
3467 TRACE("No texture unit mapped to stage %d. Skipping texture coordinates.\n", stage
);
3471 if (mapped_stage
>= min(gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_PIXEL
], WINED3D_MAX_FRAGMENT_SAMPLERS
))
3473 WARN("stage %u not mapped to a valid texture unit (%u)\n", stage
, mapped_stage
);
3476 wined3d_context_gl_active_texture(context_gl
, gl_info
, mapped_stage
);
3478 /* Values 0-7 are indexes into the FVF tex coords - See comments in DrawPrimitive
3480 * FIXME: When using generated texture coordinates, the index value is used to specify the wrapping mode.
3481 * eg. SetTextureStageState( 0, WINED3D_TSS_TEXCOORDINDEX, WINED3D_TSS_TCI_CAMERASPACEPOSITION | 1 );
3482 * means use the vertex position (camera-space) as the input texture coordinates
3483 * for this texture stage, and the wrap mode set in the WINED3D_RS_WRAP1 render
3484 * state. We do not (yet) support the WINED3DRENDERSTATE_WRAPx values, nor tie them up
3485 * to the TEXCOORDINDEX value
3487 switch (state
->texture_states
[stage
][WINED3D_TSS_TEXCOORD_INDEX
] & 0xffff0000)
3489 case WINED3DTSS_TCI_PASSTHRU
:
3490 /* Use the specified texture coordinates contained within the
3491 * vertex format. This value resolves to zero. */
3492 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_S
);
3493 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_T
);
3494 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_R
);
3495 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_Q
);
3496 checkGLcall("WINED3DTSS_TCI_PASSTHRU - Disable texgen.");
3499 case WINED3DTSS_TCI_CAMERASPACEPOSITION
:
3500 /* CameraSpacePosition means use the vertex position, transformed to camera space,
3501 * as the input texture coordinates for this stage's texture transformation. This
3502 * equates roughly to EYE_LINEAR */
3504 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3505 gl_info
->gl_ops
.gl
.p_glPushMatrix();
3506 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
3507 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
3508 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
3509 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
3510 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
3511 gl_info
->gl_ops
.gl
.p_glPopMatrix();
3512 checkGLcall("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set eye plane.");
3514 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
3515 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
3516 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
3517 checkGLcall("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set texgen mode.");
3519 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_S
);
3520 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_T
);
3521 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_R
);
3522 checkGLcall("WINED3DTSS_TCI_CAMERASPACEPOSITION - Enable texgen.");
3526 case WINED3DTSS_TCI_CAMERASPACENORMAL
:
3527 /* Note that NV_TEXGEN_REFLECTION support is implied when
3528 * ARB_TEXTURE_CUBE_MAP is supported */
3529 if (!gl_info
->supported
[NV_TEXGEN_REFLECTION
])
3531 FIXME("WINED3DTSS_TCI_CAMERASPACENORMAL not supported.\n");
3535 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3536 gl_info
->gl_ops
.gl
.p_glPushMatrix();
3537 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
3538 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
3539 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
3540 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
3541 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
3542 gl_info
->gl_ops
.gl
.p_glPopMatrix();
3543 checkGLcall("WINED3DTSS_TCI_CAMERASPACENORMAL - Set eye plane.");
3545 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
3546 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
3547 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
3548 checkGLcall("WINED3DTSS_TCI_CAMERASPACENORMAL - Set texgen mode.");
3550 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_S
);
3551 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_T
);
3552 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_R
);
3553 checkGLcall("WINED3DTSS_TCI_CAMERASPACENORMAL - Enable texgen.");
3557 case WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR
:
3558 /* Note that NV_TEXGEN_REFLECTION support is implied when
3559 * ARB_TEXTURE_CUBE_MAP is supported */
3560 if (!gl_info
->supported
[NV_TEXGEN_REFLECTION
])
3562 FIXME("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR not supported.\n");
3566 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3567 gl_info
->gl_ops
.gl
.p_glPushMatrix();
3568 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
3569 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
3570 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
3571 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
3572 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
3573 gl_info
->gl_ops
.gl
.p_glPopMatrix();
3574 checkGLcall("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Set eye plane.");
3576 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
3577 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
3578 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
3579 checkGLcall("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Set texgen mode.");
3581 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_S
);
3582 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_T
);
3583 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_R
);
3584 checkGLcall("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Enable texgen.");
3588 case WINED3DTSS_TCI_SPHEREMAP
:
3589 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_SPHERE_MAP
);
3590 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_SPHERE_MAP
);
3591 checkGLcall("WINED3DTSS_TCI_SPHEREMAP - Set texgen mode.");
3593 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_S
);
3594 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_T
);
3595 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_R
);
3596 checkGLcall("WINED3DTSS_TCI_SPHEREMAP - Enable texgen.");
3601 FIXME("Unhandled WINED3D_TSS_TEXCOORD_INDEX %#x.\n",
3602 state
->texture_states
[stage
][WINED3D_TSS_TEXCOORD_INDEX
]);
3603 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_S
);
3604 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_T
);
3605 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_R
);
3606 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_Q
);
3607 checkGLcall("Disable texgen.");
3612 /* Update the texture matrix. */
3613 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_TEXTURE0
+ stage
)))
3614 transform_texture(context
, state
, STATE_TEXTURESTAGE(stage
, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
));
3616 if (!isStateDirty(context
, STATE_VDECL
) && context
->namedArraysLoaded
)
3618 /* Reload the arrays if we are using fixed function arrays to reflect the selected coord input
3619 * source. Call loadTexCoords directly because there is no need to reparse the vertex declaration
3620 * and do all the things linked to it
3621 * TODO: Tidy that up to reload only the arrays of the changed unit
3623 GLuint curVBO
= gl_info
->supported
[ARB_VERTEX_BUFFER_OBJECT
] ? ~0U : 0;
3625 wined3d_context_gl_unload_tex_coords(context_gl
);
3626 wined3d_context_gl_load_tex_coords(context_gl
, &context
->stream_info
, &curVBO
, state
);
3630 static void sampler_texmatrix(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3632 const DWORD sampler
= state_id
- STATE_SAMPLER(0);
3633 const struct wined3d_texture
*texture
= state
->textures
[sampler
];
3635 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
3640 /* The fixed function np2 texture emulation uses the texture matrix to fix up the coordinates
3641 * wined3d_texture_apply_state_changes() multiplies the set matrix with a fixup matrix. Before the
3642 * scaling is reapplied or removed, the texture matrix has to be reapplied.
3644 if (sampler
< WINED3D_MAX_TEXTURES
)
3646 const BOOL tex_is_pow2
= !(texture
->flags
& WINED3D_TEXTURE_POW2_MAT_IDENT
);
3648 if (tex_is_pow2
|| (context
->lastWasPow2Texture
& (1u << sampler
)))
3651 context
->lastWasPow2Texture
|= 1u << sampler
;
3653 context
->lastWasPow2Texture
&= ~(1u << sampler
);
3655 transform_texture(context
, state
, STATE_TEXTURESTAGE(sampler
, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
));
3660 static enum wined3d_texture_address
wined3d_texture_gl_address_mode(const struct wined3d_texture_gl
*texture_gl
,
3661 enum wined3d_texture_address t
)
3663 if (t
< WINED3D_TADDRESS_WRAP
|| t
> WINED3D_TADDRESS_MIRROR_ONCE
)
3665 FIXME("Unrecognized or unsupported texture address mode %#x.\n", t
);
3666 return WINED3D_TADDRESS_WRAP
;
3669 /* Cubemaps are always set to clamp, regardless of the sampler state. */
3670 if (texture_gl
->target
== GL_TEXTURE_CUBE_MAP_ARB
|| ((texture_gl
->t
.flags
& WINED3D_TEXTURE_COND_NP2
)
3671 && t
== WINED3D_TADDRESS_WRAP
))
3672 return WINED3D_TADDRESS_CLAMP
;
3677 static void wined3d_sampler_desc_from_sampler_states(struct wined3d_sampler_desc
*desc
,
3678 const struct wined3d_context_gl
*context_gl
, const DWORD
*sampler_states
,
3679 const struct wined3d_texture_gl
*texture_gl
)
3687 desc
->address_u
= wined3d_texture_gl_address_mode(texture_gl
, sampler_states
[WINED3D_SAMP_ADDRESS_U
]);
3688 desc
->address_v
= wined3d_texture_gl_address_mode(texture_gl
, sampler_states
[WINED3D_SAMP_ADDRESS_V
]);
3689 desc
->address_w
= wined3d_texture_gl_address_mode(texture_gl
, sampler_states
[WINED3D_SAMP_ADDRESS_W
]);
3690 wined3d_color_from_d3dcolor((struct wined3d_color
*)desc
->border_color
,
3691 sampler_states
[WINED3D_SAMP_BORDER_COLOR
]);
3692 if (sampler_states
[WINED3D_SAMP_MAG_FILTER
] > WINED3D_TEXF_ANISOTROPIC
)
3693 FIXME("Unrecognized or unsupported WINED3D_SAMP_MAG_FILTER %#x.\n",
3694 sampler_states
[WINED3D_SAMP_MAG_FILTER
]);
3695 desc
->mag_filter
= min(max(sampler_states
[WINED3D_SAMP_MAG_FILTER
], WINED3D_TEXF_POINT
), WINED3D_TEXF_LINEAR
);
3696 if (sampler_states
[WINED3D_SAMP_MIN_FILTER
] > WINED3D_TEXF_ANISOTROPIC
)
3697 FIXME("Unrecognized or unsupported WINED3D_SAMP_MIN_FILTER %#x.\n",
3698 sampler_states
[WINED3D_SAMP_MIN_FILTER
]);
3699 desc
->min_filter
= min(max(sampler_states
[WINED3D_SAMP_MIN_FILTER
], WINED3D_TEXF_POINT
), WINED3D_TEXF_LINEAR
);
3700 if (sampler_states
[WINED3D_SAMP_MIP_FILTER
] > WINED3D_TEXF_ANISOTROPIC
)
3701 FIXME("Unrecognized or unsupported WINED3D_SAMP_MIP_FILTER %#x.\n",
3702 sampler_states
[WINED3D_SAMP_MIP_FILTER
]);
3703 desc
->mip_filter
= min(max(sampler_states
[WINED3D_SAMP_MIP_FILTER
], WINED3D_TEXF_NONE
), WINED3D_TEXF_LINEAR
);
3704 lod_bias
.d
= sampler_states
[WINED3D_SAMP_MIPMAP_LOD_BIAS
];
3705 desc
->lod_bias
= lod_bias
.f
;
3706 desc
->min_lod
= -1000.0f
;
3707 desc
->max_lod
= 1000.0f
;
3708 desc
->mip_base_level
= sampler_states
[WINED3D_SAMP_MAX_MIP_LEVEL
];
3709 desc
->max_anisotropy
= sampler_states
[WINED3D_SAMP_MAX_ANISOTROPY
];
3710 if ((sampler_states
[WINED3D_SAMP_MAG_FILTER
] != WINED3D_TEXF_ANISOTROPIC
3711 && sampler_states
[WINED3D_SAMP_MIN_FILTER
] != WINED3D_TEXF_ANISOTROPIC
3712 && sampler_states
[WINED3D_SAMP_MIP_FILTER
] != WINED3D_TEXF_ANISOTROPIC
)
3713 || (texture_gl
->t
.flags
& WINED3D_TEXTURE_COND_NP2
))
3714 desc
->max_anisotropy
= 1;
3715 desc
->compare
= texture_gl
->t
.resource
.format_flags
& WINED3DFMT_FLAG_SHADOW
;
3716 desc
->comparison_func
= WINED3D_CMP_LESSEQUAL
;
3717 desc
->srgb_decode
= is_srgb_enabled(sampler_states
);
3719 if (!(texture_gl
->t
.resource
.format_flags
& WINED3DFMT_FLAG_FILTERING
))
3721 desc
->mag_filter
= WINED3D_TEXF_POINT
;
3722 desc
->min_filter
= WINED3D_TEXF_POINT
;
3723 desc
->mip_filter
= WINED3D_TEXF_NONE
;
3726 if (texture_gl
->t
.flags
& WINED3D_TEXTURE_COND_NP2
)
3728 desc
->mip_filter
= WINED3D_TEXF_NONE
;
3729 if (context_gl
->gl_info
->supported
[WINED3D_GL_NORMALIZED_TEXRECT
])
3730 desc
->min_filter
= WINED3D_TEXF_POINT
;
3734 /* Enabling and disabling texture dimensions is done by texture stage state /
3735 * pixel shader setup, this function only has to bind textures and set the per
3736 * texture states. */
3737 static void sampler(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3739 struct wined3d_context_gl
*context_gl
= wined3d_context_gl(context
);
3740 unsigned int sampler_idx
= state_id
- STATE_SAMPLER(0);
3741 unsigned int mapped_stage
= context_gl
->tex_unit_map
[sampler_idx
];
3742 const struct wined3d_gl_info
*gl_info
= context_gl
->gl_info
;
3744 TRACE("Sampler %u.\n", sampler_idx
);
3746 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
)
3748 TRACE("No sampler mapped to stage %u. Returning.\n", sampler_idx
);
3752 if (mapped_stage
>= gl_info
->limits
.graphics_samplers
)
3754 wined3d_context_gl_active_texture(context_gl
, gl_info
, mapped_stage
);
3756 if (state
->textures
[sampler_idx
])
3758 struct wined3d_texture_gl
*texture_gl
= wined3d_texture_gl(state
->textures
[sampler_idx
]);
3759 const DWORD
*sampler_states
= state
->sampler_states
[sampler_idx
];
3760 struct wined3d_device
*device
= context
->device
;
3761 BOOL srgb
= is_srgb_enabled(sampler_states
);
3762 struct wined3d_sampler_desc desc
;
3763 struct wined3d_sampler
*sampler
;
3764 struct wine_rb_entry
*entry
;
3766 wined3d_sampler_desc_from_sampler_states(&desc
, context_gl
, sampler_states
, texture_gl
);
3768 wined3d_texture_gl_bind(texture_gl
, context_gl
, srgb
);
3770 if ((entry
= wine_rb_get(&device
->samplers
, &desc
)))
3772 sampler
= WINE_RB_ENTRY_VALUE(entry
, struct wined3d_sampler
, entry
);
3776 if (FAILED(wined3d_sampler_create(device
, &desc
, NULL
, &wined3d_null_parent_ops
, &sampler
)))
3778 ERR("Failed to create sampler.\n");
3781 if (wine_rb_put(&device
->samplers
, &desc
, &sampler
->entry
) == -1)
3783 ERR("Failed to insert sampler.\n");
3784 wined3d_sampler_decref(sampler
);
3789 wined3d_sampler_gl_bind(wined3d_sampler_gl(sampler
), mapped_stage
, texture_gl
, context_gl
);
3791 /* Trigger shader constant reloading (for NP2 texcoord fixup) */
3792 if (!(texture_gl
->t
.flags
& WINED3D_TEXTURE_POW2_MAT_IDENT
))
3793 context
->constant_update_mask
|= WINED3D_SHADER_CONST_PS_NP2_FIXUP
;
3797 wined3d_context_gl_bind_texture(context_gl
, GL_NONE
, 0);
3798 if (gl_info
->supported
[ARB_SAMPLER_OBJECTS
])
3800 GL_EXTCALL(glBindSampler(mapped_stage
, 0));
3801 checkGLcall("glBindSampler");
3806 void apply_pixelshader(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3812 if (!context
->last_was_pshader
)
3814 /* Former draw without a pixel shader, some samplers may be
3815 * disabled because of WINED3D_TSS_COLOR_OP = WINED3DTOP_DISABLE
3816 * make sure to enable them. */
3817 for (i
= 0; i
< WINED3D_MAX_FRAGMENT_SAMPLERS
; ++i
)
3819 if (!isStateDirty(context
, STATE_SAMPLER(i
)))
3820 sampler(context
, state
, STATE_SAMPLER(i
));
3822 context
->last_was_pshader
= TRUE
;
3826 /* Otherwise all samplers were activated by the code above in
3827 * earlier draws, or by sampler() if a different texture was
3828 * bound. I don't have to do anything. */
3833 /* Disabled the pixel shader - color ops weren't applied while it was
3834 * enabled, so re-apply them. */
3835 for (i
= 0; i
< context
->d3d_info
->limits
.ffp_blend_stages
; ++i
)
3837 if (!isStateDirty(context
, STATE_TEXTURESTAGE(i
, WINED3D_TSS_COLOR_OP
)))
3838 context_apply_state(context
, state
, STATE_TEXTURESTAGE(i
, WINED3D_TSS_COLOR_OP
));
3840 context
->last_was_pshader
= FALSE
;
3843 context
->shader_update_mask
|= 1u << WINED3D_SHADER_TYPE_PIXEL
;
3846 static void state_compute_shader(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3848 context
->shader_update_mask
|= 1u << WINED3D_SHADER_TYPE_COMPUTE
;
3851 static void state_shader(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3853 enum wined3d_shader_type shader_type
= state_id
- STATE_SHADER(0);
3854 context
->shader_update_mask
|= 1u << shader_type
;
3857 static void shader_bumpenv(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3859 context
->constant_update_mask
|= WINED3D_SHADER_CONST_PS_BUMP_ENV
;
3862 static void transform_world(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3864 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
3865 struct wined3d_matrix mat
;
3867 /* This function is called by transform_view below if the view matrix was changed too
3869 * Deliberately no check if the vertex declaration is dirty because the vdecl state
3870 * does not always update the world matrix, only on a switch between transformed
3871 * and untransformed draws. It *may* happen that the world matrix is set 2 times during one
3872 * draw, but that should be rather rare and cheaper in total.
3874 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3875 checkGLcall("glMatrixMode");
3877 get_modelview_matrix(context
, state
, 0, &mat
);
3879 gl_info
->gl_ops
.gl
.p_glLoadMatrixf((GLfloat
*)&mat
);
3880 checkGLcall("glLoadMatrixf");
3883 void clipplane(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3885 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
3886 UINT index
= state_id
- STATE_CLIPPLANE(0);
3889 if (isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_VIEW
)) || index
>= gl_info
->limits
.user_clip_distances
)
3892 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3893 gl_info
->gl_ops
.gl
.p_glPushMatrix();
3895 /* Clip Plane settings are affected by the model view in OpenGL, the View transform in direct3d */
3897 gl_info
->gl_ops
.gl
.p_glLoadMatrixf(&state
->transforms
[WINED3D_TS_VIEW
]._11
);
3899 /* With vertex shaders, clip planes are not transformed in Direct3D,
3900 * while in OpenGL they are still transformed by the model view matrix. */
3901 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
3903 plane
[0] = state
->clip_planes
[index
].x
;
3904 plane
[1] = state
->clip_planes
[index
].y
;
3905 plane
[2] = state
->clip_planes
[index
].z
;
3906 plane
[3] = state
->clip_planes
[index
].w
;
3908 TRACE("Clipplane [%.8e, %.8e, %.8e, %.8e]\n",
3909 plane
[0], plane
[1], plane
[2], plane
[3]);
3910 gl_info
->gl_ops
.gl
.p_glClipPlane(GL_CLIP_PLANE0
+ index
, plane
);
3911 checkGLcall("glClipPlane");
3913 gl_info
->gl_ops
.gl
.p_glPopMatrix();
3916 static void transform_worldex(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3918 unsigned int matrix
= state_id
- STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0));
3920 WARN("Unsupported world matrix %u set.\n", matrix
);
3923 static void state_vertexblend_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3925 enum wined3d_vertex_blend_flags f
= state
->render_states
[WINED3D_RS_VERTEXBLEND
];
3926 static unsigned int once
;
3928 if (f
== WINED3D_VBF_DISABLE
)
3931 if (!once
++) FIXME("Vertex blend flags %#x not supported.\n", f
);
3932 else WARN("Vertex blend flags %#x not supported.\n", f
);
3935 static void transform_view(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3937 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
3938 const struct wined3d_light_info
*light
= NULL
;
3941 /* If we are changing the View matrix, reset the light and clipping planes to the new view
3942 * NOTE: We have to reset the positions even if the light/plane is not currently
3943 * enabled, since the call to enable it will not reset the position.
3944 * NOTE2: Apparently texture transforms do NOT need reapplying
3947 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3948 checkGLcall("glMatrixMode(GL_MODELVIEW)");
3949 gl_info
->gl_ops
.gl
.p_glLoadMatrixf(&state
->transforms
[WINED3D_TS_VIEW
]._11
);
3950 checkGLcall("glLoadMatrixf(...)");
3952 /* Reset lights. TODO: Call light apply func */
3953 for (k
= 0; k
< gl_info
->limits
.lights
; ++k
)
3955 if (!(light
= state
->light_state
.lights
[k
]))
3957 if (light
->OriginalParms
.type
== WINED3D_LIGHT_DIRECTIONAL
)
3958 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ light
->glIndex
, GL_POSITION
, &light
->direction
.x
);
3960 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ light
->glIndex
, GL_POSITION
, &light
->position
.x
);
3961 checkGLcall("glLightfv posn");
3962 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ light
->glIndex
, GL_SPOT_DIRECTION
, &light
->direction
.x
);
3963 checkGLcall("glLightfv dirn");
3966 /* Reset Clipping Planes */
3967 for (k
= 0; k
< gl_info
->limits
.user_clip_distances
; ++k
)
3969 if (!isStateDirty(context
, STATE_CLIPPLANE(k
)))
3970 clipplane(context
, state
, STATE_CLIPPLANE(k
));
3973 if (context
->last_was_rhw
)
3975 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
3976 checkGLcall("glLoadIdentity()");
3977 /* No need to update the world matrix, the identity is fine */
3981 /* Call the world matrix state, this will apply the combined WORLD + VIEW matrix
3982 * No need to do it here if the state is scheduled for update. */
3983 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0))))
3984 transform_world(context
, state
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0)));
3987 static void transform_projection(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3989 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
3990 struct wined3d_matrix projection
;
3992 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_PROJECTION
);
3993 checkGLcall("glMatrixMode(GL_PROJECTION)");
3995 get_projection_matrix(context
, state
, &projection
);
3996 gl_info
->gl_ops
.gl
.p_glLoadMatrixf(&projection
._11
);
3997 checkGLcall("glLoadMatrixf");
4000 static void streamsrc(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4002 wined3d_context_gl_update_stream_sources(wined3d_context_gl(context
), state
);
4005 static void vdecl_miscpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4007 if (isStateDirty(context
, STATE_STREAMSRC
))
4009 wined3d_context_gl_update_stream_sources(wined3d_context_gl(context
), state
);
4012 static void vertexdeclaration(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4014 struct wined3d_context_gl
*context_gl
= wined3d_context_gl(context
);
4015 const struct wined3d_gl_info
*gl_info
= context_gl
->gl_info
;
4016 BOOL useVertexShaderFunction
= use_vs(state
);
4017 BOOL updateFog
= FALSE
;
4019 BOOL wasrhw
= context
->last_was_rhw
;
4022 transformed
= context
->stream_info
.position_transformed
;
4023 if (transformed
!= context
->last_was_rhw
&& !useVertexShaderFunction
)
4026 context
->last_was_rhw
= transformed
;
4028 if (context
->stream_info
.swizzle_map
!= context
->last_swizzle_map
)
4029 context
->shader_update_mask
|= 1u << WINED3D_SHADER_TYPE_VERTEX
;
4031 context
->last_swizzle_map
= context
->stream_info
.swizzle_map
;
4033 /* Don't have to apply the matrices when vertex shaders are used. When
4034 * vshaders are turned off this function will be called again anyway to
4035 * make sure they're properly set. */
4036 if (!useVertexShaderFunction
)
4038 /* TODO: Move this mainly to the viewport state and only apply when
4039 * the vp has changed or transformed / untransformed was switched. */
4040 if (wasrhw
!= context
->last_was_rhw
4041 && !isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
))
4042 && !isStateDirty(context
, STATE_VIEWPORT
))
4043 transform_projection(context
, state
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
));
4044 /* World matrix needs reapplication here only if we're switching between rhw and non-rhw
4047 * If a vertex shader is used, the world matrix changed and then vertex shader unbound
4048 * this check will fail and the matrix not applied again. This is OK because a simple
4049 * world matrix change reapplies the matrix - These checks here are only to satisfy the
4050 * needs of the vertex declaration.
4052 * World and view matrix go into the same gl matrix, so only apply them when neither is
4055 if (transformed
!= wasrhw
&& !isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0)))
4056 && !isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_VIEW
)))
4057 transform_world(context
, state
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0)));
4058 if (!isStateDirty(context
, STATE_RENDER(WINED3D_RS_COLORVERTEX
)))
4059 context_apply_state(context
, state
, STATE_RENDER(WINED3D_RS_COLORVERTEX
));
4060 if (!isStateDirty(context
, STATE_RENDER(WINED3D_RS_LIGHTING
)))
4061 state_lighting(context
, state
, STATE_RENDER(WINED3D_RS_LIGHTING
));
4063 if (context
->last_was_vshader
)
4067 if (!context
->d3d_info
->vs_clipping
4068 && !isStateDirty(context
, STATE_RENDER(WINED3D_RS_CLIPPLANEENABLE
)))
4070 state_clipping(context
, state
, STATE_RENDER(WINED3D_RS_CLIPPLANEENABLE
));
4073 for (i
= 0; i
< gl_info
->limits
.user_clip_distances
; ++i
)
4075 clipplane(context
, state
, STATE_CLIPPLANE(i
));
4078 if (!isStateDirty(context
, STATE_RENDER(WINED3D_RS_NORMALIZENORMALS
)))
4079 state_normalize(context
, state
, STATE_RENDER(WINED3D_RS_NORMALIZENORMALS
));
4083 if (!context
->last_was_vshader
)
4085 static BOOL warned
= FALSE
;
4086 if (!context
->d3d_info
->vs_clipping
)
4088 /* Disable all clip planes to get defined results on all drivers. See comment in the
4089 * state_clipping state handler
4091 wined3d_context_gl_enable_clip_distances(context_gl
, 0);
4093 if (!warned
&& state
->render_states
[WINED3D_RS_CLIPPLANEENABLE
])
4095 FIXME("Clipping not supported with vertex shaders.\n");
4101 /* Apply the transform matrices when switching from rhw
4102 * drawing to vertex shaders. Vertex shaders themselves do
4103 * not need it, but the matrices are not reapplied
4104 * automatically when switching back from vertex shaders to
4105 * fixed function processing. So make sure we leave the fixed
4106 * function vertex processing states back in a sane state
4107 * before switching to shaders. */
4108 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
)))
4109 transform_projection(context
, state
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
));
4110 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0))))
4111 transform_world(context
, state
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0)));
4115 /* Vertex shader clipping ignores the view matrix. Update all clipplanes
4116 * (Note: ARB shaders can read the clip planes for clipping emulation even if
4117 * device->vs_clipping is false.
4119 for (i
= 0; i
< gl_info
->limits
.user_clip_distances
; ++i
)
4121 clipplane(context
, state
, STATE_CLIPPLANE(i
));
4126 context
->last_was_vshader
= useVertexShaderFunction
;
4127 context
->shader_update_mask
|= 1u << WINED3D_SHADER_TYPE_VERTEX
;
4130 context_apply_state(context
, state
, STATE_RENDER(WINED3D_RS_FOGVERTEXMODE
));
4132 if (!useVertexShaderFunction
)
4136 for (i
= 0; i
< WINED3D_MAX_TEXTURES
; ++i
)
4138 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_TEXTURE0
+ i
)))
4139 transform_texture(context
, state
, STATE_TEXTURESTAGE(i
, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
));
4142 if (use_ps(state
) && state
->shader
[WINED3D_SHADER_TYPE_PIXEL
]->reg_maps
.shader_version
.major
== 1
4143 && state
->shader
[WINED3D_SHADER_TYPE_PIXEL
]->reg_maps
.shader_version
.minor
<= 3)
4144 context
->shader_update_mask
|= 1u << WINED3D_SHADER_TYPE_PIXEL
;
4148 static void get_viewports(struct wined3d_context
*context
, const struct wined3d_state
*state
,
4149 unsigned int viewport_count
, struct wined3d_viewport
*viewports
)
4151 const struct wined3d_rendertarget_view
*depth_stencil
= state
->fb
.depth_stencil
;
4152 const struct wined3d_rendertarget_view
*target
= state
->fb
.render_targets
[0];
4153 unsigned int width
, height
, i
;
4155 for (i
= 0; i
< viewport_count
; ++i
)
4156 viewports
[i
] = state
->viewports
[i
];
4158 /* Note: GL uses a lower left origin while DirectX uses upper left. This
4159 * is reversed when using offscreen rendering. */
4160 if (context
->render_offscreen
)
4165 wined3d_rendertarget_view_get_drawable_size(target
, context
, &width
, &height
);
4167 else if (depth_stencil
)
4169 height
= depth_stencil
->height
;
4173 FIXME("Could not get the height of render targets.\n");
4177 for (i
= 0; i
< viewport_count
; ++i
)
4178 viewports
[i
].y
= height
- (viewports
[i
].y
+ viewports
[i
].height
);
4181 static void viewport_miscpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4183 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
4184 struct wined3d_viewport vp
[WINED3D_MAX_VIEWPORTS
];
4187 if (gl_info
->supported
[ARB_VIEWPORT_ARRAY
])
4189 GLdouble depth_ranges
[2 * WINED3D_MAX_VIEWPORTS
];
4190 GLfloat viewports
[4 * WINED3D_MAX_VIEWPORTS
];
4192 unsigned int i
, reset_count
= 0;
4194 get_viewports(context
, state
, state
->viewport_count
, vp
);
4195 for (i
= 0; i
< state
->viewport_count
; ++i
)
4197 wined3d_viewport_get_z_range(&vp
[i
], &min_z
, &max_z
);
4198 depth_ranges
[i
* 2] = min_z
;
4199 depth_ranges
[i
* 2 + 1] = max_z
;
4201 viewports
[i
* 4] = vp
[i
].x
;
4202 viewports
[i
* 4 + 1] = vp
[i
].y
;
4203 viewports
[i
* 4 + 2] = vp
[i
].width
;
4204 viewports
[i
* 4 + 3] = vp
[i
].height
;
4207 if (context
->viewport_count
> state
->viewport_count
)
4208 reset_count
= context
->viewport_count
- state
->viewport_count
;
4212 memset(&depth_ranges
[state
->viewport_count
* 2], 0, reset_count
* 2 * sizeof(*depth_ranges
));
4213 memset(&viewports
[state
->viewport_count
* 4], 0, reset_count
* 4 * sizeof(*viewports
));
4216 GL_EXTCALL(glDepthRangeArrayv(0, state
->viewport_count
+ reset_count
, depth_ranges
));
4217 GL_EXTCALL(glViewportArrayv(0, state
->viewport_count
+ reset_count
, viewports
));
4218 context
->viewport_count
= state
->viewport_count
;
4222 get_viewports(context
, state
, 1, vp
);
4223 wined3d_viewport_get_z_range(&vp
[0], &min_z
, &max_z
);
4224 gl_info
->gl_ops
.gl
.p_glDepthRange(min_z
, max_z
);
4225 gl_info
->gl_ops
.gl
.p_glViewport(vp
[0].x
, vp
[0].y
, vp
[0].width
, vp
[0].height
);
4227 checkGLcall("setting clip space and viewport");
4230 static void viewport_miscpart_cc(struct wined3d_context
*context
,
4231 const struct wined3d_state
*state
, DWORD state_id
)
4233 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
4234 /* See get_projection_matrix() in utils.c for a discussion about those values. */
4235 float pixel_center_offset
= context
->d3d_info
->wined3d_creation_flags
4236 & WINED3D_PIXEL_CENTER_INTEGER
? 63.0f
/ 128.0f
: -1.0f
/ 128.0f
;
4237 struct wined3d_viewport vp
[WINED3D_MAX_VIEWPORTS
];
4238 GLdouble depth_ranges
[2 * WINED3D_MAX_VIEWPORTS
];
4239 GLfloat viewports
[4 * WINED3D_MAX_VIEWPORTS
];
4240 unsigned int i
, reset_count
= 0;
4243 get_viewports(context
, state
, state
->viewport_count
, vp
);
4245 GL_EXTCALL(glClipControl(context
->render_offscreen
? GL_UPPER_LEFT
: GL_LOWER_LEFT
, GL_ZERO_TO_ONE
));
4247 for (i
= 0; i
< state
->viewport_count
; ++i
)
4249 wined3d_viewport_get_z_range(&vp
[i
], &min_z
, &max_z
);
4250 depth_ranges
[i
* 2] = min_z
;
4251 depth_ranges
[i
* 2 + 1] = max_z
;
4253 viewports
[i
* 4] = vp
[i
].x
+ pixel_center_offset
;
4254 viewports
[i
* 4 + 1] = vp
[i
].y
+ pixel_center_offset
;
4255 viewports
[i
* 4 + 2] = vp
[i
].width
;
4256 viewports
[i
* 4 + 3] = vp
[i
].height
;
4259 if (context
->viewport_count
> state
->viewport_count
)
4260 reset_count
= context
->viewport_count
- state
->viewport_count
;
4264 memset(&depth_ranges
[state
->viewport_count
* 2], 0, reset_count
* 2 * sizeof(*depth_ranges
));
4265 memset(&viewports
[state
->viewport_count
* 4], 0, reset_count
* 4 * sizeof(*viewports
));
4268 GL_EXTCALL(glDepthRangeArrayv(0, state
->viewport_count
+ reset_count
, depth_ranges
));
4269 GL_EXTCALL(glViewportArrayv(0, state
->viewport_count
+ reset_count
, viewports
));
4270 context
->viewport_count
= state
->viewport_count
;
4272 checkGLcall("setting clip space and viewport");
4275 static void viewport_vertexpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4277 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
)))
4278 transform_projection(context
, state
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
));
4279 if (!isStateDirty(context
, STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
))
4280 && state
->render_states
[WINED3D_RS_POINTSCALEENABLE
])
4281 state_pscale(context
, state
, STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
));
4282 /* Update the position fixup. */
4283 context
->constant_update_mask
|= WINED3D_SHADER_CONST_POS_FIXUP
;
4286 static void light(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4288 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
4289 UINT Index
= state_id
- STATE_ACTIVELIGHT(0);
4290 const struct wined3d_light_info
*lightInfo
= state
->light_state
.lights
[Index
];
4294 gl_info
->gl_ops
.gl
.p_glDisable(GL_LIGHT0
+ Index
);
4295 checkGLcall("glDisable(GL_LIGHT0 + Index)");
4301 /* Light settings are affected by the model view in OpenGL, the View transform in direct3d*/
4302 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
4303 gl_info
->gl_ops
.gl
.p_glPushMatrix();
4304 gl_info
->gl_ops
.gl
.p_glLoadMatrixf(&state
->transforms
[WINED3D_TS_VIEW
]._11
);
4306 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_DIFFUSE
, &lightInfo
->OriginalParms
.diffuse
.r
);
4307 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_SPECULAR
, &lightInfo
->OriginalParms
.specular
.r
);
4308 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_AMBIENT
, &lightInfo
->OriginalParms
.ambient
.r
);
4309 checkGLcall("glLightfv");
4311 if ((lightInfo
->OriginalParms
.range
* lightInfo
->OriginalParms
.range
) >= FLT_MIN
)
4312 quad_att
= 1.4f
/ (lightInfo
->OriginalParms
.range
* lightInfo
->OriginalParms
.range
);
4314 quad_att
= 0.0f
; /* 0 or MAX? (0 seems to be ok) */
4316 /* Do not assign attenuation values for lights that do not use them. D3D apps are free to pass any junk,
4317 * but gl drivers use them and may crash due to bad Attenuation values. Need for Speed most wanted sets
4318 * Attenuation0 to NaN and crashes in the gl lib
4321 switch (lightInfo
->OriginalParms
.type
)
4323 case WINED3D_LIGHT_POINT
:
4325 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->position
.x
);
4326 checkGLcall("glLightfv");
4327 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
4328 checkGLcall("glLightf");
4329 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_CONSTANT_ATTENUATION
,
4330 lightInfo
->OriginalParms
.attenuation0
);
4331 checkGLcall("glLightf");
4332 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_LINEAR_ATTENUATION
,
4333 lightInfo
->OriginalParms
.attenuation1
);
4334 checkGLcall("glLightf");
4335 if (quad_att
< lightInfo
->OriginalParms
.attenuation2
)
4336 quad_att
= lightInfo
->OriginalParms
.attenuation2
;
4337 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_QUADRATIC_ATTENUATION
, quad_att
);
4338 checkGLcall("glLightf");
4342 case WINED3D_LIGHT_SPOT
:
4344 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->position
.x
);
4345 checkGLcall("glLightfv");
4347 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_SPOT_DIRECTION
, &lightInfo
->direction
.x
);
4348 checkGLcall("glLightfv");
4349 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_SPOT_EXPONENT
, lightInfo
->exponent
);
4350 checkGLcall("glLightf");
4351 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
4352 checkGLcall("glLightf");
4353 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_CONSTANT_ATTENUATION
,
4354 lightInfo
->OriginalParms
.attenuation0
);
4355 checkGLcall("glLightf");
4356 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_LINEAR_ATTENUATION
,
4357 lightInfo
->OriginalParms
.attenuation1
);
4358 checkGLcall("glLightf");
4359 if (quad_att
< lightInfo
->OriginalParms
.attenuation2
)
4360 quad_att
= lightInfo
->OriginalParms
.attenuation2
;
4361 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_QUADRATIC_ATTENUATION
, quad_att
);
4362 checkGLcall("glLightf");
4366 case WINED3D_LIGHT_DIRECTIONAL
:
4368 /* Note GL uses w position of 0 for direction! */
4369 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->direction
.x
);
4370 checkGLcall("glLightfv");
4371 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
4372 checkGLcall("glLightf");
4373 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_SPOT_EXPONENT
, 0.0f
);
4374 checkGLcall("glLightf");
4378 FIXME("Unrecognized light type %#x.\n", lightInfo
->OriginalParms
.type
);
4381 /* Restore the modelview matrix */
4382 gl_info
->gl_ops
.gl
.p_glPopMatrix();
4384 gl_info
->gl_ops
.gl
.p_glEnable(GL_LIGHT0
+ Index
);
4385 checkGLcall("glEnable(GL_LIGHT0 + Index)");
4389 static void scissorrect(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4391 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
4392 unsigned int height
= 0;
4395 /* Warning: glScissor uses window coordinates, not viewport coordinates,
4396 * so our viewport correction does not apply. Warning2: Even in windowed
4397 * mode the coords are relative to the window, not the screen. */
4399 if (!context
->render_offscreen
)
4401 const struct wined3d_rendertarget_view
*target
= state
->fb
.render_targets
[0];
4404 wined3d_rendertarget_view_get_drawable_size(target
, context
, &width
, &height
);
4407 if (gl_info
->supported
[ARB_VIEWPORT_ARRAY
])
4409 GLint sr
[4 * WINED3D_MAX_VIEWPORTS
];
4410 unsigned int i
, reset_count
= 0;
4412 for (i
= 0; i
< state
->scissor_rect_count
; ++i
)
4414 r
= &state
->scissor_rects
[i
];
4416 sr
[i
* 4] = r
->left
;
4417 sr
[i
* 4 + 1] = height
? height
- r
->top
: r
->top
;
4418 sr
[i
* 4 + 2] = r
->right
- r
->left
;
4419 sr
[i
* 4 + 3] = r
->bottom
- r
->top
;
4422 if (context
->scissor_rect_count
> state
->scissor_rect_count
)
4423 reset_count
= context
->scissor_rect_count
- state
->scissor_rect_count
;
4426 memset(&sr
[state
->scissor_rect_count
* 4], 0, reset_count
* 4 * sizeof(GLint
));
4428 GL_EXTCALL(glScissorArrayv(0, state
->scissor_rect_count
+ reset_count
, sr
));
4429 checkGLcall("glScissorArrayv");
4430 context
->scissor_rect_count
= state
->scissor_rect_count
;
4434 r
= &state
->scissor_rects
[0];
4435 gl_info
->gl_ops
.gl
.p_glScissor(r
->left
, height
? height
- r
->top
: r
->top
,
4436 r
->right
- r
->left
, r
->bottom
- r
->top
);
4437 checkGLcall("glScissor");
4441 static void indexbuffer(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4443 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
4444 const struct wined3d_stream_info
*stream_info
= &context
->stream_info
;
4445 struct wined3d_buffer_gl
*buffer_gl
;
4447 if (!state
->index_buffer
|| !stream_info
->all_vbo
)
4449 GL_EXTCALL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER
, 0));
4453 buffer_gl
= wined3d_buffer_gl(state
->index_buffer
);
4454 GL_EXTCALL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER
, buffer_gl
->bo
.id
));
4455 buffer_gl
->bo_user
.valid
= true;
4458 static void depth_clip(const struct wined3d_rasterizer_state
*r
, const struct wined3d_gl_info
*gl_info
)
4460 if (!gl_info
->supported
[ARB_DEPTH_CLAMP
])
4462 if (r
&& !r
->desc
.depth_clip
)
4463 FIXME("Depth clamp not supported by this GL implementation.\n");
4467 if (r
&& !r
->desc
.depth_clip
)
4468 gl_info
->gl_ops
.gl
.p_glEnable(GL_DEPTH_CLAMP
);
4470 gl_info
->gl_ops
.gl
.p_glDisable(GL_DEPTH_CLAMP
);
4471 checkGLcall("depth clip");
4474 static void rasterizer(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4476 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
4477 const struct wined3d_rasterizer_state
*r
= state
->rasterizer_state
;
4480 mode
= r
&& r
->desc
.front_ccw
? GL_CCW
: GL_CW
;
4481 if (context
->render_offscreen
)
4482 mode
= (mode
== GL_CW
) ? GL_CCW
: GL_CW
;
4484 gl_info
->gl_ops
.gl
.p_glFrontFace(mode
);
4485 checkGLcall("glFrontFace");
4486 depthbias(context
, state
);
4487 fillmode(r
, gl_info
);
4488 cullmode(r
, gl_info
);
4489 depth_clip(r
, gl_info
);
4490 scissor(r
, gl_info
);
4491 line_antialias(r
, gl_info
);
4494 static void rasterizer_cc(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4496 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
4497 const struct wined3d_rasterizer_state
*r
= state
->rasterizer_state
;
4500 mode
= r
&& r
->desc
.front_ccw
? GL_CCW
: GL_CW
;
4502 gl_info
->gl_ops
.gl
.p_glFrontFace(mode
);
4503 checkGLcall("glFrontFace");
4504 depthbias(context
, state
);
4505 fillmode(r
, gl_info
);
4506 cullmode(r
, gl_info
);
4507 depth_clip(r
, gl_info
);
4508 scissor(r
, gl_info
);
4509 line_antialias(r
, gl_info
);
4512 static void psorigin_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4518 WARN("Point sprite coordinate origin switching not supported.\n");
4523 static void psorigin(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4525 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
4526 GLint origin
= context
->render_offscreen
? GL_LOWER_LEFT
: GL_UPPER_LEFT
;
4528 GL_EXTCALL(glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN
, origin
));
4529 checkGLcall("glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, ...)");
4532 void state_srgbwrite(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4534 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
4536 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
4538 if (needs_srgb_write(context
->d3d_info
, state
, &state
->fb
))
4539 gl_info
->gl_ops
.gl
.p_glEnable(GL_FRAMEBUFFER_SRGB
);
4541 gl_info
->gl_ops
.gl
.p_glDisable(GL_FRAMEBUFFER_SRGB
);
4544 static void state_cb(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4546 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
4547 enum wined3d_shader_type shader_type
;
4548 struct wined3d_buffer_gl
*buffer_gl
;
4549 unsigned int i
, base
, count
;
4551 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
4553 if (STATE_IS_GRAPHICS_CONSTANT_BUFFER(state_id
))
4554 shader_type
= state_id
- STATE_GRAPHICS_CONSTANT_BUFFER(0);
4556 shader_type
= WINED3D_SHADER_TYPE_COMPUTE
;
4558 wined3d_gl_limits_get_uniform_block_range(&gl_info
->limits
, shader_type
, &base
, &count
);
4559 for (i
= 0; i
< count
; ++i
)
4561 if (!state
->cb
[shader_type
][i
])
4563 GL_EXTCALL(glBindBufferBase(GL_UNIFORM_BUFFER
, base
+ i
, 0));
4567 buffer_gl
= wined3d_buffer_gl(state
->cb
[shader_type
][i
]);
4568 GL_EXTCALL(glBindBufferBase(GL_UNIFORM_BUFFER
, base
+ i
, buffer_gl
->bo
.id
));
4569 buffer_gl
->bo_user
.valid
= true;
4571 checkGLcall("bind constant buffers");
4574 static void state_cb_warn(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4576 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
4578 WARN("Constant buffers (%s) no supported.\n", debug_d3dstate(state_id
));
4581 static void state_shader_resource_binding(struct wined3d_context
*context
,
4582 const struct wined3d_state
*state
, DWORD state_id
)
4584 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
4586 context
->update_shader_resource_bindings
= 1;
4589 static void state_cs_resource_binding(struct wined3d_context
*context
,
4590 const struct wined3d_state
*state
, DWORD state_id
)
4592 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
4593 context
->update_compute_shader_resource_bindings
= 1;
4596 static void state_uav_binding(struct wined3d_context
*context
,
4597 const struct wined3d_state
*state
, DWORD state_id
)
4599 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
4600 context
->update_unordered_access_view_bindings
= 1;
4603 static void state_cs_uav_binding(struct wined3d_context
*context
,
4604 const struct wined3d_state
*state
, DWORD state_id
)
4606 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
4607 context
->update_compute_unordered_access_view_bindings
= 1;
4610 static void state_uav_warn(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4612 WARN("ARB_image_load_store is not supported by OpenGL implementation.\n");
4615 static void state_so(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4617 struct wined3d_context_gl
*context_gl
= wined3d_context_gl(context
);
4618 const struct wined3d_gl_info
*gl_info
= context_gl
->gl_info
;
4619 struct wined3d_buffer_gl
*buffer_gl
;
4620 unsigned int offset
, size
, i
;
4622 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
4624 wined3d_context_gl_end_transform_feedback(context_gl
);
4626 for (i
= 0; i
< ARRAY_SIZE(state
->stream_output
); ++i
)
4628 if (!state
->stream_output
[i
].buffer
)
4630 GL_EXTCALL(glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER
, i
, 0));
4634 buffer_gl
= wined3d_buffer_gl(state
->stream_output
[i
].buffer
);
4635 offset
= state
->stream_output
[i
].offset
;
4638 FIXME("Appending to stream output buffers not implemented.\n");
4641 size
= buffer_gl
->b
.resource
.size
- offset
;
4642 GL_EXTCALL(glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER
, i
, buffer_gl
->bo
.id
, offset
, size
));
4643 buffer_gl
->bo_user
.valid
= true;
4645 checkGLcall("bind transform feedback buffers");
4648 static void state_so_warn(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4650 WARN("Transform feedback not supported.\n");
4653 const struct wined3d_state_entry_template misc_state_template_gl
[] =
4655 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX
), state_cb
, }, ARB_UNIFORM_BUFFER_OBJECT
},
4656 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX
), state_cb_warn
, }, WINED3D_GL_EXT_NONE
},
4657 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_HULL
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_HULL
), state_cb
, }, ARB_UNIFORM_BUFFER_OBJECT
},
4658 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_HULL
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_HULL
), state_cb_warn
, }, WINED3D_GL_EXT_NONE
},
4659 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_DOMAIN
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_DOMAIN
), state_cb
, }, ARB_UNIFORM_BUFFER_OBJECT
},
4660 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_DOMAIN
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_DOMAIN
), state_cb_warn
, }, WINED3D_GL_EXT_NONE
},
4661 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY
),{ STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY
),state_cb
, }, ARB_UNIFORM_BUFFER_OBJECT
},
4662 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY
),{ STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY
),state_cb_warn
, }, WINED3D_GL_EXT_NONE
},
4663 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL
), state_cb
, }, ARB_UNIFORM_BUFFER_OBJECT
},
4664 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL
), state_cb_warn
, }, WINED3D_GL_EXT_NONE
},
4665 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_COMPUTE
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_COMPUTE
), state_cb
, }, ARB_UNIFORM_BUFFER_OBJECT
},
4666 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_COMPUTE
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_COMPUTE
), state_cb_warn
, }, WINED3D_GL_EXT_NONE
},
4667 { STATE_GRAPHICS_SHADER_RESOURCE_BINDING
, { STATE_GRAPHICS_SHADER_RESOURCE_BINDING
, state_shader_resource_binding
}, WINED3D_GL_EXT_NONE
},
4668 { STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING
, { STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING
, state_uav_binding
}, ARB_SHADER_IMAGE_LOAD_STORE
},
4669 { STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING
, { STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING
, state_uav_warn
}, WINED3D_GL_EXT_NONE
},
4670 { STATE_COMPUTE_SHADER_RESOURCE_BINDING
, { STATE_COMPUTE_SHADER_RESOURCE_BINDING
, state_cs_resource_binding
}, WINED3D_GL_EXT_NONE
},
4671 { STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING
, { STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING
, state_cs_uav_binding
}, ARB_SHADER_IMAGE_LOAD_STORE
},
4672 { STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING
, { STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING
, state_uav_warn
}, WINED3D_GL_EXT_NONE
},
4673 { STATE_STREAM_OUTPUT
, { STATE_STREAM_OUTPUT
, state_so
, }, WINED3D_GL_VERSION_3_2
},
4674 { STATE_STREAM_OUTPUT
, { STATE_STREAM_OUTPUT
, state_so_warn
, }, WINED3D_GL_EXT_NONE
},
4675 { STATE_BLEND
, { STATE_BLEND
, blend_dbb
}, ARB_DRAW_BUFFERS_BLEND
},
4676 { STATE_BLEND
, { STATE_BLEND
, blend_db2
}, EXT_DRAW_BUFFERS2
},
4677 { STATE_BLEND
, { STATE_BLEND
, blend
}, WINED3D_GL_EXT_NONE
},
4678 { STATE_BLEND_FACTOR
, { STATE_BLEND_FACTOR
, state_blend_factor
}, EXT_BLEND_COLOR
},
4679 { STATE_BLEND_FACTOR
, { STATE_BLEND_FACTOR
, state_blend_factor_w
}, WINED3D_GL_EXT_NONE
},
4680 { STATE_SAMPLE_MASK
, { STATE_SAMPLE_MASK
, state_sample_mask
}, ARB_TEXTURE_MULTISAMPLE
},
4681 { STATE_SAMPLE_MASK
, { STATE_SAMPLE_MASK
, state_sample_mask_w
}, WINED3D_GL_EXT_NONE
},
4682 { STATE_DEPTH_STENCIL
, { STATE_DEPTH_STENCIL
, depth_stencil_2s
}, EXT_STENCIL_TWO_SIDE
},
4683 { STATE_DEPTH_STENCIL
, { STATE_DEPTH_STENCIL
, depth_stencil
}, WINED3D_GL_EXT_NONE
},
4684 { STATE_STENCIL_REF
, { STATE_DEPTH_STENCIL
, NULL
}, WINED3D_GL_EXT_NONE
},
4685 { STATE_STREAMSRC
, { STATE_STREAMSRC
, streamsrc
}, WINED3D_GL_EXT_NONE
},
4686 { STATE_VDECL
, { STATE_VDECL
, vdecl_miscpart
}, WINED3D_GL_EXT_NONE
},
4687 { STATE_RASTERIZER
, { STATE_RASTERIZER
, rasterizer_cc
}, ARB_CLIP_CONTROL
},
4688 { STATE_RASTERIZER
, { STATE_RASTERIZER
, rasterizer
}, WINED3D_GL_EXT_NONE
},
4689 { STATE_SCISSORRECT
, { STATE_SCISSORRECT
, scissorrect
}, WINED3D_GL_EXT_NONE
},
4690 { STATE_POINTSPRITECOORDORIGIN
, { STATE_POINTSPRITECOORDORIGIN
, state_nop
}, ARB_CLIP_CONTROL
},
4691 { STATE_POINTSPRITECOORDORIGIN
, { STATE_POINTSPRITECOORDORIGIN
, psorigin
}, WINED3D_GL_VERSION_2_0
},
4692 { STATE_POINTSPRITECOORDORIGIN
, { STATE_POINTSPRITECOORDORIGIN
, psorigin_w
}, WINED3D_GL_EXT_NONE
},
4694 /* TODO: Move shader constant loading to vertex and fragment pipeline respectively, as soon as the pshader and
4695 * vshader loadings are untied from each other
4697 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4698 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4699 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4700 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4701 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4702 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4703 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4704 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4705 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4706 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4707 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4708 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4709 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4710 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4711 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4712 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4713 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4714 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4715 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4716 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4717 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4718 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4719 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4720 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4721 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4722 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4723 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4724 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4725 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4726 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4727 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4728 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4729 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4730 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4731 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4732 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4733 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4734 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4735 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4736 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4737 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4738 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4739 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4740 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4741 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4742 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4743 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4744 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4746 { STATE_VIEWPORT
, { STATE_VIEWPORT
, viewport_miscpart_cc
}, ARB_CLIP_CONTROL
},
4747 { STATE_VIEWPORT
, { STATE_VIEWPORT
, viewport_miscpart
}, WINED3D_GL_EXT_NONE
},
4748 { STATE_INDEXBUFFER
, { STATE_INDEXBUFFER
, indexbuffer
}, ARB_VERTEX_BUFFER_OBJECT
},
4749 { STATE_INDEXBUFFER
, { STATE_INDEXBUFFER
, state_nop
}, WINED3D_GL_EXT_NONE
},
4750 { STATE_RENDER(WINED3D_RS_ANTIALIAS
), { STATE_RENDER(WINED3D_RS_ANTIALIAS
), state_antialias
}, WINED3D_GL_EXT_NONE
},
4751 { STATE_RENDER(WINED3D_RS_TEXTUREPERSPECTIVE
), { STATE_RENDER(WINED3D_RS_TEXTUREPERSPECTIVE
), state_nop
}, WINED3D_GL_EXT_NONE
},
4752 { STATE_RENDER(WINED3D_RS_WRAPU
), { STATE_RENDER(WINED3D_RS_WRAPU
), state_wrapu
}, WINED3D_GL_EXT_NONE
},
4753 { STATE_RENDER(WINED3D_RS_WRAPV
), { STATE_RENDER(WINED3D_RS_WRAPV
), state_wrapv
}, WINED3D_GL_EXT_NONE
},
4754 { STATE_RENDER(WINED3D_RS_LINEPATTERN
), { STATE_RENDER(WINED3D_RS_LINEPATTERN
), state_linepattern
}, WINED3D_GL_LEGACY_CONTEXT
},
4755 { STATE_RENDER(WINED3D_RS_LINEPATTERN
), { STATE_RENDER(WINED3D_RS_LINEPATTERN
), state_linepattern_w
}, WINED3D_GL_EXT_NONE
},
4756 { STATE_RENDER(WINED3D_RS_MONOENABLE
), { STATE_RENDER(WINED3D_RS_MONOENABLE
), state_monoenable
}, WINED3D_GL_EXT_NONE
},
4757 { STATE_RENDER(WINED3D_RS_ROP2
), { STATE_RENDER(WINED3D_RS_ROP2
), state_rop2
}, WINED3D_GL_EXT_NONE
},
4758 { STATE_RENDER(WINED3D_RS_PLANEMASK
), { STATE_RENDER(WINED3D_RS_PLANEMASK
), state_planemask
}, WINED3D_GL_EXT_NONE
},
4759 { STATE_RENDER(WINED3D_RS_LASTPIXEL
), { STATE_RENDER(WINED3D_RS_LASTPIXEL
), state_lastpixel
}, WINED3D_GL_EXT_NONE
},
4760 { STATE_RENDER(WINED3D_RS_DITHERENABLE
), { STATE_RENDER(WINED3D_RS_DITHERENABLE
), state_ditherenable
}, WINED3D_GL_EXT_NONE
},
4761 { STATE_RENDER(WINED3D_RS_SUBPIXEL
), { STATE_RENDER(WINED3D_RS_SUBPIXEL
), state_subpixel
}, WINED3D_GL_EXT_NONE
},
4762 { STATE_RENDER(WINED3D_RS_SUBPIXELX
), { STATE_RENDER(WINED3D_RS_SUBPIXELX
), state_subpixelx
}, WINED3D_GL_EXT_NONE
},
4763 { STATE_RENDER(WINED3D_RS_STIPPLEDALPHA
), { STATE_RENDER(WINED3D_RS_STIPPLEDALPHA
), state_stippledalpha
}, WINED3D_GL_EXT_NONE
},
4764 { STATE_RENDER(WINED3D_RS_STIPPLEENABLE
), { STATE_RENDER(WINED3D_RS_STIPPLEENABLE
), state_stippleenable
}, WINED3D_GL_EXT_NONE
},
4765 { STATE_RENDER(WINED3D_RS_MIPMAPLODBIAS
), { STATE_RENDER(WINED3D_RS_MIPMAPLODBIAS
), state_mipmaplodbias
}, WINED3D_GL_EXT_NONE
},
4766 { STATE_RENDER(WINED3D_RS_ANISOTROPY
), { STATE_RENDER(WINED3D_RS_ANISOTROPY
), state_anisotropy
}, WINED3D_GL_EXT_NONE
},
4767 { STATE_RENDER(WINED3D_RS_FLUSHBATCH
), { STATE_RENDER(WINED3D_RS_FLUSHBATCH
), state_flushbatch
}, WINED3D_GL_EXT_NONE
},
4768 { STATE_RENDER(WINED3D_RS_TRANSLUCENTSORTINDEPENDENT
),{ STATE_RENDER(WINED3D_RS_TRANSLUCENTSORTINDEPENDENT
),state_translucentsi
}, WINED3D_GL_EXT_NONE
},
4769 { STATE_RENDER(WINED3D_RS_WRAP0
), { STATE_RENDER(WINED3D_RS_WRAP0
), state_wrap
}, WINED3D_GL_EXT_NONE
},
4770 { STATE_RENDER(WINED3D_RS_WRAP1
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
4771 { STATE_RENDER(WINED3D_RS_WRAP2
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
4772 { STATE_RENDER(WINED3D_RS_WRAP3
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
4773 { STATE_RENDER(WINED3D_RS_WRAP4
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
4774 { STATE_RENDER(WINED3D_RS_WRAP5
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
4775 { STATE_RENDER(WINED3D_RS_WRAP6
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
4776 { STATE_RENDER(WINED3D_RS_WRAP7
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
4777 { STATE_RENDER(WINED3D_RS_WRAP8
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
4778 { STATE_RENDER(WINED3D_RS_WRAP9
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
4779 { STATE_RENDER(WINED3D_RS_WRAP10
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
4780 { STATE_RENDER(WINED3D_RS_WRAP11
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
4781 { STATE_RENDER(WINED3D_RS_WRAP12
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
4782 { STATE_RENDER(WINED3D_RS_WRAP13
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
4783 { STATE_RENDER(WINED3D_RS_WRAP14
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
4784 { STATE_RENDER(WINED3D_RS_WRAP15
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
4785 { STATE_RENDER(WINED3D_RS_EXTENTS
), { STATE_RENDER(WINED3D_RS_EXTENTS
), state_extents
}, WINED3D_GL_EXT_NONE
},
4786 { STATE_RENDER(WINED3D_RS_COLORKEYBLENDENABLE
), { STATE_RENDER(WINED3D_RS_COLORKEYBLENDENABLE
), state_ckeyblend
}, WINED3D_GL_EXT_NONE
},
4787 { STATE_RENDER(WINED3D_RS_SOFTWAREVERTEXPROCESSING
), { STATE_RENDER(WINED3D_RS_SOFTWAREVERTEXPROCESSING
), state_swvp
}, WINED3D_GL_EXT_NONE
},
4788 { STATE_RENDER(WINED3D_RS_PATCHEDGESTYLE
), { STATE_RENDER(WINED3D_RS_PATCHEDGESTYLE
), state_patchedgestyle
}, WINED3D_GL_EXT_NONE
},
4789 { STATE_RENDER(WINED3D_RS_PATCHSEGMENTS
), { STATE_RENDER(WINED3D_RS_PATCHSEGMENTS
), state_patchsegments
}, WINED3D_GL_EXT_NONE
},
4790 { STATE_RENDER(WINED3D_RS_POSITIONDEGREE
), { STATE_RENDER(WINED3D_RS_POSITIONDEGREE
), state_positiondegree
}, WINED3D_GL_EXT_NONE
},
4791 { STATE_RENDER(WINED3D_RS_NORMALDEGREE
), { STATE_RENDER(WINED3D_RS_NORMALDEGREE
), state_normaldegree
}, WINED3D_GL_EXT_NONE
},
4792 { STATE_RENDER(WINED3D_RS_MINTESSELLATIONLEVEL
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
4793 { STATE_RENDER(WINED3D_RS_MAXTESSELLATIONLEVEL
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
4794 { STATE_RENDER(WINED3D_RS_ADAPTIVETESS_X
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
4795 { STATE_RENDER(WINED3D_RS_ADAPTIVETESS_Y
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
4796 { STATE_RENDER(WINED3D_RS_ADAPTIVETESS_Z
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
4797 { STATE_RENDER(WINED3D_RS_ADAPTIVETESS_W
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
4798 { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),{ STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),state_nvdb
}, EXT_DEPTH_BOUNDS_TEST
},
4799 { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),{ STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),state_tessellation
}, WINED3D_GL_EXT_NONE
},
4800 { STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS
), { STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS
), state_msaa
}, ARB_MULTISAMPLE
},
4801 { STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS
), { STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS
), state_msaa_w
}, WINED3D_GL_EXT_NONE
},
4802 { STATE_RENDER(WINED3D_RS_DEBUGMONITORTOKEN
), { STATE_RENDER(WINED3D_RS_DEBUGMONITORTOKEN
), state_debug_monitor
}, WINED3D_GL_EXT_NONE
},
4803 { STATE_RENDER(WINED3D_RS_ZVISIBLE
), { STATE_RENDER(WINED3D_RS_ZVISIBLE
), state_zvisible
}, WINED3D_GL_EXT_NONE
},
4805 { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler
}, WINED3D_GL_EXT_NONE
},
4806 { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler
}, WINED3D_GL_EXT_NONE
},
4807 { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler
}, WINED3D_GL_EXT_NONE
},
4808 { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler
}, WINED3D_GL_EXT_NONE
},
4809 { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler
}, WINED3D_GL_EXT_NONE
},
4810 { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler
}, WINED3D_GL_EXT_NONE
},
4811 { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler
}, WINED3D_GL_EXT_NONE
},
4812 { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler
}, WINED3D_GL_EXT_NONE
},
4813 { STATE_SAMPLER(8), { STATE_SAMPLER(8), sampler
}, WINED3D_GL_EXT_NONE
},
4814 { STATE_SAMPLER(9), { STATE_SAMPLER(9), sampler
}, WINED3D_GL_EXT_NONE
},
4815 { STATE_SAMPLER(10), { STATE_SAMPLER(10), sampler
}, WINED3D_GL_EXT_NONE
},
4816 { STATE_SAMPLER(11), { STATE_SAMPLER(11), sampler
}, WINED3D_GL_EXT_NONE
},
4817 { STATE_SAMPLER(12), { STATE_SAMPLER(12), sampler
}, WINED3D_GL_EXT_NONE
},
4818 { STATE_SAMPLER(13), { STATE_SAMPLER(13), sampler
}, WINED3D_GL_EXT_NONE
},
4819 { STATE_SAMPLER(14), { STATE_SAMPLER(14), sampler
}, WINED3D_GL_EXT_NONE
},
4820 { STATE_SAMPLER(15), { STATE_SAMPLER(15), sampler
}, WINED3D_GL_EXT_NONE
},
4821 { STATE_SAMPLER(16), /* Vertex sampler 0 */ { STATE_SAMPLER(16), sampler
}, WINED3D_GL_EXT_NONE
},
4822 { STATE_SAMPLER(17), /* Vertex sampler 1 */ { STATE_SAMPLER(17), sampler
}, WINED3D_GL_EXT_NONE
},
4823 { STATE_SAMPLER(18), /* Vertex sampler 2 */ { STATE_SAMPLER(18), sampler
}, WINED3D_GL_EXT_NONE
},
4824 { STATE_SAMPLER(19), /* Vertex sampler 3 */ { STATE_SAMPLER(19), sampler
}, WINED3D_GL_EXT_NONE
},
4825 { STATE_BASEVERTEXINDEX
, { STATE_BASEVERTEXINDEX
, state_nop
, }, ARB_DRAW_ELEMENTS_BASE_VERTEX
},
4826 { STATE_BASEVERTEXINDEX
, { STATE_STREAMSRC
, NULL
, }, WINED3D_GL_EXT_NONE
},
4827 { STATE_FRAMEBUFFER
, { STATE_FRAMEBUFFER
, context_state_fb
}, WINED3D_GL_EXT_NONE
},
4828 { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
), context_state_drawbuf
},WINED3D_GL_EXT_NONE
},
4829 { STATE_SHADER(WINED3D_SHADER_TYPE_HULL
), { STATE_SHADER(WINED3D_SHADER_TYPE_HULL
), state_shader
}, WINED3D_GL_EXT_NONE
},
4830 { STATE_SHADER(WINED3D_SHADER_TYPE_DOMAIN
), { STATE_SHADER(WINED3D_SHADER_TYPE_DOMAIN
), state_shader
}, WINED3D_GL_EXT_NONE
},
4831 { STATE_SHADER(WINED3D_SHADER_TYPE_GEOMETRY
), { STATE_SHADER(WINED3D_SHADER_TYPE_GEOMETRY
), state_shader
}, WINED3D_GL_EXT_NONE
},
4832 { STATE_SHADER(WINED3D_SHADER_TYPE_COMPUTE
), { STATE_SHADER(WINED3D_SHADER_TYPE_COMPUTE
), state_compute_shader
}, WINED3D_GL_EXT_NONE
},
4833 {0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE
},
4836 static const struct wined3d_state_entry_template vp_ffp_states
[] =
4838 { STATE_VDECL
, { STATE_VDECL
, vertexdeclaration
}, WINED3D_GL_EXT_NONE
},
4839 { STATE_SHADER(WINED3D_SHADER_TYPE_VERTEX
), { STATE_VDECL
, NULL
}, WINED3D_GL_EXT_NONE
},
4840 { STATE_MATERIAL
, { STATE_RENDER(WINED3D_RS_SPECULARENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4841 { STATE_RENDER(WINED3D_RS_SPECULARENABLE
), { STATE_RENDER(WINED3D_RS_SPECULARENABLE
), state_specularenable
}, WINED3D_GL_EXT_NONE
},
4843 { STATE_CLIPPLANE(0), { STATE_CLIPPLANE(0), clipplane
}, WINED3D_GL_EXT_NONE
},
4844 { STATE_CLIPPLANE(1), { STATE_CLIPPLANE(1), clipplane
}, WINED3D_GL_EXT_NONE
},
4845 { STATE_CLIPPLANE(2), { STATE_CLIPPLANE(2), clipplane
}, WINED3D_GL_EXT_NONE
},
4846 { STATE_CLIPPLANE(3), { STATE_CLIPPLANE(3), clipplane
}, WINED3D_GL_EXT_NONE
},
4847 { STATE_CLIPPLANE(4), { STATE_CLIPPLANE(4), clipplane
}, WINED3D_GL_EXT_NONE
},
4848 { STATE_CLIPPLANE(5), { STATE_CLIPPLANE(5), clipplane
}, WINED3D_GL_EXT_NONE
},
4849 { STATE_CLIPPLANE(6), { STATE_CLIPPLANE(6), clipplane
}, WINED3D_GL_EXT_NONE
},
4850 { STATE_CLIPPLANE(7), { STATE_CLIPPLANE(7), clipplane
}, WINED3D_GL_EXT_NONE
},
4852 { STATE_LIGHT_TYPE
, { STATE_LIGHT_TYPE
, state_nop
}, WINED3D_GL_EXT_NONE
},
4853 { STATE_ACTIVELIGHT(0), { STATE_ACTIVELIGHT(0), light
}, WINED3D_GL_EXT_NONE
},
4854 { STATE_ACTIVELIGHT(1), { STATE_ACTIVELIGHT(1), light
}, WINED3D_GL_EXT_NONE
},
4855 { STATE_ACTIVELIGHT(2), { STATE_ACTIVELIGHT(2), light
}, WINED3D_GL_EXT_NONE
},
4856 { STATE_ACTIVELIGHT(3), { STATE_ACTIVELIGHT(3), light
}, WINED3D_GL_EXT_NONE
},
4857 { STATE_ACTIVELIGHT(4), { STATE_ACTIVELIGHT(4), light
}, WINED3D_GL_EXT_NONE
},
4858 { STATE_ACTIVELIGHT(5), { STATE_ACTIVELIGHT(5), light
}, WINED3D_GL_EXT_NONE
},
4859 { STATE_ACTIVELIGHT(6), { STATE_ACTIVELIGHT(6), light
}, WINED3D_GL_EXT_NONE
},
4860 { STATE_ACTIVELIGHT(7), { STATE_ACTIVELIGHT(7), light
}, WINED3D_GL_EXT_NONE
},
4862 { STATE_VIEWPORT
, { STATE_VIEWPORT
, viewport_vertexpart
}, WINED3D_GL_EXT_NONE
},
4863 /* Transform states follow */
4864 { STATE_TRANSFORM(WINED3D_TS_VIEW
), { STATE_TRANSFORM(WINED3D_TS_VIEW
), transform_view
}, WINED3D_GL_EXT_NONE
},
4865 { STATE_TRANSFORM(WINED3D_TS_PROJECTION
), { STATE_TRANSFORM(WINED3D_TS_PROJECTION
), transform_projection
}, WINED3D_GL_EXT_NONE
},
4866 { STATE_TRANSFORM(WINED3D_TS_TEXTURE0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
4867 { STATE_TRANSFORM(WINED3D_TS_TEXTURE1
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
4868 { STATE_TRANSFORM(WINED3D_TS_TEXTURE2
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
4869 { STATE_TRANSFORM(WINED3D_TS_TEXTURE3
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
4870 { STATE_TRANSFORM(WINED3D_TS_TEXTURE4
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
4871 { STATE_TRANSFORM(WINED3D_TS_TEXTURE5
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
4872 { STATE_TRANSFORM(WINED3D_TS_TEXTURE6
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
4873 { STATE_TRANSFORM(WINED3D_TS_TEXTURE7
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
4874 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 0)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 0)), transform_world
}, WINED3D_GL_EXT_NONE
},
4875 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 1)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 1)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4876 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 2)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 2)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4877 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 3)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 3)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4878 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 4)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 4)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4879 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 5)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 5)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4880 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 6)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 6)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4881 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 7)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 7)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4882 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 8)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 8)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4883 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 9)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 9)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4884 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 10)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 10)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4885 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 11)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 11)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4886 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 12)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 12)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4887 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 13)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 13)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4888 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 14)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 14)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4889 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 15)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 15)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4890 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 16)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 16)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4891 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 17)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 17)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4892 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 18)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 18)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4893 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 19)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 19)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4894 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 20)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 20)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4895 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 21)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 21)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4896 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 22)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 22)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4897 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 23)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 23)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4898 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 24)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 24)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4899 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 25)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 25)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4900 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 26)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 26)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4901 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 27)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 27)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4902 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 28)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 28)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4903 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 29)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 29)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4904 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 30)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 30)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4905 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 31)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 31)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4906 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 32)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 32)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4907 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 33)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 33)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4908 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 34)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 34)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4909 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 35)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 35)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4910 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 36)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 36)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4911 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 37)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 37)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4912 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 38)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 38)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4913 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 39)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 39)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4914 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 40)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 40)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4915 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 41)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 41)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4916 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 42)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 42)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4917 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 43)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 43)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4918 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 44)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 44)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4919 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 45)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 45)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4920 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 46)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 46)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4921 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 47)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 47)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4922 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 48)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 48)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4923 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 49)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 49)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4924 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 50)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 50)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4925 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 51)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 51)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4926 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 52)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 52)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4927 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 53)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 53)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4928 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 54)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 54)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4929 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 55)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 55)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4930 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 56)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 56)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4931 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 57)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 57)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4932 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 58)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 58)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4933 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 59)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 59)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4934 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 60)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 60)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4935 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 61)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 61)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4936 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 62)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 62)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4937 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 63)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 63)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4938 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 64)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 64)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4939 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 65)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 65)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4940 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 66)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 66)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4941 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 67)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 67)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4942 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 68)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 68)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4943 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 69)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 69)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4944 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 70)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 70)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4945 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 71)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 71)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4946 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 72)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 72)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4947 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 73)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 73)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4948 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 74)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 74)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4949 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 75)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 75)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4950 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 76)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 76)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4951 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 77)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 77)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4952 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 78)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 78)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4953 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 79)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 79)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4954 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 80)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 80)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4955 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 81)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 81)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4956 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 82)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 82)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4957 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 83)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 83)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4958 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 84)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 84)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4959 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 85)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 85)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4960 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 86)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 86)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4961 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 87)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 87)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4962 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 88)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 88)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4963 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 89)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 89)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4964 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 90)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 90)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4965 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 91)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 91)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4966 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 92)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 92)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4967 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 93)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 93)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4968 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 94)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 94)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4969 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 95)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 95)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4970 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 96)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 96)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4971 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 97)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 97)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4972 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 98)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 98)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4973 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 99)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 99)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4974 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(100)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(100)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4975 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(101)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(101)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4976 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(102)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(102)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4977 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(103)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(103)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4978 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(104)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(104)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4979 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(105)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(105)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4980 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(106)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(106)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4981 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(107)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(107)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4982 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(108)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(108)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4983 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(109)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(109)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4984 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(110)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(110)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4985 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(111)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(111)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4986 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(112)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(112)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4987 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(113)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(113)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4988 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(114)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(114)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4989 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(115)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(115)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4990 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(116)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(116)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4991 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(117)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(117)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4992 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(118)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(118)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4993 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(119)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(119)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4994 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(120)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(120)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4995 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(121)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(121)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4996 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(122)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(122)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4997 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(123)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(123)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4998 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(124)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(124)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4999 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(125)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(125)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5000 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(126)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(126)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5001 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(127)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(127)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5002 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(128)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(128)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5003 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(129)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(129)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5004 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(130)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(130)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5005 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(131)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(131)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5006 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(132)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(132)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5007 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(133)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(133)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5008 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(134)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(134)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5009 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(135)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(135)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5010 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(136)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(136)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5011 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(137)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(137)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5012 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(138)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(138)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5013 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(139)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(139)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5014 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(140)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(140)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5015 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(141)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(141)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5016 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(142)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(142)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5017 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(143)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(143)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5018 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(144)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(144)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5019 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(145)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(145)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5020 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(146)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(146)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5021 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(147)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(147)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5022 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(148)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(148)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5023 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(149)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(149)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5024 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(150)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(150)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5025 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(151)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(151)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5026 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(152)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(152)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5027 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(153)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(153)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5028 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(154)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(154)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5029 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(155)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(155)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5030 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(156)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(156)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5031 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(157)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(157)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5032 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(158)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(158)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5033 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(159)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(159)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5034 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(160)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(160)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5035 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(161)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(161)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5036 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(162)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(162)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5037 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(163)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(163)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5038 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(164)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(164)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5039 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(165)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(165)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5040 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(166)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(166)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5041 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(167)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(167)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5042 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(168)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(168)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5043 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(169)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(169)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5044 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(170)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(170)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5045 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(171)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(171)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5046 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(172)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(172)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5047 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(173)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(173)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5048 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(174)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(174)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5049 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(175)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(175)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5050 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(176)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(176)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5051 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(177)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(177)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5052 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(178)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(178)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5053 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(179)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(179)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5054 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(180)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(180)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5055 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(181)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(181)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5056 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(182)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(182)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5057 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(183)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(183)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5058 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(184)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(184)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5059 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(185)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(185)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5060 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(186)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(186)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5061 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(187)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(187)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5062 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(188)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(188)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5063 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(189)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(189)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5064 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(190)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(190)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5065 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(191)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(191)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5066 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(192)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(192)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5067 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(193)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(193)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5068 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(194)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(194)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5069 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(195)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(195)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5070 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(196)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(196)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5071 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(197)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(197)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5072 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(198)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(198)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5073 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(199)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(199)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5074 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(200)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(200)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5075 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(201)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(201)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5076 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(202)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(202)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5077 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(203)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(203)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5078 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(204)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(204)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5079 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(205)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(205)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5080 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(206)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(206)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5081 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(207)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(207)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5082 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(208)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(208)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5083 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(209)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(209)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5084 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(210)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(210)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5085 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(211)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(211)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5086 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(212)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(212)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5087 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(213)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(213)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5088 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(214)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(214)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5089 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(215)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(215)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5090 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(216)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(216)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5091 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(217)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(217)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5092 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(218)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(218)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5093 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(219)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(219)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5094 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(220)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(220)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5095 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(221)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(221)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5096 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(222)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(222)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5097 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(223)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(223)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5098 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(224)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(224)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5099 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(225)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(225)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5100 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(226)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(226)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5101 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(227)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(227)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5102 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(228)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(228)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5103 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(229)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(229)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5104 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(230)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(230)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5105 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(231)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(231)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5106 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(232)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(232)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5107 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(233)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(233)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5108 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(234)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(234)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5109 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(235)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(235)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5110 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(236)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(236)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5111 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(237)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(237)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5112 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(238)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(238)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5113 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(239)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(239)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5114 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(240)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(240)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5115 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(241)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(241)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5116 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(242)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(242)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5117 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(243)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(243)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5118 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(244)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(244)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5119 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(245)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(245)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5120 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(246)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(246)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5121 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(247)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(247)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5122 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(248)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(248)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5123 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(249)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(249)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5124 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(250)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(250)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5125 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(251)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(251)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5126 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(252)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(252)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5127 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(253)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(253)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5128 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(254)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(254)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5129 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5130 { STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5131 { STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5132 { STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5133 { STATE_TEXTURESTAGE(3, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(3, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5134 { STATE_TEXTURESTAGE(4, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(4, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5135 { STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5136 { STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5137 { STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5138 { STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5139 { STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5140 { STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5141 { STATE_TEXTURESTAGE(3, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5142 { STATE_TEXTURESTAGE(4, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5143 { STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5144 { STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5145 { STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5147 { STATE_RENDER(WINED3D_RS_FOGENABLE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), state_fog_vertexpart
}, WINED3D_GL_EXT_NONE
},
5148 { STATE_RENDER(WINED3D_RS_FOGTABLEMODE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5149 { STATE_RENDER(WINED3D_RS_FOGVERTEXMODE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5150 { STATE_RENDER(WINED3D_RS_RANGEFOGENABLE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5151 { STATE_RENDER(WINED3D_RS_CLIPPING
), { STATE_RENDER(WINED3D_RS_CLIPPING
), state_clipping
}, WINED3D_GL_EXT_NONE
},
5152 { STATE_RENDER(WINED3D_RS_CLIPPLANEENABLE
), { STATE_RENDER(WINED3D_RS_CLIPPING
), NULL
}, WINED3D_GL_EXT_NONE
},
5153 { STATE_RENDER(WINED3D_RS_LIGHTING
), { STATE_RENDER(WINED3D_RS_LIGHTING
), state_lighting
}, WINED3D_GL_EXT_NONE
},
5154 { STATE_RENDER(WINED3D_RS_AMBIENT
), { STATE_RENDER(WINED3D_RS_AMBIENT
), state_ambient
}, WINED3D_GL_EXT_NONE
},
5155 { STATE_RENDER(WINED3D_RS_COLORVERTEX
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), state_colormat
}, WINED3D_GL_EXT_NONE
},
5156 { STATE_RENDER(WINED3D_RS_LOCALVIEWER
), { STATE_RENDER(WINED3D_RS_LOCALVIEWER
), state_localviewer
}, WINED3D_GL_EXT_NONE
},
5157 { STATE_RENDER(WINED3D_RS_NORMALIZENORMALS
), { STATE_RENDER(WINED3D_RS_NORMALIZENORMALS
), state_normalize
}, WINED3D_GL_EXT_NONE
},
5158 { STATE_RENDER(WINED3D_RS_DIFFUSEMATERIALSOURCE
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), NULL
}, WINED3D_GL_EXT_NONE
},
5159 { STATE_RENDER(WINED3D_RS_SPECULARMATERIALSOURCE
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), NULL
}, WINED3D_GL_EXT_NONE
},
5160 { STATE_RENDER(WINED3D_RS_AMBIENTMATERIALSOURCE
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), NULL
}, WINED3D_GL_EXT_NONE
},
5161 { STATE_RENDER(WINED3D_RS_EMISSIVEMATERIALSOURCE
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), NULL
}, WINED3D_GL_EXT_NONE
},
5162 { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), state_vertexblend_w
}, WINED3D_GL_EXT_NONE
},
5163 { STATE_RENDER(WINED3D_RS_POINTSIZE
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5164 { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), state_psizemin_arb
}, ARB_POINT_PARAMETERS
},
5165 { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), state_psizemin_ext
}, EXT_POINT_PARAMETERS
},
5166 { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), state_psizemin_w
}, WINED3D_GL_EXT_NONE
},
5167 { STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE
), { STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE
), state_pointsprite
}, ARB_POINT_SPRITE
},
5168 { STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE
), { STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE
), state_pointsprite_w
}, WINED3D_GL_EXT_NONE
},
5169 { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), state_pscale
}, WINED3D_GL_EXT_NONE
},
5170 { STATE_RENDER(WINED3D_RS_POINTSCALE_A
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5171 { STATE_RENDER(WINED3D_RS_POINTSCALE_B
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5172 { STATE_RENDER(WINED3D_RS_POINTSCALE_C
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5173 { STATE_RENDER(WINED3D_RS_POINTSIZE_MAX
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), NULL
}, ARB_POINT_PARAMETERS
},
5174 { STATE_RENDER(WINED3D_RS_POINTSIZE_MAX
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), NULL
}, EXT_POINT_PARAMETERS
},
5175 { STATE_RENDER(WINED3D_RS_POINTSIZE_MAX
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), NULL
}, WINED3D_GL_EXT_NONE
},
5176 { STATE_RENDER(WINED3D_RS_TWEENFACTOR
), { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), NULL
}, WINED3D_GL_EXT_NONE
},
5177 { STATE_RENDER(WINED3D_RS_INDEXEDVERTEXBLENDENABLE
), { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), NULL
}, WINED3D_GL_EXT_NONE
},
5179 /* Samplers for NP2 texture matrix adjustions. They are not needed if GL_ARB_texture_non_power_of_two is supported,
5180 * so register a NULL state handler in that case to get the vertex part of sampler() skipped(VTF is handled in the misc states.
5181 * otherwise, register sampler_texmatrix, which takes care of updating the texture matrix
5183 { STATE_SAMPLER(0), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5184 { STATE_SAMPLER(0), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5185 { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5186 { STATE_SAMPLER(1), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5187 { STATE_SAMPLER(1), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5188 { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5189 { STATE_SAMPLER(2), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5190 { STATE_SAMPLER(2), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5191 { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5192 { STATE_SAMPLER(3), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5193 { STATE_SAMPLER(3), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5194 { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5195 { STATE_SAMPLER(4), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5196 { STATE_SAMPLER(4), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5197 { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5198 { STATE_SAMPLER(5), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5199 { STATE_SAMPLER(5), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5200 { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5201 { STATE_SAMPLER(6), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5202 { STATE_SAMPLER(6), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5203 { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5204 { STATE_SAMPLER(7), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5205 { STATE_SAMPLER(7), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5206 { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5207 { STATE_POINT_ENABLE
, { STATE_POINT_ENABLE
, state_nop
}, WINED3D_GL_EXT_NONE
},
5208 {0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE
},
5211 static const struct wined3d_state_entry_template ffp_fragmentstate_template
[] = {
5212 { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5213 { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5214 { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5215 { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5216 { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5217 { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5218 { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5219 { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5220 { STATE_TEXTURESTAGE(0, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5221 { STATE_TEXTURESTAGE(0, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5222 { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5223 { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5224 { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5225 { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5226 { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5227 { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5228 { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5229 { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5230 { STATE_TEXTURESTAGE(1, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5231 { STATE_TEXTURESTAGE(1, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5232 { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5233 { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5234 { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5235 { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5236 { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5237 { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5238 { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5239 { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5240 { STATE_TEXTURESTAGE(2, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5241 { STATE_TEXTURESTAGE(2, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5242 { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5243 { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5244 { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5245 { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5246 { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5247 { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5248 { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5249 { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5250 { STATE_TEXTURESTAGE(3, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5251 { STATE_TEXTURESTAGE(3, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5252 { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5253 { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5254 { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5255 { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5256 { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5257 { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5258 { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5259 { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5260 { STATE_TEXTURESTAGE(4, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5261 { STATE_TEXTURESTAGE(4, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5262 { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5263 { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5264 { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5265 { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5266 { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5267 { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5268 { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5269 { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5270 { STATE_TEXTURESTAGE(5, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5271 { STATE_TEXTURESTAGE(5, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5272 { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5273 { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5274 { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5275 { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5276 { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5277 { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5278 { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5279 { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5280 { STATE_TEXTURESTAGE(6, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5281 { STATE_TEXTURESTAGE(6, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5282 { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5283 { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5284 { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5285 { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5286 { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5287 { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5288 { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5289 { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5290 { STATE_TEXTURESTAGE(7, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5291 { STATE_TEXTURESTAGE(7, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5292 { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
), apply_pixelshader
}, WINED3D_GL_EXT_NONE
},
5293 { STATE_RENDER(WINED3D_RS_ALPHAFUNC
), { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5294 { STATE_RENDER(WINED3D_RS_ALPHAREF
), { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5295 { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), state_alpha_test
}, WINED3D_GL_EXT_NONE
},
5296 { STATE_RENDER(WINED3D_RS_COLORKEYENABLE
), { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5297 { STATE_COLOR_KEY
, { STATE_COLOR_KEY
, state_nop
}, WINED3D_GL_EXT_NONE
},
5298 { STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE
), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
), NULL
}, WINED3D_GL_EXT_NONE
},
5299 { STATE_RENDER(WINED3D_RS_TEXTUREFACTOR
), { STATE_RENDER(WINED3D_RS_TEXTUREFACTOR
), state_texfactor
}, WINED3D_GL_EXT_NONE
},
5300 { STATE_RENDER(WINED3D_RS_FOGCOLOR
), { STATE_RENDER(WINED3D_RS_FOGCOLOR
), state_fogcolor
}, WINED3D_GL_EXT_NONE
},
5301 { STATE_RENDER(WINED3D_RS_FOGDENSITY
), { STATE_RENDER(WINED3D_RS_FOGDENSITY
), state_fogdensity
}, WINED3D_GL_EXT_NONE
},
5302 { STATE_RENDER(WINED3D_RS_FOGENABLE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), state_fog_fragpart
}, WINED3D_GL_EXT_NONE
},
5303 { STATE_RENDER(WINED3D_RS_FOGTABLEMODE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5304 { STATE_RENDER(WINED3D_RS_FOGVERTEXMODE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5305 { STATE_RENDER(WINED3D_RS_FOGSTART
), { STATE_RENDER(WINED3D_RS_FOGSTART
), state_fogstartend
}, WINED3D_GL_EXT_NONE
},
5306 { STATE_RENDER(WINED3D_RS_FOGEND
), { STATE_RENDER(WINED3D_RS_FOGSTART
), NULL
}, WINED3D_GL_EXT_NONE
},
5307 { STATE_RENDER(WINED3D_RS_SHADEMODE
), { STATE_RENDER(WINED3D_RS_SHADEMODE
), state_shademode
}, WINED3D_GL_EXT_NONE
},
5308 { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5309 { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5310 { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5311 { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5312 { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5313 { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5314 { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5315 { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5316 {0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE
},
5319 /* Context activation is done by the caller. */
5320 static void ffp_pipe_enable(const struct wined3d_context
*context
, BOOL enable
) {}
5322 static void *ffp_alloc(const struct wined3d_shader_backend_ops
*shader_backend
, void *shader_priv
)
5327 static void ffp_free(struct wined3d_device
*device
, struct wined3d_context
*context
) {}
5329 static void vp_ffp_get_caps(const struct wined3d_adapter
*adapter
, struct wined3d_vertex_caps
*caps
)
5331 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
5333 caps
->xyzrhw
= FALSE
;
5334 caps
->ffp_generic_attributes
= FALSE
;
5335 caps
->max_active_lights
= gl_info
->limits
.lights
;
5336 caps
->max_vertex_blend_matrices
= 1;
5337 caps
->max_vertex_blend_matrix_index
= 0;
5338 caps
->vertex_processing_caps
= WINED3DVTXPCAPS_DIRECTIONALLIGHTS
5339 | WINED3DVTXPCAPS_MATERIALSOURCE7
5340 | WINED3DVTXPCAPS_POSITIONALLIGHTS
5341 | WINED3DVTXPCAPS_LOCALVIEWER
5342 | WINED3DVTXPCAPS_VERTEXFOG
5343 | WINED3DVTXPCAPS_TEXGEN
5344 | WINED3DVTXPCAPS_TEXGEN_SPHEREMAP
;
5345 caps
->fvf_caps
= WINED3DFVFCAPS_PSIZE
| 0x0008; /* 8 texture coords */
5346 caps
->max_user_clip_planes
= gl_info
->limits
.user_clip_distances
;
5347 caps
->raster_caps
= 0;
5348 if (gl_info
->supported
[NV_FOG_DISTANCE
])
5349 caps
->raster_caps
|= WINED3DPRASTERCAPS_FOGRANGE
;
5352 static DWORD
vp_ffp_get_emul_mask(const struct wined3d_gl_info
*gl_info
)
5354 return GL_EXT_EMUL_ARB_MULTITEXTURE
| GL_EXT_EMUL_EXT_FOG_COORD
;
5357 const struct wined3d_vertex_pipe_ops ffp_vertex_pipe
=
5361 vp_ffp_get_emul_mask
,
5367 static void ffp_fragment_get_caps(const struct wined3d_adapter
*adapter
, struct fragment_caps
*caps
)
5369 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
5371 caps
->wined3d_caps
= 0;
5372 caps
->PrimitiveMiscCaps
= 0;
5373 caps
->TextureOpCaps
= WINED3DTEXOPCAPS_ADD
5374 | WINED3DTEXOPCAPS_ADDSIGNED
5375 | WINED3DTEXOPCAPS_ADDSIGNED2X
5376 | WINED3DTEXOPCAPS_MODULATE
5377 | WINED3DTEXOPCAPS_MODULATE2X
5378 | WINED3DTEXOPCAPS_MODULATE4X
5379 | WINED3DTEXOPCAPS_SELECTARG1
5380 | WINED3DTEXOPCAPS_SELECTARG2
5381 | WINED3DTEXOPCAPS_DISABLE
;
5383 if (gl_info
->supported
[ARB_TEXTURE_ENV_COMBINE
]
5384 || gl_info
->supported
[EXT_TEXTURE_ENV_COMBINE
]
5385 || gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
5387 caps
->TextureOpCaps
|= WINED3DTEXOPCAPS_BLENDDIFFUSEALPHA
5388 | WINED3DTEXOPCAPS_BLENDTEXTUREALPHA
5389 | WINED3DTEXOPCAPS_BLENDFACTORALPHA
5390 | WINED3DTEXOPCAPS_BLENDCURRENTALPHA
5391 | WINED3DTEXOPCAPS_LERP
5392 | WINED3DTEXOPCAPS_SUBTRACT
;
5394 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
]
5395 || gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
5397 caps
->TextureOpCaps
|= WINED3DTEXOPCAPS_ADDSMOOTH
5398 | WINED3DTEXOPCAPS_MULTIPLYADD
5399 | WINED3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR
5400 | WINED3DTEXOPCAPS_MODULATECOLOR_ADDALPHA
5401 | WINED3DTEXOPCAPS_BLENDTEXTUREALPHAPM
;
5403 if (gl_info
->supported
[ARB_TEXTURE_ENV_DOT3
])
5404 caps
->TextureOpCaps
|= WINED3DTEXOPCAPS_DOTPRODUCT3
;
5406 caps
->MaxTextureBlendStages
= gl_info
->limits
.textures
;
5407 caps
->MaxSimultaneousTextures
= gl_info
->limits
.textures
;
5410 static DWORD
ffp_fragment_get_emul_mask(const struct wined3d_gl_info
*gl_info
)
5412 return GL_EXT_EMUL_ARB_MULTITEXTURE
| GL_EXT_EMUL_EXT_FOG_COORD
;
5415 static BOOL
ffp_color_fixup_supported(struct color_fixup_desc fixup
)
5417 /* We only support identity conversions. */
5418 return is_identity_fixup(fixup
);
5421 static BOOL
ffp_none_context_alloc(struct wined3d_context
*context
)
5426 static void ffp_none_context_free(struct wined3d_context
*context
)
5430 const struct wined3d_fragment_pipe_ops ffp_fragment_pipeline
=
5433 ffp_fragment_get_caps
,
5434 ffp_fragment_get_emul_mask
,
5437 ffp_none_context_alloc
,
5438 ffp_none_context_free
,
5439 ffp_color_fixup_supported
,
5440 ffp_fragmentstate_template
,
5443 static void none_pipe_enable(const struct wined3d_context
*context
, BOOL enable
) {}
5445 static void *none_alloc(const struct wined3d_shader_backend_ops
*shader_backend
, void *shader_priv
)
5450 static void none_free(struct wined3d_device
*device
, struct wined3d_context
*context
) {}
5452 static void vp_none_get_caps(const struct wined3d_adapter
*adapter
, struct wined3d_vertex_caps
*caps
)
5454 memset(caps
, 0, sizeof(*caps
));
5457 static DWORD
vp_none_get_emul_mask(const struct wined3d_gl_info
*gl_info
)
5462 const struct wined3d_vertex_pipe_ops none_vertex_pipe
=
5466 vp_none_get_emul_mask
,
5472 static void fp_none_get_caps(const struct wined3d_adapter
*adapter
, struct fragment_caps
*caps
)
5474 memset(caps
, 0, sizeof(*caps
));
5477 static DWORD
fp_none_get_emul_mask(const struct wined3d_gl_info
*gl_info
)
5482 static BOOL
fp_none_color_fixup_supported(struct color_fixup_desc fixup
)
5484 return is_identity_fixup(fixup
);
5487 const struct wined3d_fragment_pipe_ops none_fragment_pipe
=
5491 fp_none_get_emul_mask
,
5494 ffp_none_context_alloc
,
5495 ffp_none_context_free
,
5496 fp_none_color_fixup_supported
,
5500 static unsigned int num_handlers(const APPLYSTATEFUNC
*funcs
)
5503 for(i
= 0; funcs
[i
]; i
++);
5507 static void multistate_apply_2(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
5509 context
->device
->multistate_funcs
[state_id
][0](context
, state
, state_id
);
5510 context
->device
->multistate_funcs
[state_id
][1](context
, state
, state_id
);
5513 static void multistate_apply_3(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
5515 context
->device
->multistate_funcs
[state_id
][0](context
, state
, state_id
);
5516 context
->device
->multistate_funcs
[state_id
][1](context
, state
, state_id
);
5517 context
->device
->multistate_funcs
[state_id
][2](context
, state
, state_id
);
5520 static void prune_invalid_states(struct wined3d_state_entry
*state_table
, const struct wined3d_d3d_info
*d3d_info
)
5522 unsigned int start
, last
, i
;
5524 start
= STATE_TEXTURESTAGE(d3d_info
->limits
.ffp_blend_stages
, 0);
5525 last
= STATE_TEXTURESTAGE(WINED3D_MAX_TEXTURES
- 1, WINED3D_HIGHEST_TEXTURE_STATE
);
5526 for (i
= start
; i
<= last
; ++i
)
5528 state_table
[i
].representative
= 0;
5529 state_table
[i
].apply
= state_undefined
;
5532 start
= STATE_TRANSFORM(WINED3D_TS_TEXTURE0
+ d3d_info
->limits
.ffp_blend_stages
);
5533 last
= STATE_TRANSFORM(WINED3D_TS_TEXTURE0
+ WINED3D_MAX_TEXTURES
- 1);
5534 for (i
= start
; i
<= last
; ++i
)
5536 state_table
[i
].representative
= 0;
5537 state_table
[i
].apply
= state_undefined
;
5540 start
= STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(d3d_info
->limits
.ffp_vertex_blend_matrices
));
5541 last
= STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255));
5542 for (i
= start
; i
<= last
; ++i
)
5544 state_table
[i
].representative
= 0;
5545 state_table
[i
].apply
= state_undefined
;
5549 static void validate_state_table(struct wined3d_state_entry
*state_table
)
5579 static const DWORD simple_states
[] =
5585 STATE_SHADER(WINED3D_SHADER_TYPE_VERTEX
),
5586 STATE_SHADER(WINED3D_SHADER_TYPE_HULL
),
5587 STATE_SHADER(WINED3D_SHADER_TYPE_DOMAIN
),
5588 STATE_SHADER(WINED3D_SHADER_TYPE_GEOMETRY
),
5589 STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
),
5590 STATE_SHADER(WINED3D_SHADER_TYPE_COMPUTE
),
5591 STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX
),
5592 STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_HULL
),
5593 STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_DOMAIN
),
5594 STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY
),
5595 STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL
),
5596 STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_COMPUTE
),
5597 STATE_COMPUTE_SHADER_RESOURCE_BINDING
,
5598 STATE_GRAPHICS_SHADER_RESOURCE_BINDING
,
5599 STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING
,
5600 STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING
,
5605 STATE_POINTSPRITECOORDORIGIN
,
5606 STATE_BASEVERTEXINDEX
,
5612 STATE_DEPTH_STENCIL
,
5615 unsigned int i
, current
;
5617 for (i
= STATE_RENDER(1), current
= 0; i
<= STATE_RENDER(WINEHIGHEST_RENDER_STATE
); ++i
)
5619 if (!rs_holes
[current
].first
|| i
< STATE_RENDER(rs_holes
[current
].first
))
5621 if (!state_table
[i
].representative
)
5622 ERR("State %s (%#x) should have a representative.\n", debug_d3dstate(i
), i
);
5624 else if (state_table
[i
].representative
)
5625 ERR("State %s (%#x) shouldn't have a representative.\n", debug_d3dstate(i
), i
);
5627 if (i
== STATE_RENDER(rs_holes
[current
].last
)) ++current
;
5630 for (i
= 0; i
< ARRAY_SIZE(simple_states
); ++i
)
5632 if (!state_table
[simple_states
[i
]].representative
)
5633 ERR("State %s (%#x) should have a representative.\n",
5634 debug_d3dstate(simple_states
[i
]), simple_states
[i
]);
5637 for (i
= 0; i
< STATE_HIGHEST
+ 1; ++i
)
5639 DWORD rep
= state_table
[i
].representative
;
5642 if (state_table
[rep
].representative
!= rep
)
5644 ERR("State %s (%#x) has invalid representative %s (%#x).\n",
5645 debug_d3dstate(i
), i
, debug_d3dstate(rep
), rep
);
5646 state_table
[i
].representative
= 0;
5651 if (state_table
[i
].apply
)
5652 ERR("State %s (%#x) has both a handler and representative.\n", debug_d3dstate(i
), i
);
5654 else if (!state_table
[i
].apply
)
5656 ERR("Self representing state %s (%#x) has no handler.\n", debug_d3dstate(i
), i
);
5662 HRESULT
compile_state_table(struct wined3d_state_entry
*state_table
, APPLYSTATEFUNC
**dev_multistate_funcs
,
5663 const struct wined3d_d3d_info
*d3d_info
, const BOOL
*supported_extensions
,
5664 const struct wined3d_vertex_pipe_ops
*vertex
, const struct wined3d_fragment_pipe_ops
*fragment
,
5665 const struct wined3d_state_entry_template
*misc
)
5667 APPLYSTATEFUNC multistate_funcs
[STATE_HIGHEST
+ 1][3];
5668 const struct wined3d_state_entry_template
*cur
;
5669 unsigned int i
, type
, handlers
;
5670 BOOL set
[STATE_HIGHEST
+ 1];
5672 memset(multistate_funcs
, 0, sizeof(multistate_funcs
));
5674 for (i
= 0; i
< STATE_HIGHEST
+ 1; ++i
)
5676 state_table
[i
].representative
= 0;
5677 state_table
[i
].apply
= state_undefined
;
5680 for (type
= 0; type
< 3; ++type
)
5682 /* This switch decides the order in which the states are applied */
5685 case 0: cur
= misc
; break;
5686 case 1: cur
= fragment
->states
; break;
5687 case 2: cur
= vertex
->vp_states
; break;
5688 default: cur
= NULL
; /* Stupid compiler */
5692 /* GL extension filtering should not prevent multiple handlers being applied from different
5695 memset(set
, 0, sizeof(set
));
5697 for (i
= 0; cur
[i
].state
; ++i
)
5699 APPLYSTATEFUNC
*funcs_array
;
5701 /* Only use the first matching state with the available extension from one template.
5703 * {D3DRS_FOOBAR, {D3DRS_FOOBAR, func1}, XYZ_FANCY},
5704 * {D3DRS_FOOBAR, {D3DRS_FOOBAR, func2}, 0 }
5706 * if GL_XYZ_fancy is supported, ignore the 2nd line
5708 if (set
[cur
[i
].state
]) continue;
5709 /* Skip state lines depending on unsupported extensions */
5710 if (!supported_extensions
[cur
[i
].extension
]) continue;
5711 set
[cur
[i
].state
] = TRUE
;
5712 /* In some cases having an extension means that nothing has to be
5713 * done for a state, e.g. if GL_ARB_texture_non_power_of_two is
5714 * supported, the texture coordinate fixup can be ignored. If the
5715 * apply function is used, mark the state set(done above) to prevent
5716 * applying later lines, but do not record anything in the state
5719 if (!cur
[i
].content
.representative
) continue;
5721 handlers
= num_handlers(multistate_funcs
[cur
[i
].state
]);
5722 multistate_funcs
[cur
[i
].state
][handlers
] = cur
[i
].content
.apply
;
5726 state_table
[cur
[i
].state
].apply
= cur
[i
].content
.apply
;
5729 state_table
[cur
[i
].state
].apply
= multistate_apply_2
;
5730 if (!(dev_multistate_funcs
[cur
[i
].state
] = heap_calloc(2, sizeof(**dev_multistate_funcs
))))
5733 dev_multistate_funcs
[cur
[i
].state
][0] = multistate_funcs
[cur
[i
].state
][0];
5734 dev_multistate_funcs
[cur
[i
].state
][1] = multistate_funcs
[cur
[i
].state
][1];
5737 state_table
[cur
[i
].state
].apply
= multistate_apply_3
;
5738 if (!(funcs_array
= heap_realloc(dev_multistate_funcs
[cur
[i
].state
],
5739 sizeof(**dev_multistate_funcs
) * 3)))
5742 dev_multistate_funcs
[cur
[i
].state
] = funcs_array
;
5743 dev_multistate_funcs
[cur
[i
].state
][2] = multistate_funcs
[cur
[i
].state
][2];
5746 ERR("Unexpected amount of state handlers for state %u: %u.\n",
5747 cur
[i
].state
, handlers
+ 1);
5750 if (state_table
[cur
[i
].state
].representative
5751 && state_table
[cur
[i
].state
].representative
!= cur
[i
].content
.representative
)
5753 FIXME("State %s (%#x) has different representatives in different pipeline parts.\n",
5754 debug_d3dstate(cur
[i
].state
), cur
[i
].state
);
5756 state_table
[cur
[i
].state
].representative
= cur
[i
].content
.representative
;
5760 prune_invalid_states(state_table
, d3d_info
);
5761 validate_state_table(state_table
);
5766 for (i
= 0; i
<= STATE_HIGHEST
; ++i
)
5768 heap_free(dev_multistate_funcs
[i
]);
5771 memset(dev_multistate_funcs
, 0, (STATE_HIGHEST
+ 1) * sizeof(*dev_multistate_funcs
));
5773 return E_OUTOFMEMORY
;