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
30 #include "wined3d_private.h"
31 #include "wined3d_gl.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(d3d
);
35 ULONG CDECL
wined3d_blend_state_incref(struct wined3d_blend_state
*state
)
37 unsigned int refcount
= InterlockedIncrement(&state
->refcount
);
39 TRACE("%p increasing refcount to %u.\n", state
, refcount
);
44 static void wined3d_blend_state_destroy_object(void *object
)
46 TRACE("object %p.\n", object
);
51 ULONG CDECL
wined3d_blend_state_decref(struct wined3d_blend_state
*state
)
53 unsigned int refcount
= wined3d_atomic_decrement_mutex_lock(&state
->refcount
);
54 struct wined3d_device
*device
= state
->device
;
56 TRACE("%p decreasing refcount to %u.\n", state
, refcount
);
60 state
->parent_ops
->wined3d_object_destroyed(state
->parent
);
61 wined3d_cs_destroy_object(device
->cs
, wined3d_blend_state_destroy_object
, state
);
62 wined3d_mutex_unlock();
68 void * CDECL
wined3d_blend_state_get_parent(const struct wined3d_blend_state
*state
)
70 TRACE("state %p.\n", state
);
75 static BOOL
is_dual_source(enum wined3d_blend state
)
77 return state
>= WINED3D_BLEND_SRC1COLOR
&& state
<= WINED3D_BLEND_INVSRC1ALPHA
;
80 HRESULT CDECL
wined3d_blend_state_create(struct wined3d_device
*device
,
81 const struct wined3d_blend_state_desc
*desc
, void *parent
,
82 const struct wined3d_parent_ops
*parent_ops
, struct wined3d_blend_state
**state
)
84 struct wined3d_blend_state
*object
;
86 TRACE("device %p, desc %p, parent %p, parent_ops %p, state %p.\n",
87 device
, desc
, parent
, parent_ops
, state
);
89 if (!(object
= heap_alloc_zero(sizeof(*object
))))
94 object
->parent
= parent
;
95 object
->parent_ops
= parent_ops
;
96 object
->device
= device
;
98 object
->dual_source
= desc
->rt
[0].enable
99 && (is_dual_source(desc
->rt
[0].src
)
100 || is_dual_source(desc
->rt
[0].dst
)
101 || is_dual_source(desc
->rt
[0].src_alpha
)
102 || is_dual_source(desc
->rt
[0].dst_alpha
));
104 TRACE("Created blend state %p.\n", object
);
110 ULONG CDECL
wined3d_depth_stencil_state_incref(struct wined3d_depth_stencil_state
*state
)
112 unsigned int refcount
= InterlockedIncrement(&state
->refcount
);
114 TRACE("%p increasing refcount to %u.\n", state
, refcount
);
119 static void wined3d_depth_stencil_state_destroy_object(void *object
)
121 TRACE("object %p.\n", object
);
126 ULONG CDECL
wined3d_depth_stencil_state_decref(struct wined3d_depth_stencil_state
*state
)
128 unsigned int refcount
= wined3d_atomic_decrement_mutex_lock(&state
->refcount
);
129 struct wined3d_device
*device
= state
->device
;
131 TRACE("%p decreasing refcount to %u.\n", state
, refcount
);
135 state
->parent_ops
->wined3d_object_destroyed(state
->parent
);
136 wined3d_cs_destroy_object(device
->cs
, wined3d_depth_stencil_state_destroy_object
, state
);
137 wined3d_mutex_unlock();
143 void * CDECL
wined3d_depth_stencil_state_get_parent(const struct wined3d_depth_stencil_state
*state
)
145 TRACE("state %p.\n", state
);
147 return state
->parent
;
150 static bool stencil_op_writes_ds(const struct wined3d_stencil_op_desc
*desc
)
152 return desc
->fail_op
!= WINED3D_STENCIL_OP_KEEP
153 || desc
->depth_fail_op
!= WINED3D_STENCIL_OP_KEEP
154 || desc
->pass_op
!= WINED3D_STENCIL_OP_KEEP
;
157 static bool depth_stencil_state_desc_writes_ds(const struct wined3d_depth_stencil_state_desc
*desc
)
159 if (desc
->depth
&& desc
->depth_write
)
162 if (desc
->stencil
&& desc
->stencil_write_mask
)
164 if (stencil_op_writes_ds(&desc
->front
) || stencil_op_writes_ds(&desc
->back
))
171 HRESULT CDECL
wined3d_depth_stencil_state_create(struct wined3d_device
*device
,
172 const struct wined3d_depth_stencil_state_desc
*desc
, void *parent
,
173 const struct wined3d_parent_ops
*parent_ops
, struct wined3d_depth_stencil_state
**state
)
175 struct wined3d_depth_stencil_state
*object
;
177 TRACE("device %p, desc %p, parent %p, parent_ops %p, state %p.\n",
178 device
, desc
, parent
, parent_ops
, state
);
180 if (!(object
= heap_alloc_zero(sizeof(*object
))))
181 return E_OUTOFMEMORY
;
183 object
->refcount
= 1;
184 object
->desc
= *desc
;
185 object
->parent
= parent
;
186 object
->parent_ops
= parent_ops
;
187 object
->device
= device
;
189 object
->writes_ds
= depth_stencil_state_desc_writes_ds(desc
);
191 TRACE("Created depth/stencil state %p.\n", object
);
197 ULONG CDECL
wined3d_rasterizer_state_incref(struct wined3d_rasterizer_state
*state
)
199 unsigned int refcount
= InterlockedIncrement(&state
->refcount
);
201 TRACE("%p increasing refcount to %u.\n", state
, refcount
);
206 static void wined3d_rasterizer_state_destroy_object(void *object
)
208 TRACE("object %p.\n", object
);
213 ULONG CDECL
wined3d_rasterizer_state_decref(struct wined3d_rasterizer_state
*state
)
215 unsigned int refcount
= wined3d_atomic_decrement_mutex_lock(&state
->refcount
);
216 struct wined3d_device
*device
= state
->device
;
218 TRACE("%p decreasing refcount to %u.\n", state
, refcount
);
222 state
->parent_ops
->wined3d_object_destroyed(state
->parent
);
223 wined3d_cs_destroy_object(device
->cs
, wined3d_rasterizer_state_destroy_object
, state
);
224 wined3d_mutex_unlock();
230 void * CDECL
wined3d_rasterizer_state_get_parent(const struct wined3d_rasterizer_state
*state
)
232 TRACE("rasterizer_state %p.\n", state
);
234 return state
->parent
;
237 HRESULT CDECL
wined3d_rasterizer_state_create(struct wined3d_device
*device
,
238 const struct wined3d_rasterizer_state_desc
*desc
, void *parent
,
239 const struct wined3d_parent_ops
*parent_ops
, struct wined3d_rasterizer_state
**state
)
241 struct wined3d_rasterizer_state
*object
;
243 TRACE("device %p, desc %p, parent %p, parent_ops %p, state %p.\n",
244 device
, desc
, parent
, parent_ops
, state
);
246 if (!(object
= heap_alloc_zero(sizeof(*object
))))
247 return E_OUTOFMEMORY
;
249 object
->refcount
= 1;
250 object
->desc
= *desc
;
251 object
->parent
= parent
;
252 object
->parent_ops
= parent_ops
;
253 object
->device
= device
;
255 TRACE("Created rasterizer state %p.\n", object
);
261 /* Context activation for state handler is done by the caller. */
263 static void state_undefined(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
265 ERR("Undefined state %s (%#lx).\n", debug_d3dstate(state_id
), state_id
);
268 void state_nop(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
270 TRACE("%s: nop in current pipe config.\n", debug_d3dstate(state_id
));
273 static void fillmode(const struct wined3d_rasterizer_state
*r
, const struct wined3d_gl_info
*gl_info
)
275 enum wined3d_fill_mode mode
= r
? r
->desc
.fill_mode
: WINED3D_FILL_SOLID
;
279 case WINED3D_FILL_POINT
:
280 gl_info
->gl_ops
.gl
.p_glPolygonMode(GL_FRONT_AND_BACK
, GL_POINT
);
281 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_POINT)");
283 case WINED3D_FILL_WIREFRAME
:
284 gl_info
->gl_ops
.gl
.p_glPolygonMode(GL_FRONT_AND_BACK
, GL_LINE
);
285 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)");
287 case WINED3D_FILL_SOLID
:
288 gl_info
->gl_ops
.gl
.p_glPolygonMode(GL_FRONT_AND_BACK
, GL_FILL
);
289 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)");
292 FIXME("Unrecognized fill mode %#x.\n", mode
);
296 static void state_lighting(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
298 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
300 /* Lighting is not enabled if transformed vertices are drawn, but lighting
301 * does not affect the stream sources, so it is not grouped for
302 * performance reasons. */
304 if (state
->render_states
[WINED3D_RS_LIGHTING
]
305 && !context
->stream_info
.position_transformed
)
307 gl_info
->gl_ops
.gl
.p_glEnable(GL_LIGHTING
);
308 checkGLcall("glEnable GL_LIGHTING");
312 gl_info
->gl_ops
.gl
.p_glDisable(GL_LIGHTING
);
313 checkGLcall("glDisable GL_LIGHTING");
317 static void cullmode(const struct wined3d_rasterizer_state
*r
, const struct wined3d_gl_info
*gl_info
)
319 enum wined3d_cull mode
= r
? r
->desc
.cull_mode
: WINED3D_CULL_BACK
;
321 /* glFrontFace() is set in context.c at context init and on an
322 * offscreen / onscreen rendering switch. */
325 case WINED3D_CULL_NONE
:
326 gl_info
->gl_ops
.gl
.p_glDisable(GL_CULL_FACE
);
327 checkGLcall("glDisable GL_CULL_FACE");
329 case WINED3D_CULL_FRONT
:
330 gl_info
->gl_ops
.gl
.p_glEnable(GL_CULL_FACE
);
331 checkGLcall("glEnable GL_CULL_FACE");
332 gl_info
->gl_ops
.gl
.p_glCullFace(GL_FRONT
);
333 checkGLcall("glCullFace(GL_FRONT)");
335 case WINED3D_CULL_BACK
:
336 gl_info
->gl_ops
.gl
.p_glEnable(GL_CULL_FACE
);
337 checkGLcall("glEnable GL_CULL_FACE");
338 gl_info
->gl_ops
.gl
.p_glCullFace(GL_BACK
);
339 checkGLcall("glCullFace(GL_BACK)");
342 FIXME("Unrecognized cull mode %#x.\n", mode
);
346 void state_shademode(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
348 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
350 switch (state
->render_states
[WINED3D_RS_SHADEMODE
])
352 case WINED3D_SHADE_FLAT
:
353 gl_info
->gl_ops
.gl
.p_glShadeModel(GL_FLAT
);
354 checkGLcall("glShadeModel(GL_FLAT)");
356 case WINED3D_SHADE_GOURAUD
:
357 /* WINED3D_SHADE_PHONG in practice is the same as WINED3D_SHADE_GOURAUD
359 case WINED3D_SHADE_PHONG
:
360 gl_info
->gl_ops
.gl
.p_glShadeModel(GL_SMOOTH
);
361 checkGLcall("glShadeModel(GL_SMOOTH)");
364 FIXME("Unrecognized shade mode %#x.\n",
365 state
->render_states
[WINED3D_RS_SHADEMODE
]);
369 static void state_ditherenable(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
371 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
373 if (state
->render_states
[WINED3D_RS_DITHERENABLE
])
375 gl_info
->gl_ops
.gl
.p_glEnable(GL_DITHER
);
376 checkGLcall("glEnable GL_DITHER");
380 gl_info
->gl_ops
.gl
.p_glDisable(GL_DITHER
);
381 checkGLcall("glDisable GL_DITHER");
385 GLenum
wined3d_gl_compare_func(enum wined3d_cmp_func f
)
389 case WINED3D_CMP_NEVER
:
391 case WINED3D_CMP_LESS
:
393 case WINED3D_CMP_EQUAL
:
395 case WINED3D_CMP_LESSEQUAL
:
397 case WINED3D_CMP_GREATER
:
399 case WINED3D_CMP_NOTEQUAL
:
401 case WINED3D_CMP_GREATEREQUAL
:
403 case WINED3D_CMP_ALWAYS
:
407 WARN("Unrecognized compare function %#x.\n", f
);
409 FIXME("Unrecognized compare function %#x.\n", f
);
414 static void state_ambient(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
416 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
417 struct wined3d_color color
;
419 wined3d_color_from_d3dcolor(&color
, state
->render_states
[WINED3D_RS_AMBIENT
]);
420 TRACE("Setting ambient to %s.\n", debug_color(&color
));
421 gl_info
->gl_ops
.gl
.p_glLightModelfv(GL_LIGHT_MODEL_AMBIENT
, &color
.r
);
422 checkGLcall("glLightModel for MODEL_AMBIENT");
425 static GLenum
gl_blend_op(const struct wined3d_gl_info
*gl_info
, enum wined3d_blend_op op
)
429 case WINED3D_BLEND_OP_ADD
:
431 case WINED3D_BLEND_OP_SUBTRACT
:
432 return gl_info
->supported
[EXT_BLEND_SUBTRACT
] ? GL_FUNC_SUBTRACT
: GL_FUNC_ADD
;
433 case WINED3D_BLEND_OP_REVSUBTRACT
:
434 return gl_info
->supported
[EXT_BLEND_SUBTRACT
] ? GL_FUNC_REVERSE_SUBTRACT
: GL_FUNC_ADD
;
435 case WINED3D_BLEND_OP_MIN
:
436 return gl_info
->supported
[EXT_BLEND_MINMAX
] ? GL_MIN
: GL_FUNC_ADD
;
437 case WINED3D_BLEND_OP_MAX
:
438 return gl_info
->supported
[EXT_BLEND_MINMAX
] ? GL_MAX
: GL_FUNC_ADD
;
441 WARN("Unhandled blend op %#x.\n", op
);
443 FIXME("Unhandled blend op %#x.\n", op
);
448 static void blendop(const struct wined3d_state
*state
, const struct wined3d_gl_info
*gl_info
)
450 const struct wined3d_blend_state
*b
= state
->blend_state
;
451 GLenum blend_equation_alpha
= GL_FUNC_ADD_EXT
;
452 GLenum blend_equation
= GL_FUNC_ADD_EXT
;
454 if (!gl_info
->supported
[WINED3D_GL_BLEND_EQUATION
])
456 WARN("Unsupported in local OpenGL implementation: glBlendEquation.\n");
460 /* BLENDOPALPHA requires GL_EXT_blend_equation_separate, so make sure it is around */
461 if (b
->desc
.rt
[0].op_alpha
&& !gl_info
->supported
[EXT_BLEND_EQUATION_SEPARATE
])
463 WARN("Unsupported in local OpenGL implementation: glBlendEquationSeparate.\n");
467 blend_equation
= gl_blend_op(gl_info
, b
->desc
.rt
[0].op
);
468 blend_equation_alpha
= gl_blend_op(gl_info
, b
->desc
.rt
[0].op_alpha
);
469 TRACE("blend_equation %#x, blend_equation_alpha %#x.\n", blend_equation
, blend_equation_alpha
);
471 if (b
->desc
.rt
[0].op
!= b
->desc
.rt
[0].op_alpha
)
473 GL_EXTCALL(glBlendEquationSeparate(blend_equation
, blend_equation_alpha
));
474 checkGLcall("glBlendEquationSeparate");
478 GL_EXTCALL(glBlendEquation(blend_equation
));
479 checkGLcall("glBlendEquation");
483 static GLenum
gl_blend_factor(enum wined3d_blend factor
, const struct wined3d_format
*dst_format
)
487 case WINED3D_BLEND_ZERO
:
489 case WINED3D_BLEND_ONE
:
491 case WINED3D_BLEND_SRCCOLOR
:
493 case WINED3D_BLEND_INVSRCCOLOR
:
494 return GL_ONE_MINUS_SRC_COLOR
;
495 case WINED3D_BLEND_SRCALPHA
:
497 case WINED3D_BLEND_INVSRCALPHA
:
498 return GL_ONE_MINUS_SRC_ALPHA
;
499 case WINED3D_BLEND_DESTCOLOR
:
501 case WINED3D_BLEND_INVDESTCOLOR
:
502 return GL_ONE_MINUS_DST_COLOR
;
503 /* To compensate for the lack of format switching with backbuffer
504 * offscreen rendering, and with onscreen rendering, we modify the
505 * alpha test parameters for (INV)DESTALPHA if the render target
506 * doesn't support alpha blending. A nonexistent alpha channel
507 * returns 1.0, so WINED3D_BLEND_DESTALPHA becomes GL_ONE, and
508 * WINED3D_BLEND_INVDESTALPHA becomes GL_ZERO. */
509 case WINED3D_BLEND_DESTALPHA
:
510 return dst_format
->alpha_size
? GL_DST_ALPHA
: GL_ONE
;
511 case WINED3D_BLEND_INVDESTALPHA
:
512 return dst_format
->alpha_size
? GL_ONE_MINUS_DST_ALPHA
: GL_ZERO
;
513 case WINED3D_BLEND_SRCALPHASAT
:
514 return GL_SRC_ALPHA_SATURATE
;
515 case WINED3D_BLEND_BLENDFACTOR
:
516 return GL_CONSTANT_COLOR_EXT
;
517 case WINED3D_BLEND_INVBLENDFACTOR
:
518 return GL_ONE_MINUS_CONSTANT_COLOR_EXT
;
519 case WINED3D_BLEND_SRC1COLOR
:
520 return GL_SRC1_COLOR
;
521 case WINED3D_BLEND_INVSRC1COLOR
:
522 return GL_ONE_MINUS_SRC1_COLOR
;
523 case WINED3D_BLEND_SRC1ALPHA
:
524 return GL_SRC1_ALPHA
;
525 case WINED3D_BLEND_INVSRC1ALPHA
:
526 return GL_ONE_MINUS_SRC1_ALPHA
;
529 WARN("Unhandled blend factor %#x.\n", factor
);
531 FIXME("Unhandled blend factor %#x.\n", factor
);
536 static void gl_blend_from_d3d(GLenum
*src_blend
, GLenum
*dst_blend
,
537 enum wined3d_blend d3d_src_blend
, enum wined3d_blend d3d_dst_blend
,
538 const struct wined3d_format
*rt_format
)
540 /* WINED3D_BLEND_BOTHSRCALPHA and WINED3D_BLEND_BOTHINVSRCALPHA are legacy
541 * source blending values which are still valid up to d3d9. They should
542 * not occur as dest blend values. */
543 if (d3d_src_blend
== WINED3D_BLEND_BOTHSRCALPHA
)
545 *src_blend
= GL_SRC_ALPHA
;
546 *dst_blend
= GL_ONE_MINUS_SRC_ALPHA
;
548 else if (d3d_src_blend
== WINED3D_BLEND_BOTHINVSRCALPHA
)
550 *src_blend
= GL_ONE_MINUS_SRC_ALPHA
;
551 *dst_blend
= GL_SRC_ALPHA
;
555 *src_blend
= gl_blend_factor(d3d_src_blend
, rt_format
);
556 *dst_blend
= gl_blend_factor(d3d_dst_blend
, rt_format
);
560 static void state_blend_factor_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
562 WARN("Unsupported in local OpenGL implementation: glBlendColor.\n");
565 static void state_blend_factor(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
567 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
568 const struct wined3d_color
*factor
= &state
->blend_factor
;
570 TRACE("Setting blend factor to %s.\n", debug_color(factor
));
572 GL_EXTCALL(glBlendColor(factor
->r
, factor
->g
, factor
->b
, factor
->a
));
573 checkGLcall("glBlendColor");
576 static BOOL
is_blend_enabled(struct wined3d_context
*context
, const struct wined3d_state
*state
, UINT index
)
578 const struct wined3d_blend_state
*b
= state
->blend_state
;
580 if (!state
->fb
.render_targets
[index
])
583 if (!b
->desc
.rt
[index
].enable
)
586 /* Disable blending in all cases even without pixel shaders.
587 * With blending on we could face a big performance penalty.
588 * The d3d9 visual test confirms the behavior. */
589 if (context
->render_offscreen
590 && !(state
->fb
.render_targets
[index
]->format_caps
& WINED3D_FORMAT_CAP_POSTPIXELSHADER_BLENDING
))
596 static void blend(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
598 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
599 const struct wined3d_blend_state
*b
= state
->blend_state
;
600 const struct wined3d_format
*rt_format
;
601 GLenum src_blend
, dst_blend
;
604 if (gl_info
->supported
[ARB_MULTISAMPLE
])
606 if (b
&& b
->desc
.alpha_to_coverage
)
607 gl_info
->gl_ops
.gl
.p_glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE
);
609 gl_info
->gl_ops
.gl
.p_glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE
);
610 checkGLcall("glEnable GL_SAMPLE_ALPHA_TO_COVERAGE");
613 if (b
&& b
->desc
.independent
)
614 WARN("Independent blend is not supported by this GL implementation.\n");
616 mask
= b
? b
->desc
.rt
[0].writemask
: 0xf;
618 gl_info
->gl_ops
.gl
.p_glColorMask(mask
& WINED3DCOLORWRITEENABLE_RED
? GL_TRUE
: GL_FALSE
,
619 mask
& WINED3DCOLORWRITEENABLE_GREEN
? GL_TRUE
: GL_FALSE
,
620 mask
& WINED3DCOLORWRITEENABLE_BLUE
? GL_TRUE
: GL_FALSE
,
621 mask
& WINED3DCOLORWRITEENABLE_ALPHA
? GL_TRUE
: GL_FALSE
);
622 checkGLcall("glColorMask");
624 if (!b
|| !is_blend_enabled(context
, state
, 0))
626 gl_info
->gl_ops
.gl
.p_glDisable(GL_BLEND
);
627 checkGLcall("glDisable GL_BLEND");
631 gl_info
->gl_ops
.gl
.p_glEnable(GL_BLEND
);
632 checkGLcall("glEnable GL_BLEND");
634 rt_format
= state
->fb
.render_targets
[0]->format
;
636 gl_blend_from_d3d(&src_blend
, &dst_blend
, b
->desc
.rt
[0].src
, b
->desc
.rt
[0].dst
, rt_format
);
638 blendop(state
, gl_info
);
640 if (b
->desc
.rt
[0].src
!= b
->desc
.rt
[0].src_alpha
|| b
->desc
.rt
[0].dst
!= b
->desc
.rt
[0].dst_alpha
)
642 GLenum src_blend_alpha
, dst_blend_alpha
;
644 /* Separate alpha blending requires GL_EXT_blend_function_separate, so make sure it is around */
645 if (!gl_info
->supported
[EXT_BLEND_FUNC_SEPARATE
])
647 WARN("Unsupported in local OpenGL implementation: glBlendFuncSeparate.\n");
651 gl_blend_from_d3d(&src_blend_alpha
, &dst_blend_alpha
, b
->desc
.rt
[0].src_alpha
, b
->desc
.rt
[0].dst_alpha
, rt_format
);
653 GL_EXTCALL(glBlendFuncSeparate(src_blend
, dst_blend
, src_blend_alpha
, dst_blend_alpha
));
654 checkGLcall("glBlendFuncSeparate");
658 TRACE("glBlendFunc src=%x, dst=%x.\n", src_blend
, dst_blend
);
659 gl_info
->gl_ops
.gl
.p_glBlendFunc(src_blend
, dst_blend
);
660 checkGLcall("glBlendFunc");
663 /* Colorkey fixup for stage 0 alphaop depends on blend state, so it may need
665 if (state
->render_states
[WINED3D_RS_COLORKEYENABLE
])
666 context_apply_state(context
, state
, STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
));
669 static void set_color_mask(const struct wined3d_gl_info
*gl_info
, UINT index
, DWORD mask
)
671 GL_EXTCALL(glColorMaski(index
,
672 mask
& WINED3DCOLORWRITEENABLE_RED
? GL_TRUE
: GL_FALSE
,
673 mask
& WINED3DCOLORWRITEENABLE_GREEN
? GL_TRUE
: GL_FALSE
,
674 mask
& WINED3DCOLORWRITEENABLE_BLUE
? GL_TRUE
: GL_FALSE
,
675 mask
& WINED3DCOLORWRITEENABLE_ALPHA
? GL_TRUE
: GL_FALSE
));
676 checkGLcall("glColorMaski");
679 static void blend_db2(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
681 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
682 GLenum src_blend
, dst_blend
, src_blend_alpha
, dst_blend_alpha
;
683 const struct wined3d_blend_state
*b
= state
->blend_state
;
684 const struct wined3d_format
*rt_format
;
685 BOOL dual_source
= b
&& b
->dual_source
;
688 if (b
&& b
->desc
.alpha_to_coverage
)
689 gl_info
->gl_ops
.gl
.p_glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE
);
691 gl_info
->gl_ops
.gl
.p_glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE
);
692 checkGLcall("glEnable GL_SAMPLE_ALPHA_TO_COVERAGE");
694 if (context
->last_was_dual_source_blend
!= dual_source
)
696 /* Dual source blending changes the location of the output varyings. */
697 context
->shader_update_mask
|= 1u << WINED3D_SHADER_TYPE_PIXEL
;
698 context
->last_was_dual_source_blend
= dual_source
;
701 if (!b
|| !b
->desc
.independent
)
703 blend(context
, state
, state_id
);
707 rt_format
= state
->fb
.render_targets
[0]->format
;
708 gl_blend_from_d3d(&src_blend
, &dst_blend
, b
->desc
.rt
[0].src
, b
->desc
.rt
[0].dst
, rt_format
);
709 gl_blend_from_d3d(&src_blend_alpha
, &dst_blend_alpha
, b
->desc
.rt
[0].src_alpha
, b
->desc
.rt
[0].dst_alpha
, rt_format
);
711 GL_EXTCALL(glBlendFuncSeparate(src_blend
, dst_blend
, src_blend_alpha
, dst_blend_alpha
));
712 checkGLcall("glBlendFuncSeparate");
714 GL_EXTCALL(glBlendEquationSeparate(gl_blend_op(gl_info
, b
->desc
.rt
[0].op
),
715 gl_blend_op(gl_info
, b
->desc
.rt
[0].op_alpha
)));
716 checkGLcall("glBlendEquationSeparate");
718 for (i
= 0; i
< WINED3D_MAX_RENDER_TARGETS
; ++i
)
720 set_color_mask(gl_info
, i
, b
->desc
.rt
[i
].writemask
);
722 if (!is_blend_enabled(context
, state
, i
))
724 GL_EXTCALL(glDisablei(GL_BLEND
, i
));
725 checkGLcall("glDisablei GL_BLEND");
729 GL_EXTCALL(glEnablei(GL_BLEND
, i
));
730 checkGLcall("glEnablei GL_BLEND");
732 if (b
->desc
.rt
[i
].src
!= b
->desc
.rt
[0].src
733 || b
->desc
.rt
[i
].dst
!= b
->desc
.rt
[0].dst
734 || b
->desc
.rt
[i
].op
!= b
->desc
.rt
[0].op
735 || b
->desc
.rt
[i
].src_alpha
!= b
->desc
.rt
[0].src_alpha
736 || b
->desc
.rt
[i
].dst_alpha
!= b
->desc
.rt
[0].dst_alpha
737 || b
->desc
.rt
[i
].op_alpha
!= b
->desc
.rt
[0].op_alpha
)
738 WARN("Independent blend equations and blend functions are not supported by this GL implementation.\n");
741 /* Colorkey fixup for stage 0 alphaop depends on blend state, so it may need
743 if (state
->render_states
[WINED3D_RS_COLORKEYENABLE
])
744 context_apply_state(context
, state
, STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
));
747 static void blend_dbb(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
749 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
750 const struct wined3d_blend_state
*b
= state
->blend_state
;
751 BOOL dual_source
= b
&& b
->dual_source
;
754 if (b
&& b
->desc
.alpha_to_coverage
)
755 gl_info
->gl_ops
.gl
.p_glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE
);
757 gl_info
->gl_ops
.gl
.p_glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE
);
758 checkGLcall("glEnable GL_SAMPLE_ALPHA_TO_COVERAGE");
760 if (context
->last_was_dual_source_blend
!= dual_source
)
762 /* Dual source blending changes the location of the output varyings. */
763 context
->shader_update_mask
|= 1u << WINED3D_SHADER_TYPE_PIXEL
;
764 context
->last_was_dual_source_blend
= dual_source
;
767 if (!b
|| !b
->desc
.independent
)
769 blend(context
, state
, state_id
);
773 for (i
= 0; i
< WINED3D_MAX_RENDER_TARGETS
; ++i
)
775 GLenum src_blend
, dst_blend
, src_blend_alpha
, dst_blend_alpha
;
776 const struct wined3d_format
*rt_format
;
778 set_color_mask(gl_info
, i
, b
->desc
.rt
[i
].writemask
);
780 if (!is_blend_enabled(context
, state
, i
))
782 GL_EXTCALL(glDisablei(GL_BLEND
, i
));
783 checkGLcall("glDisablei GL_BLEND");
787 GL_EXTCALL(glEnablei(GL_BLEND
, i
));
788 checkGLcall("glEnablei GL_BLEND");
790 rt_format
= state
->fb
.render_targets
[i
]->format
;
791 gl_blend_from_d3d(&src_blend
, &dst_blend
, b
->desc
.rt
[i
].src
, b
->desc
.rt
[i
].dst
, rt_format
);
792 gl_blend_from_d3d(&src_blend_alpha
, &dst_blend_alpha
,
793 b
->desc
.rt
[i
].src_alpha
, b
->desc
.rt
[i
].dst_alpha
, rt_format
);
795 GL_EXTCALL(glBlendFuncSeparatei(i
, src_blend
, dst_blend
, src_blend_alpha
, dst_blend_alpha
));
796 checkGLcall("glBlendFuncSeparatei");
798 GL_EXTCALL(glBlendEquationSeparatei(i
, gl_blend_op(gl_info
, b
->desc
.rt
[i
].op
),
799 gl_blend_op(gl_info
, b
->desc
.rt
[i
].op_alpha
)));
800 checkGLcall("glBlendEquationSeparatei");
803 /* Colorkey fixup for stage 0 alphaop depends on blend state, so it may need
805 if (state
->render_states
[WINED3D_RS_COLORKEYENABLE
])
806 context_apply_state(context
, state
, STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
));
809 void state_alpha_test(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
811 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
814 BOOL enable_ckey
= FALSE
;
816 TRACE("context %p, state %p, state_id %#lx.\n", context
, state
, state_id
);
818 /* Find out if the texture on the first stage has a ckey set. The alpha
819 * state func reads the texture settings, even though alpha and texture
820 * are not grouped together. This is to avoid making a huge alpha +
821 * texture + texture stage + ckey block due to the hardly used
822 * WINED3D_RS_COLORKEYENABLE state(which is d3d <= 3 only). The texture
823 * function will call alpha in case it finds some texture + colorkeyenable
824 * combination which needs extra care. */
825 if (state
->textures
[0] && (state
->textures
[0]->async
.color_key_flags
& WINED3D_CKEY_SRC_BLT
))
828 if (enable_ckey
|| context
->last_was_ckey
)
829 context_apply_state(context
, state
, STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
));
830 context
->last_was_ckey
= enable_ckey
;
832 if (state
->render_states
[WINED3D_RS_ALPHATESTENABLE
]
833 || (state
->render_states
[WINED3D_RS_COLORKEYENABLE
] && enable_ckey
))
835 gl_info
->gl_ops
.gl
.p_glEnable(GL_ALPHA_TEST
);
836 checkGLcall("glEnable GL_ALPHA_TEST");
840 gl_info
->gl_ops
.gl
.p_glDisable(GL_ALPHA_TEST
);
841 checkGLcall("glDisable GL_ALPHA_TEST");
842 /* Alpha test is disabled, don't bother setting the params - it will happen on the next
848 if (state
->render_states
[WINED3D_RS_COLORKEYENABLE
] && enable_ckey
)
850 glParm
= GL_NOTEQUAL
;
855 ref
= wined3d_alpha_ref(state
);
856 glParm
= wined3d_gl_compare_func(state
->render_states
[WINED3D_RS_ALPHAFUNC
]);
860 gl_info
->gl_ops
.gl
.p_glAlphaFunc(glParm
, ref
);
861 checkGLcall("glAlphaFunc");
865 void state_clipping(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
867 struct wined3d_context_gl
*context_gl
= wined3d_context_gl(context
);
868 uint32_t enable_mask
;
870 if (use_vs(state
) && !context
->d3d_info
->vs_clipping
)
874 /* The OpenGL spec says that clipping planes are disabled when using
875 * shaders. Direct3D planes aren't, so that is an issue. The MacOS ATI
876 * driver keeps clipping planes activated with shaders in some
877 * conditions I got sick of tracking down. The shader state handler
878 * disables all clip planes because of that - don't do anything here
879 * and keep them disabled. */
880 if (state
->render_states
[WINED3D_RS_CLIPPLANEENABLE
] && !warned
++)
881 FIXME("Clipping not supported with vertex shaders.\n");
885 /* glEnable(GL_CLIP_PLANEx) doesn't apply to (ARB backend) vertex shaders.
886 * The enabled / disabled planes are hardcoded into the shader. Update the
887 * shader to update the enabled clipplanes. In case of fixed function, we
888 * need to update the clipping field from ffp_vertex_settings. */
889 context
->shader_update_mask
|= 1u << WINED3D_SHADER_TYPE_VERTEX
;
891 /* If enabling / disabling all
892 * TODO: Is this correct? Doesn't D3DRS_CLIPPING disable clipping on the viewport frustrum?
894 enable_mask
= state
->render_states
[WINED3D_RS_CLIPPING
] ?
895 state
->render_states
[WINED3D_RS_CLIPPLANEENABLE
] : 0;
896 wined3d_context_gl_enable_clip_distances(context_gl
, enable_mask
);
899 static void state_specularenable(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
901 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
903 /* Originally this used glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR)
904 * and (GL_LIGHT_MODEL_COLOR_CONTROL,GL_SINGLE_COLOR) to swap between enabled/disabled
905 * specular color. This is wrong:
906 * Separate specular color means the specular colour is maintained separately, whereas
907 * single color means it is merged in. However in both cases they are being used to
909 * To disable specular color, set it explicitly to black and turn off GL_COLOR_SUM_EXT
910 * NOTE: If not supported don't give FIXMEs the impact is really minimal and very few people are
914 * If register combiners are enabled, enabling / disabling GL_COLOR_SUM has no effect.
915 * Instead, we need to setup the FinalCombiner properly.
917 * The default setup for the FinalCombiner is:
919 * <variable> <input> <mapping> <usage>
920 * GL_VARIABLE_A_NV GL_FOG, GL_UNSIGNED_IDENTITY_NV GL_ALPHA
921 * GL_VARIABLE_B_NV GL_SPARE0_PLUS_SECONDARY_COLOR_NV GL_UNSIGNED_IDENTITY_NV GL_RGB
922 * GL_VARIABLE_C_NV GL_FOG GL_UNSIGNED_IDENTITY_NV GL_RGB
923 * GL_VARIABLE_D_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
924 * GL_VARIABLE_E_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
925 * GL_VARIABLE_F_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
926 * GL_VARIABLE_G_NV GL_SPARE0_NV GL_UNSIGNED_IDENTITY_NV GL_ALPHA
928 * That's pretty much fine as it is, except for variable B, which needs to take
929 * either GL_SPARE0_PLUS_SECONDARY_COLOR_NV or GL_SPARE0_NV, depending on
930 * whether WINED3D_RS_SPECULARENABLE is enabled or not.
933 TRACE("Setting specular enable state and materials\n");
934 if (state
->render_states
[WINED3D_RS_SPECULARENABLE
])
936 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, (float *)&state
->material
.specular
);
937 checkGLcall("glMaterialfv");
939 if (state
->material
.power
> gl_info
->limits
.shininess
)
941 /* glMaterialf man page says that the material says that GL_SHININESS must be between 0.0
942 * and 128.0, although in d3d neither -1 nor 129 produce an error. GL_NV_max_light_exponent
943 * allows bigger values. If the extension is supported, gl_info->limits.shininess contains the
944 * value reported by the extension, otherwise 128. For values > gl_info->limits.shininess clamp
945 * them, it should be safe to do so without major visual distortions.
947 WARN("Material power = %.8e, limit %.8e\n", state
->material
.power
, gl_info
->limits
.shininess
);
948 gl_info
->gl_ops
.gl
.p_glMaterialf(GL_FRONT_AND_BACK
, GL_SHININESS
, gl_info
->limits
.shininess
);
952 gl_info
->gl_ops
.gl
.p_glMaterialf(GL_FRONT_AND_BACK
, GL_SHININESS
, state
->material
.power
);
954 checkGLcall("glMaterialf(GL_SHININESS)");
956 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
957 gl_info
->gl_ops
.gl
.p_glEnable(GL_COLOR_SUM_EXT
);
959 TRACE("Specular colors cannot be enabled in this version of opengl\n");
960 checkGLcall("glEnable(GL_COLOR_SUM)");
962 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
964 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV
, GL_SPARE0_PLUS_SECONDARY_COLOR_NV
, GL_UNSIGNED_IDENTITY_NV
, GL_RGB
));
965 checkGLcall("glFinalCombinerInputNV()");
968 static const GLfloat black
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
970 /* for the case of enabled lighting: */
971 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, &black
[0]);
972 checkGLcall("glMaterialfv");
974 /* for the case of disabled lighting: */
975 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
976 gl_info
->gl_ops
.gl
.p_glDisable(GL_COLOR_SUM_EXT
);
978 TRACE("Specular colors cannot be disabled in this version of opengl\n");
979 checkGLcall("glDisable(GL_COLOR_SUM)");
981 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
983 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV
, GL_SPARE0_NV
, GL_UNSIGNED_IDENTITY_NV
, GL_RGB
));
984 checkGLcall("glFinalCombinerInputNV()");
988 TRACE("diffuse %s\n", debug_color(&state
->material
.diffuse
));
989 TRACE("ambient %s\n", debug_color(&state
->material
.ambient
));
990 TRACE("specular %s\n", debug_color(&state
->material
.specular
));
991 TRACE("emissive %s\n", debug_color(&state
->material
.emissive
));
993 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float *)&state
->material
.ambient
);
994 checkGLcall("glMaterialfv(GL_AMBIENT)");
995 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float *)&state
->material
.diffuse
);
996 checkGLcall("glMaterialfv(GL_DIFFUSE)");
997 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_EMISSION
, (float *)&state
->material
.emissive
);
998 checkGLcall("glMaterialfv(GL_EMISSION)");
1001 static void state_texfactor(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1003 struct wined3d_context_gl
*context_gl
= wined3d_context_gl(context
);
1004 const struct wined3d_gl_info
*gl_info
= context_gl
->gl_info
;
1005 struct wined3d_color color
;
1008 /* Note the texture color applies to all textures whereas
1009 * GL_TEXTURE_ENV_COLOR applies to active only. */
1010 wined3d_color_from_d3dcolor(&color
, state
->render_states
[WINED3D_RS_TEXTUREFACTOR
]);
1012 /* And now the default texture color as well */
1013 for (i
= 0; i
< context
->d3d_info
->limits
.ffp_blend_stages
; ++i
)
1015 /* Note the WINED3D_RS value applies to all textures, but GL has one
1016 * per texture, so apply it now ready to be used! */
1017 wined3d_context_gl_active_texture(context_gl
, gl_info
, i
);
1019 gl_info
->gl_ops
.gl
.p_glTexEnvfv(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_COLOR
, &color
.r
);
1020 checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);");
1024 static void renderstate_stencil_twosided(struct wined3d_context
*context
, GLint face
,
1025 GLint func
, GLint ref
, GLuint mask
, GLint stencilFail
, GLint depthFail
, GLint stencilPass
)
1027 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1029 gl_info
->gl_ops
.gl
.p_glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT
);
1030 checkGLcall("glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT)");
1031 GL_EXTCALL(glActiveStencilFaceEXT(face
));
1032 checkGLcall("glActiveStencilFaceEXT(...)");
1033 gl_info
->gl_ops
.gl
.p_glStencilFunc(func
, ref
, mask
);
1034 checkGLcall("glStencilFunc(...)");
1035 gl_info
->gl_ops
.gl
.p_glStencilOp(stencilFail
, depthFail
, stencilPass
);
1036 checkGLcall("glStencilOp(...)");
1039 static GLenum
gl_stencil_op(enum wined3d_stencil_op op
)
1043 case WINED3D_STENCIL_OP_KEEP
:
1045 case WINED3D_STENCIL_OP_ZERO
:
1047 case WINED3D_STENCIL_OP_REPLACE
:
1049 case WINED3D_STENCIL_OP_INCR_SAT
:
1051 case WINED3D_STENCIL_OP_DECR_SAT
:
1053 case WINED3D_STENCIL_OP_INVERT
:
1055 case WINED3D_STENCIL_OP_INCR
:
1056 return GL_INCR_WRAP
;
1057 case WINED3D_STENCIL_OP_DECR
:
1058 return GL_DECR_WRAP
;
1061 WARN("Unrecognized stencil op %#x.\n", op
);
1063 FIXME("Unrecognized stencil op %#x.\n", op
);
1068 static void state_stencil(struct wined3d_context
*context
, const struct wined3d_state
*state
)
1070 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1071 const struct wined3d_depth_stencil_state
*d
= state
->depth_stencil_state
;
1077 GLint stencilFail_back
;
1079 GLint stencilPass_back
;
1081 GLint depthFail_back
;
1083 /* No stencil test without a stencil buffer. */
1084 if (!state
->fb
.depth_stencil
|| !d
|| !d
->desc
.stencil
)
1086 gl_info
->gl_ops
.gl
.p_glDisable(GL_STENCIL_TEST
);
1087 checkGLcall("glDisable GL_STENCIL_TEST");
1091 if (!(func
= wined3d_gl_compare_func(d
->desc
.front
.func
)))
1093 if (!(func_back
= wined3d_gl_compare_func(d
->desc
.back
.func
)))
1094 func_back
= GL_ALWAYS
;
1095 mask
= d
->desc
.stencil_read_mask
;
1096 ref
= state
->stencil_ref
& wined3d_mask_from_size(state
->fb
.depth_stencil
->format
->stencil_size
);
1097 stencilFail
= gl_stencil_op(d
->desc
.front
.fail_op
);
1098 depthFail
= gl_stencil_op(d
->desc
.front
.depth_fail_op
);
1099 stencilPass
= gl_stencil_op(d
->desc
.front
.pass_op
);
1100 stencilFail_back
= gl_stencil_op(d
->desc
.back
.fail_op
);
1101 depthFail_back
= gl_stencil_op(d
->desc
.back
.depth_fail_op
);
1102 stencilPass_back
= gl_stencil_op(d
->desc
.back
.pass_op
);
1104 TRACE("(ref %x, mask %x, "
1105 "GL_FRONT: func: %x, fail %x, zfail %x, zpass %x "
1106 "GL_BACK: func: %x, fail %x, zfail %x, zpass %x)\n",
1108 func
, stencilFail
, depthFail
, stencilPass
,
1109 func_back
, stencilFail_back
, depthFail_back
, stencilPass_back
);
1111 if (memcmp(&d
->desc
.front
, &d
->desc
.back
, sizeof(d
->desc
.front
)))
1113 gl_info
->gl_ops
.gl
.p_glEnable(GL_STENCIL_TEST
);
1114 checkGLcall("glEnable GL_STENCIL_TEST");
1116 if (gl_info
->supported
[WINED3D_GL_VERSION_2_0
])
1118 GL_EXTCALL(glStencilFuncSeparate(GL_FRONT
, func
, ref
, mask
));
1119 GL_EXTCALL(glStencilOpSeparate(GL_FRONT
, stencilFail
, depthFail
, stencilPass
));
1120 GL_EXTCALL(glStencilFuncSeparate(GL_BACK
, func_back
, ref
, mask
));
1121 GL_EXTCALL(glStencilOpSeparate(GL_BACK
, stencilFail_back
, depthFail_back
, stencilPass_back
));
1122 checkGLcall("setting two sided stencil state");
1124 else if (gl_info
->supported
[EXT_STENCIL_TWO_SIDE
])
1126 /* Apply back first, then front. This function calls glActiveStencilFaceEXT,
1127 * which has an effect on the code below too. If we apply the front face
1128 * afterwards, we are sure that the active stencil face is set to front,
1129 * and other stencil functions which do not use two sided stencil do not have
1132 renderstate_stencil_twosided(context
, GL_BACK
,
1133 func_back
, ref
, mask
, stencilFail_back
, depthFail_back
, stencilPass_back
);
1134 renderstate_stencil_twosided(context
, GL_FRONT
,
1135 func
, ref
, mask
, stencilFail
, depthFail
, stencilPass
);
1137 else if (gl_info
->supported
[ATI_SEPARATE_STENCIL
])
1139 GL_EXTCALL(glStencilFuncSeparateATI(func
, func_back
, ref
, mask
));
1140 checkGLcall("glStencilFuncSeparateATI(...)");
1141 GL_EXTCALL(glStencilOpSeparateATI(GL_FRONT
, stencilFail
, depthFail
, stencilPass
));
1142 checkGLcall("glStencilOpSeparateATI(GL_FRONT, ...)");
1143 GL_EXTCALL(glStencilOpSeparateATI(GL_BACK
, stencilFail_back
, depthFail_back
, stencilPass_back
));
1144 checkGLcall("glStencilOpSeparateATI(GL_BACK, ...)");
1148 FIXME("Separate (two sided) stencil not supported on this version of OpenGL. Caps weren't honored?\n");
1153 if (gl_info
->supported
[EXT_STENCIL_TWO_SIDE
])
1155 gl_info
->gl_ops
.gl
.p_glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT
);
1156 checkGLcall("glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT)");
1159 /* This code disables the ATI extension as well, since the standard stencil functions are equal
1160 * to calling the ATI functions with GL_FRONT_AND_BACK as face parameter
1162 gl_info
->gl_ops
.gl
.p_glEnable(GL_STENCIL_TEST
);
1163 checkGLcall("glEnable GL_STENCIL_TEST");
1164 gl_info
->gl_ops
.gl
.p_glStencilFunc(func
, ref
, mask
);
1165 checkGLcall("glStencilFunc(...)");
1166 gl_info
->gl_ops
.gl
.p_glStencilOp(stencilFail
, depthFail
, stencilPass
);
1167 checkGLcall("glStencilOp(...)");
1171 static void depth(struct wined3d_context
*context
, const struct wined3d_state
*state
)
1173 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1174 const struct wined3d_depth_stencil_state
*d
= state
->depth_stencil_state
;
1175 BOOL enable_depth
= d
? d
->desc
.depth
: TRUE
;
1176 GLenum depth_func
= GL_LESS
;
1178 if (!state
->fb
.depth_stencil
)
1180 TRACE("No depth/stencil buffer is attached; disabling depth test.\n");
1181 enable_depth
= FALSE
;
1186 gl_info
->gl_ops
.gl
.p_glEnable(GL_DEPTH_TEST
);
1187 checkGLcall("glEnable GL_DEPTH_TEST");
1191 gl_info
->gl_ops
.gl
.p_glDisable(GL_DEPTH_TEST
);
1192 checkGLcall("glDisable GL_DEPTH_TEST");
1195 if (!d
|| d
->desc
.depth_write
)
1197 gl_info
->gl_ops
.gl
.p_glDepthMask(GL_TRUE
);
1198 checkGLcall("glDepthMask(GL_TRUE)");
1202 gl_info
->gl_ops
.gl
.p_glDepthMask(GL_FALSE
);
1203 checkGLcall("glDepthMask(GL_FALSE)");
1207 depth_func
= wined3d_gl_compare_func(d
->desc
.depth_func
);
1210 gl_info
->gl_ops
.gl
.p_glDepthFunc(depth_func
);
1211 checkGLcall("glDepthFunc");
1214 if (gl_info
->supported
[EXT_DEPTH_BOUNDS_TEST
])
1216 /* If min is larger than max, an INVALID_VALUE error is generated.
1217 * In d3d9, the test is not performed in this case. */
1218 if (state
->depth_bounds_enable
&& state
->depth_bounds_min
<= state
->depth_bounds_max
)
1220 gl_info
->gl_ops
.gl
.p_glEnable(GL_DEPTH_BOUNDS_TEST_EXT
);
1221 checkGLcall("glEnable(GL_DEPTH_BOUNDS_TEST_EXT)");
1222 GL_EXTCALL(glDepthBoundsEXT(state
->depth_bounds_min
, state
->depth_bounds_max
));
1223 checkGLcall("glDepthBoundsEXT");
1227 gl_info
->gl_ops
.gl
.p_glDisable(GL_DEPTH_BOUNDS_TEST_EXT
);
1228 checkGLcall("glDisable(GL_DEPTH_BOUNDS_TEST_EXT)");
1232 if (context
->last_was_rhw
&& !isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
)))
1233 context_apply_state(context
, state
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
));
1236 static void depth_stencil(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1238 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1239 const struct wined3d_depth_stencil_state
*d
= state
->depth_stencil_state
;
1240 GLuint stencil_write_mask
= 0;
1242 depth(context
, state
);
1243 state_stencil(context
, state
);
1245 if (state
->fb
.depth_stencil
)
1246 stencil_write_mask
= d
? d
->desc
.stencil_write_mask
: ~0u;
1248 gl_info
->gl_ops
.gl
.p_glStencilMask(stencil_write_mask
);
1249 checkGLcall("glStencilMask");
1252 static void depth_stencil_2s(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1254 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1255 const struct wined3d_depth_stencil_state
*d
= state
->depth_stencil_state
;
1256 GLuint stencil_write_mask
= 0;
1258 depth(context
, state
);
1259 state_stencil(context
, state
);
1261 if (state
->fb
.depth_stencil
)
1262 stencil_write_mask
= d
? d
->desc
.stencil_write_mask
: ~0u;
1264 GL_EXTCALL(glActiveStencilFaceEXT(GL_BACK
));
1265 checkGLcall("glActiveStencilFaceEXT(GL_BACK)");
1266 gl_info
->gl_ops
.gl
.p_glStencilMask(stencil_write_mask
);
1267 checkGLcall("glStencilMask");
1268 GL_EXTCALL(glActiveStencilFaceEXT(GL_FRONT
));
1269 checkGLcall("glActiveStencilFaceEXT(GL_FRONT)");
1270 gl_info
->gl_ops
.gl
.p_glStencilMask(stencil_write_mask
);
1273 static void state_fog_vertexpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1275 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1277 TRACE("context %p, state %p, state_id %#lx.\n", context
, state
, state_id
);
1279 if (!state
->render_states
[WINED3D_RS_FOGENABLE
])
1282 /* Table fog on: Never use fog coords, and use per-fragment fog */
1283 if (state
->render_states
[WINED3D_RS_FOGTABLEMODE
] != WINED3D_FOG_NONE
)
1285 gl_info
->gl_ops
.gl
.p_glHint(GL_FOG_HINT
, GL_NICEST
);
1286 if (context
->fog_coord
)
1288 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FRAGMENT_DEPTH_EXT
);
1289 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT)");
1290 context
->fog_coord
= FALSE
;
1293 /* Range fog is only used with per-vertex fog in d3d */
1294 if (gl_info
->supported
[NV_FOG_DISTANCE
])
1296 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_DISTANCE_MODE_NV
, GL_EYE_PLANE_ABSOLUTE_NV
);
1297 checkGLcall("glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_PLANE_ABSOLUTE_NV)");
1302 /* Otherwise use per-vertex fog in any case */
1303 gl_info
->gl_ops
.gl
.p_glHint(GL_FOG_HINT
, GL_FASTEST
);
1305 if (state
->render_states
[WINED3D_RS_FOGVERTEXMODE
] == WINED3D_FOG_NONE
|| context
->last_was_rhw
)
1307 /* No fog at all, or transformed vertices: Use fog coord */
1308 if (!context
->fog_coord
)
1310 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FOG_COORDINATE_EXT
);
1311 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT)");
1312 context
->fog_coord
= TRUE
;
1317 /* Otherwise, use the fragment depth */
1318 if (context
->fog_coord
)
1320 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FRAGMENT_DEPTH_EXT
);
1321 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT)");
1322 context
->fog_coord
= FALSE
;
1325 if (state
->render_states
[WINED3D_RS_RANGEFOGENABLE
])
1327 if (gl_info
->supported
[NV_FOG_DISTANCE
])
1329 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_DISTANCE_MODE_NV
, GL_EYE_RADIAL_NV
);
1330 checkGLcall("glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_RADIAL_NV)");
1334 WARN("Range fog enabled, but not supported by this GL implementation.\n");
1337 else if (gl_info
->supported
[NV_FOG_DISTANCE
])
1339 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_DISTANCE_MODE_NV
, GL_EYE_PLANE_ABSOLUTE_NV
);
1340 checkGLcall("glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_PLANE_ABSOLUTE_NV)");
1345 void state_fogstartend(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1347 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1348 float fogstart
, fogend
;
1350 get_fog_start_end(context
, state
, &fogstart
, &fogend
);
1352 gl_info
->gl_ops
.gl
.p_glFogf(GL_FOG_START
, fogstart
);
1353 checkGLcall("glFogf(GL_FOG_START, fogstart)");
1354 TRACE("Fog Start == %f\n", fogstart
);
1356 gl_info
->gl_ops
.gl
.p_glFogf(GL_FOG_END
, fogend
);
1357 checkGLcall("glFogf(GL_FOG_END, fogend)");
1358 TRACE("Fog End == %f\n", fogend
);
1361 void state_fog_fragpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1363 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1364 enum fogsource new_source
;
1365 DWORD fogstart
= state
->render_states
[WINED3D_RS_FOGSTART
];
1366 DWORD fogend
= state
->render_states
[WINED3D_RS_FOGEND
];
1368 TRACE("context %p, state %p, state_id %#lx.\n", context
, state
, state_id
);
1370 if (!state
->render_states
[WINED3D_RS_FOGENABLE
])
1372 /* No fog? Disable it, and we're done :-) */
1373 gl_info
->p_glDisableWINE(GL_FOG
);
1374 checkGLcall("glDisable GL_FOG");
1380 * With fixed function vertex processing, Direct3D knows 2 different fog input sources.
1381 * It can use the Z value of the vertex, or the alpha component of the specular color.
1382 * This depends on the fog vertex, fog table and the vertex declaration. If the Z value
1383 * is used, fogstart, fogend and the equation type are used, otherwise linear fog with
1384 * start = 255, end = 0 is used. Obviously the msdn is not very clear on that.
1386 * FOGTABLEMODE != NONE:
1387 * The Z value is used, with the equation specified, no matter what vertex type.
1389 * FOGTABLEMODE == NONE, FOGVERTEXMODE != NONE, untransformed:
1390 * Per vertex fog is calculated using the specified fog equation and the parameters
1392 * FOGTABLEMODE == NONE, FOGVERTEXMODE != NONE, transformed, OR
1393 * FOGTABLEMODE == NONE, FOGVERTEXMODE == NONE, untransformed:
1394 * Linear fog with start = 255.0, end = 0.0, input comes from the specular color
1397 * Rules for vertex fog with shaders:
1399 * When mixing fixed function functionality with the programmable pipeline, D3D expects
1400 * the fog computation to happen during transformation while openGL expects it to happen
1401 * during rasterization. Also, prior to pixel shader 3.0 D3D handles fog blending after
1402 * the pixel shader while openGL always expects the pixel shader to handle the blending.
1403 * To solve this problem, WineD3D does:
1404 * 1) implement a linear fog equation and fog blending at the end of every pre 3.0 pixel
1406 * and 2) disables the fog computation (in either the fixed function or programmable
1407 * rasterizer) if using a vertex program.
1409 * D3D shaders can provide an explicit fog coordinate. This fog coordinate is used with
1410 * D3DRS_FOGTABLEMODE==D3DFOG_NONE. The FOGVERTEXMODE is ignored, d3d always uses linear
1411 * fog with start=1.0 and end=0.0 in this case. This is similar to fog coordinates in
1412 * the specular color, a vertex shader counts as pretransformed geometry in this case.
1413 * There are some GL differences between specular fog coords and vertex shaders though.
1415 * With table fog the vertex shader fog coordinate is ignored.
1417 * If a fogtablemode and a fogvertexmode are specified, table fog is applied (with or
1421 /* DX 7 sdk: "If both render states(vertex and table fog) are set to valid modes,
1422 * the system will apply only pixel(=table) fog effects."
1424 if (state
->render_states
[WINED3D_RS_FOGTABLEMODE
] == WINED3D_FOG_NONE
)
1428 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_LINEAR
);
1429 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1430 new_source
= FOGSOURCE_VS
;
1434 switch (state
->render_states
[WINED3D_RS_FOGVERTEXMODE
])
1436 /* If processed vertices are used, fall through to the NONE case */
1437 case WINED3D_FOG_EXP
:
1438 if (!context
->last_was_rhw
)
1440 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_EXP
);
1441 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP)");
1442 new_source
= FOGSOURCE_FFP
;
1447 case WINED3D_FOG_EXP2
:
1448 if (!context
->last_was_rhw
)
1450 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_EXP2
);
1451 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2)");
1452 new_source
= FOGSOURCE_FFP
;
1457 case WINED3D_FOG_LINEAR
:
1458 if (!context
->last_was_rhw
)
1460 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_LINEAR
);
1461 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1462 new_source
= FOGSOURCE_FFP
;
1467 case WINED3D_FOG_NONE
:
1468 /* Both are none? According to msdn the alpha channel of
1469 * the specular colour contains a fog factor. Set it in
1470 * draw_primitive_immediate_mode(). Same happens with
1471 * vertex fog on transformed vertices. */
1472 new_source
= FOGSOURCE_COORD
;
1473 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_LINEAR
);
1474 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1478 FIXME("Unexpected WINED3D_RS_FOGVERTEXMODE %#x.\n",
1479 state
->render_states
[WINED3D_RS_FOGVERTEXMODE
]);
1480 new_source
= FOGSOURCE_FFP
; /* Make the compiler happy */
1484 new_source
= FOGSOURCE_FFP
;
1486 switch (state
->render_states
[WINED3D_RS_FOGTABLEMODE
])
1488 case WINED3D_FOG_EXP
:
1489 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_EXP
);
1490 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP)");
1493 case WINED3D_FOG_EXP2
:
1494 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_EXP2
);
1495 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2)");
1498 case WINED3D_FOG_LINEAR
:
1499 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_LINEAR
);
1500 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1503 case WINED3D_FOG_NONE
: /* Won't happen */
1505 FIXME("Unexpected WINED3D_RS_FOGTABLEMODE %#x.\n",
1506 state
->render_states
[WINED3D_RS_FOGTABLEMODE
]);
1510 gl_info
->p_glEnableWINE(GL_FOG
);
1511 checkGLcall("glEnable GL_FOG");
1512 if (new_source
!= context
->fog_source
|| fogstart
== fogend
)
1514 context
->fog_source
= new_source
;
1515 state_fogstartend(context
, state
, STATE_RENDER(WINED3D_RS_FOGSTART
));
1519 void state_fogcolor(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1521 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1522 struct wined3d_color color
;
1524 wined3d_color_from_d3dcolor(&color
, state
->render_states
[WINED3D_RS_FOGCOLOR
]);
1525 gl_info
->gl_ops
.gl
.p_glFogfv(GL_FOG_COLOR
, &color
.r
);
1526 checkGLcall("glFog GL_FOG_COLOR");
1529 void state_fogdensity(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1531 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1537 tmpvalue
.d
= state
->render_states
[WINED3D_RS_FOGDENSITY
];
1538 gl_info
->gl_ops
.gl
.p_glFogfv(GL_FOG_DENSITY
, &tmpvalue
.f
);
1539 checkGLcall("glFogf(GL_FOG_DENSITY, (float) Value)");
1542 static void state_colormat(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1544 struct wined3d_context_gl
*context_gl
= wined3d_context_gl(context
);
1545 const struct wined3d_gl_info
*gl_info
= context_gl
->gl_info
;
1548 context_gl
->untracked_material_count
= 0;
1549 if ((context_gl
->c
.stream_info
.use_map
& (1u << WINED3D_FFP_DIFFUSE
))
1550 && state
->render_states
[WINED3D_RS_COLORVERTEX
])
1552 TRACE("diff %d, amb %d, emis %d, spec %d\n",
1553 state
->render_states
[WINED3D_RS_DIFFUSEMATERIALSOURCE
],
1554 state
->render_states
[WINED3D_RS_AMBIENTMATERIALSOURCE
],
1555 state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
],
1556 state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
]);
1558 if (state
->render_states
[WINED3D_RS_DIFFUSEMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1560 if (state
->render_states
[WINED3D_RS_AMBIENTMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1561 Parm
= GL_AMBIENT_AND_DIFFUSE
;
1564 if (state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1565 context_gl
->untracked_materials
[context_gl
->untracked_material_count
++] = GL_EMISSION
;
1566 if (state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1567 context_gl
->untracked_materials
[context_gl
->untracked_material_count
++] = GL_SPECULAR
;
1569 else if (state
->render_states
[WINED3D_RS_AMBIENTMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1572 if (state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1573 context_gl
->untracked_materials
[context_gl
->untracked_material_count
++] = GL_EMISSION
;
1574 if (state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1575 context_gl
->untracked_materials
[context_gl
->untracked_material_count
++] = GL_SPECULAR
;
1577 else if (state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1580 if (state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1581 context_gl
->untracked_materials
[context_gl
->untracked_material_count
++] = GL_SPECULAR
;
1583 else if (state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1589 /* Nothing changed, return. */
1590 if (Parm
== context_gl
->tracking_parm
)
1595 gl_info
->gl_ops
.gl
.p_glDisable(GL_COLOR_MATERIAL
);
1596 checkGLcall("glDisable GL_COLOR_MATERIAL");
1600 gl_info
->gl_ops
.gl
.p_glColorMaterial(GL_FRONT_AND_BACK
, Parm
);
1601 checkGLcall("glColorMaterial(GL_FRONT_AND_BACK, Parm)");
1602 gl_info
->gl_ops
.gl
.p_glEnable(GL_COLOR_MATERIAL
);
1603 checkGLcall("glEnable(GL_COLOR_MATERIAL)");
1606 /* Apparently calls to glMaterialfv are ignored for properties we're
1607 * tracking with glColorMaterial, so apply those here. */
1608 switch (context_gl
->tracking_parm
)
1610 case GL_AMBIENT_AND_DIFFUSE
:
1611 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float *)&state
->material
.ambient
);
1612 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float *)&state
->material
.diffuse
);
1613 checkGLcall("glMaterialfv");
1617 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float *)&state
->material
.diffuse
);
1618 checkGLcall("glMaterialfv");
1622 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float *)&state
->material
.ambient
);
1623 checkGLcall("glMaterialfv");
1627 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_EMISSION
, (float *)&state
->material
.emissive
);
1628 checkGLcall("glMaterialfv");
1632 /* Only change material color if specular is enabled, otherwise it is set to black */
1633 if (state
->render_states
[WINED3D_RS_SPECULARENABLE
])
1635 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, (float *)&state
->material
.specular
);
1636 checkGLcall("glMaterialfv");
1640 static const GLfloat black
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
1641 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, &black
[0]);
1642 checkGLcall("glMaterialfv");
1647 context_gl
->tracking_parm
= Parm
;
1650 static void state_linepattern(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1652 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1656 struct wined3d_line_pattern lp
;
1658 tmppattern
.d
= state
->render_states
[WINED3D_RS_LINEPATTERN
];
1660 TRACE("Line pattern: repeat %d bits %x.\n", tmppattern
.lp
.repeat_factor
, tmppattern
.lp
.line_pattern
);
1662 if (tmppattern
.lp
.repeat_factor
)
1664 gl_info
->gl_ops
.gl
.p_glLineStipple(tmppattern
.lp
.repeat_factor
, tmppattern
.lp
.line_pattern
);
1665 checkGLcall("glLineStipple(repeat, linepattern)");
1666 gl_info
->gl_ops
.gl
.p_glEnable(GL_LINE_STIPPLE
);
1667 checkGLcall("glEnable(GL_LINE_STIPPLE);");
1671 gl_info
->gl_ops
.gl
.p_glDisable(GL_LINE_STIPPLE
);
1672 checkGLcall("glDisable(GL_LINE_STIPPLE);");
1676 static void state_linepattern_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1678 static unsigned int once
;
1681 FIXME("Setting line patterns is not supported in OpenGL core contexts.\n");
1684 static void state_normalize(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1686 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1688 /* Without vertex normals, we set the current normal to 0/0/0 to remove the diffuse factor
1689 * from the opengl lighting equation, as d3d does. Normalization of 0/0/0 can lead to a division
1690 * by zero and is not properly defined in opengl, so avoid it
1692 if (state
->render_states
[WINED3D_RS_NORMALIZENORMALS
]
1693 && (context
->stream_info
.use_map
& (1u << WINED3D_FFP_NORMAL
)))
1695 gl_info
->gl_ops
.gl
.p_glEnable(GL_NORMALIZE
);
1696 checkGLcall("glEnable(GL_NORMALIZE);");
1700 gl_info
->gl_ops
.gl
.p_glDisable(GL_NORMALIZE
);
1701 checkGLcall("glDisable(GL_NORMALIZE);");
1705 static void state_psizemin_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1709 get_pointsize_minmax(context
, state
, &min
, &max
);
1712 FIXME("WINED3D_RS_POINTSIZE_MIN value %.8e not supported on this OpenGL implementation.\n", min
);
1714 FIXME("WINED3D_RS_POINTSIZE_MAX value %.8e not supported on this OpenGL implementation.\n", max
);
1717 static void state_psizemin_ext(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1719 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1722 get_pointsize_minmax(context
, state
, &min
, &max
);
1724 GL_EXTCALL(glPointParameterfEXT
)(GL_POINT_SIZE_MIN_EXT
, min
);
1725 checkGLcall("glPointParameterfEXT(...)");
1726 GL_EXTCALL(glPointParameterfEXT
)(GL_POINT_SIZE_MAX_EXT
, max
);
1727 checkGLcall("glPointParameterfEXT(...)");
1730 static void state_psizemin_arb(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1732 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1735 get_pointsize_minmax(context
, state
, &min
, &max
);
1737 GL_EXTCALL(glPointParameterfARB
)(GL_POINT_SIZE_MIN_ARB
, min
);
1738 checkGLcall("glPointParameterfARB(...)");
1739 GL_EXTCALL(glPointParameterfARB
)(GL_POINT_SIZE_MAX_ARB
, max
);
1740 checkGLcall("glPointParameterfARB(...)");
1743 static void state_pscale(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1745 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1749 get_pointsize(context
, state
, &pointsize
, att
);
1751 if (gl_info
->supported
[ARB_POINT_PARAMETERS
])
1753 GL_EXTCALL(glPointParameterfvARB
)(GL_POINT_DISTANCE_ATTENUATION_ARB
, att
);
1754 checkGLcall("glPointParameterfvARB(GL_DISTANCE_ATTENUATION_ARB, ...)");
1756 else if (gl_info
->supported
[EXT_POINT_PARAMETERS
])
1758 GL_EXTCALL(glPointParameterfvEXT
)(GL_DISTANCE_ATTENUATION_EXT
, att
);
1759 checkGLcall("glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, ...)");
1761 else if (state
->render_states
[WINED3D_RS_POINTSCALEENABLE
])
1763 WARN("POINT_PARAMETERS not supported in this version of opengl\n");
1766 gl_info
->gl_ops
.gl
.p_glPointSize(max(pointsize
, FLT_MIN
));
1767 checkGLcall("glPointSize(...);");
1770 static void state_localviewer(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1772 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1774 if (state
->render_states
[WINED3D_RS_LOCALVIEWER
])
1776 gl_info
->gl_ops
.gl
.p_glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER
, 1);
1777 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1)");
1781 gl_info
->gl_ops
.gl
.p_glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER
, 0);
1782 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 0)");
1786 void state_pointsprite_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1790 /* TODO: NV_POINT_SPRITE */
1791 if (!warned
&& state
->render_states
[WINED3D_RS_POINTSPRITEENABLE
])
1793 /* A FIXME, not a WARN because point sprites should be software emulated if not supported by HW */
1794 FIXME("Point sprites not supported\n");
1799 void state_pointsprite(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1801 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1803 if (state
->render_states
[WINED3D_RS_POINTSPRITEENABLE
])
1805 gl_info
->gl_ops
.gl
.p_glEnable(GL_POINT_SPRITE_ARB
);
1806 checkGLcall("glEnable(GL_POINT_SPRITE_ARB)");
1810 gl_info
->gl_ops
.gl
.p_glDisable(GL_POINT_SPRITE_ARB
);
1811 checkGLcall("glDisable(GL_POINT_SPRITE_ARB)");
1815 static void state_msaa_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1817 if (state
->render_states
[WINED3D_RS_MULTISAMPLEANTIALIAS
])
1818 WARN("Multisample antialiasing not supported by GL.\n");
1821 static void state_msaa(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1823 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1825 if (state
->render_states
[WINED3D_RS_MULTISAMPLEANTIALIAS
])
1827 gl_info
->gl_ops
.gl
.p_glEnable(GL_MULTISAMPLE_ARB
);
1828 checkGLcall("glEnable(GL_MULTISAMPLE_ARB)");
1832 gl_info
->gl_ops
.gl
.p_glDisable(GL_MULTISAMPLE_ARB
);
1833 checkGLcall("glDisable(GL_MULTISAMPLE_ARB)");
1837 static void line_antialias(const struct wined3d_rasterizer_state
*r
, const struct wined3d_gl_info
*gl_info
)
1839 if (r
&& r
->desc
.line_antialias
)
1841 gl_info
->gl_ops
.gl
.p_glEnable(GL_LINE_SMOOTH
);
1842 checkGLcall("glEnable(GL_LINE_SMOOTH)");
1846 gl_info
->gl_ops
.gl
.p_glDisable(GL_LINE_SMOOTH
);
1847 checkGLcall("glDisable(GL_LINE_SMOOTH)");
1851 static void scissor(const struct wined3d_rasterizer_state
*r
, const struct wined3d_gl_info
*gl_info
)
1853 if (r
&& r
->desc
.scissor
)
1855 gl_info
->gl_ops
.gl
.p_glEnable(GL_SCISSOR_TEST
);
1856 checkGLcall("glEnable(GL_SCISSOR_TEST)");
1860 gl_info
->gl_ops
.gl
.p_glDisable(GL_SCISSOR_TEST
);
1861 checkGLcall("glDisable(GL_SCISSOR_TEST)");
1865 /* The Direct3D depth bias is specified in normalized depth coordinates. In
1866 * OpenGL the bias is specified in units of "the smallest value that is
1867 * guaranteed to produce a resolvable offset for a given implementation". To
1868 * convert from D3D to GL we need to divide the D3D depth bias by that value.
1869 * We try to detect the value from GL with test draws. On most drivers (r300g,
1870 * 600g, Nvidia, i965 on Mesa) the value is 2^23 for fixed point depth buffers,
1871 * for r200 and i965 on OSX it is 2^24, for r500 on OSX it is 2^22. For floating
1872 * point buffers it is 2^22, 2^23 or 2^24 depending on the GPU. The value does
1873 * not depend on the depth buffer precision on any driver.
1875 * Two games that are picky regarding depth bias are Mass Effect 2 (flickering
1876 * decals) and F.E.A.R and F.E.A.R. 2 (semi-transparent guns).
1878 * Note that SLOPESCALEDEPTHBIAS is a scaling factor for the depth slope, and
1879 * doesn't need to be scaled to account for GL vs D3D differences. */
1880 static void depthbias(struct wined3d_context
*context
, const struct wined3d_state
*state
)
1882 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1883 const struct wined3d_rasterizer_state
*r
= state
->rasterizer_state
;
1884 float scale_bias
= r
? r
->desc
.scale_bias
: 0.0f
;
1891 const_bias
.f
= r
? r
->desc
.depth_bias
: 0.0f
;
1893 if (scale_bias
|| const_bias
.f
)
1895 const struct wined3d_rendertarget_view
*depth
= state
->fb
.depth_stencil
;
1896 float factor
, units
, scale
, clamp
;
1898 clamp
= r
? r
->desc
.depth_bias_clamp
: 0.0f
;
1900 if (context
->d3d_info
->wined3d_creation_flags
& WINED3D_LEGACY_DEPTH_BIAS
)
1902 factor
= units
= -(float)const_bias
.d
;
1908 scale
= depth
->format
->depth_bias_scale
;
1910 TRACE("Depth format %s, using depthbias scale of %.8e.\n",
1911 debug_d3dformat(depth
->format
->id
), scale
);
1915 /* The context manager will reapply this state on a depth stencil change */
1916 TRACE("No depth stencil, using depth bias scale of 0.0.\n");
1920 factor
= scale_bias
;
1921 units
= const_bias
.f
* scale
;
1924 gl_info
->gl_ops
.gl
.p_glEnable(GL_POLYGON_OFFSET_FILL
);
1925 if (gl_info
->supported
[ARB_POLYGON_OFFSET_CLAMP
])
1927 gl_info
->gl_ops
.ext
.p_glPolygonOffsetClamp(factor
, units
, clamp
);
1932 WARN("Ignoring depth bias clamp %.8e.\n", clamp
);
1933 gl_info
->gl_ops
.gl
.p_glPolygonOffset(factor
, units
);
1938 gl_info
->gl_ops
.gl
.p_glDisable(GL_POLYGON_OFFSET_FILL
);
1941 checkGLcall("depth bias");
1944 static void state_sample_mask(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1946 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
1947 unsigned int sample_mask
= state
->sample_mask
;
1949 TRACE("Setting sample mask to %#x.\n", sample_mask
);
1950 if (sample_mask
!= 0xffffffff)
1952 gl_info
->gl_ops
.gl
.p_glEnable(GL_SAMPLE_MASK
);
1953 checkGLcall("glEnable GL_SAMPLE_MASK");
1954 GL_EXTCALL(glSampleMaski(0, sample_mask
));
1955 checkGLcall("glSampleMaski");
1959 gl_info
->gl_ops
.gl
.p_glDisable(GL_SAMPLE_MASK
);
1960 checkGLcall("glDisable GL_SAMPLE_MASK");
1964 static void state_sample_mask_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1966 WARN("Unsupported in local OpenGL implementation: glSampleMaski.\n");
1969 static void get_src_and_opr(uint32_t arg
, BOOL is_alpha
, GLenum
* source
, GLenum
* operand
) {
1970 /* The WINED3DTA_ALPHAREPLICATE flag specifies the alpha component of the
1971 * input should be used for all input components. The WINED3DTA_COMPLEMENT
1972 * flag specifies the complement of the input should be used. */
1973 BOOL from_alpha
= is_alpha
|| arg
& WINED3DTA_ALPHAREPLICATE
;
1974 BOOL complement
= arg
& WINED3DTA_COMPLEMENT
;
1976 /* Calculate the operand */
1978 if (from_alpha
) *operand
= GL_ONE_MINUS_SRC_ALPHA
;
1979 else *operand
= GL_ONE_MINUS_SRC_COLOR
;
1981 if (from_alpha
) *operand
= GL_SRC_ALPHA
;
1982 else *operand
= GL_SRC_COLOR
;
1985 /* Calculate the source */
1986 switch (arg
& WINED3DTA_SELECTMASK
) {
1987 case WINED3DTA_CURRENT
: *source
= GL_PREVIOUS_EXT
; break;
1988 case WINED3DTA_DIFFUSE
: *source
= GL_PRIMARY_COLOR_EXT
; break;
1989 case WINED3DTA_TEXTURE
: *source
= GL_TEXTURE
; break;
1990 case WINED3DTA_TFACTOR
: *source
= GL_CONSTANT_EXT
; break;
1991 case WINED3DTA_SPECULAR
:
1993 * According to the GL_ARB_texture_env_combine specs, SPECULAR is
1994 * 'Secondary color' and isn't supported until base GL supports it
1995 * There is no concept of temp registers as far as I can tell
1997 FIXME("Unhandled texture arg WINED3DTA_SPECULAR\n");
1998 *source
= GL_TEXTURE
;
2001 FIXME("Unrecognized texture arg %#x\n", arg
);
2002 *source
= GL_TEXTURE
;
2007 /* Setup the texture operations texture stage states */
2008 static void set_tex_op(const struct wined3d_gl_info
*gl_info
, const struct wined3d_state
*state
,
2009 BOOL isAlpha
, int Stage
, enum wined3d_texture_op op
, uint32_t arg1
, uint32_t arg2
, uint32_t arg3
)
2011 GLenum src1
, src2
, src3
;
2012 GLenum opr1
, opr2
, opr3
;
2014 GLenum src0_target
, src1_target
, src2_target
;
2015 GLenum opr0_target
, opr1_target
, opr2_target
;
2017 GLenum opr
=0, invopr
, src3_target
, opr3_target
;
2018 BOOL Handled
= FALSE
;
2020 TRACE("Alpha?(%d), Stage:%d Op(%s), a1(%d), a2(%d), a3(%d)\n", isAlpha
, Stage
, debug_d3dtop(op
), arg1
, arg2
, arg3
);
2022 /* Operations usually involve two args, src0 and src1 and are operations
2023 * of the form (a1 <operation> a2). However, some of the more complex
2024 * operations take 3 parameters. Instead of the (sensible) addition of a3,
2025 * Microsoft added in a third parameter called a0. Therefore these are
2026 * operations of the form a0 <operation> a1 <operation> a2. I.e., the new
2027 * parameter goes to the front.
2029 * However, below we treat the new (a0) parameter as src2/opr2, so in the
2030 * actual functions below, expect their syntax to differ slightly to those
2031 * listed in the manuals. I.e., replace arg1 with arg3, arg2 with arg1 and
2032 * arg3 with arg2. This affects WINED3DTOP_MULTIPLYADD and WINED3DTOP_LERP. */
2036 comb_target
= GL_COMBINE_ALPHA
;
2037 src0_target
= GL_SOURCE0_ALPHA
;
2038 src1_target
= GL_SOURCE1_ALPHA
;
2039 src2_target
= GL_SOURCE2_ALPHA
;
2040 opr0_target
= GL_OPERAND0_ALPHA
;
2041 opr1_target
= GL_OPERAND1_ALPHA
;
2042 opr2_target
= GL_OPERAND2_ALPHA
;
2043 scal_target
= GL_ALPHA_SCALE
;
2047 comb_target
= GL_COMBINE_RGB
;
2048 src0_target
= GL_SOURCE0_RGB
;
2049 src1_target
= GL_SOURCE1_RGB
;
2050 src2_target
= GL_SOURCE2_RGB
;
2051 opr0_target
= GL_OPERAND0_RGB
;
2052 opr1_target
= GL_OPERAND1_RGB
;
2053 opr2_target
= GL_OPERAND2_RGB
;
2054 scal_target
= GL_RGB_SCALE
;
2057 /* If a texture stage references an invalid texture unit the stage just
2058 * passes through the result from the previous stage */
2059 if (is_invalid_op(state
, Stage
, op
, arg1
, arg2
, arg3
))
2061 arg1
= WINED3DTA_CURRENT
;
2062 op
= WINED3D_TOP_SELECT_ARG1
;
2065 if (isAlpha
&& !state
->textures
[Stage
] && arg1
== WINED3DTA_TEXTURE
)
2067 get_src_and_opr(WINED3DTA_DIFFUSE
, isAlpha
, &src1
, &opr1
);
2069 get_src_and_opr(arg1
, isAlpha
, &src1
, &opr1
);
2071 get_src_and_opr(arg2
, isAlpha
, &src2
, &opr2
);
2072 get_src_and_opr(arg3
, isAlpha
, &src3
, &opr3
);
2074 TRACE("ct(%x), 1:(%x,%x), 2:(%x,%x), 3:(%x,%x)\n", comb_target
, src1
, opr1
, src2
, opr2
, src3
, opr3
);
2076 Handled
= TRUE
; /* Assume will be handled */
2078 /* Other texture operations require special extensions: */
2079 if (gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
2083 invopr
= GL_ONE_MINUS_SRC_ALPHA
;
2084 src3_target
= GL_SOURCE3_ALPHA_NV
;
2085 opr3_target
= GL_OPERAND3_ALPHA_NV
;
2088 invopr
= GL_ONE_MINUS_SRC_COLOR
;
2089 src3_target
= GL_SOURCE3_RGB_NV
;
2090 opr3_target
= GL_OPERAND3_RGB_NV
;
2094 case WINED3D_TOP_DISABLE
: /* Only for alpha */
2095 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2096 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2097 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_PREVIOUS_EXT
);
2098 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2099 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_SRC_ALPHA
);
2100 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2101 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2102 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2103 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2104 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2105 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2106 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_ZERO");
2107 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2108 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2109 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2110 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2111 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2112 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2115 case WINED3D_TOP_SELECT_ARG1
: /* = a1 * 1 + 0 * 0 */
2116 case WINED3D_TOP_SELECT_ARG2
: /* = a2 * 1 + 0 * 0 */
2117 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2118 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2119 if (op
== WINED3D_TOP_SELECT_ARG1
)
2121 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2122 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2123 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2124 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2128 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src2
);
2129 checkGLcall("GL_TEXTURE_ENV, src0_target, src2");
2130 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr2
);
2131 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr2");
2133 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2134 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2135 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2136 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2137 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2138 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_ZERO");
2139 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2140 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2141 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2142 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2143 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2144 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2147 case WINED3D_TOP_MODULATE
:
2148 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2149 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2150 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2151 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2152 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2153 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2154 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2155 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2156 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2157 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2158 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2159 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2160 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2161 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2162 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2163 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2164 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2165 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2166 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2167 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2169 case WINED3D_TOP_MODULATE_2X
:
2170 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2171 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2172 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2173 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2174 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2175 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2176 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2177 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2178 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2179 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2180 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2181 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2182 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2183 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2184 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2185 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2186 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2187 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2188 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2189 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2191 case WINED3D_TOP_MODULATE_4X
:
2192 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2193 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2194 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2195 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2196 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2197 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2198 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2199 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2200 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2201 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2202 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2203 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2204 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2205 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2206 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2207 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2208 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2209 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2210 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 4);
2211 checkGLcall("GL_TEXTURE_ENV, scal_target, 4");
2214 case WINED3D_TOP_ADD
:
2215 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2216 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2217 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2218 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2219 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2220 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2221 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2222 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2223 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2224 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2225 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2226 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2227 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2228 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2229 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2230 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2231 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2232 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2233 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2234 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2237 case WINED3D_TOP_ADD_SIGNED
:
2238 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD_SIGNED
);
2239 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2240 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2241 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2242 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2243 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2244 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2245 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2246 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2247 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2248 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2249 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2250 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2251 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2252 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2253 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2254 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2255 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2256 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2257 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2260 case WINED3D_TOP_ADD_SIGNED_2X
:
2261 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD_SIGNED
);
2262 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2263 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2264 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2265 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2266 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2267 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2268 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2269 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2270 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2271 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2272 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2273 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2274 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2275 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2276 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2277 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2278 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2279 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2280 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2283 case WINED3D_TOP_ADD_SMOOTH
:
2284 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2285 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2286 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2287 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2288 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2289 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2290 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2291 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2292 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2293 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2294 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2295 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2296 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2297 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2298 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
2299 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2301 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2302 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2303 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2304 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2306 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2307 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2308 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2309 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2312 case WINED3D_TOP_BLEND_DIFFUSE_ALPHA
:
2313 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2314 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2315 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2316 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2317 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2318 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2319 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_PRIMARY_COLOR
);
2320 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_PRIMARY_COLOR");
2321 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2322 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2323 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2324 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2325 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2326 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2327 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_PRIMARY_COLOR
);
2328 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_PRIMARY_COLOR");
2329 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2330 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2331 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2332 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2334 case WINED3D_TOP_BLEND_TEXTURE_ALPHA
:
2335 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2336 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2337 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2338 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2339 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2340 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2341 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_TEXTURE
);
2342 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_TEXTURE");
2343 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2344 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2345 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2346 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2347 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2348 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2349 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_TEXTURE
);
2350 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_TEXTURE");
2351 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2352 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2353 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2354 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2356 case WINED3D_TOP_BLEND_FACTOR_ALPHA
:
2357 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2358 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2359 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2360 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2361 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2362 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2363 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_CONSTANT
);
2364 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_CONSTANT");
2365 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2366 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2367 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2368 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2369 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2370 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2371 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_CONSTANT
);
2372 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_CONSTANT");
2373 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2374 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2375 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2376 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2378 case WINED3D_TOP_BLEND_TEXTURE_ALPHA_PM
:
2379 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2380 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2381 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2382 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2383 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2384 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2385 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2386 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2387 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2388 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2389 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2390 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2391 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2392 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2393 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_TEXTURE
);
2394 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_TEXTURE");
2395 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2396 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2397 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2398 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2400 case WINED3D_TOP_MODULATE_ALPHA_ADD_COLOR
:
2401 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2402 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2403 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
); /* a0 = src1/opr1 */
2404 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2405 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2406 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1"); /* a1 = 1 (see docs) */
2407 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2408 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2409 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2410 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2411 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
); /* a2 = arg2 */
2412 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2413 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2414 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2"); /* a3 = src1 alpha */
2415 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
2416 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2418 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2419 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2421 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2422 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2423 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2424 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2426 case WINED3D_TOP_MODULATE_COLOR_ADD_ALPHA
:
2427 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2428 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2429 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2430 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2431 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2432 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2433 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2434 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2435 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2436 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2437 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
2438 checkGLcall("GL_TEXTURE_ENV, src2_target, src1");
2440 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2441 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2443 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2444 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2445 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2446 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2447 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2448 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2449 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2450 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2452 case WINED3D_TOP_MODULATE_INVALPHA_ADD_COLOR
:
2453 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2454 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2455 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2456 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2457 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2458 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2459 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2460 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2461 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2462 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2463 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2464 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2465 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2466 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2467 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
2468 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2470 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2471 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2472 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2473 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2475 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2476 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2477 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2478 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2480 case WINED3D_TOP_MODULATE_INVCOLOR_ADD_ALPHA
:
2481 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2482 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2483 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2484 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2486 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2487 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2488 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2489 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2491 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2492 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2493 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2494 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2495 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2496 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2497 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
2498 checkGLcall("GL_TEXTURE_ENV, src2_target, src1");
2500 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2501 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2503 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2504 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2505 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2506 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2507 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2508 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2509 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2510 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2512 case WINED3D_TOP_MULTIPLY_ADD
:
2513 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2514 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2515 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src3
);
2516 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2517 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr3
);
2518 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2519 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2520 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2521 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2522 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2523 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
2524 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2525 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr1
);
2526 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2527 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src2
);
2528 checkGLcall("GL_TEXTURE_ENV, src3_target, src3");
2529 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr2
);
2530 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr3");
2531 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2532 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2535 case WINED3D_TOP_BUMPENVMAP
:
2536 case WINED3D_TOP_BUMPENVMAP_LUMINANCE
:
2537 FIXME("Implement bump environment mapping in GL_NV_texture_env_combine4 path\n");
2546 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_COMBINE4_NV
);
2547 checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV");
2551 } /* GL_NV_texture_env_combine4 */
2553 Handled
= TRUE
; /* Again, assume handled */
2555 case WINED3D_TOP_DISABLE
: /* Only for alpha */
2556 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
2557 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2558 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_PREVIOUS_EXT
);
2559 checkGLcall("GL_TEXTURE_ENV, src0_target, GL_PREVIOUS_EXT");
2560 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_SRC_ALPHA
);
2561 checkGLcall("GL_TEXTURE_ENV, opr0_target, GL_SRC_ALPHA");
2562 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2563 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2565 case WINED3D_TOP_SELECT_ARG1
:
2566 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
2567 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2568 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2569 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2570 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2571 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2572 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2573 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2575 case WINED3D_TOP_SELECT_ARG2
:
2576 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
2577 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2578 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src2
);
2579 checkGLcall("GL_TEXTURE_ENV, src0_target, src2");
2580 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr2
);
2581 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr2");
2582 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2583 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2585 case WINED3D_TOP_MODULATE
:
2586 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
2587 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2588 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2589 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2590 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2591 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2592 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2593 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2594 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2595 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2596 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2597 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2599 case WINED3D_TOP_MODULATE_2X
:
2600 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
2601 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2602 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2603 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2604 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2605 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2606 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2607 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2608 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2609 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2610 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2611 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2613 case WINED3D_TOP_MODULATE_4X
:
2614 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
2615 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2616 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2617 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2618 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2619 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2620 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2621 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2622 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2623 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2624 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 4);
2625 checkGLcall("GL_TEXTURE_ENV, scal_target, 4");
2627 case WINED3D_TOP_ADD
:
2628 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2629 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2630 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2631 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2632 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2633 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2634 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2635 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2636 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2637 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2638 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2639 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2641 case WINED3D_TOP_ADD_SIGNED
:
2642 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD_SIGNED
);
2643 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2644 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2645 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2646 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2647 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2648 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2649 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2650 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2651 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2652 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2653 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2655 case WINED3D_TOP_ADD_SIGNED_2X
:
2656 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD_SIGNED
);
2657 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2658 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2659 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2660 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2661 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2662 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2663 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2664 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2665 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2666 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2667 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2669 case WINED3D_TOP_SUBTRACT
:
2670 if (gl_info
->supported
[ARB_TEXTURE_ENV_COMBINE
])
2672 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_SUBTRACT
);
2673 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_SUBTRACT");
2674 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2675 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2676 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2677 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2678 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2679 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2680 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2681 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2682 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2683 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2685 FIXME("This version of opengl does not support GL_SUBTRACT\n");
2689 case WINED3D_TOP_BLEND_DIFFUSE_ALPHA
:
2690 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2691 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2692 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2693 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2694 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2695 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2696 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2697 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2698 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2699 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2700 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_PRIMARY_COLOR
);
2701 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_PRIMARY_COLOR");
2702 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2703 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2704 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2705 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2707 case WINED3D_TOP_BLEND_TEXTURE_ALPHA
:
2708 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2709 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2710 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2711 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2712 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2713 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2714 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2715 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2716 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2717 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2718 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_TEXTURE
);
2719 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_TEXTURE");
2720 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2721 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2722 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2723 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2725 case WINED3D_TOP_BLEND_FACTOR_ALPHA
:
2726 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2727 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2728 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2729 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2730 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2731 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2732 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2733 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2734 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2735 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2736 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_CONSTANT
);
2737 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_CONSTANT");
2738 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2739 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2740 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2741 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2743 case WINED3D_TOP_BLEND_CURRENT_ALPHA
:
2744 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2745 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2746 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2747 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2748 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2749 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2750 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2751 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2752 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2753 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2754 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_PREVIOUS
);
2755 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_PREVIOUS");
2756 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2757 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2758 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2759 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2761 case WINED3D_TOP_DOTPRODUCT3
:
2762 if (gl_info
->supported
[ARB_TEXTURE_ENV_DOT3
])
2764 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_DOT3_RGBA_ARB
);
2765 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_ARB");
2767 else if (gl_info
->supported
[EXT_TEXTURE_ENV_DOT3
])
2769 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_DOT3_RGBA_EXT
);
2770 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_EXT");
2772 FIXME("This version of opengl does not support GL_DOT3\n");
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
, src1_target
, src2
);
2779 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2780 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2781 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2782 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2783 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2785 case WINED3D_TOP_LERP
:
2786 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2787 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2788 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2789 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2790 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2791 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2792 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2793 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2794 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2795 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2796 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src3
);
2797 checkGLcall("GL_TEXTURE_ENV, src2_target, src3");
2798 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr3
);
2799 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr3");
2800 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2801 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2803 case WINED3D_TOP_ADD_SMOOTH
:
2804 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2806 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2807 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2808 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2809 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2811 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2812 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2813 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2814 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2816 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2817 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2818 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2819 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2820 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2821 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2822 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2823 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2824 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2825 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2826 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2827 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2831 case WINED3D_TOP_BLEND_TEXTURE_ALPHA_PM
:
2832 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2834 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2835 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2836 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_TEXTURE
);
2837 checkGLcall("GL_TEXTURE_ENV, src0_target, GL_TEXTURE");
2838 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_ONE_MINUS_SRC_ALPHA
);
2839 checkGLcall("GL_TEXTURE_ENV, opr0_target, GL_ONE_MINUS_SRC_APHA");
2840 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2841 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2842 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2843 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2844 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2845 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2846 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2847 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2848 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2849 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2853 case WINED3D_TOP_MODULATE_ALPHA_ADD_COLOR
:
2854 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2856 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2857 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2858 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2859 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2861 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2862 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2863 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2864 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2866 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2867 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2868 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2869 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2870 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2871 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2872 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2873 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2874 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2875 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2876 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2877 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2881 case WINED3D_TOP_MODULATE_COLOR_ADD_ALPHA
:
2882 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2884 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2885 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2886 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2887 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2888 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2889 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2890 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2891 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2893 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2894 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2895 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2896 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2898 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr
);
2899 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr");
2900 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2901 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2902 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2903 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2904 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2905 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2909 case WINED3D_TOP_MODULATE_INVALPHA_ADD_COLOR
:
2910 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2912 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2913 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2914 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2915 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2917 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2918 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2919 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2920 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2922 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2923 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2924 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2925 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2926 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2927 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2928 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2929 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2930 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2931 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2932 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2933 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2937 case WINED3D_TOP_MODULATE_INVCOLOR_ADD_ALPHA
:
2938 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2940 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2941 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2942 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2943 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2945 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2946 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2947 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2948 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2950 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2951 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2952 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2953 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2955 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2956 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2957 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2958 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2960 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr
);
2961 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr");
2962 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2963 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2964 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2965 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2966 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2967 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2971 case WINED3D_TOP_MULTIPLY_ADD
:
2972 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2974 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2975 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2976 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2977 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2978 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2979 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2980 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src3
);
2981 checkGLcall("GL_TEXTURE_ENV, src1_target, src3");
2982 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr3
);
2983 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr3");
2984 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2985 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2986 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2987 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2988 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2989 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2993 case WINED3D_TOP_BUMPENVMAP_LUMINANCE
:
2994 case WINED3D_TOP_BUMPENVMAP
:
2995 if (gl_info
->supported
[NV_TEXTURE_SHADER2
])
2997 /* Technically texture shader support without register combiners is possible, but not expected to occur
2998 * on real world cards, so for now a fixme should be enough
3000 FIXME("Implement bump mapping with GL_NV_texture_shader in non register combiner path\n");
3010 BOOL combineOK
= TRUE
;
3011 if (gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
3016 op2
= state
->texture_states
[Stage
][WINED3D_TSS_COLOR_OP
];
3018 op2
= state
->texture_states
[Stage
][WINED3D_TSS_ALPHA_OP
];
3020 /* Note: If COMBINE4 in effect can't go back to combine! */
3023 case WINED3D_TOP_ADD_SMOOTH
:
3024 case WINED3D_TOP_BLEND_TEXTURE_ALPHA_PM
:
3025 case WINED3D_TOP_MODULATE_ALPHA_ADD_COLOR
:
3026 case WINED3D_TOP_MODULATE_COLOR_ADD_ALPHA
:
3027 case WINED3D_TOP_MODULATE_INVALPHA_ADD_COLOR
:
3028 case WINED3D_TOP_MODULATE_INVCOLOR_ADD_ALPHA
:
3029 case WINED3D_TOP_MULTIPLY_ADD
:
3030 /* Ignore those implemented in both cases */
3033 case WINED3D_TOP_SELECT_ARG1
:
3034 case WINED3D_TOP_SELECT_ARG2
:
3039 FIXME("Can't use COMBINE4 and COMBINE together, thisop=%s, otherop=%s, isAlpha(%d)\n", debug_d3dtop(op
), debug_d3dtop(op2
), isAlpha
);
3047 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_COMBINE
);
3048 checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE");
3054 /* After all the extensions, if still unhandled, report fixme */
3055 FIXME("Unhandled texture operation %s\n", debug_d3dtop(op
));
3059 static void tex_colorop(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3061 unsigned int stage
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3062 struct wined3d_context_gl
*context_gl
= wined3d_context_gl(context
);
3063 BOOL tex_used
= context
->fixed_function_usage_map
& (1u << stage
);
3064 unsigned int mapped_stage
= context_gl
->tex_unit_map
[stage
];
3065 const struct wined3d_gl_info
*gl_info
= context_gl
->gl_info
;
3067 TRACE("Setting color op for stage %d\n", stage
);
3069 /* Using a pixel shader? Don't care for anything here, the shader applying does it */
3070 if (use_ps(state
)) return;
3072 if (stage
!= mapped_stage
) WARN("Using non 1:1 mapping: %d -> %d!\n", stage
, mapped_stage
);
3074 if (mapped_stage
!= WINED3D_UNMAPPED_STAGE
)
3076 if (tex_used
&& mapped_stage
>= gl_info
->limits
.textures
)
3078 FIXME("Attempt to enable unsupported stage!\n");
3081 wined3d_context_gl_active_texture(context_gl
, gl_info
, mapped_stage
);
3084 if (stage
>= context
->lowest_disabled_stage
)
3086 TRACE("Stage disabled\n");
3087 if (mapped_stage
!= WINED3D_UNMAPPED_STAGE
)
3089 /* Disable everything here */
3090 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_2D
);
3091 checkGLcall("glDisable(GL_TEXTURE_2D)");
3092 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_3D
);
3093 checkGLcall("glDisable(GL_TEXTURE_3D)");
3094 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
3096 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB
);
3097 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
3099 if (gl_info
->supported
[ARB_TEXTURE_RECTANGLE
])
3101 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_RECTANGLE_ARB
);
3102 checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)");
3109 /* The sampler will also activate the correct texture dimensions, so no
3110 * need to do it here if the sampler for this stage is dirty. */
3111 if (!isStateDirty(context
, STATE_SAMPLER(stage
)) && tex_used
)
3112 texture_activate_dimensions(state
->textures
[stage
], gl_info
);
3114 set_tex_op(gl_info
, state
, FALSE
, stage
,
3115 state
->texture_states
[stage
][WINED3D_TSS_COLOR_OP
],
3116 state
->texture_states
[stage
][WINED3D_TSS_COLOR_ARG1
],
3117 state
->texture_states
[stage
][WINED3D_TSS_COLOR_ARG2
],
3118 state
->texture_states
[stage
][WINED3D_TSS_COLOR_ARG0
]);
3121 void tex_alphaop(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3123 unsigned int stage
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3124 struct wined3d_context_gl
*context_gl
= wined3d_context_gl(context
);
3125 BOOL tex_used
= context
->fixed_function_usage_map
& (1u << stage
);
3126 const struct wined3d_gl_info
*gl_info
= context_gl
->gl_info
;
3127 unsigned int mapped_stage
= context_gl
->tex_unit_map
[stage
];
3128 DWORD op
, arg1
, arg2
, arg0
;
3130 TRACE("Setting alpha op for stage %d\n", stage
);
3131 /* Do not care for enabled / disabled stages, just assign the settings. colorop disables / enables required stuff */
3132 if (mapped_stage
!= WINED3D_UNMAPPED_STAGE
)
3134 if (tex_used
&& mapped_stage
>= gl_info
->limits
.textures
)
3136 FIXME("Attempt to enable unsupported stage!\n");
3139 wined3d_context_gl_active_texture(context_gl
, gl_info
, mapped_stage
);
3142 op
= state
->texture_states
[stage
][WINED3D_TSS_ALPHA_OP
];
3143 arg1
= state
->texture_states
[stage
][WINED3D_TSS_ALPHA_ARG1
];
3144 arg2
= state
->texture_states
[stage
][WINED3D_TSS_ALPHA_ARG2
];
3145 arg0
= state
->texture_states
[stage
][WINED3D_TSS_ALPHA_ARG0
];
3147 if (state
->render_states
[WINED3D_RS_COLORKEYENABLE
] && !stage
&& state
->textures
[0])
3149 struct wined3d_texture_gl
*texture_gl
= wined3d_texture_gl(state
->textures
[0]);
3150 GLenum texture_dimensions
= texture_gl
->target
;
3152 if (texture_dimensions
== GL_TEXTURE_2D
|| texture_dimensions
== GL_TEXTURE_RECTANGLE_ARB
)
3154 if (texture_gl
->t
.async
.color_key_flags
& WINED3D_CKEY_SRC_BLT
3155 && !texture_gl
->t
.resource
.format
->alpha_size
)
3157 /* Color keying needs to pass alpha values from the texture through to have the alpha test work
3158 * properly. On the other hand applications can still use texture combiners apparently. This code
3159 * takes care that apps cannot remove the texture's alpha channel entirely.
3161 * The fixup is required for Prince of Persia 3D(prison bars), while Moto racer 2 requires
3162 * D3DTOP_MODULATE to work on color keyed surfaces. Aliens vs Predator 1 uses color keyed textures
3163 * and alpha component of diffuse color to draw things like translucent text and perform other
3166 * Aliens vs Predator 1 relies on diffuse alpha having an effect, so it cannot be ignored. To
3167 * provide the behavior expected by the game, while emulating the colorkey, diffuse alpha must be
3168 * modulated with texture alpha. OTOH, Moto racer 2 at some points sets alphaop/alphaarg to
3169 * SELECTARG/CURRENT, yet puts garbage in diffuse alpha (zeroes). This works on native, because the
3170 * game disables alpha test and alpha blending. Alpha test is overwritten by wine's for purposes of
3171 * color-keying though, so this will lead to missing geometry if texture alpha is modulated (pixels
3172 * fail alpha test). To get around this, blend state is checked: if the app enables alpha blending,
3173 * it can be expected to provide meaningful values in diffuse alpha, so it should be modulated with
3174 * texture alpha; otherwise, selecting diffuse alpha is ignored in favour of texture alpha.
3176 * What to do with multitexturing? So far no app has been found that uses color keying with
3178 if (op
== WINED3D_TOP_DISABLE
)
3180 arg1
= WINED3DTA_TEXTURE
;
3181 op
= WINED3D_TOP_SELECT_ARG1
;
3183 else if (op
== WINED3D_TOP_SELECT_ARG1
&& arg1
!= WINED3DTA_TEXTURE
)
3185 if (state
->blend_state
&& state
->blend_state
->desc
.rt
[0].enable
)
3187 arg2
= WINED3DTA_TEXTURE
;
3188 op
= WINED3D_TOP_MODULATE
;
3190 else arg1
= WINED3DTA_TEXTURE
;
3192 else if (op
== WINED3D_TOP_SELECT_ARG2
&& arg2
!= WINED3DTA_TEXTURE
)
3194 if (state
->blend_state
&& state
->blend_state
->desc
.rt
[0].enable
)
3196 arg1
= WINED3DTA_TEXTURE
;
3197 op
= WINED3D_TOP_MODULATE
;
3199 else arg2
= WINED3DTA_TEXTURE
;
3205 /* tex_alphaop is shared between the ffp and nvrc because the difference only comes down to
3206 * this if block here, and the other code(color keying, texture unit selection) are the same
3208 TRACE("Setting alpha op for stage %d\n", stage
);
3209 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
3211 set_tex_op_nvrc(gl_info
, state
, TRUE
, stage
, op
, arg1
, arg2
, arg0
,
3212 mapped_stage
, state
->texture_states
[stage
][WINED3D_TSS_RESULT_ARG
]);
3216 set_tex_op(gl_info
, state
, TRUE
, stage
, op
, arg1
, arg2
, arg0
);
3220 static void transform_texture(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3222 unsigned int tex
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3223 struct wined3d_context_gl
*context_gl
= wined3d_context_gl(context
);
3224 const struct wined3d_gl_info
*gl_info
= context_gl
->gl_info
;
3225 unsigned int mapped_stage
= context_gl
->tex_unit_map
[tex
];
3226 struct wined3d_matrix mat
;
3230 TRACE("Using a vertex shader, skipping.\n");
3234 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
) return;
3235 if (mapped_stage
>= gl_info
->limits
.textures
) return;
3237 wined3d_context_gl_active_texture(context_gl
, gl_info
, mapped_stage
);
3238 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_TEXTURE
);
3239 checkGLcall("glMatrixMode(GL_TEXTURE)");
3241 get_texture_matrix(context
, state
, mapped_stage
, &mat
);
3243 gl_info
->gl_ops
.gl
.p_glLoadMatrixf(&mat
._11
);
3244 checkGLcall("glLoadMatrixf");
3247 static void tex_coordindex(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3249 unsigned int stage
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3250 struct wined3d_context_gl
*context_gl
= wined3d_context_gl(context
);
3251 const struct wined3d_gl_info
*gl_info
= context_gl
->gl_info
;
3252 unsigned int mapped_stage
= context_gl
->tex_unit_map
[stage
];
3254 static const GLfloat s_plane
[] = { 1.0f
, 0.0f
, 0.0f
, 0.0f
};
3255 static const GLfloat t_plane
[] = { 0.0f
, 1.0f
, 0.0f
, 0.0f
};
3256 static const GLfloat r_plane
[] = { 0.0f
, 0.0f
, 1.0f
, 0.0f
};
3257 static const GLfloat q_plane
[] = { 0.0f
, 0.0f
, 0.0f
, 1.0f
};
3259 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
)
3261 TRACE("No texture unit mapped to stage %d. Skipping texture coordinates.\n", stage
);
3265 if (mapped_stage
>= min(gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_PIXEL
], WINED3D_MAX_FRAGMENT_SAMPLERS
))
3267 WARN("stage %u not mapped to a valid texture unit (%u)\n", stage
, mapped_stage
);
3270 wined3d_context_gl_active_texture(context_gl
, gl_info
, mapped_stage
);
3272 /* Values 0-7 are indexes into the FVF tex coords - See comments in DrawPrimitive
3274 * FIXME: When using generated texture coordinates, the index value is used to specify the wrapping mode.
3275 * eg. SetTextureStageState( 0, WINED3D_TSS_TEXCOORDINDEX, WINED3D_TSS_TCI_CAMERASPACEPOSITION | 1 );
3276 * means use the vertex position (camera-space) as the input texture coordinates
3277 * for this texture stage, and the wrap mode set in the WINED3D_RS_WRAP1 render
3278 * state. We do not (yet) support the WINED3DRENDERSTATE_WRAPx values, nor tie them up
3279 * to the TEXCOORDINDEX value
3281 switch (state
->texture_states
[stage
][WINED3D_TSS_TEXCOORD_INDEX
] & 0xffff0000)
3283 case WINED3DTSS_TCI_PASSTHRU
:
3284 /* Use the specified texture coordinates contained within the
3285 * vertex format. This value resolves to zero. */
3286 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_S
);
3287 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_T
);
3288 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_R
);
3289 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_Q
);
3290 checkGLcall("WINED3DTSS_TCI_PASSTHRU - Disable texgen.");
3293 case WINED3DTSS_TCI_CAMERASPACEPOSITION
:
3294 /* CameraSpacePosition means use the vertex position, transformed to camera space,
3295 * as the input texture coordinates for this stage's texture transformation. This
3296 * equates roughly to EYE_LINEAR */
3298 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3299 gl_info
->gl_ops
.gl
.p_glPushMatrix();
3300 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
3301 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
3302 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
3303 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
3304 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
3305 gl_info
->gl_ops
.gl
.p_glPopMatrix();
3306 checkGLcall("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set eye plane.");
3308 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
3309 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
3310 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
3311 checkGLcall("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set texgen mode.");
3313 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_S
);
3314 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_T
);
3315 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_R
);
3316 checkGLcall("WINED3DTSS_TCI_CAMERASPACEPOSITION - Enable texgen.");
3320 case WINED3DTSS_TCI_CAMERASPACENORMAL
:
3321 /* Note that NV_TEXGEN_REFLECTION support is implied when
3322 * ARB_TEXTURE_CUBE_MAP is supported */
3323 if (!gl_info
->supported
[NV_TEXGEN_REFLECTION
])
3325 FIXME("WINED3DTSS_TCI_CAMERASPACENORMAL not supported.\n");
3329 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3330 gl_info
->gl_ops
.gl
.p_glPushMatrix();
3331 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
3332 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
3333 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
3334 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
3335 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
3336 gl_info
->gl_ops
.gl
.p_glPopMatrix();
3337 checkGLcall("WINED3DTSS_TCI_CAMERASPACENORMAL - Set eye plane.");
3339 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
3340 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
3341 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
3342 checkGLcall("WINED3DTSS_TCI_CAMERASPACENORMAL - Set texgen mode.");
3344 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_S
);
3345 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_T
);
3346 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_R
);
3347 checkGLcall("WINED3DTSS_TCI_CAMERASPACENORMAL - Enable texgen.");
3351 case WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR
:
3352 /* Note that NV_TEXGEN_REFLECTION support is implied when
3353 * ARB_TEXTURE_CUBE_MAP is supported */
3354 if (!gl_info
->supported
[NV_TEXGEN_REFLECTION
])
3356 FIXME("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR not supported.\n");
3360 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3361 gl_info
->gl_ops
.gl
.p_glPushMatrix();
3362 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
3363 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
3364 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
3365 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
3366 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
3367 gl_info
->gl_ops
.gl
.p_glPopMatrix();
3368 checkGLcall("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Set eye plane.");
3370 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
3371 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
3372 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
3373 checkGLcall("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Set texgen mode.");
3375 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_S
);
3376 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_T
);
3377 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_R
);
3378 checkGLcall("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Enable texgen.");
3382 case WINED3DTSS_TCI_SPHEREMAP
:
3383 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_SPHERE_MAP
);
3384 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_SPHERE_MAP
);
3385 checkGLcall("WINED3DTSS_TCI_SPHEREMAP - Set texgen mode.");
3387 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_S
);
3388 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_T
);
3389 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_R
);
3390 checkGLcall("WINED3DTSS_TCI_SPHEREMAP - Enable texgen.");
3395 FIXME("Unhandled WINED3D_TSS_TEXCOORD_INDEX %#x.\n",
3396 state
->texture_states
[stage
][WINED3D_TSS_TEXCOORD_INDEX
]);
3397 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_S
);
3398 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_T
);
3399 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_R
);
3400 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_Q
);
3401 checkGLcall("Disable texgen.");
3406 /* Update the texture matrix. */
3407 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_TEXTURE0
+ stage
)))
3408 transform_texture(context
, state
, STATE_TEXTURESTAGE(stage
, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
));
3410 if (!isStateDirty(context
, STATE_VDECL
) && context
->namedArraysLoaded
)
3412 /* Reload the arrays if we are using fixed function arrays to reflect the selected coord input
3413 * source. Call loadTexCoords directly because there is no need to reparse the vertex declaration
3414 * and do all the things linked to it
3415 * TODO: Tidy that up to reload only the arrays of the changed unit
3417 GLuint curVBO
= gl_info
->supported
[ARB_VERTEX_BUFFER_OBJECT
] ? ~0U : 0;
3419 wined3d_context_gl_unload_tex_coords(context_gl
);
3420 wined3d_context_gl_load_tex_coords(context_gl
, &context
->stream_info
, &curVBO
, state
);
3424 static void sampler_texmatrix(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3426 const DWORD sampler
= state_id
- STATE_SAMPLER(0);
3427 const struct wined3d_texture
*texture
= state
->textures
[sampler
];
3429 TRACE("context %p, state %p, state_id %#lx.\n", context
, state
, state_id
);
3434 /* The fixed function np2 texture emulation uses the texture matrix to fix up the coordinates
3435 * wined3d_texture_apply_state_changes() multiplies the set matrix with a fixup matrix. Before the
3436 * scaling is reapplied or removed, the texture matrix has to be reapplied.
3438 if (sampler
< WINED3D_MAX_TEXTURES
)
3440 const BOOL tex_is_pow2
= !(texture
->flags
& WINED3D_TEXTURE_POW2_MAT_IDENT
);
3442 if (tex_is_pow2
|| (context
->lastWasPow2Texture
& (1u << sampler
)))
3445 context
->lastWasPow2Texture
|= 1u << sampler
;
3447 context
->lastWasPow2Texture
&= ~(1u << sampler
);
3449 transform_texture(context
, state
, STATE_TEXTURESTAGE(sampler
, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
));
3454 static enum wined3d_texture_address
wined3d_texture_gl_address_mode(const struct wined3d_texture_gl
*texture_gl
,
3455 enum wined3d_texture_address t
)
3457 if (t
< WINED3D_TADDRESS_WRAP
|| t
> WINED3D_TADDRESS_MIRROR_ONCE
)
3459 FIXME("Unrecognized or unsupported texture address mode %#x.\n", t
);
3460 return WINED3D_TADDRESS_WRAP
;
3463 /* Cubemaps are always set to clamp, regardless of the sampler state. */
3464 if (texture_gl
->target
== GL_TEXTURE_CUBE_MAP_ARB
|| ((texture_gl
->t
.flags
& WINED3D_TEXTURE_COND_NP2
)
3465 && t
== WINED3D_TADDRESS_WRAP
))
3466 return WINED3D_TADDRESS_CLAMP
;
3471 static void wined3d_sampler_desc_from_sampler_states(struct wined3d_sampler_desc
*desc
,
3472 const struct wined3d_context_gl
*context_gl
, const uint32_t *sampler_states
,
3473 const struct wined3d_texture_gl
*texture_gl
)
3481 desc
->address_u
= wined3d_texture_gl_address_mode(texture_gl
, sampler_states
[WINED3D_SAMP_ADDRESS_U
]);
3482 desc
->address_v
= wined3d_texture_gl_address_mode(texture_gl
, sampler_states
[WINED3D_SAMP_ADDRESS_V
]);
3483 desc
->address_w
= wined3d_texture_gl_address_mode(texture_gl
, sampler_states
[WINED3D_SAMP_ADDRESS_W
]);
3484 wined3d_color_from_d3dcolor((struct wined3d_color
*)desc
->border_color
,
3485 sampler_states
[WINED3D_SAMP_BORDER_COLOR
]);
3486 if (sampler_states
[WINED3D_SAMP_MAG_FILTER
] > WINED3D_TEXF_ANISOTROPIC
)
3487 FIXME("Unrecognized or unsupported WINED3D_SAMP_MAG_FILTER %#x.\n",
3488 sampler_states
[WINED3D_SAMP_MAG_FILTER
]);
3489 desc
->mag_filter
= min(max(sampler_states
[WINED3D_SAMP_MAG_FILTER
], WINED3D_TEXF_POINT
), WINED3D_TEXF_LINEAR
);
3490 if (sampler_states
[WINED3D_SAMP_MIN_FILTER
] > WINED3D_TEXF_ANISOTROPIC
)
3491 FIXME("Unrecognized or unsupported WINED3D_SAMP_MIN_FILTER %#x.\n",
3492 sampler_states
[WINED3D_SAMP_MIN_FILTER
]);
3493 desc
->min_filter
= min(max(sampler_states
[WINED3D_SAMP_MIN_FILTER
], WINED3D_TEXF_POINT
), WINED3D_TEXF_LINEAR
);
3494 if (sampler_states
[WINED3D_SAMP_MIP_FILTER
] > WINED3D_TEXF_ANISOTROPIC
)
3495 FIXME("Unrecognized or unsupported WINED3D_SAMP_MIP_FILTER %#x.\n",
3496 sampler_states
[WINED3D_SAMP_MIP_FILTER
]);
3497 desc
->mip_filter
= min(max(sampler_states
[WINED3D_SAMP_MIP_FILTER
], WINED3D_TEXF_NONE
), WINED3D_TEXF_LINEAR
);
3498 lod_bias
.d
= sampler_states
[WINED3D_SAMP_MIPMAP_LOD_BIAS
];
3499 desc
->lod_bias
= lod_bias
.f
;
3500 desc
->min_lod
= -1000.0f
;
3501 desc
->max_lod
= 1000.0f
;
3502 desc
->mip_base_level
= sampler_states
[WINED3D_SAMP_MAX_MIP_LEVEL
];
3503 desc
->max_anisotropy
= sampler_states
[WINED3D_SAMP_MAX_ANISOTROPY
];
3504 if ((sampler_states
[WINED3D_SAMP_MAG_FILTER
] != WINED3D_TEXF_ANISOTROPIC
3505 && sampler_states
[WINED3D_SAMP_MIN_FILTER
] != WINED3D_TEXF_ANISOTROPIC
3506 && sampler_states
[WINED3D_SAMP_MIP_FILTER
] != WINED3D_TEXF_ANISOTROPIC
)
3507 || (texture_gl
->t
.flags
& WINED3D_TEXTURE_COND_NP2
))
3508 desc
->max_anisotropy
= 1;
3509 desc
->compare
= texture_gl
->t
.resource
.format_caps
& WINED3D_FORMAT_CAP_SHADOW
;
3510 desc
->comparison_func
= WINED3D_CMP_LESSEQUAL
;
3511 desc
->srgb_decode
= is_srgb_enabled(sampler_states
);
3513 if (!(texture_gl
->t
.resource
.format_caps
& WINED3D_FORMAT_CAP_FILTERING
))
3515 desc
->mag_filter
= WINED3D_TEXF_POINT
;
3516 desc
->min_filter
= WINED3D_TEXF_POINT
;
3517 desc
->mip_filter
= WINED3D_TEXF_NONE
;
3520 if (texture_gl
->t
.flags
& WINED3D_TEXTURE_COND_NP2
)
3522 desc
->mip_filter
= WINED3D_TEXF_NONE
;
3523 if (context_gl
->gl_info
->supported
[WINED3D_GL_NORMALIZED_TEXRECT
])
3524 desc
->min_filter
= WINED3D_TEXF_POINT
;
3528 /* Enabling and disabling texture dimensions is done by texture stage state /
3529 * pixel shader setup, this function only has to bind textures and set the per
3530 * texture states. */
3531 static void sampler(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3533 struct wined3d_context_gl
*context_gl
= wined3d_context_gl(context
);
3534 unsigned int sampler_idx
= state_id
- STATE_SAMPLER(0);
3535 unsigned int mapped_stage
= context_gl
->tex_unit_map
[sampler_idx
];
3536 const struct wined3d_gl_info
*gl_info
= context_gl
->gl_info
;
3538 TRACE("Sampler %u.\n", sampler_idx
);
3540 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
)
3542 TRACE("No sampler mapped to stage %u. Returning.\n", sampler_idx
);
3546 if (mapped_stage
>= gl_info
->limits
.graphics_samplers
)
3548 wined3d_context_gl_active_texture(context_gl
, gl_info
, mapped_stage
);
3550 if (state
->textures
[sampler_idx
])
3552 struct wined3d_texture_gl
*texture_gl
= wined3d_texture_gl(state
->textures
[sampler_idx
]);
3553 const uint32_t *sampler_states
= state
->sampler_states
[sampler_idx
];
3554 struct wined3d_device
*device
= context
->device
;
3555 BOOL srgb
= is_srgb_enabled(sampler_states
);
3556 struct wined3d_sampler_desc desc
;
3557 struct wined3d_sampler
*sampler
;
3558 struct wine_rb_entry
*entry
;
3560 wined3d_sampler_desc_from_sampler_states(&desc
, context_gl
, sampler_states
, texture_gl
);
3562 wined3d_texture_gl_bind(texture_gl
, context_gl
, srgb
);
3564 if ((entry
= wine_rb_get(&device
->samplers
, &desc
)))
3566 sampler
= WINE_RB_ENTRY_VALUE(entry
, struct wined3d_sampler
, entry
);
3570 if (FAILED(wined3d_sampler_create(device
, &desc
, NULL
, &wined3d_null_parent_ops
, &sampler
)))
3572 ERR("Failed to create sampler.\n");
3575 if (wine_rb_put(&device
->samplers
, &desc
, &sampler
->entry
) == -1)
3577 ERR("Failed to insert sampler.\n");
3578 wined3d_sampler_decref(sampler
);
3583 wined3d_sampler_gl_bind(wined3d_sampler_gl(sampler
), mapped_stage
, texture_gl
, context_gl
);
3585 /* Trigger shader constant reloading (for NP2 texcoord fixup) */
3586 if (!(texture_gl
->t
.flags
& WINED3D_TEXTURE_POW2_MAT_IDENT
))
3587 context
->constant_update_mask
|= WINED3D_SHADER_CONST_PS_NP2_FIXUP
;
3591 wined3d_context_gl_bind_texture(context_gl
, GL_NONE
, 0);
3592 if (gl_info
->supported
[ARB_SAMPLER_OBJECTS
])
3594 GL_EXTCALL(glBindSampler(mapped_stage
, 0));
3595 checkGLcall("glBindSampler");
3600 void apply_pixelshader(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3606 if (!context
->last_was_pshader
)
3608 /* Former draw without a pixel shader, some samplers may be
3609 * disabled because of WINED3D_TSS_COLOR_OP = WINED3DTOP_DISABLE
3610 * make sure to enable them. */
3611 for (i
= 0; i
< WINED3D_MAX_FRAGMENT_SAMPLERS
; ++i
)
3613 if (!isStateDirty(context
, STATE_SAMPLER(i
)))
3614 sampler(context
, state
, STATE_SAMPLER(i
));
3616 context
->last_was_pshader
= TRUE
;
3620 /* Otherwise all samplers were activated by the code above in
3621 * earlier draws, or by sampler() if a different texture was
3622 * bound. I don't have to do anything. */
3627 /* Disabled the pixel shader - color ops weren't applied while it was
3628 * enabled, so re-apply them. */
3629 for (i
= 0; i
< context
->d3d_info
->limits
.ffp_blend_stages
; ++i
)
3631 if (!isStateDirty(context
, STATE_TEXTURESTAGE(i
, WINED3D_TSS_COLOR_OP
)))
3632 context_apply_state(context
, state
, STATE_TEXTURESTAGE(i
, WINED3D_TSS_COLOR_OP
));
3634 context
->last_was_pshader
= FALSE
;
3637 context
->shader_update_mask
|= 1u << WINED3D_SHADER_TYPE_PIXEL
;
3640 static void state_compute_shader(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3642 context
->shader_update_mask
|= 1u << WINED3D_SHADER_TYPE_COMPUTE
;
3645 static void state_shader(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3647 enum wined3d_shader_type shader_type
= state_id
- STATE_SHADER(0);
3648 context
->shader_update_mask
|= 1u << shader_type
;
3651 static void shader_bumpenv(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3653 context
->constant_update_mask
|= WINED3D_SHADER_CONST_PS_BUMP_ENV
;
3656 static void transform_world(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3658 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
3659 struct wined3d_matrix mat
;
3661 /* This function is called by transform_view below if the view matrix was changed too
3663 * Deliberately no check if the vertex declaration is dirty because the vdecl state
3664 * does not always update the world matrix, only on a switch between transformed
3665 * and untransformed draws. It *may* happen that the world matrix is set 2 times during one
3666 * draw, but that should be rather rare and cheaper in total.
3668 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3669 checkGLcall("glMatrixMode");
3671 get_modelview_matrix(context
, state
, 0, &mat
);
3673 gl_info
->gl_ops
.gl
.p_glLoadMatrixf((GLfloat
*)&mat
);
3674 checkGLcall("glLoadMatrixf");
3677 void clipplane(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3679 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
3680 UINT index
= state_id
- STATE_CLIPPLANE(0);
3683 if (isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_VIEW
)) || index
>= gl_info
->limits
.user_clip_distances
)
3686 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3687 gl_info
->gl_ops
.gl
.p_glPushMatrix();
3689 /* Clip Plane settings are affected by the model view in OpenGL, the View transform in direct3d */
3691 gl_info
->gl_ops
.gl
.p_glLoadMatrixf(&state
->transforms
[WINED3D_TS_VIEW
]._11
);
3693 /* With vertex shaders, clip planes are not transformed in Direct3D,
3694 * while in OpenGL they are still transformed by the model view matrix. */
3695 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
3697 plane
[0] = state
->clip_planes
[index
].x
;
3698 plane
[1] = state
->clip_planes
[index
].y
;
3699 plane
[2] = state
->clip_planes
[index
].z
;
3700 plane
[3] = state
->clip_planes
[index
].w
;
3702 TRACE("Clipplane [%.8e, %.8e, %.8e, %.8e]\n",
3703 plane
[0], plane
[1], plane
[2], plane
[3]);
3704 gl_info
->gl_ops
.gl
.p_glClipPlane(GL_CLIP_PLANE0
+ index
, plane
);
3705 checkGLcall("glClipPlane");
3707 gl_info
->gl_ops
.gl
.p_glPopMatrix();
3710 static void transform_worldex(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3712 unsigned int matrix
= state_id
- STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0));
3714 WARN("Unsupported world matrix %u set.\n", matrix
);
3717 static void state_vertexblend_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3719 enum wined3d_vertex_blend_flags f
= state
->render_states
[WINED3D_RS_VERTEXBLEND
];
3720 static unsigned int once
;
3722 if (f
== WINED3D_VBF_DISABLE
)
3725 if (!once
++) FIXME("Vertex blend flags %#x not supported.\n", f
);
3726 else WARN("Vertex blend flags %#x not supported.\n", f
);
3729 static void transform_view(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3731 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
3732 const struct wined3d_light_info
*light
= NULL
;
3735 /* If we are changing the View matrix, reset the light and clipping planes to the new view
3736 * NOTE: We have to reset the positions even if the light/plane is not currently
3737 * enabled, since the call to enable it will not reset the position.
3738 * NOTE2: Apparently texture transforms do NOT need reapplying
3741 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3742 checkGLcall("glMatrixMode(GL_MODELVIEW)");
3743 gl_info
->gl_ops
.gl
.p_glLoadMatrixf(&state
->transforms
[WINED3D_TS_VIEW
]._11
);
3744 checkGLcall("glLoadMatrixf(...)");
3746 /* Reset lights. TODO: Call light apply func */
3747 for (k
= 0; k
< gl_info
->limits
.lights
; ++k
)
3749 if (!(light
= state
->light_state
.lights
[k
]))
3751 if (light
->OriginalParms
.type
== WINED3D_LIGHT_DIRECTIONAL
)
3752 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ light
->glIndex
, GL_POSITION
, &light
->direction
.x
);
3754 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ light
->glIndex
, GL_POSITION
, &light
->position
.x
);
3755 checkGLcall("glLightfv posn");
3756 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ light
->glIndex
, GL_SPOT_DIRECTION
, &light
->direction
.x
);
3757 checkGLcall("glLightfv dirn");
3760 /* Reset Clipping Planes */
3761 for (k
= 0; k
< gl_info
->limits
.user_clip_distances
; ++k
)
3763 if (!isStateDirty(context
, STATE_CLIPPLANE(k
)))
3764 clipplane(context
, state
, STATE_CLIPPLANE(k
));
3767 if (context
->last_was_rhw
)
3769 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
3770 checkGLcall("glLoadIdentity()");
3771 /* No need to update the world matrix, the identity is fine */
3775 /* Call the world matrix state, this will apply the combined WORLD + VIEW matrix
3776 * No need to do it here if the state is scheduled for update. */
3777 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0))))
3778 transform_world(context
, state
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0)));
3781 static void transform_projection(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3783 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
3784 struct wined3d_matrix projection
;
3786 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_PROJECTION
);
3787 checkGLcall("glMatrixMode(GL_PROJECTION)");
3789 get_projection_matrix(context
, state
, &projection
);
3790 gl_info
->gl_ops
.gl
.p_glLoadMatrixf(&projection
._11
);
3791 checkGLcall("glLoadMatrixf");
3794 static void streamsrc(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3796 wined3d_context_gl_update_stream_sources(wined3d_context_gl(context
), state
);
3799 static void vdecl_miscpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3801 if (isStateDirty(context
, STATE_STREAMSRC
))
3803 wined3d_context_gl_update_stream_sources(wined3d_context_gl(context
), state
);
3806 static void vertexdeclaration(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3808 struct wined3d_context_gl
*context_gl
= wined3d_context_gl(context
);
3809 const struct wined3d_gl_info
*gl_info
= context_gl
->gl_info
;
3810 BOOL useVertexShaderFunction
= use_vs(state
);
3811 BOOL updateFog
= FALSE
;
3813 BOOL wasrhw
= context
->last_was_rhw
;
3816 transformed
= context
->stream_info
.position_transformed
;
3817 if (transformed
!= context
->last_was_rhw
&& !useVertexShaderFunction
)
3820 context
->last_was_rhw
= transformed
;
3822 if (context
->stream_info
.swizzle_map
!= context
->last_swizzle_map
)
3823 context
->shader_update_mask
|= 1u << WINED3D_SHADER_TYPE_VERTEX
;
3825 context
->last_swizzle_map
= context
->stream_info
.swizzle_map
;
3827 /* Don't have to apply the matrices when vertex shaders are used. When
3828 * vshaders are turned off this function will be called again anyway to
3829 * make sure they're properly set. */
3830 if (!useVertexShaderFunction
)
3832 /* TODO: Move this mainly to the viewport state and only apply when
3833 * the vp has changed or transformed / untransformed was switched. */
3834 if (wasrhw
!= context
->last_was_rhw
3835 && !isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
))
3836 && !isStateDirty(context
, STATE_VIEWPORT
))
3837 transform_projection(context
, state
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
));
3838 /* World matrix needs reapplication here only if we're switching between rhw and non-rhw
3841 * If a vertex shader is used, the world matrix changed and then vertex shader unbound
3842 * this check will fail and the matrix not applied again. This is OK because a simple
3843 * world matrix change reapplies the matrix - These checks here are only to satisfy the
3844 * needs of the vertex declaration.
3846 * World and view matrix go into the same gl matrix, so only apply them when neither is
3849 if (transformed
!= wasrhw
&& !isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0)))
3850 && !isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_VIEW
)))
3851 transform_world(context
, state
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0)));
3852 if (!isStateDirty(context
, STATE_RENDER(WINED3D_RS_COLORVERTEX
)))
3853 context_apply_state(context
, state
, STATE_RENDER(WINED3D_RS_COLORVERTEX
));
3854 if (!isStateDirty(context
, STATE_RENDER(WINED3D_RS_LIGHTING
)))
3855 state_lighting(context
, state
, STATE_RENDER(WINED3D_RS_LIGHTING
));
3857 if (context
->last_was_vshader
)
3861 if (!context
->d3d_info
->vs_clipping
3862 && !isStateDirty(context
, STATE_RENDER(WINED3D_RS_CLIPPLANEENABLE
)))
3864 state_clipping(context
, state
, STATE_RENDER(WINED3D_RS_CLIPPLANEENABLE
));
3867 for (i
= 0; i
< gl_info
->limits
.user_clip_distances
; ++i
)
3869 clipplane(context
, state
, STATE_CLIPPLANE(i
));
3872 if (!isStateDirty(context
, STATE_RENDER(WINED3D_RS_NORMALIZENORMALS
)))
3873 state_normalize(context
, state
, STATE_RENDER(WINED3D_RS_NORMALIZENORMALS
));
3877 if (!context
->last_was_vshader
)
3879 static BOOL warned
= FALSE
;
3880 if (!context
->d3d_info
->vs_clipping
)
3882 /* Disable all clip planes to get defined results on all drivers. See comment in the
3883 * state_clipping state handler
3885 wined3d_context_gl_enable_clip_distances(context_gl
, 0);
3887 if (!warned
&& state
->render_states
[WINED3D_RS_CLIPPLANEENABLE
])
3889 FIXME("Clipping not supported with vertex shaders.\n");
3895 /* Apply the transform matrices when switching from rhw
3896 * drawing to vertex shaders. Vertex shaders themselves do
3897 * not need it, but the matrices are not reapplied
3898 * automatically when switching back from vertex shaders to
3899 * fixed function processing. So make sure we leave the fixed
3900 * function vertex processing states back in a sane state
3901 * before switching to shaders. */
3902 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
)))
3903 transform_projection(context
, state
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
));
3904 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0))))
3905 transform_world(context
, state
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0)));
3909 /* Vertex shader clipping ignores the view matrix. Update all clipplanes
3910 * (Note: ARB shaders can read the clip planes for clipping emulation even if
3911 * device->vs_clipping is false.
3913 for (i
= 0; i
< gl_info
->limits
.user_clip_distances
; ++i
)
3915 clipplane(context
, state
, STATE_CLIPPLANE(i
));
3920 context
->last_was_vshader
= useVertexShaderFunction
;
3921 context
->shader_update_mask
|= 1u << WINED3D_SHADER_TYPE_VERTEX
;
3924 context_apply_state(context
, state
, STATE_RENDER(WINED3D_RS_FOGVERTEXMODE
));
3926 if (!useVertexShaderFunction
)
3930 for (i
= 0; i
< WINED3D_MAX_TEXTURES
; ++i
)
3932 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_TEXTURE0
+ i
)))
3933 transform_texture(context
, state
, STATE_TEXTURESTAGE(i
, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
));
3936 if (use_ps(state
) && state
->shader
[WINED3D_SHADER_TYPE_PIXEL
]->reg_maps
.shader_version
.major
== 1
3937 && state
->shader
[WINED3D_SHADER_TYPE_PIXEL
]->reg_maps
.shader_version
.minor
<= 3)
3938 context
->shader_update_mask
|= 1u << WINED3D_SHADER_TYPE_PIXEL
;
3942 static void get_viewports(struct wined3d_context
*context
, const struct wined3d_state
*state
,
3943 unsigned int viewport_count
, struct wined3d_viewport
*viewports
)
3945 const struct wined3d_rendertarget_view
*depth_stencil
= state
->fb
.depth_stencil
;
3946 const struct wined3d_rendertarget_view
*target
= state
->fb
.render_targets
[0];
3947 unsigned int width
, height
, i
;
3949 for (i
= 0; i
< viewport_count
; ++i
)
3950 viewports
[i
] = state
->viewports
[i
];
3952 /* Note: GL uses a lower left origin while DirectX uses upper left. This
3953 * is reversed when using offscreen rendering. */
3954 if (context
->render_offscreen
)
3959 wined3d_rendertarget_view_get_drawable_size(target
, context
, &width
, &height
);
3961 else if (depth_stencil
)
3963 height
= depth_stencil
->height
;
3967 FIXME("Could not get the height of render targets.\n");
3971 for (i
= 0; i
< viewport_count
; ++i
)
3972 viewports
[i
].y
= height
- (viewports
[i
].y
+ viewports
[i
].height
);
3975 static void viewport_miscpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3977 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
3978 struct wined3d_viewport vp
[WINED3D_MAX_VIEWPORTS
];
3981 if (gl_info
->supported
[ARB_VIEWPORT_ARRAY
])
3983 GLdouble depth_ranges
[2 * WINED3D_MAX_VIEWPORTS
];
3984 GLfloat viewports
[4 * WINED3D_MAX_VIEWPORTS
];
3986 unsigned int i
, reset_count
= 0;
3988 get_viewports(context
, state
, state
->viewport_count
, vp
);
3989 for (i
= 0; i
< state
->viewport_count
; ++i
)
3991 wined3d_viewport_get_z_range(&vp
[i
], &min_z
, &max_z
);
3992 depth_ranges
[i
* 2] = min_z
;
3993 depth_ranges
[i
* 2 + 1] = max_z
;
3995 viewports
[i
* 4] = vp
[i
].x
;
3996 viewports
[i
* 4 + 1] = vp
[i
].y
;
3997 viewports
[i
* 4 + 2] = vp
[i
].width
;
3998 viewports
[i
* 4 + 3] = vp
[i
].height
;
4000 /* Don't pass fractionals to GL if we earlier decided not to use
4001 * this functionality for two reasons: First, GL might offer us
4002 * fewer than 8 bits, and still make use of the fractional, in
4003 * addition to the emulation we apply in shader_get_position_fixup.
4004 * Second, even if GL tells us it has no subpixel precision (Mac OS!)
4005 * it might still do something with the fractional amount, e.g.
4006 * round it upwards. I can't find any info on rounding in
4007 * GL_ARB_viewport_array. */
4008 if (!context
->d3d_info
->subpixel_viewport
)
4010 viewports
[i
* 4] = floor(viewports
[i
* 4]);
4011 viewports
[i
* 4 + 1] = floor(viewports
[i
* 4 + 1]);
4012 viewports
[i
* 4 + 2] = floor(viewports
[i
* 4 + 2]);
4013 viewports
[i
* 4 + 3] = floor(viewports
[i
* 4 + 3]);
4017 if (context
->viewport_count
> state
->viewport_count
)
4018 reset_count
= context
->viewport_count
- state
->viewport_count
;
4022 memset(&depth_ranges
[state
->viewport_count
* 2], 0, reset_count
* 2 * sizeof(*depth_ranges
));
4023 memset(&viewports
[state
->viewport_count
* 4], 0, reset_count
* 4 * sizeof(*viewports
));
4026 GL_EXTCALL(glDepthRangeArrayv(0, state
->viewport_count
+ reset_count
, depth_ranges
));
4027 GL_EXTCALL(glViewportArrayv(0, state
->viewport_count
+ reset_count
, viewports
));
4028 context
->viewport_count
= state
->viewport_count
;
4032 get_viewports(context
, state
, 1, vp
);
4033 wined3d_viewport_get_z_range(&vp
[0], &min_z
, &max_z
);
4034 gl_info
->gl_ops
.gl
.p_glDepthRange(min_z
, max_z
);
4035 gl_info
->gl_ops
.gl
.p_glViewport(vp
[0].x
, vp
[0].y
, vp
[0].width
, vp
[0].height
);
4037 checkGLcall("setting clip space and viewport");
4040 static void viewport_miscpart_cc(struct wined3d_context
*context
,
4041 const struct wined3d_state
*state
, DWORD state_id
)
4043 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
4044 /* See get_projection_matrix() in utils.c for a discussion about those values. */
4045 float pixel_center_offset
= context
->d3d_info
->wined3d_creation_flags
4046 & WINED3D_PIXEL_CENTER_INTEGER
? 0.5f
: 0.0f
;
4047 struct wined3d_viewport vp
[WINED3D_MAX_VIEWPORTS
];
4048 GLdouble depth_ranges
[2 * WINED3D_MAX_VIEWPORTS
];
4049 GLfloat viewports
[4 * WINED3D_MAX_VIEWPORTS
];
4050 unsigned int i
, reset_count
= 0;
4053 pixel_center_offset
+= context
->d3d_info
->filling_convention_offset
/ 2.0f
;
4054 get_viewports(context
, state
, state
->viewport_count
, vp
);
4056 GL_EXTCALL(glClipControl(context
->render_offscreen
? GL_UPPER_LEFT
: GL_LOWER_LEFT
, GL_ZERO_TO_ONE
));
4058 for (i
= 0; i
< state
->viewport_count
; ++i
)
4060 wined3d_viewport_get_z_range(&vp
[i
], &min_z
, &max_z
);
4061 depth_ranges
[i
* 2] = min_z
;
4062 depth_ranges
[i
* 2 + 1] = max_z
;
4064 viewports
[i
* 4] = vp
[i
].x
+ pixel_center_offset
;
4065 viewports
[i
* 4 + 1] = vp
[i
].y
+ pixel_center_offset
;
4066 viewports
[i
* 4 + 2] = vp
[i
].width
;
4067 viewports
[i
* 4 + 3] = vp
[i
].height
;
4070 if (context
->viewport_count
> state
->viewport_count
)
4071 reset_count
= context
->viewport_count
- state
->viewport_count
;
4075 memset(&depth_ranges
[state
->viewport_count
* 2], 0, reset_count
* 2 * sizeof(*depth_ranges
));
4076 memset(&viewports
[state
->viewport_count
* 4], 0, reset_count
* 4 * sizeof(*viewports
));
4079 GL_EXTCALL(glDepthRangeArrayv(0, state
->viewport_count
+ reset_count
, depth_ranges
));
4080 GL_EXTCALL(glViewportArrayv(0, state
->viewport_count
+ reset_count
, viewports
));
4081 context
->viewport_count
= state
->viewport_count
;
4083 checkGLcall("setting clip space and viewport");
4086 static void viewport_vertexpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4088 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
)))
4089 transform_projection(context
, state
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
));
4090 if (!isStateDirty(context
, STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
))
4091 && state
->render_states
[WINED3D_RS_POINTSCALEENABLE
])
4092 state_pscale(context
, state
, STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
));
4093 /* Update the position fixup. */
4094 context
->constant_update_mask
|= WINED3D_SHADER_CONST_POS_FIXUP
;
4097 static void light(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4099 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
4100 UINT Index
= state_id
- STATE_ACTIVELIGHT(0);
4101 const struct wined3d_light_info
*lightInfo
= state
->light_state
.lights
[Index
];
4105 gl_info
->gl_ops
.gl
.p_glDisable(GL_LIGHT0
+ Index
);
4106 checkGLcall("glDisable(GL_LIGHT0 + Index)");
4112 /* Light settings are affected by the model view in OpenGL, the View transform in direct3d*/
4113 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
4114 gl_info
->gl_ops
.gl
.p_glPushMatrix();
4115 gl_info
->gl_ops
.gl
.p_glLoadMatrixf(&state
->transforms
[WINED3D_TS_VIEW
]._11
);
4117 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_DIFFUSE
, &lightInfo
->OriginalParms
.diffuse
.r
);
4118 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_SPECULAR
, &lightInfo
->OriginalParms
.specular
.r
);
4119 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_AMBIENT
, &lightInfo
->OriginalParms
.ambient
.r
);
4120 checkGLcall("glLightfv");
4122 if ((lightInfo
->OriginalParms
.range
* lightInfo
->OriginalParms
.range
) >= FLT_MIN
)
4123 quad_att
= 1.4f
/ (lightInfo
->OriginalParms
.range
* lightInfo
->OriginalParms
.range
);
4125 quad_att
= 0.0f
; /* 0 or MAX? (0 seems to be ok) */
4127 /* Do not assign attenuation values for lights that do not use them. D3D apps are free to pass any junk,
4128 * but gl drivers use them and may crash due to bad Attenuation values. Need for Speed most wanted sets
4129 * Attenuation0 to NaN and crashes in the gl lib
4132 switch (lightInfo
->OriginalParms
.type
)
4134 case WINED3D_LIGHT_POINT
:
4136 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->position
.x
);
4137 checkGLcall("glLightfv");
4138 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
4139 checkGLcall("glLightf");
4140 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_CONSTANT_ATTENUATION
,
4141 lightInfo
->OriginalParms
.attenuation0
);
4142 checkGLcall("glLightf");
4143 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_LINEAR_ATTENUATION
,
4144 lightInfo
->OriginalParms
.attenuation1
);
4145 checkGLcall("glLightf");
4146 if (quad_att
< lightInfo
->OriginalParms
.attenuation2
)
4147 quad_att
= lightInfo
->OriginalParms
.attenuation2
;
4148 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_QUADRATIC_ATTENUATION
, quad_att
);
4149 checkGLcall("glLightf");
4153 case WINED3D_LIGHT_SPOT
:
4155 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->position
.x
);
4156 checkGLcall("glLightfv");
4158 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_SPOT_DIRECTION
, &lightInfo
->direction
.x
);
4159 checkGLcall("glLightfv");
4160 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_SPOT_EXPONENT
, lightInfo
->exponent
);
4161 checkGLcall("glLightf");
4162 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
4163 checkGLcall("glLightf");
4164 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_CONSTANT_ATTENUATION
,
4165 lightInfo
->OriginalParms
.attenuation0
);
4166 checkGLcall("glLightf");
4167 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_LINEAR_ATTENUATION
,
4168 lightInfo
->OriginalParms
.attenuation1
);
4169 checkGLcall("glLightf");
4170 if (quad_att
< lightInfo
->OriginalParms
.attenuation2
)
4171 quad_att
= lightInfo
->OriginalParms
.attenuation2
;
4172 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_QUADRATIC_ATTENUATION
, quad_att
);
4173 checkGLcall("glLightf");
4177 case WINED3D_LIGHT_DIRECTIONAL
:
4179 /* Note GL uses w position of 0 for direction! */
4180 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->direction
.x
);
4181 checkGLcall("glLightfv");
4182 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
4183 checkGLcall("glLightf");
4184 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_SPOT_EXPONENT
, 0.0f
);
4185 checkGLcall("glLightf");
4189 FIXME("Unrecognized light type %#x.\n", lightInfo
->OriginalParms
.type
);
4192 /* Restore the modelview matrix */
4193 gl_info
->gl_ops
.gl
.p_glPopMatrix();
4195 gl_info
->gl_ops
.gl
.p_glEnable(GL_LIGHT0
+ Index
);
4196 checkGLcall("glEnable(GL_LIGHT0 + Index)");
4200 static void scissorrect(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4202 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
4203 unsigned int height
= 0;
4206 /* Warning: glScissor uses window coordinates, not viewport coordinates,
4207 * so our viewport correction does not apply. Warning2: Even in windowed
4208 * mode the coords are relative to the window, not the screen. */
4210 if (!context
->render_offscreen
)
4212 const struct wined3d_rendertarget_view
*target
= state
->fb
.render_targets
[0];
4215 wined3d_rendertarget_view_get_drawable_size(target
, context
, &width
, &height
);
4218 if (gl_info
->supported
[ARB_VIEWPORT_ARRAY
])
4220 GLint sr
[4 * WINED3D_MAX_VIEWPORTS
];
4221 unsigned int i
, reset_count
= 0;
4223 for (i
= 0; i
< state
->scissor_rect_count
; ++i
)
4225 r
= &state
->scissor_rects
[i
];
4227 sr
[i
* 4] = r
->left
;
4228 sr
[i
* 4 + 1] = height
? height
- r
->top
: r
->top
;
4229 sr
[i
* 4 + 2] = r
->right
- r
->left
;
4230 sr
[i
* 4 + 3] = r
->bottom
- r
->top
;
4233 if (context
->scissor_rect_count
> state
->scissor_rect_count
)
4234 reset_count
= context
->scissor_rect_count
- state
->scissor_rect_count
;
4237 memset(&sr
[state
->scissor_rect_count
* 4], 0, reset_count
* 4 * sizeof(GLint
));
4239 GL_EXTCALL(glScissorArrayv(0, state
->scissor_rect_count
+ reset_count
, sr
));
4240 checkGLcall("glScissorArrayv");
4241 context
->scissor_rect_count
= state
->scissor_rect_count
;
4245 r
= &state
->scissor_rects
[0];
4246 gl_info
->gl_ops
.gl
.p_glScissor(r
->left
, height
? height
- r
->top
: r
->top
,
4247 r
->right
- r
->left
, r
->bottom
- r
->top
);
4248 checkGLcall("glScissor");
4252 static void indexbuffer(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4254 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
4255 const struct wined3d_stream_info
*stream_info
= &context
->stream_info
;
4256 struct wined3d_buffer
*buffer
;
4258 if (!state
->index_buffer
|| !stream_info
->all_vbo
)
4260 GL_EXTCALL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER
, 0));
4264 buffer
= state
->index_buffer
;
4265 if (buffer
->buffer_object
)
4267 GL_EXTCALL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER
, wined3d_bo_gl(buffer
->buffer_object
)->id
));
4268 wined3d_buffer_validate_user(buffer
);
4272 GL_EXTCALL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER
, 0));
4276 static void depth_clip(const struct wined3d_rasterizer_state
*r
, const struct wined3d_gl_info
*gl_info
)
4278 if (!gl_info
->supported
[ARB_DEPTH_CLAMP
])
4280 if (r
&& !r
->desc
.depth_clip
)
4281 FIXME("Depth clamp not supported by this GL implementation.\n");
4285 if (r
&& !r
->desc
.depth_clip
)
4286 gl_info
->gl_ops
.gl
.p_glEnable(GL_DEPTH_CLAMP
);
4288 gl_info
->gl_ops
.gl
.p_glDisable(GL_DEPTH_CLAMP
);
4289 checkGLcall("depth clip");
4292 static void rasterizer(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4294 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
4295 const struct wined3d_rasterizer_state
*r
= state
->rasterizer_state
;
4298 mode
= r
&& r
->desc
.front_ccw
? GL_CCW
: GL_CW
;
4299 if (context
->render_offscreen
)
4300 mode
= (mode
== GL_CW
) ? GL_CCW
: GL_CW
;
4302 gl_info
->gl_ops
.gl
.p_glFrontFace(mode
);
4303 checkGLcall("glFrontFace");
4304 depthbias(context
, state
);
4305 fillmode(r
, gl_info
);
4306 cullmode(r
, gl_info
);
4307 depth_clip(r
, gl_info
);
4308 scissor(r
, gl_info
);
4309 line_antialias(r
, gl_info
);
4312 static void rasterizer_cc(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4314 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
4315 const struct wined3d_rasterizer_state
*r
= state
->rasterizer_state
;
4318 mode
= r
&& r
->desc
.front_ccw
? GL_CCW
: GL_CW
;
4320 gl_info
->gl_ops
.gl
.p_glFrontFace(mode
);
4321 checkGLcall("glFrontFace");
4322 depthbias(context
, state
);
4323 fillmode(r
, gl_info
);
4324 cullmode(r
, gl_info
);
4325 depth_clip(r
, gl_info
);
4326 scissor(r
, gl_info
);
4327 line_antialias(r
, gl_info
);
4330 static void psorigin_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4336 WARN("Point sprite coordinate origin switching not supported.\n");
4341 static void psorigin(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4343 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
4344 GLint origin
= context
->render_offscreen
? GL_LOWER_LEFT
: GL_UPPER_LEFT
;
4346 GL_EXTCALL(glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN
, origin
));
4347 checkGLcall("glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, ...)");
4350 void state_srgbwrite(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4352 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
4354 TRACE("context %p, state %p, state_id %#lx.\n", context
, state
, state_id
);
4356 if (needs_srgb_write(context
->d3d_info
, state
, &state
->fb
))
4357 gl_info
->gl_ops
.gl
.p_glEnable(GL_FRAMEBUFFER_SRGB
);
4359 gl_info
->gl_ops
.gl
.p_glDisable(GL_FRAMEBUFFER_SRGB
);
4362 static void state_cb(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4364 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl(context
)->gl_info
;
4365 enum wined3d_shader_type shader_type
;
4366 struct wined3d_buffer
*buffer
;
4367 unsigned int i
, base
, count
;
4368 struct wined3d_bo_gl
*bo_gl
;
4370 TRACE("context %p, state %p, state_id %#lx.\n", context
, state
, state_id
);
4372 if (STATE_IS_GRAPHICS_CONSTANT_BUFFER(state_id
))
4373 shader_type
= state_id
- STATE_GRAPHICS_CONSTANT_BUFFER(0);
4375 shader_type
= WINED3D_SHADER_TYPE_COMPUTE
;
4377 /* If a shader has not been set, buffer objects are not yet initialised. */
4378 if (!state
->shader
[shader_type
])
4381 wined3d_gl_limits_get_uniform_block_range(&gl_info
->limits
, shader_type
, &base
, &count
);
4382 for (i
= 0; i
< count
; ++i
)
4384 const struct wined3d_constant_buffer_state
*buffer_state
= &state
->cb
[shader_type
][i
];
4386 if (!buffer_state
->buffer
)
4388 GL_EXTCALL(glBindBufferBase(GL_UNIFORM_BUFFER
, base
+ i
, 0));
4392 buffer
= buffer_state
->buffer
;
4393 bo_gl
= wined3d_bo_gl(buffer
->buffer_object
);
4394 GL_EXTCALL(glBindBufferRange(GL_UNIFORM_BUFFER
, base
+ i
,
4395 bo_gl
->id
, bo_gl
->b
.buffer_offset
+ buffer_state
->offset
,
4396 min(buffer_state
->size
, buffer
->resource
.size
- buffer_state
->offset
)));
4398 wined3d_buffer_validate_user(buffer
);
4400 checkGLcall("bind constant buffers");
4403 static void state_cb_warn(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4405 TRACE("context %p, state %p, state_id %#lx.\n", context
, state
, state_id
);
4407 WARN("Constant buffers (%s) no supported.\n", debug_d3dstate(state_id
));
4410 static void state_shader_resource_binding(struct wined3d_context
*context
,
4411 const struct wined3d_state
*state
, DWORD state_id
)
4413 TRACE("context %p, state %p, state_id %#lx.\n", context
, state
, state_id
);
4415 context
->update_shader_resource_bindings
= 1;
4418 static void state_cs_resource_binding(struct wined3d_context
*context
,
4419 const struct wined3d_state
*state
, DWORD state_id
)
4421 TRACE("context %p, state %p, state_id %#lx.\n", context
, state
, state_id
);
4422 context
->update_compute_shader_resource_bindings
= 1;
4425 static void state_uav_binding(struct wined3d_context
*context
,
4426 const struct wined3d_state
*state
, DWORD state_id
)
4428 TRACE("context %p, state %p, state_id %#lx.\n", context
, state
, state_id
);
4429 context
->update_unordered_access_view_bindings
= 1;
4432 static void state_cs_uav_binding(struct wined3d_context
*context
,
4433 const struct wined3d_state
*state
, DWORD state_id
)
4435 TRACE("context %p, state %p, state_id %#lx.\n", context
, state
, state_id
);
4436 context
->update_compute_unordered_access_view_bindings
= 1;
4439 static void state_uav_warn(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4441 WARN("ARB_shader_image_load_store is not supported by this OpenGL implementation.\n");
4444 static void state_so(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4446 struct wined3d_context_gl
*context_gl
= wined3d_context_gl(context
);
4447 const struct wined3d_gl_info
*gl_info
= context_gl
->gl_info
;
4448 struct wined3d_buffer
*buffer
;
4449 unsigned int offset
, size
, i
;
4450 struct wined3d_bo_gl
*bo_gl
;
4452 TRACE("context %p, state %p, state_id %#lx.\n", context
, state
, state_id
);
4454 wined3d_context_gl_end_transform_feedback(context_gl
);
4456 for (i
= 0; i
< ARRAY_SIZE(state
->stream_output
); ++i
)
4458 if (!state
->stream_output
[i
].buffer
)
4460 GL_EXTCALL(glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER
, i
, 0));
4464 buffer
= state
->stream_output
[i
].buffer
;
4465 offset
= state
->stream_output
[i
].offset
;
4466 bo_gl
= wined3d_bo_gl(buffer
->buffer_object
);
4469 FIXME("Appending to stream output buffers not implemented.\n");
4472 size
= buffer
->resource
.size
- offset
;
4473 GL_EXTCALL(glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER
, i
,
4474 bo_gl
->id
, bo_gl
->b
.buffer_offset
+ offset
, size
));
4475 wined3d_buffer_validate_user(buffer
);
4477 checkGLcall("bind transform feedback buffers");
4480 static void state_so_warn(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4482 WARN("Transform feedback not supported.\n");
4485 const struct wined3d_state_entry_template misc_state_template_gl
[] =
4487 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX
), state_cb
, }, ARB_UNIFORM_BUFFER_OBJECT
},
4488 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX
), state_cb_warn
, }, WINED3D_GL_EXT_NONE
},
4489 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_HULL
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_HULL
), state_cb
, }, ARB_UNIFORM_BUFFER_OBJECT
},
4490 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_HULL
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_HULL
), state_cb_warn
, }, WINED3D_GL_EXT_NONE
},
4491 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_DOMAIN
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_DOMAIN
), state_cb
, }, ARB_UNIFORM_BUFFER_OBJECT
},
4492 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_DOMAIN
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_DOMAIN
), state_cb_warn
, }, WINED3D_GL_EXT_NONE
},
4493 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY
),{ STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY
),state_cb
, }, ARB_UNIFORM_BUFFER_OBJECT
},
4494 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY
),{ STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY
),state_cb_warn
, }, WINED3D_GL_EXT_NONE
},
4495 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL
), state_cb
, }, ARB_UNIFORM_BUFFER_OBJECT
},
4496 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL
), state_cb_warn
, }, WINED3D_GL_EXT_NONE
},
4497 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_COMPUTE
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_COMPUTE
), state_cb
, }, ARB_UNIFORM_BUFFER_OBJECT
},
4498 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_COMPUTE
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_COMPUTE
), state_cb_warn
, }, WINED3D_GL_EXT_NONE
},
4499 { STATE_GRAPHICS_SHADER_RESOURCE_BINDING
, { STATE_GRAPHICS_SHADER_RESOURCE_BINDING
, state_shader_resource_binding
}, WINED3D_GL_EXT_NONE
},
4500 { STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING
, { STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING
, state_uav_binding
}, ARB_SHADER_IMAGE_LOAD_STORE
},
4501 { STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING
, { STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING
, state_uav_warn
}, WINED3D_GL_EXT_NONE
},
4502 { STATE_COMPUTE_SHADER_RESOURCE_BINDING
, { STATE_COMPUTE_SHADER_RESOURCE_BINDING
, state_cs_resource_binding
}, WINED3D_GL_EXT_NONE
},
4503 { STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING
, { STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING
, state_cs_uav_binding
}, ARB_SHADER_IMAGE_LOAD_STORE
},
4504 { STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING
, { STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING
, state_uav_warn
}, WINED3D_GL_EXT_NONE
},
4505 { STATE_STREAM_OUTPUT
, { STATE_STREAM_OUTPUT
, state_so
, }, WINED3D_GL_VERSION_3_2
},
4506 { STATE_STREAM_OUTPUT
, { STATE_STREAM_OUTPUT
, state_so_warn
, }, WINED3D_GL_EXT_NONE
},
4507 { STATE_BLEND
, { STATE_BLEND
, blend_dbb
}, ARB_DRAW_BUFFERS_BLEND
},
4508 { STATE_BLEND
, { STATE_BLEND
, blend_db2
}, EXT_DRAW_BUFFERS2
},
4509 { STATE_BLEND
, { STATE_BLEND
, blend
}, WINED3D_GL_EXT_NONE
},
4510 { STATE_BLEND_FACTOR
, { STATE_BLEND_FACTOR
, state_blend_factor
}, EXT_BLEND_COLOR
},
4511 { STATE_BLEND_FACTOR
, { STATE_BLEND_FACTOR
, state_blend_factor_w
}, WINED3D_GL_EXT_NONE
},
4512 { STATE_SAMPLE_MASK
, { STATE_SAMPLE_MASK
, state_sample_mask
}, ARB_TEXTURE_MULTISAMPLE
},
4513 { STATE_SAMPLE_MASK
, { STATE_SAMPLE_MASK
, state_sample_mask_w
}, WINED3D_GL_EXT_NONE
},
4514 { STATE_DEPTH_STENCIL
, { STATE_DEPTH_STENCIL
, depth_stencil_2s
}, EXT_STENCIL_TWO_SIDE
},
4515 { STATE_DEPTH_STENCIL
, { STATE_DEPTH_STENCIL
, depth_stencil
}, WINED3D_GL_EXT_NONE
},
4516 { STATE_STENCIL_REF
, { STATE_DEPTH_STENCIL
, NULL
}, WINED3D_GL_EXT_NONE
},
4517 { STATE_DEPTH_BOUNDS
, { STATE_DEPTH_STENCIL
, NULL
}, WINED3D_GL_EXT_NONE
},
4518 { STATE_STREAMSRC
, { STATE_STREAMSRC
, streamsrc
}, WINED3D_GL_EXT_NONE
},
4519 { STATE_VDECL
, { STATE_VDECL
, vdecl_miscpart
}, WINED3D_GL_EXT_NONE
},
4520 { STATE_RASTERIZER
, { STATE_RASTERIZER
, rasterizer_cc
}, ARB_CLIP_CONTROL
},
4521 { STATE_RASTERIZER
, { STATE_RASTERIZER
, rasterizer
}, WINED3D_GL_EXT_NONE
},
4522 { STATE_SCISSORRECT
, { STATE_SCISSORRECT
, scissorrect
}, WINED3D_GL_EXT_NONE
},
4523 { STATE_POINTSPRITECOORDORIGIN
, { STATE_POINTSPRITECOORDORIGIN
, state_nop
}, ARB_CLIP_CONTROL
},
4524 { STATE_POINTSPRITECOORDORIGIN
, { STATE_POINTSPRITECOORDORIGIN
, psorigin
}, WINED3D_GL_VERSION_2_0
},
4525 { STATE_POINTSPRITECOORDORIGIN
, { STATE_POINTSPRITECOORDORIGIN
, psorigin_w
}, WINED3D_GL_EXT_NONE
},
4527 /* TODO: Move shader constant loading to vertex and fragment pipeline respectively, as soon as the pshader and
4528 * vshader loadings are untied from each other
4530 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4531 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4532 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4533 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4534 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4535 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4536 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4537 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4538 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4539 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4540 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4541 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4542 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4543 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4544 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4545 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4546 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4547 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4548 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4549 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4550 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4551 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4552 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4553 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4554 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4555 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4556 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4557 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4558 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4559 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4560 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4561 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4562 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4563 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4564 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4565 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4566 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4567 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4568 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4569 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4570 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4571 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4572 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4573 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4574 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4575 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4576 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4577 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4579 { STATE_VIEWPORT
, { STATE_VIEWPORT
, viewport_miscpart_cc
}, ARB_CLIP_CONTROL
},
4580 { STATE_VIEWPORT
, { STATE_VIEWPORT
, viewport_miscpart
}, WINED3D_GL_EXT_NONE
},
4581 { STATE_INDEXBUFFER
, { STATE_INDEXBUFFER
, indexbuffer
}, ARB_VERTEX_BUFFER_OBJECT
},
4582 { STATE_INDEXBUFFER
, { STATE_INDEXBUFFER
, state_nop
}, WINED3D_GL_EXT_NONE
},
4583 { STATE_RENDER(WINED3D_RS_LINEPATTERN
), { STATE_RENDER(WINED3D_RS_LINEPATTERN
), state_linepattern
}, WINED3D_GL_LEGACY_CONTEXT
},
4584 { STATE_RENDER(WINED3D_RS_LINEPATTERN
), { STATE_RENDER(WINED3D_RS_LINEPATTERN
), state_linepattern_w
}, WINED3D_GL_EXT_NONE
},
4585 { STATE_RENDER(WINED3D_RS_DITHERENABLE
), { STATE_RENDER(WINED3D_RS_DITHERENABLE
), state_ditherenable
}, WINED3D_GL_EXT_NONE
},
4586 { STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS
), { STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS
), state_msaa
}, ARB_MULTISAMPLE
},
4587 { STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS
), { STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS
), state_msaa_w
}, WINED3D_GL_EXT_NONE
},
4589 { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler
}, WINED3D_GL_EXT_NONE
},
4590 { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler
}, WINED3D_GL_EXT_NONE
},
4591 { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler
}, WINED3D_GL_EXT_NONE
},
4592 { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler
}, WINED3D_GL_EXT_NONE
},
4593 { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler
}, WINED3D_GL_EXT_NONE
},
4594 { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler
}, WINED3D_GL_EXT_NONE
},
4595 { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler
}, WINED3D_GL_EXT_NONE
},
4596 { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler
}, WINED3D_GL_EXT_NONE
},
4597 { STATE_SAMPLER(8), { STATE_SAMPLER(8), sampler
}, WINED3D_GL_EXT_NONE
},
4598 { STATE_SAMPLER(9), { STATE_SAMPLER(9), sampler
}, WINED3D_GL_EXT_NONE
},
4599 { STATE_SAMPLER(10), { STATE_SAMPLER(10), sampler
}, WINED3D_GL_EXT_NONE
},
4600 { STATE_SAMPLER(11), { STATE_SAMPLER(11), sampler
}, WINED3D_GL_EXT_NONE
},
4601 { STATE_SAMPLER(12), { STATE_SAMPLER(12), sampler
}, WINED3D_GL_EXT_NONE
},
4602 { STATE_SAMPLER(13), { STATE_SAMPLER(13), sampler
}, WINED3D_GL_EXT_NONE
},
4603 { STATE_SAMPLER(14), { STATE_SAMPLER(14), sampler
}, WINED3D_GL_EXT_NONE
},
4604 { STATE_SAMPLER(15), { STATE_SAMPLER(15), sampler
}, WINED3D_GL_EXT_NONE
},
4605 { STATE_SAMPLER(16), /* Vertex sampler 0 */ { STATE_SAMPLER(16), sampler
}, WINED3D_GL_EXT_NONE
},
4606 { STATE_SAMPLER(17), /* Vertex sampler 1 */ { STATE_SAMPLER(17), sampler
}, WINED3D_GL_EXT_NONE
},
4607 { STATE_SAMPLER(18), /* Vertex sampler 2 */ { STATE_SAMPLER(18), sampler
}, WINED3D_GL_EXT_NONE
},
4608 { STATE_SAMPLER(19), /* Vertex sampler 3 */ { STATE_SAMPLER(19), sampler
}, WINED3D_GL_EXT_NONE
},
4609 { STATE_BASEVERTEXINDEX
, { STATE_BASEVERTEXINDEX
, state_nop
, }, ARB_DRAW_ELEMENTS_BASE_VERTEX
},
4610 { STATE_BASEVERTEXINDEX
, { STATE_STREAMSRC
, NULL
, }, WINED3D_GL_EXT_NONE
},
4611 { STATE_FRAMEBUFFER
, { STATE_FRAMEBUFFER
, context_state_fb
}, WINED3D_GL_EXT_NONE
},
4612 { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
), context_state_drawbuf
},WINED3D_GL_EXT_NONE
},
4613 { STATE_SHADER(WINED3D_SHADER_TYPE_HULL
), { STATE_SHADER(WINED3D_SHADER_TYPE_HULL
), state_shader
}, WINED3D_GL_EXT_NONE
},
4614 { STATE_SHADER(WINED3D_SHADER_TYPE_DOMAIN
), { STATE_SHADER(WINED3D_SHADER_TYPE_DOMAIN
), state_shader
}, WINED3D_GL_EXT_NONE
},
4615 { STATE_SHADER(WINED3D_SHADER_TYPE_GEOMETRY
), { STATE_SHADER(WINED3D_SHADER_TYPE_GEOMETRY
), state_shader
}, WINED3D_GL_EXT_NONE
},
4616 { STATE_SHADER(WINED3D_SHADER_TYPE_COMPUTE
), { STATE_SHADER(WINED3D_SHADER_TYPE_COMPUTE
), state_compute_shader
}, WINED3D_GL_EXT_NONE
},
4617 {0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE
},
4620 static const struct wined3d_state_entry_template vp_ffp_states
[] =
4622 { STATE_VDECL
, { STATE_VDECL
, vertexdeclaration
}, WINED3D_GL_EXT_NONE
},
4623 { STATE_SHADER(WINED3D_SHADER_TYPE_VERTEX
), { STATE_VDECL
, NULL
}, WINED3D_GL_EXT_NONE
},
4624 { STATE_MATERIAL
, { STATE_RENDER(WINED3D_RS_SPECULARENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4625 { STATE_RENDER(WINED3D_RS_SPECULARENABLE
), { STATE_RENDER(WINED3D_RS_SPECULARENABLE
), state_specularenable
}, WINED3D_GL_EXT_NONE
},
4627 { STATE_CLIPPLANE(0), { STATE_CLIPPLANE(0), clipplane
}, WINED3D_GL_EXT_NONE
},
4628 { STATE_CLIPPLANE(1), { STATE_CLIPPLANE(1), clipplane
}, WINED3D_GL_EXT_NONE
},
4629 { STATE_CLIPPLANE(2), { STATE_CLIPPLANE(2), clipplane
}, WINED3D_GL_EXT_NONE
},
4630 { STATE_CLIPPLANE(3), { STATE_CLIPPLANE(3), clipplane
}, WINED3D_GL_EXT_NONE
},
4631 { STATE_CLIPPLANE(4), { STATE_CLIPPLANE(4), clipplane
}, WINED3D_GL_EXT_NONE
},
4632 { STATE_CLIPPLANE(5), { STATE_CLIPPLANE(5), clipplane
}, WINED3D_GL_EXT_NONE
},
4633 { STATE_CLIPPLANE(6), { STATE_CLIPPLANE(6), clipplane
}, WINED3D_GL_EXT_NONE
},
4634 { STATE_CLIPPLANE(7), { STATE_CLIPPLANE(7), clipplane
}, WINED3D_GL_EXT_NONE
},
4636 { STATE_LIGHT_TYPE
, { STATE_LIGHT_TYPE
, state_nop
}, WINED3D_GL_EXT_NONE
},
4637 { STATE_ACTIVELIGHT(0), { STATE_ACTIVELIGHT(0), light
}, WINED3D_GL_EXT_NONE
},
4638 { STATE_ACTIVELIGHT(1), { STATE_ACTIVELIGHT(1), light
}, WINED3D_GL_EXT_NONE
},
4639 { STATE_ACTIVELIGHT(2), { STATE_ACTIVELIGHT(2), light
}, WINED3D_GL_EXT_NONE
},
4640 { STATE_ACTIVELIGHT(3), { STATE_ACTIVELIGHT(3), light
}, WINED3D_GL_EXT_NONE
},
4641 { STATE_ACTIVELIGHT(4), { STATE_ACTIVELIGHT(4), light
}, WINED3D_GL_EXT_NONE
},
4642 { STATE_ACTIVELIGHT(5), { STATE_ACTIVELIGHT(5), light
}, WINED3D_GL_EXT_NONE
},
4643 { STATE_ACTIVELIGHT(6), { STATE_ACTIVELIGHT(6), light
}, WINED3D_GL_EXT_NONE
},
4644 { STATE_ACTIVELIGHT(7), { STATE_ACTIVELIGHT(7), light
}, WINED3D_GL_EXT_NONE
},
4646 { STATE_VIEWPORT
, { STATE_VIEWPORT
, viewport_vertexpart
}, WINED3D_GL_EXT_NONE
},
4647 /* Transform states follow */
4648 { STATE_TRANSFORM(WINED3D_TS_VIEW
), { STATE_TRANSFORM(WINED3D_TS_VIEW
), transform_view
}, WINED3D_GL_EXT_NONE
},
4649 { STATE_TRANSFORM(WINED3D_TS_PROJECTION
), { STATE_TRANSFORM(WINED3D_TS_PROJECTION
), transform_projection
}, WINED3D_GL_EXT_NONE
},
4650 { STATE_TRANSFORM(WINED3D_TS_TEXTURE0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
4651 { STATE_TRANSFORM(WINED3D_TS_TEXTURE1
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
4652 { STATE_TRANSFORM(WINED3D_TS_TEXTURE2
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
4653 { STATE_TRANSFORM(WINED3D_TS_TEXTURE3
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
4654 { STATE_TRANSFORM(WINED3D_TS_TEXTURE4
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
4655 { STATE_TRANSFORM(WINED3D_TS_TEXTURE5
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
4656 { STATE_TRANSFORM(WINED3D_TS_TEXTURE6
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
4657 { STATE_TRANSFORM(WINED3D_TS_TEXTURE7
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
4658 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 0)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 0)), transform_world
}, WINED3D_GL_EXT_NONE
},
4659 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 1)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 1)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4660 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 2)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 2)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4661 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 3)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 3)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4662 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 4)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 4)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4663 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 5)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 5)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4664 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 6)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 6)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4665 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 7)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 7)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4666 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 8)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 8)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4667 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 9)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 9)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4668 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 10)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 10)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4669 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 11)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 11)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4670 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 12)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 12)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4671 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 13)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 13)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4672 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 14)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 14)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4673 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 15)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 15)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4674 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 16)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 16)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4675 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 17)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 17)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4676 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 18)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 18)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4677 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 19)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 19)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4678 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 20)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 20)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4679 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 21)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 21)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4680 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 22)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 22)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4681 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 23)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 23)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4682 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 24)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 24)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4683 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 25)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 25)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4684 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 26)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 26)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4685 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 27)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 27)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4686 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 28)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 28)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4687 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 29)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 29)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4688 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 30)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 30)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4689 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 31)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 31)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4690 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 32)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 32)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4691 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 33)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 33)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4692 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 34)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 34)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4693 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 35)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 35)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4694 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 36)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 36)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4695 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 37)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 37)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4696 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 38)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 38)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4697 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 39)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 39)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4698 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 40)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 40)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4699 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 41)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 41)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4700 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 42)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 42)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4701 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 43)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 43)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4702 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 44)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 44)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4703 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 45)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 45)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4704 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 46)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 46)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4705 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 47)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 47)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4706 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 48)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 48)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4707 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 49)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 49)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4708 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 50)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 50)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4709 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 51)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 51)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4710 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 52)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 52)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4711 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 53)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 53)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4712 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 54)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 54)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4713 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 55)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 55)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4714 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 56)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 56)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4715 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 57)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 57)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4716 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 58)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 58)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4717 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 59)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 59)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4718 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 60)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 60)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4719 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 61)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 61)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4720 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 62)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 62)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4721 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 63)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 63)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4722 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 64)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 64)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4723 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 65)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 65)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4724 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 66)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 66)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4725 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 67)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 67)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4726 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 68)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 68)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4727 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 69)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 69)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4728 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 70)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 70)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4729 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 71)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 71)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4730 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 72)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 72)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4731 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 73)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 73)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4732 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 74)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 74)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4733 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 75)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 75)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4734 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 76)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 76)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4735 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 77)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 77)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4736 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 78)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 78)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4737 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 79)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 79)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4738 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 80)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 80)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4739 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 81)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 81)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4740 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 82)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 82)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4741 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 83)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 83)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4742 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 84)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 84)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4743 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 85)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 85)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4744 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 86)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 86)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4745 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 87)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 87)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4746 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 88)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 88)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4747 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 89)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 89)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4748 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 90)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 90)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4749 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 91)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 91)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4750 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 92)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 92)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4751 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 93)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 93)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4752 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 94)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 94)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4753 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 95)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 95)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4754 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 96)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 96)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4755 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 97)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 97)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4756 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 98)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 98)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4757 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 99)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 99)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4758 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(100)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(100)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4759 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(101)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(101)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4760 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(102)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(102)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4761 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(103)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(103)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4762 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(104)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(104)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4763 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(105)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(105)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4764 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(106)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(106)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4765 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(107)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(107)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4766 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(108)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(108)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4767 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(109)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(109)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4768 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(110)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(110)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4769 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(111)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(111)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4770 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(112)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(112)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4771 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(113)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(113)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4772 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(114)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(114)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4773 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(115)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(115)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4774 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(116)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(116)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4775 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(117)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(117)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4776 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(118)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(118)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4777 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(119)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(119)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4778 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(120)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(120)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4779 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(121)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(121)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4780 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(122)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(122)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4781 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(123)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(123)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4782 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(124)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(124)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4783 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(125)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(125)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4784 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(126)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(126)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4785 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(127)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(127)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4786 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(128)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(128)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4787 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(129)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(129)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4788 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(130)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(130)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4789 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(131)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(131)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4790 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(132)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(132)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4791 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(133)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(133)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4792 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(134)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(134)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4793 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(135)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(135)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4794 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(136)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(136)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4795 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(137)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(137)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4796 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(138)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(138)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4797 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(139)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(139)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4798 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(140)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(140)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4799 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(141)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(141)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4800 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(142)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(142)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4801 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(143)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(143)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4802 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(144)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(144)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4803 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(145)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(145)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4804 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(146)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(146)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4805 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(147)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(147)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4806 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(148)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(148)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4807 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(149)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(149)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4808 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(150)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(150)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4809 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(151)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(151)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4810 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(152)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(152)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4811 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(153)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(153)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4812 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(154)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(154)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4813 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(155)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(155)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4814 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(156)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(156)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4815 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(157)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(157)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4816 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(158)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(158)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4817 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(159)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(159)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4818 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(160)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(160)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4819 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(161)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(161)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4820 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(162)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(162)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4821 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(163)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(163)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4822 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(164)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(164)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4823 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(165)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(165)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4824 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(166)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(166)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4825 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(167)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(167)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4826 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(168)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(168)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4827 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(169)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(169)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4828 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(170)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(170)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4829 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(171)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(171)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4830 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(172)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(172)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4831 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(173)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(173)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4832 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(174)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(174)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4833 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(175)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(175)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4834 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(176)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(176)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4835 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(177)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(177)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4836 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(178)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(178)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4837 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(179)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(179)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4838 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(180)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(180)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4839 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(181)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(181)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4840 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(182)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(182)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4841 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(183)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(183)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4842 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(184)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(184)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4843 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(185)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(185)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4844 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(186)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(186)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4845 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(187)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(187)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4846 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(188)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(188)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4847 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(189)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(189)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4848 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(190)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(190)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4849 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(191)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(191)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4850 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(192)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(192)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4851 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(193)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(193)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4852 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(194)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(194)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4853 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(195)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(195)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4854 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(196)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(196)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4855 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(197)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(197)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4856 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(198)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(198)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4857 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(199)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(199)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4858 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(200)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(200)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4859 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(201)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(201)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4860 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(202)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(202)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4861 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(203)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(203)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4862 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(204)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(204)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4863 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(205)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(205)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4864 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(206)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(206)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4865 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(207)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(207)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4866 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(208)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(208)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4867 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(209)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(209)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4868 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(210)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(210)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4869 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(211)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(211)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4870 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(212)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(212)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4871 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(213)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(213)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4872 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(214)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(214)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4873 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(215)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(215)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4874 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(216)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(216)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4875 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(217)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(217)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4876 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(218)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(218)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4877 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(219)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(219)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4878 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(220)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(220)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4879 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(221)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(221)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4880 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(222)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(222)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4881 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(223)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(223)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4882 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(224)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(224)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4883 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(225)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(225)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4884 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(226)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(226)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4885 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(227)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(227)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4886 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(228)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(228)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4887 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(229)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(229)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4888 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(230)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(230)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4889 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(231)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(231)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4890 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(232)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(232)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4891 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(233)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(233)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4892 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(234)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(234)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4893 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(235)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(235)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4894 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(236)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(236)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4895 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(237)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(237)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4896 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(238)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(238)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4897 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(239)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(239)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4898 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(240)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(240)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4899 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(241)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(241)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4900 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(242)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(242)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4901 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(243)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(243)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4902 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(244)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(244)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4903 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(245)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(245)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4904 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(246)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(246)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4905 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(247)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(247)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4906 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(248)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(248)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4907 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(249)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(249)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4908 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(250)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(250)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4909 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(251)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(251)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4910 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(252)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(252)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4911 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(253)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(253)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4912 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(254)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(254)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4913 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
4914 { STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
4915 { STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
4916 { STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
4917 { STATE_TEXTURESTAGE(3, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(3, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
4918 { STATE_TEXTURESTAGE(4, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(4, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
4919 { STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
4920 { STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
4921 { STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
4922 { STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
4923 { STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
4924 { STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
4925 { STATE_TEXTURESTAGE(3, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
4926 { STATE_TEXTURESTAGE(4, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
4927 { STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
4928 { STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
4929 { STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
4931 { STATE_RENDER(WINED3D_RS_FOGENABLE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), state_fog_vertexpart
}, WINED3D_GL_EXT_NONE
},
4932 { STATE_RENDER(WINED3D_RS_FOGTABLEMODE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4933 { STATE_RENDER(WINED3D_RS_FOGVERTEXMODE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4934 { STATE_RENDER(WINED3D_RS_RANGEFOGENABLE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4935 { STATE_RENDER(WINED3D_RS_CLIPPING
), { STATE_RENDER(WINED3D_RS_CLIPPING
), state_clipping
}, WINED3D_GL_EXT_NONE
},
4936 { STATE_RENDER(WINED3D_RS_CLIPPLANEENABLE
), { STATE_RENDER(WINED3D_RS_CLIPPING
), NULL
}, WINED3D_GL_EXT_NONE
},
4937 { STATE_RENDER(WINED3D_RS_LIGHTING
), { STATE_RENDER(WINED3D_RS_LIGHTING
), state_lighting
}, WINED3D_GL_EXT_NONE
},
4938 { STATE_RENDER(WINED3D_RS_AMBIENT
), { STATE_RENDER(WINED3D_RS_AMBIENT
), state_ambient
}, WINED3D_GL_EXT_NONE
},
4939 { STATE_RENDER(WINED3D_RS_COLORVERTEX
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), state_colormat
}, WINED3D_GL_EXT_NONE
},
4940 { STATE_RENDER(WINED3D_RS_LOCALVIEWER
), { STATE_RENDER(WINED3D_RS_LOCALVIEWER
), state_localviewer
}, WINED3D_GL_EXT_NONE
},
4941 { STATE_RENDER(WINED3D_RS_NORMALIZENORMALS
), { STATE_RENDER(WINED3D_RS_NORMALIZENORMALS
), state_normalize
}, WINED3D_GL_EXT_NONE
},
4942 { STATE_RENDER(WINED3D_RS_DIFFUSEMATERIALSOURCE
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), NULL
}, WINED3D_GL_EXT_NONE
},
4943 { STATE_RENDER(WINED3D_RS_SPECULARMATERIALSOURCE
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), NULL
}, WINED3D_GL_EXT_NONE
},
4944 { STATE_RENDER(WINED3D_RS_AMBIENTMATERIALSOURCE
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), NULL
}, WINED3D_GL_EXT_NONE
},
4945 { STATE_RENDER(WINED3D_RS_EMISSIVEMATERIALSOURCE
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), NULL
}, WINED3D_GL_EXT_NONE
},
4946 { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), state_vertexblend_w
}, WINED3D_GL_EXT_NONE
},
4947 { STATE_RENDER(WINED3D_RS_POINTSIZE
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4948 { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), state_psizemin_arb
}, ARB_POINT_PARAMETERS
},
4949 { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), state_psizemin_ext
}, EXT_POINT_PARAMETERS
},
4950 { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), state_psizemin_w
}, WINED3D_GL_EXT_NONE
},
4951 { STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE
), { STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE
), state_pointsprite
}, ARB_POINT_SPRITE
},
4952 { STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE
), { STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE
), state_pointsprite_w
}, WINED3D_GL_EXT_NONE
},
4953 { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), state_pscale
}, WINED3D_GL_EXT_NONE
},
4954 { STATE_RENDER(WINED3D_RS_POINTSCALE_A
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4955 { STATE_RENDER(WINED3D_RS_POINTSCALE_B
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4956 { STATE_RENDER(WINED3D_RS_POINTSCALE_C
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4957 { STATE_RENDER(WINED3D_RS_POINTSIZE_MAX
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), NULL
}, ARB_POINT_PARAMETERS
},
4958 { STATE_RENDER(WINED3D_RS_POINTSIZE_MAX
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), NULL
}, EXT_POINT_PARAMETERS
},
4959 { STATE_RENDER(WINED3D_RS_POINTSIZE_MAX
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), NULL
}, WINED3D_GL_EXT_NONE
},
4961 /* Samplers for NP2 texture matrix adjustions. They are not needed if GL_ARB_texture_non_power_of_two is supported,
4962 * so register a NULL state handler in that case to get the vertex part of sampler() skipped(VTF is handled in the misc states.
4963 * otherwise, register sampler_texmatrix, which takes care of updating the texture matrix
4965 { STATE_SAMPLER(0), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
4966 { STATE_SAMPLER(0), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
4967 { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
4968 { STATE_SAMPLER(1), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
4969 { STATE_SAMPLER(1), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
4970 { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
4971 { STATE_SAMPLER(2), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
4972 { STATE_SAMPLER(2), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
4973 { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
4974 { STATE_SAMPLER(3), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
4975 { STATE_SAMPLER(3), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
4976 { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
4977 { STATE_SAMPLER(4), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
4978 { STATE_SAMPLER(4), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
4979 { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
4980 { STATE_SAMPLER(5), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
4981 { STATE_SAMPLER(5), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
4982 { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
4983 { STATE_SAMPLER(6), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
4984 { STATE_SAMPLER(6), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
4985 { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
4986 { STATE_SAMPLER(7), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
4987 { STATE_SAMPLER(7), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
4988 { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
4989 { STATE_POINT_ENABLE
, { STATE_POINT_ENABLE
, state_nop
}, WINED3D_GL_EXT_NONE
},
4990 {0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE
},
4993 static const struct wined3d_state_entry_template ffp_fragmentstate_template
[] = {
4994 { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
4995 { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
4996 { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
4997 { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
4998 { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
4999 { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5000 { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5001 { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5002 { STATE_TEXTURESTAGE(0, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5003 { STATE_TEXTURESTAGE(0, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5004 { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5005 { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5006 { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5007 { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5008 { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5009 { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5010 { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5011 { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5012 { STATE_TEXTURESTAGE(1, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5013 { STATE_TEXTURESTAGE(1, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5014 { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5015 { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5016 { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5017 { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5018 { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5019 { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5020 { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5021 { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5022 { STATE_TEXTURESTAGE(2, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5023 { STATE_TEXTURESTAGE(2, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5024 { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5025 { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5026 { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5027 { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5028 { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5029 { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5030 { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5031 { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5032 { STATE_TEXTURESTAGE(3, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5033 { STATE_TEXTURESTAGE(3, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5034 { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5035 { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5036 { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5037 { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5038 { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5039 { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5040 { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5041 { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5042 { STATE_TEXTURESTAGE(4, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5043 { STATE_TEXTURESTAGE(4, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5044 { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5045 { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5046 { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5047 { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5048 { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5049 { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5050 { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5051 { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5052 { STATE_TEXTURESTAGE(5, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5053 { STATE_TEXTURESTAGE(5, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5054 { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5055 { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5056 { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5057 { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5058 { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5059 { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5060 { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5061 { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5062 { STATE_TEXTURESTAGE(6, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5063 { STATE_TEXTURESTAGE(6, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5064 { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5065 { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5066 { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5067 { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5068 { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5069 { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5070 { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5071 { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5072 { STATE_TEXTURESTAGE(7, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5073 { STATE_TEXTURESTAGE(7, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5074 { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
), apply_pixelshader
}, WINED3D_GL_EXT_NONE
},
5075 { STATE_RENDER(WINED3D_RS_ALPHAFUNC
), { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5076 { STATE_RENDER(WINED3D_RS_ALPHAREF
), { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5077 { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), state_alpha_test
}, WINED3D_GL_EXT_NONE
},
5078 { STATE_RENDER(WINED3D_RS_COLORKEYENABLE
), { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5079 { STATE_COLOR_KEY
, { STATE_COLOR_KEY
, state_nop
}, WINED3D_GL_EXT_NONE
},
5080 { STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE
), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
), NULL
}, WINED3D_GL_EXT_NONE
},
5081 { STATE_RENDER(WINED3D_RS_TEXTUREFACTOR
), { STATE_RENDER(WINED3D_RS_TEXTUREFACTOR
), state_texfactor
}, WINED3D_GL_EXT_NONE
},
5082 { STATE_RENDER(WINED3D_RS_FOGCOLOR
), { STATE_RENDER(WINED3D_RS_FOGCOLOR
), state_fogcolor
}, WINED3D_GL_EXT_NONE
},
5083 { STATE_RENDER(WINED3D_RS_FOGDENSITY
), { STATE_RENDER(WINED3D_RS_FOGDENSITY
), state_fogdensity
}, WINED3D_GL_EXT_NONE
},
5084 { STATE_RENDER(WINED3D_RS_FOGENABLE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), state_fog_fragpart
}, WINED3D_GL_EXT_NONE
},
5085 { STATE_RENDER(WINED3D_RS_FOGTABLEMODE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5086 { STATE_RENDER(WINED3D_RS_FOGVERTEXMODE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5087 { STATE_RENDER(WINED3D_RS_FOGSTART
), { STATE_RENDER(WINED3D_RS_FOGSTART
), state_fogstartend
}, WINED3D_GL_EXT_NONE
},
5088 { STATE_RENDER(WINED3D_RS_FOGEND
), { STATE_RENDER(WINED3D_RS_FOGSTART
), NULL
}, WINED3D_GL_EXT_NONE
},
5089 { STATE_RENDER(WINED3D_RS_SHADEMODE
), { STATE_RENDER(WINED3D_RS_SHADEMODE
), state_shademode
}, WINED3D_GL_EXT_NONE
},
5090 { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5091 { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5092 { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5093 { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5094 { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5095 { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5096 { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5097 { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5098 {0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE
},
5101 /* Context activation is done by the caller. */
5102 static void ffp_pipe_enable(const struct wined3d_context
*context
, BOOL enable
) {}
5104 static void *ffp_alloc(const struct wined3d_shader_backend_ops
*shader_backend
, void *shader_priv
)
5109 static void ffp_free(struct wined3d_device
*device
, struct wined3d_context
*context
) {}
5111 static void vp_ffp_get_caps(const struct wined3d_adapter
*adapter
, struct wined3d_vertex_caps
*caps
)
5113 const struct wined3d_gl_info
*gl_info
= &wined3d_adapter_gl_const(adapter
)->gl_info
;
5115 caps
->xyzrhw
= FALSE
;
5116 caps
->ffp_generic_attributes
= FALSE
;
5117 caps
->max_active_lights
= gl_info
->limits
.lights
;
5118 caps
->max_vertex_blend_matrices
= 1;
5119 caps
->max_vertex_blend_matrix_index
= 0;
5120 caps
->vertex_processing_caps
= WINED3DVTXPCAPS_DIRECTIONALLIGHTS
5121 | WINED3DVTXPCAPS_MATERIALSOURCE7
5122 | WINED3DVTXPCAPS_POSITIONALLIGHTS
5123 | WINED3DVTXPCAPS_LOCALVIEWER
5124 | WINED3DVTXPCAPS_VERTEXFOG
5125 | WINED3DVTXPCAPS_TEXGEN
5126 | WINED3DVTXPCAPS_TEXGEN_SPHEREMAP
;
5127 caps
->fvf_caps
= WINED3DFVFCAPS_PSIZE
| 0x0008; /* 8 texture coords */
5128 caps
->max_user_clip_planes
= gl_info
->limits
.user_clip_distances
;
5129 caps
->raster_caps
= 0;
5130 if (gl_info
->supported
[NV_FOG_DISTANCE
])
5131 caps
->raster_caps
|= WINED3DPRASTERCAPS_FOGRANGE
;
5134 static unsigned int vp_ffp_get_emul_mask(const struct wined3d_adapter
*adapter
)
5136 return GL_EXT_EMUL_ARB_MULTITEXTURE
| GL_EXT_EMUL_EXT_FOG_COORD
;
5139 const struct wined3d_vertex_pipe_ops ffp_vertex_pipe
=
5143 vp_ffp_get_emul_mask
,
5149 static void ffp_fragment_get_caps(const struct wined3d_adapter
*adapter
, struct fragment_caps
*caps
)
5151 const struct wined3d_gl_info
*gl_info
= &wined3d_adapter_gl_const(adapter
)->gl_info
;
5153 caps
->wined3d_caps
= 0;
5154 caps
->PrimitiveMiscCaps
= 0;
5155 caps
->TextureOpCaps
= WINED3DTEXOPCAPS_ADD
5156 | WINED3DTEXOPCAPS_ADDSIGNED
5157 | WINED3DTEXOPCAPS_ADDSIGNED2X
5158 | WINED3DTEXOPCAPS_MODULATE
5159 | WINED3DTEXOPCAPS_MODULATE2X
5160 | WINED3DTEXOPCAPS_MODULATE4X
5161 | WINED3DTEXOPCAPS_SELECTARG1
5162 | WINED3DTEXOPCAPS_SELECTARG2
5163 | WINED3DTEXOPCAPS_DISABLE
;
5165 if (gl_info
->supported
[ARB_TEXTURE_ENV_COMBINE
]
5166 || gl_info
->supported
[EXT_TEXTURE_ENV_COMBINE
]
5167 || gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
5169 caps
->TextureOpCaps
|= WINED3DTEXOPCAPS_BLENDDIFFUSEALPHA
5170 | WINED3DTEXOPCAPS_BLENDTEXTUREALPHA
5171 | WINED3DTEXOPCAPS_BLENDFACTORALPHA
5172 | WINED3DTEXOPCAPS_BLENDCURRENTALPHA
5173 | WINED3DTEXOPCAPS_LERP
5174 | WINED3DTEXOPCAPS_SUBTRACT
;
5176 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
]
5177 || gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
5179 caps
->TextureOpCaps
|= WINED3DTEXOPCAPS_ADDSMOOTH
5180 | WINED3DTEXOPCAPS_MULTIPLYADD
5181 | WINED3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR
5182 | WINED3DTEXOPCAPS_MODULATECOLOR_ADDALPHA
5183 | WINED3DTEXOPCAPS_BLENDTEXTUREALPHAPM
;
5185 if (gl_info
->supported
[ARB_TEXTURE_ENV_DOT3
])
5186 caps
->TextureOpCaps
|= WINED3DTEXOPCAPS_DOTPRODUCT3
;
5188 caps
->MaxTextureBlendStages
= gl_info
->limits
.textures
;
5189 caps
->MaxSimultaneousTextures
= gl_info
->limits
.textures
;
5192 static unsigned int ffp_fragment_get_emul_mask(const struct wined3d_adapter
*adapter
)
5194 return GL_EXT_EMUL_ARB_MULTITEXTURE
| GL_EXT_EMUL_EXT_FOG_COORD
;
5197 static BOOL
ffp_color_fixup_supported(struct color_fixup_desc fixup
)
5199 /* We only support identity conversions. */
5200 return is_identity_fixup(fixup
);
5203 static BOOL
ffp_none_context_alloc(struct wined3d_context
*context
)
5208 static void ffp_none_context_free(struct wined3d_context
*context
)
5212 const struct wined3d_fragment_pipe_ops ffp_fragment_pipeline
=
5215 ffp_fragment_get_caps
,
5216 ffp_fragment_get_emul_mask
,
5219 ffp_none_context_alloc
,
5220 ffp_none_context_free
,
5221 ffp_color_fixup_supported
,
5222 ffp_fragmentstate_template
,
5225 static void none_pipe_enable(const struct wined3d_context
*context
, BOOL enable
) {}
5227 static void *none_alloc(const struct wined3d_shader_backend_ops
*shader_backend
, void *shader_priv
)
5232 static void none_free(struct wined3d_device
*device
, struct wined3d_context
*context
) {}
5234 static void vp_none_get_caps(const struct wined3d_adapter
*adapter
, struct wined3d_vertex_caps
*caps
)
5236 memset(caps
, 0, sizeof(*caps
));
5239 static unsigned int vp_none_get_emul_mask(const struct wined3d_adapter
*adapter
)
5244 const struct wined3d_vertex_pipe_ops none_vertex_pipe
=
5248 vp_none_get_emul_mask
,
5254 static void fp_none_get_caps(const struct wined3d_adapter
*adapter
, struct fragment_caps
*caps
)
5256 memset(caps
, 0, sizeof(*caps
));
5259 static unsigned int fp_none_get_emul_mask(const struct wined3d_adapter
*adapter
)
5264 static BOOL
fp_none_color_fixup_supported(struct color_fixup_desc fixup
)
5266 return is_identity_fixup(fixup
);
5269 const struct wined3d_fragment_pipe_ops none_fragment_pipe
=
5273 fp_none_get_emul_mask
,
5276 ffp_none_context_alloc
,
5277 ffp_none_context_free
,
5278 fp_none_color_fixup_supported
,
5282 static unsigned int num_handlers(const APPLYSTATEFUNC
*funcs
)
5285 for(i
= 0; funcs
[i
]; i
++);
5289 static void multistate_apply_2(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
5291 context
->device
->multistate_funcs
[state_id
][0](context
, state
, state_id
);
5292 context
->device
->multistate_funcs
[state_id
][1](context
, state
, state_id
);
5295 static void multistate_apply_3(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
5297 context
->device
->multistate_funcs
[state_id
][0](context
, state
, state_id
);
5298 context
->device
->multistate_funcs
[state_id
][1](context
, state
, state_id
);
5299 context
->device
->multistate_funcs
[state_id
][2](context
, state
, state_id
);
5302 static void prune_invalid_states(struct wined3d_state_entry
*state_table
, const struct wined3d_d3d_info
*d3d_info
)
5304 unsigned int start
, last
, i
;
5306 start
= STATE_TEXTURESTAGE(d3d_info
->limits
.ffp_blend_stages
, 0);
5307 last
= STATE_TEXTURESTAGE(WINED3D_MAX_TEXTURES
- 1, WINED3D_HIGHEST_TEXTURE_STATE
);
5308 for (i
= start
; i
<= last
; ++i
)
5310 state_table
[i
].representative
= 0;
5311 state_table
[i
].apply
= state_undefined
;
5314 start
= STATE_TRANSFORM(WINED3D_TS_TEXTURE0
+ d3d_info
->limits
.ffp_blend_stages
);
5315 last
= STATE_TRANSFORM(WINED3D_TS_TEXTURE0
+ WINED3D_MAX_TEXTURES
- 1);
5316 for (i
= start
; i
<= last
; ++i
)
5318 state_table
[i
].representative
= 0;
5319 state_table
[i
].apply
= state_undefined
;
5322 start
= STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(d3d_info
->limits
.ffp_vertex_blend_matrices
));
5323 last
= STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255));
5324 for (i
= start
; i
<= last
; ++i
)
5326 state_table
[i
].representative
= 0;
5327 state_table
[i
].apply
= state_undefined
;
5331 static void validate_state_table(struct wined3d_state_entry
*state_table
)
5358 static const unsigned int simple_states
[] =
5364 STATE_SHADER(WINED3D_SHADER_TYPE_VERTEX
),
5365 STATE_SHADER(WINED3D_SHADER_TYPE_HULL
),
5366 STATE_SHADER(WINED3D_SHADER_TYPE_DOMAIN
),
5367 STATE_SHADER(WINED3D_SHADER_TYPE_GEOMETRY
),
5368 STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
),
5369 STATE_SHADER(WINED3D_SHADER_TYPE_COMPUTE
),
5370 STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX
),
5371 STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_HULL
),
5372 STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_DOMAIN
),
5373 STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY
),
5374 STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL
),
5375 STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_COMPUTE
),
5376 STATE_COMPUTE_SHADER_RESOURCE_BINDING
,
5377 STATE_GRAPHICS_SHADER_RESOURCE_BINDING
,
5378 STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING
,
5379 STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING
,
5384 STATE_POINTSPRITECOORDORIGIN
,
5385 STATE_BASEVERTEXINDEX
,
5391 STATE_DEPTH_STENCIL
,
5395 unsigned int i
, current
;
5397 for (i
= STATE_RENDER(1), current
= 0; i
<= STATE_RENDER(WINEHIGHEST_RENDER_STATE
); ++i
)
5399 if (!rs_holes
[current
].first
|| i
< STATE_RENDER(rs_holes
[current
].first
))
5401 if (!state_table
[i
].representative
)
5402 ERR("State %s (%#x) should have a representative.\n", debug_d3dstate(i
), i
);
5404 else if (state_table
[i
].representative
)
5405 ERR("State %s (%#x) shouldn't have a representative.\n", debug_d3dstate(i
), i
);
5407 if (i
== STATE_RENDER(rs_holes
[current
].last
)) ++current
;
5410 for (i
= 0; i
< ARRAY_SIZE(simple_states
); ++i
)
5412 if (!state_table
[simple_states
[i
]].representative
)
5413 ERR("State %s (%#x) should have a representative.\n",
5414 debug_d3dstate(simple_states
[i
]), simple_states
[i
]);
5417 for (i
= 0; i
< STATE_HIGHEST
+ 1; ++i
)
5419 unsigned int rep
= state_table
[i
].representative
;
5422 if (state_table
[rep
].representative
!= rep
)
5424 ERR("State %s (%#x) has invalid representative %s (%#x).\n",
5425 debug_d3dstate(i
), i
, debug_d3dstate(rep
), rep
);
5426 state_table
[i
].representative
= 0;
5431 if (state_table
[i
].apply
)
5432 ERR("State %s (%#x) has both a handler and representative.\n", debug_d3dstate(i
), i
);
5434 else if (!state_table
[i
].apply
)
5436 ERR("Self representing state %s (%#x) has no handler.\n", debug_d3dstate(i
), i
);
5442 HRESULT
compile_state_table(struct wined3d_state_entry
*state_table
, APPLYSTATEFUNC
**dev_multistate_funcs
,
5443 const struct wined3d_d3d_info
*d3d_info
, const BOOL
*supported_extensions
,
5444 const struct wined3d_vertex_pipe_ops
*vertex
, const struct wined3d_fragment_pipe_ops
*fragment
,
5445 const struct wined3d_state_entry_template
*misc
)
5447 APPLYSTATEFUNC multistate_funcs
[STATE_HIGHEST
+ 1][3];
5448 const struct wined3d_state_entry_template
*cur
;
5449 unsigned int i
, type
, handlers
;
5450 BOOL set
[STATE_HIGHEST
+ 1];
5452 memset(multistate_funcs
, 0, sizeof(multistate_funcs
));
5454 for (i
= 0; i
< STATE_HIGHEST
+ 1; ++i
)
5456 state_table
[i
].representative
= 0;
5457 state_table
[i
].apply
= state_undefined
;
5460 for (type
= 0; type
< 3; ++type
)
5462 /* This switch decides the order in which the states are applied */
5465 case 0: cur
= misc
; break;
5466 case 1: cur
= fragment
->states
; break;
5467 case 2: cur
= vertex
->vp_states
; break;
5468 default: cur
= NULL
; /* Stupid compiler */
5472 /* GL extension filtering should not prevent multiple handlers being applied from different
5475 memset(set
, 0, sizeof(set
));
5477 for (i
= 0; cur
[i
].state
; ++i
)
5479 APPLYSTATEFUNC
*funcs_array
;
5481 /* Only use the first matching state with the available extension from one template.
5483 * {D3DRS_FOOBAR, {D3DRS_FOOBAR, func1}, XYZ_FANCY},
5484 * {D3DRS_FOOBAR, {D3DRS_FOOBAR, func2}, 0 }
5486 * if GL_XYZ_fancy is supported, ignore the 2nd line
5488 if (set
[cur
[i
].state
]) continue;
5489 /* Skip state lines depending on unsupported extensions */
5490 if (!supported_extensions
[cur
[i
].extension
]) continue;
5491 set
[cur
[i
].state
] = TRUE
;
5492 /* In some cases having an extension means that nothing has to be
5493 * done for a state, e.g. if GL_ARB_texture_non_power_of_two is
5494 * supported, the texture coordinate fixup can be ignored. If the
5495 * apply function is used, mark the state set(done above) to prevent
5496 * applying later lines, but do not record anything in the state
5499 if (!cur
[i
].content
.representative
) continue;
5501 handlers
= num_handlers(multistate_funcs
[cur
[i
].state
]);
5502 multistate_funcs
[cur
[i
].state
][handlers
] = cur
[i
].content
.apply
;
5506 state_table
[cur
[i
].state
].apply
= cur
[i
].content
.apply
;
5509 state_table
[cur
[i
].state
].apply
= multistate_apply_2
;
5510 if (!(dev_multistate_funcs
[cur
[i
].state
] = heap_calloc(2, sizeof(**dev_multistate_funcs
))))
5513 dev_multistate_funcs
[cur
[i
].state
][0] = multistate_funcs
[cur
[i
].state
][0];
5514 dev_multistate_funcs
[cur
[i
].state
][1] = multistate_funcs
[cur
[i
].state
][1];
5517 state_table
[cur
[i
].state
].apply
= multistate_apply_3
;
5518 if (!(funcs_array
= heap_realloc(dev_multistate_funcs
[cur
[i
].state
],
5519 sizeof(**dev_multistate_funcs
) * 3)))
5522 dev_multistate_funcs
[cur
[i
].state
] = funcs_array
;
5523 dev_multistate_funcs
[cur
[i
].state
][2] = multistate_funcs
[cur
[i
].state
][2];
5526 ERR("Unexpected amount of state handlers for state %u: %u.\n",
5527 cur
[i
].state
, handlers
+ 1);
5530 if (state_table
[cur
[i
].state
].representative
5531 && state_table
[cur
[i
].state
].representative
!= cur
[i
].content
.representative
)
5533 FIXME("State %s (%#x) has different representatives in different pipeline parts.\n",
5534 debug_d3dstate(cur
[i
].state
), cur
[i
].state
);
5536 state_table
[cur
[i
].state
].representative
= cur
[i
].content
.representative
;
5540 prune_invalid_states(state_table
, d3d_info
);
5541 validate_state_table(state_table
);
5546 for (i
= 0; i
<= STATE_HIGHEST
; ++i
)
5548 heap_free(dev_multistate_funcs
[i
]);
5551 memset(dev_multistate_funcs
, 0, (STATE_HIGHEST
+ 1) * sizeof(*dev_multistate_funcs
));
5553 return E_OUTOFMEMORY
;