2 * Direct3D state management
4 * Copyright 2002 Lionel Ulmer
5 * Copyright 2002-2005 Jason Edmeades
6 * Copyright 2003-2004 Raphael Junqueira
7 * Copyright 2004 Christian Costa
8 * Copyright 2005 Oliver Stieber
9 * Copyright 2006 Henri Verbeet
10 * Copyright 2006-2008 Stefan Dösinger for CodeWeavers
11 * Copyright 2009-2011 Henri Verbeet for CodeWeavers
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 2.1 of the License, or (at your option) any later version.
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this library; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "wine/port.h"
36 #include "wined3d_private.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(d3d
);
39 WINE_DECLARE_DEBUG_CHANNEL(d3d_shader
);
41 ULONG CDECL
wined3d_rasterizer_state_incref(struct wined3d_rasterizer_state
*state
)
43 ULONG refcount
= InterlockedIncrement(&state
->refcount
);
45 TRACE("%p increasing refcount to %u.\n", state
, refcount
);
50 static void wined3d_rasterizer_state_destroy_object(void *object
)
52 HeapFree(GetProcessHeap(), 0, object
);
55 ULONG CDECL
wined3d_rasterizer_state_decref(struct wined3d_rasterizer_state
*state
)
57 ULONG refcount
= InterlockedDecrement(&state
->refcount
);
58 struct wined3d_device
*device
= state
->device
;
60 TRACE("%p decreasing refcount to %u.\n", state
, refcount
);
63 wined3d_cs_emit_destroy_object(device
->cs
, wined3d_rasterizer_state_destroy_object
, state
);
68 HRESULT CDECL
wined3d_rasterizer_state_create(struct wined3d_device
*device
,
69 const struct wined3d_rasterizer_state_desc
*desc
, struct wined3d_rasterizer_state
**state
)
71 struct wined3d_rasterizer_state
*object
;
73 TRACE("device %p, desc %p, state %p.\n", device
, desc
, state
);
75 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
80 object
->device
= device
;
82 TRACE("Created rasterizer state %p.\n", object
);
88 /* Context activation for state handler is done by the caller. */
90 static void state_undefined(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
92 ERR("Undefined state %s (%#x).\n", debug_d3dstate(state_id
), state_id
);
95 void state_nop(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
97 TRACE("%s: nop in current pipe config.\n", debug_d3dstate(state_id
));
100 static void state_fillmode(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
102 enum wined3d_fill_mode mode
= state
->render_states
[WINED3D_RS_FILLMODE
];
103 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
107 case WINED3D_FILL_POINT
:
108 gl_info
->gl_ops
.gl
.p_glPolygonMode(GL_FRONT_AND_BACK
, GL_POINT
);
109 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_POINT)");
111 case WINED3D_FILL_WIREFRAME
:
112 gl_info
->gl_ops
.gl
.p_glPolygonMode(GL_FRONT_AND_BACK
, GL_LINE
);
113 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)");
115 case WINED3D_FILL_SOLID
:
116 gl_info
->gl_ops
.gl
.p_glPolygonMode(GL_FRONT_AND_BACK
, GL_FILL
);
117 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)");
120 FIXME("Unrecognized fill mode %#x.\n", mode
);
124 static void state_lighting(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
126 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
128 /* Lighting is not enabled if transformed vertices are drawn, but lighting
129 * does not affect the stream sources, so it is not grouped for
130 * performance reasons. This state reads the decoded vertex declaration,
131 * so if it is dirty don't do anything. The vertex declaration applying
132 * function calls this function for updating. */
133 if (isStateDirty(context
, STATE_VDECL
))
136 if (state
->render_states
[WINED3D_RS_LIGHTING
]
137 && !context
->stream_info
.position_transformed
)
139 gl_info
->gl_ops
.gl
.p_glEnable(GL_LIGHTING
);
140 checkGLcall("glEnable GL_LIGHTING");
144 gl_info
->gl_ops
.gl
.p_glDisable(GL_LIGHTING
);
145 checkGLcall("glDisable GL_LIGHTING");
149 static void state_zenable(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
151 enum wined3d_depth_buffer_type zenable
= state
->render_states
[WINED3D_RS_ZENABLE
];
152 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
154 /* No z test without depth stencil buffers */
155 if (!state
->fb
->depth_stencil
)
157 TRACE("No Z buffer - disabling depth test\n");
158 zenable
= WINED3D_ZB_FALSE
;
163 case WINED3D_ZB_FALSE
:
164 gl_info
->gl_ops
.gl
.p_glDisable(GL_DEPTH_TEST
);
165 checkGLcall("glDisable GL_DEPTH_TEST");
167 case WINED3D_ZB_TRUE
:
168 gl_info
->gl_ops
.gl
.p_glEnable(GL_DEPTH_TEST
);
169 checkGLcall("glEnable GL_DEPTH_TEST");
171 case WINED3D_ZB_USEW
:
172 gl_info
->gl_ops
.gl
.p_glEnable(GL_DEPTH_TEST
);
173 checkGLcall("glEnable GL_DEPTH_TEST");
174 FIXME("W buffer is not well handled\n");
177 FIXME("Unrecognized depth buffer type %#x.\n", zenable
);
181 if (context
->last_was_rhw
&& !isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
)))
182 context_apply_state(context
, state
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
));
185 static void state_cullmode(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
187 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
189 /* glFrontFace() is set in context.c at context init and on an
190 * offscreen / onscreen rendering switch. */
191 switch (state
->render_states
[WINED3D_RS_CULLMODE
])
193 case WINED3D_CULL_NONE
:
194 gl_info
->gl_ops
.gl
.p_glDisable(GL_CULL_FACE
);
195 checkGLcall("glDisable GL_CULL_FACE");
197 case WINED3D_CULL_FRONT
:
198 gl_info
->gl_ops
.gl
.p_glEnable(GL_CULL_FACE
);
199 checkGLcall("glEnable GL_CULL_FACE");
200 gl_info
->gl_ops
.gl
.p_glCullFace(GL_FRONT
);
201 checkGLcall("glCullFace(GL_FRONT)");
203 case WINED3D_CULL_BACK
:
204 gl_info
->gl_ops
.gl
.p_glEnable(GL_CULL_FACE
);
205 checkGLcall("glEnable GL_CULL_FACE");
206 gl_info
->gl_ops
.gl
.p_glCullFace(GL_BACK
);
207 checkGLcall("glCullFace(GL_BACK)");
210 FIXME("Unrecognized cull mode %#x.\n",
211 state
->render_states
[WINED3D_RS_CULLMODE
]);
215 void state_shademode(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
217 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
219 switch (state
->render_states
[WINED3D_RS_SHADEMODE
])
221 case WINED3D_SHADE_FLAT
:
222 gl_info
->gl_ops
.gl
.p_glShadeModel(GL_FLAT
);
223 checkGLcall("glShadeModel(GL_FLAT)");
225 case WINED3D_SHADE_GOURAUD
:
226 /* WINED3D_SHADE_PHONG in practice is the same as WINED3D_SHADE_GOURAUD
228 case WINED3D_SHADE_PHONG
:
229 gl_info
->gl_ops
.gl
.p_glShadeModel(GL_SMOOTH
);
230 checkGLcall("glShadeModel(GL_SMOOTH)");
233 FIXME("Unrecognized shade mode %#x.\n",
234 state
->render_states
[WINED3D_RS_SHADEMODE
]);
238 static void state_ditherenable(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
240 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
242 if (state
->render_states
[WINED3D_RS_DITHERENABLE
])
244 gl_info
->gl_ops
.gl
.p_glEnable(GL_DITHER
);
245 checkGLcall("glEnable GL_DITHER");
249 gl_info
->gl_ops
.gl
.p_glDisable(GL_DITHER
);
250 checkGLcall("glDisable GL_DITHER");
254 static void state_zwriteenable(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
256 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
258 if (state
->render_states
[WINED3D_RS_ZWRITEENABLE
])
260 gl_info
->gl_ops
.gl
.p_glDepthMask(1);
261 checkGLcall("glDepthMask(1)");
265 gl_info
->gl_ops
.gl
.p_glDepthMask(0);
266 checkGLcall("glDepthMask(0)");
270 GLenum
wined3d_gl_compare_func(enum wined3d_cmp_func f
)
274 case WINED3D_CMP_NEVER
:
276 case WINED3D_CMP_LESS
:
278 case WINED3D_CMP_EQUAL
:
280 case WINED3D_CMP_LESSEQUAL
:
282 case WINED3D_CMP_GREATER
:
284 case WINED3D_CMP_NOTEQUAL
:
286 case WINED3D_CMP_GREATEREQUAL
:
288 case WINED3D_CMP_ALWAYS
:
291 FIXME("Unrecognized compare function %#x.\n", f
);
296 static void state_zfunc(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
298 GLenum depth_func
= wined3d_gl_compare_func(state
->render_states
[WINED3D_RS_ZFUNC
]);
299 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
301 if (!depth_func
) return;
303 gl_info
->gl_ops
.gl
.p_glDepthFunc(depth_func
);
304 checkGLcall("glDepthFunc");
307 static void state_ambient(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
309 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
310 struct wined3d_color color
;
312 wined3d_color_from_d3dcolor(&color
, state
->render_states
[WINED3D_RS_AMBIENT
]);
313 TRACE("Setting ambient to %s.\n", debug_color(&color
));
314 gl_info
->gl_ops
.gl
.p_glLightModelfv(GL_LIGHT_MODEL_AMBIENT
, &color
.r
);
315 checkGLcall("glLightModel for MODEL_AMBIENT");
318 static void state_blendop_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
320 WARN("Unsupported in local OpenGL implementation: glBlendEquation\n");
323 static GLenum
gl_blend_op(const struct wined3d_gl_info
*gl_info
, enum wined3d_blend_op op
)
327 case WINED3D_BLEND_OP_ADD
:
329 case WINED3D_BLEND_OP_SUBTRACT
:
330 return gl_info
->supported
[EXT_BLEND_SUBTRACT
] ? GL_FUNC_SUBTRACT
: GL_FUNC_ADD
;
331 case WINED3D_BLEND_OP_REVSUBTRACT
:
332 return gl_info
->supported
[EXT_BLEND_SUBTRACT
] ? GL_FUNC_REVERSE_SUBTRACT
: GL_FUNC_ADD
;
333 case WINED3D_BLEND_OP_MIN
:
334 return gl_info
->supported
[EXT_BLEND_MINMAX
] ? GL_MIN
: GL_FUNC_ADD
;
335 case WINED3D_BLEND_OP_MAX
:
336 return gl_info
->supported
[EXT_BLEND_MINMAX
] ? GL_MAX
: GL_FUNC_ADD
;
338 FIXME("Unhandled blend op %#x.\n", op
);
343 static void state_blendop(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
345 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
346 GLenum blend_equation_alpha
= GL_FUNC_ADD_EXT
;
347 GLenum blend_equation
= GL_FUNC_ADD_EXT
;
349 /* BLENDOPALPHA requires GL_EXT_blend_equation_separate, so make sure it is around */
350 if (state
->render_states
[WINED3D_RS_BLENDOPALPHA
]
351 && !gl_info
->supported
[EXT_BLEND_EQUATION_SEPARATE
])
353 WARN("Unsupported in local OpenGL implementation: glBlendEquationSeparate.\n");
357 blend_equation
= gl_blend_op(gl_info
, state
->render_states
[WINED3D_RS_BLENDOP
]);
358 blend_equation_alpha
= gl_blend_op(gl_info
, state
->render_states
[WINED3D_RS_BLENDOPALPHA
]);
359 TRACE("blend_equation %#x, blend_equation_alpha %#x.\n", blend_equation
, blend_equation_alpha
);
361 if (state
->render_states
[WINED3D_RS_SEPARATEALPHABLENDENABLE
])
363 GL_EXTCALL(glBlendEquationSeparate(blend_equation
, blend_equation_alpha
));
364 checkGLcall("glBlendEquationSeparate");
368 GL_EXTCALL(glBlendEquation(blend_equation
));
369 checkGLcall("glBlendEquation");
373 static GLenum
gl_blend_factor(enum wined3d_blend factor
, const struct wined3d_format
*dst_format
)
377 case WINED3D_BLEND_ZERO
:
379 case WINED3D_BLEND_ONE
:
381 case WINED3D_BLEND_SRCCOLOR
:
383 case WINED3D_BLEND_INVSRCCOLOR
:
384 return GL_ONE_MINUS_SRC_COLOR
;
385 case WINED3D_BLEND_SRCALPHA
:
387 case WINED3D_BLEND_INVSRCALPHA
:
388 return GL_ONE_MINUS_SRC_ALPHA
;
389 case WINED3D_BLEND_DESTCOLOR
:
391 case WINED3D_BLEND_INVDESTCOLOR
:
392 return GL_ONE_MINUS_DST_COLOR
;
393 /* To compensate for the lack of format switching with backbuffer
394 * offscreen rendering, and with onscreen rendering, we modify the
395 * alpha test parameters for (INV)DESTALPHA if the render target
396 * doesn't support alpha blending. A nonexistent alpha channel
397 * returns 1.0, so WINED3D_BLEND_DESTALPHA becomes GL_ONE, and
398 * WINED3D_BLEND_INVDESTALPHA becomes GL_ZERO. */
399 case WINED3D_BLEND_DESTALPHA
:
400 return dst_format
->alpha_size
? GL_DST_ALPHA
: GL_ONE
;
401 case WINED3D_BLEND_INVDESTALPHA
:
402 return dst_format
->alpha_size
? GL_ONE_MINUS_DST_ALPHA
: GL_ZERO
;
403 case WINED3D_BLEND_SRCALPHASAT
:
404 return GL_SRC_ALPHA_SATURATE
;
405 case WINED3D_BLEND_BLENDFACTOR
:
406 return GL_CONSTANT_COLOR_EXT
;
407 case WINED3D_BLEND_INVBLENDFACTOR
:
408 return GL_ONE_MINUS_CONSTANT_COLOR_EXT
;
410 FIXME("Unhandled blend factor %#x.\n", factor
);
415 static void gl_blend_from_d3d(GLenum
*src_blend
, GLenum
*dst_blend
,
416 enum wined3d_blend d3d_src_blend
, enum wined3d_blend d3d_dst_blend
,
417 const struct wined3d_format
*rt_format
)
419 /* WINED3D_BLEND_BOTHSRCALPHA and WINED3D_BLEND_BOTHINVSRCALPHA are legacy
420 * source blending values which are still valid up to d3d9. They should
421 * not occur as dest blend values. */
422 if (d3d_src_blend
== WINED3D_BLEND_BOTHSRCALPHA
)
424 *src_blend
= GL_SRC_ALPHA
;
425 *dst_blend
= GL_ONE_MINUS_SRC_ALPHA
;
427 else if (d3d_src_blend
== WINED3D_BLEND_BOTHINVSRCALPHA
)
429 *src_blend
= GL_ONE_MINUS_SRC_ALPHA
;
430 *dst_blend
= GL_SRC_ALPHA
;
434 *src_blend
= gl_blend_factor(d3d_src_blend
, rt_format
);
435 *dst_blend
= gl_blend_factor(d3d_dst_blend
, rt_format
);
439 static void state_blend(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
441 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
442 const struct wined3d_format
*rt_format
;
443 BOOL enable_blend
, enable_line_smooth
;
444 GLenum src_blend
, dst_blend
;
445 unsigned int rt_fmt_flags
;
447 enable_line_smooth
= state
->render_states
[WINED3D_RS_EDGEANTIALIAS
]
448 || state
->render_states
[WINED3D_RS_ANTIALIASEDLINEENABLE
];
449 if (enable_line_smooth
)
451 gl_info
->gl_ops
.gl
.p_glEnable(GL_LINE_SMOOTH
);
452 checkGLcall("glEnable(GL_LINE_SMOOTH)");
456 gl_info
->gl_ops
.gl
.p_glDisable(GL_LINE_SMOOTH
);
457 checkGLcall("glDisable(GL_LINE_SMOOTH)");
460 enable_blend
= state
->fb
->render_targets
[0] && state
->render_states
[WINED3D_RS_ALPHABLENDENABLE
];
463 rt_format
= state
->fb
->render_targets
[0]->format
;
464 rt_fmt_flags
= state
->fb
->render_targets
[0]->format_flags
;
466 /* Disable blending in all cases even without pixelshaders.
467 * With blending on we could face a big performance penalty.
468 * The d3d9 visual test confirms the behavior. */
469 if (context
->render_offscreen
&& !(rt_fmt_flags
& WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
))
470 enable_blend
= FALSE
;
475 gl_info
->gl_ops
.gl
.p_glEnable(GL_BLEND
);
476 checkGLcall("glEnable(GL_BLEND)");
480 gl_info
->gl_ops
.gl
.p_glDisable(GL_BLEND
);
481 checkGLcall("glDisable(GL_BLEND)");
482 if (enable_line_smooth
)
483 WARN("LINE/EDGEANTIALIAS enabled with disabled blending.\n");
487 gl_blend_from_d3d(&src_blend
, &dst_blend
,
488 state
->render_states
[WINED3D_RS_SRCBLEND
],
489 state
->render_states
[WINED3D_RS_DESTBLEND
], rt_format
);
491 /* According to the red book, GL_LINE_SMOOTH needs GL_BLEND with specific
492 * blending parameters to work. */
493 if (enable_line_smooth
)
495 if (src_blend
!= GL_SRC_ALPHA
)
496 WARN("LINE/EDGEANTIALIAS enabled, but unexpected src blending param.\n");
497 if (dst_blend
!= GL_ONE_MINUS_SRC_ALPHA
&& dst_blend
!= GL_ONE
)
498 WARN("LINE/EDGEANTIALIAS enabled, but unexpected dst blending param.\n");
501 /* Re-apply BLENDOP(ALPHA) because of a possible SEPARATEALPHABLENDENABLE change */
502 if (!isStateDirty(context
, STATE_RENDER(WINED3D_RS_BLENDOP
)))
503 state_blendop(context
, state
, STATE_RENDER(WINED3D_RS_BLENDOPALPHA
));
505 if (state
->render_states
[WINED3D_RS_SEPARATEALPHABLENDENABLE
])
507 GLenum src_blend_alpha
, dst_blend_alpha
;
509 /* Separate alpha blending requires GL_EXT_blend_function_separate, so make sure it is around */
510 if (!context
->gl_info
->supported
[EXT_BLEND_FUNC_SEPARATE
])
512 WARN("Unsupported in local OpenGL implementation: glBlendFuncSeparate.\n");
516 gl_blend_from_d3d(&src_blend_alpha
, &dst_blend_alpha
,
517 state
->render_states
[WINED3D_RS_SRCBLENDALPHA
],
518 state
->render_states
[WINED3D_RS_DESTBLENDALPHA
], rt_format
);
520 GL_EXTCALL(glBlendFuncSeparate(src_blend
, dst_blend
, src_blend_alpha
, dst_blend_alpha
));
521 checkGLcall("glBlendFuncSeparate");
525 TRACE("glBlendFunc src=%x, dst=%x.\n", src_blend
, dst_blend
);
526 gl_info
->gl_ops
.gl
.p_glBlendFunc(src_blend
, dst_blend
);
527 checkGLcall("glBlendFunc");
530 /* Colorkey fixup for stage 0 alphaop depends on
531 * WINED3D_RS_ALPHABLENDENABLE state, so it may need updating. */
532 if (state
->render_states
[WINED3D_RS_COLORKEYENABLE
])
533 context_apply_state(context
, state
, STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
));
536 static void state_blendfactor_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
538 WARN("Unsupported in local OpenGL implementation: glBlendColor.\n");
541 static void state_blendfactor(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
543 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
544 struct wined3d_color color
;
546 TRACE("Setting blend factor to %#x.\n", state
->render_states
[WINED3D_RS_BLENDFACTOR
]);
548 wined3d_color_from_d3dcolor(&color
, state
->render_states
[WINED3D_RS_BLENDFACTOR
]);
549 GL_EXTCALL(glBlendColor(color
.r
, color
.g
, color
.b
, color
.a
));
550 checkGLcall("glBlendColor");
553 void state_alpha_test(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
555 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
558 BOOL enable_ckey
= FALSE
;
560 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
562 /* Find out if the texture on the first stage has a ckey set. The alpha
563 * state func reads the texture settings, even though alpha and texture
564 * are not grouped together. This is to avoid making a huge alpha +
565 * texture + texture stage + ckey block due to the hardly used
566 * WINED3D_RS_COLORKEYENABLE state(which is d3d <= 3 only). The texture
567 * function will call alpha in case it finds some texture + colorkeyenable
568 * combination which needs extra care. */
569 if (state
->textures
[0] && (state
->textures
[0]->async
.color_key_flags
& WINED3D_CKEY_SRC_BLT
))
572 if (enable_ckey
|| context
->last_was_ckey
)
573 context_apply_state(context
, state
, STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
));
574 context
->last_was_ckey
= enable_ckey
;
576 if (state
->render_states
[WINED3D_RS_ALPHATESTENABLE
]
577 || (state
->render_states
[WINED3D_RS_COLORKEYENABLE
] && enable_ckey
))
579 gl_info
->gl_ops
.gl
.p_glEnable(GL_ALPHA_TEST
);
580 checkGLcall("glEnable GL_ALPHA_TEST");
584 gl_info
->gl_ops
.gl
.p_glDisable(GL_ALPHA_TEST
);
585 checkGLcall("glDisable GL_ALPHA_TEST");
586 /* Alpha test is disabled, don't bother setting the params - it will happen on the next
592 if (state
->render_states
[WINED3D_RS_COLORKEYENABLE
] && enable_ckey
)
594 glParm
= GL_NOTEQUAL
;
599 ref
= ((float)state
->render_states
[WINED3D_RS_ALPHAREF
]) / 255.0f
;
600 glParm
= wined3d_gl_compare_func(state
->render_states
[WINED3D_RS_ALPHAFUNC
]);
604 gl_info
->gl_ops
.gl
.p_glAlphaFunc(glParm
, ref
);
605 checkGLcall("glAlphaFunc");
609 void state_clipping(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
611 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
612 unsigned int clipplane_count
= gl_info
->limits
.clipplanes
;
613 unsigned int i
, enable_mask
, disable_mask
;
615 if (use_vs(state
) && !context
->d3d_info
->vs_clipping
)
619 /* The OpenGL spec says that clipping planes are disabled when using
620 * shaders. Direct3D planes aren't, so that is an issue. The MacOS ATI
621 * driver keeps clipping planes activated with shaders in some
622 * conditions I got sick of tracking down. The shader state handler
623 * disables all clip planes because of that - don't do anything here
624 * and keep them disabled. */
625 if (state
->render_states
[WINED3D_RS_CLIPPLANEENABLE
] && !warned
++)
626 FIXME("Clipping not supported with vertex shaders\n");
630 /* glEnable(GL_CLIP_PLANEx) doesn't apply to (ARB backend) vertex shaders.
631 * The enabled / disabled planes are hardcoded into the shader. Update the
632 * shader to update the enabled clipplanes. In case of fixed function, we
633 * need to update the clipping field from ffp_vertex_settings. */
634 context
->shader_update_mask
|= 1u << WINED3D_SHADER_TYPE_VERTEX
;
636 /* TODO: Keep track of previously enabled clipplanes to avoid unnecessary resetting
637 * of already set values
640 /* If enabling / disabling all
641 * TODO: Is this correct? Doesn't D3DRS_CLIPPING disable clipping on the viewport frustrum?
643 if (state
->render_states
[WINED3D_RS_CLIPPING
])
645 enable_mask
= state
->render_states
[WINED3D_RS_CLIPPLANEENABLE
];
646 disable_mask
= ~state
->render_states
[WINED3D_RS_CLIPPLANEENABLE
];
654 if (clipplane_count
< 32)
656 enable_mask
&= (1u << clipplane_count
) - 1;
657 disable_mask
&= (1u << clipplane_count
) - 1;
660 for (i
= 0; enable_mask
&& i
< clipplane_count
; enable_mask
>>= 1, ++i
)
662 gl_info
->gl_ops
.gl
.p_glEnable(GL_CLIP_DISTANCE0
+ i
);
663 checkGLcall("clip plane enable");
665 for (i
= 0; disable_mask
&& i
< clipplane_count
; disable_mask
>>= 1, ++i
)
666 if (disable_mask
& 1)
667 gl_info
->gl_ops
.gl
.p_glDisable(GL_CLIP_DISTANCE0
+ i
);
668 checkGLcall("clip plane disable");
671 static void state_specularenable(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
673 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
674 /* Originally this used glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR)
675 * and (GL_LIGHT_MODEL_COLOR_CONTROL,GL_SINGLE_COLOR) to swap between enabled/disabled
676 * specular color. This is wrong:
677 * Separate specular color means the specular colour is maintained separately, whereas
678 * single color means it is merged in. However in both cases they are being used to
680 * To disable specular color, set it explicitly to black and turn off GL_COLOR_SUM_EXT
681 * NOTE: If not supported don't give FIXMEs the impact is really minimal and very few people are
685 * If register combiners are enabled, enabling / disabling GL_COLOR_SUM has no effect.
686 * Instead, we need to setup the FinalCombiner properly.
688 * The default setup for the FinalCombiner is:
690 * <variable> <input> <mapping> <usage>
691 * GL_VARIABLE_A_NV GL_FOG, GL_UNSIGNED_IDENTITY_NV GL_ALPHA
692 * GL_VARIABLE_B_NV GL_SPARE0_PLUS_SECONDARY_COLOR_NV GL_UNSIGNED_IDENTITY_NV GL_RGB
693 * GL_VARIABLE_C_NV GL_FOG GL_UNSIGNED_IDENTITY_NV GL_RGB
694 * GL_VARIABLE_D_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
695 * GL_VARIABLE_E_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
696 * GL_VARIABLE_F_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
697 * GL_VARIABLE_G_NV GL_SPARE0_NV GL_UNSIGNED_IDENTITY_NV GL_ALPHA
699 * That's pretty much fine as it is, except for variable B, which needs to take
700 * either GL_SPARE0_PLUS_SECONDARY_COLOR_NV or GL_SPARE0_NV, depending on
701 * whether WINED3D_RS_SPECULARENABLE is enabled or not.
704 TRACE("Setting specular enable state and materials\n");
705 if (state
->render_states
[WINED3D_RS_SPECULARENABLE
])
707 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, (float *)&state
->material
.specular
);
708 checkGLcall("glMaterialfv");
710 if (state
->material
.power
> gl_info
->limits
.shininess
)
712 /* glMaterialf man page says that the material says that GL_SHININESS must be between 0.0
713 * and 128.0, although in d3d neither -1 nor 129 produce an error. GL_NV_max_light_exponent
714 * allows bigger values. If the extension is supported, gl_info->limits.shininess contains the
715 * value reported by the extension, otherwise 128. For values > gl_info->limits.shininess clamp
716 * them, it should be safe to do so without major visual distortions.
718 WARN("Material power = %.8e, limit %.8e\n", state
->material
.power
, gl_info
->limits
.shininess
);
719 gl_info
->gl_ops
.gl
.p_glMaterialf(GL_FRONT_AND_BACK
, GL_SHININESS
, gl_info
->limits
.shininess
);
723 gl_info
->gl_ops
.gl
.p_glMaterialf(GL_FRONT_AND_BACK
, GL_SHININESS
, state
->material
.power
);
725 checkGLcall("glMaterialf(GL_SHININESS)");
727 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
728 gl_info
->gl_ops
.gl
.p_glEnable(GL_COLOR_SUM_EXT
);
730 TRACE("Specular colors cannot be enabled in this version of opengl\n");
731 checkGLcall("glEnable(GL_COLOR_SUM)");
733 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
735 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV
, GL_SPARE0_PLUS_SECONDARY_COLOR_NV
, GL_UNSIGNED_IDENTITY_NV
, GL_RGB
));
736 checkGLcall("glFinalCombinerInputNV()");
739 static const GLfloat black
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
741 /* for the case of enabled lighting: */
742 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, &black
[0]);
743 checkGLcall("glMaterialfv");
745 /* for the case of disabled lighting: */
746 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
747 gl_info
->gl_ops
.gl
.p_glDisable(GL_COLOR_SUM_EXT
);
749 TRACE("Specular colors cannot be disabled in this version of opengl\n");
750 checkGLcall("glDisable(GL_COLOR_SUM)");
752 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
754 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV
, GL_SPARE0_NV
, GL_UNSIGNED_IDENTITY_NV
, GL_RGB
));
755 checkGLcall("glFinalCombinerInputNV()");
759 TRACE("diffuse %s\n", debug_color(&state
->material
.diffuse
));
760 TRACE("ambient %s\n", debug_color(&state
->material
.ambient
));
761 TRACE("specular %s\n", debug_color(&state
->material
.specular
));
762 TRACE("emissive %s\n", debug_color(&state
->material
.emissive
));
764 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float *)&state
->material
.ambient
);
765 checkGLcall("glMaterialfv(GL_AMBIENT)");
766 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float *)&state
->material
.diffuse
);
767 checkGLcall("glMaterialfv(GL_DIFFUSE)");
768 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_EMISSION
, (float *)&state
->material
.emissive
);
769 checkGLcall("glMaterialfv(GL_EMISSION)");
772 static void state_texfactor(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
774 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
775 struct wined3d_color color
;
778 /* Note the texture color applies to all textures whereas
779 * GL_TEXTURE_ENV_COLOR applies to active only. */
780 wined3d_color_from_d3dcolor(&color
, state
->render_states
[WINED3D_RS_TEXTUREFACTOR
]);
782 /* And now the default texture color as well */
783 for (i
= 0; i
< context
->d3d_info
->limits
.ffp_blend_stages
; ++i
)
785 /* Note the WINED3D_RS value applies to all textures, but GL has one
786 * per texture, so apply it now ready to be used! */
787 context_active_texture(context
, gl_info
, i
);
789 gl_info
->gl_ops
.gl
.p_glTexEnvfv(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_COLOR
, &color
.r
);
790 checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);");
794 static void renderstate_stencil_twosided(struct wined3d_context
*context
, GLint face
,
795 GLint func
, GLint ref
, GLuint mask
, GLint stencilFail
, GLint depthFail
, GLint stencilPass
)
797 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
799 gl_info
->gl_ops
.gl
.p_glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT
);
800 checkGLcall("glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT)");
801 GL_EXTCALL(glActiveStencilFaceEXT(face
));
802 checkGLcall("glActiveStencilFaceEXT(...)");
803 gl_info
->gl_ops
.gl
.p_glStencilFunc(func
, ref
, mask
);
804 checkGLcall("glStencilFunc(...)");
805 gl_info
->gl_ops
.gl
.p_glStencilOp(stencilFail
, depthFail
, stencilPass
);
806 checkGLcall("glStencilOp(...)");
809 static GLenum
gl_stencil_op(enum wined3d_stencil_op op
)
813 case WINED3D_STENCIL_OP_KEEP
:
815 case WINED3D_STENCIL_OP_ZERO
:
817 case WINED3D_STENCIL_OP_REPLACE
:
819 case WINED3D_STENCIL_OP_INCR_SAT
:
821 case WINED3D_STENCIL_OP_DECR_SAT
:
823 case WINED3D_STENCIL_OP_INVERT
:
825 case WINED3D_STENCIL_OP_INCR
:
827 case WINED3D_STENCIL_OP_DECR
:
830 FIXME("Unrecognized stencil op %#x.\n", op
);
835 static void state_stencil(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
837 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
838 DWORD onesided_enable
;
839 DWORD twosided_enable
;
845 GLint stencilFail_ccw
;
847 GLint stencilPass_ccw
;
851 /* No stencil test without a stencil buffer. */
852 if (!state
->fb
->depth_stencil
)
854 gl_info
->gl_ops
.gl
.p_glDisable(GL_STENCIL_TEST
);
855 checkGLcall("glDisable GL_STENCIL_TEST");
859 onesided_enable
= state
->render_states
[WINED3D_RS_STENCILENABLE
];
860 twosided_enable
= state
->render_states
[WINED3D_RS_TWOSIDEDSTENCILMODE
];
861 if (!(func
= wined3d_gl_compare_func(state
->render_states
[WINED3D_RS_STENCILFUNC
])))
863 if (!(func_ccw
= wined3d_gl_compare_func(state
->render_states
[WINED3D_RS_CCW_STENCILFUNC
])))
864 func_ccw
= GL_ALWAYS
;
865 ref
= state
->render_states
[WINED3D_RS_STENCILREF
];
866 mask
= state
->render_states
[WINED3D_RS_STENCILMASK
];
867 stencilFail
= gl_stencil_op(state
->render_states
[WINED3D_RS_STENCILFAIL
]);
868 depthFail
= gl_stencil_op(state
->render_states
[WINED3D_RS_STENCILZFAIL
]);
869 stencilPass
= gl_stencil_op(state
->render_states
[WINED3D_RS_STENCILPASS
]);
870 stencilFail_ccw
= gl_stencil_op(state
->render_states
[WINED3D_RS_CCW_STENCILFAIL
]);
871 depthFail_ccw
= gl_stencil_op(state
->render_states
[WINED3D_RS_CCW_STENCILZFAIL
]);
872 stencilPass_ccw
= gl_stencil_op(state
->render_states
[WINED3D_RS_CCW_STENCILPASS
]);
874 TRACE("(onesided %d, twosided %d, ref %x, mask %x, "
875 "GL_FRONT: func: %x, fail %x, zfail %x, zpass %x "
876 "GL_BACK: func: %x, fail %x, zfail %x, zpass %x )\n",
877 onesided_enable
, twosided_enable
, ref
, mask
,
878 func
, stencilFail
, depthFail
, stencilPass
,
879 func_ccw
, stencilFail_ccw
, depthFail_ccw
, stencilPass_ccw
);
881 if (twosided_enable
&& onesided_enable
)
883 gl_info
->gl_ops
.gl
.p_glEnable(GL_STENCIL_TEST
);
884 checkGLcall("glEnable GL_STENCIL_TEST");
886 if (gl_info
->supported
[WINED3D_GL_VERSION_2_0
])
888 GL_EXTCALL(glStencilFuncSeparate(GL_FRONT
, func
, ref
, mask
));
889 GL_EXTCALL(glStencilOpSeparate(GL_FRONT
, stencilFail
, depthFail
, stencilPass
));
890 GL_EXTCALL(glStencilFuncSeparate(GL_BACK
, func_ccw
, ref
, mask
));
891 GL_EXTCALL(glStencilOpSeparate(GL_BACK
, stencilFail_ccw
, depthFail_ccw
, stencilPass_ccw
));
892 checkGLcall("setting two sided stencil state");
894 else if (gl_info
->supported
[EXT_STENCIL_TWO_SIDE
])
896 /* Apply back first, then front. This function calls glActiveStencilFaceEXT,
897 * which has an effect on the code below too. If we apply the front face
898 * afterwards, we are sure that the active stencil face is set to front,
899 * and other stencil functions which do not use two sided stencil do not have
902 renderstate_stencil_twosided(context
, GL_BACK
,
903 func_ccw
, ref
, mask
, stencilFail_ccw
, depthFail_ccw
, stencilPass_ccw
);
904 renderstate_stencil_twosided(context
, GL_FRONT
,
905 func
, ref
, mask
, stencilFail
, depthFail
, stencilPass
);
907 else if (gl_info
->supported
[ATI_SEPARATE_STENCIL
])
909 GL_EXTCALL(glStencilFuncSeparateATI(func
, func_ccw
, ref
, mask
));
910 checkGLcall("glStencilFuncSeparateATI(...)");
911 GL_EXTCALL(glStencilOpSeparateATI(GL_FRONT
, stencilFail
, depthFail
, stencilPass
));
912 checkGLcall("glStencilOpSeparateATI(GL_FRONT, ...)");
913 GL_EXTCALL(glStencilOpSeparateATI(GL_BACK
, stencilFail_ccw
, depthFail_ccw
, stencilPass_ccw
));
914 checkGLcall("glStencilOpSeparateATI(GL_BACK, ...)");
918 ERR("Separate (two sided) stencil not supported on this version of opengl. Caps weren't honored?\n");
921 else if(onesided_enable
)
923 if (gl_info
->supported
[EXT_STENCIL_TWO_SIDE
])
925 gl_info
->gl_ops
.gl
.p_glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT
);
926 checkGLcall("glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT)");
929 /* This code disables the ATI extension as well, since the standard stencil functions are equal
930 * to calling the ATI functions with GL_FRONT_AND_BACK as face parameter
932 gl_info
->gl_ops
.gl
.p_glEnable(GL_STENCIL_TEST
);
933 checkGLcall("glEnable GL_STENCIL_TEST");
934 gl_info
->gl_ops
.gl
.p_glStencilFunc(func
, ref
, mask
);
935 checkGLcall("glStencilFunc(...)");
936 gl_info
->gl_ops
.gl
.p_glStencilOp(stencilFail
, depthFail
, stencilPass
);
937 checkGLcall("glStencilOp(...)");
941 gl_info
->gl_ops
.gl
.p_glDisable(GL_STENCIL_TEST
);
942 checkGLcall("glDisable GL_STENCIL_TEST");
946 static void state_stencilwrite2s(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
948 DWORD mask
= state
->fb
->depth_stencil
? state
->render_states
[WINED3D_RS_STENCILWRITEMASK
] : 0;
949 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
951 GL_EXTCALL(glActiveStencilFaceEXT(GL_BACK
));
952 checkGLcall("glActiveStencilFaceEXT(GL_BACK)");
953 gl_info
->gl_ops
.gl
.p_glStencilMask(mask
);
954 checkGLcall("glStencilMask");
955 GL_EXTCALL(glActiveStencilFaceEXT(GL_FRONT
));
956 checkGLcall("glActiveStencilFaceEXT(GL_FRONT)");
957 gl_info
->gl_ops
.gl
.p_glStencilMask(mask
);
960 static void state_stencilwrite(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
962 DWORD mask
= state
->fb
->depth_stencil
? state
->render_states
[WINED3D_RS_STENCILWRITEMASK
] : 0;
963 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
965 gl_info
->gl_ops
.gl
.p_glStencilMask(mask
);
966 checkGLcall("glStencilMask");
969 static void state_fog_vertexpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
971 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
973 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
975 if (!state
->render_states
[WINED3D_RS_FOGENABLE
])
978 /* Table fog on: Never use fog coords, and use per-fragment fog */
979 if (state
->render_states
[WINED3D_RS_FOGTABLEMODE
] != WINED3D_FOG_NONE
)
981 gl_info
->gl_ops
.gl
.p_glHint(GL_FOG_HINT
, GL_NICEST
);
982 if (context
->fog_coord
)
984 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FRAGMENT_DEPTH_EXT
);
985 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT)");
986 context
->fog_coord
= FALSE
;
989 /* Range fog is only used with per-vertex fog in d3d */
990 if (gl_info
->supported
[NV_FOG_DISTANCE
])
992 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_DISTANCE_MODE_NV
, GL_EYE_PLANE_ABSOLUTE_NV
);
993 checkGLcall("glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_PLANE_ABSOLUTE_NV)");
998 /* Otherwise use per-vertex fog in any case */
999 gl_info
->gl_ops
.gl
.p_glHint(GL_FOG_HINT
, GL_FASTEST
);
1001 if (state
->render_states
[WINED3D_RS_FOGVERTEXMODE
] == WINED3D_FOG_NONE
|| context
->last_was_rhw
)
1003 /* No fog at all, or transformed vertices: Use fog coord */
1004 if (!context
->fog_coord
)
1006 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FOG_COORDINATE_EXT
);
1007 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT)");
1008 context
->fog_coord
= TRUE
;
1013 /* Otherwise, use the fragment depth */
1014 if (context
->fog_coord
)
1016 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FRAGMENT_DEPTH_EXT
);
1017 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT)");
1018 context
->fog_coord
= FALSE
;
1021 if (state
->render_states
[WINED3D_RS_RANGEFOGENABLE
])
1023 if (gl_info
->supported
[NV_FOG_DISTANCE
])
1025 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_DISTANCE_MODE_NV
, GL_EYE_RADIAL_NV
);
1026 checkGLcall("glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_RADIAL_NV)");
1030 WARN("Range fog enabled, but not supported by this GL implementation.\n");
1033 else if (gl_info
->supported
[NV_FOG_DISTANCE
])
1035 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_DISTANCE_MODE_NV
, GL_EYE_PLANE_ABSOLUTE_NV
);
1036 checkGLcall("glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_PLANE_ABSOLUTE_NV)");
1041 void state_fogstartend(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1043 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1044 float fogstart
, fogend
;
1046 get_fog_start_end(context
, state
, &fogstart
, &fogend
);
1048 gl_info
->gl_ops
.gl
.p_glFogf(GL_FOG_START
, fogstart
);
1049 checkGLcall("glFogf(GL_FOG_START, fogstart)");
1050 TRACE("Fog Start == %f\n", fogstart
);
1052 gl_info
->gl_ops
.gl
.p_glFogf(GL_FOG_END
, fogend
);
1053 checkGLcall("glFogf(GL_FOG_END, fogend)");
1054 TRACE("Fog End == %f\n", fogend
);
1057 void state_fog_fragpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1059 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1060 enum fogsource new_source
;
1061 DWORD fogstart
= state
->render_states
[WINED3D_RS_FOGSTART
];
1062 DWORD fogend
= state
->render_states
[WINED3D_RS_FOGEND
];
1064 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
1066 if (!state
->render_states
[WINED3D_RS_FOGENABLE
])
1068 /* No fog? Disable it, and we're done :-) */
1069 glDisableWINE(GL_FOG
);
1070 checkGLcall("glDisable GL_FOG");
1076 * With fixed function vertex processing, Direct3D knows 2 different fog input sources.
1077 * It can use the Z value of the vertex, or the alpha component of the specular color.
1078 * This depends on the fog vertex, fog table and the vertex declaration. If the Z value
1079 * is used, fogstart, fogend and the equation type are used, otherwise linear fog with
1080 * start = 255, end = 0 is used. Obviously the msdn is not very clear on that.
1082 * FOGTABLEMODE != NONE:
1083 * The Z value is used, with the equation specified, no matter what vertex type.
1085 * FOGTABLEMODE == NONE, FOGVERTEXMODE != NONE, untransformed:
1086 * Per vertex fog is calculated using the specified fog equation and the parameters
1088 * FOGTABLEMODE == NONE, FOGVERTEXMODE != NONE, transformed, OR
1089 * FOGTABLEMODE == NONE, FOGVERTEXMODE == NONE, untransformed:
1090 * Linear fog with start = 255.0, end = 0.0, input comes from the specular color
1093 * Rules for vertex fog with shaders:
1095 * When mixing fixed function functionality with the programmable pipeline, D3D expects
1096 * the fog computation to happen during transformation while openGL expects it to happen
1097 * during rasterization. Also, prior to pixel shader 3.0 D3D handles fog blending after
1098 * the pixel shader while openGL always expects the pixel shader to handle the blending.
1099 * To solve this problem, WineD3D does:
1100 * 1) implement a linear fog equation and fog blending at the end of every pre 3.0 pixel
1102 * and 2) disables the fog computation (in either the fixed function or programmable
1103 * rasterizer) if using a vertex program.
1105 * D3D shaders can provide an explicit fog coordinate. This fog coordinate is used with
1106 * D3DRS_FOGTABLEMODE==D3DFOG_NONE. The FOGVERTEXMODE is ignored, d3d always uses linear
1107 * fog with start=1.0 and end=0.0 in this case. This is similar to fog coordinates in
1108 * the specular color, a vertex shader counts as pretransformed geometry in this case.
1109 * There are some GL differences between specular fog coords and vertex shaders though.
1111 * With table fog the vertex shader fog coordinate is ignored.
1113 * If a fogtablemode and a fogvertexmode are specified, table fog is applied (with or
1117 /* DX 7 sdk: "If both render states(vertex and table fog) are set to valid modes,
1118 * the system will apply only pixel(=table) fog effects."
1120 if (state
->render_states
[WINED3D_RS_FOGTABLEMODE
] == WINED3D_FOG_NONE
)
1124 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_LINEAR
);
1125 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1126 new_source
= FOGSOURCE_VS
;
1130 switch (state
->render_states
[WINED3D_RS_FOGVERTEXMODE
])
1132 /* If processed vertices are used, fall through to the NONE case */
1133 case WINED3D_FOG_EXP
:
1134 if (!context
->last_was_rhw
)
1136 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_EXP
);
1137 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP)");
1138 new_source
= FOGSOURCE_FFP
;
1143 case WINED3D_FOG_EXP2
:
1144 if (!context
->last_was_rhw
)
1146 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_EXP2
);
1147 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2)");
1148 new_source
= FOGSOURCE_FFP
;
1153 case WINED3D_FOG_LINEAR
:
1154 if (!context
->last_was_rhw
)
1156 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_LINEAR
);
1157 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1158 new_source
= FOGSOURCE_FFP
;
1163 case WINED3D_FOG_NONE
:
1164 /* Both are none? According to msdn the alpha channel of
1165 * the specular colour contains a fog factor. Set it in
1166 * draw_primitive_immediate_mode(). Same happens with
1167 * vertex fog on transformed vertices. */
1168 new_source
= FOGSOURCE_COORD
;
1169 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_LINEAR
);
1170 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1174 FIXME("Unexpected WINED3D_RS_FOGVERTEXMODE %#x.\n",
1175 state
->render_states
[WINED3D_RS_FOGVERTEXMODE
]);
1176 new_source
= FOGSOURCE_FFP
; /* Make the compiler happy */
1180 new_source
= FOGSOURCE_FFP
;
1182 switch (state
->render_states
[WINED3D_RS_FOGTABLEMODE
])
1184 case WINED3D_FOG_EXP
:
1185 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_EXP
);
1186 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP)");
1189 case WINED3D_FOG_EXP2
:
1190 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_EXP2
);
1191 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2)");
1194 case WINED3D_FOG_LINEAR
:
1195 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_LINEAR
);
1196 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1199 case WINED3D_FOG_NONE
: /* Won't happen */
1201 FIXME("Unexpected WINED3D_RS_FOGTABLEMODE %#x.\n",
1202 state
->render_states
[WINED3D_RS_FOGTABLEMODE
]);
1206 glEnableWINE(GL_FOG
);
1207 checkGLcall("glEnable GL_FOG");
1208 if (new_source
!= context
->fog_source
|| fogstart
== fogend
)
1210 context
->fog_source
= new_source
;
1211 state_fogstartend(context
, state
, STATE_RENDER(WINED3D_RS_FOGSTART
));
1215 void state_fogcolor(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1217 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1218 struct wined3d_color color
;
1220 wined3d_color_from_d3dcolor(&color
, state
->render_states
[WINED3D_RS_FOGCOLOR
]);
1221 gl_info
->gl_ops
.gl
.p_glFogfv(GL_FOG_COLOR
, &color
.r
);
1222 checkGLcall("glFog GL_FOG_COLOR");
1225 void state_fogdensity(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1227 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1233 tmpvalue
.d
= state
->render_states
[WINED3D_RS_FOGDENSITY
];
1234 gl_info
->gl_ops
.gl
.p_glFogfv(GL_FOG_DENSITY
, &tmpvalue
.f
);
1235 checkGLcall("glFogf(GL_FOG_DENSITY, (float) Value)");
1238 static void state_colormat(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1240 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1243 /* Depends on the decoded vertex declaration to read the existence of diffuse data.
1244 * The vertex declaration will call this function if the fixed function pipeline is used.
1247 if(isStateDirty(context
, STATE_VDECL
)) {
1251 context
->num_untracked_materials
= 0;
1252 if ((context
->stream_info
.use_map
& (1u << WINED3D_FFP_DIFFUSE
))
1253 && state
->render_states
[WINED3D_RS_COLORVERTEX
])
1255 TRACE("diff %d, amb %d, emis %d, spec %d\n",
1256 state
->render_states
[WINED3D_RS_DIFFUSEMATERIALSOURCE
],
1257 state
->render_states
[WINED3D_RS_AMBIENTMATERIALSOURCE
],
1258 state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
],
1259 state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
]);
1261 if (state
->render_states
[WINED3D_RS_DIFFUSEMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1263 if (state
->render_states
[WINED3D_RS_AMBIENTMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1264 Parm
= GL_AMBIENT_AND_DIFFUSE
;
1267 if (state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1269 context
->untracked_materials
[context
->num_untracked_materials
] = GL_EMISSION
;
1270 context
->num_untracked_materials
++;
1272 if (state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1274 context
->untracked_materials
[context
->num_untracked_materials
] = GL_SPECULAR
;
1275 context
->num_untracked_materials
++;
1278 else if (state
->render_states
[WINED3D_RS_AMBIENTMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1281 if (state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1283 context
->untracked_materials
[context
->num_untracked_materials
] = GL_EMISSION
;
1284 context
->num_untracked_materials
++;
1286 if (state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1288 context
->untracked_materials
[context
->num_untracked_materials
] = GL_SPECULAR
;
1289 context
->num_untracked_materials
++;
1292 else if (state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1295 if (state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1297 context
->untracked_materials
[context
->num_untracked_materials
] = GL_SPECULAR
;
1298 context
->num_untracked_materials
++;
1301 else if (state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1307 /* Nothing changed, return. */
1308 if (Parm
== context
->tracking_parm
) return;
1312 gl_info
->gl_ops
.gl
.p_glDisable(GL_COLOR_MATERIAL
);
1313 checkGLcall("glDisable GL_COLOR_MATERIAL");
1317 gl_info
->gl_ops
.gl
.p_glColorMaterial(GL_FRONT_AND_BACK
, Parm
);
1318 checkGLcall("glColorMaterial(GL_FRONT_AND_BACK, Parm)");
1319 gl_info
->gl_ops
.gl
.p_glEnable(GL_COLOR_MATERIAL
);
1320 checkGLcall("glEnable(GL_COLOR_MATERIAL)");
1323 /* Apparently calls to glMaterialfv are ignored for properties we're
1324 * tracking with glColorMaterial, so apply those here. */
1325 switch (context
->tracking_parm
)
1327 case GL_AMBIENT_AND_DIFFUSE
:
1328 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float *)&state
->material
.ambient
);
1329 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float *)&state
->material
.diffuse
);
1330 checkGLcall("glMaterialfv");
1334 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float *)&state
->material
.diffuse
);
1335 checkGLcall("glMaterialfv");
1339 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float *)&state
->material
.ambient
);
1340 checkGLcall("glMaterialfv");
1344 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_EMISSION
, (float *)&state
->material
.emissive
);
1345 checkGLcall("glMaterialfv");
1349 /* Only change material color if specular is enabled, otherwise it is set to black */
1350 if (state
->render_states
[WINED3D_RS_SPECULARENABLE
])
1352 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, (float *)&state
->material
.specular
);
1353 checkGLcall("glMaterialfv");
1357 static const GLfloat black
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
1358 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, &black
[0]);
1359 checkGLcall("glMaterialfv");
1364 context
->tracking_parm
= Parm
;
1367 static void state_linepattern(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1369 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1373 struct wined3d_line_pattern lp
;
1375 tmppattern
.d
= state
->render_states
[WINED3D_RS_LINEPATTERN
];
1377 TRACE("Line pattern: repeat %d bits %x.\n", tmppattern
.lp
.repeat_factor
, tmppattern
.lp
.line_pattern
);
1379 if (tmppattern
.lp
.repeat_factor
)
1381 gl_info
->gl_ops
.gl
.p_glLineStipple(tmppattern
.lp
.repeat_factor
, tmppattern
.lp
.line_pattern
);
1382 checkGLcall("glLineStipple(repeat, linepattern)");
1383 gl_info
->gl_ops
.gl
.p_glEnable(GL_LINE_STIPPLE
);
1384 checkGLcall("glEnable(GL_LINE_STIPPLE);");
1388 gl_info
->gl_ops
.gl
.p_glDisable(GL_LINE_STIPPLE
);
1389 checkGLcall("glDisable(GL_LINE_STIPPLE);");
1393 static void state_linepattern_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1395 static unsigned int once
;
1398 FIXME("Setting line patterns is not supported in OpenGL core contexts.\n");
1401 static void state_normalize(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1403 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1405 if (isStateDirty(context
, STATE_VDECL
))
1408 /* Without vertex normals, we set the current normal to 0/0/0 to remove the diffuse factor
1409 * from the opengl lighting equation, as d3d does. Normalization of 0/0/0 can lead to a division
1410 * by zero and is not properly defined in opengl, so avoid it
1412 if (state
->render_states
[WINED3D_RS_NORMALIZENORMALS
]
1413 && (context
->stream_info
.use_map
& (1u << WINED3D_FFP_NORMAL
)))
1415 gl_info
->gl_ops
.gl
.p_glEnable(GL_NORMALIZE
);
1416 checkGLcall("glEnable(GL_NORMALIZE);");
1420 gl_info
->gl_ops
.gl
.p_glDisable(GL_NORMALIZE
);
1421 checkGLcall("glDisable(GL_NORMALIZE);");
1425 static void state_psizemin_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1429 get_pointsize_minmax(context
, state
, &min
, &max
);
1432 FIXME("WINED3D_RS_POINTSIZE_MIN value %.8e not supported on this OpenGL implementation.\n", min
);
1434 FIXME("WINED3D_RS_POINTSIZE_MAX value %.8e not supported on this OpenGL implementation.\n", max
);
1437 static void state_psizemin_ext(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1439 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1442 get_pointsize_minmax(context
, state
, &min
, &max
);
1444 GL_EXTCALL(glPointParameterfEXT
)(GL_POINT_SIZE_MIN_EXT
, min
);
1445 checkGLcall("glPointParameterfEXT(...)");
1446 GL_EXTCALL(glPointParameterfEXT
)(GL_POINT_SIZE_MAX_EXT
, max
);
1447 checkGLcall("glPointParameterfEXT(...)");
1450 static void state_psizemin_arb(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1452 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1455 get_pointsize_minmax(context
, state
, &min
, &max
);
1457 GL_EXTCALL(glPointParameterfARB
)(GL_POINT_SIZE_MIN_ARB
, min
);
1458 checkGLcall("glPointParameterfARB(...)");
1459 GL_EXTCALL(glPointParameterfARB
)(GL_POINT_SIZE_MAX_ARB
, max
);
1460 checkGLcall("glPointParameterfARB(...)");
1463 static void state_pscale(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1465 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1469 get_pointsize(context
, state
, &pointsize
, att
);
1471 if (gl_info
->supported
[ARB_POINT_PARAMETERS
])
1473 GL_EXTCALL(glPointParameterfvARB
)(GL_POINT_DISTANCE_ATTENUATION_ARB
, att
);
1474 checkGLcall("glPointParameterfvARB(GL_DISTANCE_ATTENUATION_ARB, ...)");
1476 else if (gl_info
->supported
[EXT_POINT_PARAMETERS
])
1478 GL_EXTCALL(glPointParameterfvEXT
)(GL_DISTANCE_ATTENUATION_EXT
, att
);
1479 checkGLcall("glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, ...)");
1481 else if (state
->render_states
[WINED3D_RS_POINTSCALEENABLE
])
1483 WARN("POINT_PARAMETERS not supported in this version of opengl\n");
1486 gl_info
->gl_ops
.gl
.p_glPointSize(max(pointsize
, FLT_MIN
));
1487 checkGLcall("glPointSize(...);");
1490 static void state_debug_monitor(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1492 WARN("token: %#x.\n", state
->render_states
[WINED3D_RS_DEBUGMONITORTOKEN
]);
1495 static void state_colorwrite(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1497 DWORD mask0
= state
->render_states
[WINED3D_RS_COLORWRITEENABLE
];
1498 DWORD mask1
= state
->render_states
[WINED3D_RS_COLORWRITEENABLE1
];
1499 DWORD mask2
= state
->render_states
[WINED3D_RS_COLORWRITEENABLE2
];
1500 DWORD mask3
= state
->render_states
[WINED3D_RS_COLORWRITEENABLE3
];
1501 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1503 TRACE("Color mask: r(%d) g(%d) b(%d) a(%d)\n",
1504 mask0
& WINED3DCOLORWRITEENABLE_RED
? 1 : 0,
1505 mask0
& WINED3DCOLORWRITEENABLE_GREEN
? 1 : 0,
1506 mask0
& WINED3DCOLORWRITEENABLE_BLUE
? 1 : 0,
1507 mask0
& WINED3DCOLORWRITEENABLE_ALPHA
? 1 : 0);
1508 gl_info
->gl_ops
.gl
.p_glColorMask(mask0
& WINED3DCOLORWRITEENABLE_RED
? GL_TRUE
: GL_FALSE
,
1509 mask0
& WINED3DCOLORWRITEENABLE_GREEN
? GL_TRUE
: GL_FALSE
,
1510 mask0
& WINED3DCOLORWRITEENABLE_BLUE
? GL_TRUE
: GL_FALSE
,
1511 mask0
& WINED3DCOLORWRITEENABLE_ALPHA
? GL_TRUE
: GL_FALSE
);
1512 checkGLcall("glColorMask(...)");
1514 if (!((mask1
== mask0
&& mask2
== mask0
&& mask3
== mask0
)
1515 || (mask1
== 0xf && mask2
== 0xf && mask3
== 0xf)))
1517 FIXME("WINED3D_RS_COLORWRITEENABLE/1/2/3, %#x/%#x/%#x/%#x not yet implemented.\n",
1518 mask0
, mask1
, mask2
, mask3
);
1519 FIXME("Missing of cap D3DPMISCCAPS_INDEPENDENTWRITEMASKS wasn't honored?\n");
1523 static void set_color_mask(const struct wined3d_gl_info
*gl_info
, UINT index
, DWORD mask
)
1525 GL_EXTCALL(glColorMaski(index
,
1526 mask
& WINED3DCOLORWRITEENABLE_RED
? GL_TRUE
: GL_FALSE
,
1527 mask
& WINED3DCOLORWRITEENABLE_GREEN
? GL_TRUE
: GL_FALSE
,
1528 mask
& WINED3DCOLORWRITEENABLE_BLUE
? GL_TRUE
: GL_FALSE
,
1529 mask
& WINED3DCOLORWRITEENABLE_ALPHA
? GL_TRUE
: GL_FALSE
));
1530 checkGLcall("glColorMaski");
1533 static void state_colorwrite0(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1535 set_color_mask(context
->gl_info
, 0, state
->render_states
[WINED3D_RS_COLORWRITEENABLE
]);
1538 static void state_colorwrite1(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1540 set_color_mask(context
->gl_info
, 1, state
->render_states
[WINED3D_RS_COLORWRITEENABLE1
]);
1543 static void state_colorwrite2(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1545 set_color_mask(context
->gl_info
, 2, state
->render_states
[WINED3D_RS_COLORWRITEENABLE2
]);
1548 static void state_colorwrite3(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1550 set_color_mask(context
->gl_info
, 3, state
->render_states
[WINED3D_RS_COLORWRITEENABLE3
]);
1553 static void state_localviewer(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1555 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1557 if (state
->render_states
[WINED3D_RS_LOCALVIEWER
])
1559 gl_info
->gl_ops
.gl
.p_glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER
, 1);
1560 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1)");
1564 gl_info
->gl_ops
.gl
.p_glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER
, 0);
1565 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 0)");
1569 static void state_lastpixel(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1571 if (state
->render_states
[WINED3D_RS_LASTPIXEL
])
1573 TRACE("Last Pixel Drawing Enabled\n");
1579 FIXME("Last Pixel Drawing Disabled, not handled yet\n");
1582 TRACE("Last Pixel Drawing Disabled, not handled yet\n");
1587 void state_pointsprite_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1591 /* TODO: NV_POINT_SPRITE */
1592 if (!warned
&& state
->render_states
[WINED3D_RS_POINTSPRITEENABLE
])
1594 /* A FIXME, not a WARN because point sprites should be software emulated if not supported by HW */
1595 FIXME("Point sprites not supported\n");
1600 void state_pointsprite(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1602 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1604 if (state
->render_states
[WINED3D_RS_POINTSPRITEENABLE
])
1606 gl_info
->gl_ops
.gl
.p_glEnable(GL_POINT_SPRITE_ARB
);
1607 checkGLcall("glEnable(GL_POINT_SPRITE_ARB)");
1611 gl_info
->gl_ops
.gl
.p_glDisable(GL_POINT_SPRITE_ARB
);
1612 checkGLcall("glDisable(GL_POINT_SPRITE_ARB)");
1616 static void state_wrap(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1618 static unsigned int once
;
1620 if ((state
->render_states
[WINED3D_RS_WRAP0
]
1621 || state
->render_states
[WINED3D_RS_WRAP1
]
1622 || state
->render_states
[WINED3D_RS_WRAP2
]
1623 || state
->render_states
[WINED3D_RS_WRAP3
]
1624 || state
->render_states
[WINED3D_RS_WRAP4
]
1625 || state
->render_states
[WINED3D_RS_WRAP5
]
1626 || state
->render_states
[WINED3D_RS_WRAP6
]
1627 || state
->render_states
[WINED3D_RS_WRAP7
]
1628 || state
->render_states
[WINED3D_RS_WRAP8
]
1629 || state
->render_states
[WINED3D_RS_WRAP9
]
1630 || state
->render_states
[WINED3D_RS_WRAP10
]
1631 || state
->render_states
[WINED3D_RS_WRAP11
]
1632 || state
->render_states
[WINED3D_RS_WRAP12
]
1633 || state
->render_states
[WINED3D_RS_WRAP13
]
1634 || state
->render_states
[WINED3D_RS_WRAP14
]
1635 || state
->render_states
[WINED3D_RS_WRAP15
])
1637 FIXME("(WINED3D_RS_WRAP0) Texture wrapping not yet supported.\n");
1640 static void state_msaa_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1642 if (state
->render_states
[WINED3D_RS_MULTISAMPLEANTIALIAS
])
1643 WARN("Multisample antialiasing not supported by GL.\n");
1646 static void state_msaa(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1648 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1650 if (state
->render_states
[WINED3D_RS_MULTISAMPLEANTIALIAS
])
1652 gl_info
->gl_ops
.gl
.p_glEnable(GL_MULTISAMPLE_ARB
);
1653 checkGLcall("glEnable(GL_MULTISAMPLE_ARB)");
1657 gl_info
->gl_ops
.gl
.p_glDisable(GL_MULTISAMPLE_ARB
);
1658 checkGLcall("glDisable(GL_MULTISAMPLE_ARB)");
1662 static void state_scissor(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1664 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1666 if (state
->render_states
[WINED3D_RS_SCISSORTESTENABLE
])
1668 gl_info
->gl_ops
.gl
.p_glEnable(GL_SCISSOR_TEST
);
1669 checkGLcall("glEnable(GL_SCISSOR_TEST)");
1673 gl_info
->gl_ops
.gl
.p_glDisable(GL_SCISSOR_TEST
);
1674 checkGLcall("glDisable(GL_SCISSOR_TEST)");
1678 /* The Direct3D depth bias is specified in normalized depth coordinates. In
1679 * OpenGL the bias is specified in units of "the smallest value that is
1680 * guaranteed to produce a resolvable offset for a given implementation". To
1681 * convert from D3D to GL we need to divide the D3D depth bias by that value.
1682 * We try to detect the value from GL with test draws. On most drivers (r300g,
1683 * 600g, Nvidia, i965 on Mesa) the value is 2^23 for fixed point depth buffers,
1684 * for r200 and i965 on OSX it is 2^24, for r500 on OSX it is 2^22. For floating
1685 * point buffers it is 2^22, 2^23 or 2^24 depending on the GPU. The value does
1686 * not depend on the depth buffer precision on any driver.
1688 * Two games that are picky regarding depth bias are Mass Effect 2 (flickering
1689 * decals) and F.E.A.R and F.E.A.R. 2 (semi-transparent guns).
1691 * Note that SLOPESCALEDEPTHBIAS is a scaling factor for the depth slope, and
1692 * doesn't need to be scaled to account for GL vs D3D differences. */
1693 static void state_depthbias(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1695 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1697 if (state
->render_states
[WINED3D_RS_SLOPESCALEDEPTHBIAS
]
1698 || state
->render_states
[WINED3D_RS_DEPTHBIAS
])
1700 const struct wined3d_rendertarget_view
*depth
= state
->fb
->depth_stencil
;
1707 } scale_bias
, const_bias
;
1709 scale_bias
.d
= state
->render_states
[WINED3D_RS_SLOPESCALEDEPTHBIAS
];
1710 const_bias
.d
= state
->render_states
[WINED3D_RS_DEPTHBIAS
];
1712 gl_info
->gl_ops
.gl
.p_glEnable(GL_POLYGON_OFFSET_FILL
);
1713 checkGLcall("glEnable(GL_POLYGON_OFFSET_FILL)");
1715 if (context
->swapchain
->device
->wined3d
->flags
& WINED3D_LEGACY_DEPTH_BIAS
)
1717 float bias
= -(float)const_bias
.d
;
1718 gl_info
->gl_ops
.gl
.p_glPolygonOffset(bias
, bias
);
1719 checkGLcall("glPolygonOffset");
1725 if (depth
->format_flags
& WINED3DFMT_FLAG_FLOAT
)
1726 scale
= gl_info
->float_polyoffset_scale
;
1728 scale
= gl_info
->fixed_polyoffset_scale
;
1730 TRACE("Depth format %s, using depthbias scale of %.8e.\n",
1731 debug_d3dformat(depth
->format
->id
), scale
);
1735 /* The context manager will reapply this state on a depth stencil change */
1736 TRACE("No depth stencil, using depthbias scale of 0.0.\n");
1740 gl_info
->gl_ops
.gl
.p_glPolygonOffset(scale_bias
.f
, const_bias
.f
* scale
);
1741 checkGLcall("glPolygonOffset(...)");
1746 gl_info
->gl_ops
.gl
.p_glDisable(GL_POLYGON_OFFSET_FILL
);
1747 checkGLcall("glDisable(GL_POLYGON_OFFSET_FILL)");
1751 static void state_zvisible(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1753 if (state
->render_states
[WINED3D_RS_ZVISIBLE
])
1754 FIXME("WINED3D_RS_ZVISIBLE not implemented.\n");
1757 static void state_stippledalpha(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1759 if (state
->render_states
[WINED3D_RS_STIPPLEDALPHA
])
1760 FIXME("Stippled Alpha not supported yet.\n");
1763 static void state_antialias(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1765 if (state
->render_states
[WINED3D_RS_ANTIALIAS
])
1766 FIXME("Antialias not supported yet.\n");
1769 static void state_multisampmask(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1771 if (state
->render_states
[WINED3D_RS_MULTISAMPLEMASK
] != 0xffffffff)
1772 FIXME("WINED3D_RS_MULTISAMPLEMASK %#x not yet implemented.\n",
1773 state
->render_states
[WINED3D_RS_MULTISAMPLEMASK
]);
1776 static void state_patchedgestyle(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1778 if (state
->render_states
[WINED3D_RS_PATCHEDGESTYLE
] != WINED3D_PATCH_EDGE_DISCRETE
)
1779 FIXME("WINED3D_RS_PATCHEDGESTYLE %#x not yet implemented.\n",
1780 state
->render_states
[WINED3D_RS_PATCHEDGESTYLE
]);
1783 static void state_patchsegments(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1791 if (state
->render_states
[WINED3D_RS_PATCHSEGMENTS
] != tmpvalue
.d
)
1793 static BOOL displayed
= FALSE
;
1795 tmpvalue
.d
= state
->render_states
[WINED3D_RS_PATCHSEGMENTS
];
1797 FIXME("(WINED3D_RS_PATCHSEGMENTS,%f) not yet implemented\n", tmpvalue
.f
);
1803 static void state_positiondegree(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1805 if (state
->render_states
[WINED3D_RS_POSITIONDEGREE
] != WINED3D_DEGREE_CUBIC
)
1806 FIXME("WINED3D_RS_POSITIONDEGREE %#x not yet implemented.\n",
1807 state
->render_states
[WINED3D_RS_POSITIONDEGREE
]);
1810 static void state_normaldegree(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1812 if (state
->render_states
[WINED3D_RS_NORMALDEGREE
] != WINED3D_DEGREE_LINEAR
)
1813 FIXME("WINED3D_RS_NORMALDEGREE %#x not yet implemented.\n",
1814 state
->render_states
[WINED3D_RS_NORMALDEGREE
]);
1817 static void state_tessellation(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1819 if (state
->render_states
[WINED3D_RS_ENABLEADAPTIVETESSELLATION
])
1820 FIXME("WINED3D_RS_ENABLEADAPTIVETESSELLATION %#x not yet implemented.\n",
1821 state
->render_states
[WINED3D_RS_ENABLEADAPTIVETESSELLATION
]);
1824 static void state_nvdb(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1831 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1833 if (state
->render_states
[WINED3D_RS_ADAPTIVETESS_X
] == WINED3DFMT_NVDB
)
1835 zmin
.d
= state
->render_states
[WINED3D_RS_ADAPTIVETESS_Z
];
1836 zmax
.d
= state
->render_states
[WINED3D_RS_ADAPTIVETESS_W
];
1838 /* If zmin is larger than zmax INVALID_VALUE error is generated.
1839 * In d3d9 test is not performed in this case*/
1840 if (zmin
.f
<= zmax
.f
)
1842 gl_info
->gl_ops
.gl
.p_glEnable(GL_DEPTH_BOUNDS_TEST_EXT
);
1843 checkGLcall("glEnable(GL_DEPTH_BOUNDS_TEST_EXT)");
1844 GL_EXTCALL(glDepthBoundsEXT(zmin
.f
, zmax
.f
));
1845 checkGLcall("glDepthBoundsEXT(...)");
1849 gl_info
->gl_ops
.gl
.p_glDisable(GL_DEPTH_BOUNDS_TEST_EXT
);
1850 checkGLcall("glDisable(GL_DEPTH_BOUNDS_TEST_EXT)");
1855 gl_info
->gl_ops
.gl
.p_glDisable(GL_DEPTH_BOUNDS_TEST_EXT
);
1856 checkGLcall("glDisable(GL_DEPTH_BOUNDS_TEST_EXT)");
1859 state_tessellation(context
, state
, STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
));
1862 static void state_wrapu(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1864 if (state
->render_states
[WINED3D_RS_WRAPU
])
1865 FIXME("Render state WINED3D_RS_WRAPU not implemented yet.\n");
1868 static void state_wrapv(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1870 if (state
->render_states
[WINED3D_RS_WRAPV
])
1871 FIXME("Render state WINED3D_RS_WRAPV not implemented yet.\n");
1874 static void state_monoenable(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1876 if (state
->render_states
[WINED3D_RS_MONOENABLE
])
1877 FIXME("Render state WINED3D_RS_MONOENABLE not implemented yet.\n");
1880 static void state_rop2(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1882 if (state
->render_states
[WINED3D_RS_ROP2
])
1883 FIXME("Render state WINED3D_RS_ROP2 not implemented yet.\n");
1886 static void state_planemask(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1888 if (state
->render_states
[WINED3D_RS_PLANEMASK
])
1889 FIXME("Render state WINED3D_RS_PLANEMASK not implemented yet.\n");
1892 static void state_subpixel(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1894 if (state
->render_states
[WINED3D_RS_SUBPIXEL
])
1895 FIXME("Render state WINED3D_RS_SUBPIXEL not implemented yet.\n");
1898 static void state_subpixelx(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1900 if (state
->render_states
[WINED3D_RS_SUBPIXELX
])
1901 FIXME("Render state WINED3D_RS_SUBPIXELX not implemented yet.\n");
1904 static void state_stippleenable(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1906 if (state
->render_states
[WINED3D_RS_STIPPLEENABLE
])
1907 FIXME("Render state WINED3D_RS_STIPPLEENABLE not implemented yet.\n");
1910 static void state_mipmaplodbias(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1912 if (state
->render_states
[WINED3D_RS_MIPMAPLODBIAS
])
1913 FIXME("Render state WINED3D_RS_MIPMAPLODBIAS not implemented yet.\n");
1916 static void state_anisotropy(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1918 if (state
->render_states
[WINED3D_RS_ANISOTROPY
])
1919 FIXME("Render state WINED3D_RS_ANISOTROPY not implemented yet.\n");
1922 static void state_flushbatch(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1924 if (state
->render_states
[WINED3D_RS_FLUSHBATCH
])
1925 FIXME("Render state WINED3D_RS_FLUSHBATCH not implemented yet.\n");
1928 static void state_translucentsi(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1930 if (state
->render_states
[WINED3D_RS_TRANSLUCENTSORTINDEPENDENT
])
1931 FIXME("Render state WINED3D_RS_TRANSLUCENTSORTINDEPENDENT not implemented yet.\n");
1934 static void state_extents(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1936 if (state
->render_states
[WINED3D_RS_EXTENTS
])
1937 FIXME("Render state WINED3D_RS_EXTENTS not implemented yet.\n");
1940 static void state_ckeyblend(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1942 if (state
->render_states
[WINED3D_RS_COLORKEYBLENDENABLE
])
1943 FIXME("Render state WINED3D_RS_COLORKEYBLENDENABLE not implemented yet.\n");
1946 static void state_swvp(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1949 if (state
->render_states
[WINED3D_RS_SOFTWAREVERTEXPROCESSING
])
1952 FIXME("Software vertex processing not implemented.\n");
1956 static void get_src_and_opr(DWORD arg
, BOOL is_alpha
, GLenum
* source
, GLenum
* operand
) {
1957 /* The WINED3DTA_ALPHAREPLICATE flag specifies the alpha component of the
1958 * input should be used for all input components. The WINED3DTA_COMPLEMENT
1959 * flag specifies the complement of the input should be used. */
1960 BOOL from_alpha
= is_alpha
|| arg
& WINED3DTA_ALPHAREPLICATE
;
1961 BOOL complement
= arg
& WINED3DTA_COMPLEMENT
;
1963 /* Calculate the operand */
1965 if (from_alpha
) *operand
= GL_ONE_MINUS_SRC_ALPHA
;
1966 else *operand
= GL_ONE_MINUS_SRC_COLOR
;
1968 if (from_alpha
) *operand
= GL_SRC_ALPHA
;
1969 else *operand
= GL_SRC_COLOR
;
1972 /* Calculate the source */
1973 switch (arg
& WINED3DTA_SELECTMASK
) {
1974 case WINED3DTA_CURRENT
: *source
= GL_PREVIOUS_EXT
; break;
1975 case WINED3DTA_DIFFUSE
: *source
= GL_PRIMARY_COLOR_EXT
; break;
1976 case WINED3DTA_TEXTURE
: *source
= GL_TEXTURE
; break;
1977 case WINED3DTA_TFACTOR
: *source
= GL_CONSTANT_EXT
; break;
1978 case WINED3DTA_SPECULAR
:
1980 * According to the GL_ARB_texture_env_combine specs, SPECULAR is
1981 * 'Secondary color' and isn't supported until base GL supports it
1982 * There is no concept of temp registers as far as I can tell
1984 FIXME("Unhandled texture arg WINED3DTA_SPECULAR\n");
1985 *source
= GL_TEXTURE
;
1988 FIXME("Unrecognized texture arg %#x\n", arg
);
1989 *source
= GL_TEXTURE
;
1994 /* Setup the texture operations texture stage states */
1995 static void set_tex_op(const struct wined3d_gl_info
*gl_info
, const struct wined3d_state
*state
,
1996 BOOL isAlpha
, int Stage
, enum wined3d_texture_op op
, DWORD arg1
, DWORD arg2
, DWORD arg3
)
1998 GLenum src1
, src2
, src3
;
1999 GLenum opr1
, opr2
, opr3
;
2001 GLenum src0_target
, src1_target
, src2_target
;
2002 GLenum opr0_target
, opr1_target
, opr2_target
;
2004 GLenum opr
=0, invopr
, src3_target
, opr3_target
;
2005 BOOL Handled
= FALSE
;
2007 TRACE("Alpha?(%d), Stage:%d Op(%s), a1(%d), a2(%d), a3(%d)\n", isAlpha
, Stage
, debug_d3dtop(op
), arg1
, arg2
, arg3
);
2009 /* Operations usually involve two args, src0 and src1 and are operations
2010 * of the form (a1 <operation> a2). However, some of the more complex
2011 * operations take 3 parameters. Instead of the (sensible) addition of a3,
2012 * Microsoft added in a third parameter called a0. Therefore these are
2013 * operations of the form a0 <operation> a1 <operation> a2. I.e., the new
2014 * parameter goes to the front.
2016 * However, below we treat the new (a0) parameter as src2/opr2, so in the
2017 * actual functions below, expect their syntax to differ slightly to those
2018 * listed in the manuals. I.e., replace arg1 with arg3, arg2 with arg1 and
2019 * arg3 with arg2. This affects WINED3DTOP_MULTIPLYADD and WINED3DTOP_LERP. */
2023 comb_target
= GL_COMBINE_ALPHA
;
2024 src0_target
= GL_SOURCE0_ALPHA
;
2025 src1_target
= GL_SOURCE1_ALPHA
;
2026 src2_target
= GL_SOURCE2_ALPHA
;
2027 opr0_target
= GL_OPERAND0_ALPHA
;
2028 opr1_target
= GL_OPERAND1_ALPHA
;
2029 opr2_target
= GL_OPERAND2_ALPHA
;
2030 scal_target
= GL_ALPHA_SCALE
;
2034 comb_target
= GL_COMBINE_RGB
;
2035 src0_target
= GL_SOURCE0_RGB
;
2036 src1_target
= GL_SOURCE1_RGB
;
2037 src2_target
= GL_SOURCE2_RGB
;
2038 opr0_target
= GL_OPERAND0_RGB
;
2039 opr1_target
= GL_OPERAND1_RGB
;
2040 opr2_target
= GL_OPERAND2_RGB
;
2041 scal_target
= GL_RGB_SCALE
;
2044 /* If a texture stage references an invalid texture unit the stage just
2045 * passes through the result from the previous stage */
2046 if (is_invalid_op(state
, Stage
, op
, arg1
, arg2
, arg3
))
2048 arg1
= WINED3DTA_CURRENT
;
2049 op
= WINED3D_TOP_SELECT_ARG1
;
2052 if (isAlpha
&& !state
->textures
[Stage
] && arg1
== WINED3DTA_TEXTURE
)
2054 get_src_and_opr(WINED3DTA_DIFFUSE
, isAlpha
, &src1
, &opr1
);
2056 get_src_and_opr(arg1
, isAlpha
, &src1
, &opr1
);
2058 get_src_and_opr(arg2
, isAlpha
, &src2
, &opr2
);
2059 get_src_and_opr(arg3
, isAlpha
, &src3
, &opr3
);
2061 TRACE("ct(%x), 1:(%x,%x), 2:(%x,%x), 3:(%x,%x)\n", comb_target
, src1
, opr1
, src2
, opr2
, src3
, opr3
);
2063 Handled
= TRUE
; /* Assume will be handled */
2065 /* Other texture operations require special extensions: */
2066 if (gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
2070 invopr
= GL_ONE_MINUS_SRC_ALPHA
;
2071 src3_target
= GL_SOURCE3_ALPHA_NV
;
2072 opr3_target
= GL_OPERAND3_ALPHA_NV
;
2075 invopr
= GL_ONE_MINUS_SRC_COLOR
;
2076 src3_target
= GL_SOURCE3_RGB_NV
;
2077 opr3_target
= GL_OPERAND3_RGB_NV
;
2081 case WINED3D_TOP_DISABLE
: /* Only for alpha */
2082 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2083 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2084 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_PREVIOUS_EXT
);
2085 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2086 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_SRC_ALPHA
);
2087 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2088 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2089 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2090 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2091 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2092 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2093 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_ZERO");
2094 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2095 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2096 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2097 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2098 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2099 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2102 case WINED3D_TOP_SELECT_ARG1
: /* = a1 * 1 + 0 * 0 */
2103 case WINED3D_TOP_SELECT_ARG2
: /* = a2 * 1 + 0 * 0 */
2104 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2105 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2106 if (op
== WINED3D_TOP_SELECT_ARG1
)
2108 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2109 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2110 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2111 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2115 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src2
);
2116 checkGLcall("GL_TEXTURE_ENV, src0_target, src2");
2117 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr2
);
2118 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr2");
2120 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2121 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2122 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2123 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2124 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2125 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_ZERO");
2126 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2127 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2128 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2129 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2130 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2131 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2134 case WINED3D_TOP_MODULATE
:
2135 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2136 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2137 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2138 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2139 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2140 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2141 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2142 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2143 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2144 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2145 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2146 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2147 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2148 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2149 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2150 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2151 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2152 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2153 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2154 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2156 case WINED3D_TOP_MODULATE_2X
:
2157 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2158 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2159 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2160 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2161 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2162 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2163 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2164 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2165 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2166 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2167 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2168 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2169 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2170 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2171 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2172 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2173 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2174 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2175 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2176 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2178 case WINED3D_TOP_MODULATE_4X
:
2179 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2180 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2181 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2182 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2183 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2184 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2185 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2186 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2187 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2188 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2189 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2190 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2191 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2192 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2193 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2194 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2195 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2196 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2197 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 4);
2198 checkGLcall("GL_TEXTURE_ENV, scal_target, 4");
2201 case WINED3D_TOP_ADD
:
2202 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2203 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2204 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2205 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2206 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2207 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2208 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2209 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2210 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2211 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2212 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2213 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2214 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2215 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2216 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2217 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2218 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2219 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2220 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2221 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2224 case WINED3D_TOP_ADD_SIGNED
:
2225 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD_SIGNED
);
2226 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2227 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2228 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2229 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2230 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2231 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2232 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2233 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2234 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2235 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2236 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2237 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2238 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2239 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2240 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2241 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2242 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2243 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2244 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2247 case WINED3D_TOP_ADD_SIGNED_2X
:
2248 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD_SIGNED
);
2249 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2250 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2251 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2252 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2253 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2254 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2255 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2256 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2257 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2258 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2259 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2260 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2261 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2262 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2263 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2264 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2265 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2266 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2267 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2270 case WINED3D_TOP_ADD_SMOOTH
:
2271 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2272 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2273 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2274 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2275 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2276 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2277 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2278 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2279 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2280 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2281 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2282 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2283 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2284 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2285 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
2286 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2288 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2289 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2290 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2291 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2293 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2294 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2295 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2296 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2299 case WINED3D_TOP_BLEND_DIFFUSE_ALPHA
:
2300 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2301 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2302 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2303 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2304 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2305 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2306 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_PRIMARY_COLOR
);
2307 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_PRIMARY_COLOR");
2308 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2309 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2310 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2311 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2312 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2313 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2314 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_PRIMARY_COLOR
);
2315 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_PRIMARY_COLOR");
2316 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2317 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2318 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2319 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2321 case WINED3D_TOP_BLEND_TEXTURE_ALPHA
:
2322 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2323 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2324 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2325 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2326 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2327 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2328 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_TEXTURE
);
2329 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_TEXTURE");
2330 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2331 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2332 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2333 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2334 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2335 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2336 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_TEXTURE
);
2337 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_TEXTURE");
2338 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2339 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2340 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2341 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2343 case WINED3D_TOP_BLEND_FACTOR_ALPHA
:
2344 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2345 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2346 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2347 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2348 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2349 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2350 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_CONSTANT
);
2351 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_CONSTANT");
2352 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2353 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2354 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2355 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2356 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2357 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2358 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_CONSTANT
);
2359 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_CONSTANT");
2360 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2361 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2362 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2363 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2365 case WINED3D_TOP_BLEND_TEXTURE_ALPHA_PM
:
2366 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2367 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2368 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2369 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2370 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2371 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2372 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2373 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2374 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2375 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2376 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2377 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2378 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2379 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2380 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_TEXTURE
);
2381 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_TEXTURE");
2382 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2383 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2384 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2385 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2387 case WINED3D_TOP_MODULATE_ALPHA_ADD_COLOR
:
2388 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2389 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2390 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
); /* a0 = src1/opr1 */
2391 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2392 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2393 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1"); /* a1 = 1 (see docs) */
2394 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2395 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2396 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2397 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2398 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
); /* a2 = arg2 */
2399 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2400 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2401 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2"); /* a3 = src1 alpha */
2402 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
2403 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2405 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2406 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2408 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2409 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2410 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2411 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2413 case WINED3D_TOP_MODULATE_COLOR_ADD_ALPHA
:
2414 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2415 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2416 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2417 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2418 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2419 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2420 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2421 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2422 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2423 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2424 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
2425 checkGLcall("GL_TEXTURE_ENV, src2_target, src1");
2427 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2428 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2430 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2431 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2432 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2433 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2434 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2435 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2436 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2437 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2439 case WINED3D_TOP_MODULATE_INVALPHA_ADD_COLOR
:
2440 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2441 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2442 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2443 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2444 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2445 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2446 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2447 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2448 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2449 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2450 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2451 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2452 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2453 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2454 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
2455 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2457 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2458 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2459 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2460 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2462 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2463 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2464 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2465 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2467 case WINED3D_TOP_MODULATE_INVCOLOR_ADD_ALPHA
:
2468 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2469 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2470 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2471 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2473 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2474 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2475 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2476 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2478 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2479 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2480 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2481 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2482 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2483 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2484 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
2485 checkGLcall("GL_TEXTURE_ENV, src2_target, src1");
2487 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2488 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2490 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2491 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2492 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2493 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2494 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2495 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2496 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2497 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2499 case WINED3D_TOP_MULTIPLY_ADD
:
2500 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2501 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2502 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src3
);
2503 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2504 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr3
);
2505 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2506 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2507 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2508 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2509 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2510 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
2511 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2512 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr1
);
2513 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2514 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src2
);
2515 checkGLcall("GL_TEXTURE_ENV, src3_target, src3");
2516 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr2
);
2517 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr3");
2518 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2519 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2522 case WINED3D_TOP_BUMPENVMAP
:
2523 case WINED3D_TOP_BUMPENVMAP_LUMINANCE
:
2524 FIXME("Implement bump environment mapping in GL_NV_texture_env_combine4 path\n");
2533 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_COMBINE4_NV
);
2534 checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV");
2538 } /* GL_NV_texture_env_combine4 */
2540 Handled
= TRUE
; /* Again, assume handled */
2542 case WINED3D_TOP_DISABLE
: /* Only for alpha */
2543 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
2544 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2545 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_PREVIOUS_EXT
);
2546 checkGLcall("GL_TEXTURE_ENV, src0_target, GL_PREVIOUS_EXT");
2547 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_SRC_ALPHA
);
2548 checkGLcall("GL_TEXTURE_ENV, opr0_target, GL_SRC_ALPHA");
2549 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2550 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2552 case WINED3D_TOP_SELECT_ARG1
:
2553 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
2554 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2555 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2556 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2557 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2558 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2559 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2560 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2562 case WINED3D_TOP_SELECT_ARG2
:
2563 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
2564 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2565 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src2
);
2566 checkGLcall("GL_TEXTURE_ENV, src0_target, src2");
2567 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr2
);
2568 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr2");
2569 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2570 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2572 case WINED3D_TOP_MODULATE
:
2573 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
2574 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2575 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2576 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2577 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2578 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2579 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2580 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2581 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2582 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2583 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2584 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2586 case WINED3D_TOP_MODULATE_2X
:
2587 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
2588 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2589 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2590 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2591 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2592 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2593 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2594 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2595 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2596 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2597 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2598 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2600 case WINED3D_TOP_MODULATE_4X
:
2601 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
2602 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2603 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2604 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2605 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2606 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2607 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2608 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2609 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2610 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2611 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 4);
2612 checkGLcall("GL_TEXTURE_ENV, scal_target, 4");
2614 case WINED3D_TOP_ADD
:
2615 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2616 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2617 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2618 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2619 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2620 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2621 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2622 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2623 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2624 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2625 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2626 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2628 case WINED3D_TOP_ADD_SIGNED
:
2629 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD_SIGNED
);
2630 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2631 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2632 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2633 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2634 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2635 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2636 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2637 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2638 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2639 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2640 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2642 case WINED3D_TOP_ADD_SIGNED_2X
:
2643 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD_SIGNED
);
2644 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2645 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2646 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2647 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2648 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2649 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2650 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2651 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2652 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2653 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2654 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2656 case WINED3D_TOP_SUBTRACT
:
2657 if (gl_info
->supported
[ARB_TEXTURE_ENV_COMBINE
])
2659 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_SUBTRACT
);
2660 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_SUBTRACT");
2661 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2662 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2663 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2664 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2665 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2666 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2667 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2668 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2669 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2670 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2672 FIXME("This version of opengl does not support GL_SUBTRACT\n");
2676 case WINED3D_TOP_BLEND_DIFFUSE_ALPHA
:
2677 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2678 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2679 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2680 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2681 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2682 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2683 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2684 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2685 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2686 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2687 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_PRIMARY_COLOR
);
2688 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_PRIMARY_COLOR");
2689 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2690 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2691 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2692 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2694 case WINED3D_TOP_BLEND_TEXTURE_ALPHA
:
2695 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2696 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2697 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2698 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2699 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2700 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2701 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2702 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2703 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2704 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2705 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_TEXTURE
);
2706 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_TEXTURE");
2707 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2708 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2709 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2710 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2712 case WINED3D_TOP_BLEND_FACTOR_ALPHA
:
2713 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2714 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2715 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2716 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2717 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2718 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2719 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2720 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2721 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2722 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2723 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_CONSTANT
);
2724 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_CONSTANT");
2725 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2726 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2727 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2728 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2730 case WINED3D_TOP_BLEND_CURRENT_ALPHA
:
2731 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2732 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2733 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2734 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2735 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2736 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2737 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2738 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2739 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2740 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2741 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_PREVIOUS
);
2742 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_PREVIOUS");
2743 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2744 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2745 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2746 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2748 case WINED3D_TOP_DOTPRODUCT3
:
2749 if (gl_info
->supported
[ARB_TEXTURE_ENV_DOT3
])
2751 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_DOT3_RGBA_ARB
);
2752 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_ARB");
2754 else if (gl_info
->supported
[EXT_TEXTURE_ENV_DOT3
])
2756 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_DOT3_RGBA_EXT
);
2757 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_EXT");
2759 FIXME("This version of opengl does not support GL_DOT3\n");
2761 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2762 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2763 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2764 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2765 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2766 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2767 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2768 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2769 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2770 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2772 case WINED3D_TOP_LERP
:
2773 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2774 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2775 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2776 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2777 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2778 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2779 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2780 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2781 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2782 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2783 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src3
);
2784 checkGLcall("GL_TEXTURE_ENV, src2_target, src3");
2785 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr3
);
2786 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr3");
2787 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2788 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2790 case WINED3D_TOP_ADD_SMOOTH
:
2791 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2793 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2794 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2795 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2796 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2798 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2799 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2800 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2801 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2803 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2804 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2805 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2806 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2807 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2808 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2809 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2810 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2811 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2812 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2813 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2814 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2818 case WINED3D_TOP_BLEND_TEXTURE_ALPHA_PM
:
2819 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2821 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2822 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2823 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_TEXTURE
);
2824 checkGLcall("GL_TEXTURE_ENV, src0_target, GL_TEXTURE");
2825 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_ONE_MINUS_SRC_ALPHA
);
2826 checkGLcall("GL_TEXTURE_ENV, opr0_target, GL_ONE_MINUS_SRC_APHA");
2827 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2828 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2829 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2830 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2831 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2832 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2833 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2834 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2835 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2836 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2840 case WINED3D_TOP_MODULATE_ALPHA_ADD_COLOR
:
2841 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2843 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2844 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2845 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2846 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2848 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2849 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2850 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2851 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2853 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2854 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2855 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2856 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2857 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2858 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2859 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2860 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2861 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2862 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2863 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2864 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2868 case WINED3D_TOP_MODULATE_COLOR_ADD_ALPHA
:
2869 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2871 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2872 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2873 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2874 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2875 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2876 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2877 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2878 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2880 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2881 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2882 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2883 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2885 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr
);
2886 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr");
2887 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2888 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2889 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2890 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2891 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2892 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2896 case WINED3D_TOP_MODULATE_INVALPHA_ADD_COLOR
:
2897 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2899 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2900 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2901 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2902 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2904 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2905 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2906 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2907 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2909 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2910 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2911 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2912 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2913 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2914 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2915 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2916 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2917 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2918 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2919 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2920 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2924 case WINED3D_TOP_MODULATE_INVCOLOR_ADD_ALPHA
:
2925 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2927 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2928 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2929 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2930 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2932 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2933 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2934 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2935 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2937 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2938 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2939 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2940 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2942 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2943 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2944 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2945 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2947 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr
);
2948 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr");
2949 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2950 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2951 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2952 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2953 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2954 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2958 case WINED3D_TOP_MULTIPLY_ADD
:
2959 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2961 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2962 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2963 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2964 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2965 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2966 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2967 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src3
);
2968 checkGLcall("GL_TEXTURE_ENV, src1_target, src3");
2969 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr3
);
2970 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr3");
2971 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2972 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2973 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2974 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2975 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2976 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2980 case WINED3D_TOP_BUMPENVMAP_LUMINANCE
:
2981 case WINED3D_TOP_BUMPENVMAP
:
2982 if (gl_info
->supported
[NV_TEXTURE_SHADER2
])
2984 /* Technically texture shader support without register combiners is possible, but not expected to occur
2985 * on real world cards, so for now a fixme should be enough
2987 FIXME("Implement bump mapping with GL_NV_texture_shader in non register combiner path\n");
2997 BOOL combineOK
= TRUE
;
2998 if (gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
3003 op2
= state
->texture_states
[Stage
][WINED3D_TSS_COLOR_OP
];
3005 op2
= state
->texture_states
[Stage
][WINED3D_TSS_ALPHA_OP
];
3007 /* Note: If COMBINE4 in effect can't go back to combine! */
3010 case WINED3D_TOP_ADD_SMOOTH
:
3011 case WINED3D_TOP_BLEND_TEXTURE_ALPHA_PM
:
3012 case WINED3D_TOP_MODULATE_ALPHA_ADD_COLOR
:
3013 case WINED3D_TOP_MODULATE_COLOR_ADD_ALPHA
:
3014 case WINED3D_TOP_MODULATE_INVALPHA_ADD_COLOR
:
3015 case WINED3D_TOP_MODULATE_INVCOLOR_ADD_ALPHA
:
3016 case WINED3D_TOP_MULTIPLY_ADD
:
3017 /* Ignore those implemented in both cases */
3020 case WINED3D_TOP_SELECT_ARG1
:
3021 case WINED3D_TOP_SELECT_ARG2
:
3026 FIXME("Can't use COMBINE4 and COMBINE together, thisop=%s, otherop=%s, isAlpha(%d)\n", debug_d3dtop(op
), debug_d3dtop(op2
), isAlpha
);
3034 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_COMBINE
);
3035 checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE");
3041 /* After all the extensions, if still unhandled, report fixme */
3042 FIXME("Unhandled texture operation %s\n", debug_d3dtop(op
));
3046 static void tex_colorop(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3048 DWORD stage
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3049 BOOL tex_used
= context
->fixed_function_usage_map
& (1u << stage
);
3050 DWORD mapped_stage
= context
->tex_unit_map
[stage
];
3051 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3053 TRACE("Setting color op for stage %d\n", stage
);
3055 /* Using a pixel shader? Don't care for anything here, the shader applying does it */
3056 if (use_ps(state
)) return;
3058 if (stage
!= mapped_stage
) WARN("Using non 1:1 mapping: %d -> %d!\n", stage
, mapped_stage
);
3060 if (mapped_stage
!= WINED3D_UNMAPPED_STAGE
)
3062 if (tex_used
&& mapped_stage
>= gl_info
->limits
.textures
)
3064 FIXME("Attempt to enable unsupported stage!\n");
3067 context_active_texture(context
, gl_info
, mapped_stage
);
3070 if (stage
>= context
->lowest_disabled_stage
)
3072 TRACE("Stage disabled\n");
3073 if (mapped_stage
!= WINED3D_UNMAPPED_STAGE
)
3075 /* Disable everything here */
3076 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_2D
);
3077 checkGLcall("glDisable(GL_TEXTURE_2D)");
3078 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_3D
);
3079 checkGLcall("glDisable(GL_TEXTURE_3D)");
3080 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
3082 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB
);
3083 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
3085 if (gl_info
->supported
[ARB_TEXTURE_RECTANGLE
])
3087 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_RECTANGLE_ARB
);
3088 checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)");
3095 /* The sampler will also activate the correct texture dimensions, so no
3096 * need to do it here if the sampler for this stage is dirty. */
3097 if (!isStateDirty(context
, STATE_SAMPLER(stage
)) && tex_used
)
3098 texture_activate_dimensions(state
->textures
[stage
], gl_info
);
3100 set_tex_op(gl_info
, state
, FALSE
, stage
,
3101 state
->texture_states
[stage
][WINED3D_TSS_COLOR_OP
],
3102 state
->texture_states
[stage
][WINED3D_TSS_COLOR_ARG1
],
3103 state
->texture_states
[stage
][WINED3D_TSS_COLOR_ARG2
],
3104 state
->texture_states
[stage
][WINED3D_TSS_COLOR_ARG0
]);
3107 void tex_alphaop(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3109 DWORD stage
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3110 BOOL tex_used
= context
->fixed_function_usage_map
& (1u << stage
);
3111 DWORD mapped_stage
= context
->tex_unit_map
[stage
];
3112 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3113 DWORD op
, arg1
, arg2
, arg0
;
3115 TRACE("Setting alpha op for stage %d\n", stage
);
3116 /* Do not care for enabled / disabled stages, just assign the settings. colorop disables / enables required stuff */
3117 if (mapped_stage
!= WINED3D_UNMAPPED_STAGE
)
3119 if (tex_used
&& mapped_stage
>= gl_info
->limits
.textures
)
3121 FIXME("Attempt to enable unsupported stage!\n");
3124 context_active_texture(context
, gl_info
, mapped_stage
);
3127 op
= state
->texture_states
[stage
][WINED3D_TSS_ALPHA_OP
];
3128 arg1
= state
->texture_states
[stage
][WINED3D_TSS_ALPHA_ARG1
];
3129 arg2
= state
->texture_states
[stage
][WINED3D_TSS_ALPHA_ARG2
];
3130 arg0
= state
->texture_states
[stage
][WINED3D_TSS_ALPHA_ARG0
];
3132 if (state
->render_states
[WINED3D_RS_COLORKEYENABLE
] && !stage
&& state
->textures
[0])
3134 struct wined3d_texture
*texture
= state
->textures
[0];
3135 GLenum texture_dimensions
= texture
->target
;
3137 if (texture_dimensions
== GL_TEXTURE_2D
|| texture_dimensions
== GL_TEXTURE_RECTANGLE_ARB
)
3139 if (texture
->async
.color_key_flags
& WINED3D_CKEY_SRC_BLT
&& !texture
->resource
.format
->alpha_size
)
3141 /* Color keying needs to pass alpha values from the texture through to have the alpha test work
3142 * properly. On the other hand applications can still use texture combiners apparently. This code
3143 * takes care that apps cannot remove the texture's alpha channel entirely.
3145 * The fixup is required for Prince of Persia 3D(prison bars), while Moto racer 2 requires
3146 * D3DTOP_MODULATE to work on color keyed surfaces. Aliens vs Predator 1 uses color keyed textures
3147 * and alpha component of diffuse color to draw things like translucent text and perform other
3150 * Aliens vs Predator 1 relies on diffuse alpha having an effect, so it cannot be ignored. To
3151 * provide the behavior expected by the game, while emulating the colorkey, diffuse alpha must be
3152 * modulated with texture alpha. OTOH, Moto racer 2 at some points sets alphaop/alphaarg to
3153 * SELECTARG/CURRENT, yet puts garbage in diffuse alpha (zeroes). This works on native, because the
3154 * game disables alpha test and alpha blending. Alpha test is overwritten by wine's for purposes of
3155 * color-keying though, so this will lead to missing geometry if texture alpha is modulated (pixels
3156 * fail alpha test). To get around this, ALPHABLENDENABLE state is checked: if the app enables alpha
3157 * blending, it can be expected to provide meaningful values in diffuse alpha, so it should be
3158 * modulated with texture alpha; otherwise, selecting diffuse alpha is ignored in favour of texture
3161 * What to do with multitexturing? So far no app has been found that uses color keying with
3163 if (op
== WINED3D_TOP_DISABLE
)
3165 arg1
= WINED3DTA_TEXTURE
;
3166 op
= WINED3D_TOP_SELECT_ARG1
;
3168 else if (op
== WINED3D_TOP_SELECT_ARG1
&& arg1
!= WINED3DTA_TEXTURE
)
3170 if (state
->render_states
[WINED3D_RS_ALPHABLENDENABLE
])
3172 arg2
= WINED3DTA_TEXTURE
;
3173 op
= WINED3D_TOP_MODULATE
;
3175 else arg1
= WINED3DTA_TEXTURE
;
3177 else if (op
== WINED3D_TOP_SELECT_ARG2
&& arg2
!= WINED3DTA_TEXTURE
)
3179 if (state
->render_states
[WINED3D_RS_ALPHABLENDENABLE
])
3181 arg1
= WINED3DTA_TEXTURE
;
3182 op
= WINED3D_TOP_MODULATE
;
3184 else arg2
= WINED3DTA_TEXTURE
;
3190 /* tex_alphaop is shared between the ffp and nvrc because the difference only comes down to
3191 * this if block here, and the other code(color keying, texture unit selection) are the same
3193 TRACE("Setting alpha op for stage %d\n", stage
);
3194 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
3196 set_tex_op_nvrc(gl_info
, state
, TRUE
, stage
, op
, arg1
, arg2
, arg0
,
3197 mapped_stage
, state
->texture_states
[stage
][WINED3D_TSS_RESULT_ARG
]);
3201 set_tex_op(gl_info
, state
, TRUE
, stage
, op
, arg1
, arg2
, arg0
);
3205 static void transform_texture(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3207 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3208 unsigned int tex
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3209 unsigned int mapped_stage
= context
->tex_unit_map
[tex
];
3210 struct wined3d_matrix mat
;
3212 /* Ignore this when a vertex shader is used, or if the streams aren't sorted out yet */
3213 if (use_vs(state
) || isStateDirty(context
, STATE_VDECL
))
3215 TRACE("Using a vertex shader, or stream sources not sorted out yet, skipping\n");
3219 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
) return;
3220 if (mapped_stage
>= gl_info
->limits
.textures
) return;
3222 context_active_texture(context
, gl_info
, mapped_stage
);
3223 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_TEXTURE
);
3224 checkGLcall("glMatrixMode(GL_TEXTURE)");
3226 get_texture_matrix(context
, state
, mapped_stage
, &mat
);
3228 gl_info
->gl_ops
.gl
.p_glLoadMatrixf(&mat
._11
);
3229 checkGLcall("glLoadMatrixf");
3232 static void unload_tex_coords(const struct wined3d_gl_info
*gl_info
)
3234 unsigned int texture_idx
;
3236 for (texture_idx
= 0; texture_idx
< gl_info
->limits
.texture_coords
; ++texture_idx
)
3238 GL_EXTCALL(glClientActiveTextureARB(GL_TEXTURE0_ARB
+ texture_idx
));
3239 gl_info
->gl_ops
.gl
.p_glDisableClientState(GL_TEXTURE_COORD_ARRAY
);
3243 static void load_tex_coords(const struct wined3d_context
*context
, const struct wined3d_stream_info
*si
,
3244 GLuint
*curVBO
, const struct wined3d_state
*state
)
3246 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3247 unsigned int mapped_stage
= 0;
3248 unsigned int textureNo
;
3250 for (textureNo
= 0; textureNo
< context
->d3d_info
->limits
.ffp_blend_stages
; ++textureNo
)
3252 int coordIdx
= state
->texture_states
[textureNo
][WINED3D_TSS_TEXCOORD_INDEX
];
3254 mapped_stage
= context
->tex_unit_map
[textureNo
];
3255 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
) continue;
3257 if (mapped_stage
>= gl_info
->limits
.texture_coords
)
3259 FIXME("Attempted to load unsupported texture coordinate %u\n", mapped_stage
);
3263 if (coordIdx
< MAX_TEXTURES
&& (si
->use_map
& (1u << (WINED3D_FFP_TEXCOORD0
+ coordIdx
))))
3265 const struct wined3d_stream_info_element
*e
= &si
->elements
[WINED3D_FFP_TEXCOORD0
+ coordIdx
];
3267 TRACE("Setting up texture %u, idx %d, coordindx %u, data {%#x:%p}.\n",
3268 textureNo
, mapped_stage
, coordIdx
, e
->data
.buffer_object
, e
->data
.addr
);
3270 if (*curVBO
!= e
->data
.buffer_object
)
3272 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER
, e
->data
.buffer_object
));
3273 checkGLcall("glBindBuffer");
3274 *curVBO
= e
->data
.buffer_object
;
3277 GL_EXTCALL(glClientActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
3278 checkGLcall("glClientActiveTextureARB");
3280 /* The coords to supply depend completely on the fvf / vertex shader */
3281 gl_info
->gl_ops
.gl
.p_glTexCoordPointer(e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
3282 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
3283 gl_info
->gl_ops
.gl
.p_glEnableClientState(GL_TEXTURE_COORD_ARRAY
);
3287 GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB
+ mapped_stage
, 0, 0, 0, 1));
3290 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
3292 /* The number of the mapped stages increases monotonically, so it's fine to use the last used one. */
3293 for (textureNo
= mapped_stage
+ 1; textureNo
< gl_info
->limits
.textures
; ++textureNo
)
3295 GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB
+ textureNo
, 0, 0, 0, 1));
3299 checkGLcall("loadTexCoords");
3302 static void tex_coordindex(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3304 DWORD stage
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3305 static const GLfloat s_plane
[] = { 1.0f
, 0.0f
, 0.0f
, 0.0f
};
3306 static const GLfloat t_plane
[] = { 0.0f
, 1.0f
, 0.0f
, 0.0f
};
3307 static const GLfloat r_plane
[] = { 0.0f
, 0.0f
, 1.0f
, 0.0f
};
3308 static const GLfloat q_plane
[] = { 0.0f
, 0.0f
, 0.0f
, 1.0f
};
3309 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3310 DWORD mapped_stage
= context
->tex_unit_map
[stage
];
3312 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
)
3314 TRACE("No texture unit mapped to stage %d. Skipping texture coordinates.\n", stage
);
3318 if (mapped_stage
>= gl_info
->limits
.fragment_samplers
)
3320 WARN("stage %u not mapped to a valid texture unit (%u)\n", stage
, mapped_stage
);
3323 context_active_texture(context
, gl_info
, mapped_stage
);
3325 /* Values 0-7 are indexes into the FVF tex coords - See comments in DrawPrimitive
3327 * FIXME: When using generated texture coordinates, the index value is used to specify the wrapping mode.
3328 * eg. SetTextureStageState( 0, WINED3D_TSS_TEXCOORDINDEX, WINED3D_TSS_TCI_CAMERASPACEPOSITION | 1 );
3329 * means use the vertex position (camera-space) as the input texture coordinates
3330 * for this texture stage, and the wrap mode set in the WINED3D_RS_WRAP1 render
3331 * state. We do not (yet) support the WINED3DRENDERSTATE_WRAPx values, nor tie them up
3332 * to the TEXCOORDINDEX value
3334 switch (state
->texture_states
[stage
][WINED3D_TSS_TEXCOORD_INDEX
] & 0xffff0000)
3336 case WINED3DTSS_TCI_PASSTHRU
:
3337 /* Use the specified texture coordinates contained within the
3338 * vertex format. This value resolves to zero. */
3339 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_S
);
3340 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_T
);
3341 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_R
);
3342 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_Q
);
3343 checkGLcall("WINED3DTSS_TCI_PASSTHRU - Disable texgen.");
3346 case WINED3DTSS_TCI_CAMERASPACEPOSITION
:
3347 /* CameraSpacePosition means use the vertex position, transformed to camera space,
3348 * as the input texture coordinates for this stage's texture transformation. This
3349 * equates roughly to EYE_LINEAR */
3351 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3352 gl_info
->gl_ops
.gl
.p_glPushMatrix();
3353 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
3354 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
3355 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
3356 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
3357 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
3358 gl_info
->gl_ops
.gl
.p_glPopMatrix();
3359 checkGLcall("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set eye plane.");
3361 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
3362 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
3363 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
3364 checkGLcall("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set texgen mode.");
3366 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_S
);
3367 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_T
);
3368 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_R
);
3369 checkGLcall("WINED3DTSS_TCI_CAMERASPACEPOSITION - Enable texgen.");
3373 case WINED3DTSS_TCI_CAMERASPACENORMAL
:
3374 /* Note that NV_TEXGEN_REFLECTION support is implied when
3375 * ARB_TEXTURE_CUBE_MAP is supported */
3376 if (!gl_info
->supported
[NV_TEXGEN_REFLECTION
])
3378 FIXME("WINED3DTSS_TCI_CAMERASPACENORMAL not supported.\n");
3382 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3383 gl_info
->gl_ops
.gl
.p_glPushMatrix();
3384 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
3385 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
3386 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
3387 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
3388 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
3389 gl_info
->gl_ops
.gl
.p_glPopMatrix();
3390 checkGLcall("WINED3DTSS_TCI_CAMERASPACENORMAL - Set eye plane.");
3392 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
3393 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
3394 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
3395 checkGLcall("WINED3DTSS_TCI_CAMERASPACENORMAL - Set texgen mode.");
3397 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_S
);
3398 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_T
);
3399 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_R
);
3400 checkGLcall("WINED3DTSS_TCI_CAMERASPACENORMAL - Enable texgen.");
3404 case WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR
:
3405 /* Note that NV_TEXGEN_REFLECTION support is implied when
3406 * ARB_TEXTURE_CUBE_MAP is supported */
3407 if (!gl_info
->supported
[NV_TEXGEN_REFLECTION
])
3409 FIXME("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR not supported.\n");
3413 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3414 gl_info
->gl_ops
.gl
.p_glPushMatrix();
3415 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
3416 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
3417 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
3418 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
3419 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
3420 gl_info
->gl_ops
.gl
.p_glPopMatrix();
3421 checkGLcall("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Set eye plane.");
3423 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
3424 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
3425 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
3426 checkGLcall("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Set texgen mode.");
3428 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_S
);
3429 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_T
);
3430 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_R
);
3431 checkGLcall("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Enable texgen.");
3435 case WINED3DTSS_TCI_SPHEREMAP
:
3436 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_SPHERE_MAP
);
3437 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_SPHERE_MAP
);
3438 checkGLcall("WINED3DTSS_TCI_SPHEREMAP - Set texgen mode.");
3440 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_S
);
3441 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_T
);
3442 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_R
);
3443 checkGLcall("WINED3DTSS_TCI_SPHEREMAP - Enable texgen.");
3448 FIXME("Unhandled WINED3D_TSS_TEXCOORD_INDEX %#x.\n",
3449 state
->texture_states
[stage
][WINED3D_TSS_TEXCOORD_INDEX
]);
3450 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_S
);
3451 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_T
);
3452 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_R
);
3453 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_Q
);
3454 checkGLcall("Disable texgen.");
3459 /* Update the texture matrix. */
3460 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_TEXTURE0
+ stage
)))
3461 transform_texture(context
, state
, STATE_TEXTURESTAGE(stage
, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
));
3463 if (!isStateDirty(context
, STATE_VDECL
) && context
->namedArraysLoaded
)
3465 /* Reload the arrays if we are using fixed function arrays to reflect the selected coord input
3466 * source. Call loadTexCoords directly because there is no need to reparse the vertex declaration
3467 * and do all the things linked to it
3468 * TODO: Tidy that up to reload only the arrays of the changed unit
3470 GLuint curVBO
= gl_info
->supported
[ARB_VERTEX_BUFFER_OBJECT
] ? ~0U : 0;
3472 unload_tex_coords(gl_info
);
3473 load_tex_coords(context
, &context
->stream_info
, &curVBO
, state
);
3477 static void sampler_texmatrix(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3479 const DWORD sampler
= state_id
- STATE_SAMPLER(0);
3480 const struct wined3d_texture
*texture
= state
->textures
[sampler
];
3482 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
3484 if(!texture
) return;
3485 /* The fixed function np2 texture emulation uses the texture matrix to fix up the coordinates
3486 * wined3d_texture_apply_state_changes() multiplies the set matrix with a fixup matrix. Before the
3487 * scaling is reapplied or removed, the texture matrix has to be reapplied
3489 * The mapped stage is already active because the sampler() function below, which is part of the
3492 if (sampler
< MAX_TEXTURES
)
3494 const BOOL texIsPow2
= !(texture
->flags
& WINED3D_TEXTURE_POW2_MAT_IDENT
);
3496 if (texIsPow2
|| (context
->lastWasPow2Texture
& (1u << sampler
)))
3499 context
->lastWasPow2Texture
|= 1u << sampler
;
3501 context
->lastWasPow2Texture
&= ~(1u << sampler
);
3503 transform_texture(context
, state
,
3504 STATE_TEXTURESTAGE(context
->tex_unit_map
[sampler
], WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
));
3509 static enum wined3d_texture_address
wined3d_texture_address_mode(const struct wined3d_texture
*texture
,
3510 enum wined3d_texture_address t
)
3512 if (t
< WINED3D_TADDRESS_WRAP
|| t
> WINED3D_TADDRESS_MIRROR_ONCE
)
3514 FIXME("Unrecognized or unsupported texture address mode %#x.\n", t
);
3515 return WINED3D_TADDRESS_WRAP
;
3518 /* Cubemaps are always set to clamp, regardless of the sampler state. */
3519 if (texture
->target
== GL_TEXTURE_CUBE_MAP_ARB
|| ((texture
->flags
& WINED3D_TEXTURE_COND_NP2
)
3520 && t
== WINED3D_TADDRESS_WRAP
))
3521 return WINED3D_TADDRESS_CLAMP
;
3526 static void wined3d_sampler_desc_from_sampler_states(struct wined3d_sampler_desc
*desc
,
3527 const struct wined3d_context
*context
, const DWORD
*sampler_states
, const struct wined3d_texture
*texture
)
3535 desc
->address_u
= wined3d_texture_address_mode(texture
, sampler_states
[WINED3D_SAMP_ADDRESS_U
]);
3536 desc
->address_v
= wined3d_texture_address_mode(texture
, sampler_states
[WINED3D_SAMP_ADDRESS_V
]);
3537 desc
->address_w
= wined3d_texture_address_mode(texture
, sampler_states
[WINED3D_SAMP_ADDRESS_W
]);
3538 wined3d_color_from_d3dcolor((struct wined3d_color
*)desc
->border_color
,
3539 sampler_states
[WINED3D_SAMP_BORDER_COLOR
]);
3540 if (sampler_states
[WINED3D_SAMP_MAG_FILTER
] > WINED3D_TEXF_ANISOTROPIC
)
3541 FIXME("Unrecognized or unsupported WINED3D_SAMP_MAG_FILTER %#x.\n",
3542 sampler_states
[WINED3D_SAMP_MAG_FILTER
]);
3543 desc
->mag_filter
= min(max(sampler_states
[WINED3D_SAMP_MAG_FILTER
], WINED3D_TEXF_POINT
), WINED3D_TEXF_LINEAR
);
3544 if (sampler_states
[WINED3D_SAMP_MIN_FILTER
] > WINED3D_TEXF_ANISOTROPIC
)
3545 FIXME("Unrecognized or unsupported WINED3D_SAMP_MIN_FILTER %#x.\n",
3546 sampler_states
[WINED3D_SAMP_MIN_FILTER
]);
3547 desc
->min_filter
= min(max(sampler_states
[WINED3D_SAMP_MIN_FILTER
], WINED3D_TEXF_POINT
), WINED3D_TEXF_LINEAR
);
3548 if (sampler_states
[WINED3D_SAMP_MIP_FILTER
] > WINED3D_TEXF_ANISOTROPIC
)
3549 FIXME("Unrecognized or unsupported WINED3D_SAMP_MIP_FILTER %#x.\n",
3550 sampler_states
[WINED3D_SAMP_MIP_FILTER
]);
3551 desc
->mip_filter
= min(max(sampler_states
[WINED3D_SAMP_MIP_FILTER
], WINED3D_TEXF_NONE
), WINED3D_TEXF_LINEAR
);
3552 lod_bias
.d
= sampler_states
[WINED3D_SAMP_MIPMAP_LOD_BIAS
];
3553 desc
->lod_bias
= lod_bias
.f
;
3554 desc
->min_lod
= -1000.0f
;
3555 desc
->max_lod
= 1000.0f
;
3556 desc
->max_anisotropy
= sampler_states
[WINED3D_SAMP_MAX_ANISOTROPY
];
3557 if ((sampler_states
[WINED3D_SAMP_MAG_FILTER
] != WINED3D_TEXF_ANISOTROPIC
3558 && sampler_states
[WINED3D_SAMP_MIN_FILTER
] != WINED3D_TEXF_ANISOTROPIC
3559 && sampler_states
[WINED3D_SAMP_MIP_FILTER
] != WINED3D_TEXF_ANISOTROPIC
)
3560 || (texture
->flags
& WINED3D_TEXTURE_COND_NP2
))
3561 desc
->max_anisotropy
= 1;
3562 desc
->compare
= texture
->resource
.format_flags
& WINED3DFMT_FLAG_SHADOW
;
3563 desc
->comparison_func
= WINED3D_CMP_LESSEQUAL
;
3564 desc
->srgb_decode
= sampler_states
[WINED3D_SAMP_SRGB_TEXTURE
];
3566 if (!(texture
->resource
.format_flags
& WINED3DFMT_FLAG_FILTERING
))
3568 desc
->mag_filter
= WINED3D_TEXF_POINT
;
3569 desc
->min_filter
= WINED3D_TEXF_POINT
;
3570 desc
->mip_filter
= WINED3D_TEXF_NONE
;
3573 if (texture
->flags
& WINED3D_TEXTURE_COND_NP2
)
3575 desc
->mip_filter
= WINED3D_TEXF_NONE
;
3576 if (context
->gl_info
->supported
[WINED3D_GL_NORMALIZED_TEXRECT
])
3577 desc
->min_filter
= WINED3D_TEXF_POINT
;
3581 /* Enabling and disabling texture dimensions is done by texture stage state /
3582 * pixel shader setup, this function only has to bind textures and set the per
3583 * texture states. */
3584 static void sampler(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3586 DWORD sampler_idx
= state_id
- STATE_SAMPLER(0);
3587 DWORD mapped_stage
= context
->tex_unit_map
[sampler_idx
];
3588 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3590 TRACE("Sampler %u.\n", sampler_idx
);
3593 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
)
3595 TRACE("No sampler mapped to stage %u. Returning.\n", sampler_idx
);
3599 if (mapped_stage
>= gl_info
->limits
.combined_samplers
)
3603 context_active_texture(context
, gl_info
, mapped_stage
);
3605 if (state
->textures
[sampler_idx
])
3607 struct wined3d_texture
*texture
= state
->textures
[sampler_idx
];
3608 BOOL srgb
= state
->sampler_states
[sampler_idx
][WINED3D_SAMP_SRGB_TEXTURE
];
3609 const DWORD
*sampler_states
= state
->sampler_states
[sampler_idx
];
3610 struct wined3d_sampler_desc desc
;
3611 struct gl_texture
*gl_tex
;
3612 unsigned int base_level
;
3614 wined3d_sampler_desc_from_sampler_states(&desc
, context
, sampler_states
, texture
);
3616 wined3d_texture_bind(texture
, context
, srgb
);
3617 if (!gl_info
->supported
[ARB_SAMPLER_OBJECTS
])
3619 wined3d_texture_apply_sampler_desc(texture
, &desc
, context
);
3623 struct wined3d_device
*device
= context
->swapchain
->device
;
3624 struct wined3d_sampler
*sampler
;
3625 struct wine_rb_entry
*entry
;
3627 if ((entry
= wine_rb_get(&device
->samplers
, &desc
)))
3629 sampler
= WINE_RB_ENTRY_VALUE(entry
, struct wined3d_sampler
, entry
);
3633 if (FAILED(wined3d_sampler_create(device
, &desc
, NULL
, &sampler
)))
3635 ERR("Failed to create sampler.\n");
3640 if (wine_rb_put(&device
->samplers
, &desc
, &sampler
->entry
) == -1)
3641 ERR("Failed to insert sampler.\n");
3647 GL_EXTCALL(glBindSampler(mapped_stage
, sampler
->name
));
3648 checkGLcall("glBindSampler");
3652 if (texture
->flags
& WINED3D_TEXTURE_COND_NP2
)
3654 else if (desc
.mip_filter
== WINED3D_TEXF_NONE
)
3655 base_level
= texture
->lod
;
3657 base_level
= min(max(sampler_states
[WINED3D_SAMP_MAX_MIP_LEVEL
],
3658 texture
->lod
), texture
->level_count
- 1);
3660 gl_tex
= wined3d_texture_get_gl_texture(texture
, texture
->flags
& WINED3D_TEXTURE_IS_SRGB
);
3661 if (base_level
!= gl_tex
->base_level
)
3663 /* Note that WINED3D_SAMP_MAX_MIP_LEVEL specifies the largest mipmap
3664 * (default 0), while GL_TEXTURE_MAX_LEVEL specifies the smallest
3665 * mipmap used (default 1000). So WINED3D_SAMP_MAX_MIP_LEVEL
3666 * corresponds to GL_TEXTURE_BASE_LEVEL. */
3667 gl_info
->gl_ops
.gl
.p_glTexParameteri(texture
->target
, GL_TEXTURE_BASE_LEVEL
, base_level
);
3668 gl_tex
->base_level
= base_level
;
3671 /* Trigger shader constant reloading (for NP2 texcoord fixup) */
3672 if (!(texture
->flags
& WINED3D_TEXTURE_POW2_MAT_IDENT
))
3673 context
->constant_update_mask
|= WINED3D_SHADER_CONST_PS_NP2_FIXUP
;
3677 context_bind_texture(context
, GL_NONE
, 0);
3678 if (gl_info
->supported
[ARB_SAMPLER_OBJECTS
])
3680 GL_EXTCALL(glBindSampler(mapped_stage
, 0));
3681 checkGLcall("glBindSampler");
3686 void apply_pixelshader(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3692 if (!context
->last_was_pshader
)
3694 /* Former draw without a pixel shader, some samplers may be
3695 * disabled because of WINED3D_TSS_COLOR_OP = WINED3DTOP_DISABLE
3696 * make sure to enable them. */
3697 for (i
= 0; i
< MAX_FRAGMENT_SAMPLERS
; ++i
)
3699 if (!isStateDirty(context
, STATE_SAMPLER(i
)))
3700 sampler(context
, state
, STATE_SAMPLER(i
));
3702 context
->last_was_pshader
= TRUE
;
3706 /* Otherwise all samplers were activated by the code above in
3707 * earlier draws, or by sampler() if a different texture was
3708 * bound. I don't have to do anything. */
3713 /* Disabled the pixel shader - color ops weren't applied while it was
3714 * enabled, so re-apply them. */
3715 for (i
= 0; i
< context
->d3d_info
->limits
.ffp_blend_stages
; ++i
)
3717 if (!isStateDirty(context
, STATE_TEXTURESTAGE(i
, WINED3D_TSS_COLOR_OP
)))
3718 context_apply_state(context
, state
, STATE_TEXTURESTAGE(i
, WINED3D_TSS_COLOR_OP
));
3720 context
->last_was_pshader
= FALSE
;
3723 context
->shader_update_mask
|= 1u << WINED3D_SHADER_TYPE_PIXEL
;
3726 static void state_geometry_shader(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3728 context
->shader_update_mask
|= 1u << WINED3D_SHADER_TYPE_GEOMETRY
;
3731 static void shader_bumpenv(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3733 context
->constant_update_mask
|= WINED3D_SHADER_CONST_PS_BUMP_ENV
;
3736 static void transform_world(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3738 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3739 struct wined3d_matrix mat
;
3741 /* This function is called by transform_view below if the view matrix was changed too
3743 * Deliberately no check if the vertex declaration is dirty because the vdecl state
3744 * does not always update the world matrix, only on a switch between transformed
3745 * and untransformed draws. It *may* happen that the world matrix is set 2 times during one
3746 * draw, but that should be rather rare and cheaper in total.
3748 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3749 checkGLcall("glMatrixMode");
3751 get_modelview_matrix(context
, state
, 0, &mat
);
3753 gl_info
->gl_ops
.gl
.p_glLoadMatrixf((GLfloat
*)&mat
);
3754 checkGLcall("glLoadMatrixf");
3757 void clipplane(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3759 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3760 UINT index
= state_id
- STATE_CLIPPLANE(0);
3763 if (isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_VIEW
)) || index
>= gl_info
->limits
.clipplanes
)
3766 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3767 gl_info
->gl_ops
.gl
.p_glPushMatrix();
3769 /* Clip Plane settings are affected by the model view in OpenGL, the View transform in direct3d */
3771 gl_info
->gl_ops
.gl
.p_glLoadMatrixf(&state
->transforms
[WINED3D_TS_VIEW
]._11
);
3773 /* With vertex shaders, clip planes are not transformed in Direct3D,
3774 * while in OpenGL they are still transformed by the model view matrix. */
3775 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
3777 plane
[0] = state
->clip_planes
[index
].x
;
3778 plane
[1] = state
->clip_planes
[index
].y
;
3779 plane
[2] = state
->clip_planes
[index
].z
;
3780 plane
[3] = state
->clip_planes
[index
].w
;
3782 TRACE("Clipplane [%.8e, %.8e, %.8e, %.8e]\n",
3783 plane
[0], plane
[1], plane
[2], plane
[3]);
3784 gl_info
->gl_ops
.gl
.p_glClipPlane(GL_CLIP_PLANE0
+ index
, plane
);
3785 checkGLcall("glClipPlane");
3787 gl_info
->gl_ops
.gl
.p_glPopMatrix();
3790 static void transform_worldex(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3792 UINT matrix
= state_id
- STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0));
3793 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3796 TRACE("Setting world matrix %d\n", matrix
);
3798 if (matrix
>= gl_info
->limits
.blends
)
3800 WARN("Unsupported blend matrix set\n");
3804 if (isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_VIEW
)))
3807 /* GL_MODELVIEW0_ARB: 0x1700
3808 * GL_MODELVIEW1_ARB: 0x850a
3809 * GL_MODELVIEW2_ARB: 0x8722
3810 * GL_MODELVIEW3_ARB: 0x8723
3812 * GL_MODELVIEW31_ARB: 0x873f
3814 if(matrix
== 1) glMat
= GL_MODELVIEW1_ARB
;
3815 else glMat
= GL_MODELVIEW2_ARB
- 2 + matrix
;
3817 gl_info
->gl_ops
.gl
.p_glMatrixMode(glMat
);
3818 checkGLcall("glMatrixMode(glMat)");
3820 /* World matrix 0 is multiplied with the view matrix because d3d uses 3
3821 * matrices while gl uses only 2. To avoid weighting the view matrix
3822 * incorrectly it has to be multiplied into every GL modelview matrix. */
3823 gl_info
->gl_ops
.gl
.p_glLoadMatrixf(&state
->transforms
[WINED3D_TS_VIEW
]._11
);
3824 checkGLcall("glLoadMatrixf");
3825 gl_info
->gl_ops
.gl
.p_glMultMatrixf(&state
->transforms
[WINED3D_TS_WORLD_MATRIX(matrix
)]._11
);
3826 checkGLcall("glMultMatrixf");
3829 static void state_vertexblend_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3831 enum wined3d_vertex_blend_flags f
= state
->render_states
[WINED3D_RS_VERTEXBLEND
];
3832 static unsigned int once
;
3834 if (f
== WINED3D_VBF_DISABLE
)
3837 if (!once
++) FIXME("Vertex blend flags %#x not supported.\n", f
);
3838 else WARN("Vertex blend flags %#x not supported.\n", f
);
3841 static void state_vertexblend(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3843 enum wined3d_vertex_blend_flags val
= state
->render_states
[WINED3D_RS_VERTEXBLEND
];
3844 struct wined3d_device
*device
= context
->swapchain
->device
;
3845 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3846 static unsigned int once
;
3850 case WINED3D_VBF_1WEIGHTS
:
3851 case WINED3D_VBF_2WEIGHTS
:
3852 case WINED3D_VBF_3WEIGHTS
:
3853 gl_info
->gl_ops
.gl
.p_glEnable(GL_VERTEX_BLEND_ARB
);
3854 checkGLcall("glEnable(GL_VERTEX_BLEND_ARB)");
3856 /* D3D adds one more matrix which has weight (1 - sum(weights)).
3857 * This is enabled at context creation with enabling
3858 * GL_WEIGHT_SUM_UNITY_ARB. */
3859 GL_EXTCALL(glVertexBlendARB(state
->render_states
[WINED3D_RS_VERTEXBLEND
] + 1));
3861 if (!device
->vertexBlendUsed
)
3864 for (i
= 1; i
< gl_info
->limits
.blends
; ++i
)
3866 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(i
))))
3867 transform_worldex(context
, state
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(i
)));
3869 device
->vertexBlendUsed
= TRUE
;
3873 case WINED3D_VBF_TWEENING
:
3874 case WINED3D_VBF_0WEIGHTS
: /* Indexed vertex blending, not supported. */
3875 if (!once
++) FIXME("Vertex blend flags %#x not supported.\n", val
);
3876 else WARN("Vertex blend flags %#x not supported.\n", val
);
3878 case WINED3D_VBF_DISABLE
:
3879 gl_info
->gl_ops
.gl
.p_glDisable(GL_VERTEX_BLEND_ARB
);
3880 checkGLcall("glDisable(GL_VERTEX_BLEND_ARB)");
3885 static void transform_view(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3887 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3888 const struct wined3d_light_info
*light
= NULL
;
3891 /* If we are changing the View matrix, reset the light and clipping planes to the new view
3892 * NOTE: We have to reset the positions even if the light/plane is not currently
3893 * enabled, since the call to enable it will not reset the position.
3894 * NOTE2: Apparently texture transforms do NOT need reapplying
3897 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3898 checkGLcall("glMatrixMode(GL_MODELVIEW)");
3899 gl_info
->gl_ops
.gl
.p_glLoadMatrixf(&state
->transforms
[WINED3D_TS_VIEW
]._11
);
3900 checkGLcall("glLoadMatrixf(...)");
3902 /* Reset lights. TODO: Call light apply func */
3903 for (k
= 0; k
< gl_info
->limits
.lights
; ++k
)
3905 if (!(light
= state
->lights
[k
]))
3907 if (light
->OriginalParms
.type
== WINED3D_LIGHT_DIRECTIONAL
)
3908 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ light
->glIndex
, GL_POSITION
, &light
->direction
.x
);
3910 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ light
->glIndex
, GL_POSITION
, &light
->position
.x
);
3911 checkGLcall("glLightfv posn");
3912 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ light
->glIndex
, GL_SPOT_DIRECTION
, &light
->direction
.x
);
3913 checkGLcall("glLightfv dirn");
3916 /* Reset Clipping Planes */
3917 for (k
= 0; k
< gl_info
->limits
.clipplanes
; ++k
)
3919 if (!isStateDirty(context
, STATE_CLIPPLANE(k
)))
3920 clipplane(context
, state
, STATE_CLIPPLANE(k
));
3923 if (context
->last_was_rhw
)
3925 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
3926 checkGLcall("glLoadIdentity()");
3927 /* No need to update the world matrix, the identity is fine */
3931 /* Call the world matrix state, this will apply the combined WORLD + VIEW matrix
3932 * No need to do it here if the state is scheduled for update. */
3933 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0))))
3934 transform_world(context
, state
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0)));
3936 /* Avoid looping over a number of matrices if the app never used the functionality */
3937 if (context
->swapchain
->device
->vertexBlendUsed
)
3939 for (k
= 1; k
< gl_info
->limits
.blends
; ++k
)
3941 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(k
))))
3942 transform_worldex(context
, state
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(k
)));
3947 static void transform_projection(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3949 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3950 struct wined3d_matrix projection
;
3952 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_PROJECTION
);
3953 checkGLcall("glMatrixMode(GL_PROJECTION)");
3955 get_projection_matrix(context
, state
, &projection
);
3956 gl_info
->gl_ops
.gl
.p_glLoadMatrixf(&projection
._11
);
3957 checkGLcall("glLoadMatrixf");
3960 /* This should match any arrays loaded in load_vertex_data.
3961 * TODO: Only load / unload arrays if we have to. */
3962 static void unload_vertex_data(const struct wined3d_gl_info
*gl_info
)
3964 gl_info
->gl_ops
.gl
.p_glDisableClientState(GL_VERTEX_ARRAY
);
3965 gl_info
->gl_ops
.gl
.p_glDisableClientState(GL_NORMAL_ARRAY
);
3966 gl_info
->gl_ops
.gl
.p_glDisableClientState(GL_COLOR_ARRAY
);
3967 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
3968 gl_info
->gl_ops
.gl
.p_glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT
);
3969 if (gl_info
->supported
[ARB_VERTEX_BLEND
])
3970 gl_info
->gl_ops
.gl
.p_glDisableClientState(GL_WEIGHT_ARRAY_ARB
);
3971 unload_tex_coords(gl_info
);
3974 static inline void unload_numbered_array(struct wined3d_context
*context
, int i
)
3976 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3978 GL_EXTCALL(glDisableVertexAttribArray(i
));
3979 checkGLcall("glDisableVertexAttribArray");
3980 if (gl_info
->supported
[ARB_INSTANCED_ARRAYS
])
3981 GL_EXTCALL(glVertexAttribDivisor(i
, 0));
3983 context
->numbered_array_mask
&= ~(1u << i
);
3986 /* This should match any arrays loaded in loadNumberedArrays
3987 * TODO: Only load / unload arrays if we have to. */
3988 static void unload_numbered_arrays(struct wined3d_context
*context
)
3990 /* disable any attribs (this is the same for both GLSL and ARB modes) */
3993 for (i
= 0; i
< context
->gl_info
->limits
.vertex_attribs
; ++i
) {
3994 unload_numbered_array(context
, i
);
3998 static void load_numbered_arrays(struct wined3d_context
*context
,
3999 const struct wined3d_stream_info
*stream_info
, const struct wined3d_state
*state
)
4001 const struct wined3d_shader
*vs
= state
->shader
[WINED3D_SHADER_TYPE_VERTEX
];
4002 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4003 GLuint curVBO
= gl_info
->supported
[ARB_VERTEX_BUFFER_OBJECT
] ? ~0U : 0;
4006 /* Default to no instancing */
4007 context
->instance_count
= 0;
4009 for (i
= 0; i
< MAX_ATTRIBS
; ++i
)
4011 const struct wined3d_stream_info_element
*element
= &stream_info
->elements
[i
];
4012 const struct wined3d_stream_state
*stream
;
4014 if (!(stream_info
->use_map
& (1u << i
)))
4016 if (context
->numbered_array_mask
& (1u << i
))
4017 unload_numbered_array(context
, i
);
4018 if (!use_vs(state
) && i
== WINED3D_FFP_DIFFUSE
)
4019 GL_EXTCALL(glVertexAttrib4f(i
, 1.0f
, 1.0f
, 1.0f
, 1.0f
));
4021 GL_EXTCALL(glVertexAttrib4f(i
, 0.0f
, 0.0f
, 0.0f
, 0.0f
));
4025 stream
= &state
->streams
[element
->stream_idx
];
4027 if ((stream
->flags
& WINED3DSTREAMSOURCE_INSTANCEDATA
) && !context
->instance_count
)
4028 context
->instance_count
= state
->streams
[0].frequency
? state
->streams
[0].frequency
: 1;
4030 if (gl_info
->supported
[ARB_INSTANCED_ARRAYS
])
4032 GL_EXTCALL(glVertexAttribDivisor(i
, element
->divisor
));
4034 else if (element
->divisor
)
4036 /* Unload instanced arrays, they will be loaded using
4037 * immediate mode instead. */
4038 if (context
->numbered_array_mask
& (1u << i
))
4039 unload_numbered_array(context
, i
);
4043 TRACE_(d3d_shader
)("Loading array %u [VBO=%u].\n", i
, element
->data
.buffer_object
);
4045 if (element
->stride
)
4047 if (curVBO
!= element
->data
.buffer_object
)
4049 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER
, element
->data
.buffer_object
));
4050 checkGLcall("glBindBuffer");
4051 curVBO
= element
->data
.buffer_object
;
4053 /* Use the VBO to find out if a vertex buffer exists, not the vb
4054 * pointer. vb can point to a user pointer data blob. In that case
4055 * curVBO will be 0. If there is a vertex buffer but no vbo we
4056 * won't be load converted attributes anyway. */
4057 if (vs
&& vs
->reg_maps
.shader_version
.major
>= 4
4058 && (element
->format
->flags
[WINED3D_GL_RES_TYPE_BUFFER
] & WINED3DFMT_FLAG_INTEGER
))
4060 GL_EXTCALL(glVertexAttribIPointer(i
, element
->format
->gl_vtx_format
, element
->format
->gl_vtx_type
,
4061 element
->stride
, element
->data
.addr
+ state
->load_base_vertex_index
* element
->stride
));
4065 GL_EXTCALL(glVertexAttribPointer(i
, element
->format
->gl_vtx_format
, element
->format
->gl_vtx_type
,
4066 element
->format
->gl_normalized
, element
->stride
,
4067 element
->data
.addr
+ state
->load_base_vertex_index
* element
->stride
));
4070 if (!(context
->numbered_array_mask
& (1u << i
)))
4072 GL_EXTCALL(glEnableVertexAttribArray(i
));
4073 context
->numbered_array_mask
|= (1u << i
);
4078 /* Stride = 0 means always the same values.
4079 * glVertexAttribPointer doesn't do that. Instead disable the
4080 * pointer and set up the attribute statically. But we have to
4081 * figure out the system memory address. */
4082 const BYTE
*ptr
= element
->data
.addr
;
4083 if (element
->data
.buffer_object
)
4084 ptr
+= (ULONG_PTR
)buffer_get_sysmem(stream
->buffer
, context
);
4086 if (context
->numbered_array_mask
& (1u << i
))
4087 unload_numbered_array(context
, i
);
4089 switch (element
->format
->id
)
4091 case WINED3DFMT_R32_FLOAT
:
4092 GL_EXTCALL(glVertexAttrib1fv(i
, (const GLfloat
*)ptr
));
4094 case WINED3DFMT_R32G32_FLOAT
:
4095 GL_EXTCALL(glVertexAttrib2fv(i
, (const GLfloat
*)ptr
));
4097 case WINED3DFMT_R32G32B32_FLOAT
:
4098 GL_EXTCALL(glVertexAttrib3fv(i
, (const GLfloat
*)ptr
));
4100 case WINED3DFMT_R32G32B32A32_FLOAT
:
4101 GL_EXTCALL(glVertexAttrib4fv(i
, (const GLfloat
*)ptr
));
4104 case WINED3DFMT_R8G8B8A8_UINT
:
4105 GL_EXTCALL(glVertexAttrib4ubv(i
, ptr
));
4107 case WINED3DFMT_B8G8R8A8_UNORM
:
4108 if (gl_info
->supported
[ARB_VERTEX_ARRAY_BGRA
])
4110 const DWORD
*src
= (const DWORD
*)ptr
;
4111 DWORD c
= *src
& 0xff00ff00u
;
4112 c
|= (*src
& 0xff0000u
) >> 16;
4113 c
|= (*src
& 0xffu
) << 16;
4114 GL_EXTCALL(glVertexAttrib4Nubv(i
, (GLubyte
*)&c
));
4117 /* else fallthrough */
4118 case WINED3DFMT_R8G8B8A8_UNORM
:
4119 GL_EXTCALL(glVertexAttrib4Nubv(i
, ptr
));
4122 case WINED3DFMT_R16G16_SINT
:
4123 GL_EXTCALL(glVertexAttrib2sv(i
, (const GLshort
*)ptr
));
4125 case WINED3DFMT_R16G16B16A16_SINT
:
4126 GL_EXTCALL(glVertexAttrib4sv(i
, (const GLshort
*)ptr
));
4129 case WINED3DFMT_R16G16_SNORM
:
4131 const GLshort s
[4] = {((const GLshort
*)ptr
)[0], ((const GLshort
*)ptr
)[1], 0, 1};
4132 GL_EXTCALL(glVertexAttrib4Nsv(i
, s
));
4135 case WINED3DFMT_R16G16_UNORM
:
4137 const GLushort s
[4] = {((const GLushort
*)ptr
)[0], ((const GLushort
*)ptr
)[1], 0, 1};
4138 GL_EXTCALL(glVertexAttrib4Nusv(i
, s
));
4141 case WINED3DFMT_R16G16B16A16_SNORM
:
4142 GL_EXTCALL(glVertexAttrib4Nsv(i
, (const GLshort
*)ptr
));
4144 case WINED3DFMT_R16G16B16A16_UNORM
:
4145 GL_EXTCALL(glVertexAttrib4Nusv(i
, (const GLushort
*)ptr
));
4148 case WINED3DFMT_R10G10B10X2_UINT
:
4149 FIXME("Unsure about WINED3DDECLTYPE_UDEC3.\n");
4150 /*glVertexAttrib3usvARB(i, (const GLushort *)ptr); Does not exist */
4152 case WINED3DFMT_R10G10B10X2_SNORM
:
4153 FIXME("Unsure about WINED3DDECLTYPE_DEC3N.\n");
4154 /*glVertexAttrib3NusvARB(i, (const GLushort *)ptr); Does not exist */
4157 case WINED3DFMT_R16G16_FLOAT
:
4158 if (gl_info
->supported
[NV_HALF_FLOAT
] && gl_info
->supported
[NV_VERTEX_PROGRAM
])
4160 /* Not supported by GL_ARB_half_float_vertex. */
4161 GL_EXTCALL(glVertexAttrib2hvNV(i
, (const GLhalfNV
*)ptr
));
4165 float x
= float_16_to_32(((const unsigned short *)ptr
) + 0);
4166 float y
= float_16_to_32(((const unsigned short *)ptr
) + 1);
4167 GL_EXTCALL(glVertexAttrib2f(i
, x
, y
));
4170 case WINED3DFMT_R16G16B16A16_FLOAT
:
4171 if (gl_info
->supported
[NV_HALF_FLOAT
] && gl_info
->supported
[NV_VERTEX_PROGRAM
])
4173 /* Not supported by GL_ARB_half_float_vertex. */
4174 GL_EXTCALL(glVertexAttrib4hvNV(i
, (const GLhalfNV
*)ptr
));
4178 float x
= float_16_to_32(((const unsigned short *)ptr
) + 0);
4179 float y
= float_16_to_32(((const unsigned short *)ptr
) + 1);
4180 float z
= float_16_to_32(((const unsigned short *)ptr
) + 2);
4181 float w
= float_16_to_32(((const unsigned short *)ptr
) + 3);
4182 GL_EXTCALL(glVertexAttrib4f(i
, x
, y
, z
, w
));
4187 ERR("Unexpected declaration in stride 0 attributes.\n");
4193 checkGLcall("Loading numbered arrays");
4196 static void load_vertex_data(struct wined3d_context
*context
,
4197 const struct wined3d_stream_info
*si
, const struct wined3d_state
*state
)
4199 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4200 GLuint curVBO
= gl_info
->supported
[ARB_VERTEX_BUFFER_OBJECT
] ? ~0U : 0;
4201 const struct wined3d_stream_info_element
*e
;
4203 TRACE("Using fast vertex array code\n");
4205 /* This is fixed function pipeline only, and the fixed function pipeline doesn't do instancing */
4206 context
->instance_count
= 0;
4208 /* Blend Data ---------------------------------------------- */
4209 if ((si
->use_map
& (1u << WINED3D_FFP_BLENDWEIGHT
))
4210 || si
->use_map
& (1u << WINED3D_FFP_BLENDINDICES
))
4212 e
= &si
->elements
[WINED3D_FFP_BLENDWEIGHT
];
4214 if (gl_info
->supported
[ARB_VERTEX_BLEND
])
4216 TRACE("Blend %u %p %u\n", e
->format
->component_count
,
4217 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
, e
->stride
);
4219 gl_info
->gl_ops
.gl
.p_glEnableClientState(GL_WEIGHT_ARRAY_ARB
);
4220 checkGLcall("glEnableClientState(GL_WEIGHT_ARRAY_ARB)");
4222 GL_EXTCALL(glVertexBlendARB(e
->format
->component_count
+ 1));
4224 if (curVBO
!= e
->data
.buffer_object
)
4226 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER
, e
->data
.buffer_object
));
4227 checkGLcall("glBindBuffer");
4228 curVBO
= e
->data
.buffer_object
;
4231 TRACE("glWeightPointerARB(%#x, %#x, %#x, %p);\n",
4232 e
->format
->gl_vtx_format
,
4233 e
->format
->gl_vtx_type
,
4235 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4236 GL_EXTCALL(glWeightPointerARB(e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
4237 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
));
4239 checkGLcall("glWeightPointerARB");
4241 if (si
->use_map
& (1u << WINED3D_FFP_BLENDINDICES
))
4246 FIXME("blendMatrixIndices support\n");
4253 /* TODO: Support vertex blending in immediate mode draws. No need
4254 * to write a FIXME here, this is done after the general vertex
4255 * declaration decoding. */
4256 WARN("Vertex blending not supported.\n");
4261 if (gl_info
->supported
[ARB_VERTEX_BLEND
])
4263 static const GLbyte one
= 1;
4264 GL_EXTCALL(glWeightbvARB(1, &one
));
4265 checkGLcall("glWeightbvARB(gl_info->max_blends, weights)");
4269 /* Point Size ----------------------------------------------*/
4270 if (si
->use_map
& (1u << WINED3D_FFP_PSIZE
))
4272 /* no such functionality in the fixed function GL pipeline */
4273 TRACE("Cannot change ptSize here in openGl\n");
4274 /* TODO: Implement this function in using shaders if they are available */
4277 /* Vertex Pointers -----------------------------------------*/
4278 if (si
->use_map
& (1u << WINED3D_FFP_POSITION
))
4280 e
= &si
->elements
[WINED3D_FFP_POSITION
];
4282 if (curVBO
!= e
->data
.buffer_object
)
4284 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER
, e
->data
.buffer_object
));
4285 checkGLcall("glBindBuffer");
4286 curVBO
= e
->data
.buffer_object
;
4289 TRACE("glVertexPointer(%#x, %#x, %#x, %p);\n",
4290 e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
4291 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4292 gl_info
->gl_ops
.gl
.p_glVertexPointer(e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
4293 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4294 checkGLcall("glVertexPointer(...)");
4295 gl_info
->gl_ops
.gl
.p_glEnableClientState(GL_VERTEX_ARRAY
);
4296 checkGLcall("glEnableClientState(GL_VERTEX_ARRAY)");
4299 /* Normals -------------------------------------------------*/
4300 if (si
->use_map
& (1u << WINED3D_FFP_NORMAL
))
4302 e
= &si
->elements
[WINED3D_FFP_NORMAL
];
4304 if (curVBO
!= e
->data
.buffer_object
)
4306 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER
, e
->data
.buffer_object
));
4307 checkGLcall("glBindBuffer");
4308 curVBO
= e
->data
.buffer_object
;
4311 TRACE("glNormalPointer(%#x, %#x, %p);\n", e
->format
->gl_vtx_type
, e
->stride
,
4312 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4313 gl_info
->gl_ops
.gl
.p_glNormalPointer(e
->format
->gl_vtx_type
, e
->stride
,
4314 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4315 checkGLcall("glNormalPointer(...)");
4316 gl_info
->gl_ops
.gl
.p_glEnableClientState(GL_NORMAL_ARRAY
);
4317 checkGLcall("glEnableClientState(GL_NORMAL_ARRAY)");
4322 gl_info
->gl_ops
.gl
.p_glNormal3f(0, 0, 0);
4323 checkGLcall("glNormal3f(0, 0, 0)");
4326 /* Diffuse Colour --------------------------------------------*/
4327 if (si
->use_map
& (1u << WINED3D_FFP_DIFFUSE
))
4329 e
= &si
->elements
[WINED3D_FFP_DIFFUSE
];
4331 if (curVBO
!= e
->data
.buffer_object
)
4333 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER
, e
->data
.buffer_object
));
4334 checkGLcall("glBindBuffer");
4335 curVBO
= e
->data
.buffer_object
;
4338 TRACE("glColorPointer(%#x, %#x %#x, %p);\n",
4339 e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
4340 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4341 gl_info
->gl_ops
.gl
.p_glColorPointer(e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
4342 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4343 checkGLcall("glColorPointer(4, GL_UNSIGNED_BYTE, ...)");
4344 gl_info
->gl_ops
.gl
.p_glEnableClientState(GL_COLOR_ARRAY
);
4345 checkGLcall("glEnableClientState(GL_COLOR_ARRAY)");
4350 gl_info
->gl_ops
.gl
.p_glColor4f(1.0f
, 1.0f
, 1.0f
, 1.0f
);
4351 checkGLcall("glColor4f(1, 1, 1, 1)");
4354 /* Specular Colour ------------------------------------------*/
4355 if (si
->use_map
& (1u << WINED3D_FFP_SPECULAR
))
4357 TRACE("setting specular colour\n");
4359 e
= &si
->elements
[WINED3D_FFP_SPECULAR
];
4361 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
4363 GLenum type
= e
->format
->gl_vtx_type
;
4364 GLint format
= e
->format
->gl_vtx_format
;
4366 if (curVBO
!= e
->data
.buffer_object
)
4368 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER
, e
->data
.buffer_object
));
4369 checkGLcall("glBindBuffer");
4370 curVBO
= e
->data
.buffer_object
;
4373 if (format
!= 4 || (gl_info
->quirks
& WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA
))
4375 /* Usually specular colors only allow 3 components, since they have no alpha. In D3D, the specular alpha
4376 * contains the fog coordinate, which is passed to GL with GL_EXT_fog_coord. However, the fixed function
4377 * vertex pipeline can pass the specular alpha through, and pixel shaders can read it. So it GL accepts
4378 * 4 component secondary colors use it
4380 TRACE("glSecondaryColorPointer(%#x, %#x, %#x, %p);\n", format
, type
, e
->stride
,
4381 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4382 GL_EXTCALL(glSecondaryColorPointerEXT(format
, type
, e
->stride
,
4383 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
));
4384 checkGLcall("glSecondaryColorPointerEXT(format, type, ...)");
4390 case GL_UNSIGNED_BYTE
:
4391 TRACE("glSecondaryColorPointer(3, GL_UNSIGNED_BYTE, %#x, %p);\n", e
->stride
,
4392 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4393 GL_EXTCALL(glSecondaryColorPointerEXT(3, GL_UNSIGNED_BYTE
, e
->stride
,
4394 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
));
4395 checkGLcall("glSecondaryColorPointerEXT(3, GL_UNSIGNED_BYTE, ...)");
4399 FIXME("Add 4 component specular color pointers for type %x\n", type
);
4400 /* Make sure that the right color component is dropped */
4401 TRACE("glSecondaryColorPointer(3, %#x, %#x, %p);\n", type
, e
->stride
,
4402 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4403 GL_EXTCALL(glSecondaryColorPointerEXT(3, type
, e
->stride
,
4404 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
));
4405 checkGLcall("glSecondaryColorPointerEXT(3, type, ...)");
4408 gl_info
->gl_ops
.gl
.p_glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT
);
4409 checkGLcall("glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
4413 WARN("Specular colour is not supported in this GL implementation.\n");
4418 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
4420 GL_EXTCALL(glSecondaryColor3fEXT
)(0, 0, 0);
4421 checkGLcall("glSecondaryColor3fEXT(0, 0, 0)");
4425 WARN("Specular colour is not supported in this GL implementation.\n");
4429 /* Texture coords -------------------------------------------*/
4430 load_tex_coords(context
, si
, &curVBO
, state
);
4433 static void streamsrc(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4435 BOOL load_numbered
= context
->d3d_info
->ffp_generic_attributes
4436 || (use_vs(state
) && !context
->use_immediate_mode_draw
);
4437 BOOL load_named
= !context
->d3d_info
->ffp_generic_attributes
4438 && !use_vs(state
) && !context
->use_immediate_mode_draw
;
4440 if (isStateDirty(context
, STATE_VDECL
)) return;
4441 if (context
->numberedArraysLoaded
&& !load_numbered
)
4443 unload_numbered_arrays(context
);
4444 context
->numberedArraysLoaded
= FALSE
;
4445 context
->numbered_array_mask
= 0;
4447 else if (context
->namedArraysLoaded
)
4449 unload_vertex_data(context
->gl_info
);
4450 context
->namedArraysLoaded
= FALSE
;
4455 TRACE("Loading numbered arrays\n");
4456 load_numbered_arrays(context
, &context
->stream_info
, state
);
4457 context
->numberedArraysLoaded
= TRUE
;
4459 else if (load_named
)
4461 TRACE("Loading vertex data\n");
4462 load_vertex_data(context
, &context
->stream_info
, state
);
4463 context
->namedArraysLoaded
= TRUE
;
4467 static void vdecl_miscpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4469 if (isStateDirty(context
, STATE_STREAMSRC
))
4471 streamsrc(context
, state
, STATE_STREAMSRC
);
4474 static void vertexdeclaration(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4476 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4477 BOOL useVertexShaderFunction
= use_vs(state
);
4478 BOOL updateFog
= FALSE
;
4480 BOOL wasrhw
= context
->last_was_rhw
;
4483 transformed
= context
->stream_info
.position_transformed
;
4484 if (transformed
!= context
->last_was_rhw
&& !useVertexShaderFunction
)
4487 context
->last_was_rhw
= transformed
;
4489 if (context
->stream_info
.swizzle_map
!= context
->last_swizzle_map
)
4490 context
->shader_update_mask
|= 1u << WINED3D_SHADER_TYPE_VERTEX
;
4492 context
->last_swizzle_map
= context
->stream_info
.swizzle_map
;
4494 /* Don't have to apply the matrices when vertex shaders are used. When
4495 * vshaders are turned off this function will be called again anyway to
4496 * make sure they're properly set. */
4497 if (!useVertexShaderFunction
)
4499 /* TODO: Move this mainly to the viewport state and only apply when
4500 * the vp has changed or transformed / untransformed was switched. */
4501 if (wasrhw
!= context
->last_was_rhw
4502 && !isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
))
4503 && !isStateDirty(context
, STATE_VIEWPORT
))
4504 transform_projection(context
, state
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
));
4505 /* World matrix needs reapplication here only if we're switching between rhw and non-rhw
4508 * If a vertex shader is used, the world matrix changed and then vertex shader unbound
4509 * this check will fail and the matrix not applied again. This is OK because a simple
4510 * world matrix change reapplies the matrix - These checks here are only to satisfy the
4511 * needs of the vertex declaration.
4513 * World and view matrix go into the same gl matrix, so only apply them when neither is
4516 if (transformed
!= wasrhw
&& !isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0)))
4517 && !isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_VIEW
)))
4518 transform_world(context
, state
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0)));
4519 if (!isStateDirty(context
, STATE_RENDER(WINED3D_RS_COLORVERTEX
)))
4520 context_apply_state(context
, state
, STATE_RENDER(WINED3D_RS_COLORVERTEX
));
4521 if (!isStateDirty(context
, STATE_RENDER(WINED3D_RS_LIGHTING
)))
4522 state_lighting(context
, state
, STATE_RENDER(WINED3D_RS_LIGHTING
));
4524 if (context
->last_was_vshader
)
4528 if (!context
->d3d_info
->vs_clipping
4529 && !isStateDirty(context
, STATE_RENDER(WINED3D_RS_CLIPPLANEENABLE
)))
4531 state_clipping(context
, state
, STATE_RENDER(WINED3D_RS_CLIPPLANEENABLE
));
4534 for (i
= 0; i
< gl_info
->limits
.clipplanes
; ++i
)
4536 clipplane(context
, state
, STATE_CLIPPLANE(i
));
4539 if (!isStateDirty(context
, STATE_RENDER(WINED3D_RS_NORMALIZENORMALS
)))
4540 state_normalize(context
, state
, STATE_RENDER(WINED3D_RS_NORMALIZENORMALS
));
4544 if(!context
->last_was_vshader
) {
4545 static BOOL warned
= FALSE
;
4546 if (!context
->d3d_info
->vs_clipping
)
4548 /* Disable all clip planes to get defined results on all drivers. See comment in the
4549 * state_clipping state handler
4551 for (i
= 0; i
< gl_info
->limits
.clipplanes
; ++i
)
4553 gl_info
->gl_ops
.gl
.p_glDisable(GL_CLIP_PLANE0
+ i
);
4554 checkGLcall("glDisable(GL_CLIP_PLANE0 + i)");
4557 if (!warned
&& state
->render_states
[WINED3D_RS_CLIPPLANEENABLE
])
4559 FIXME("Clipping not supported with vertex shaders\n");
4565 /* Apply the transform matrices when switching from rhw
4566 * drawing to vertex shaders. Vertex shaders themselves do
4567 * not need it, but the matrices are not reapplied
4568 * automatically when switching back from vertex shaders to
4569 * fixed function processing. So make sure we leave the fixed
4570 * function vertex processing states back in a sane state
4571 * before switching to shaders. */
4572 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
)))
4573 transform_projection(context
, state
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
));
4574 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0))))
4575 transform_world(context
, state
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0)));
4579 /* Vertex shader clipping ignores the view matrix. Update all clipplanes
4580 * (Note: ARB shaders can read the clip planes for clipping emulation even if
4581 * device->vs_clipping is false.
4583 for (i
= 0; i
< gl_info
->limits
.clipplanes
; ++i
)
4585 clipplane(context
, state
, STATE_CLIPPLANE(i
));
4590 context
->last_was_vshader
= useVertexShaderFunction
;
4591 context
->shader_update_mask
|= 1u << WINED3D_SHADER_TYPE_VERTEX
;
4594 context_apply_state(context
, state
, STATE_RENDER(WINED3D_RS_FOGVERTEXMODE
));
4596 if (!useVertexShaderFunction
)
4600 for (i
= 0; i
< MAX_TEXTURES
; ++i
)
4602 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_TEXTURE0
+ i
)))
4603 transform_texture(context
, state
, STATE_TEXTURESTAGE(i
, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
));
4606 if (use_ps(state
) && state
->shader
[WINED3D_SHADER_TYPE_PIXEL
]->reg_maps
.shader_version
.major
== 1
4607 && state
->shader
[WINED3D_SHADER_TYPE_PIXEL
]->reg_maps
.shader_version
.minor
<= 3)
4608 context
->shader_update_mask
|= 1u << WINED3D_SHADER_TYPE_PIXEL
;
4612 static void viewport_miscpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4614 const struct wined3d_rendertarget_view
*depth_stencil
= state
->fb
->depth_stencil
;
4615 const struct wined3d_rendertarget_view
*target
= state
->fb
->render_targets
[0];
4616 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4617 struct wined3d_viewport vp
= state
->viewport
;
4618 unsigned int width
, height
;
4622 if (vp
.width
> target
->width
)
4623 vp
.width
= target
->width
;
4624 if (vp
.height
> target
->height
)
4625 vp
.height
= target
->height
;
4627 surface_get_drawable_size(wined3d_rendertarget_view_get_surface(target
), context
, &width
, &height
);
4629 else if (depth_stencil
)
4631 width
= depth_stencil
->width
;
4632 height
= depth_stencil
->height
;
4636 FIXME("No attachments draw calls not supported.\n");
4640 gl_info
->gl_ops
.gl
.p_glDepthRange(vp
.min_z
, vp
.max_z
);
4641 checkGLcall("glDepthRange");
4642 /* Note: GL requires lower left, DirectX supplies upper left. This is
4643 * reversed when using offscreen rendering. */
4644 if (context
->render_offscreen
)
4645 gl_info
->gl_ops
.gl
.p_glViewport(vp
.x
, vp
.y
, vp
.width
, vp
.height
);
4647 gl_info
->gl_ops
.gl
.p_glViewport(vp
.x
, (height
- (vp
.y
+ vp
.height
)), vp
.width
, vp
.height
);
4648 checkGLcall("glViewport");
4651 static void viewport_vertexpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4653 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
)))
4654 transform_projection(context
, state
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
));
4655 if (!isStateDirty(context
, STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
))
4656 && state
->render_states
[WINED3D_RS_POINTSCALEENABLE
])
4657 state_pscale(context
, state
, STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
));
4658 /* Update the position fixup. */
4659 context
->constant_update_mask
|= WINED3D_SHADER_CONST_POS_FIXUP
;
4662 static void light(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4664 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4665 UINT Index
= state_id
- STATE_ACTIVELIGHT(0);
4666 const struct wined3d_light_info
*lightInfo
= state
->lights
[Index
];
4670 gl_info
->gl_ops
.gl
.p_glDisable(GL_LIGHT0
+ Index
);
4671 checkGLcall("glDisable(GL_LIGHT0 + Index)");
4676 float colRGBA
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
4678 /* Light settings are affected by the model view in OpenGL, the View transform in direct3d*/
4679 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
4680 gl_info
->gl_ops
.gl
.p_glPushMatrix();
4681 gl_info
->gl_ops
.gl
.p_glLoadMatrixf(&state
->transforms
[WINED3D_TS_VIEW
]._11
);
4684 colRGBA
[0] = lightInfo
->OriginalParms
.diffuse
.r
;
4685 colRGBA
[1] = lightInfo
->OriginalParms
.diffuse
.g
;
4686 colRGBA
[2] = lightInfo
->OriginalParms
.diffuse
.b
;
4687 colRGBA
[3] = lightInfo
->OriginalParms
.diffuse
.a
;
4688 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_DIFFUSE
, colRGBA
);
4689 checkGLcall("glLightfv");
4692 colRGBA
[0] = lightInfo
->OriginalParms
.specular
.r
;
4693 colRGBA
[1] = lightInfo
->OriginalParms
.specular
.g
;
4694 colRGBA
[2] = lightInfo
->OriginalParms
.specular
.b
;
4695 colRGBA
[3] = lightInfo
->OriginalParms
.specular
.a
;
4696 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_SPECULAR
, colRGBA
);
4697 checkGLcall("glLightfv");
4700 colRGBA
[0] = lightInfo
->OriginalParms
.ambient
.r
;
4701 colRGBA
[1] = lightInfo
->OriginalParms
.ambient
.g
;
4702 colRGBA
[2] = lightInfo
->OriginalParms
.ambient
.b
;
4703 colRGBA
[3] = lightInfo
->OriginalParms
.ambient
.a
;
4704 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_AMBIENT
, colRGBA
);
4705 checkGLcall("glLightfv");
4707 if ((lightInfo
->OriginalParms
.range
* lightInfo
->OriginalParms
.range
) >= FLT_MIN
)
4708 quad_att
= 1.4f
/ (lightInfo
->OriginalParms
.range
* lightInfo
->OriginalParms
.range
);
4710 quad_att
= 0.0f
; /* 0 or MAX? (0 seems to be ok) */
4712 /* Do not assign attenuation values for lights that do not use them. D3D apps are free to pass any junk,
4713 * but gl drivers use them and may crash due to bad Attenuation values. Need for Speed most wanted sets
4714 * Attenuation0 to NaN and crashes in the gl lib
4717 switch (lightInfo
->OriginalParms
.type
)
4719 case WINED3D_LIGHT_POINT
:
4721 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->position
.x
);
4722 checkGLcall("glLightfv");
4723 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
4724 checkGLcall("glLightf");
4725 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_CONSTANT_ATTENUATION
,
4726 lightInfo
->OriginalParms
.attenuation0
);
4727 checkGLcall("glLightf");
4728 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_LINEAR_ATTENUATION
,
4729 lightInfo
->OriginalParms
.attenuation1
);
4730 checkGLcall("glLightf");
4731 if (quad_att
< lightInfo
->OriginalParms
.attenuation2
)
4732 quad_att
= lightInfo
->OriginalParms
.attenuation2
;
4733 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_QUADRATIC_ATTENUATION
, quad_att
);
4734 checkGLcall("glLightf");
4738 case WINED3D_LIGHT_SPOT
:
4740 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->position
.x
);
4741 checkGLcall("glLightfv");
4743 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_SPOT_DIRECTION
, &lightInfo
->direction
.x
);
4744 checkGLcall("glLightfv");
4745 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_SPOT_EXPONENT
, lightInfo
->exponent
);
4746 checkGLcall("glLightf");
4747 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
4748 checkGLcall("glLightf");
4749 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_CONSTANT_ATTENUATION
,
4750 lightInfo
->OriginalParms
.attenuation0
);
4751 checkGLcall("glLightf");
4752 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_LINEAR_ATTENUATION
,
4753 lightInfo
->OriginalParms
.attenuation1
);
4754 checkGLcall("glLightf");
4755 if (quad_att
< lightInfo
->OriginalParms
.attenuation2
)
4756 quad_att
= lightInfo
->OriginalParms
.attenuation2
;
4757 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_QUADRATIC_ATTENUATION
, quad_att
);
4758 checkGLcall("glLightf");
4762 case WINED3D_LIGHT_DIRECTIONAL
:
4764 /* Note GL uses w position of 0 for direction! */
4765 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->direction
.x
);
4766 checkGLcall("glLightfv");
4767 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
4768 checkGLcall("glLightf");
4769 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_SPOT_EXPONENT
, 0.0f
);
4770 checkGLcall("glLightf");
4774 FIXME("Unrecognized light type %#x.\n", lightInfo
->OriginalParms
.type
);
4777 /* Restore the modelview matrix */
4778 gl_info
->gl_ops
.gl
.p_glPopMatrix();
4780 gl_info
->gl_ops
.gl
.p_glEnable(GL_LIGHT0
+ Index
);
4781 checkGLcall("glEnable(GL_LIGHT0 + Index)");
4785 static void scissorrect(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4787 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4788 const RECT
*r
= &state
->scissor_rect
;
4790 /* Warning: glScissor uses window coordinates, not viewport coordinates,
4791 * so our viewport correction does not apply. Warning2: Even in windowed
4792 * mode the coords are relative to the window, not the screen. */
4793 TRACE("Setting new scissor rect to %s.\n", wine_dbgstr_rect(r
));
4795 if (context
->render_offscreen
)
4797 gl_info
->gl_ops
.gl
.p_glScissor(r
->left
, r
->top
, r
->right
- r
->left
, r
->bottom
- r
->top
);
4801 const struct wined3d_rendertarget_view
*target
= state
->fb
->render_targets
[0];
4805 surface_get_drawable_size(wined3d_rendertarget_view_get_surface(target
), context
, &width
, &height
);
4806 gl_info
->gl_ops
.gl
.p_glScissor(r
->left
, height
- r
->bottom
, r
->right
- r
->left
, r
->bottom
- r
->top
);
4808 checkGLcall("glScissor");
4811 static void indexbuffer(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4813 const struct wined3d_stream_info
*stream_info
= &context
->stream_info
;
4814 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4816 if (!state
->index_buffer
|| !stream_info
->all_vbo
)
4818 GL_EXTCALL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER
, 0));
4822 struct wined3d_buffer
*ib
= state
->index_buffer
;
4823 GL_EXTCALL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER
, ib
->buffer_object
));
4827 static void frontface(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4829 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4832 mode
= state
->rasterizer_state
&& state
->rasterizer_state
->desc
.front_ccw
? GL_CCW
: GL_CW
;
4833 if (context
->render_offscreen
)
4834 mode
= (mode
== GL_CW
) ? GL_CCW
: GL_CW
;
4836 gl_info
->gl_ops
.gl
.p_glFrontFace(mode
);
4837 checkGLcall("glFrontFace");
4840 static void psorigin_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4846 WARN("Point sprite coordinate origin switching not supported.\n");
4851 static void psorigin(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4853 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4854 GLint origin
= context
->render_offscreen
? GL_LOWER_LEFT
: GL_UPPER_LEFT
;
4856 GL_EXTCALL(glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN
, origin
));
4857 checkGLcall("glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, ...)");
4860 void state_srgbwrite(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4862 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4864 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
4866 if (needs_srgb_write(context
, state
, state
->fb
))
4867 gl_info
->gl_ops
.gl
.p_glEnable(GL_FRAMEBUFFER_SRGB
);
4869 gl_info
->gl_ops
.gl
.p_glDisable(GL_FRAMEBUFFER_SRGB
);
4872 static void state_cb(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4874 enum wined3d_shader_type shader_type
= state_id
- STATE_CONSTANT_BUFFER(0);
4875 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4876 struct wined3d_buffer
*buffer
;
4877 unsigned int i
, base
, count
;
4879 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
4881 wined3d_gl_limits_get_uniform_block_range(&gl_info
->limits
, shader_type
, &base
, &count
);
4882 for (i
= 0; i
< count
; ++i
)
4884 buffer
= state
->cb
[shader_type
][i
];
4885 GL_EXTCALL(glBindBufferBase(GL_UNIFORM_BUFFER
, base
+ i
, buffer
? buffer
->buffer_object
: 0));
4887 checkGLcall("glBindBufferBase");
4890 static void state_cb_warn(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4892 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
4894 WARN("Constant buffers (%s) no supported.\n", debug_d3dstate(state_id
));
4897 static void state_shader_resource_binding(struct wined3d_context
*context
,
4898 const struct wined3d_state
*state
, DWORD state_id
)
4900 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
4902 context
->update_shader_resource_bindings
= 1;
4905 const struct StateEntryTemplate misc_state_template
[] =
4907 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX
), state_cb
, }, ARB_UNIFORM_BUFFER_OBJECT
},
4908 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX
), state_cb_warn
, }, WINED3D_GL_EXT_NONE
},
4909 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY
),{ STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY
),state_cb
, }, ARB_UNIFORM_BUFFER_OBJECT
},
4910 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY
),{ STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY
),state_cb_warn
, }, WINED3D_GL_EXT_NONE
},
4911 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL
), state_cb
, }, ARB_UNIFORM_BUFFER_OBJECT
},
4912 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL
), state_cb_warn
, }, WINED3D_GL_EXT_NONE
},
4913 { STATE_SHADER_RESOURCE_BINDING
, { STATE_SHADER_RESOURCE_BINDING
, state_shader_resource_binding
}, WINED3D_GL_EXT_NONE
},
4914 { STATE_RENDER(WINED3D_RS_SRCBLEND
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4915 { STATE_RENDER(WINED3D_RS_DESTBLEND
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4916 { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), state_blend
}, WINED3D_GL_EXT_NONE
},
4917 { STATE_RENDER(WINED3D_RS_EDGEANTIALIAS
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4918 { STATE_RENDER(WINED3D_RS_ANTIALIASEDLINEENABLE
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4919 { STATE_RENDER(WINED3D_RS_SEPARATEALPHABLENDENABLE
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4920 { STATE_RENDER(WINED3D_RS_SRCBLENDALPHA
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4921 { STATE_RENDER(WINED3D_RS_DESTBLENDALPHA
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4922 { STATE_RENDER(WINED3D_RS_DESTBLENDALPHA
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4923 { STATE_RENDER(WINED3D_RS_BLENDOPALPHA
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4924 { STATE_STREAMSRC
, { STATE_STREAMSRC
, streamsrc
}, WINED3D_GL_EXT_NONE
},
4925 { STATE_VDECL
, { STATE_VDECL
, vdecl_miscpart
}, WINED3D_GL_EXT_NONE
},
4926 { STATE_FRONTFACE
, { STATE_FRONTFACE
, frontface
}, WINED3D_GL_EXT_NONE
},
4927 { STATE_SCISSORRECT
, { STATE_SCISSORRECT
, scissorrect
}, WINED3D_GL_EXT_NONE
},
4928 { STATE_POINTSPRITECOORDORIGIN
, { STATE_POINTSPRITECOORDORIGIN
, psorigin
}, WINED3D_GL_VERSION_2_0
},
4929 { STATE_POINTSPRITECOORDORIGIN
, { STATE_POINTSPRITECOORDORIGIN
, psorigin_w
}, WINED3D_GL_EXT_NONE
},
4931 /* TODO: Move shader constant loading to vertex and fragment pipeline respectively, as soon as the pshader and
4932 * vshader loadings are untied from each other
4934 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4935 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4936 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4937 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4938 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4939 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4940 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4941 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4942 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4943 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4944 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4945 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4946 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4947 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4948 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4949 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4950 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4951 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4952 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4953 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4954 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4955 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4956 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4957 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4958 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4959 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4960 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4961 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4962 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4963 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4964 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4965 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4966 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4967 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4968 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4969 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4970 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4971 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4972 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4973 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4974 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4975 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4976 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4977 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4978 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4979 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4980 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
4981 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4983 { STATE_VIEWPORT
, { STATE_VIEWPORT
, viewport_miscpart
}, WINED3D_GL_EXT_NONE
},
4984 { STATE_INDEXBUFFER
, { STATE_INDEXBUFFER
, indexbuffer
}, ARB_VERTEX_BUFFER_OBJECT
},
4985 { STATE_INDEXBUFFER
, { STATE_INDEXBUFFER
, state_nop
}, WINED3D_GL_EXT_NONE
},
4986 { STATE_RENDER(WINED3D_RS_ANTIALIAS
), { STATE_RENDER(WINED3D_RS_ANTIALIAS
), state_antialias
}, WINED3D_GL_EXT_NONE
},
4987 { STATE_RENDER(WINED3D_RS_TEXTUREPERSPECTIVE
), { STATE_RENDER(WINED3D_RS_TEXTUREPERSPECTIVE
), state_nop
}, WINED3D_GL_EXT_NONE
},
4988 { STATE_RENDER(WINED3D_RS_ZENABLE
), { STATE_RENDER(WINED3D_RS_ZENABLE
), state_zenable
}, WINED3D_GL_EXT_NONE
},
4989 { STATE_RENDER(WINED3D_RS_WRAPU
), { STATE_RENDER(WINED3D_RS_WRAPU
), state_wrapu
}, WINED3D_GL_EXT_NONE
},
4990 { STATE_RENDER(WINED3D_RS_WRAPV
), { STATE_RENDER(WINED3D_RS_WRAPV
), state_wrapv
}, WINED3D_GL_EXT_NONE
},
4991 { STATE_RENDER(WINED3D_RS_FILLMODE
), { STATE_RENDER(WINED3D_RS_FILLMODE
), state_fillmode
}, WINED3D_GL_EXT_NONE
},
4992 { STATE_RENDER(WINED3D_RS_LINEPATTERN
), { STATE_RENDER(WINED3D_RS_LINEPATTERN
), state_linepattern
}, WINED3D_GL_LEGACY_CONTEXT
},
4993 { STATE_RENDER(WINED3D_RS_LINEPATTERN
), { STATE_RENDER(WINED3D_RS_LINEPATTERN
), state_linepattern_w
}, WINED3D_GL_EXT_NONE
},
4994 { STATE_RENDER(WINED3D_RS_MONOENABLE
), { STATE_RENDER(WINED3D_RS_MONOENABLE
), state_monoenable
}, WINED3D_GL_EXT_NONE
},
4995 { STATE_RENDER(WINED3D_RS_ROP2
), { STATE_RENDER(WINED3D_RS_ROP2
), state_rop2
}, WINED3D_GL_EXT_NONE
},
4996 { STATE_RENDER(WINED3D_RS_PLANEMASK
), { STATE_RENDER(WINED3D_RS_PLANEMASK
), state_planemask
}, WINED3D_GL_EXT_NONE
},
4997 { STATE_RENDER(WINED3D_RS_ZWRITEENABLE
), { STATE_RENDER(WINED3D_RS_ZWRITEENABLE
), state_zwriteenable
}, WINED3D_GL_EXT_NONE
},
4998 { STATE_RENDER(WINED3D_RS_LASTPIXEL
), { STATE_RENDER(WINED3D_RS_LASTPIXEL
), state_lastpixel
}, WINED3D_GL_EXT_NONE
},
4999 { STATE_RENDER(WINED3D_RS_CULLMODE
), { STATE_RENDER(WINED3D_RS_CULLMODE
), state_cullmode
}, WINED3D_GL_EXT_NONE
},
5000 { STATE_RENDER(WINED3D_RS_ZFUNC
), { STATE_RENDER(WINED3D_RS_ZFUNC
), state_zfunc
}, WINED3D_GL_EXT_NONE
},
5001 { STATE_RENDER(WINED3D_RS_DITHERENABLE
), { STATE_RENDER(WINED3D_RS_DITHERENABLE
), state_ditherenable
}, WINED3D_GL_EXT_NONE
},
5002 { STATE_RENDER(WINED3D_RS_SUBPIXEL
), { STATE_RENDER(WINED3D_RS_SUBPIXEL
), state_subpixel
}, WINED3D_GL_EXT_NONE
},
5003 { STATE_RENDER(WINED3D_RS_SUBPIXELX
), { STATE_RENDER(WINED3D_RS_SUBPIXELX
), state_subpixelx
}, WINED3D_GL_EXT_NONE
},
5004 { STATE_RENDER(WINED3D_RS_STIPPLEDALPHA
), { STATE_RENDER(WINED3D_RS_STIPPLEDALPHA
), state_stippledalpha
}, WINED3D_GL_EXT_NONE
},
5005 { STATE_RENDER(WINED3D_RS_STIPPLEENABLE
), { STATE_RENDER(WINED3D_RS_STIPPLEENABLE
), state_stippleenable
}, WINED3D_GL_EXT_NONE
},
5006 { STATE_RENDER(WINED3D_RS_MIPMAPLODBIAS
), { STATE_RENDER(WINED3D_RS_MIPMAPLODBIAS
), state_mipmaplodbias
}, WINED3D_GL_EXT_NONE
},
5007 { STATE_RENDER(WINED3D_RS_ANISOTROPY
), { STATE_RENDER(WINED3D_RS_ANISOTROPY
), state_anisotropy
}, WINED3D_GL_EXT_NONE
},
5008 { STATE_RENDER(WINED3D_RS_FLUSHBATCH
), { STATE_RENDER(WINED3D_RS_FLUSHBATCH
), state_flushbatch
}, WINED3D_GL_EXT_NONE
},
5009 { STATE_RENDER(WINED3D_RS_TRANSLUCENTSORTINDEPENDENT
),{ STATE_RENDER(WINED3D_RS_TRANSLUCENTSORTINDEPENDENT
),state_translucentsi
}, WINED3D_GL_EXT_NONE
},
5010 { STATE_RENDER(WINED3D_RS_STENCILENABLE
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), state_stencil
}, WINED3D_GL_EXT_NONE
},
5011 { STATE_RENDER(WINED3D_RS_STENCILFAIL
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5012 { STATE_RENDER(WINED3D_RS_STENCILZFAIL
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5013 { STATE_RENDER(WINED3D_RS_STENCILPASS
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5014 { STATE_RENDER(WINED3D_RS_STENCILFUNC
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5015 { STATE_RENDER(WINED3D_RS_STENCILREF
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5016 { STATE_RENDER(WINED3D_RS_STENCILMASK
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5017 { STATE_RENDER(WINED3D_RS_STENCILWRITEMASK
), { STATE_RENDER(WINED3D_RS_STENCILWRITEMASK
), state_stencilwrite2s
}, EXT_STENCIL_TWO_SIDE
},
5018 { STATE_RENDER(WINED3D_RS_STENCILWRITEMASK
), { STATE_RENDER(WINED3D_RS_STENCILWRITEMASK
), state_stencilwrite
}, WINED3D_GL_EXT_NONE
},
5019 { STATE_RENDER(WINED3D_RS_TWOSIDEDSTENCILMODE
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5020 { STATE_RENDER(WINED3D_RS_CCW_STENCILFAIL
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5021 { STATE_RENDER(WINED3D_RS_CCW_STENCILZFAIL
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5022 { STATE_RENDER(WINED3D_RS_CCW_STENCILPASS
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5023 { STATE_RENDER(WINED3D_RS_CCW_STENCILFUNC
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5024 { STATE_RENDER(WINED3D_RS_WRAP0
), { STATE_RENDER(WINED3D_RS_WRAP0
), state_wrap
}, WINED3D_GL_EXT_NONE
},
5025 { STATE_RENDER(WINED3D_RS_WRAP1
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5026 { STATE_RENDER(WINED3D_RS_WRAP2
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5027 { STATE_RENDER(WINED3D_RS_WRAP3
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5028 { STATE_RENDER(WINED3D_RS_WRAP4
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5029 { STATE_RENDER(WINED3D_RS_WRAP5
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5030 { STATE_RENDER(WINED3D_RS_WRAP6
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5031 { STATE_RENDER(WINED3D_RS_WRAP7
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5032 { STATE_RENDER(WINED3D_RS_WRAP8
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5033 { STATE_RENDER(WINED3D_RS_WRAP9
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5034 { STATE_RENDER(WINED3D_RS_WRAP10
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5035 { STATE_RENDER(WINED3D_RS_WRAP11
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5036 { STATE_RENDER(WINED3D_RS_WRAP12
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5037 { STATE_RENDER(WINED3D_RS_WRAP13
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5038 { STATE_RENDER(WINED3D_RS_WRAP14
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5039 { STATE_RENDER(WINED3D_RS_WRAP15
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5040 { STATE_RENDER(WINED3D_RS_EXTENTS
), { STATE_RENDER(WINED3D_RS_EXTENTS
), state_extents
}, WINED3D_GL_EXT_NONE
},
5041 { STATE_RENDER(WINED3D_RS_COLORKEYBLENDENABLE
), { STATE_RENDER(WINED3D_RS_COLORKEYBLENDENABLE
), state_ckeyblend
}, WINED3D_GL_EXT_NONE
},
5042 { STATE_RENDER(WINED3D_RS_SOFTWAREVERTEXPROCESSING
), { STATE_RENDER(WINED3D_RS_SOFTWAREVERTEXPROCESSING
), state_swvp
}, WINED3D_GL_EXT_NONE
},
5043 { STATE_RENDER(WINED3D_RS_PATCHEDGESTYLE
), { STATE_RENDER(WINED3D_RS_PATCHEDGESTYLE
), state_patchedgestyle
}, WINED3D_GL_EXT_NONE
},
5044 { STATE_RENDER(WINED3D_RS_PATCHSEGMENTS
), { STATE_RENDER(WINED3D_RS_PATCHSEGMENTS
), state_patchsegments
}, WINED3D_GL_EXT_NONE
},
5045 { STATE_RENDER(WINED3D_RS_POSITIONDEGREE
), { STATE_RENDER(WINED3D_RS_POSITIONDEGREE
), state_positiondegree
}, WINED3D_GL_EXT_NONE
},
5046 { STATE_RENDER(WINED3D_RS_NORMALDEGREE
), { STATE_RENDER(WINED3D_RS_NORMALDEGREE
), state_normaldegree
}, WINED3D_GL_EXT_NONE
},
5047 { STATE_RENDER(WINED3D_RS_MINTESSELLATIONLEVEL
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
5048 { STATE_RENDER(WINED3D_RS_MAXTESSELLATIONLEVEL
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
5049 { STATE_RENDER(WINED3D_RS_ADAPTIVETESS_X
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
5050 { STATE_RENDER(WINED3D_RS_ADAPTIVETESS_Y
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
5051 { STATE_RENDER(WINED3D_RS_ADAPTIVETESS_Z
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
5052 { STATE_RENDER(WINED3D_RS_ADAPTIVETESS_W
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
5053 { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),{ STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),state_nvdb
}, EXT_DEPTH_BOUNDS_TEST
},
5054 { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),{ STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),state_tessellation
}, WINED3D_GL_EXT_NONE
},
5055 { STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS
), { STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS
), state_msaa
}, ARB_MULTISAMPLE
},
5056 { STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS
), { STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS
), state_msaa_w
}, WINED3D_GL_EXT_NONE
},
5057 { STATE_RENDER(WINED3D_RS_MULTISAMPLEMASK
), { STATE_RENDER(WINED3D_RS_MULTISAMPLEMASK
), state_multisampmask
}, WINED3D_GL_EXT_NONE
},
5058 { STATE_RENDER(WINED3D_RS_DEBUGMONITORTOKEN
), { STATE_RENDER(WINED3D_RS_DEBUGMONITORTOKEN
), state_debug_monitor
}, WINED3D_GL_EXT_NONE
},
5059 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE
), state_colorwrite0
}, EXT_DRAW_BUFFERS2
},
5060 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE
), state_colorwrite
}, WINED3D_GL_EXT_NONE
},
5061 { STATE_RENDER(WINED3D_RS_BLENDOP
), { STATE_RENDER(WINED3D_RS_BLENDOP
), state_blendop
}, WINED3D_GL_BLEND_EQUATION
},
5062 { STATE_RENDER(WINED3D_RS_BLENDOP
), { STATE_RENDER(WINED3D_RS_BLENDOP
), state_blendop_w
}, WINED3D_GL_EXT_NONE
},
5063 { STATE_RENDER(WINED3D_RS_SCISSORTESTENABLE
), { STATE_RENDER(WINED3D_RS_SCISSORTESTENABLE
), state_scissor
}, WINED3D_GL_EXT_NONE
},
5064 { STATE_RENDER(WINED3D_RS_SLOPESCALEDEPTHBIAS
), { STATE_RENDER(WINED3D_RS_DEPTHBIAS
), NULL
}, WINED3D_GL_EXT_NONE
},
5065 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1
), state_colorwrite1
}, EXT_DRAW_BUFFERS2
},
5066 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5067 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2
), state_colorwrite2
}, EXT_DRAW_BUFFERS2
},
5068 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5069 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3
), state_colorwrite3
}, EXT_DRAW_BUFFERS2
},
5070 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5071 { STATE_RENDER(WINED3D_RS_BLENDFACTOR
), { STATE_RENDER(WINED3D_RS_BLENDFACTOR
), state_blendfactor
}, EXT_BLEND_COLOR
},
5072 { STATE_RENDER(WINED3D_RS_BLENDFACTOR
), { STATE_RENDER(WINED3D_RS_BLENDFACTOR
), state_blendfactor_w
}, WINED3D_GL_EXT_NONE
},
5073 { STATE_RENDER(WINED3D_RS_DEPTHBIAS
), { STATE_RENDER(WINED3D_RS_DEPTHBIAS
), state_depthbias
}, WINED3D_GL_EXT_NONE
},
5074 { STATE_RENDER(WINED3D_RS_ZVISIBLE
), { STATE_RENDER(WINED3D_RS_ZVISIBLE
), state_zvisible
}, WINED3D_GL_EXT_NONE
},
5076 { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler
}, WINED3D_GL_EXT_NONE
},
5077 { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler
}, WINED3D_GL_EXT_NONE
},
5078 { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler
}, WINED3D_GL_EXT_NONE
},
5079 { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler
}, WINED3D_GL_EXT_NONE
},
5080 { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler
}, WINED3D_GL_EXT_NONE
},
5081 { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler
}, WINED3D_GL_EXT_NONE
},
5082 { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler
}, WINED3D_GL_EXT_NONE
},
5083 { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler
}, WINED3D_GL_EXT_NONE
},
5084 { STATE_SAMPLER(8), { STATE_SAMPLER(8), sampler
}, WINED3D_GL_EXT_NONE
},
5085 { STATE_SAMPLER(9), { STATE_SAMPLER(9), sampler
}, WINED3D_GL_EXT_NONE
},
5086 { STATE_SAMPLER(10), { STATE_SAMPLER(10), sampler
}, WINED3D_GL_EXT_NONE
},
5087 { STATE_SAMPLER(11), { STATE_SAMPLER(11), sampler
}, WINED3D_GL_EXT_NONE
},
5088 { STATE_SAMPLER(12), { STATE_SAMPLER(12), sampler
}, WINED3D_GL_EXT_NONE
},
5089 { STATE_SAMPLER(13), { STATE_SAMPLER(13), sampler
}, WINED3D_GL_EXT_NONE
},
5090 { STATE_SAMPLER(14), { STATE_SAMPLER(14), sampler
}, WINED3D_GL_EXT_NONE
},
5091 { STATE_SAMPLER(15), { STATE_SAMPLER(15), sampler
}, WINED3D_GL_EXT_NONE
},
5092 { STATE_SAMPLER(16), /* Vertex sampler 0 */ { STATE_SAMPLER(16), sampler
}, WINED3D_GL_EXT_NONE
},
5093 { STATE_SAMPLER(17), /* Vertex sampler 1 */ { STATE_SAMPLER(17), sampler
}, WINED3D_GL_EXT_NONE
},
5094 { STATE_SAMPLER(18), /* Vertex sampler 2 */ { STATE_SAMPLER(18), sampler
}, WINED3D_GL_EXT_NONE
},
5095 { STATE_SAMPLER(19), /* Vertex sampler 3 */ { STATE_SAMPLER(19), sampler
}, WINED3D_GL_EXT_NONE
},
5096 { STATE_BASEVERTEXINDEX
, { STATE_BASEVERTEXINDEX
, state_nop
, }, ARB_DRAW_ELEMENTS_BASE_VERTEX
},
5097 { STATE_BASEVERTEXINDEX
, { STATE_STREAMSRC
, NULL
, }, WINED3D_GL_EXT_NONE
},
5098 { STATE_FRAMEBUFFER
, { STATE_FRAMEBUFFER
, context_state_fb
}, WINED3D_GL_EXT_NONE
},
5099 { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
), context_state_drawbuf
},WINED3D_GL_EXT_NONE
},
5100 { STATE_SHADER(WINED3D_SHADER_TYPE_GEOMETRY
), { STATE_SHADER(WINED3D_SHADER_TYPE_GEOMETRY
), state_geometry_shader
}, WINED3D_GL_EXT_NONE
},
5101 {0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE
},
5104 static const struct StateEntryTemplate vp_ffp_states
[] =
5106 { STATE_VDECL
, { STATE_VDECL
, vertexdeclaration
}, WINED3D_GL_EXT_NONE
},
5107 { STATE_SHADER(WINED3D_SHADER_TYPE_VERTEX
), { STATE_VDECL
, NULL
}, WINED3D_GL_EXT_NONE
},
5108 { STATE_MATERIAL
, { STATE_RENDER(WINED3D_RS_SPECULARENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5109 { STATE_RENDER(WINED3D_RS_SPECULARENABLE
), { STATE_RENDER(WINED3D_RS_SPECULARENABLE
), state_specularenable
}, WINED3D_GL_EXT_NONE
},
5111 { STATE_CLIPPLANE(0), { STATE_CLIPPLANE(0), clipplane
}, WINED3D_GL_EXT_NONE
},
5112 { STATE_CLIPPLANE(1), { STATE_CLIPPLANE(1), clipplane
}, WINED3D_GL_EXT_NONE
},
5113 { STATE_CLIPPLANE(2), { STATE_CLIPPLANE(2), clipplane
}, WINED3D_GL_EXT_NONE
},
5114 { STATE_CLIPPLANE(3), { STATE_CLIPPLANE(3), clipplane
}, WINED3D_GL_EXT_NONE
},
5115 { STATE_CLIPPLANE(4), { STATE_CLIPPLANE(4), clipplane
}, WINED3D_GL_EXT_NONE
},
5116 { STATE_CLIPPLANE(5), { STATE_CLIPPLANE(5), clipplane
}, WINED3D_GL_EXT_NONE
},
5117 { STATE_CLIPPLANE(6), { STATE_CLIPPLANE(6), clipplane
}, WINED3D_GL_EXT_NONE
},
5118 { STATE_CLIPPLANE(7), { STATE_CLIPPLANE(7), clipplane
}, WINED3D_GL_EXT_NONE
},
5119 { STATE_CLIPPLANE(8), { STATE_CLIPPLANE(8), clipplane
}, WINED3D_GL_EXT_NONE
},
5120 { STATE_CLIPPLANE(9), { STATE_CLIPPLANE(9), clipplane
}, WINED3D_GL_EXT_NONE
},
5121 { STATE_CLIPPLANE(10), { STATE_CLIPPLANE(10), clipplane
}, WINED3D_GL_EXT_NONE
},
5122 { STATE_CLIPPLANE(11), { STATE_CLIPPLANE(11), clipplane
}, WINED3D_GL_EXT_NONE
},
5123 { STATE_CLIPPLANE(12), { STATE_CLIPPLANE(12), clipplane
}, WINED3D_GL_EXT_NONE
},
5124 { STATE_CLIPPLANE(13), { STATE_CLIPPLANE(13), clipplane
}, WINED3D_GL_EXT_NONE
},
5125 { STATE_CLIPPLANE(14), { STATE_CLIPPLANE(14), clipplane
}, WINED3D_GL_EXT_NONE
},
5126 { STATE_CLIPPLANE(15), { STATE_CLIPPLANE(15), clipplane
}, WINED3D_GL_EXT_NONE
},
5127 { STATE_CLIPPLANE(16), { STATE_CLIPPLANE(16), clipplane
}, WINED3D_GL_EXT_NONE
},
5128 { STATE_CLIPPLANE(17), { STATE_CLIPPLANE(17), clipplane
}, WINED3D_GL_EXT_NONE
},
5129 { STATE_CLIPPLANE(18), { STATE_CLIPPLANE(18), clipplane
}, WINED3D_GL_EXT_NONE
},
5130 { STATE_CLIPPLANE(19), { STATE_CLIPPLANE(19), clipplane
}, WINED3D_GL_EXT_NONE
},
5131 { STATE_CLIPPLANE(20), { STATE_CLIPPLANE(20), clipplane
}, WINED3D_GL_EXT_NONE
},
5132 { STATE_CLIPPLANE(21), { STATE_CLIPPLANE(21), clipplane
}, WINED3D_GL_EXT_NONE
},
5133 { STATE_CLIPPLANE(22), { STATE_CLIPPLANE(22), clipplane
}, WINED3D_GL_EXT_NONE
},
5134 { STATE_CLIPPLANE(23), { STATE_CLIPPLANE(23), clipplane
}, WINED3D_GL_EXT_NONE
},
5135 { STATE_CLIPPLANE(24), { STATE_CLIPPLANE(24), clipplane
}, WINED3D_GL_EXT_NONE
},
5136 { STATE_CLIPPLANE(25), { STATE_CLIPPLANE(25), clipplane
}, WINED3D_GL_EXT_NONE
},
5137 { STATE_CLIPPLANE(26), { STATE_CLIPPLANE(26), clipplane
}, WINED3D_GL_EXT_NONE
},
5138 { STATE_CLIPPLANE(27), { STATE_CLIPPLANE(27), clipplane
}, WINED3D_GL_EXT_NONE
},
5139 { STATE_CLIPPLANE(28), { STATE_CLIPPLANE(28), clipplane
}, WINED3D_GL_EXT_NONE
},
5140 { STATE_CLIPPLANE(29), { STATE_CLIPPLANE(29), clipplane
}, WINED3D_GL_EXT_NONE
},
5141 { STATE_CLIPPLANE(30), { STATE_CLIPPLANE(30), clipplane
}, WINED3D_GL_EXT_NONE
},
5142 { STATE_CLIPPLANE(31), { STATE_CLIPPLANE(31), clipplane
}, WINED3D_GL_EXT_NONE
},
5144 { STATE_LIGHT_TYPE
, { STATE_LIGHT_TYPE
, state_nop
}, WINED3D_GL_EXT_NONE
},
5145 { STATE_ACTIVELIGHT(0), { STATE_ACTIVELIGHT(0), light
}, WINED3D_GL_EXT_NONE
},
5146 { STATE_ACTIVELIGHT(1), { STATE_ACTIVELIGHT(1), light
}, WINED3D_GL_EXT_NONE
},
5147 { STATE_ACTIVELIGHT(2), { STATE_ACTIVELIGHT(2), light
}, WINED3D_GL_EXT_NONE
},
5148 { STATE_ACTIVELIGHT(3), { STATE_ACTIVELIGHT(3), light
}, WINED3D_GL_EXT_NONE
},
5149 { STATE_ACTIVELIGHT(4), { STATE_ACTIVELIGHT(4), light
}, WINED3D_GL_EXT_NONE
},
5150 { STATE_ACTIVELIGHT(5), { STATE_ACTIVELIGHT(5), light
}, WINED3D_GL_EXT_NONE
},
5151 { STATE_ACTIVELIGHT(6), { STATE_ACTIVELIGHT(6), light
}, WINED3D_GL_EXT_NONE
},
5152 { STATE_ACTIVELIGHT(7), { STATE_ACTIVELIGHT(7), light
}, WINED3D_GL_EXT_NONE
},
5154 { STATE_VIEWPORT
, { STATE_VIEWPORT
, viewport_vertexpart
}, WINED3D_GL_EXT_NONE
},
5155 /* Transform states follow */
5156 { STATE_TRANSFORM(WINED3D_TS_VIEW
), { STATE_TRANSFORM(WINED3D_TS_VIEW
), transform_view
}, WINED3D_GL_EXT_NONE
},
5157 { STATE_TRANSFORM(WINED3D_TS_PROJECTION
), { STATE_TRANSFORM(WINED3D_TS_PROJECTION
), transform_projection
}, WINED3D_GL_EXT_NONE
},
5158 { STATE_TRANSFORM(WINED3D_TS_TEXTURE0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5159 { STATE_TRANSFORM(WINED3D_TS_TEXTURE1
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5160 { STATE_TRANSFORM(WINED3D_TS_TEXTURE2
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5161 { STATE_TRANSFORM(WINED3D_TS_TEXTURE3
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5162 { STATE_TRANSFORM(WINED3D_TS_TEXTURE4
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5163 { STATE_TRANSFORM(WINED3D_TS_TEXTURE5
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5164 { STATE_TRANSFORM(WINED3D_TS_TEXTURE6
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5165 { STATE_TRANSFORM(WINED3D_TS_TEXTURE7
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5166 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 0)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 0)), transform_world
}, WINED3D_GL_EXT_NONE
},
5167 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 1)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 1)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5168 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 2)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 2)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5169 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 3)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 3)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5170 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 4)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 4)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5171 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 5)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 5)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5172 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 6)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 6)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5173 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 7)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 7)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5174 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 8)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 8)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5175 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 9)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 9)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5176 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 10)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 10)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5177 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 11)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 11)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5178 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 12)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 12)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5179 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 13)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 13)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5180 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 14)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 14)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5181 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 15)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 15)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5182 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 16)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 16)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5183 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 17)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 17)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5184 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 18)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 18)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5185 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 19)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 19)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5186 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 20)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 20)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5187 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 21)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 21)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5188 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 22)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 22)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5189 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 23)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 23)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5190 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 24)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 24)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5191 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 25)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 25)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5192 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 26)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 26)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5193 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 27)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 27)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5194 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 28)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 28)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5195 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 29)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 29)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5196 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 30)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 30)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5197 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 31)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 31)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5198 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 32)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 32)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5199 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 33)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 33)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5200 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 34)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 34)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5201 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 35)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 35)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5202 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 36)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 36)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5203 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 37)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 37)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5204 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 38)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 38)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5205 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 39)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 39)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5206 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 40)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 40)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5207 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 41)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 41)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5208 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 42)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 42)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5209 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 43)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 43)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5210 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 44)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 44)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5211 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 45)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 45)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5212 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 46)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 46)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5213 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 47)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 47)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5214 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 48)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 48)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5215 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 49)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 49)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5216 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 50)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 50)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5217 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 51)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 51)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5218 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 52)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 52)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5219 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 53)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 53)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5220 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 54)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 54)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5221 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 55)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 55)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5222 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 56)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 56)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5223 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 57)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 57)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5224 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 58)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 58)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5225 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 59)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 59)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5226 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 60)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 60)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5227 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 61)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 61)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5228 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 62)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 62)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5229 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 63)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 63)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5230 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 64)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 64)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5231 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 65)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 65)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5232 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 66)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 66)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5233 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 67)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 67)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5234 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 68)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 68)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5235 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 69)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 69)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5236 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 70)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 70)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5237 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 71)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 71)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5238 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 72)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 72)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5239 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 73)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 73)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5240 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 74)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 74)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5241 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 75)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 75)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5242 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 76)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 76)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5243 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 77)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 77)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5244 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 78)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 78)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5245 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 79)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 79)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5246 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 80)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 80)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5247 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 81)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 81)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5248 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 82)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 82)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5249 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 83)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 83)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5250 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 84)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 84)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5251 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 85)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 85)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5252 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 86)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 86)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5253 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 87)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 87)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5254 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 88)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 88)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5255 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 89)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 89)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5256 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 90)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 90)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5257 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 91)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 91)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5258 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 92)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 92)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5259 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 93)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 93)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5260 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 94)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 94)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5261 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 95)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 95)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5262 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 96)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 96)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5263 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 97)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 97)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5264 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 98)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 98)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5265 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 99)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 99)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5266 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(100)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(100)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5267 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(101)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(101)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5268 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(102)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(102)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5269 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(103)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(103)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5270 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(104)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(104)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5271 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(105)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(105)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5272 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(106)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(106)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5273 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(107)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(107)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5274 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(108)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(108)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5275 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(109)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(109)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5276 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(110)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(110)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5277 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(111)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(111)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5278 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(112)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(112)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5279 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(113)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(113)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5280 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(114)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(114)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5281 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(115)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(115)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5282 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(116)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(116)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5283 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(117)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(117)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5284 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(118)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(118)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5285 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(119)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(119)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5286 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(120)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(120)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5287 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(121)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(121)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5288 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(122)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(122)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5289 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(123)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(123)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5290 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(124)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(124)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5291 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(125)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(125)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5292 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(126)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(126)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5293 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(127)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(127)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5294 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(128)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(128)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5295 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(129)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(129)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5296 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(130)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(130)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5297 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(131)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(131)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5298 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(132)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(132)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5299 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(133)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(133)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5300 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(134)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(134)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5301 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(135)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(135)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5302 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(136)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(136)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5303 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(137)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(137)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5304 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(138)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(138)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5305 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(139)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(139)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5306 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(140)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(140)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5307 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(141)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(141)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5308 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(142)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(142)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5309 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(143)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(143)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5310 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(144)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(144)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5311 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(145)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(145)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5312 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(146)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(146)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5313 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(147)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(147)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5314 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(148)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(148)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5315 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(149)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(149)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5316 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(150)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(150)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5317 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(151)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(151)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5318 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(152)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(152)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5319 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(153)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(153)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5320 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(154)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(154)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5321 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(155)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(155)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5322 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(156)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(156)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5323 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(157)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(157)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5324 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(158)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(158)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5325 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(159)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(159)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5326 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(160)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(160)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5327 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(161)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(161)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5328 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(162)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(162)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5329 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(163)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(163)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5330 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(164)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(164)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5331 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(165)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(165)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5332 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(166)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(166)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5333 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(167)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(167)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5334 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(168)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(168)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5335 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(169)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(169)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5336 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(170)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(170)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5337 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(171)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(171)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5338 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(172)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(172)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5339 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(173)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(173)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5340 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(174)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(174)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5341 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(175)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(175)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5342 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(176)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(176)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5343 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(177)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(177)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5344 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(178)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(178)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5345 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(179)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(179)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5346 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(180)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(180)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5347 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(181)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(181)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5348 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(182)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(182)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5349 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(183)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(183)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5350 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(184)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(184)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5351 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(185)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(185)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5352 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(186)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(186)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5353 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(187)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(187)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5354 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(188)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(188)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5355 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(189)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(189)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5356 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(190)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(190)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5357 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(191)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(191)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5358 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(192)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(192)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5359 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(193)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(193)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5360 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(194)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(194)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5361 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(195)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(195)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5362 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(196)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(196)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5363 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(197)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(197)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5364 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(198)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(198)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5365 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(199)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(199)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5366 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(200)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(200)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5367 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(201)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(201)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5368 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(202)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(202)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5369 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(203)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(203)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5370 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(204)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(204)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5371 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(205)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(205)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5372 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(206)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(206)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5373 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(207)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(207)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5374 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(208)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(208)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5375 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(209)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(209)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5376 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(210)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(210)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5377 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(211)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(211)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5378 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(212)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(212)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5379 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(213)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(213)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5380 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(214)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(214)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5381 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(215)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(215)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5382 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(216)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(216)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5383 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(217)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(217)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5384 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(218)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(218)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5385 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(219)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(219)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5386 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(220)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(220)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5387 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(221)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(221)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5388 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(222)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(222)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5389 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(223)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(223)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5390 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(224)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(224)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5391 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(225)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(225)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5392 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(226)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(226)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5393 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(227)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(227)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5394 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(228)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(228)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5395 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(229)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(229)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5396 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(230)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(230)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5397 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(231)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(231)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5398 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(232)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(232)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5399 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(233)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(233)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5400 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(234)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(234)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5401 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(235)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(235)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5402 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(236)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(236)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5403 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(237)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(237)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5404 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(238)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(238)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5405 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(239)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(239)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5406 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(240)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(240)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5407 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(241)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(241)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5408 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(242)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(242)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5409 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(243)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(243)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5410 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(244)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(244)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5411 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(245)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(245)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5412 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(246)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(246)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5413 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(247)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(247)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5414 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(248)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(248)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5415 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(249)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(249)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5416 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(250)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(250)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5417 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(251)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(251)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5418 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(252)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(252)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5419 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(253)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(253)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5420 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(254)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(254)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5421 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5422 { STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5423 { STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5424 { STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5425 { STATE_TEXTURESTAGE(3, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(3, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5426 { STATE_TEXTURESTAGE(4, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(4, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5427 { STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5428 { STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5429 { STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5430 { STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5431 { STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5432 { STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5433 { STATE_TEXTURESTAGE(3, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5434 { STATE_TEXTURESTAGE(4, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5435 { STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5436 { STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5437 { STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5439 { STATE_RENDER(WINED3D_RS_FOGENABLE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), state_fog_vertexpart
}, WINED3D_GL_EXT_NONE
},
5440 { STATE_RENDER(WINED3D_RS_FOGTABLEMODE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5441 { STATE_RENDER(WINED3D_RS_FOGVERTEXMODE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5442 { STATE_RENDER(WINED3D_RS_RANGEFOGENABLE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5443 { STATE_RENDER(WINED3D_RS_CLIPPING
), { STATE_RENDER(WINED3D_RS_CLIPPING
), state_clipping
}, WINED3D_GL_EXT_NONE
},
5444 { STATE_RENDER(WINED3D_RS_CLIPPLANEENABLE
), { STATE_RENDER(WINED3D_RS_CLIPPING
), NULL
}, WINED3D_GL_EXT_NONE
},
5445 { STATE_RENDER(WINED3D_RS_LIGHTING
), { STATE_RENDER(WINED3D_RS_LIGHTING
), state_lighting
}, WINED3D_GL_EXT_NONE
},
5446 { STATE_RENDER(WINED3D_RS_AMBIENT
), { STATE_RENDER(WINED3D_RS_AMBIENT
), state_ambient
}, WINED3D_GL_EXT_NONE
},
5447 { STATE_RENDER(WINED3D_RS_COLORVERTEX
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), state_colormat
}, WINED3D_GL_EXT_NONE
},
5448 { STATE_RENDER(WINED3D_RS_LOCALVIEWER
), { STATE_RENDER(WINED3D_RS_LOCALVIEWER
), state_localviewer
}, WINED3D_GL_EXT_NONE
},
5449 { STATE_RENDER(WINED3D_RS_NORMALIZENORMALS
), { STATE_RENDER(WINED3D_RS_NORMALIZENORMALS
), state_normalize
}, WINED3D_GL_EXT_NONE
},
5450 { STATE_RENDER(WINED3D_RS_DIFFUSEMATERIALSOURCE
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), NULL
}, WINED3D_GL_EXT_NONE
},
5451 { STATE_RENDER(WINED3D_RS_SPECULARMATERIALSOURCE
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), NULL
}, WINED3D_GL_EXT_NONE
},
5452 { STATE_RENDER(WINED3D_RS_AMBIENTMATERIALSOURCE
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), NULL
}, WINED3D_GL_EXT_NONE
},
5453 { STATE_RENDER(WINED3D_RS_EMISSIVEMATERIALSOURCE
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), NULL
}, WINED3D_GL_EXT_NONE
},
5454 { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), state_vertexblend
}, ARB_VERTEX_BLEND
},
5455 { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), state_vertexblend_w
}, WINED3D_GL_EXT_NONE
},
5456 { STATE_RENDER(WINED3D_RS_POINTSIZE
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5457 { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), state_psizemin_arb
}, ARB_POINT_PARAMETERS
},
5458 { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), state_psizemin_ext
}, EXT_POINT_PARAMETERS
},
5459 { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), state_psizemin_w
}, WINED3D_GL_EXT_NONE
},
5460 { STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE
), { STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE
), state_pointsprite
}, ARB_POINT_SPRITE
},
5461 { STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE
), { STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE
), state_pointsprite_w
}, WINED3D_GL_EXT_NONE
},
5462 { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), state_pscale
}, WINED3D_GL_EXT_NONE
},
5463 { STATE_RENDER(WINED3D_RS_POINTSCALE_A
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5464 { STATE_RENDER(WINED3D_RS_POINTSCALE_B
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5465 { STATE_RENDER(WINED3D_RS_POINTSCALE_C
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5466 { STATE_RENDER(WINED3D_RS_POINTSIZE_MAX
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), NULL
}, ARB_POINT_PARAMETERS
},
5467 { STATE_RENDER(WINED3D_RS_POINTSIZE_MAX
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), NULL
}, EXT_POINT_PARAMETERS
},
5468 { STATE_RENDER(WINED3D_RS_POINTSIZE_MAX
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), NULL
}, WINED3D_GL_EXT_NONE
},
5469 { STATE_RENDER(WINED3D_RS_TWEENFACTOR
), { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), NULL
}, WINED3D_GL_EXT_NONE
},
5470 { STATE_RENDER(WINED3D_RS_INDEXEDVERTEXBLENDENABLE
), { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), NULL
}, WINED3D_GL_EXT_NONE
},
5472 /* Samplers for NP2 texture matrix adjustions. They are not needed if GL_ARB_texture_non_power_of_two is supported,
5473 * so register a NULL state handler in that case to get the vertex part of sampler() skipped(VTF is handled in the misc states.
5474 * otherwise, register sampler_texmatrix, which takes care of updating the texture matrix
5476 { STATE_SAMPLER(0), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5477 { STATE_SAMPLER(0), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5478 { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5479 { STATE_SAMPLER(1), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5480 { STATE_SAMPLER(1), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5481 { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5482 { STATE_SAMPLER(2), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5483 { STATE_SAMPLER(2), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5484 { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5485 { STATE_SAMPLER(3), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5486 { STATE_SAMPLER(3), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5487 { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5488 { STATE_SAMPLER(4), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5489 { STATE_SAMPLER(4), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5490 { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5491 { STATE_SAMPLER(5), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5492 { STATE_SAMPLER(5), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5493 { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5494 { STATE_SAMPLER(6), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5495 { STATE_SAMPLER(6), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5496 { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5497 { STATE_SAMPLER(7), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5498 { STATE_SAMPLER(7), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5499 { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5500 { STATE_POINT_ENABLE
, { STATE_POINT_ENABLE
, state_nop
}, WINED3D_GL_EXT_NONE
},
5501 {0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE
},
5504 static const struct StateEntryTemplate ffp_fragmentstate_template
[] = {
5505 { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5506 { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5507 { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5508 { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5509 { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5510 { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5511 { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5512 { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5513 { STATE_TEXTURESTAGE(0, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5514 { STATE_TEXTURESTAGE(0, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5515 { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5516 { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5517 { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5518 { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5519 { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5520 { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5521 { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5522 { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5523 { STATE_TEXTURESTAGE(1, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5524 { STATE_TEXTURESTAGE(1, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5525 { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5526 { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5527 { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5528 { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5529 { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5530 { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5531 { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5532 { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5533 { STATE_TEXTURESTAGE(2, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5534 { STATE_TEXTURESTAGE(2, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5535 { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5536 { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5537 { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5538 { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5539 { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5540 { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5541 { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5542 { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5543 { STATE_TEXTURESTAGE(3, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5544 { STATE_TEXTURESTAGE(3, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5545 { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5546 { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5547 { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5548 { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5549 { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5550 { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5551 { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5552 { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5553 { STATE_TEXTURESTAGE(4, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5554 { STATE_TEXTURESTAGE(4, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5555 { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5556 { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5557 { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5558 { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5559 { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5560 { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5561 { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5562 { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5563 { STATE_TEXTURESTAGE(5, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5564 { STATE_TEXTURESTAGE(5, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5565 { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5566 { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5567 { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5568 { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5569 { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5570 { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5571 { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5572 { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5573 { STATE_TEXTURESTAGE(6, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5574 { STATE_TEXTURESTAGE(6, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5575 { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5576 { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5577 { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5578 { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5579 { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5580 { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5581 { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5582 { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5583 { STATE_TEXTURESTAGE(7, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5584 { STATE_TEXTURESTAGE(7, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5585 { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
), apply_pixelshader
}, WINED3D_GL_EXT_NONE
},
5586 { STATE_RENDER(WINED3D_RS_ALPHAFUNC
), { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5587 { STATE_RENDER(WINED3D_RS_ALPHAREF
), { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5588 { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), state_alpha_test
}, WINED3D_GL_EXT_NONE
},
5589 { STATE_RENDER(WINED3D_RS_COLORKEYENABLE
), { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5590 { STATE_COLOR_KEY
, { STATE_COLOR_KEY
, state_nop
}, WINED3D_GL_EXT_NONE
},
5591 { STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE
), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
), NULL
}, WINED3D_GL_EXT_NONE
},
5592 { STATE_RENDER(WINED3D_RS_TEXTUREFACTOR
), { STATE_RENDER(WINED3D_RS_TEXTUREFACTOR
), state_texfactor
}, WINED3D_GL_EXT_NONE
},
5593 { STATE_RENDER(WINED3D_RS_FOGCOLOR
), { STATE_RENDER(WINED3D_RS_FOGCOLOR
), state_fogcolor
}, WINED3D_GL_EXT_NONE
},
5594 { STATE_RENDER(WINED3D_RS_FOGDENSITY
), { STATE_RENDER(WINED3D_RS_FOGDENSITY
), state_fogdensity
}, WINED3D_GL_EXT_NONE
},
5595 { STATE_RENDER(WINED3D_RS_FOGENABLE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), state_fog_fragpart
}, WINED3D_GL_EXT_NONE
},
5596 { STATE_RENDER(WINED3D_RS_FOGTABLEMODE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5597 { STATE_RENDER(WINED3D_RS_FOGVERTEXMODE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5598 { STATE_RENDER(WINED3D_RS_FOGSTART
), { STATE_RENDER(WINED3D_RS_FOGSTART
), state_fogstartend
}, WINED3D_GL_EXT_NONE
},
5599 { STATE_RENDER(WINED3D_RS_FOGEND
), { STATE_RENDER(WINED3D_RS_FOGSTART
), NULL
}, WINED3D_GL_EXT_NONE
},
5600 { STATE_RENDER(WINED3D_RS_SHADEMODE
), { STATE_RENDER(WINED3D_RS_SHADEMODE
), state_shademode
}, WINED3D_GL_EXT_NONE
},
5601 { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5602 { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5603 { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5604 { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5605 { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5606 { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5607 { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5608 { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5609 {0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE
},
5612 /* Context activation is done by the caller. */
5613 static void ffp_enable(const struct wined3d_gl_info
*gl_info
, BOOL enable
) {}
5615 static void *ffp_alloc(const struct wined3d_shader_backend_ops
*shader_backend
, void *shader_priv
)
5620 static void ffp_free(struct wined3d_device
*device
) {}
5622 static void vp_ffp_get_caps(const struct wined3d_gl_info
*gl_info
, struct wined3d_vertex_caps
*caps
)
5624 caps
->xyzrhw
= FALSE
;
5625 caps
->ffp_generic_attributes
= FALSE
;
5626 caps
->max_active_lights
= gl_info
->limits
.lights
;
5627 caps
->max_vertex_blend_matrices
= gl_info
->limits
.blends
;
5628 caps
->max_vertex_blend_matrix_index
= 0;
5629 caps
->vertex_processing_caps
= WINED3DVTXPCAPS_DIRECTIONALLIGHTS
5630 | WINED3DVTXPCAPS_MATERIALSOURCE7
5631 | WINED3DVTXPCAPS_POSITIONALLIGHTS
5632 | WINED3DVTXPCAPS_LOCALVIEWER
5633 | WINED3DVTXPCAPS_VERTEXFOG
5634 | WINED3DVTXPCAPS_TEXGEN
5635 | WINED3DVTXPCAPS_TEXGEN_SPHEREMAP
;
5636 caps
->fvf_caps
= WINED3DFVFCAPS_PSIZE
| 0x0008; /* 8 texture coords */
5637 caps
->max_user_clip_planes
= gl_info
->limits
.clipplanes
;
5638 caps
->raster_caps
= 0;
5639 if (gl_info
->supported
[NV_FOG_DISTANCE
])
5640 caps
->raster_caps
|= WINED3DPRASTERCAPS_FOGRANGE
;
5643 static DWORD
vp_ffp_get_emul_mask(const struct wined3d_gl_info
*gl_info
)
5645 return GL_EXT_EMUL_ARB_MULTITEXTURE
| GL_EXT_EMUL_EXT_FOG_COORD
;
5648 const struct wined3d_vertex_pipe_ops ffp_vertex_pipe
=
5652 vp_ffp_get_emul_mask
,
5658 static void ffp_fragment_get_caps(const struct wined3d_gl_info
*gl_info
, struct fragment_caps
*caps
)
5660 caps
->wined3d_caps
= 0;
5661 caps
->PrimitiveMiscCaps
= 0;
5662 caps
->TextureOpCaps
= WINED3DTEXOPCAPS_ADD
5663 | WINED3DTEXOPCAPS_ADDSIGNED
5664 | WINED3DTEXOPCAPS_ADDSIGNED2X
5665 | WINED3DTEXOPCAPS_MODULATE
5666 | WINED3DTEXOPCAPS_MODULATE2X
5667 | WINED3DTEXOPCAPS_MODULATE4X
5668 | WINED3DTEXOPCAPS_SELECTARG1
5669 | WINED3DTEXOPCAPS_SELECTARG2
5670 | WINED3DTEXOPCAPS_DISABLE
;
5672 if (gl_info
->supported
[ARB_TEXTURE_ENV_COMBINE
]
5673 || gl_info
->supported
[EXT_TEXTURE_ENV_COMBINE
]
5674 || gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
5676 caps
->TextureOpCaps
|= WINED3DTEXOPCAPS_BLENDDIFFUSEALPHA
5677 | WINED3DTEXOPCAPS_BLENDTEXTUREALPHA
5678 | WINED3DTEXOPCAPS_BLENDFACTORALPHA
5679 | WINED3DTEXOPCAPS_BLENDCURRENTALPHA
5680 | WINED3DTEXOPCAPS_LERP
5681 | WINED3DTEXOPCAPS_SUBTRACT
;
5683 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
]
5684 || gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
5686 caps
->TextureOpCaps
|= WINED3DTEXOPCAPS_ADDSMOOTH
5687 | WINED3DTEXOPCAPS_MULTIPLYADD
5688 | WINED3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR
5689 | WINED3DTEXOPCAPS_MODULATECOLOR_ADDALPHA
5690 | WINED3DTEXOPCAPS_BLENDTEXTUREALPHAPM
;
5692 if (gl_info
->supported
[ARB_TEXTURE_ENV_DOT3
])
5693 caps
->TextureOpCaps
|= WINED3DTEXOPCAPS_DOTPRODUCT3
;
5695 caps
->MaxTextureBlendStages
= gl_info
->limits
.textures
;
5696 caps
->MaxSimultaneousTextures
= gl_info
->limits
.textures
;
5699 static DWORD
ffp_fragment_get_emul_mask(const struct wined3d_gl_info
*gl_info
)
5701 return GL_EXT_EMUL_ARB_MULTITEXTURE
| GL_EXT_EMUL_EXT_FOG_COORD
;
5704 static BOOL
ffp_color_fixup_supported(struct color_fixup_desc fixup
)
5708 TRACE("Checking support for fixup:\n");
5709 dump_color_fixup_desc(fixup
);
5712 /* We only support identity conversions. */
5713 if (is_identity_fixup(fixup
))
5719 TRACE("[FAILED]\n");
5723 static BOOL
ffp_none_context_alloc(struct wined3d_context
*context
)
5728 static void ffp_none_context_free(struct wined3d_context
*context
)
5732 const struct fragment_pipeline ffp_fragment_pipeline
= {
5734 ffp_fragment_get_caps
,
5735 ffp_fragment_get_emul_mask
,
5738 ffp_none_context_alloc
,
5739 ffp_none_context_free
,
5740 ffp_color_fixup_supported
,
5741 ffp_fragmentstate_template
,
5744 static void none_enable(const struct wined3d_gl_info
*gl_info
, BOOL enable
) {}
5746 static void *none_alloc(const struct wined3d_shader_backend_ops
*shader_backend
, void *shader_priv
)
5751 static void none_free(struct wined3d_device
*device
) {}
5753 static void vp_none_get_caps(const struct wined3d_gl_info
*gl_info
, struct wined3d_vertex_caps
*caps
)
5755 memset(caps
, 0, sizeof(*caps
));
5758 static DWORD
vp_none_get_emul_mask(const struct wined3d_gl_info
*gl_info
)
5763 const struct wined3d_vertex_pipe_ops none_vertex_pipe
=
5767 vp_none_get_emul_mask
,
5773 static void fp_none_get_caps(const struct wined3d_gl_info
*gl_info
, struct fragment_caps
*caps
)
5775 memset(caps
, 0, sizeof(*caps
));
5778 static DWORD
fp_none_get_emul_mask(const struct wined3d_gl_info
*gl_info
)
5783 static BOOL
fp_none_color_fixup_supported(struct color_fixup_desc fixup
)
5785 return is_identity_fixup(fixup
);
5788 const struct fragment_pipeline none_fragment_pipe
=
5792 fp_none_get_emul_mask
,
5795 ffp_none_context_alloc
,
5796 ffp_none_context_free
,
5797 fp_none_color_fixup_supported
,
5801 static unsigned int num_handlers(const APPLYSTATEFUNC
*funcs
)
5804 for(i
= 0; funcs
[i
]; i
++);
5808 static void multistate_apply_2(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
5810 context
->swapchain
->device
->multistate_funcs
[state_id
][0](context
, state
, state_id
);
5811 context
->swapchain
->device
->multistate_funcs
[state_id
][1](context
, state
, state_id
);
5814 static void multistate_apply_3(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
5816 context
->swapchain
->device
->multistate_funcs
[state_id
][0](context
, state
, state_id
);
5817 context
->swapchain
->device
->multistate_funcs
[state_id
][1](context
, state
, state_id
);
5818 context
->swapchain
->device
->multistate_funcs
[state_id
][2](context
, state
, state_id
);
5821 static void prune_invalid_states(struct StateEntry
*state_table
, const struct wined3d_gl_info
*gl_info
,
5822 const struct wined3d_d3d_info
*d3d_info
)
5824 unsigned int start
, last
, i
;
5826 start
= STATE_TEXTURESTAGE(d3d_info
->limits
.ffp_blend_stages
, 0);
5827 last
= STATE_TEXTURESTAGE(MAX_TEXTURES
- 1, WINED3D_HIGHEST_TEXTURE_STATE
);
5828 for (i
= start
; i
<= last
; ++i
)
5830 state_table
[i
].representative
= 0;
5831 state_table
[i
].apply
= state_undefined
;
5834 start
= STATE_TRANSFORM(WINED3D_TS_TEXTURE0
+ d3d_info
->limits
.ffp_blend_stages
);
5835 last
= STATE_TRANSFORM(WINED3D_TS_TEXTURE0
+ MAX_TEXTURES
- 1);
5836 for (i
= start
; i
<= last
; ++i
)
5838 state_table
[i
].representative
= 0;
5839 state_table
[i
].apply
= state_undefined
;
5842 start
= STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(d3d_info
->limits
.ffp_vertex_blend_matrices
));
5843 last
= STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255));
5844 for (i
= start
; i
<= last
; ++i
)
5846 state_table
[i
].representative
= 0;
5847 state_table
[i
].apply
= state_undefined
;
5851 static void validate_state_table(struct StateEntry
*state_table
)
5873 static const DWORD simple_states
[] =
5879 STATE_SHADER(WINED3D_SHADER_TYPE_VERTEX
),
5880 STATE_SHADER(WINED3D_SHADER_TYPE_GEOMETRY
),
5881 STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
),
5882 STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX
),
5883 STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY
),
5884 STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL
),
5885 STATE_SHADER_RESOURCE_BINDING
,
5890 STATE_POINTSPRITECOORDORIGIN
,
5891 STATE_BASEVERTEXINDEX
,
5896 unsigned int i
, current
;
5898 for (i
= STATE_RENDER(1), current
= 0; i
<= STATE_RENDER(WINEHIGHEST_RENDER_STATE
); ++i
)
5900 if (!rs_holes
[current
].first
|| i
< STATE_RENDER(rs_holes
[current
].first
))
5902 if (!state_table
[i
].representative
)
5903 ERR("State %s (%#x) should have a representative.\n", debug_d3dstate(i
), i
);
5905 else if (state_table
[i
].representative
)
5906 ERR("State %s (%#x) shouldn't have a representative.\n", debug_d3dstate(i
), i
);
5908 if (i
== STATE_RENDER(rs_holes
[current
].last
)) ++current
;
5911 for (i
= 0; i
< sizeof(simple_states
) / sizeof(*simple_states
); ++i
)
5913 if (!state_table
[simple_states
[i
]].representative
)
5914 ERR("State %s (%#x) should have a representative.\n",
5915 debug_d3dstate(simple_states
[i
]), simple_states
[i
]);
5918 for (i
= 0; i
< STATE_HIGHEST
+ 1; ++i
)
5920 DWORD rep
= state_table
[i
].representative
;
5923 if (state_table
[rep
].representative
!= rep
)
5925 ERR("State %s (%#x) has invalid representative %s (%#x).\n",
5926 debug_d3dstate(i
), i
, debug_d3dstate(rep
), rep
);
5927 state_table
[i
].representative
= 0;
5932 if (state_table
[i
].apply
)
5933 ERR("State %s (%#x) has both a handler and representative.\n", debug_d3dstate(i
), i
);
5935 else if (!state_table
[i
].apply
)
5937 ERR("Self representing state %s (%#x) has no handler.\n", debug_d3dstate(i
), i
);
5943 HRESULT
compile_state_table(struct StateEntry
*StateTable
, APPLYSTATEFUNC
**dev_multistate_funcs
,
5944 const struct wined3d_gl_info
*gl_info
, const struct wined3d_d3d_info
*d3d_info
,
5945 const struct wined3d_vertex_pipe_ops
*vertex
, const struct fragment_pipeline
*fragment
,
5946 const struct StateEntryTemplate
*misc
)
5948 unsigned int i
, type
, handlers
;
5949 APPLYSTATEFUNC multistate_funcs
[STATE_HIGHEST
+ 1][3];
5950 const struct StateEntryTemplate
*cur
;
5951 BOOL set
[STATE_HIGHEST
+ 1];
5953 memset(multistate_funcs
, 0, sizeof(multistate_funcs
));
5955 for(i
= 0; i
< STATE_HIGHEST
+ 1; i
++) {
5956 StateTable
[i
].representative
= 0;
5957 StateTable
[i
].apply
= state_undefined
;
5960 for(type
= 0; type
< 3; type
++) {
5961 /* This switch decides the order in which the states are applied */
5963 case 0: cur
= misc
; break;
5964 case 1: cur
= fragment
->states
; break;
5965 case 2: cur
= vertex
->vp_states
; break;
5966 default: cur
= NULL
; /* Stupid compiler */
5970 /* GL extension filtering should not prevent multiple handlers being applied from different
5973 memset(set
, 0, sizeof(set
));
5975 for(i
= 0; cur
[i
].state
; i
++) {
5976 APPLYSTATEFUNC
*funcs_array
;
5978 /* Only use the first matching state with the available extension from one template.
5980 * {D3DRS_FOOBAR, {D3DRS_FOOBAR, func1}, XYZ_FANCY},
5981 * {D3DRS_FOOBAR, {D3DRS_FOOBAR, func2}, 0 }
5983 * if GL_XYZ_fancy is supported, ignore the 2nd line
5985 if(set
[cur
[i
].state
]) continue;
5986 /* Skip state lines depending on unsupported extensions */
5987 if (!gl_info
->supported
[cur
[i
].extension
]) continue;
5988 set
[cur
[i
].state
] = TRUE
;
5989 /* In some cases having an extension means that nothing has to be
5990 * done for a state, e.g. if GL_ARB_texture_non_power_of_two is
5991 * supported, the texture coordinate fixup can be ignored. If the
5992 * apply function is used, mark the state set(done above) to prevent
5993 * applying later lines, but do not record anything in the state
5996 if (!cur
[i
].content
.representative
) continue;
5998 handlers
= num_handlers(multistate_funcs
[cur
[i
].state
]);
5999 multistate_funcs
[cur
[i
].state
][handlers
] = cur
[i
].content
.apply
;
6002 StateTable
[cur
[i
].state
].apply
= cur
[i
].content
.apply
;
6005 StateTable
[cur
[i
].state
].apply
= multistate_apply_2
;
6006 if (!(dev_multistate_funcs
[cur
[i
].state
] = wined3d_calloc(2, sizeof(**dev_multistate_funcs
))))
6009 dev_multistate_funcs
[cur
[i
].state
][0] = multistate_funcs
[cur
[i
].state
][0];
6010 dev_multistate_funcs
[cur
[i
].state
][1] = multistate_funcs
[cur
[i
].state
][1];
6013 StateTable
[cur
[i
].state
].apply
= multistate_apply_3
;
6014 funcs_array
= HeapReAlloc(GetProcessHeap(),
6016 dev_multistate_funcs
[cur
[i
].state
],
6017 sizeof(**dev_multistate_funcs
) * 3);
6022 dev_multistate_funcs
[cur
[i
].state
] = funcs_array
;
6023 dev_multistate_funcs
[cur
[i
].state
][2] = multistate_funcs
[cur
[i
].state
][2];
6026 ERR("Unexpected amount of state handlers for state %u: %u\n",
6027 cur
[i
].state
, handlers
+ 1);
6030 if (StateTable
[cur
[i
].state
].representative
6031 && StateTable
[cur
[i
].state
].representative
!= cur
[i
].content
.representative
)
6033 FIXME("State %s (%#x) has different representatives in different pipeline parts.\n",
6034 debug_d3dstate(cur
[i
].state
), cur
[i
].state
);
6036 StateTable
[cur
[i
].state
].representative
= cur
[i
].content
.representative
;
6040 prune_invalid_states(StateTable
, gl_info
, d3d_info
);
6041 validate_state_table(StateTable
);
6046 for (i
= 0; i
<= STATE_HIGHEST
; ++i
) {
6047 HeapFree(GetProcessHeap(), 0, dev_multistate_funcs
[i
]);
6050 memset(dev_multistate_funcs
, 0, (STATE_HIGHEST
+ 1)*sizeof(*dev_multistate_funcs
));
6052 return E_OUTOFMEMORY
;