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
;
409 case WINED3D_BLEND_SRC1COLOR
:
410 return GL_SRC1_COLOR
;
411 case WINED3D_BLEND_INVSRC1COLOR
:
412 return GL_ONE_MINUS_SRC1_COLOR
;
413 case WINED3D_BLEND_SRC1ALPHA
:
414 return GL_SRC1_ALPHA
;
415 case WINED3D_BLEND_INVSRC1ALPHA
:
416 return GL_ONE_MINUS_SRC1_ALPHA
;
418 FIXME("Unhandled blend factor %#x.\n", factor
);
423 static void gl_blend_from_d3d(GLenum
*src_blend
, GLenum
*dst_blend
,
424 enum wined3d_blend d3d_src_blend
, enum wined3d_blend d3d_dst_blend
,
425 const struct wined3d_format
*rt_format
)
427 /* WINED3D_BLEND_BOTHSRCALPHA and WINED3D_BLEND_BOTHINVSRCALPHA are legacy
428 * source blending values which are still valid up to d3d9. They should
429 * not occur as dest blend values. */
430 if (d3d_src_blend
== WINED3D_BLEND_BOTHSRCALPHA
)
432 *src_blend
= GL_SRC_ALPHA
;
433 *dst_blend
= GL_ONE_MINUS_SRC_ALPHA
;
435 else if (d3d_src_blend
== WINED3D_BLEND_BOTHINVSRCALPHA
)
437 *src_blend
= GL_ONE_MINUS_SRC_ALPHA
;
438 *dst_blend
= GL_SRC_ALPHA
;
442 *src_blend
= gl_blend_factor(d3d_src_blend
, rt_format
);
443 *dst_blend
= gl_blend_factor(d3d_dst_blend
, rt_format
);
447 static void state_blend(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
449 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
450 const struct wined3d_format
*rt_format
;
451 BOOL enable_blend
, enable_line_smooth
;
452 GLenum src_blend
, dst_blend
;
453 unsigned int rt_fmt_flags
;
455 enable_line_smooth
= state
->render_states
[WINED3D_RS_EDGEANTIALIAS
]
456 || state
->render_states
[WINED3D_RS_ANTIALIASEDLINEENABLE
];
457 if (enable_line_smooth
)
459 gl_info
->gl_ops
.gl
.p_glEnable(GL_LINE_SMOOTH
);
460 checkGLcall("glEnable(GL_LINE_SMOOTH)");
464 gl_info
->gl_ops
.gl
.p_glDisable(GL_LINE_SMOOTH
);
465 checkGLcall("glDisable(GL_LINE_SMOOTH)");
468 enable_blend
= state
->fb
->render_targets
[0] && state
->render_states
[WINED3D_RS_ALPHABLENDENABLE
];
471 rt_format
= state
->fb
->render_targets
[0]->format
;
472 rt_fmt_flags
= state
->fb
->render_targets
[0]->format_flags
;
474 /* Disable blending in all cases even without pixelshaders.
475 * With blending on we could face a big performance penalty.
476 * The d3d9 visual test confirms the behavior. */
477 if (context
->render_offscreen
&& !(rt_fmt_flags
& WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
))
478 enable_blend
= FALSE
;
483 gl_info
->gl_ops
.gl
.p_glEnable(GL_BLEND
);
484 checkGLcall("glEnable(GL_BLEND)");
488 gl_info
->gl_ops
.gl
.p_glDisable(GL_BLEND
);
489 checkGLcall("glDisable(GL_BLEND)");
490 if (enable_line_smooth
)
491 WARN("LINE/EDGEANTIALIAS enabled with disabled blending.\n");
495 gl_blend_from_d3d(&src_blend
, &dst_blend
,
496 state
->render_states
[WINED3D_RS_SRCBLEND
],
497 state
->render_states
[WINED3D_RS_DESTBLEND
], rt_format
);
499 /* According to the red book, GL_LINE_SMOOTH needs GL_BLEND with specific
500 * blending parameters to work. */
501 if (enable_line_smooth
)
503 if (src_blend
!= GL_SRC_ALPHA
)
504 WARN("LINE/EDGEANTIALIAS enabled, but unexpected src blending param.\n");
505 if (dst_blend
!= GL_ONE_MINUS_SRC_ALPHA
&& dst_blend
!= GL_ONE
)
506 WARN("LINE/EDGEANTIALIAS enabled, but unexpected dst blending param.\n");
509 /* Re-apply BLENDOP(ALPHA) because of a possible SEPARATEALPHABLENDENABLE change */
510 if (!isStateDirty(context
, STATE_RENDER(WINED3D_RS_BLENDOP
)))
511 state_blendop(context
, state
, STATE_RENDER(WINED3D_RS_BLENDOPALPHA
));
513 if (state
->render_states
[WINED3D_RS_SEPARATEALPHABLENDENABLE
])
515 GLenum src_blend_alpha
, dst_blend_alpha
;
517 /* Separate alpha blending requires GL_EXT_blend_function_separate, so make sure it is around */
518 if (!context
->gl_info
->supported
[EXT_BLEND_FUNC_SEPARATE
])
520 WARN("Unsupported in local OpenGL implementation: glBlendFuncSeparate.\n");
524 gl_blend_from_d3d(&src_blend_alpha
, &dst_blend_alpha
,
525 state
->render_states
[WINED3D_RS_SRCBLENDALPHA
],
526 state
->render_states
[WINED3D_RS_DESTBLENDALPHA
], rt_format
);
528 GL_EXTCALL(glBlendFuncSeparate(src_blend
, dst_blend
, src_blend_alpha
, dst_blend_alpha
));
529 checkGLcall("glBlendFuncSeparate");
533 TRACE("glBlendFunc src=%x, dst=%x.\n", src_blend
, dst_blend
);
534 gl_info
->gl_ops
.gl
.p_glBlendFunc(src_blend
, dst_blend
);
535 checkGLcall("glBlendFunc");
538 /* Colorkey fixup for stage 0 alphaop depends on
539 * WINED3D_RS_ALPHABLENDENABLE state, so it may need updating. */
540 if (state
->render_states
[WINED3D_RS_COLORKEYENABLE
])
541 context_apply_state(context
, state
, STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
));
544 static void state_blendfactor_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
546 WARN("Unsupported in local OpenGL implementation: glBlendColor.\n");
549 static void state_blendfactor(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
551 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
552 struct wined3d_color color
;
554 TRACE("Setting blend factor to %#x.\n", state
->render_states
[WINED3D_RS_BLENDFACTOR
]);
556 wined3d_color_from_d3dcolor(&color
, state
->render_states
[WINED3D_RS_BLENDFACTOR
]);
557 GL_EXTCALL(glBlendColor(color
.r
, color
.g
, color
.b
, color
.a
));
558 checkGLcall("glBlendColor");
561 void state_alpha_test(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
563 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
566 BOOL enable_ckey
= FALSE
;
568 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
570 /* Find out if the texture on the first stage has a ckey set. The alpha
571 * state func reads the texture settings, even though alpha and texture
572 * are not grouped together. This is to avoid making a huge alpha +
573 * texture + texture stage + ckey block due to the hardly used
574 * WINED3D_RS_COLORKEYENABLE state(which is d3d <= 3 only). The texture
575 * function will call alpha in case it finds some texture + colorkeyenable
576 * combination which needs extra care. */
577 if (state
->textures
[0] && (state
->textures
[0]->async
.color_key_flags
& WINED3D_CKEY_SRC_BLT
))
580 if (enable_ckey
|| context
->last_was_ckey
)
581 context_apply_state(context
, state
, STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
));
582 context
->last_was_ckey
= enable_ckey
;
584 if (state
->render_states
[WINED3D_RS_ALPHATESTENABLE
]
585 || (state
->render_states
[WINED3D_RS_COLORKEYENABLE
] && enable_ckey
))
587 gl_info
->gl_ops
.gl
.p_glEnable(GL_ALPHA_TEST
);
588 checkGLcall("glEnable GL_ALPHA_TEST");
592 gl_info
->gl_ops
.gl
.p_glDisable(GL_ALPHA_TEST
);
593 checkGLcall("glDisable GL_ALPHA_TEST");
594 /* Alpha test is disabled, don't bother setting the params - it will happen on the next
600 if (state
->render_states
[WINED3D_RS_COLORKEYENABLE
] && enable_ckey
)
602 glParm
= GL_NOTEQUAL
;
607 ref
= ((float)state
->render_states
[WINED3D_RS_ALPHAREF
]) / 255.0f
;
608 glParm
= wined3d_gl_compare_func(state
->render_states
[WINED3D_RS_ALPHAFUNC
]);
612 gl_info
->gl_ops
.gl
.p_glAlphaFunc(glParm
, ref
);
613 checkGLcall("glAlphaFunc");
617 void state_clipping(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
619 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
620 unsigned int clipplane_count
= gl_info
->limits
.user_clip_distances
;
621 unsigned int i
, enable_mask
, disable_mask
;
623 if (use_vs(state
) && !context
->d3d_info
->vs_clipping
)
627 /* The OpenGL spec says that clipping planes are disabled when using
628 * shaders. Direct3D planes aren't, so that is an issue. The MacOS ATI
629 * driver keeps clipping planes activated with shaders in some
630 * conditions I got sick of tracking down. The shader state handler
631 * disables all clip planes because of that - don't do anything here
632 * and keep them disabled. */
633 if (state
->render_states
[WINED3D_RS_CLIPPLANEENABLE
] && !warned
++)
634 FIXME("Clipping not supported with vertex shaders\n");
638 /* glEnable(GL_CLIP_PLANEx) doesn't apply to (ARB backend) vertex shaders.
639 * The enabled / disabled planes are hardcoded into the shader. Update the
640 * shader to update the enabled clipplanes. In case of fixed function, we
641 * need to update the clipping field from ffp_vertex_settings. */
642 context
->shader_update_mask
|= 1u << WINED3D_SHADER_TYPE_VERTEX
;
644 /* TODO: Keep track of previously enabled clipplanes to avoid unnecessary resetting
645 * of already set values
648 /* If enabling / disabling all
649 * TODO: Is this correct? Doesn't D3DRS_CLIPPING disable clipping on the viewport frustrum?
651 if (state
->render_states
[WINED3D_RS_CLIPPING
])
653 enable_mask
= state
->render_states
[WINED3D_RS_CLIPPLANEENABLE
];
654 disable_mask
= ~state
->render_states
[WINED3D_RS_CLIPPLANEENABLE
];
662 if (clipplane_count
< 32)
664 enable_mask
&= (1u << clipplane_count
) - 1;
665 disable_mask
&= (1u << clipplane_count
) - 1;
668 for (i
= 0; enable_mask
&& i
< clipplane_count
; enable_mask
>>= 1, ++i
)
670 gl_info
->gl_ops
.gl
.p_glEnable(GL_CLIP_DISTANCE0
+ i
);
671 checkGLcall("clip plane enable");
673 for (i
= 0; disable_mask
&& i
< clipplane_count
; disable_mask
>>= 1, ++i
)
674 if (disable_mask
& 1)
675 gl_info
->gl_ops
.gl
.p_glDisable(GL_CLIP_DISTANCE0
+ i
);
676 checkGLcall("clip plane disable");
679 static void state_specularenable(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
681 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
682 /* Originally this used glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR)
683 * and (GL_LIGHT_MODEL_COLOR_CONTROL,GL_SINGLE_COLOR) to swap between enabled/disabled
684 * specular color. This is wrong:
685 * Separate specular color means the specular colour is maintained separately, whereas
686 * single color means it is merged in. However in both cases they are being used to
688 * To disable specular color, set it explicitly to black and turn off GL_COLOR_SUM_EXT
689 * NOTE: If not supported don't give FIXMEs the impact is really minimal and very few people are
693 * If register combiners are enabled, enabling / disabling GL_COLOR_SUM has no effect.
694 * Instead, we need to setup the FinalCombiner properly.
696 * The default setup for the FinalCombiner is:
698 * <variable> <input> <mapping> <usage>
699 * GL_VARIABLE_A_NV GL_FOG, GL_UNSIGNED_IDENTITY_NV GL_ALPHA
700 * GL_VARIABLE_B_NV GL_SPARE0_PLUS_SECONDARY_COLOR_NV GL_UNSIGNED_IDENTITY_NV GL_RGB
701 * GL_VARIABLE_C_NV GL_FOG GL_UNSIGNED_IDENTITY_NV GL_RGB
702 * GL_VARIABLE_D_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
703 * GL_VARIABLE_E_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
704 * GL_VARIABLE_F_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
705 * GL_VARIABLE_G_NV GL_SPARE0_NV GL_UNSIGNED_IDENTITY_NV GL_ALPHA
707 * That's pretty much fine as it is, except for variable B, which needs to take
708 * either GL_SPARE0_PLUS_SECONDARY_COLOR_NV or GL_SPARE0_NV, depending on
709 * whether WINED3D_RS_SPECULARENABLE is enabled or not.
712 TRACE("Setting specular enable state and materials\n");
713 if (state
->render_states
[WINED3D_RS_SPECULARENABLE
])
715 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, (float *)&state
->material
.specular
);
716 checkGLcall("glMaterialfv");
718 if (state
->material
.power
> gl_info
->limits
.shininess
)
720 /* glMaterialf man page says that the material says that GL_SHININESS must be between 0.0
721 * and 128.0, although in d3d neither -1 nor 129 produce an error. GL_NV_max_light_exponent
722 * allows bigger values. If the extension is supported, gl_info->limits.shininess contains the
723 * value reported by the extension, otherwise 128. For values > gl_info->limits.shininess clamp
724 * them, it should be safe to do so without major visual distortions.
726 WARN("Material power = %.8e, limit %.8e\n", state
->material
.power
, gl_info
->limits
.shininess
);
727 gl_info
->gl_ops
.gl
.p_glMaterialf(GL_FRONT_AND_BACK
, GL_SHININESS
, gl_info
->limits
.shininess
);
731 gl_info
->gl_ops
.gl
.p_glMaterialf(GL_FRONT_AND_BACK
, GL_SHININESS
, state
->material
.power
);
733 checkGLcall("glMaterialf(GL_SHININESS)");
735 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
736 gl_info
->gl_ops
.gl
.p_glEnable(GL_COLOR_SUM_EXT
);
738 TRACE("Specular colors cannot be enabled in this version of opengl\n");
739 checkGLcall("glEnable(GL_COLOR_SUM)");
741 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
743 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV
, GL_SPARE0_PLUS_SECONDARY_COLOR_NV
, GL_UNSIGNED_IDENTITY_NV
, GL_RGB
));
744 checkGLcall("glFinalCombinerInputNV()");
747 static const GLfloat black
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
749 /* for the case of enabled lighting: */
750 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, &black
[0]);
751 checkGLcall("glMaterialfv");
753 /* for the case of disabled lighting: */
754 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
755 gl_info
->gl_ops
.gl
.p_glDisable(GL_COLOR_SUM_EXT
);
757 TRACE("Specular colors cannot be disabled in this version of opengl\n");
758 checkGLcall("glDisable(GL_COLOR_SUM)");
760 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
762 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV
, GL_SPARE0_NV
, GL_UNSIGNED_IDENTITY_NV
, GL_RGB
));
763 checkGLcall("glFinalCombinerInputNV()");
767 TRACE("diffuse %s\n", debug_color(&state
->material
.diffuse
));
768 TRACE("ambient %s\n", debug_color(&state
->material
.ambient
));
769 TRACE("specular %s\n", debug_color(&state
->material
.specular
));
770 TRACE("emissive %s\n", debug_color(&state
->material
.emissive
));
772 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float *)&state
->material
.ambient
);
773 checkGLcall("glMaterialfv(GL_AMBIENT)");
774 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float *)&state
->material
.diffuse
);
775 checkGLcall("glMaterialfv(GL_DIFFUSE)");
776 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_EMISSION
, (float *)&state
->material
.emissive
);
777 checkGLcall("glMaterialfv(GL_EMISSION)");
780 static void state_texfactor(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
782 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
783 struct wined3d_color color
;
786 /* Note the texture color applies to all textures whereas
787 * GL_TEXTURE_ENV_COLOR applies to active only. */
788 wined3d_color_from_d3dcolor(&color
, state
->render_states
[WINED3D_RS_TEXTUREFACTOR
]);
790 /* And now the default texture color as well */
791 for (i
= 0; i
< context
->d3d_info
->limits
.ffp_blend_stages
; ++i
)
793 /* Note the WINED3D_RS value applies to all textures, but GL has one
794 * per texture, so apply it now ready to be used! */
795 context_active_texture(context
, gl_info
, i
);
797 gl_info
->gl_ops
.gl
.p_glTexEnvfv(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_COLOR
, &color
.r
);
798 checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);");
802 static void renderstate_stencil_twosided(struct wined3d_context
*context
, GLint face
,
803 GLint func
, GLint ref
, GLuint mask
, GLint stencilFail
, GLint depthFail
, GLint stencilPass
)
805 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
807 gl_info
->gl_ops
.gl
.p_glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT
);
808 checkGLcall("glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT)");
809 GL_EXTCALL(glActiveStencilFaceEXT(face
));
810 checkGLcall("glActiveStencilFaceEXT(...)");
811 gl_info
->gl_ops
.gl
.p_glStencilFunc(func
, ref
, mask
);
812 checkGLcall("glStencilFunc(...)");
813 gl_info
->gl_ops
.gl
.p_glStencilOp(stencilFail
, depthFail
, stencilPass
);
814 checkGLcall("glStencilOp(...)");
817 static GLenum
gl_stencil_op(enum wined3d_stencil_op op
)
821 case WINED3D_STENCIL_OP_KEEP
:
823 case WINED3D_STENCIL_OP_ZERO
:
825 case WINED3D_STENCIL_OP_REPLACE
:
827 case WINED3D_STENCIL_OP_INCR_SAT
:
829 case WINED3D_STENCIL_OP_DECR_SAT
:
831 case WINED3D_STENCIL_OP_INVERT
:
833 case WINED3D_STENCIL_OP_INCR
:
835 case WINED3D_STENCIL_OP_DECR
:
838 FIXME("Unrecognized stencil op %#x.\n", op
);
843 static void state_stencil(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
845 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
846 DWORD onesided_enable
;
847 DWORD twosided_enable
;
853 GLint stencilFail_back
;
855 GLint stencilPass_back
;
857 GLint depthFail_back
;
859 /* No stencil test without a stencil buffer. */
860 if (!state
->fb
->depth_stencil
)
862 gl_info
->gl_ops
.gl
.p_glDisable(GL_STENCIL_TEST
);
863 checkGLcall("glDisable GL_STENCIL_TEST");
867 onesided_enable
= state
->render_states
[WINED3D_RS_STENCILENABLE
];
868 twosided_enable
= state
->render_states
[WINED3D_RS_TWOSIDEDSTENCILMODE
];
869 if (!(func
= wined3d_gl_compare_func(state
->render_states
[WINED3D_RS_STENCILFUNC
])))
871 if (!(func_back
= wined3d_gl_compare_func(state
->render_states
[WINED3D_RS_BACK_STENCILFUNC
])))
872 func_back
= GL_ALWAYS
;
873 ref
= state
->render_states
[WINED3D_RS_STENCILREF
];
874 mask
= state
->render_states
[WINED3D_RS_STENCILMASK
];
875 stencilFail
= gl_stencil_op(state
->render_states
[WINED3D_RS_STENCILFAIL
]);
876 depthFail
= gl_stencil_op(state
->render_states
[WINED3D_RS_STENCILZFAIL
]);
877 stencilPass
= gl_stencil_op(state
->render_states
[WINED3D_RS_STENCILPASS
]);
878 stencilFail_back
= gl_stencil_op(state
->render_states
[WINED3D_RS_BACK_STENCILFAIL
]);
879 depthFail_back
= gl_stencil_op(state
->render_states
[WINED3D_RS_BACK_STENCILZFAIL
]);
880 stencilPass_back
= gl_stencil_op(state
->render_states
[WINED3D_RS_BACK_STENCILPASS
]);
882 TRACE("(onesided %d, twosided %d, ref %x, mask %x, "
883 "GL_FRONT: func: %x, fail %x, zfail %x, zpass %x "
884 "GL_BACK: func: %x, fail %x, zfail %x, zpass %x)\n",
885 onesided_enable
, twosided_enable
, ref
, mask
,
886 func
, stencilFail
, depthFail
, stencilPass
,
887 func_back
, stencilFail_back
, depthFail_back
, stencilPass_back
);
889 if (twosided_enable
&& onesided_enable
)
891 gl_info
->gl_ops
.gl
.p_glEnable(GL_STENCIL_TEST
);
892 checkGLcall("glEnable GL_STENCIL_TEST");
894 if (gl_info
->supported
[WINED3D_GL_VERSION_2_0
])
896 GL_EXTCALL(glStencilFuncSeparate(GL_FRONT
, func
, ref
, mask
));
897 GL_EXTCALL(glStencilOpSeparate(GL_FRONT
, stencilFail
, depthFail
, stencilPass
));
898 GL_EXTCALL(glStencilFuncSeparate(GL_BACK
, func_back
, ref
, mask
));
899 GL_EXTCALL(glStencilOpSeparate(GL_BACK
, stencilFail_back
, depthFail_back
, stencilPass_back
));
900 checkGLcall("setting two sided stencil state");
902 else if (gl_info
->supported
[EXT_STENCIL_TWO_SIDE
])
904 /* Apply back first, then front. This function calls glActiveStencilFaceEXT,
905 * which has an effect on the code below too. If we apply the front face
906 * afterwards, we are sure that the active stencil face is set to front,
907 * and other stencil functions which do not use two sided stencil do not have
910 renderstate_stencil_twosided(context
, GL_BACK
,
911 func_back
, ref
, mask
, stencilFail_back
, depthFail_back
, stencilPass_back
);
912 renderstate_stencil_twosided(context
, GL_FRONT
,
913 func
, ref
, mask
, stencilFail
, depthFail
, stencilPass
);
915 else if (gl_info
->supported
[ATI_SEPARATE_STENCIL
])
917 GL_EXTCALL(glStencilFuncSeparateATI(func
, func_back
, ref
, mask
));
918 checkGLcall("glStencilFuncSeparateATI(...)");
919 GL_EXTCALL(glStencilOpSeparateATI(GL_FRONT
, stencilFail
, depthFail
, stencilPass
));
920 checkGLcall("glStencilOpSeparateATI(GL_FRONT, ...)");
921 GL_EXTCALL(glStencilOpSeparateATI(GL_BACK
, stencilFail_back
, depthFail_back
, stencilPass_back
));
922 checkGLcall("glStencilOpSeparateATI(GL_BACK, ...)");
926 FIXME("Separate (two sided) stencil not supported on this version of OpenGL. Caps weren't honored?\n");
929 else if(onesided_enable
)
931 if (gl_info
->supported
[EXT_STENCIL_TWO_SIDE
])
933 gl_info
->gl_ops
.gl
.p_glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT
);
934 checkGLcall("glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT)");
937 /* This code disables the ATI extension as well, since the standard stencil functions are equal
938 * to calling the ATI functions with GL_FRONT_AND_BACK as face parameter
940 gl_info
->gl_ops
.gl
.p_glEnable(GL_STENCIL_TEST
);
941 checkGLcall("glEnable GL_STENCIL_TEST");
942 gl_info
->gl_ops
.gl
.p_glStencilFunc(func
, ref
, mask
);
943 checkGLcall("glStencilFunc(...)");
944 gl_info
->gl_ops
.gl
.p_glStencilOp(stencilFail
, depthFail
, stencilPass
);
945 checkGLcall("glStencilOp(...)");
949 gl_info
->gl_ops
.gl
.p_glDisable(GL_STENCIL_TEST
);
950 checkGLcall("glDisable GL_STENCIL_TEST");
954 static void state_stencilwrite2s(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
956 DWORD mask
= state
->fb
->depth_stencil
? state
->render_states
[WINED3D_RS_STENCILWRITEMASK
] : 0;
957 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
959 GL_EXTCALL(glActiveStencilFaceEXT(GL_BACK
));
960 checkGLcall("glActiveStencilFaceEXT(GL_BACK)");
961 gl_info
->gl_ops
.gl
.p_glStencilMask(mask
);
962 checkGLcall("glStencilMask");
963 GL_EXTCALL(glActiveStencilFaceEXT(GL_FRONT
));
964 checkGLcall("glActiveStencilFaceEXT(GL_FRONT)");
965 gl_info
->gl_ops
.gl
.p_glStencilMask(mask
);
968 static void state_stencilwrite(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
970 DWORD mask
= state
->fb
->depth_stencil
? state
->render_states
[WINED3D_RS_STENCILWRITEMASK
] : 0;
971 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
973 gl_info
->gl_ops
.gl
.p_glStencilMask(mask
);
974 checkGLcall("glStencilMask");
977 static void state_fog_vertexpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
979 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
981 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
983 if (!state
->render_states
[WINED3D_RS_FOGENABLE
])
986 /* Table fog on: Never use fog coords, and use per-fragment fog */
987 if (state
->render_states
[WINED3D_RS_FOGTABLEMODE
] != WINED3D_FOG_NONE
)
989 gl_info
->gl_ops
.gl
.p_glHint(GL_FOG_HINT
, GL_NICEST
);
990 if (context
->fog_coord
)
992 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FRAGMENT_DEPTH_EXT
);
993 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT)");
994 context
->fog_coord
= FALSE
;
997 /* Range fog is only used with per-vertex fog in d3d */
998 if (gl_info
->supported
[NV_FOG_DISTANCE
])
1000 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_DISTANCE_MODE_NV
, GL_EYE_PLANE_ABSOLUTE_NV
);
1001 checkGLcall("glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_PLANE_ABSOLUTE_NV)");
1006 /* Otherwise use per-vertex fog in any case */
1007 gl_info
->gl_ops
.gl
.p_glHint(GL_FOG_HINT
, GL_FASTEST
);
1009 if (state
->render_states
[WINED3D_RS_FOGVERTEXMODE
] == WINED3D_FOG_NONE
|| context
->last_was_rhw
)
1011 /* No fog at all, or transformed vertices: Use fog coord */
1012 if (!context
->fog_coord
)
1014 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FOG_COORDINATE_EXT
);
1015 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT)");
1016 context
->fog_coord
= TRUE
;
1021 /* Otherwise, use the fragment depth */
1022 if (context
->fog_coord
)
1024 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FRAGMENT_DEPTH_EXT
);
1025 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT)");
1026 context
->fog_coord
= FALSE
;
1029 if (state
->render_states
[WINED3D_RS_RANGEFOGENABLE
])
1031 if (gl_info
->supported
[NV_FOG_DISTANCE
])
1033 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_DISTANCE_MODE_NV
, GL_EYE_RADIAL_NV
);
1034 checkGLcall("glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_RADIAL_NV)");
1038 WARN("Range fog enabled, but not supported by this GL implementation.\n");
1041 else if (gl_info
->supported
[NV_FOG_DISTANCE
])
1043 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_DISTANCE_MODE_NV
, GL_EYE_PLANE_ABSOLUTE_NV
);
1044 checkGLcall("glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_PLANE_ABSOLUTE_NV)");
1049 void state_fogstartend(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1051 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1052 float fogstart
, fogend
;
1054 get_fog_start_end(context
, state
, &fogstart
, &fogend
);
1056 gl_info
->gl_ops
.gl
.p_glFogf(GL_FOG_START
, fogstart
);
1057 checkGLcall("glFogf(GL_FOG_START, fogstart)");
1058 TRACE("Fog Start == %f\n", fogstart
);
1060 gl_info
->gl_ops
.gl
.p_glFogf(GL_FOG_END
, fogend
);
1061 checkGLcall("glFogf(GL_FOG_END, fogend)");
1062 TRACE("Fog End == %f\n", fogend
);
1065 void state_fog_fragpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1067 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1068 enum fogsource new_source
;
1069 DWORD fogstart
= state
->render_states
[WINED3D_RS_FOGSTART
];
1070 DWORD fogend
= state
->render_states
[WINED3D_RS_FOGEND
];
1072 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
1074 if (!state
->render_states
[WINED3D_RS_FOGENABLE
])
1076 /* No fog? Disable it, and we're done :-) */
1077 glDisableWINE(GL_FOG
);
1078 checkGLcall("glDisable GL_FOG");
1084 * With fixed function vertex processing, Direct3D knows 2 different fog input sources.
1085 * It can use the Z value of the vertex, or the alpha component of the specular color.
1086 * This depends on the fog vertex, fog table and the vertex declaration. If the Z value
1087 * is used, fogstart, fogend and the equation type are used, otherwise linear fog with
1088 * start = 255, end = 0 is used. Obviously the msdn is not very clear on that.
1090 * FOGTABLEMODE != NONE:
1091 * The Z value is used, with the equation specified, no matter what vertex type.
1093 * FOGTABLEMODE == NONE, FOGVERTEXMODE != NONE, untransformed:
1094 * Per vertex fog is calculated using the specified fog equation and the parameters
1096 * FOGTABLEMODE == NONE, FOGVERTEXMODE != NONE, transformed, OR
1097 * FOGTABLEMODE == NONE, FOGVERTEXMODE == NONE, untransformed:
1098 * Linear fog with start = 255.0, end = 0.0, input comes from the specular color
1101 * Rules for vertex fog with shaders:
1103 * When mixing fixed function functionality with the programmable pipeline, D3D expects
1104 * the fog computation to happen during transformation while openGL expects it to happen
1105 * during rasterization. Also, prior to pixel shader 3.0 D3D handles fog blending after
1106 * the pixel shader while openGL always expects the pixel shader to handle the blending.
1107 * To solve this problem, WineD3D does:
1108 * 1) implement a linear fog equation and fog blending at the end of every pre 3.0 pixel
1110 * and 2) disables the fog computation (in either the fixed function or programmable
1111 * rasterizer) if using a vertex program.
1113 * D3D shaders can provide an explicit fog coordinate. This fog coordinate is used with
1114 * D3DRS_FOGTABLEMODE==D3DFOG_NONE. The FOGVERTEXMODE is ignored, d3d always uses linear
1115 * fog with start=1.0 and end=0.0 in this case. This is similar to fog coordinates in
1116 * the specular color, a vertex shader counts as pretransformed geometry in this case.
1117 * There are some GL differences between specular fog coords and vertex shaders though.
1119 * With table fog the vertex shader fog coordinate is ignored.
1121 * If a fogtablemode and a fogvertexmode are specified, table fog is applied (with or
1125 /* DX 7 sdk: "If both render states(vertex and table fog) are set to valid modes,
1126 * the system will apply only pixel(=table) fog effects."
1128 if (state
->render_states
[WINED3D_RS_FOGTABLEMODE
] == WINED3D_FOG_NONE
)
1132 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_LINEAR
);
1133 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1134 new_source
= FOGSOURCE_VS
;
1138 switch (state
->render_states
[WINED3D_RS_FOGVERTEXMODE
])
1140 /* If processed vertices are used, fall through to the NONE case */
1141 case WINED3D_FOG_EXP
:
1142 if (!context
->last_was_rhw
)
1144 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_EXP
);
1145 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP)");
1146 new_source
= FOGSOURCE_FFP
;
1151 case WINED3D_FOG_EXP2
:
1152 if (!context
->last_was_rhw
)
1154 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_EXP2
);
1155 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2)");
1156 new_source
= FOGSOURCE_FFP
;
1161 case WINED3D_FOG_LINEAR
:
1162 if (!context
->last_was_rhw
)
1164 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_LINEAR
);
1165 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1166 new_source
= FOGSOURCE_FFP
;
1171 case WINED3D_FOG_NONE
:
1172 /* Both are none? According to msdn the alpha channel of
1173 * the specular colour contains a fog factor. Set it in
1174 * draw_primitive_immediate_mode(). Same happens with
1175 * vertex fog on transformed vertices. */
1176 new_source
= FOGSOURCE_COORD
;
1177 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_LINEAR
);
1178 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1182 FIXME("Unexpected WINED3D_RS_FOGVERTEXMODE %#x.\n",
1183 state
->render_states
[WINED3D_RS_FOGVERTEXMODE
]);
1184 new_source
= FOGSOURCE_FFP
; /* Make the compiler happy */
1188 new_source
= FOGSOURCE_FFP
;
1190 switch (state
->render_states
[WINED3D_RS_FOGTABLEMODE
])
1192 case WINED3D_FOG_EXP
:
1193 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_EXP
);
1194 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP)");
1197 case WINED3D_FOG_EXP2
:
1198 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_EXP2
);
1199 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2)");
1202 case WINED3D_FOG_LINEAR
:
1203 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_LINEAR
);
1204 checkGLcall("glFogi(GL_FOG_MODE, GL_LINEAR)");
1207 case WINED3D_FOG_NONE
: /* Won't happen */
1209 FIXME("Unexpected WINED3D_RS_FOGTABLEMODE %#x.\n",
1210 state
->render_states
[WINED3D_RS_FOGTABLEMODE
]);
1214 glEnableWINE(GL_FOG
);
1215 checkGLcall("glEnable GL_FOG");
1216 if (new_source
!= context
->fog_source
|| fogstart
== fogend
)
1218 context
->fog_source
= new_source
;
1219 state_fogstartend(context
, state
, STATE_RENDER(WINED3D_RS_FOGSTART
));
1223 void state_fogcolor(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1225 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1226 struct wined3d_color color
;
1228 wined3d_color_from_d3dcolor(&color
, state
->render_states
[WINED3D_RS_FOGCOLOR
]);
1229 gl_info
->gl_ops
.gl
.p_glFogfv(GL_FOG_COLOR
, &color
.r
);
1230 checkGLcall("glFog GL_FOG_COLOR");
1233 void state_fogdensity(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1235 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1241 tmpvalue
.d
= state
->render_states
[WINED3D_RS_FOGDENSITY
];
1242 gl_info
->gl_ops
.gl
.p_glFogfv(GL_FOG_DENSITY
, &tmpvalue
.f
);
1243 checkGLcall("glFogf(GL_FOG_DENSITY, (float) Value)");
1246 static void state_colormat(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1248 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1251 /* Depends on the decoded vertex declaration to read the existence of diffuse data.
1252 * The vertex declaration will call this function if the fixed function pipeline is used.
1255 if(isStateDirty(context
, STATE_VDECL
)) {
1259 context
->num_untracked_materials
= 0;
1260 if ((context
->stream_info
.use_map
& (1u << WINED3D_FFP_DIFFUSE
))
1261 && state
->render_states
[WINED3D_RS_COLORVERTEX
])
1263 TRACE("diff %d, amb %d, emis %d, spec %d\n",
1264 state
->render_states
[WINED3D_RS_DIFFUSEMATERIALSOURCE
],
1265 state
->render_states
[WINED3D_RS_AMBIENTMATERIALSOURCE
],
1266 state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
],
1267 state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
]);
1269 if (state
->render_states
[WINED3D_RS_DIFFUSEMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1271 if (state
->render_states
[WINED3D_RS_AMBIENTMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1272 Parm
= GL_AMBIENT_AND_DIFFUSE
;
1275 if (state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1277 context
->untracked_materials
[context
->num_untracked_materials
] = GL_EMISSION
;
1278 context
->num_untracked_materials
++;
1280 if (state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1282 context
->untracked_materials
[context
->num_untracked_materials
] = GL_SPECULAR
;
1283 context
->num_untracked_materials
++;
1286 else if (state
->render_states
[WINED3D_RS_AMBIENTMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1289 if (state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1291 context
->untracked_materials
[context
->num_untracked_materials
] = GL_EMISSION
;
1292 context
->num_untracked_materials
++;
1294 if (state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1296 context
->untracked_materials
[context
->num_untracked_materials
] = GL_SPECULAR
;
1297 context
->num_untracked_materials
++;
1300 else if (state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1303 if (state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1305 context
->untracked_materials
[context
->num_untracked_materials
] = GL_SPECULAR
;
1306 context
->num_untracked_materials
++;
1309 else if (state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1315 /* Nothing changed, return. */
1316 if (Parm
== context
->tracking_parm
) return;
1320 gl_info
->gl_ops
.gl
.p_glDisable(GL_COLOR_MATERIAL
);
1321 checkGLcall("glDisable GL_COLOR_MATERIAL");
1325 gl_info
->gl_ops
.gl
.p_glColorMaterial(GL_FRONT_AND_BACK
, Parm
);
1326 checkGLcall("glColorMaterial(GL_FRONT_AND_BACK, Parm)");
1327 gl_info
->gl_ops
.gl
.p_glEnable(GL_COLOR_MATERIAL
);
1328 checkGLcall("glEnable(GL_COLOR_MATERIAL)");
1331 /* Apparently calls to glMaterialfv are ignored for properties we're
1332 * tracking with glColorMaterial, so apply those here. */
1333 switch (context
->tracking_parm
)
1335 case GL_AMBIENT_AND_DIFFUSE
:
1336 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float *)&state
->material
.ambient
);
1337 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float *)&state
->material
.diffuse
);
1338 checkGLcall("glMaterialfv");
1342 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float *)&state
->material
.diffuse
);
1343 checkGLcall("glMaterialfv");
1347 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float *)&state
->material
.ambient
);
1348 checkGLcall("glMaterialfv");
1352 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_EMISSION
, (float *)&state
->material
.emissive
);
1353 checkGLcall("glMaterialfv");
1357 /* Only change material color if specular is enabled, otherwise it is set to black */
1358 if (state
->render_states
[WINED3D_RS_SPECULARENABLE
])
1360 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, (float *)&state
->material
.specular
);
1361 checkGLcall("glMaterialfv");
1365 static const GLfloat black
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
1366 gl_info
->gl_ops
.gl
.p_glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, &black
[0]);
1367 checkGLcall("glMaterialfv");
1372 context
->tracking_parm
= Parm
;
1375 static void state_linepattern(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1377 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1381 struct wined3d_line_pattern lp
;
1383 tmppattern
.d
= state
->render_states
[WINED3D_RS_LINEPATTERN
];
1385 TRACE("Line pattern: repeat %d bits %x.\n", tmppattern
.lp
.repeat_factor
, tmppattern
.lp
.line_pattern
);
1387 if (tmppattern
.lp
.repeat_factor
)
1389 gl_info
->gl_ops
.gl
.p_glLineStipple(tmppattern
.lp
.repeat_factor
, tmppattern
.lp
.line_pattern
);
1390 checkGLcall("glLineStipple(repeat, linepattern)");
1391 gl_info
->gl_ops
.gl
.p_glEnable(GL_LINE_STIPPLE
);
1392 checkGLcall("glEnable(GL_LINE_STIPPLE);");
1396 gl_info
->gl_ops
.gl
.p_glDisable(GL_LINE_STIPPLE
);
1397 checkGLcall("glDisable(GL_LINE_STIPPLE);");
1401 static void state_linepattern_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1403 static unsigned int once
;
1406 FIXME("Setting line patterns is not supported in OpenGL core contexts.\n");
1409 static void state_normalize(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1411 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1413 if (isStateDirty(context
, STATE_VDECL
))
1416 /* Without vertex normals, we set the current normal to 0/0/0 to remove the diffuse factor
1417 * from the opengl lighting equation, as d3d does. Normalization of 0/0/0 can lead to a division
1418 * by zero and is not properly defined in opengl, so avoid it
1420 if (state
->render_states
[WINED3D_RS_NORMALIZENORMALS
]
1421 && (context
->stream_info
.use_map
& (1u << WINED3D_FFP_NORMAL
)))
1423 gl_info
->gl_ops
.gl
.p_glEnable(GL_NORMALIZE
);
1424 checkGLcall("glEnable(GL_NORMALIZE);");
1428 gl_info
->gl_ops
.gl
.p_glDisable(GL_NORMALIZE
);
1429 checkGLcall("glDisable(GL_NORMALIZE);");
1433 static void state_psizemin_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1437 get_pointsize_minmax(context
, state
, &min
, &max
);
1440 FIXME("WINED3D_RS_POINTSIZE_MIN value %.8e not supported on this OpenGL implementation.\n", min
);
1442 FIXME("WINED3D_RS_POINTSIZE_MAX value %.8e not supported on this OpenGL implementation.\n", max
);
1445 static void state_psizemin_ext(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1447 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1450 get_pointsize_minmax(context
, state
, &min
, &max
);
1452 GL_EXTCALL(glPointParameterfEXT
)(GL_POINT_SIZE_MIN_EXT
, min
);
1453 checkGLcall("glPointParameterfEXT(...)");
1454 GL_EXTCALL(glPointParameterfEXT
)(GL_POINT_SIZE_MAX_EXT
, max
);
1455 checkGLcall("glPointParameterfEXT(...)");
1458 static void state_psizemin_arb(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1460 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1463 get_pointsize_minmax(context
, state
, &min
, &max
);
1465 GL_EXTCALL(glPointParameterfARB
)(GL_POINT_SIZE_MIN_ARB
, min
);
1466 checkGLcall("glPointParameterfARB(...)");
1467 GL_EXTCALL(glPointParameterfARB
)(GL_POINT_SIZE_MAX_ARB
, max
);
1468 checkGLcall("glPointParameterfARB(...)");
1471 static void state_pscale(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1473 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1477 get_pointsize(context
, state
, &pointsize
, att
);
1479 if (gl_info
->supported
[ARB_POINT_PARAMETERS
])
1481 GL_EXTCALL(glPointParameterfvARB
)(GL_POINT_DISTANCE_ATTENUATION_ARB
, att
);
1482 checkGLcall("glPointParameterfvARB(GL_DISTANCE_ATTENUATION_ARB, ...)");
1484 else if (gl_info
->supported
[EXT_POINT_PARAMETERS
])
1486 GL_EXTCALL(glPointParameterfvEXT
)(GL_DISTANCE_ATTENUATION_EXT
, att
);
1487 checkGLcall("glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, ...)");
1489 else if (state
->render_states
[WINED3D_RS_POINTSCALEENABLE
])
1491 WARN("POINT_PARAMETERS not supported in this version of opengl\n");
1494 gl_info
->gl_ops
.gl
.p_glPointSize(max(pointsize
, FLT_MIN
));
1495 checkGLcall("glPointSize(...);");
1498 static void state_debug_monitor(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1500 WARN("token: %#x.\n", state
->render_states
[WINED3D_RS_DEBUGMONITORTOKEN
]);
1503 static void state_colorwrite(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1505 DWORD mask0
= state
->render_states
[WINED3D_RS_COLORWRITEENABLE
];
1506 DWORD mask1
= state
->render_states
[WINED3D_RS_COLORWRITEENABLE1
];
1507 DWORD mask2
= state
->render_states
[WINED3D_RS_COLORWRITEENABLE2
];
1508 DWORD mask3
= state
->render_states
[WINED3D_RS_COLORWRITEENABLE3
];
1509 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1511 TRACE("Color mask: r(%d) g(%d) b(%d) a(%d)\n",
1512 mask0
& WINED3DCOLORWRITEENABLE_RED
? 1 : 0,
1513 mask0
& WINED3DCOLORWRITEENABLE_GREEN
? 1 : 0,
1514 mask0
& WINED3DCOLORWRITEENABLE_BLUE
? 1 : 0,
1515 mask0
& WINED3DCOLORWRITEENABLE_ALPHA
? 1 : 0);
1516 gl_info
->gl_ops
.gl
.p_glColorMask(mask0
& WINED3DCOLORWRITEENABLE_RED
? GL_TRUE
: GL_FALSE
,
1517 mask0
& WINED3DCOLORWRITEENABLE_GREEN
? GL_TRUE
: GL_FALSE
,
1518 mask0
& WINED3DCOLORWRITEENABLE_BLUE
? GL_TRUE
: GL_FALSE
,
1519 mask0
& WINED3DCOLORWRITEENABLE_ALPHA
? GL_TRUE
: GL_FALSE
);
1520 checkGLcall("glColorMask(...)");
1522 if (!((mask1
== mask0
&& mask2
== mask0
&& mask3
== mask0
)
1523 || (mask1
== 0xf && mask2
== 0xf && mask3
== 0xf)))
1525 FIXME("WINED3D_RS_COLORWRITEENABLE/1/2/3, %#x/%#x/%#x/%#x not yet implemented.\n",
1526 mask0
, mask1
, mask2
, mask3
);
1527 FIXME("Missing of cap D3DPMISCCAPS_INDEPENDENTWRITEMASKS wasn't honored?\n");
1531 static void set_color_mask(const struct wined3d_gl_info
*gl_info
, UINT index
, DWORD mask
)
1533 GL_EXTCALL(glColorMaski(index
,
1534 mask
& WINED3DCOLORWRITEENABLE_RED
? GL_TRUE
: GL_FALSE
,
1535 mask
& WINED3DCOLORWRITEENABLE_GREEN
? GL_TRUE
: GL_FALSE
,
1536 mask
& WINED3DCOLORWRITEENABLE_BLUE
? GL_TRUE
: GL_FALSE
,
1537 mask
& WINED3DCOLORWRITEENABLE_ALPHA
? GL_TRUE
: GL_FALSE
));
1538 checkGLcall("glColorMaski");
1541 static void state_colorwrite0(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1543 set_color_mask(context
->gl_info
, 0, state
->render_states
[WINED3D_RS_COLORWRITEENABLE
]);
1546 static void state_colorwrite1(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1548 set_color_mask(context
->gl_info
, 1, state
->render_states
[WINED3D_RS_COLORWRITEENABLE1
]);
1551 static void state_colorwrite2(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1553 set_color_mask(context
->gl_info
, 2, state
->render_states
[WINED3D_RS_COLORWRITEENABLE2
]);
1556 static void state_colorwrite3(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1558 set_color_mask(context
->gl_info
, 3, state
->render_states
[WINED3D_RS_COLORWRITEENABLE3
]);
1561 static void state_localviewer(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1563 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1565 if (state
->render_states
[WINED3D_RS_LOCALVIEWER
])
1567 gl_info
->gl_ops
.gl
.p_glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER
, 1);
1568 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1)");
1572 gl_info
->gl_ops
.gl
.p_glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER
, 0);
1573 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 0)");
1577 static void state_lastpixel(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1579 if (state
->render_states
[WINED3D_RS_LASTPIXEL
])
1581 TRACE("Last Pixel Drawing Enabled\n");
1587 FIXME("Last Pixel Drawing Disabled, not handled yet\n");
1590 TRACE("Last Pixel Drawing Disabled, not handled yet\n");
1595 void state_pointsprite_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1599 /* TODO: NV_POINT_SPRITE */
1600 if (!warned
&& state
->render_states
[WINED3D_RS_POINTSPRITEENABLE
])
1602 /* A FIXME, not a WARN because point sprites should be software emulated if not supported by HW */
1603 FIXME("Point sprites not supported\n");
1608 void state_pointsprite(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1610 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1612 if (state
->render_states
[WINED3D_RS_POINTSPRITEENABLE
])
1614 gl_info
->gl_ops
.gl
.p_glEnable(GL_POINT_SPRITE_ARB
);
1615 checkGLcall("glEnable(GL_POINT_SPRITE_ARB)");
1619 gl_info
->gl_ops
.gl
.p_glDisable(GL_POINT_SPRITE_ARB
);
1620 checkGLcall("glDisable(GL_POINT_SPRITE_ARB)");
1624 static void state_wrap(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1626 static unsigned int once
;
1628 if ((state
->render_states
[WINED3D_RS_WRAP0
]
1629 || state
->render_states
[WINED3D_RS_WRAP1
]
1630 || state
->render_states
[WINED3D_RS_WRAP2
]
1631 || state
->render_states
[WINED3D_RS_WRAP3
]
1632 || state
->render_states
[WINED3D_RS_WRAP4
]
1633 || state
->render_states
[WINED3D_RS_WRAP5
]
1634 || state
->render_states
[WINED3D_RS_WRAP6
]
1635 || state
->render_states
[WINED3D_RS_WRAP7
]
1636 || state
->render_states
[WINED3D_RS_WRAP8
]
1637 || state
->render_states
[WINED3D_RS_WRAP9
]
1638 || state
->render_states
[WINED3D_RS_WRAP10
]
1639 || state
->render_states
[WINED3D_RS_WRAP11
]
1640 || state
->render_states
[WINED3D_RS_WRAP12
]
1641 || state
->render_states
[WINED3D_RS_WRAP13
]
1642 || state
->render_states
[WINED3D_RS_WRAP14
]
1643 || state
->render_states
[WINED3D_RS_WRAP15
])
1645 FIXME("(WINED3D_RS_WRAP0) Texture wrapping not yet supported.\n");
1648 static void state_msaa_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1650 if (state
->render_states
[WINED3D_RS_MULTISAMPLEANTIALIAS
])
1651 WARN("Multisample antialiasing not supported by GL.\n");
1654 static void state_msaa(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1656 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1658 if (state
->render_states
[WINED3D_RS_MULTISAMPLEANTIALIAS
])
1660 gl_info
->gl_ops
.gl
.p_glEnable(GL_MULTISAMPLE_ARB
);
1661 checkGLcall("glEnable(GL_MULTISAMPLE_ARB)");
1665 gl_info
->gl_ops
.gl
.p_glDisable(GL_MULTISAMPLE_ARB
);
1666 checkGLcall("glDisable(GL_MULTISAMPLE_ARB)");
1670 static void state_scissor(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1672 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1674 if (state
->render_states
[WINED3D_RS_SCISSORTESTENABLE
])
1676 gl_info
->gl_ops
.gl
.p_glEnable(GL_SCISSOR_TEST
);
1677 checkGLcall("glEnable(GL_SCISSOR_TEST)");
1681 gl_info
->gl_ops
.gl
.p_glDisable(GL_SCISSOR_TEST
);
1682 checkGLcall("glDisable(GL_SCISSOR_TEST)");
1686 /* The Direct3D depth bias is specified in normalized depth coordinates. In
1687 * OpenGL the bias is specified in units of "the smallest value that is
1688 * guaranteed to produce a resolvable offset for a given implementation". To
1689 * convert from D3D to GL we need to divide the D3D depth bias by that value.
1690 * We try to detect the value from GL with test draws. On most drivers (r300g,
1691 * 600g, Nvidia, i965 on Mesa) the value is 2^23 for fixed point depth buffers,
1692 * for r200 and i965 on OSX it is 2^24, for r500 on OSX it is 2^22. For floating
1693 * point buffers it is 2^22, 2^23 or 2^24 depending on the GPU. The value does
1694 * not depend on the depth buffer precision on any driver.
1696 * Two games that are picky regarding depth bias are Mass Effect 2 (flickering
1697 * decals) and F.E.A.R and F.E.A.R. 2 (semi-transparent guns).
1699 * Note that SLOPESCALEDEPTHBIAS is a scaling factor for the depth slope, and
1700 * doesn't need to be scaled to account for GL vs D3D differences. */
1701 static void state_depthbias(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1703 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1705 if (state
->render_states
[WINED3D_RS_SLOPESCALEDEPTHBIAS
]
1706 || state
->render_states
[WINED3D_RS_DEPTHBIAS
])
1708 const struct wined3d_rendertarget_view
*depth
= state
->fb
->depth_stencil
;
1715 } scale_bias
, const_bias
;
1717 scale_bias
.d
= state
->render_states
[WINED3D_RS_SLOPESCALEDEPTHBIAS
];
1718 const_bias
.d
= state
->render_states
[WINED3D_RS_DEPTHBIAS
];
1720 gl_info
->gl_ops
.gl
.p_glEnable(GL_POLYGON_OFFSET_FILL
);
1721 checkGLcall("glEnable(GL_POLYGON_OFFSET_FILL)");
1723 if (context
->d3d_info
->wined3d_creation_flags
& WINED3D_LEGACY_DEPTH_BIAS
)
1725 float bias
= -(float)const_bias
.d
;
1726 gl_info
->gl_ops
.gl
.p_glPolygonOffset(bias
, bias
);
1727 checkGLcall("glPolygonOffset");
1733 if (depth
->format_flags
& WINED3DFMT_FLAG_FLOAT
)
1734 scale
= gl_info
->float_polyoffset_scale
;
1736 scale
= gl_info
->fixed_polyoffset_scale
;
1738 TRACE("Depth format %s, using depthbias scale of %.8e.\n",
1739 debug_d3dformat(depth
->format
->id
), scale
);
1743 /* The context manager will reapply this state on a depth stencil change */
1744 TRACE("No depth stencil, using depthbias scale of 0.0.\n");
1748 gl_info
->gl_ops
.gl
.p_glPolygonOffset(scale_bias
.f
, const_bias
.f
* scale
);
1749 checkGLcall("glPolygonOffset(...)");
1754 gl_info
->gl_ops
.gl
.p_glDisable(GL_POLYGON_OFFSET_FILL
);
1755 checkGLcall("glDisable(GL_POLYGON_OFFSET_FILL)");
1759 static void state_zvisible(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1761 if (state
->render_states
[WINED3D_RS_ZVISIBLE
])
1762 FIXME("WINED3D_RS_ZVISIBLE not implemented.\n");
1765 static void state_stippledalpha(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1767 if (state
->render_states
[WINED3D_RS_STIPPLEDALPHA
])
1768 FIXME("Stippled Alpha not supported yet.\n");
1771 static void state_antialias(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1773 if (state
->render_states
[WINED3D_RS_ANTIALIAS
])
1774 FIXME("Antialias not supported yet.\n");
1777 static void state_multisampmask(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1779 if (state
->render_states
[WINED3D_RS_MULTISAMPLEMASK
] != 0xffffffff)
1780 FIXME("WINED3D_RS_MULTISAMPLEMASK %#x not yet implemented.\n",
1781 state
->render_states
[WINED3D_RS_MULTISAMPLEMASK
]);
1784 static void state_patchedgestyle(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1786 if (state
->render_states
[WINED3D_RS_PATCHEDGESTYLE
] != WINED3D_PATCH_EDGE_DISCRETE
)
1787 FIXME("WINED3D_RS_PATCHEDGESTYLE %#x not yet implemented.\n",
1788 state
->render_states
[WINED3D_RS_PATCHEDGESTYLE
]);
1791 static void state_patchsegments(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1799 if (state
->render_states
[WINED3D_RS_PATCHSEGMENTS
] != tmpvalue
.d
)
1801 static BOOL displayed
= FALSE
;
1803 tmpvalue
.d
= state
->render_states
[WINED3D_RS_PATCHSEGMENTS
];
1805 FIXME("(WINED3D_RS_PATCHSEGMENTS,%f) not yet implemented\n", tmpvalue
.f
);
1811 static void state_positiondegree(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1813 if (state
->render_states
[WINED3D_RS_POSITIONDEGREE
] != WINED3D_DEGREE_CUBIC
)
1814 FIXME("WINED3D_RS_POSITIONDEGREE %#x not yet implemented.\n",
1815 state
->render_states
[WINED3D_RS_POSITIONDEGREE
]);
1818 static void state_normaldegree(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1820 if (state
->render_states
[WINED3D_RS_NORMALDEGREE
] != WINED3D_DEGREE_LINEAR
)
1821 FIXME("WINED3D_RS_NORMALDEGREE %#x not yet implemented.\n",
1822 state
->render_states
[WINED3D_RS_NORMALDEGREE
]);
1825 static void state_tessellation(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1827 if (state
->render_states
[WINED3D_RS_ENABLEADAPTIVETESSELLATION
])
1828 FIXME("WINED3D_RS_ENABLEADAPTIVETESSELLATION %#x not yet implemented.\n",
1829 state
->render_states
[WINED3D_RS_ENABLEADAPTIVETESSELLATION
]);
1832 static void state_nvdb(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1839 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1841 if (state
->render_states
[WINED3D_RS_ADAPTIVETESS_X
] == WINED3DFMT_NVDB
)
1843 zmin
.d
= state
->render_states
[WINED3D_RS_ADAPTIVETESS_Z
];
1844 zmax
.d
= state
->render_states
[WINED3D_RS_ADAPTIVETESS_W
];
1846 /* If zmin is larger than zmax INVALID_VALUE error is generated.
1847 * In d3d9 test is not performed in this case*/
1848 if (zmin
.f
<= zmax
.f
)
1850 gl_info
->gl_ops
.gl
.p_glEnable(GL_DEPTH_BOUNDS_TEST_EXT
);
1851 checkGLcall("glEnable(GL_DEPTH_BOUNDS_TEST_EXT)");
1852 GL_EXTCALL(glDepthBoundsEXT(zmin
.f
, zmax
.f
));
1853 checkGLcall("glDepthBoundsEXT(...)");
1857 gl_info
->gl_ops
.gl
.p_glDisable(GL_DEPTH_BOUNDS_TEST_EXT
);
1858 checkGLcall("glDisable(GL_DEPTH_BOUNDS_TEST_EXT)");
1863 gl_info
->gl_ops
.gl
.p_glDisable(GL_DEPTH_BOUNDS_TEST_EXT
);
1864 checkGLcall("glDisable(GL_DEPTH_BOUNDS_TEST_EXT)");
1867 state_tessellation(context
, state
, STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
));
1870 static void state_wrapu(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1872 if (state
->render_states
[WINED3D_RS_WRAPU
])
1873 FIXME("Render state WINED3D_RS_WRAPU not implemented yet.\n");
1876 static void state_wrapv(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1878 if (state
->render_states
[WINED3D_RS_WRAPV
])
1879 FIXME("Render state WINED3D_RS_WRAPV not implemented yet.\n");
1882 static void state_monoenable(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1884 if (state
->render_states
[WINED3D_RS_MONOENABLE
])
1885 FIXME("Render state WINED3D_RS_MONOENABLE not implemented yet.\n");
1888 static void state_rop2(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1890 if (state
->render_states
[WINED3D_RS_ROP2
])
1891 FIXME("Render state WINED3D_RS_ROP2 not implemented yet.\n");
1894 static void state_planemask(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1896 if (state
->render_states
[WINED3D_RS_PLANEMASK
])
1897 FIXME("Render state WINED3D_RS_PLANEMASK not implemented yet.\n");
1900 static void state_subpixel(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1902 if (state
->render_states
[WINED3D_RS_SUBPIXEL
])
1903 FIXME("Render state WINED3D_RS_SUBPIXEL not implemented yet.\n");
1906 static void state_subpixelx(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1908 if (state
->render_states
[WINED3D_RS_SUBPIXELX
])
1909 FIXME("Render state WINED3D_RS_SUBPIXELX not implemented yet.\n");
1912 static void state_stippleenable(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1914 if (state
->render_states
[WINED3D_RS_STIPPLEENABLE
])
1915 FIXME("Render state WINED3D_RS_STIPPLEENABLE not implemented yet.\n");
1918 static void state_mipmaplodbias(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1920 if (state
->render_states
[WINED3D_RS_MIPMAPLODBIAS
])
1921 FIXME("Render state WINED3D_RS_MIPMAPLODBIAS not implemented yet.\n");
1924 static void state_anisotropy(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1926 if (state
->render_states
[WINED3D_RS_ANISOTROPY
])
1927 FIXME("Render state WINED3D_RS_ANISOTROPY not implemented yet.\n");
1930 static void state_flushbatch(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1932 if (state
->render_states
[WINED3D_RS_FLUSHBATCH
])
1933 FIXME("Render state WINED3D_RS_FLUSHBATCH not implemented yet.\n");
1936 static void state_translucentsi(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1938 if (state
->render_states
[WINED3D_RS_TRANSLUCENTSORTINDEPENDENT
])
1939 FIXME("Render state WINED3D_RS_TRANSLUCENTSORTINDEPENDENT not implemented yet.\n");
1942 static void state_extents(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1944 if (state
->render_states
[WINED3D_RS_EXTENTS
])
1945 FIXME("Render state WINED3D_RS_EXTENTS not implemented yet.\n");
1948 static void state_ckeyblend(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1950 if (state
->render_states
[WINED3D_RS_COLORKEYBLENDENABLE
])
1951 FIXME("Render state WINED3D_RS_COLORKEYBLENDENABLE not implemented yet.\n");
1954 static void state_swvp(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1957 if (state
->render_states
[WINED3D_RS_SOFTWAREVERTEXPROCESSING
])
1960 FIXME("Software vertex processing not implemented.\n");
1964 static void get_src_and_opr(DWORD arg
, BOOL is_alpha
, GLenum
* source
, GLenum
* operand
) {
1965 /* The WINED3DTA_ALPHAREPLICATE flag specifies the alpha component of the
1966 * input should be used for all input components. The WINED3DTA_COMPLEMENT
1967 * flag specifies the complement of the input should be used. */
1968 BOOL from_alpha
= is_alpha
|| arg
& WINED3DTA_ALPHAREPLICATE
;
1969 BOOL complement
= arg
& WINED3DTA_COMPLEMENT
;
1971 /* Calculate the operand */
1973 if (from_alpha
) *operand
= GL_ONE_MINUS_SRC_ALPHA
;
1974 else *operand
= GL_ONE_MINUS_SRC_COLOR
;
1976 if (from_alpha
) *operand
= GL_SRC_ALPHA
;
1977 else *operand
= GL_SRC_COLOR
;
1980 /* Calculate the source */
1981 switch (arg
& WINED3DTA_SELECTMASK
) {
1982 case WINED3DTA_CURRENT
: *source
= GL_PREVIOUS_EXT
; break;
1983 case WINED3DTA_DIFFUSE
: *source
= GL_PRIMARY_COLOR_EXT
; break;
1984 case WINED3DTA_TEXTURE
: *source
= GL_TEXTURE
; break;
1985 case WINED3DTA_TFACTOR
: *source
= GL_CONSTANT_EXT
; break;
1986 case WINED3DTA_SPECULAR
:
1988 * According to the GL_ARB_texture_env_combine specs, SPECULAR is
1989 * 'Secondary color' and isn't supported until base GL supports it
1990 * There is no concept of temp registers as far as I can tell
1992 FIXME("Unhandled texture arg WINED3DTA_SPECULAR\n");
1993 *source
= GL_TEXTURE
;
1996 FIXME("Unrecognized texture arg %#x\n", arg
);
1997 *source
= GL_TEXTURE
;
2002 /* Setup the texture operations texture stage states */
2003 static void set_tex_op(const struct wined3d_gl_info
*gl_info
, const struct wined3d_state
*state
,
2004 BOOL isAlpha
, int Stage
, enum wined3d_texture_op op
, DWORD arg1
, DWORD arg2
, DWORD arg3
)
2006 GLenum src1
, src2
, src3
;
2007 GLenum opr1
, opr2
, opr3
;
2009 GLenum src0_target
, src1_target
, src2_target
;
2010 GLenum opr0_target
, opr1_target
, opr2_target
;
2012 GLenum opr
=0, invopr
, src3_target
, opr3_target
;
2013 BOOL Handled
= FALSE
;
2015 TRACE("Alpha?(%d), Stage:%d Op(%s), a1(%d), a2(%d), a3(%d)\n", isAlpha
, Stage
, debug_d3dtop(op
), arg1
, arg2
, arg3
);
2017 /* Operations usually involve two args, src0 and src1 and are operations
2018 * of the form (a1 <operation> a2). However, some of the more complex
2019 * operations take 3 parameters. Instead of the (sensible) addition of a3,
2020 * Microsoft added in a third parameter called a0. Therefore these are
2021 * operations of the form a0 <operation> a1 <operation> a2. I.e., the new
2022 * parameter goes to the front.
2024 * However, below we treat the new (a0) parameter as src2/opr2, so in the
2025 * actual functions below, expect their syntax to differ slightly to those
2026 * listed in the manuals. I.e., replace arg1 with arg3, arg2 with arg1 and
2027 * arg3 with arg2. This affects WINED3DTOP_MULTIPLYADD and WINED3DTOP_LERP. */
2031 comb_target
= GL_COMBINE_ALPHA
;
2032 src0_target
= GL_SOURCE0_ALPHA
;
2033 src1_target
= GL_SOURCE1_ALPHA
;
2034 src2_target
= GL_SOURCE2_ALPHA
;
2035 opr0_target
= GL_OPERAND0_ALPHA
;
2036 opr1_target
= GL_OPERAND1_ALPHA
;
2037 opr2_target
= GL_OPERAND2_ALPHA
;
2038 scal_target
= GL_ALPHA_SCALE
;
2042 comb_target
= GL_COMBINE_RGB
;
2043 src0_target
= GL_SOURCE0_RGB
;
2044 src1_target
= GL_SOURCE1_RGB
;
2045 src2_target
= GL_SOURCE2_RGB
;
2046 opr0_target
= GL_OPERAND0_RGB
;
2047 opr1_target
= GL_OPERAND1_RGB
;
2048 opr2_target
= GL_OPERAND2_RGB
;
2049 scal_target
= GL_RGB_SCALE
;
2052 /* If a texture stage references an invalid texture unit the stage just
2053 * passes through the result from the previous stage */
2054 if (is_invalid_op(state
, Stage
, op
, arg1
, arg2
, arg3
))
2056 arg1
= WINED3DTA_CURRENT
;
2057 op
= WINED3D_TOP_SELECT_ARG1
;
2060 if (isAlpha
&& !state
->textures
[Stage
] && arg1
== WINED3DTA_TEXTURE
)
2062 get_src_and_opr(WINED3DTA_DIFFUSE
, isAlpha
, &src1
, &opr1
);
2064 get_src_and_opr(arg1
, isAlpha
, &src1
, &opr1
);
2066 get_src_and_opr(arg2
, isAlpha
, &src2
, &opr2
);
2067 get_src_and_opr(arg3
, isAlpha
, &src3
, &opr3
);
2069 TRACE("ct(%x), 1:(%x,%x), 2:(%x,%x), 3:(%x,%x)\n", comb_target
, src1
, opr1
, src2
, opr2
, src3
, opr3
);
2071 Handled
= TRUE
; /* Assume will be handled */
2073 /* Other texture operations require special extensions: */
2074 if (gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
2078 invopr
= GL_ONE_MINUS_SRC_ALPHA
;
2079 src3_target
= GL_SOURCE3_ALPHA_NV
;
2080 opr3_target
= GL_OPERAND3_ALPHA_NV
;
2083 invopr
= GL_ONE_MINUS_SRC_COLOR
;
2084 src3_target
= GL_SOURCE3_RGB_NV
;
2085 opr3_target
= GL_OPERAND3_RGB_NV
;
2089 case WINED3D_TOP_DISABLE
: /* Only for alpha */
2090 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2091 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2092 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_PREVIOUS_EXT
);
2093 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2094 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_SRC_ALPHA
);
2095 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2096 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2097 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2098 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2099 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2100 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2101 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_ZERO");
2102 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2103 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2104 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2105 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2106 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2107 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2110 case WINED3D_TOP_SELECT_ARG1
: /* = a1 * 1 + 0 * 0 */
2111 case WINED3D_TOP_SELECT_ARG2
: /* = a2 * 1 + 0 * 0 */
2112 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2113 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2114 if (op
== WINED3D_TOP_SELECT_ARG1
)
2116 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2117 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2118 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2119 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2123 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src2
);
2124 checkGLcall("GL_TEXTURE_ENV, src0_target, src2");
2125 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr2
);
2126 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr2");
2128 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2129 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2130 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2131 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2132 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2133 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_ZERO");
2134 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2135 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2136 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2137 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2138 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2139 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2142 case WINED3D_TOP_MODULATE
:
2143 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2144 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2145 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2146 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2147 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2148 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2149 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2150 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2151 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2152 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2153 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2154 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2155 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2156 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2157 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2158 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2159 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2160 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2161 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2162 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2164 case WINED3D_TOP_MODULATE_2X
:
2165 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2166 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2167 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2168 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2169 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2170 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2171 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2172 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2173 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2174 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2175 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2176 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2177 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2178 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2179 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2180 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2181 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2182 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2183 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2184 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2186 case WINED3D_TOP_MODULATE_4X
:
2187 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2188 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2189 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2190 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2191 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2192 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2193 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2194 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2195 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2196 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2197 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2198 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2199 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2200 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2201 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2202 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2203 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2204 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2205 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 4);
2206 checkGLcall("GL_TEXTURE_ENV, scal_target, 4");
2209 case WINED3D_TOP_ADD
:
2210 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2211 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2212 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2213 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2214 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2215 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2216 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2217 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2218 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2219 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2220 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2221 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2222 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2223 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2224 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2225 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2226 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2227 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2228 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2229 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2232 case WINED3D_TOP_ADD_SIGNED
:
2233 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD_SIGNED
);
2234 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2235 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2236 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2237 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2238 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2239 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2240 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2241 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2242 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2243 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2244 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2245 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2246 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2247 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2248 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2249 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2250 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2251 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2252 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2255 case WINED3D_TOP_ADD_SIGNED_2X
:
2256 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD_SIGNED
);
2257 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2258 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2259 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2260 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2261 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2262 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2263 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2264 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2265 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2266 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2267 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2268 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2269 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2270 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2271 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2272 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2273 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2274 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2275 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2278 case WINED3D_TOP_ADD_SMOOTH
:
2279 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2280 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2281 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2282 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2283 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2284 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2285 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2286 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2287 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2288 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2289 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2290 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2291 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2292 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2293 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
2294 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2296 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2297 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2298 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2299 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2301 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2302 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2303 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2304 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2307 case WINED3D_TOP_BLEND_DIFFUSE_ALPHA
:
2308 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2309 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2310 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2311 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2312 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2313 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2314 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_PRIMARY_COLOR
);
2315 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_PRIMARY_COLOR");
2316 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2317 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2318 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2319 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2320 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2321 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2322 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_PRIMARY_COLOR
);
2323 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_PRIMARY_COLOR");
2324 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2325 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2326 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2327 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2329 case WINED3D_TOP_BLEND_TEXTURE_ALPHA
:
2330 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2331 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2332 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2333 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2334 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2335 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2336 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_TEXTURE
);
2337 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_TEXTURE");
2338 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2339 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2340 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2341 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2342 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2343 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2344 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_TEXTURE
);
2345 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_TEXTURE");
2346 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2347 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2348 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2349 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2351 case WINED3D_TOP_BLEND_FACTOR_ALPHA
:
2352 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2353 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2354 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2355 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2356 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2357 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2358 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_CONSTANT
);
2359 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_CONSTANT");
2360 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2361 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2362 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2363 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2364 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2365 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2366 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_CONSTANT
);
2367 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_CONSTANT");
2368 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2369 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2370 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2371 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2373 case WINED3D_TOP_BLEND_TEXTURE_ALPHA_PM
:
2374 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2375 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2376 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2377 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2378 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2379 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2380 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2381 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2382 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2383 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2384 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2385 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2386 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2387 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2388 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_TEXTURE
);
2389 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_TEXTURE");
2390 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2391 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2392 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2393 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2395 case WINED3D_TOP_MODULATE_ALPHA_ADD_COLOR
:
2396 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2397 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2398 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
); /* a0 = src1/opr1 */
2399 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2400 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2401 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1"); /* a1 = 1 (see docs) */
2402 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2403 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2404 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2405 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2406 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
); /* a2 = arg2 */
2407 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2408 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2409 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2"); /* a3 = src1 alpha */
2410 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
2411 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2413 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2414 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2416 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2417 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2418 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2419 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2421 case WINED3D_TOP_MODULATE_COLOR_ADD_ALPHA
:
2422 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2423 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2424 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2425 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2426 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2427 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2428 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2429 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2430 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2431 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2432 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
2433 checkGLcall("GL_TEXTURE_ENV, src2_target, src1");
2435 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2436 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2438 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2439 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2440 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2441 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2442 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2443 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2444 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2445 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2447 case WINED3D_TOP_MODULATE_INVALPHA_ADD_COLOR
:
2448 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2449 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2450 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2451 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2452 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2453 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2454 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2455 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2456 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2457 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2458 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2459 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2460 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2461 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2462 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
2463 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2465 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2466 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2467 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2468 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2470 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2471 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2472 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2473 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2475 case WINED3D_TOP_MODULATE_INVCOLOR_ADD_ALPHA
:
2476 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2477 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2478 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2479 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2481 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2482 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2483 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2484 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2486 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2487 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2488 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2489 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2490 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2491 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2492 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
2493 checkGLcall("GL_TEXTURE_ENV, src2_target, src1");
2495 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2496 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2498 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2499 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2500 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2501 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2502 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2503 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2504 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2505 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2507 case WINED3D_TOP_MULTIPLY_ADD
:
2508 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2509 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2510 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src3
);
2511 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2512 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr3
);
2513 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2514 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2515 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2516 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2517 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2518 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
2519 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2520 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr1
);
2521 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2522 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src2
);
2523 checkGLcall("GL_TEXTURE_ENV, src3_target, src3");
2524 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr2
);
2525 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr3");
2526 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2527 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2530 case WINED3D_TOP_BUMPENVMAP
:
2531 case WINED3D_TOP_BUMPENVMAP_LUMINANCE
:
2532 FIXME("Implement bump environment mapping in GL_NV_texture_env_combine4 path\n");
2541 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_COMBINE4_NV
);
2542 checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV");
2546 } /* GL_NV_texture_env_combine4 */
2548 Handled
= TRUE
; /* Again, assume handled */
2550 case WINED3D_TOP_DISABLE
: /* Only for alpha */
2551 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
2552 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2553 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_PREVIOUS_EXT
);
2554 checkGLcall("GL_TEXTURE_ENV, src0_target, GL_PREVIOUS_EXT");
2555 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_SRC_ALPHA
);
2556 checkGLcall("GL_TEXTURE_ENV, opr0_target, GL_SRC_ALPHA");
2557 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2558 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2560 case WINED3D_TOP_SELECT_ARG1
:
2561 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
2562 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2563 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2564 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2565 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2566 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2567 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2568 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2570 case WINED3D_TOP_SELECT_ARG2
:
2571 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
2572 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2573 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src2
);
2574 checkGLcall("GL_TEXTURE_ENV, src0_target, src2");
2575 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr2
);
2576 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr2");
2577 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2578 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2580 case WINED3D_TOP_MODULATE
:
2581 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
2582 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2583 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2584 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2585 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2586 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2587 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2588 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2589 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2590 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2591 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2592 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2594 case WINED3D_TOP_MODULATE_2X
:
2595 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
2596 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2597 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2598 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2599 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2600 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2601 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2602 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2603 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2604 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2605 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2606 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2608 case WINED3D_TOP_MODULATE_4X
:
2609 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
2610 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2611 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2612 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2613 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2614 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2615 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2616 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2617 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2618 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2619 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 4);
2620 checkGLcall("GL_TEXTURE_ENV, scal_target, 4");
2622 case WINED3D_TOP_ADD
:
2623 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2624 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2625 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2626 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2627 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2628 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2629 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2630 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2631 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2632 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2633 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2634 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2636 case WINED3D_TOP_ADD_SIGNED
:
2637 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD_SIGNED
);
2638 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2639 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2640 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2641 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2642 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2643 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2644 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2645 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2646 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2647 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2648 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2650 case WINED3D_TOP_ADD_SIGNED_2X
:
2651 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD_SIGNED
);
2652 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2653 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2654 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2655 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2656 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2657 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2658 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2659 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2660 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2661 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2662 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2664 case WINED3D_TOP_SUBTRACT
:
2665 if (gl_info
->supported
[ARB_TEXTURE_ENV_COMBINE
])
2667 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_SUBTRACT
);
2668 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_SUBTRACT");
2669 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2670 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2671 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2672 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2673 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2674 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2675 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2676 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2677 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2678 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2680 FIXME("This version of opengl does not support GL_SUBTRACT\n");
2684 case WINED3D_TOP_BLEND_DIFFUSE_ALPHA
:
2685 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2686 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2687 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2688 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2689 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2690 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2691 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2692 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2693 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2694 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2695 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_PRIMARY_COLOR
);
2696 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_PRIMARY_COLOR");
2697 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2698 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2699 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2700 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2702 case WINED3D_TOP_BLEND_TEXTURE_ALPHA
:
2703 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2704 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2705 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2706 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2707 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2708 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2709 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2710 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2711 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2712 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2713 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_TEXTURE
);
2714 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_TEXTURE");
2715 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2716 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2717 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2718 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2720 case WINED3D_TOP_BLEND_FACTOR_ALPHA
:
2721 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2722 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2723 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2724 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2725 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2726 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2727 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2728 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2729 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2730 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2731 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_CONSTANT
);
2732 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_CONSTANT");
2733 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2734 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2735 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2736 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2738 case WINED3D_TOP_BLEND_CURRENT_ALPHA
:
2739 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2740 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2741 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2742 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2743 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2744 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2745 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2746 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2747 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2748 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2749 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_PREVIOUS
);
2750 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_PREVIOUS");
2751 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2752 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2753 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2754 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2756 case WINED3D_TOP_DOTPRODUCT3
:
2757 if (gl_info
->supported
[ARB_TEXTURE_ENV_DOT3
])
2759 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_DOT3_RGBA_ARB
);
2760 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_ARB");
2762 else if (gl_info
->supported
[EXT_TEXTURE_ENV_DOT3
])
2764 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_DOT3_RGBA_EXT
);
2765 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_EXT");
2767 FIXME("This version of opengl does not support GL_DOT3\n");
2769 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2770 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2771 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2772 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2773 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2774 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2775 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2776 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2777 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2778 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2780 case WINED3D_TOP_LERP
:
2781 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2782 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2783 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2784 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2785 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2786 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2787 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2788 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2789 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2790 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2791 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src3
);
2792 checkGLcall("GL_TEXTURE_ENV, src2_target, src3");
2793 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr3
);
2794 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr3");
2795 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2796 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2798 case WINED3D_TOP_ADD_SMOOTH
:
2799 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2801 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2802 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2803 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2804 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2806 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2807 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2808 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2809 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2811 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2812 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2813 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2814 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2815 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2816 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2817 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2818 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2819 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2820 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2821 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2822 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2826 case WINED3D_TOP_BLEND_TEXTURE_ALPHA_PM
:
2827 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2829 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2830 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2831 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_TEXTURE
);
2832 checkGLcall("GL_TEXTURE_ENV, src0_target, GL_TEXTURE");
2833 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_ONE_MINUS_SRC_ALPHA
);
2834 checkGLcall("GL_TEXTURE_ENV, opr0_target, GL_ONE_MINUS_SRC_APHA");
2835 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2836 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2837 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2838 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2839 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2840 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2841 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2842 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2843 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2844 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2848 case WINED3D_TOP_MODULATE_ALPHA_ADD_COLOR
:
2849 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2851 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2852 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2853 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2854 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2856 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2857 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2858 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2859 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2861 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2862 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2863 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2864 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2865 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2866 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2867 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2868 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2869 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2870 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2871 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2872 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2876 case WINED3D_TOP_MODULATE_COLOR_ADD_ALPHA
:
2877 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2879 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2880 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2881 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2882 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2883 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2884 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2885 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2886 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2888 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2889 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2890 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2891 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2893 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr
);
2894 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr");
2895 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2896 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2897 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2898 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2899 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2900 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2904 case WINED3D_TOP_MODULATE_INVALPHA_ADD_COLOR
:
2905 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2907 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2908 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2909 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2910 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2912 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2913 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2914 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2915 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2917 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2918 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2919 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2920 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2921 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2922 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2923 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2924 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2925 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2926 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2927 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2928 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2932 case WINED3D_TOP_MODULATE_INVCOLOR_ADD_ALPHA
:
2933 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2935 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2936 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2937 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2938 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2940 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2941 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2942 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2943 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2945 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2946 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2947 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2948 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2950 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2951 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2952 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2953 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2955 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr
);
2956 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr");
2957 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2958 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2959 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2960 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2961 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2962 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2966 case WINED3D_TOP_MULTIPLY_ADD
:
2967 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2969 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2970 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2971 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2972 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2973 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2974 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2975 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src3
);
2976 checkGLcall("GL_TEXTURE_ENV, src1_target, src3");
2977 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr3
);
2978 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr3");
2979 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2980 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2981 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2982 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2983 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2984 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2988 case WINED3D_TOP_BUMPENVMAP_LUMINANCE
:
2989 case WINED3D_TOP_BUMPENVMAP
:
2990 if (gl_info
->supported
[NV_TEXTURE_SHADER2
])
2992 /* Technically texture shader support without register combiners is possible, but not expected to occur
2993 * on real world cards, so for now a fixme should be enough
2995 FIXME("Implement bump mapping with GL_NV_texture_shader in non register combiner path\n");
3005 BOOL combineOK
= TRUE
;
3006 if (gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
3011 op2
= state
->texture_states
[Stage
][WINED3D_TSS_COLOR_OP
];
3013 op2
= state
->texture_states
[Stage
][WINED3D_TSS_ALPHA_OP
];
3015 /* Note: If COMBINE4 in effect can't go back to combine! */
3018 case WINED3D_TOP_ADD_SMOOTH
:
3019 case WINED3D_TOP_BLEND_TEXTURE_ALPHA_PM
:
3020 case WINED3D_TOP_MODULATE_ALPHA_ADD_COLOR
:
3021 case WINED3D_TOP_MODULATE_COLOR_ADD_ALPHA
:
3022 case WINED3D_TOP_MODULATE_INVALPHA_ADD_COLOR
:
3023 case WINED3D_TOP_MODULATE_INVCOLOR_ADD_ALPHA
:
3024 case WINED3D_TOP_MULTIPLY_ADD
:
3025 /* Ignore those implemented in both cases */
3028 case WINED3D_TOP_SELECT_ARG1
:
3029 case WINED3D_TOP_SELECT_ARG2
:
3034 FIXME("Can't use COMBINE4 and COMBINE together, thisop=%s, otherop=%s, isAlpha(%d)\n", debug_d3dtop(op
), debug_d3dtop(op2
), isAlpha
);
3042 gl_info
->gl_ops
.gl
.p_glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_COMBINE
);
3043 checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE");
3049 /* After all the extensions, if still unhandled, report fixme */
3050 FIXME("Unhandled texture operation %s\n", debug_d3dtop(op
));
3054 static void tex_colorop(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3056 DWORD stage
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3057 BOOL tex_used
= context
->fixed_function_usage_map
& (1u << stage
);
3058 DWORD mapped_stage
= context
->tex_unit_map
[stage
];
3059 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3061 TRACE("Setting color op for stage %d\n", stage
);
3063 /* Using a pixel shader? Don't care for anything here, the shader applying does it */
3064 if (use_ps(state
)) return;
3066 if (stage
!= mapped_stage
) WARN("Using non 1:1 mapping: %d -> %d!\n", stage
, mapped_stage
);
3068 if (mapped_stage
!= WINED3D_UNMAPPED_STAGE
)
3070 if (tex_used
&& mapped_stage
>= gl_info
->limits
.textures
)
3072 FIXME("Attempt to enable unsupported stage!\n");
3075 context_active_texture(context
, gl_info
, mapped_stage
);
3078 if (stage
>= context
->lowest_disabled_stage
)
3080 TRACE("Stage disabled\n");
3081 if (mapped_stage
!= WINED3D_UNMAPPED_STAGE
)
3083 /* Disable everything here */
3084 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_2D
);
3085 checkGLcall("glDisable(GL_TEXTURE_2D)");
3086 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_3D
);
3087 checkGLcall("glDisable(GL_TEXTURE_3D)");
3088 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
3090 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB
);
3091 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
3093 if (gl_info
->supported
[ARB_TEXTURE_RECTANGLE
])
3095 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_RECTANGLE_ARB
);
3096 checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)");
3103 /* The sampler will also activate the correct texture dimensions, so no
3104 * need to do it here if the sampler for this stage is dirty. */
3105 if (!isStateDirty(context
, STATE_SAMPLER(stage
)) && tex_used
)
3106 texture_activate_dimensions(state
->textures
[stage
], gl_info
);
3108 set_tex_op(gl_info
, state
, FALSE
, stage
,
3109 state
->texture_states
[stage
][WINED3D_TSS_COLOR_OP
],
3110 state
->texture_states
[stage
][WINED3D_TSS_COLOR_ARG1
],
3111 state
->texture_states
[stage
][WINED3D_TSS_COLOR_ARG2
],
3112 state
->texture_states
[stage
][WINED3D_TSS_COLOR_ARG0
]);
3115 void tex_alphaop(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3117 DWORD stage
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3118 BOOL tex_used
= context
->fixed_function_usage_map
& (1u << stage
);
3119 DWORD mapped_stage
= context
->tex_unit_map
[stage
];
3120 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3121 DWORD op
, arg1
, arg2
, arg0
;
3123 TRACE("Setting alpha op for stage %d\n", stage
);
3124 /* Do not care for enabled / disabled stages, just assign the settings. colorop disables / enables required stuff */
3125 if (mapped_stage
!= WINED3D_UNMAPPED_STAGE
)
3127 if (tex_used
&& mapped_stage
>= gl_info
->limits
.textures
)
3129 FIXME("Attempt to enable unsupported stage!\n");
3132 context_active_texture(context
, gl_info
, mapped_stage
);
3135 op
= state
->texture_states
[stage
][WINED3D_TSS_ALPHA_OP
];
3136 arg1
= state
->texture_states
[stage
][WINED3D_TSS_ALPHA_ARG1
];
3137 arg2
= state
->texture_states
[stage
][WINED3D_TSS_ALPHA_ARG2
];
3138 arg0
= state
->texture_states
[stage
][WINED3D_TSS_ALPHA_ARG0
];
3140 if (state
->render_states
[WINED3D_RS_COLORKEYENABLE
] && !stage
&& state
->textures
[0])
3142 struct wined3d_texture
*texture
= state
->textures
[0];
3143 GLenum texture_dimensions
= texture
->target
;
3145 if (texture_dimensions
== GL_TEXTURE_2D
|| texture_dimensions
== GL_TEXTURE_RECTANGLE_ARB
)
3147 if (texture
->async
.color_key_flags
& WINED3D_CKEY_SRC_BLT
&& !texture
->resource
.format
->alpha_size
)
3149 /* Color keying needs to pass alpha values from the texture through to have the alpha test work
3150 * properly. On the other hand applications can still use texture combiners apparently. This code
3151 * takes care that apps cannot remove the texture's alpha channel entirely.
3153 * The fixup is required for Prince of Persia 3D(prison bars), while Moto racer 2 requires
3154 * D3DTOP_MODULATE to work on color keyed surfaces. Aliens vs Predator 1 uses color keyed textures
3155 * and alpha component of diffuse color to draw things like translucent text and perform other
3158 * Aliens vs Predator 1 relies on diffuse alpha having an effect, so it cannot be ignored. To
3159 * provide the behavior expected by the game, while emulating the colorkey, diffuse alpha must be
3160 * modulated with texture alpha. OTOH, Moto racer 2 at some points sets alphaop/alphaarg to
3161 * SELECTARG/CURRENT, yet puts garbage in diffuse alpha (zeroes). This works on native, because the
3162 * game disables alpha test and alpha blending. Alpha test is overwritten by wine's for purposes of
3163 * color-keying though, so this will lead to missing geometry if texture alpha is modulated (pixels
3164 * fail alpha test). To get around this, ALPHABLENDENABLE state is checked: if the app enables alpha
3165 * blending, it can be expected to provide meaningful values in diffuse alpha, so it should be
3166 * modulated with texture alpha; otherwise, selecting diffuse alpha is ignored in favour of texture
3169 * What to do with multitexturing? So far no app has been found that uses color keying with
3171 if (op
== WINED3D_TOP_DISABLE
)
3173 arg1
= WINED3DTA_TEXTURE
;
3174 op
= WINED3D_TOP_SELECT_ARG1
;
3176 else if (op
== WINED3D_TOP_SELECT_ARG1
&& arg1
!= WINED3DTA_TEXTURE
)
3178 if (state
->render_states
[WINED3D_RS_ALPHABLENDENABLE
])
3180 arg2
= WINED3DTA_TEXTURE
;
3181 op
= WINED3D_TOP_MODULATE
;
3183 else arg1
= WINED3DTA_TEXTURE
;
3185 else if (op
== WINED3D_TOP_SELECT_ARG2
&& arg2
!= WINED3DTA_TEXTURE
)
3187 if (state
->render_states
[WINED3D_RS_ALPHABLENDENABLE
])
3189 arg1
= WINED3DTA_TEXTURE
;
3190 op
= WINED3D_TOP_MODULATE
;
3192 else arg2
= WINED3DTA_TEXTURE
;
3198 /* tex_alphaop is shared between the ffp and nvrc because the difference only comes down to
3199 * this if block here, and the other code(color keying, texture unit selection) are the same
3201 TRACE("Setting alpha op for stage %d\n", stage
);
3202 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
3204 set_tex_op_nvrc(gl_info
, state
, TRUE
, stage
, op
, arg1
, arg2
, arg0
,
3205 mapped_stage
, state
->texture_states
[stage
][WINED3D_TSS_RESULT_ARG
]);
3209 set_tex_op(gl_info
, state
, TRUE
, stage
, op
, arg1
, arg2
, arg0
);
3213 static void transform_texture(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3215 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3216 unsigned int tex
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3217 unsigned int mapped_stage
= context
->tex_unit_map
[tex
];
3218 struct wined3d_matrix mat
;
3220 /* Ignore this when a vertex shader is used, or if the streams aren't sorted out yet */
3221 if (use_vs(state
) || isStateDirty(context
, STATE_VDECL
))
3223 TRACE("Using a vertex shader, or stream sources not sorted out yet, skipping\n");
3227 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
) return;
3228 if (mapped_stage
>= gl_info
->limits
.textures
) return;
3230 context_active_texture(context
, gl_info
, mapped_stage
);
3231 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_TEXTURE
);
3232 checkGLcall("glMatrixMode(GL_TEXTURE)");
3234 get_texture_matrix(context
, state
, mapped_stage
, &mat
);
3236 gl_info
->gl_ops
.gl
.p_glLoadMatrixf(&mat
._11
);
3237 checkGLcall("glLoadMatrixf");
3240 static void unload_tex_coords(const struct wined3d_gl_info
*gl_info
)
3242 unsigned int texture_idx
;
3244 for (texture_idx
= 0; texture_idx
< gl_info
->limits
.texture_coords
; ++texture_idx
)
3246 GL_EXTCALL(glClientActiveTextureARB(GL_TEXTURE0_ARB
+ texture_idx
));
3247 gl_info
->gl_ops
.gl
.p_glDisableClientState(GL_TEXTURE_COORD_ARRAY
);
3251 static void load_tex_coords(const struct wined3d_context
*context
, const struct wined3d_stream_info
*si
,
3252 GLuint
*curVBO
, const struct wined3d_state
*state
)
3254 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3255 unsigned int mapped_stage
= 0;
3256 unsigned int textureNo
;
3258 for (textureNo
= 0; textureNo
< context
->d3d_info
->limits
.ffp_blend_stages
; ++textureNo
)
3260 int coordIdx
= state
->texture_states
[textureNo
][WINED3D_TSS_TEXCOORD_INDEX
];
3262 mapped_stage
= context
->tex_unit_map
[textureNo
];
3263 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
) continue;
3265 if (mapped_stage
>= gl_info
->limits
.texture_coords
)
3267 FIXME("Attempted to load unsupported texture coordinate %u\n", mapped_stage
);
3271 if (coordIdx
< MAX_TEXTURES
&& (si
->use_map
& (1u << (WINED3D_FFP_TEXCOORD0
+ coordIdx
))))
3273 const struct wined3d_stream_info_element
*e
= &si
->elements
[WINED3D_FFP_TEXCOORD0
+ coordIdx
];
3275 TRACE("Setting up texture %u, idx %d, coordindx %u, data {%#x:%p}.\n",
3276 textureNo
, mapped_stage
, coordIdx
, e
->data
.buffer_object
, e
->data
.addr
);
3278 if (*curVBO
!= e
->data
.buffer_object
)
3280 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER
, e
->data
.buffer_object
));
3281 checkGLcall("glBindBuffer");
3282 *curVBO
= e
->data
.buffer_object
;
3285 GL_EXTCALL(glClientActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
3286 checkGLcall("glClientActiveTextureARB");
3288 /* The coords to supply depend completely on the fvf / vertex shader */
3289 gl_info
->gl_ops
.gl
.p_glTexCoordPointer(e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
3290 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
3291 gl_info
->gl_ops
.gl
.p_glEnableClientState(GL_TEXTURE_COORD_ARRAY
);
3295 GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB
+ mapped_stage
, 0, 0, 0, 1));
3298 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
3300 /* The number of the mapped stages increases monotonically, so it's fine to use the last used one. */
3301 for (textureNo
= mapped_stage
+ 1; textureNo
< gl_info
->limits
.textures
; ++textureNo
)
3303 GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB
+ textureNo
, 0, 0, 0, 1));
3307 checkGLcall("loadTexCoords");
3310 static void tex_coordindex(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3312 DWORD stage
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3313 static const GLfloat s_plane
[] = { 1.0f
, 0.0f
, 0.0f
, 0.0f
};
3314 static const GLfloat t_plane
[] = { 0.0f
, 1.0f
, 0.0f
, 0.0f
};
3315 static const GLfloat r_plane
[] = { 0.0f
, 0.0f
, 1.0f
, 0.0f
};
3316 static const GLfloat q_plane
[] = { 0.0f
, 0.0f
, 0.0f
, 1.0f
};
3317 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3318 DWORD mapped_stage
= context
->tex_unit_map
[stage
];
3320 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
)
3322 TRACE("No texture unit mapped to stage %d. Skipping texture coordinates.\n", stage
);
3326 if (mapped_stage
>= gl_info
->limits
.fragment_samplers
)
3328 WARN("stage %u not mapped to a valid texture unit (%u)\n", stage
, mapped_stage
);
3331 context_active_texture(context
, gl_info
, mapped_stage
);
3333 /* Values 0-7 are indexes into the FVF tex coords - See comments in DrawPrimitive
3335 * FIXME: When using generated texture coordinates, the index value is used to specify the wrapping mode.
3336 * eg. SetTextureStageState( 0, WINED3D_TSS_TEXCOORDINDEX, WINED3D_TSS_TCI_CAMERASPACEPOSITION | 1 );
3337 * means use the vertex position (camera-space) as the input texture coordinates
3338 * for this texture stage, and the wrap mode set in the WINED3D_RS_WRAP1 render
3339 * state. We do not (yet) support the WINED3DRENDERSTATE_WRAPx values, nor tie them up
3340 * to the TEXCOORDINDEX value
3342 switch (state
->texture_states
[stage
][WINED3D_TSS_TEXCOORD_INDEX
] & 0xffff0000)
3344 case WINED3DTSS_TCI_PASSTHRU
:
3345 /* Use the specified texture coordinates contained within the
3346 * vertex format. This value resolves to zero. */
3347 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_S
);
3348 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_T
);
3349 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_R
);
3350 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_Q
);
3351 checkGLcall("WINED3DTSS_TCI_PASSTHRU - Disable texgen.");
3354 case WINED3DTSS_TCI_CAMERASPACEPOSITION
:
3355 /* CameraSpacePosition means use the vertex position, transformed to camera space,
3356 * as the input texture coordinates for this stage's texture transformation. This
3357 * equates roughly to EYE_LINEAR */
3359 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3360 gl_info
->gl_ops
.gl
.p_glPushMatrix();
3361 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
3362 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
3363 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
3364 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
3365 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
3366 gl_info
->gl_ops
.gl
.p_glPopMatrix();
3367 checkGLcall("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set eye plane.");
3369 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
3370 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
3371 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
3372 checkGLcall("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set texgen mode.");
3374 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_S
);
3375 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_T
);
3376 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_R
);
3377 checkGLcall("WINED3DTSS_TCI_CAMERASPACEPOSITION - Enable texgen.");
3381 case WINED3DTSS_TCI_CAMERASPACENORMAL
:
3382 /* Note that NV_TEXGEN_REFLECTION support is implied when
3383 * ARB_TEXTURE_CUBE_MAP is supported */
3384 if (!gl_info
->supported
[NV_TEXGEN_REFLECTION
])
3386 FIXME("WINED3DTSS_TCI_CAMERASPACENORMAL not supported.\n");
3390 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3391 gl_info
->gl_ops
.gl
.p_glPushMatrix();
3392 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
3393 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
3394 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
3395 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
3396 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
3397 gl_info
->gl_ops
.gl
.p_glPopMatrix();
3398 checkGLcall("WINED3DTSS_TCI_CAMERASPACENORMAL - Set eye plane.");
3400 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
3401 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
3402 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
3403 checkGLcall("WINED3DTSS_TCI_CAMERASPACENORMAL - Set texgen mode.");
3405 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_S
);
3406 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_T
);
3407 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_R
);
3408 checkGLcall("WINED3DTSS_TCI_CAMERASPACENORMAL - Enable texgen.");
3412 case WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR
:
3413 /* Note that NV_TEXGEN_REFLECTION support is implied when
3414 * ARB_TEXTURE_CUBE_MAP is supported */
3415 if (!gl_info
->supported
[NV_TEXGEN_REFLECTION
])
3417 FIXME("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR not supported.\n");
3421 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3422 gl_info
->gl_ops
.gl
.p_glPushMatrix();
3423 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
3424 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
3425 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
3426 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
3427 gl_info
->gl_ops
.gl
.p_glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
3428 gl_info
->gl_ops
.gl
.p_glPopMatrix();
3429 checkGLcall("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Set eye plane.");
3431 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
3432 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
3433 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
3434 checkGLcall("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Set texgen mode.");
3436 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_S
);
3437 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_T
);
3438 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_R
);
3439 checkGLcall("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Enable texgen.");
3443 case WINED3DTSS_TCI_SPHEREMAP
:
3444 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_SPHERE_MAP
);
3445 gl_info
->gl_ops
.gl
.p_glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_SPHERE_MAP
);
3446 checkGLcall("WINED3DTSS_TCI_SPHEREMAP - Set texgen mode.");
3448 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_S
);
3449 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_GEN_T
);
3450 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_R
);
3451 checkGLcall("WINED3DTSS_TCI_SPHEREMAP - Enable texgen.");
3456 FIXME("Unhandled WINED3D_TSS_TEXCOORD_INDEX %#x.\n",
3457 state
->texture_states
[stage
][WINED3D_TSS_TEXCOORD_INDEX
]);
3458 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_S
);
3459 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_T
);
3460 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_R
);
3461 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_GEN_Q
);
3462 checkGLcall("Disable texgen.");
3467 /* Update the texture matrix. */
3468 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_TEXTURE0
+ stage
)))
3469 transform_texture(context
, state
, STATE_TEXTURESTAGE(stage
, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
));
3471 if (!isStateDirty(context
, STATE_VDECL
) && context
->namedArraysLoaded
)
3473 /* Reload the arrays if we are using fixed function arrays to reflect the selected coord input
3474 * source. Call loadTexCoords directly because there is no need to reparse the vertex declaration
3475 * and do all the things linked to it
3476 * TODO: Tidy that up to reload only the arrays of the changed unit
3478 GLuint curVBO
= gl_info
->supported
[ARB_VERTEX_BUFFER_OBJECT
] ? ~0U : 0;
3480 unload_tex_coords(gl_info
);
3481 load_tex_coords(context
, &context
->stream_info
, &curVBO
, state
);
3485 static void sampler_texmatrix(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3487 const DWORD sampler
= state_id
- STATE_SAMPLER(0);
3488 const struct wined3d_texture
*texture
= state
->textures
[sampler
];
3490 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
3492 if(!texture
) return;
3493 /* The fixed function np2 texture emulation uses the texture matrix to fix up the coordinates
3494 * wined3d_texture_apply_state_changes() multiplies the set matrix with a fixup matrix. Before the
3495 * scaling is reapplied or removed, the texture matrix has to be reapplied
3497 * The mapped stage is already active because the sampler() function below, which is part of the
3500 if (sampler
< MAX_TEXTURES
)
3502 const BOOL texIsPow2
= !(texture
->flags
& WINED3D_TEXTURE_POW2_MAT_IDENT
);
3504 if (texIsPow2
|| (context
->lastWasPow2Texture
& (1u << sampler
)))
3507 context
->lastWasPow2Texture
|= 1u << sampler
;
3509 context
->lastWasPow2Texture
&= ~(1u << sampler
);
3511 transform_texture(context
, state
,
3512 STATE_TEXTURESTAGE(context
->tex_unit_map
[sampler
], WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
));
3517 static enum wined3d_texture_address
wined3d_texture_address_mode(const struct wined3d_texture
*texture
,
3518 enum wined3d_texture_address t
)
3520 if (t
< WINED3D_TADDRESS_WRAP
|| t
> WINED3D_TADDRESS_MIRROR_ONCE
)
3522 FIXME("Unrecognized or unsupported texture address mode %#x.\n", t
);
3523 return WINED3D_TADDRESS_WRAP
;
3526 /* Cubemaps are always set to clamp, regardless of the sampler state. */
3527 if (texture
->target
== GL_TEXTURE_CUBE_MAP_ARB
|| ((texture
->flags
& WINED3D_TEXTURE_COND_NP2
)
3528 && t
== WINED3D_TADDRESS_WRAP
))
3529 return WINED3D_TADDRESS_CLAMP
;
3534 static void wined3d_sampler_desc_from_sampler_states(struct wined3d_sampler_desc
*desc
,
3535 const struct wined3d_context
*context
, const DWORD
*sampler_states
, const struct wined3d_texture
*texture
)
3543 desc
->address_u
= wined3d_texture_address_mode(texture
, sampler_states
[WINED3D_SAMP_ADDRESS_U
]);
3544 desc
->address_v
= wined3d_texture_address_mode(texture
, sampler_states
[WINED3D_SAMP_ADDRESS_V
]);
3545 desc
->address_w
= wined3d_texture_address_mode(texture
, sampler_states
[WINED3D_SAMP_ADDRESS_W
]);
3546 wined3d_color_from_d3dcolor((struct wined3d_color
*)desc
->border_color
,
3547 sampler_states
[WINED3D_SAMP_BORDER_COLOR
]);
3548 if (sampler_states
[WINED3D_SAMP_MAG_FILTER
] > WINED3D_TEXF_ANISOTROPIC
)
3549 FIXME("Unrecognized or unsupported WINED3D_SAMP_MAG_FILTER %#x.\n",
3550 sampler_states
[WINED3D_SAMP_MAG_FILTER
]);
3551 desc
->mag_filter
= min(max(sampler_states
[WINED3D_SAMP_MAG_FILTER
], WINED3D_TEXF_POINT
), WINED3D_TEXF_LINEAR
);
3552 if (sampler_states
[WINED3D_SAMP_MIN_FILTER
] > WINED3D_TEXF_ANISOTROPIC
)
3553 FIXME("Unrecognized or unsupported WINED3D_SAMP_MIN_FILTER %#x.\n",
3554 sampler_states
[WINED3D_SAMP_MIN_FILTER
]);
3555 desc
->min_filter
= min(max(sampler_states
[WINED3D_SAMP_MIN_FILTER
], WINED3D_TEXF_POINT
), WINED3D_TEXF_LINEAR
);
3556 if (sampler_states
[WINED3D_SAMP_MIP_FILTER
] > WINED3D_TEXF_ANISOTROPIC
)
3557 FIXME("Unrecognized or unsupported WINED3D_SAMP_MIP_FILTER %#x.\n",
3558 sampler_states
[WINED3D_SAMP_MIP_FILTER
]);
3559 desc
->mip_filter
= min(max(sampler_states
[WINED3D_SAMP_MIP_FILTER
], WINED3D_TEXF_NONE
), WINED3D_TEXF_LINEAR
);
3560 lod_bias
.d
= sampler_states
[WINED3D_SAMP_MIPMAP_LOD_BIAS
];
3561 desc
->lod_bias
= lod_bias
.f
;
3562 desc
->min_lod
= -1000.0f
;
3563 desc
->max_lod
= 1000.0f
;
3564 desc
->max_anisotropy
= sampler_states
[WINED3D_SAMP_MAX_ANISOTROPY
];
3565 if ((sampler_states
[WINED3D_SAMP_MAG_FILTER
] != WINED3D_TEXF_ANISOTROPIC
3566 && sampler_states
[WINED3D_SAMP_MIN_FILTER
] != WINED3D_TEXF_ANISOTROPIC
3567 && sampler_states
[WINED3D_SAMP_MIP_FILTER
] != WINED3D_TEXF_ANISOTROPIC
)
3568 || (texture
->flags
& WINED3D_TEXTURE_COND_NP2
))
3569 desc
->max_anisotropy
= 1;
3570 desc
->compare
= texture
->resource
.format_flags
& WINED3DFMT_FLAG_SHADOW
;
3571 desc
->comparison_func
= WINED3D_CMP_LESSEQUAL
;
3572 desc
->srgb_decode
= sampler_states
[WINED3D_SAMP_SRGB_TEXTURE
];
3574 if (!(texture
->resource
.format_flags
& WINED3DFMT_FLAG_FILTERING
))
3576 desc
->mag_filter
= WINED3D_TEXF_POINT
;
3577 desc
->min_filter
= WINED3D_TEXF_POINT
;
3578 desc
->mip_filter
= WINED3D_TEXF_NONE
;
3581 if (texture
->flags
& WINED3D_TEXTURE_COND_NP2
)
3583 desc
->mip_filter
= WINED3D_TEXF_NONE
;
3584 if (context
->gl_info
->supported
[WINED3D_GL_NORMALIZED_TEXRECT
])
3585 desc
->min_filter
= WINED3D_TEXF_POINT
;
3589 /* Enabling and disabling texture dimensions is done by texture stage state /
3590 * pixel shader setup, this function only has to bind textures and set the per
3591 * texture states. */
3592 static void sampler(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3594 DWORD sampler_idx
= state_id
- STATE_SAMPLER(0);
3595 DWORD mapped_stage
= context
->tex_unit_map
[sampler_idx
];
3596 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3598 TRACE("Sampler %u.\n", sampler_idx
);
3601 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
)
3603 TRACE("No sampler mapped to stage %u. Returning.\n", sampler_idx
);
3607 if (mapped_stage
>= gl_info
->limits
.combined_samplers
)
3611 context_active_texture(context
, gl_info
, mapped_stage
);
3613 if (state
->textures
[sampler_idx
])
3615 struct wined3d_texture
*texture
= state
->textures
[sampler_idx
];
3616 BOOL srgb
= state
->sampler_states
[sampler_idx
][WINED3D_SAMP_SRGB_TEXTURE
];
3617 const DWORD
*sampler_states
= state
->sampler_states
[sampler_idx
];
3618 struct wined3d_sampler_desc desc
;
3619 struct gl_texture
*gl_tex
;
3620 unsigned int base_level
;
3622 wined3d_sampler_desc_from_sampler_states(&desc
, context
, sampler_states
, texture
);
3624 wined3d_texture_bind(texture
, context
, srgb
);
3625 if (!gl_info
->supported
[ARB_SAMPLER_OBJECTS
])
3627 wined3d_texture_apply_sampler_desc(texture
, &desc
, context
);
3631 struct wined3d_device
*device
= context
->device
;
3632 struct wined3d_sampler
*sampler
;
3633 struct wine_rb_entry
*entry
;
3635 if ((entry
= wine_rb_get(&device
->samplers
, &desc
)))
3637 sampler
= WINE_RB_ENTRY_VALUE(entry
, struct wined3d_sampler
, entry
);
3641 if (FAILED(wined3d_sampler_create(device
, &desc
, NULL
, &sampler
)))
3643 ERR("Failed to create sampler.\n");
3648 if (wine_rb_put(&device
->samplers
, &desc
, &sampler
->entry
) == -1)
3649 ERR("Failed to insert sampler.\n");
3655 GL_EXTCALL(glBindSampler(mapped_stage
, sampler
->name
));
3656 checkGLcall("glBindSampler");
3660 if (texture
->flags
& WINED3D_TEXTURE_COND_NP2
)
3662 else if (desc
.mip_filter
== WINED3D_TEXF_NONE
)
3663 base_level
= texture
->lod
;
3665 base_level
= min(max(sampler_states
[WINED3D_SAMP_MAX_MIP_LEVEL
],
3666 texture
->lod
), texture
->level_count
- 1);
3668 gl_tex
= wined3d_texture_get_gl_texture(texture
, texture
->flags
& WINED3D_TEXTURE_IS_SRGB
);
3669 if (base_level
!= gl_tex
->base_level
)
3671 /* Note that WINED3D_SAMP_MAX_MIP_LEVEL specifies the largest mipmap
3672 * (default 0), while GL_TEXTURE_MAX_LEVEL specifies the smallest
3673 * mipmap used (default 1000). So WINED3D_SAMP_MAX_MIP_LEVEL
3674 * corresponds to GL_TEXTURE_BASE_LEVEL. */
3675 gl_info
->gl_ops
.gl
.p_glTexParameteri(texture
->target
, GL_TEXTURE_BASE_LEVEL
, base_level
);
3676 gl_tex
->base_level
= base_level
;
3679 /* Trigger shader constant reloading (for NP2 texcoord fixup) */
3680 if (!(texture
->flags
& WINED3D_TEXTURE_POW2_MAT_IDENT
))
3681 context
->constant_update_mask
|= WINED3D_SHADER_CONST_PS_NP2_FIXUP
;
3685 context_bind_texture(context
, GL_NONE
, 0);
3686 if (gl_info
->supported
[ARB_SAMPLER_OBJECTS
])
3688 GL_EXTCALL(glBindSampler(mapped_stage
, 0));
3689 checkGLcall("glBindSampler");
3694 void apply_pixelshader(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3700 if (!context
->last_was_pshader
)
3702 /* Former draw without a pixel shader, some samplers may be
3703 * disabled because of WINED3D_TSS_COLOR_OP = WINED3DTOP_DISABLE
3704 * make sure to enable them. */
3705 for (i
= 0; i
< MAX_FRAGMENT_SAMPLERS
; ++i
)
3707 if (!isStateDirty(context
, STATE_SAMPLER(i
)))
3708 sampler(context
, state
, STATE_SAMPLER(i
));
3710 context
->last_was_pshader
= TRUE
;
3714 /* Otherwise all samplers were activated by the code above in
3715 * earlier draws, or by sampler() if a different texture was
3716 * bound. I don't have to do anything. */
3721 /* Disabled the pixel shader - color ops weren't applied while it was
3722 * enabled, so re-apply them. */
3723 for (i
= 0; i
< context
->d3d_info
->limits
.ffp_blend_stages
; ++i
)
3725 if (!isStateDirty(context
, STATE_TEXTURESTAGE(i
, WINED3D_TSS_COLOR_OP
)))
3726 context_apply_state(context
, state
, STATE_TEXTURESTAGE(i
, WINED3D_TSS_COLOR_OP
));
3728 context
->last_was_pshader
= FALSE
;
3731 context
->shader_update_mask
|= 1u << WINED3D_SHADER_TYPE_PIXEL
;
3734 static void state_compute_shader(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3736 context
->shader_update_mask
|= 1u << WINED3D_SHADER_TYPE_COMPUTE
;
3739 static void state_shader(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3741 enum wined3d_shader_type shader_type
= state_id
- STATE_SHADER(0);
3742 context
->shader_update_mask
|= 1u << shader_type
;
3745 static void shader_bumpenv(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3747 context
->constant_update_mask
|= WINED3D_SHADER_CONST_PS_BUMP_ENV
;
3750 static void transform_world(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3752 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3753 struct wined3d_matrix mat
;
3755 /* This function is called by transform_view below if the view matrix was changed too
3757 * Deliberately no check if the vertex declaration is dirty because the vdecl state
3758 * does not always update the world matrix, only on a switch between transformed
3759 * and untransformed draws. It *may* happen that the world matrix is set 2 times during one
3760 * draw, but that should be rather rare and cheaper in total.
3762 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3763 checkGLcall("glMatrixMode");
3765 get_modelview_matrix(context
, state
, 0, &mat
);
3767 gl_info
->gl_ops
.gl
.p_glLoadMatrixf((GLfloat
*)&mat
);
3768 checkGLcall("glLoadMatrixf");
3771 void clipplane(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3773 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3774 UINT index
= state_id
- STATE_CLIPPLANE(0);
3777 if (isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_VIEW
)) || index
>= gl_info
->limits
.user_clip_distances
)
3780 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3781 gl_info
->gl_ops
.gl
.p_glPushMatrix();
3783 /* Clip Plane settings are affected by the model view in OpenGL, the View transform in direct3d */
3785 gl_info
->gl_ops
.gl
.p_glLoadMatrixf(&state
->transforms
[WINED3D_TS_VIEW
]._11
);
3787 /* With vertex shaders, clip planes are not transformed in Direct3D,
3788 * while in OpenGL they are still transformed by the model view matrix. */
3789 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
3791 plane
[0] = state
->clip_planes
[index
].x
;
3792 plane
[1] = state
->clip_planes
[index
].y
;
3793 plane
[2] = state
->clip_planes
[index
].z
;
3794 plane
[3] = state
->clip_planes
[index
].w
;
3796 TRACE("Clipplane [%.8e, %.8e, %.8e, %.8e]\n",
3797 plane
[0], plane
[1], plane
[2], plane
[3]);
3798 gl_info
->gl_ops
.gl
.p_glClipPlane(GL_CLIP_PLANE0
+ index
, plane
);
3799 checkGLcall("glClipPlane");
3801 gl_info
->gl_ops
.gl
.p_glPopMatrix();
3804 static void transform_worldex(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3806 UINT matrix
= state_id
- STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0));
3807 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3810 TRACE("Setting world matrix %d\n", matrix
);
3812 if (matrix
>= gl_info
->limits
.blends
)
3814 WARN("Unsupported blend matrix set\n");
3818 if (isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_VIEW
)))
3821 /* GL_MODELVIEW0_ARB: 0x1700
3822 * GL_MODELVIEW1_ARB: 0x850a
3823 * GL_MODELVIEW2_ARB: 0x8722
3824 * GL_MODELVIEW3_ARB: 0x8723
3826 * GL_MODELVIEW31_ARB: 0x873f
3828 if(matrix
== 1) glMat
= GL_MODELVIEW1_ARB
;
3829 else glMat
= GL_MODELVIEW2_ARB
- 2 + matrix
;
3831 gl_info
->gl_ops
.gl
.p_glMatrixMode(glMat
);
3832 checkGLcall("glMatrixMode(glMat)");
3834 /* World matrix 0 is multiplied with the view matrix because d3d uses 3
3835 * matrices while gl uses only 2. To avoid weighting the view matrix
3836 * incorrectly it has to be multiplied into every GL modelview matrix. */
3837 gl_info
->gl_ops
.gl
.p_glLoadMatrixf(&state
->transforms
[WINED3D_TS_VIEW
]._11
);
3838 checkGLcall("glLoadMatrixf");
3839 gl_info
->gl_ops
.gl
.p_glMultMatrixf(&state
->transforms
[WINED3D_TS_WORLD_MATRIX(matrix
)]._11
);
3840 checkGLcall("glMultMatrixf");
3843 static void state_vertexblend_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3845 enum wined3d_vertex_blend_flags f
= state
->render_states
[WINED3D_RS_VERTEXBLEND
];
3846 static unsigned int once
;
3848 if (f
== WINED3D_VBF_DISABLE
)
3851 if (!once
++) FIXME("Vertex blend flags %#x not supported.\n", f
);
3852 else WARN("Vertex blend flags %#x not supported.\n", f
);
3855 static void state_vertexblend(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3857 enum wined3d_vertex_blend_flags val
= state
->render_states
[WINED3D_RS_VERTEXBLEND
];
3858 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3859 struct wined3d_device
*device
= context
->device
;
3860 static unsigned int once
;
3864 case WINED3D_VBF_1WEIGHTS
:
3865 case WINED3D_VBF_2WEIGHTS
:
3866 case WINED3D_VBF_3WEIGHTS
:
3867 gl_info
->gl_ops
.gl
.p_glEnable(GL_VERTEX_BLEND_ARB
);
3868 checkGLcall("glEnable(GL_VERTEX_BLEND_ARB)");
3870 /* D3D adds one more matrix which has weight (1 - sum(weights)).
3871 * This is enabled at context creation with enabling
3872 * GL_WEIGHT_SUM_UNITY_ARB. */
3873 GL_EXTCALL(glVertexBlendARB(state
->render_states
[WINED3D_RS_VERTEXBLEND
] + 1));
3875 if (!device
->vertexBlendUsed
)
3878 for (i
= 1; i
< gl_info
->limits
.blends
; ++i
)
3880 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(i
))))
3881 transform_worldex(context
, state
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(i
)));
3883 device
->vertexBlendUsed
= TRUE
;
3887 case WINED3D_VBF_TWEENING
:
3888 case WINED3D_VBF_0WEIGHTS
: /* Indexed vertex blending, not supported. */
3889 if (!once
++) FIXME("Vertex blend flags %#x not supported.\n", val
);
3890 else WARN("Vertex blend flags %#x not supported.\n", val
);
3892 case WINED3D_VBF_DISABLE
:
3893 gl_info
->gl_ops
.gl
.p_glDisable(GL_VERTEX_BLEND_ARB
);
3894 checkGLcall("glDisable(GL_VERTEX_BLEND_ARB)");
3899 static void transform_view(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3901 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3902 const struct wined3d_light_info
*light
= NULL
;
3905 /* If we are changing the View matrix, reset the light and clipping planes to the new view
3906 * NOTE: We have to reset the positions even if the light/plane is not currently
3907 * enabled, since the call to enable it will not reset the position.
3908 * NOTE2: Apparently texture transforms do NOT need reapplying
3911 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
3912 checkGLcall("glMatrixMode(GL_MODELVIEW)");
3913 gl_info
->gl_ops
.gl
.p_glLoadMatrixf(&state
->transforms
[WINED3D_TS_VIEW
]._11
);
3914 checkGLcall("glLoadMatrixf(...)");
3916 /* Reset lights. TODO: Call light apply func */
3917 for (k
= 0; k
< gl_info
->limits
.lights
; ++k
)
3919 if (!(light
= state
->lights
[k
]))
3921 if (light
->OriginalParms
.type
== WINED3D_LIGHT_DIRECTIONAL
)
3922 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ light
->glIndex
, GL_POSITION
, &light
->direction
.x
);
3924 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ light
->glIndex
, GL_POSITION
, &light
->position
.x
);
3925 checkGLcall("glLightfv posn");
3926 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ light
->glIndex
, GL_SPOT_DIRECTION
, &light
->direction
.x
);
3927 checkGLcall("glLightfv dirn");
3930 /* Reset Clipping Planes */
3931 for (k
= 0; k
< gl_info
->limits
.user_clip_distances
; ++k
)
3933 if (!isStateDirty(context
, STATE_CLIPPLANE(k
)))
3934 clipplane(context
, state
, STATE_CLIPPLANE(k
));
3937 if (context
->last_was_rhw
)
3939 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
3940 checkGLcall("glLoadIdentity()");
3941 /* No need to update the world matrix, the identity is fine */
3945 /* Call the world matrix state, this will apply the combined WORLD + VIEW matrix
3946 * No need to do it here if the state is scheduled for update. */
3947 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0))))
3948 transform_world(context
, state
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0)));
3950 /* Avoid looping over a number of matrices if the app never used the functionality */
3951 if (context
->device
->vertexBlendUsed
)
3953 for (k
= 1; k
< gl_info
->limits
.blends
; ++k
)
3955 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(k
))))
3956 transform_worldex(context
, state
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(k
)));
3961 static void transform_projection(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3963 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3964 struct wined3d_matrix projection
;
3966 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_PROJECTION
);
3967 checkGLcall("glMatrixMode(GL_PROJECTION)");
3969 get_projection_matrix(context
, state
, &projection
);
3970 gl_info
->gl_ops
.gl
.p_glLoadMatrixf(&projection
._11
);
3971 checkGLcall("glLoadMatrixf");
3974 /* This should match any arrays loaded in load_vertex_data.
3975 * TODO: Only load / unload arrays if we have to. */
3976 static void unload_vertex_data(const struct wined3d_gl_info
*gl_info
)
3978 gl_info
->gl_ops
.gl
.p_glDisableClientState(GL_VERTEX_ARRAY
);
3979 gl_info
->gl_ops
.gl
.p_glDisableClientState(GL_NORMAL_ARRAY
);
3980 gl_info
->gl_ops
.gl
.p_glDisableClientState(GL_COLOR_ARRAY
);
3981 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
3982 gl_info
->gl_ops
.gl
.p_glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT
);
3983 if (gl_info
->supported
[ARB_VERTEX_BLEND
])
3984 gl_info
->gl_ops
.gl
.p_glDisableClientState(GL_WEIGHT_ARRAY_ARB
);
3985 unload_tex_coords(gl_info
);
3988 static inline void unload_numbered_array(struct wined3d_context
*context
, int i
)
3990 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3992 GL_EXTCALL(glDisableVertexAttribArray(i
));
3993 checkGLcall("glDisableVertexAttribArray");
3994 if (gl_info
->supported
[ARB_INSTANCED_ARRAYS
])
3995 GL_EXTCALL(glVertexAttribDivisor(i
, 0));
3997 context
->numbered_array_mask
&= ~(1u << i
);
4000 /* This should match any arrays loaded in loadNumberedArrays
4001 * TODO: Only load / unload arrays if we have to. */
4002 static void unload_numbered_arrays(struct wined3d_context
*context
)
4004 /* disable any attribs (this is the same for both GLSL and ARB modes) */
4007 for (i
= 0; i
< context
->gl_info
->limits
.vertex_attribs
; ++i
) {
4008 unload_numbered_array(context
, i
);
4012 static void load_numbered_arrays(struct wined3d_context
*context
,
4013 const struct wined3d_stream_info
*stream_info
, const struct wined3d_state
*state
)
4015 const struct wined3d_shader
*vs
= state
->shader
[WINED3D_SHADER_TYPE_VERTEX
];
4016 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4017 GLuint curVBO
= gl_info
->supported
[ARB_VERTEX_BUFFER_OBJECT
] ? ~0U : 0;
4020 /* Default to no instancing */
4021 context
->instance_count
= 0;
4023 for (i
= 0; i
< MAX_ATTRIBS
; ++i
)
4025 const struct wined3d_stream_info_element
*element
= &stream_info
->elements
[i
];
4026 const struct wined3d_stream_state
*stream
;
4028 if (!(stream_info
->use_map
& (1u << i
)))
4030 if (context
->numbered_array_mask
& (1u << i
))
4031 unload_numbered_array(context
, i
);
4032 if (!use_vs(state
) && i
== WINED3D_FFP_DIFFUSE
)
4033 GL_EXTCALL(glVertexAttrib4f(i
, 1.0f
, 1.0f
, 1.0f
, 1.0f
));
4035 GL_EXTCALL(glVertexAttrib4f(i
, 0.0f
, 0.0f
, 0.0f
, 0.0f
));
4039 stream
= &state
->streams
[element
->stream_idx
];
4041 if ((stream
->flags
& WINED3DSTREAMSOURCE_INSTANCEDATA
) && !context
->instance_count
)
4042 context
->instance_count
= state
->streams
[0].frequency
? state
->streams
[0].frequency
: 1;
4044 if (gl_info
->supported
[ARB_INSTANCED_ARRAYS
])
4046 GL_EXTCALL(glVertexAttribDivisor(i
, element
->divisor
));
4048 else if (element
->divisor
)
4050 /* Unload instanced arrays, they will be loaded using
4051 * immediate mode instead. */
4052 if (context
->numbered_array_mask
& (1u << i
))
4053 unload_numbered_array(context
, i
);
4057 TRACE_(d3d_shader
)("Loading array %u [VBO=%u].\n", i
, element
->data
.buffer_object
);
4059 if (element
->stride
)
4061 if (curVBO
!= element
->data
.buffer_object
)
4063 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER
, element
->data
.buffer_object
));
4064 checkGLcall("glBindBuffer");
4065 curVBO
= element
->data
.buffer_object
;
4067 /* Use the VBO to find out if a vertex buffer exists, not the vb
4068 * pointer. vb can point to a user pointer data blob. In that case
4069 * curVBO will be 0. If there is a vertex buffer but no vbo we
4070 * won't be load converted attributes anyway. */
4071 if (vs
&& vs
->reg_maps
.shader_version
.major
>= 4
4072 && (element
->format
->flags
[WINED3D_GL_RES_TYPE_BUFFER
] & WINED3DFMT_FLAG_INTEGER
))
4074 GL_EXTCALL(glVertexAttribIPointer(i
, element
->format
->gl_vtx_format
, element
->format
->gl_vtx_type
,
4075 element
->stride
, element
->data
.addr
+ state
->load_base_vertex_index
* element
->stride
));
4079 GL_EXTCALL(glVertexAttribPointer(i
, element
->format
->gl_vtx_format
, element
->format
->gl_vtx_type
,
4080 element
->format
->gl_normalized
, element
->stride
,
4081 element
->data
.addr
+ state
->load_base_vertex_index
* element
->stride
));
4084 if (!(context
->numbered_array_mask
& (1u << i
)))
4086 GL_EXTCALL(glEnableVertexAttribArray(i
));
4087 context
->numbered_array_mask
|= (1u << i
);
4092 /* Stride = 0 means always the same values.
4093 * glVertexAttribPointer doesn't do that. Instead disable the
4094 * pointer and set up the attribute statically. But we have to
4095 * figure out the system memory address. */
4096 const BYTE
*ptr
= element
->data
.addr
;
4097 if (element
->data
.buffer_object
)
4098 ptr
+= (ULONG_PTR
)wined3d_buffer_load_sysmem(stream
->buffer
, context
);
4100 if (context
->numbered_array_mask
& (1u << i
))
4101 unload_numbered_array(context
, i
);
4103 switch (element
->format
->id
)
4105 case WINED3DFMT_R32_FLOAT
:
4106 GL_EXTCALL(glVertexAttrib1fv(i
, (const GLfloat
*)ptr
));
4108 case WINED3DFMT_R32G32_FLOAT
:
4109 GL_EXTCALL(glVertexAttrib2fv(i
, (const GLfloat
*)ptr
));
4111 case WINED3DFMT_R32G32B32_FLOAT
:
4112 GL_EXTCALL(glVertexAttrib3fv(i
, (const GLfloat
*)ptr
));
4114 case WINED3DFMT_R32G32B32A32_FLOAT
:
4115 GL_EXTCALL(glVertexAttrib4fv(i
, (const GLfloat
*)ptr
));
4118 case WINED3DFMT_R8G8B8A8_UINT
:
4119 GL_EXTCALL(glVertexAttrib4ubv(i
, ptr
));
4121 case WINED3DFMT_B8G8R8A8_UNORM
:
4122 if (gl_info
->supported
[ARB_VERTEX_ARRAY_BGRA
])
4124 const DWORD
*src
= (const DWORD
*)ptr
;
4125 DWORD c
= *src
& 0xff00ff00u
;
4126 c
|= (*src
& 0xff0000u
) >> 16;
4127 c
|= (*src
& 0xffu
) << 16;
4128 GL_EXTCALL(glVertexAttrib4Nubv(i
, (GLubyte
*)&c
));
4131 /* else fallthrough */
4132 case WINED3DFMT_R8G8B8A8_UNORM
:
4133 GL_EXTCALL(glVertexAttrib4Nubv(i
, ptr
));
4136 case WINED3DFMT_R16G16_SINT
:
4137 GL_EXTCALL(glVertexAttrib2sv(i
, (const GLshort
*)ptr
));
4139 case WINED3DFMT_R16G16B16A16_SINT
:
4140 GL_EXTCALL(glVertexAttrib4sv(i
, (const GLshort
*)ptr
));
4143 case WINED3DFMT_R16G16_SNORM
:
4145 const GLshort s
[4] = {((const GLshort
*)ptr
)[0], ((const GLshort
*)ptr
)[1], 0, 1};
4146 GL_EXTCALL(glVertexAttrib4Nsv(i
, s
));
4149 case WINED3DFMT_R16G16_UNORM
:
4151 const GLushort s
[4] = {((const GLushort
*)ptr
)[0], ((const GLushort
*)ptr
)[1], 0, 1};
4152 GL_EXTCALL(glVertexAttrib4Nusv(i
, s
));
4155 case WINED3DFMT_R16G16B16A16_SNORM
:
4156 GL_EXTCALL(glVertexAttrib4Nsv(i
, (const GLshort
*)ptr
));
4158 case WINED3DFMT_R16G16B16A16_UNORM
:
4159 GL_EXTCALL(glVertexAttrib4Nusv(i
, (const GLushort
*)ptr
));
4162 case WINED3DFMT_R10G10B10X2_UINT
:
4163 FIXME("Unsure about WINED3DDECLTYPE_UDEC3.\n");
4164 /*glVertexAttrib3usvARB(i, (const GLushort *)ptr); Does not exist */
4166 case WINED3DFMT_R10G10B10X2_SNORM
:
4167 FIXME("Unsure about WINED3DDECLTYPE_DEC3N.\n");
4168 /*glVertexAttrib3NusvARB(i, (const GLushort *)ptr); Does not exist */
4171 case WINED3DFMT_R16G16_FLOAT
:
4172 if (gl_info
->supported
[NV_HALF_FLOAT
] && gl_info
->supported
[NV_VERTEX_PROGRAM
])
4174 /* Not supported by GL_ARB_half_float_vertex. */
4175 GL_EXTCALL(glVertexAttrib2hvNV(i
, (const GLhalfNV
*)ptr
));
4179 float x
= float_16_to_32(((const unsigned short *)ptr
) + 0);
4180 float y
= float_16_to_32(((const unsigned short *)ptr
) + 1);
4181 GL_EXTCALL(glVertexAttrib2f(i
, x
, y
));
4184 case WINED3DFMT_R16G16B16A16_FLOAT
:
4185 if (gl_info
->supported
[NV_HALF_FLOAT
] && gl_info
->supported
[NV_VERTEX_PROGRAM
])
4187 /* Not supported by GL_ARB_half_float_vertex. */
4188 GL_EXTCALL(glVertexAttrib4hvNV(i
, (const GLhalfNV
*)ptr
));
4192 float x
= float_16_to_32(((const unsigned short *)ptr
) + 0);
4193 float y
= float_16_to_32(((const unsigned short *)ptr
) + 1);
4194 float z
= float_16_to_32(((const unsigned short *)ptr
) + 2);
4195 float w
= float_16_to_32(((const unsigned short *)ptr
) + 3);
4196 GL_EXTCALL(glVertexAttrib4f(i
, x
, y
, z
, w
));
4201 ERR("Unexpected declaration in stride 0 attributes.\n");
4207 checkGLcall("Loading numbered arrays");
4210 static void load_vertex_data(struct wined3d_context
*context
,
4211 const struct wined3d_stream_info
*si
, const struct wined3d_state
*state
)
4213 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4214 GLuint curVBO
= gl_info
->supported
[ARB_VERTEX_BUFFER_OBJECT
] ? ~0U : 0;
4215 const struct wined3d_stream_info_element
*e
;
4217 TRACE("Using fast vertex array code\n");
4219 /* This is fixed function pipeline only, and the fixed function pipeline doesn't do instancing */
4220 context
->instance_count
= 0;
4222 /* Blend Data ---------------------------------------------- */
4223 if ((si
->use_map
& (1u << WINED3D_FFP_BLENDWEIGHT
))
4224 || si
->use_map
& (1u << WINED3D_FFP_BLENDINDICES
))
4226 e
= &si
->elements
[WINED3D_FFP_BLENDWEIGHT
];
4228 if (gl_info
->supported
[ARB_VERTEX_BLEND
])
4230 TRACE("Blend %u %p %u\n", e
->format
->component_count
,
4231 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
, e
->stride
);
4233 gl_info
->gl_ops
.gl
.p_glEnableClientState(GL_WEIGHT_ARRAY_ARB
);
4234 checkGLcall("glEnableClientState(GL_WEIGHT_ARRAY_ARB)");
4236 GL_EXTCALL(glVertexBlendARB(e
->format
->component_count
+ 1));
4238 if (curVBO
!= e
->data
.buffer_object
)
4240 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER
, e
->data
.buffer_object
));
4241 checkGLcall("glBindBuffer");
4242 curVBO
= e
->data
.buffer_object
;
4245 TRACE("glWeightPointerARB(%#x, %#x, %#x, %p);\n",
4246 e
->format
->gl_vtx_format
,
4247 e
->format
->gl_vtx_type
,
4249 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4250 GL_EXTCALL(glWeightPointerARB(e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
4251 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
));
4253 checkGLcall("glWeightPointerARB");
4255 if (si
->use_map
& (1u << WINED3D_FFP_BLENDINDICES
))
4260 FIXME("blendMatrixIndices support\n");
4267 /* TODO: Support vertex blending in immediate mode draws. No need
4268 * to write a FIXME here, this is done after the general vertex
4269 * declaration decoding. */
4270 WARN("Vertex blending not supported.\n");
4275 if (gl_info
->supported
[ARB_VERTEX_BLEND
])
4277 static const GLbyte one
= 1;
4278 GL_EXTCALL(glWeightbvARB(1, &one
));
4279 checkGLcall("glWeightbvARB(gl_info->max_blends, weights)");
4283 /* Point Size ----------------------------------------------*/
4284 if (si
->use_map
& (1u << WINED3D_FFP_PSIZE
))
4286 /* no such functionality in the fixed function GL pipeline */
4287 TRACE("Cannot change ptSize here in openGl\n");
4288 /* TODO: Implement this function in using shaders if they are available */
4291 /* Vertex Pointers -----------------------------------------*/
4292 if (si
->use_map
& (1u << WINED3D_FFP_POSITION
))
4294 e
= &si
->elements
[WINED3D_FFP_POSITION
];
4296 if (curVBO
!= e
->data
.buffer_object
)
4298 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER
, e
->data
.buffer_object
));
4299 checkGLcall("glBindBuffer");
4300 curVBO
= e
->data
.buffer_object
;
4303 TRACE("glVertexPointer(%#x, %#x, %#x, %p);\n",
4304 e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
4305 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4306 gl_info
->gl_ops
.gl
.p_glVertexPointer(e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
4307 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4308 checkGLcall("glVertexPointer(...)");
4309 gl_info
->gl_ops
.gl
.p_glEnableClientState(GL_VERTEX_ARRAY
);
4310 checkGLcall("glEnableClientState(GL_VERTEX_ARRAY)");
4313 /* Normals -------------------------------------------------*/
4314 if (si
->use_map
& (1u << WINED3D_FFP_NORMAL
))
4316 e
= &si
->elements
[WINED3D_FFP_NORMAL
];
4318 if (curVBO
!= e
->data
.buffer_object
)
4320 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER
, e
->data
.buffer_object
));
4321 checkGLcall("glBindBuffer");
4322 curVBO
= e
->data
.buffer_object
;
4325 TRACE("glNormalPointer(%#x, %#x, %p);\n", e
->format
->gl_vtx_type
, e
->stride
,
4326 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4327 gl_info
->gl_ops
.gl
.p_glNormalPointer(e
->format
->gl_vtx_type
, e
->stride
,
4328 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4329 checkGLcall("glNormalPointer(...)");
4330 gl_info
->gl_ops
.gl
.p_glEnableClientState(GL_NORMAL_ARRAY
);
4331 checkGLcall("glEnableClientState(GL_NORMAL_ARRAY)");
4336 gl_info
->gl_ops
.gl
.p_glNormal3f(0, 0, 0);
4337 checkGLcall("glNormal3f(0, 0, 0)");
4340 /* Diffuse Colour --------------------------------------------*/
4341 if (si
->use_map
& (1u << WINED3D_FFP_DIFFUSE
))
4343 e
= &si
->elements
[WINED3D_FFP_DIFFUSE
];
4345 if (curVBO
!= e
->data
.buffer_object
)
4347 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER
, e
->data
.buffer_object
));
4348 checkGLcall("glBindBuffer");
4349 curVBO
= e
->data
.buffer_object
;
4352 TRACE("glColorPointer(%#x, %#x %#x, %p);\n",
4353 e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
4354 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4355 gl_info
->gl_ops
.gl
.p_glColorPointer(e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
4356 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4357 checkGLcall("glColorPointer(4, GL_UNSIGNED_BYTE, ...)");
4358 gl_info
->gl_ops
.gl
.p_glEnableClientState(GL_COLOR_ARRAY
);
4359 checkGLcall("glEnableClientState(GL_COLOR_ARRAY)");
4364 gl_info
->gl_ops
.gl
.p_glColor4f(1.0f
, 1.0f
, 1.0f
, 1.0f
);
4365 checkGLcall("glColor4f(1, 1, 1, 1)");
4368 /* Specular Colour ------------------------------------------*/
4369 if (si
->use_map
& (1u << WINED3D_FFP_SPECULAR
))
4371 TRACE("setting specular colour\n");
4373 e
= &si
->elements
[WINED3D_FFP_SPECULAR
];
4375 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
4377 GLenum type
= e
->format
->gl_vtx_type
;
4378 GLint format
= e
->format
->gl_vtx_format
;
4380 if (curVBO
!= e
->data
.buffer_object
)
4382 GL_EXTCALL(glBindBuffer(GL_ARRAY_BUFFER
, e
->data
.buffer_object
));
4383 checkGLcall("glBindBuffer");
4384 curVBO
= e
->data
.buffer_object
;
4387 if (format
!= 4 || (gl_info
->quirks
& WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA
))
4389 /* Usually specular colors only allow 3 components, since they have no alpha. In D3D, the specular alpha
4390 * contains the fog coordinate, which is passed to GL with GL_EXT_fog_coord. However, the fixed function
4391 * vertex pipeline can pass the specular alpha through, and pixel shaders can read it. So it GL accepts
4392 * 4 component secondary colors use it
4394 TRACE("glSecondaryColorPointer(%#x, %#x, %#x, %p);\n", format
, type
, e
->stride
,
4395 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4396 GL_EXTCALL(glSecondaryColorPointerEXT(format
, type
, e
->stride
,
4397 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
));
4398 checkGLcall("glSecondaryColorPointerEXT(format, type, ...)");
4404 case GL_UNSIGNED_BYTE
:
4405 TRACE("glSecondaryColorPointer(3, GL_UNSIGNED_BYTE, %#x, %p);\n", e
->stride
,
4406 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4407 GL_EXTCALL(glSecondaryColorPointerEXT(3, GL_UNSIGNED_BYTE
, e
->stride
,
4408 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
));
4409 checkGLcall("glSecondaryColorPointerEXT(3, GL_UNSIGNED_BYTE, ...)");
4413 FIXME("Add 4 component specular color pointers for type %x\n", type
);
4414 /* Make sure that the right color component is dropped */
4415 TRACE("glSecondaryColorPointer(3, %#x, %#x, %p);\n", type
, e
->stride
,
4416 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4417 GL_EXTCALL(glSecondaryColorPointerEXT(3, type
, e
->stride
,
4418 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
));
4419 checkGLcall("glSecondaryColorPointerEXT(3, type, ...)");
4422 gl_info
->gl_ops
.gl
.p_glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT
);
4423 checkGLcall("glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
4427 WARN("Specular colour is not supported in this GL implementation.\n");
4432 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
4434 GL_EXTCALL(glSecondaryColor3fEXT
)(0, 0, 0);
4435 checkGLcall("glSecondaryColor3fEXT(0, 0, 0)");
4439 WARN("Specular colour is not supported in this GL implementation.\n");
4443 /* Texture coords -------------------------------------------*/
4444 load_tex_coords(context
, si
, &curVBO
, state
);
4447 static void streamsrc(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4449 BOOL load_numbered
= context
->d3d_info
->ffp_generic_attributes
4450 || (use_vs(state
) && !context
->use_immediate_mode_draw
);
4451 BOOL load_named
= !context
->d3d_info
->ffp_generic_attributes
4452 && !use_vs(state
) && !context
->use_immediate_mode_draw
;
4454 if (isStateDirty(context
, STATE_VDECL
)) return;
4455 if (context
->numberedArraysLoaded
&& !load_numbered
)
4457 unload_numbered_arrays(context
);
4458 context
->numberedArraysLoaded
= FALSE
;
4459 context
->numbered_array_mask
= 0;
4461 else if (context
->namedArraysLoaded
)
4463 unload_vertex_data(context
->gl_info
);
4464 context
->namedArraysLoaded
= FALSE
;
4469 TRACE("Loading numbered arrays\n");
4470 load_numbered_arrays(context
, &context
->stream_info
, state
);
4471 context
->numberedArraysLoaded
= TRUE
;
4473 else if (load_named
)
4475 TRACE("Loading vertex data\n");
4476 load_vertex_data(context
, &context
->stream_info
, state
);
4477 context
->namedArraysLoaded
= TRUE
;
4481 static void vdecl_miscpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4483 if (isStateDirty(context
, STATE_STREAMSRC
))
4485 streamsrc(context
, state
, STATE_STREAMSRC
);
4488 static void vertexdeclaration(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4490 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4491 BOOL useVertexShaderFunction
= use_vs(state
);
4492 BOOL updateFog
= FALSE
;
4494 BOOL wasrhw
= context
->last_was_rhw
;
4497 transformed
= context
->stream_info
.position_transformed
;
4498 if (transformed
!= context
->last_was_rhw
&& !useVertexShaderFunction
)
4501 context
->last_was_rhw
= transformed
;
4503 if (context
->stream_info
.swizzle_map
!= context
->last_swizzle_map
)
4504 context
->shader_update_mask
|= 1u << WINED3D_SHADER_TYPE_VERTEX
;
4506 context
->last_swizzle_map
= context
->stream_info
.swizzle_map
;
4508 /* Don't have to apply the matrices when vertex shaders are used. When
4509 * vshaders are turned off this function will be called again anyway to
4510 * make sure they're properly set. */
4511 if (!useVertexShaderFunction
)
4513 /* TODO: Move this mainly to the viewport state and only apply when
4514 * the vp has changed or transformed / untransformed was switched. */
4515 if (wasrhw
!= context
->last_was_rhw
4516 && !isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
))
4517 && !isStateDirty(context
, STATE_VIEWPORT
))
4518 transform_projection(context
, state
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
));
4519 /* World matrix needs reapplication here only if we're switching between rhw and non-rhw
4522 * If a vertex shader is used, the world matrix changed and then vertex shader unbound
4523 * this check will fail and the matrix not applied again. This is OK because a simple
4524 * world matrix change reapplies the matrix - These checks here are only to satisfy the
4525 * needs of the vertex declaration.
4527 * World and view matrix go into the same gl matrix, so only apply them when neither is
4530 if (transformed
!= wasrhw
&& !isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0)))
4531 && !isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_VIEW
)))
4532 transform_world(context
, state
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0)));
4533 if (!isStateDirty(context
, STATE_RENDER(WINED3D_RS_COLORVERTEX
)))
4534 context_apply_state(context
, state
, STATE_RENDER(WINED3D_RS_COLORVERTEX
));
4535 if (!isStateDirty(context
, STATE_RENDER(WINED3D_RS_LIGHTING
)))
4536 state_lighting(context
, state
, STATE_RENDER(WINED3D_RS_LIGHTING
));
4538 if (context
->last_was_vshader
)
4542 if (!context
->d3d_info
->vs_clipping
4543 && !isStateDirty(context
, STATE_RENDER(WINED3D_RS_CLIPPLANEENABLE
)))
4545 state_clipping(context
, state
, STATE_RENDER(WINED3D_RS_CLIPPLANEENABLE
));
4548 for (i
= 0; i
< gl_info
->limits
.user_clip_distances
; ++i
)
4550 clipplane(context
, state
, STATE_CLIPPLANE(i
));
4553 if (!isStateDirty(context
, STATE_RENDER(WINED3D_RS_NORMALIZENORMALS
)))
4554 state_normalize(context
, state
, STATE_RENDER(WINED3D_RS_NORMALIZENORMALS
));
4558 if(!context
->last_was_vshader
) {
4559 static BOOL warned
= FALSE
;
4560 if (!context
->d3d_info
->vs_clipping
)
4562 /* Disable all clip planes to get defined results on all drivers. See comment in the
4563 * state_clipping state handler
4565 for (i
= 0; i
< gl_info
->limits
.user_clip_distances
; ++i
)
4567 gl_info
->gl_ops
.gl
.p_glDisable(GL_CLIP_PLANE0
+ i
);
4568 checkGLcall("glDisable(GL_CLIP_PLANE0 + i)");
4571 if (!warned
&& state
->render_states
[WINED3D_RS_CLIPPLANEENABLE
])
4573 FIXME("Clipping not supported with vertex shaders\n");
4579 /* Apply the transform matrices when switching from rhw
4580 * drawing to vertex shaders. Vertex shaders themselves do
4581 * not need it, but the matrices are not reapplied
4582 * automatically when switching back from vertex shaders to
4583 * fixed function processing. So make sure we leave the fixed
4584 * function vertex processing states back in a sane state
4585 * before switching to shaders. */
4586 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
)))
4587 transform_projection(context
, state
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
));
4588 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0))))
4589 transform_world(context
, state
, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0)));
4593 /* Vertex shader clipping ignores the view matrix. Update all clipplanes
4594 * (Note: ARB shaders can read the clip planes for clipping emulation even if
4595 * device->vs_clipping is false.
4597 for (i
= 0; i
< gl_info
->limits
.user_clip_distances
; ++i
)
4599 clipplane(context
, state
, STATE_CLIPPLANE(i
));
4604 context
->last_was_vshader
= useVertexShaderFunction
;
4605 context
->shader_update_mask
|= 1u << WINED3D_SHADER_TYPE_VERTEX
;
4608 context_apply_state(context
, state
, STATE_RENDER(WINED3D_RS_FOGVERTEXMODE
));
4610 if (!useVertexShaderFunction
)
4614 for (i
= 0; i
< MAX_TEXTURES
; ++i
)
4616 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_TEXTURE0
+ i
)))
4617 transform_texture(context
, state
, STATE_TEXTURESTAGE(i
, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
));
4620 if (use_ps(state
) && state
->shader
[WINED3D_SHADER_TYPE_PIXEL
]->reg_maps
.shader_version
.major
== 1
4621 && state
->shader
[WINED3D_SHADER_TYPE_PIXEL
]->reg_maps
.shader_version
.minor
<= 3)
4622 context
->shader_update_mask
|= 1u << WINED3D_SHADER_TYPE_PIXEL
;
4626 static void viewport_miscpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4628 const struct wined3d_rendertarget_view
*depth_stencil
= state
->fb
->depth_stencil
;
4629 const struct wined3d_rendertarget_view
*target
= state
->fb
->render_targets
[0];
4630 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4631 struct wined3d_viewport vp
= state
->viewport
;
4632 unsigned int width
, height
;
4636 if (vp
.width
> target
->width
)
4637 vp
.width
= target
->width
;
4638 if (vp
.height
> target
->height
)
4639 vp
.height
= target
->height
;
4641 wined3d_rendertarget_view_get_drawable_size(target
, context
, &width
, &height
);
4643 else if (depth_stencil
)
4645 width
= depth_stencil
->width
;
4646 height
= depth_stencil
->height
;
4650 FIXME("No attachments draw calls not supported.\n");
4654 gl_info
->gl_ops
.gl
.p_glDepthRange(vp
.min_z
, vp
.max_z
);
4655 checkGLcall("glDepthRange");
4656 /* Note: GL requires lower left, DirectX supplies upper left. This is
4657 * reversed when using offscreen rendering. */
4658 if (context
->render_offscreen
)
4659 gl_info
->gl_ops
.gl
.p_glViewport(vp
.x
, vp
.y
, vp
.width
, vp
.height
);
4661 gl_info
->gl_ops
.gl
.p_glViewport(vp
.x
, (height
- (vp
.y
+ vp
.height
)), vp
.width
, vp
.height
);
4662 checkGLcall("glViewport");
4665 static void viewport_miscpart_cc(struct wined3d_context
*context
,
4666 const struct wined3d_state
*state
, DWORD state_id
)
4668 const struct wined3d_rendertarget_view
*depth_stencil
= state
->fb
->depth_stencil
;
4669 const struct wined3d_rendertarget_view
*target
= state
->fb
->render_targets
[0];
4670 /* See get_projection_matrix() in utils.c for a discussion about those
4672 float pixel_center_offset
= context
->d3d_info
->wined3d_creation_flags
4673 & WINED3D_PIXEL_CENTER_INTEGER
? 63.0f
/ 128.0f
: -1.0f
/ 128.0f
;
4674 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4675 struct wined3d_viewport vp
= state
->viewport
;
4676 unsigned int width
, height
;
4680 if (vp
.width
> target
->width
)
4681 vp
.width
= target
->width
;
4682 if (vp
.height
> target
->height
)
4683 vp
.height
= target
->height
;
4685 wined3d_rendertarget_view_get_drawable_size(target
, context
, &width
, &height
);
4687 else if (depth_stencil
)
4689 width
= depth_stencil
->width
;
4690 height
= depth_stencil
->height
;
4694 FIXME("No attachments draw calls not supported.\n");
4698 gl_info
->gl_ops
.gl
.p_glDepthRange(vp
.min_z
, vp
.max_z
);
4699 checkGLcall("glDepthRange");
4701 if (context
->render_offscreen
)
4703 GL_EXTCALL(glClipControl(GL_UPPER_LEFT
, GL_ZERO_TO_ONE
));
4704 GL_EXTCALL(glViewportIndexedf(0, vp
.x
+ pixel_center_offset
, vp
.y
+ pixel_center_offset
,
4705 vp
.width
, vp
.height
));
4709 GL_EXTCALL(glClipControl(GL_LOWER_LEFT
, GL_ZERO_TO_ONE
));
4710 GL_EXTCALL(glViewportIndexedf(0, vp
.x
+ pixel_center_offset
,
4711 (height
- (vp
.y
+ vp
.height
)) + pixel_center_offset
, vp
.width
, vp
.height
));
4713 checkGLcall("setting clip space and viewport");
4716 static void viewport_vertexpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4718 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
)))
4719 transform_projection(context
, state
, STATE_TRANSFORM(WINED3D_TS_PROJECTION
));
4720 if (!isStateDirty(context
, STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
))
4721 && state
->render_states
[WINED3D_RS_POINTSCALEENABLE
])
4722 state_pscale(context
, state
, STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
));
4723 /* Update the position fixup. */
4724 context
->constant_update_mask
|= WINED3D_SHADER_CONST_POS_FIXUP
;
4727 static void light(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4729 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4730 UINT Index
= state_id
- STATE_ACTIVELIGHT(0);
4731 const struct wined3d_light_info
*lightInfo
= state
->lights
[Index
];
4735 gl_info
->gl_ops
.gl
.p_glDisable(GL_LIGHT0
+ Index
);
4736 checkGLcall("glDisable(GL_LIGHT0 + Index)");
4741 float colRGBA
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
4743 /* Light settings are affected by the model view in OpenGL, the View transform in direct3d*/
4744 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
4745 gl_info
->gl_ops
.gl
.p_glPushMatrix();
4746 gl_info
->gl_ops
.gl
.p_glLoadMatrixf(&state
->transforms
[WINED3D_TS_VIEW
]._11
);
4749 colRGBA
[0] = lightInfo
->OriginalParms
.diffuse
.r
;
4750 colRGBA
[1] = lightInfo
->OriginalParms
.diffuse
.g
;
4751 colRGBA
[2] = lightInfo
->OriginalParms
.diffuse
.b
;
4752 colRGBA
[3] = lightInfo
->OriginalParms
.diffuse
.a
;
4753 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_DIFFUSE
, colRGBA
);
4754 checkGLcall("glLightfv");
4757 colRGBA
[0] = lightInfo
->OriginalParms
.specular
.r
;
4758 colRGBA
[1] = lightInfo
->OriginalParms
.specular
.g
;
4759 colRGBA
[2] = lightInfo
->OriginalParms
.specular
.b
;
4760 colRGBA
[3] = lightInfo
->OriginalParms
.specular
.a
;
4761 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_SPECULAR
, colRGBA
);
4762 checkGLcall("glLightfv");
4765 colRGBA
[0] = lightInfo
->OriginalParms
.ambient
.r
;
4766 colRGBA
[1] = lightInfo
->OriginalParms
.ambient
.g
;
4767 colRGBA
[2] = lightInfo
->OriginalParms
.ambient
.b
;
4768 colRGBA
[3] = lightInfo
->OriginalParms
.ambient
.a
;
4769 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_AMBIENT
, colRGBA
);
4770 checkGLcall("glLightfv");
4772 if ((lightInfo
->OriginalParms
.range
* lightInfo
->OriginalParms
.range
) >= FLT_MIN
)
4773 quad_att
= 1.4f
/ (lightInfo
->OriginalParms
.range
* lightInfo
->OriginalParms
.range
);
4775 quad_att
= 0.0f
; /* 0 or MAX? (0 seems to be ok) */
4777 /* Do not assign attenuation values for lights that do not use them. D3D apps are free to pass any junk,
4778 * but gl drivers use them and may crash due to bad Attenuation values. Need for Speed most wanted sets
4779 * Attenuation0 to NaN and crashes in the gl lib
4782 switch (lightInfo
->OriginalParms
.type
)
4784 case WINED3D_LIGHT_POINT
:
4786 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->position
.x
);
4787 checkGLcall("glLightfv");
4788 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
4789 checkGLcall("glLightf");
4790 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_CONSTANT_ATTENUATION
,
4791 lightInfo
->OriginalParms
.attenuation0
);
4792 checkGLcall("glLightf");
4793 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_LINEAR_ATTENUATION
,
4794 lightInfo
->OriginalParms
.attenuation1
);
4795 checkGLcall("glLightf");
4796 if (quad_att
< lightInfo
->OriginalParms
.attenuation2
)
4797 quad_att
= lightInfo
->OriginalParms
.attenuation2
;
4798 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_QUADRATIC_ATTENUATION
, quad_att
);
4799 checkGLcall("glLightf");
4803 case WINED3D_LIGHT_SPOT
:
4805 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->position
.x
);
4806 checkGLcall("glLightfv");
4808 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_SPOT_DIRECTION
, &lightInfo
->direction
.x
);
4809 checkGLcall("glLightfv");
4810 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_SPOT_EXPONENT
, lightInfo
->exponent
);
4811 checkGLcall("glLightf");
4812 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
4813 checkGLcall("glLightf");
4814 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_CONSTANT_ATTENUATION
,
4815 lightInfo
->OriginalParms
.attenuation0
);
4816 checkGLcall("glLightf");
4817 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_LINEAR_ATTENUATION
,
4818 lightInfo
->OriginalParms
.attenuation1
);
4819 checkGLcall("glLightf");
4820 if (quad_att
< lightInfo
->OriginalParms
.attenuation2
)
4821 quad_att
= lightInfo
->OriginalParms
.attenuation2
;
4822 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_QUADRATIC_ATTENUATION
, quad_att
);
4823 checkGLcall("glLightf");
4827 case WINED3D_LIGHT_DIRECTIONAL
:
4829 /* Note GL uses w position of 0 for direction! */
4830 gl_info
->gl_ops
.gl
.p_glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->direction
.x
);
4831 checkGLcall("glLightfv");
4832 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
4833 checkGLcall("glLightf");
4834 gl_info
->gl_ops
.gl
.p_glLightf(GL_LIGHT0
+ Index
, GL_SPOT_EXPONENT
, 0.0f
);
4835 checkGLcall("glLightf");
4839 FIXME("Unrecognized light type %#x.\n", lightInfo
->OriginalParms
.type
);
4842 /* Restore the modelview matrix */
4843 gl_info
->gl_ops
.gl
.p_glPopMatrix();
4845 gl_info
->gl_ops
.gl
.p_glEnable(GL_LIGHT0
+ Index
);
4846 checkGLcall("glEnable(GL_LIGHT0 + Index)");
4850 static void scissorrect(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4852 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4853 const RECT
*r
= &state
->scissor_rect
;
4855 /* Warning: glScissor uses window coordinates, not viewport coordinates,
4856 * so our viewport correction does not apply. Warning2: Even in windowed
4857 * mode the coords are relative to the window, not the screen. */
4858 TRACE("Setting new scissor rect to %s.\n", wine_dbgstr_rect(r
));
4860 if (context
->render_offscreen
)
4862 gl_info
->gl_ops
.gl
.p_glScissor(r
->left
, r
->top
, r
->right
- r
->left
, r
->bottom
- r
->top
);
4866 const struct wined3d_rendertarget_view
*target
= state
->fb
->render_targets
[0];
4870 wined3d_rendertarget_view_get_drawable_size(target
, context
, &width
, &height
);
4871 gl_info
->gl_ops
.gl
.p_glScissor(r
->left
, height
- r
->bottom
, r
->right
- r
->left
, r
->bottom
- r
->top
);
4873 checkGLcall("glScissor");
4876 static void indexbuffer(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4878 const struct wined3d_stream_info
*stream_info
= &context
->stream_info
;
4879 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4881 if (!state
->index_buffer
|| !stream_info
->all_vbo
)
4883 GL_EXTCALL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER
, 0));
4887 struct wined3d_buffer
*ib
= state
->index_buffer
;
4888 GL_EXTCALL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER
, ib
->buffer_object
));
4892 static void frontface(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4894 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4897 mode
= state
->rasterizer_state
&& state
->rasterizer_state
->desc
.front_ccw
? GL_CCW
: GL_CW
;
4898 if (context
->render_offscreen
)
4899 mode
= (mode
== GL_CW
) ? GL_CCW
: GL_CW
;
4901 gl_info
->gl_ops
.gl
.p_glFrontFace(mode
);
4902 checkGLcall("glFrontFace");
4905 static void frontface_cc(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4907 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4910 mode
= state
->rasterizer_state
&& state
->rasterizer_state
->desc
.front_ccw
? GL_CCW
: GL_CW
;
4912 gl_info
->gl_ops
.gl
.p_glFrontFace(mode
);
4913 checkGLcall("glFrontFace");
4916 static void psorigin_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4922 WARN("Point sprite coordinate origin switching not supported.\n");
4927 static void psorigin(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4929 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4930 GLint origin
= context
->render_offscreen
? GL_LOWER_LEFT
: GL_UPPER_LEFT
;
4932 GL_EXTCALL(glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN
, origin
));
4933 checkGLcall("glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, ...)");
4936 void state_srgbwrite(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4938 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4940 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
4942 if (needs_srgb_write(context
, state
, state
->fb
))
4943 gl_info
->gl_ops
.gl
.p_glEnable(GL_FRAMEBUFFER_SRGB
);
4945 gl_info
->gl_ops
.gl
.p_glDisable(GL_FRAMEBUFFER_SRGB
);
4948 static void state_cb(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4950 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4951 enum wined3d_shader_type shader_type
;
4952 struct wined3d_buffer
*buffer
;
4953 unsigned int i
, base
, count
;
4955 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
4957 if (STATE_IS_GRAPHICS_CONSTANT_BUFFER(state_id
))
4958 shader_type
= state_id
- STATE_GRAPHICS_CONSTANT_BUFFER(0);
4960 shader_type
= WINED3D_SHADER_TYPE_COMPUTE
;
4962 wined3d_gl_limits_get_uniform_block_range(&gl_info
->limits
, shader_type
, &base
, &count
);
4963 for (i
= 0; i
< count
; ++i
)
4965 buffer
= state
->cb
[shader_type
][i
];
4966 GL_EXTCALL(glBindBufferBase(GL_UNIFORM_BUFFER
, base
+ i
, buffer
? buffer
->buffer_object
: 0));
4968 checkGLcall("glBindBufferBase");
4971 static void state_cb_warn(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4973 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
4975 WARN("Constant buffers (%s) no supported.\n", debug_d3dstate(state_id
));
4978 static void state_shader_resource_binding(struct wined3d_context
*context
,
4979 const struct wined3d_state
*state
, DWORD state_id
)
4981 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
4983 context
->update_shader_resource_bindings
= 1;
4986 static void state_uav_binding(struct wined3d_context
*context
,
4987 const struct wined3d_state
*state
, DWORD state_id
)
4989 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
4990 context
->update_unordered_access_view_bindings
= 1;
4993 static void state_uav_warn(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4995 WARN("ARB_image_load_store is not supported by OpenGL implementation.\n");
4998 const struct StateEntryTemplate misc_state_template
[] =
5000 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX
), state_cb
, }, ARB_UNIFORM_BUFFER_OBJECT
},
5001 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX
), state_cb_warn
, }, WINED3D_GL_EXT_NONE
},
5002 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY
),{ STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY
),state_cb
, }, ARB_UNIFORM_BUFFER_OBJECT
},
5003 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY
),{ STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY
),state_cb_warn
, }, WINED3D_GL_EXT_NONE
},
5004 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL
), state_cb
, }, ARB_UNIFORM_BUFFER_OBJECT
},
5005 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL
), state_cb_warn
, }, WINED3D_GL_EXT_NONE
},
5006 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_COMPUTE
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_COMPUTE
), state_cb
, }, ARB_UNIFORM_BUFFER_OBJECT
},
5007 { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_COMPUTE
), { STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_COMPUTE
), state_cb_warn
, }, WINED3D_GL_EXT_NONE
},
5008 { STATE_SHADER_RESOURCE_BINDING
, { STATE_SHADER_RESOURCE_BINDING
, state_shader_resource_binding
}, WINED3D_GL_EXT_NONE
},
5009 { STATE_UNORDERED_ACCESS_VIEW_BINDING
, { STATE_UNORDERED_ACCESS_VIEW_BINDING
, state_uav_binding
}, ARB_SHADER_IMAGE_LOAD_STORE
},
5010 { STATE_UNORDERED_ACCESS_VIEW_BINDING
, { STATE_UNORDERED_ACCESS_VIEW_BINDING
, state_uav_warn
}, WINED3D_GL_EXT_NONE
},
5011 { STATE_RENDER(WINED3D_RS_SRCBLEND
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5012 { STATE_RENDER(WINED3D_RS_DESTBLEND
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5013 { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), state_blend
}, WINED3D_GL_EXT_NONE
},
5014 { STATE_RENDER(WINED3D_RS_EDGEANTIALIAS
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5015 { STATE_RENDER(WINED3D_RS_ANTIALIASEDLINEENABLE
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5016 { STATE_RENDER(WINED3D_RS_SEPARATEALPHABLENDENABLE
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5017 { STATE_RENDER(WINED3D_RS_SRCBLENDALPHA
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5018 { STATE_RENDER(WINED3D_RS_DESTBLENDALPHA
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5019 { STATE_RENDER(WINED3D_RS_DESTBLENDALPHA
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5020 { STATE_RENDER(WINED3D_RS_BLENDOPALPHA
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5021 { STATE_STREAMSRC
, { STATE_STREAMSRC
, streamsrc
}, WINED3D_GL_EXT_NONE
},
5022 { STATE_VDECL
, { STATE_VDECL
, vdecl_miscpart
}, WINED3D_GL_EXT_NONE
},
5023 { STATE_FRONTFACE
, { STATE_FRONTFACE
, frontface_cc
}, ARB_CLIP_CONTROL
},
5024 { STATE_FRONTFACE
, { STATE_FRONTFACE
, frontface
}, WINED3D_GL_EXT_NONE
},
5025 { STATE_SCISSORRECT
, { STATE_SCISSORRECT
, scissorrect
}, WINED3D_GL_EXT_NONE
},
5026 { STATE_POINTSPRITECOORDORIGIN
, { STATE_POINTSPRITECOORDORIGIN
, state_nop
}, ARB_CLIP_CONTROL
},
5027 { STATE_POINTSPRITECOORDORIGIN
, { STATE_POINTSPRITECOORDORIGIN
, psorigin
}, WINED3D_GL_VERSION_2_0
},
5028 { STATE_POINTSPRITECOORDORIGIN
, { STATE_POINTSPRITECOORDORIGIN
, psorigin_w
}, WINED3D_GL_EXT_NONE
},
5030 /* TODO: Move shader constant loading to vertex and fragment pipeline respectively, as soon as the pshader and
5031 * vshader loadings are untied from each other
5033 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5034 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5035 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5036 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5037 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5038 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5039 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5040 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5041 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5042 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5043 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5044 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5045 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5046 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5047 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5048 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5049 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5050 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5051 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5052 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5053 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5054 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5055 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5056 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5057 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5058 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5059 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5060 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5061 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5062 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5063 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5064 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
5065 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5066 { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
5067 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5068 { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
5069 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5070 { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
5071 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5072 { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
5073 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5074 { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
5075 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5076 { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
5077 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5078 { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
5079 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_LSCALE
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_LSCALE
), shader_bumpenv
}, WINED3D_GL_EXT_NONE
},
5080 { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_LOFFSET
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_LSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
5082 { STATE_VIEWPORT
, { STATE_VIEWPORT
, viewport_miscpart_cc
}, ARB_CLIP_CONTROL
},
5083 { STATE_VIEWPORT
, { STATE_VIEWPORT
, viewport_miscpart
}, WINED3D_GL_EXT_NONE
},
5084 { STATE_INDEXBUFFER
, { STATE_INDEXBUFFER
, indexbuffer
}, ARB_VERTEX_BUFFER_OBJECT
},
5085 { STATE_INDEXBUFFER
, { STATE_INDEXBUFFER
, state_nop
}, WINED3D_GL_EXT_NONE
},
5086 { STATE_RENDER(WINED3D_RS_ANTIALIAS
), { STATE_RENDER(WINED3D_RS_ANTIALIAS
), state_antialias
}, WINED3D_GL_EXT_NONE
},
5087 { STATE_RENDER(WINED3D_RS_TEXTUREPERSPECTIVE
), { STATE_RENDER(WINED3D_RS_TEXTUREPERSPECTIVE
), state_nop
}, WINED3D_GL_EXT_NONE
},
5088 { STATE_RENDER(WINED3D_RS_ZENABLE
), { STATE_RENDER(WINED3D_RS_ZENABLE
), state_zenable
}, WINED3D_GL_EXT_NONE
},
5089 { STATE_RENDER(WINED3D_RS_WRAPU
), { STATE_RENDER(WINED3D_RS_WRAPU
), state_wrapu
}, WINED3D_GL_EXT_NONE
},
5090 { STATE_RENDER(WINED3D_RS_WRAPV
), { STATE_RENDER(WINED3D_RS_WRAPV
), state_wrapv
}, WINED3D_GL_EXT_NONE
},
5091 { STATE_RENDER(WINED3D_RS_FILLMODE
), { STATE_RENDER(WINED3D_RS_FILLMODE
), state_fillmode
}, WINED3D_GL_EXT_NONE
},
5092 { STATE_RENDER(WINED3D_RS_LINEPATTERN
), { STATE_RENDER(WINED3D_RS_LINEPATTERN
), state_linepattern
}, WINED3D_GL_LEGACY_CONTEXT
},
5093 { STATE_RENDER(WINED3D_RS_LINEPATTERN
), { STATE_RENDER(WINED3D_RS_LINEPATTERN
), state_linepattern_w
}, WINED3D_GL_EXT_NONE
},
5094 { STATE_RENDER(WINED3D_RS_MONOENABLE
), { STATE_RENDER(WINED3D_RS_MONOENABLE
), state_monoenable
}, WINED3D_GL_EXT_NONE
},
5095 { STATE_RENDER(WINED3D_RS_ROP2
), { STATE_RENDER(WINED3D_RS_ROP2
), state_rop2
}, WINED3D_GL_EXT_NONE
},
5096 { STATE_RENDER(WINED3D_RS_PLANEMASK
), { STATE_RENDER(WINED3D_RS_PLANEMASK
), state_planemask
}, WINED3D_GL_EXT_NONE
},
5097 { STATE_RENDER(WINED3D_RS_ZWRITEENABLE
), { STATE_RENDER(WINED3D_RS_ZWRITEENABLE
), state_zwriteenable
}, WINED3D_GL_EXT_NONE
},
5098 { STATE_RENDER(WINED3D_RS_LASTPIXEL
), { STATE_RENDER(WINED3D_RS_LASTPIXEL
), state_lastpixel
}, WINED3D_GL_EXT_NONE
},
5099 { STATE_RENDER(WINED3D_RS_CULLMODE
), { STATE_RENDER(WINED3D_RS_CULLMODE
), state_cullmode
}, WINED3D_GL_EXT_NONE
},
5100 { STATE_RENDER(WINED3D_RS_ZFUNC
), { STATE_RENDER(WINED3D_RS_ZFUNC
), state_zfunc
}, WINED3D_GL_EXT_NONE
},
5101 { STATE_RENDER(WINED3D_RS_DITHERENABLE
), { STATE_RENDER(WINED3D_RS_DITHERENABLE
), state_ditherenable
}, WINED3D_GL_EXT_NONE
},
5102 { STATE_RENDER(WINED3D_RS_SUBPIXEL
), { STATE_RENDER(WINED3D_RS_SUBPIXEL
), state_subpixel
}, WINED3D_GL_EXT_NONE
},
5103 { STATE_RENDER(WINED3D_RS_SUBPIXELX
), { STATE_RENDER(WINED3D_RS_SUBPIXELX
), state_subpixelx
}, WINED3D_GL_EXT_NONE
},
5104 { STATE_RENDER(WINED3D_RS_STIPPLEDALPHA
), { STATE_RENDER(WINED3D_RS_STIPPLEDALPHA
), state_stippledalpha
}, WINED3D_GL_EXT_NONE
},
5105 { STATE_RENDER(WINED3D_RS_STIPPLEENABLE
), { STATE_RENDER(WINED3D_RS_STIPPLEENABLE
), state_stippleenable
}, WINED3D_GL_EXT_NONE
},
5106 { STATE_RENDER(WINED3D_RS_MIPMAPLODBIAS
), { STATE_RENDER(WINED3D_RS_MIPMAPLODBIAS
), state_mipmaplodbias
}, WINED3D_GL_EXT_NONE
},
5107 { STATE_RENDER(WINED3D_RS_ANISOTROPY
), { STATE_RENDER(WINED3D_RS_ANISOTROPY
), state_anisotropy
}, WINED3D_GL_EXT_NONE
},
5108 { STATE_RENDER(WINED3D_RS_FLUSHBATCH
), { STATE_RENDER(WINED3D_RS_FLUSHBATCH
), state_flushbatch
}, WINED3D_GL_EXT_NONE
},
5109 { STATE_RENDER(WINED3D_RS_TRANSLUCENTSORTINDEPENDENT
),{ STATE_RENDER(WINED3D_RS_TRANSLUCENTSORTINDEPENDENT
),state_translucentsi
}, WINED3D_GL_EXT_NONE
},
5110 { STATE_RENDER(WINED3D_RS_STENCILENABLE
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), state_stencil
}, WINED3D_GL_EXT_NONE
},
5111 { STATE_RENDER(WINED3D_RS_STENCILFAIL
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5112 { STATE_RENDER(WINED3D_RS_STENCILZFAIL
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5113 { STATE_RENDER(WINED3D_RS_STENCILPASS
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5114 { STATE_RENDER(WINED3D_RS_STENCILFUNC
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5115 { STATE_RENDER(WINED3D_RS_STENCILREF
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5116 { STATE_RENDER(WINED3D_RS_STENCILMASK
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5117 { STATE_RENDER(WINED3D_RS_STENCILWRITEMASK
), { STATE_RENDER(WINED3D_RS_STENCILWRITEMASK
), state_stencilwrite2s
}, EXT_STENCIL_TWO_SIDE
},
5118 { STATE_RENDER(WINED3D_RS_STENCILWRITEMASK
), { STATE_RENDER(WINED3D_RS_STENCILWRITEMASK
), state_stencilwrite
}, WINED3D_GL_EXT_NONE
},
5119 { STATE_RENDER(WINED3D_RS_TWOSIDEDSTENCILMODE
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5120 { STATE_RENDER(WINED3D_RS_BACK_STENCILFAIL
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5121 { STATE_RENDER(WINED3D_RS_BACK_STENCILZFAIL
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5122 { STATE_RENDER(WINED3D_RS_BACK_STENCILPASS
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5123 { STATE_RENDER(WINED3D_RS_BACK_STENCILFUNC
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5124 { STATE_RENDER(WINED3D_RS_WRAP0
), { STATE_RENDER(WINED3D_RS_WRAP0
), state_wrap
}, WINED3D_GL_EXT_NONE
},
5125 { STATE_RENDER(WINED3D_RS_WRAP1
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5126 { STATE_RENDER(WINED3D_RS_WRAP2
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5127 { STATE_RENDER(WINED3D_RS_WRAP3
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5128 { STATE_RENDER(WINED3D_RS_WRAP4
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5129 { STATE_RENDER(WINED3D_RS_WRAP5
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5130 { STATE_RENDER(WINED3D_RS_WRAP6
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5131 { STATE_RENDER(WINED3D_RS_WRAP7
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5132 { STATE_RENDER(WINED3D_RS_WRAP8
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5133 { STATE_RENDER(WINED3D_RS_WRAP9
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5134 { STATE_RENDER(WINED3D_RS_WRAP10
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5135 { STATE_RENDER(WINED3D_RS_WRAP11
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5136 { STATE_RENDER(WINED3D_RS_WRAP12
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5137 { STATE_RENDER(WINED3D_RS_WRAP13
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5138 { STATE_RENDER(WINED3D_RS_WRAP14
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5139 { STATE_RENDER(WINED3D_RS_WRAP15
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5140 { STATE_RENDER(WINED3D_RS_EXTENTS
), { STATE_RENDER(WINED3D_RS_EXTENTS
), state_extents
}, WINED3D_GL_EXT_NONE
},
5141 { STATE_RENDER(WINED3D_RS_COLORKEYBLENDENABLE
), { STATE_RENDER(WINED3D_RS_COLORKEYBLENDENABLE
), state_ckeyblend
}, WINED3D_GL_EXT_NONE
},
5142 { STATE_RENDER(WINED3D_RS_SOFTWAREVERTEXPROCESSING
), { STATE_RENDER(WINED3D_RS_SOFTWAREVERTEXPROCESSING
), state_swvp
}, WINED3D_GL_EXT_NONE
},
5143 { STATE_RENDER(WINED3D_RS_PATCHEDGESTYLE
), { STATE_RENDER(WINED3D_RS_PATCHEDGESTYLE
), state_patchedgestyle
}, WINED3D_GL_EXT_NONE
},
5144 { STATE_RENDER(WINED3D_RS_PATCHSEGMENTS
), { STATE_RENDER(WINED3D_RS_PATCHSEGMENTS
), state_patchsegments
}, WINED3D_GL_EXT_NONE
},
5145 { STATE_RENDER(WINED3D_RS_POSITIONDEGREE
), { STATE_RENDER(WINED3D_RS_POSITIONDEGREE
), state_positiondegree
}, WINED3D_GL_EXT_NONE
},
5146 { STATE_RENDER(WINED3D_RS_NORMALDEGREE
), { STATE_RENDER(WINED3D_RS_NORMALDEGREE
), state_normaldegree
}, WINED3D_GL_EXT_NONE
},
5147 { STATE_RENDER(WINED3D_RS_MINTESSELLATIONLEVEL
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
5148 { STATE_RENDER(WINED3D_RS_MAXTESSELLATIONLEVEL
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
5149 { STATE_RENDER(WINED3D_RS_ADAPTIVETESS_X
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
5150 { STATE_RENDER(WINED3D_RS_ADAPTIVETESS_Y
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
5151 { STATE_RENDER(WINED3D_RS_ADAPTIVETESS_Z
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
5152 { STATE_RENDER(WINED3D_RS_ADAPTIVETESS_W
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
5153 { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),{ STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),state_nvdb
}, EXT_DEPTH_BOUNDS_TEST
},
5154 { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),{ STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),state_tessellation
}, WINED3D_GL_EXT_NONE
},
5155 { STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS
), { STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS
), state_msaa
}, ARB_MULTISAMPLE
},
5156 { STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS
), { STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS
), state_msaa_w
}, WINED3D_GL_EXT_NONE
},
5157 { STATE_RENDER(WINED3D_RS_MULTISAMPLEMASK
), { STATE_RENDER(WINED3D_RS_MULTISAMPLEMASK
), state_multisampmask
}, WINED3D_GL_EXT_NONE
},
5158 { STATE_RENDER(WINED3D_RS_DEBUGMONITORTOKEN
), { STATE_RENDER(WINED3D_RS_DEBUGMONITORTOKEN
), state_debug_monitor
}, WINED3D_GL_EXT_NONE
},
5159 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE
), state_colorwrite0
}, EXT_DRAW_BUFFERS2
},
5160 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE
), state_colorwrite
}, WINED3D_GL_EXT_NONE
},
5161 { STATE_RENDER(WINED3D_RS_BLENDOP
), { STATE_RENDER(WINED3D_RS_BLENDOP
), state_blendop
}, WINED3D_GL_BLEND_EQUATION
},
5162 { STATE_RENDER(WINED3D_RS_BLENDOP
), { STATE_RENDER(WINED3D_RS_BLENDOP
), state_blendop_w
}, WINED3D_GL_EXT_NONE
},
5163 { STATE_RENDER(WINED3D_RS_SCISSORTESTENABLE
), { STATE_RENDER(WINED3D_RS_SCISSORTESTENABLE
), state_scissor
}, WINED3D_GL_EXT_NONE
},
5164 { STATE_RENDER(WINED3D_RS_SLOPESCALEDEPTHBIAS
), { STATE_RENDER(WINED3D_RS_DEPTHBIAS
), NULL
}, WINED3D_GL_EXT_NONE
},
5165 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1
), state_colorwrite1
}, EXT_DRAW_BUFFERS2
},
5166 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5167 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2
), state_colorwrite2
}, EXT_DRAW_BUFFERS2
},
5168 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5169 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3
), state_colorwrite3
}, EXT_DRAW_BUFFERS2
},
5170 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5171 { STATE_RENDER(WINED3D_RS_BLENDFACTOR
), { STATE_RENDER(WINED3D_RS_BLENDFACTOR
), state_blendfactor
}, EXT_BLEND_COLOR
},
5172 { STATE_RENDER(WINED3D_RS_BLENDFACTOR
), { STATE_RENDER(WINED3D_RS_BLENDFACTOR
), state_blendfactor_w
}, WINED3D_GL_EXT_NONE
},
5173 { STATE_RENDER(WINED3D_RS_DEPTHBIAS
), { STATE_RENDER(WINED3D_RS_DEPTHBIAS
), state_depthbias
}, WINED3D_GL_EXT_NONE
},
5174 { STATE_RENDER(WINED3D_RS_ZVISIBLE
), { STATE_RENDER(WINED3D_RS_ZVISIBLE
), state_zvisible
}, WINED3D_GL_EXT_NONE
},
5176 { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler
}, WINED3D_GL_EXT_NONE
},
5177 { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler
}, WINED3D_GL_EXT_NONE
},
5178 { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler
}, WINED3D_GL_EXT_NONE
},
5179 { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler
}, WINED3D_GL_EXT_NONE
},
5180 { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler
}, WINED3D_GL_EXT_NONE
},
5181 { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler
}, WINED3D_GL_EXT_NONE
},
5182 { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler
}, WINED3D_GL_EXT_NONE
},
5183 { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler
}, WINED3D_GL_EXT_NONE
},
5184 { STATE_SAMPLER(8), { STATE_SAMPLER(8), sampler
}, WINED3D_GL_EXT_NONE
},
5185 { STATE_SAMPLER(9), { STATE_SAMPLER(9), sampler
}, WINED3D_GL_EXT_NONE
},
5186 { STATE_SAMPLER(10), { STATE_SAMPLER(10), sampler
}, WINED3D_GL_EXT_NONE
},
5187 { STATE_SAMPLER(11), { STATE_SAMPLER(11), sampler
}, WINED3D_GL_EXT_NONE
},
5188 { STATE_SAMPLER(12), { STATE_SAMPLER(12), sampler
}, WINED3D_GL_EXT_NONE
},
5189 { STATE_SAMPLER(13), { STATE_SAMPLER(13), sampler
}, WINED3D_GL_EXT_NONE
},
5190 { STATE_SAMPLER(14), { STATE_SAMPLER(14), sampler
}, WINED3D_GL_EXT_NONE
},
5191 { STATE_SAMPLER(15), { STATE_SAMPLER(15), sampler
}, WINED3D_GL_EXT_NONE
},
5192 { STATE_SAMPLER(16), /* Vertex sampler 0 */ { STATE_SAMPLER(16), sampler
}, WINED3D_GL_EXT_NONE
},
5193 { STATE_SAMPLER(17), /* Vertex sampler 1 */ { STATE_SAMPLER(17), sampler
}, WINED3D_GL_EXT_NONE
},
5194 { STATE_SAMPLER(18), /* Vertex sampler 2 */ { STATE_SAMPLER(18), sampler
}, WINED3D_GL_EXT_NONE
},
5195 { STATE_SAMPLER(19), /* Vertex sampler 3 */ { STATE_SAMPLER(19), sampler
}, WINED3D_GL_EXT_NONE
},
5196 { STATE_BASEVERTEXINDEX
, { STATE_BASEVERTEXINDEX
, state_nop
, }, ARB_DRAW_ELEMENTS_BASE_VERTEX
},
5197 { STATE_BASEVERTEXINDEX
, { STATE_STREAMSRC
, NULL
, }, WINED3D_GL_EXT_NONE
},
5198 { STATE_FRAMEBUFFER
, { STATE_FRAMEBUFFER
, context_state_fb
}, WINED3D_GL_EXT_NONE
},
5199 { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
), context_state_drawbuf
},WINED3D_GL_EXT_NONE
},
5200 { STATE_SHADER(WINED3D_SHADER_TYPE_GEOMETRY
), { STATE_SHADER(WINED3D_SHADER_TYPE_GEOMETRY
), state_shader
}, WINED3D_GL_EXT_NONE
},
5201 { STATE_SHADER(WINED3D_SHADER_TYPE_COMPUTE
), { STATE_SHADER(WINED3D_SHADER_TYPE_COMPUTE
), state_compute_shader
}, WINED3D_GL_EXT_NONE
},
5202 {0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE
},
5205 static const struct StateEntryTemplate vp_ffp_states
[] =
5207 { STATE_VDECL
, { STATE_VDECL
, vertexdeclaration
}, WINED3D_GL_EXT_NONE
},
5208 { STATE_SHADER(WINED3D_SHADER_TYPE_VERTEX
), { STATE_VDECL
, NULL
}, WINED3D_GL_EXT_NONE
},
5209 { STATE_MATERIAL
, { STATE_RENDER(WINED3D_RS_SPECULARENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5210 { STATE_RENDER(WINED3D_RS_SPECULARENABLE
), { STATE_RENDER(WINED3D_RS_SPECULARENABLE
), state_specularenable
}, WINED3D_GL_EXT_NONE
},
5212 { STATE_CLIPPLANE(0), { STATE_CLIPPLANE(0), clipplane
}, WINED3D_GL_EXT_NONE
},
5213 { STATE_CLIPPLANE(1), { STATE_CLIPPLANE(1), clipplane
}, WINED3D_GL_EXT_NONE
},
5214 { STATE_CLIPPLANE(2), { STATE_CLIPPLANE(2), clipplane
}, WINED3D_GL_EXT_NONE
},
5215 { STATE_CLIPPLANE(3), { STATE_CLIPPLANE(3), clipplane
}, WINED3D_GL_EXT_NONE
},
5216 { STATE_CLIPPLANE(4), { STATE_CLIPPLANE(4), clipplane
}, WINED3D_GL_EXT_NONE
},
5217 { STATE_CLIPPLANE(5), { STATE_CLIPPLANE(5), clipplane
}, WINED3D_GL_EXT_NONE
},
5218 { STATE_CLIPPLANE(6), { STATE_CLIPPLANE(6), clipplane
}, WINED3D_GL_EXT_NONE
},
5219 { STATE_CLIPPLANE(7), { STATE_CLIPPLANE(7), clipplane
}, WINED3D_GL_EXT_NONE
},
5220 { STATE_CLIPPLANE(8), { STATE_CLIPPLANE(8), clipplane
}, WINED3D_GL_EXT_NONE
},
5221 { STATE_CLIPPLANE(9), { STATE_CLIPPLANE(9), clipplane
}, WINED3D_GL_EXT_NONE
},
5222 { STATE_CLIPPLANE(10), { STATE_CLIPPLANE(10), clipplane
}, WINED3D_GL_EXT_NONE
},
5223 { STATE_CLIPPLANE(11), { STATE_CLIPPLANE(11), clipplane
}, WINED3D_GL_EXT_NONE
},
5224 { STATE_CLIPPLANE(12), { STATE_CLIPPLANE(12), clipplane
}, WINED3D_GL_EXT_NONE
},
5225 { STATE_CLIPPLANE(13), { STATE_CLIPPLANE(13), clipplane
}, WINED3D_GL_EXT_NONE
},
5226 { STATE_CLIPPLANE(14), { STATE_CLIPPLANE(14), clipplane
}, WINED3D_GL_EXT_NONE
},
5227 { STATE_CLIPPLANE(15), { STATE_CLIPPLANE(15), clipplane
}, WINED3D_GL_EXT_NONE
},
5228 { STATE_CLIPPLANE(16), { STATE_CLIPPLANE(16), clipplane
}, WINED3D_GL_EXT_NONE
},
5229 { STATE_CLIPPLANE(17), { STATE_CLIPPLANE(17), clipplane
}, WINED3D_GL_EXT_NONE
},
5230 { STATE_CLIPPLANE(18), { STATE_CLIPPLANE(18), clipplane
}, WINED3D_GL_EXT_NONE
},
5231 { STATE_CLIPPLANE(19), { STATE_CLIPPLANE(19), clipplane
}, WINED3D_GL_EXT_NONE
},
5232 { STATE_CLIPPLANE(20), { STATE_CLIPPLANE(20), clipplane
}, WINED3D_GL_EXT_NONE
},
5233 { STATE_CLIPPLANE(21), { STATE_CLIPPLANE(21), clipplane
}, WINED3D_GL_EXT_NONE
},
5234 { STATE_CLIPPLANE(22), { STATE_CLIPPLANE(22), clipplane
}, WINED3D_GL_EXT_NONE
},
5235 { STATE_CLIPPLANE(23), { STATE_CLIPPLANE(23), clipplane
}, WINED3D_GL_EXT_NONE
},
5236 { STATE_CLIPPLANE(24), { STATE_CLIPPLANE(24), clipplane
}, WINED3D_GL_EXT_NONE
},
5237 { STATE_CLIPPLANE(25), { STATE_CLIPPLANE(25), clipplane
}, WINED3D_GL_EXT_NONE
},
5238 { STATE_CLIPPLANE(26), { STATE_CLIPPLANE(26), clipplane
}, WINED3D_GL_EXT_NONE
},
5239 { STATE_CLIPPLANE(27), { STATE_CLIPPLANE(27), clipplane
}, WINED3D_GL_EXT_NONE
},
5240 { STATE_CLIPPLANE(28), { STATE_CLIPPLANE(28), clipplane
}, WINED3D_GL_EXT_NONE
},
5241 { STATE_CLIPPLANE(29), { STATE_CLIPPLANE(29), clipplane
}, WINED3D_GL_EXT_NONE
},
5242 { STATE_CLIPPLANE(30), { STATE_CLIPPLANE(30), clipplane
}, WINED3D_GL_EXT_NONE
},
5243 { STATE_CLIPPLANE(31), { STATE_CLIPPLANE(31), clipplane
}, WINED3D_GL_EXT_NONE
},
5245 { STATE_LIGHT_TYPE
, { STATE_LIGHT_TYPE
, state_nop
}, WINED3D_GL_EXT_NONE
},
5246 { STATE_ACTIVELIGHT(0), { STATE_ACTIVELIGHT(0), light
}, WINED3D_GL_EXT_NONE
},
5247 { STATE_ACTIVELIGHT(1), { STATE_ACTIVELIGHT(1), light
}, WINED3D_GL_EXT_NONE
},
5248 { STATE_ACTIVELIGHT(2), { STATE_ACTIVELIGHT(2), light
}, WINED3D_GL_EXT_NONE
},
5249 { STATE_ACTIVELIGHT(3), { STATE_ACTIVELIGHT(3), light
}, WINED3D_GL_EXT_NONE
},
5250 { STATE_ACTIVELIGHT(4), { STATE_ACTIVELIGHT(4), light
}, WINED3D_GL_EXT_NONE
},
5251 { STATE_ACTIVELIGHT(5), { STATE_ACTIVELIGHT(5), light
}, WINED3D_GL_EXT_NONE
},
5252 { STATE_ACTIVELIGHT(6), { STATE_ACTIVELIGHT(6), light
}, WINED3D_GL_EXT_NONE
},
5253 { STATE_ACTIVELIGHT(7), { STATE_ACTIVELIGHT(7), light
}, WINED3D_GL_EXT_NONE
},
5255 { STATE_VIEWPORT
, { STATE_VIEWPORT
, viewport_vertexpart
}, WINED3D_GL_EXT_NONE
},
5256 /* Transform states follow */
5257 { STATE_TRANSFORM(WINED3D_TS_VIEW
), { STATE_TRANSFORM(WINED3D_TS_VIEW
), transform_view
}, WINED3D_GL_EXT_NONE
},
5258 { STATE_TRANSFORM(WINED3D_TS_PROJECTION
), { STATE_TRANSFORM(WINED3D_TS_PROJECTION
), transform_projection
}, WINED3D_GL_EXT_NONE
},
5259 { STATE_TRANSFORM(WINED3D_TS_TEXTURE0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5260 { STATE_TRANSFORM(WINED3D_TS_TEXTURE1
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5261 { STATE_TRANSFORM(WINED3D_TS_TEXTURE2
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5262 { STATE_TRANSFORM(WINED3D_TS_TEXTURE3
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5263 { STATE_TRANSFORM(WINED3D_TS_TEXTURE4
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5264 { STATE_TRANSFORM(WINED3D_TS_TEXTURE5
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5265 { STATE_TRANSFORM(WINED3D_TS_TEXTURE6
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5266 { STATE_TRANSFORM(WINED3D_TS_TEXTURE7
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5267 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 0)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 0)), transform_world
}, WINED3D_GL_EXT_NONE
},
5268 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 1)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 1)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5269 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 2)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 2)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5270 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 3)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 3)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5271 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 4)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 4)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5272 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 5)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 5)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5273 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 6)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 6)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5274 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 7)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 7)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5275 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 8)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 8)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5276 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 9)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 9)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5277 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 10)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 10)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5278 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 11)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 11)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5279 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 12)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 12)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5280 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 13)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 13)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5281 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 14)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 14)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5282 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 15)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 15)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5283 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 16)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 16)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5284 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 17)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 17)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5285 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 18)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 18)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5286 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 19)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 19)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5287 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 20)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 20)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5288 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 21)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 21)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5289 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 22)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 22)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5290 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 23)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 23)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5291 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 24)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 24)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5292 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 25)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 25)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5293 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 26)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 26)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5294 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 27)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 27)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5295 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 28)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 28)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5296 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 29)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 29)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5297 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 30)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 30)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5298 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 31)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 31)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5299 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 32)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 32)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5300 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 33)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 33)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5301 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 34)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 34)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5302 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 35)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 35)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5303 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 36)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 36)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5304 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 37)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 37)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5305 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 38)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 38)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5306 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 39)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 39)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5307 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 40)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 40)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5308 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 41)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 41)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5309 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 42)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 42)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5310 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 43)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 43)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5311 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 44)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 44)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5312 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 45)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 45)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5313 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 46)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 46)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5314 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 47)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 47)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5315 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 48)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 48)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5316 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 49)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 49)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5317 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 50)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 50)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5318 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 51)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 51)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5319 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 52)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 52)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5320 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 53)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 53)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5321 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 54)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 54)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5322 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 55)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 55)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5323 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 56)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 56)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5324 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 57)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 57)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5325 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 58)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 58)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5326 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 59)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 59)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5327 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 60)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 60)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5328 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 61)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 61)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5329 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 62)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 62)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5330 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 63)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 63)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5331 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 64)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 64)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5332 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 65)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 65)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5333 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 66)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 66)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5334 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 67)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 67)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5335 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 68)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 68)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5336 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 69)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 69)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5337 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 70)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 70)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5338 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 71)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 71)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5339 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 72)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 72)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5340 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 73)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 73)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5341 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 74)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 74)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5342 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 75)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 75)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5343 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 76)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 76)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5344 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 77)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 77)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5345 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 78)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 78)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5346 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 79)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 79)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5347 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 80)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 80)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5348 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 81)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 81)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5349 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 82)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 82)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5350 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 83)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 83)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5351 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 84)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 84)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5352 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 85)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 85)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5353 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 86)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 86)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5354 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 87)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 87)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5355 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 88)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 88)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5356 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 89)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 89)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5357 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 90)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 90)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5358 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 91)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 91)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5359 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 92)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 92)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5360 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 93)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 93)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5361 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 94)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 94)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5362 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 95)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 95)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5363 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 96)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 96)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5364 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 97)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 97)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5365 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 98)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 98)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5366 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 99)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX( 99)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5367 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(100)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(100)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5368 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(101)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(101)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5369 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(102)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(102)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5370 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(103)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(103)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5371 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(104)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(104)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5372 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(105)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(105)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5373 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(106)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(106)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5374 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(107)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(107)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5375 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(108)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(108)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5376 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(109)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(109)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5377 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(110)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(110)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5378 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(111)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(111)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5379 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(112)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(112)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5380 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(113)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(113)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5381 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(114)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(114)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5382 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(115)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(115)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5383 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(116)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(116)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5384 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(117)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(117)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5385 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(118)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(118)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5386 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(119)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(119)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5387 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(120)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(120)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5388 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(121)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(121)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5389 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(122)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(122)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5390 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(123)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(123)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5391 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(124)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(124)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5392 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(125)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(125)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5393 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(126)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(126)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5394 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(127)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(127)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5395 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(128)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(128)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5396 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(129)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(129)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5397 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(130)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(130)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5398 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(131)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(131)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5399 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(132)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(132)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5400 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(133)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(133)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5401 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(134)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(134)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5402 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(135)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(135)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5403 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(136)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(136)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5404 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(137)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(137)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5405 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(138)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(138)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5406 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(139)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(139)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5407 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(140)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(140)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5408 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(141)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(141)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5409 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(142)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(142)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5410 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(143)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(143)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5411 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(144)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(144)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5412 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(145)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(145)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5413 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(146)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(146)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5414 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(147)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(147)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5415 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(148)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(148)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5416 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(149)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(149)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5417 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(150)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(150)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5418 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(151)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(151)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5419 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(152)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(152)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5420 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(153)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(153)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5421 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(154)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(154)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5422 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(155)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(155)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5423 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(156)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(156)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5424 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(157)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(157)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5425 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(158)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(158)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5426 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(159)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(159)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5427 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(160)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(160)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5428 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(161)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(161)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5429 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(162)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(162)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5430 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(163)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(163)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5431 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(164)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(164)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5432 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(165)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(165)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5433 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(166)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(166)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5434 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(167)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(167)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5435 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(168)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(168)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5436 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(169)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(169)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5437 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(170)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(170)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5438 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(171)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(171)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5439 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(172)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(172)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5440 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(173)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(173)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5441 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(174)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(174)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5442 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(175)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(175)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5443 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(176)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(176)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5444 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(177)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(177)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5445 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(178)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(178)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5446 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(179)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(179)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5447 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(180)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(180)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5448 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(181)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(181)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5449 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(182)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(182)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5450 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(183)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(183)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5451 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(184)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(184)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5452 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(185)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(185)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5453 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(186)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(186)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5454 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(187)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(187)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5455 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(188)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(188)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5456 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(189)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(189)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5457 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(190)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(190)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5458 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(191)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(191)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5459 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(192)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(192)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5460 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(193)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(193)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5461 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(194)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(194)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5462 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(195)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(195)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5463 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(196)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(196)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5464 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(197)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(197)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5465 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(198)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(198)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5466 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(199)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(199)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5467 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(200)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(200)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5468 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(201)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(201)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5469 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(202)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(202)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5470 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(203)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(203)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5471 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(204)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(204)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5472 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(205)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(205)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5473 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(206)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(206)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5474 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(207)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(207)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5475 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(208)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(208)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5476 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(209)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(209)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5477 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(210)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(210)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5478 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(211)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(211)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5479 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(212)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(212)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5480 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(213)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(213)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5481 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(214)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(214)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5482 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(215)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(215)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5483 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(216)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(216)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5484 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(217)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(217)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5485 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(218)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(218)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5486 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(219)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(219)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5487 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(220)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(220)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5488 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(221)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(221)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5489 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(222)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(222)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5490 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(223)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(223)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5491 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(224)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(224)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5492 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(225)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(225)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5493 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(226)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(226)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5494 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(227)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(227)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5495 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(228)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(228)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5496 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(229)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(229)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5497 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(230)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(230)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5498 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(231)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(231)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5499 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(232)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(232)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5500 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(233)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(233)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5501 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(234)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(234)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5502 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(235)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(235)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5503 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(236)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(236)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5504 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(237)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(237)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5505 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(238)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(238)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5506 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(239)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(239)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5507 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(240)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(240)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5508 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(241)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(241)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5509 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(242)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(242)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5510 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(243)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(243)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5511 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(244)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(244)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5512 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(245)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(245)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5513 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(246)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(246)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5514 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(247)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(247)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5515 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(248)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(248)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5516 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(249)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(249)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5517 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(250)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(250)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5518 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(251)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(251)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5519 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(252)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(252)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5520 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(253)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(253)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5521 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(254)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(254)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5522 { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)), { STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5523 { STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5524 { STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5525 { STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5526 { STATE_TEXTURESTAGE(3, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(3, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5527 { STATE_TEXTURESTAGE(4, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(4, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5528 { STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5529 { STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5530 { STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), transform_texture
}, WINED3D_GL_EXT_NONE
},
5531 { STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5532 { STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5533 { STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5534 { STATE_TEXTURESTAGE(3, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5535 { STATE_TEXTURESTAGE(4, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5536 { STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5537 { STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5538 { STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXCOORD_INDEX
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXCOORD_INDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5540 { STATE_RENDER(WINED3D_RS_FOGENABLE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), state_fog_vertexpart
}, WINED3D_GL_EXT_NONE
},
5541 { STATE_RENDER(WINED3D_RS_FOGTABLEMODE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5542 { STATE_RENDER(WINED3D_RS_FOGVERTEXMODE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5543 { STATE_RENDER(WINED3D_RS_RANGEFOGENABLE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5544 { STATE_RENDER(WINED3D_RS_CLIPPING
), { STATE_RENDER(WINED3D_RS_CLIPPING
), state_clipping
}, WINED3D_GL_EXT_NONE
},
5545 { STATE_RENDER(WINED3D_RS_CLIPPLANEENABLE
), { STATE_RENDER(WINED3D_RS_CLIPPING
), NULL
}, WINED3D_GL_EXT_NONE
},
5546 { STATE_RENDER(WINED3D_RS_LIGHTING
), { STATE_RENDER(WINED3D_RS_LIGHTING
), state_lighting
}, WINED3D_GL_EXT_NONE
},
5547 { STATE_RENDER(WINED3D_RS_AMBIENT
), { STATE_RENDER(WINED3D_RS_AMBIENT
), state_ambient
}, WINED3D_GL_EXT_NONE
},
5548 { STATE_RENDER(WINED3D_RS_COLORVERTEX
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), state_colormat
}, WINED3D_GL_EXT_NONE
},
5549 { STATE_RENDER(WINED3D_RS_LOCALVIEWER
), { STATE_RENDER(WINED3D_RS_LOCALVIEWER
), state_localviewer
}, WINED3D_GL_EXT_NONE
},
5550 { STATE_RENDER(WINED3D_RS_NORMALIZENORMALS
), { STATE_RENDER(WINED3D_RS_NORMALIZENORMALS
), state_normalize
}, WINED3D_GL_EXT_NONE
},
5551 { STATE_RENDER(WINED3D_RS_DIFFUSEMATERIALSOURCE
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), NULL
}, WINED3D_GL_EXT_NONE
},
5552 { STATE_RENDER(WINED3D_RS_SPECULARMATERIALSOURCE
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), NULL
}, WINED3D_GL_EXT_NONE
},
5553 { STATE_RENDER(WINED3D_RS_AMBIENTMATERIALSOURCE
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), NULL
}, WINED3D_GL_EXT_NONE
},
5554 { STATE_RENDER(WINED3D_RS_EMISSIVEMATERIALSOURCE
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), NULL
}, WINED3D_GL_EXT_NONE
},
5555 { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), state_vertexblend
}, ARB_VERTEX_BLEND
},
5556 { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), state_vertexblend_w
}, WINED3D_GL_EXT_NONE
},
5557 { STATE_RENDER(WINED3D_RS_POINTSIZE
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5558 { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), state_psizemin_arb
}, ARB_POINT_PARAMETERS
},
5559 { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), state_psizemin_ext
}, EXT_POINT_PARAMETERS
},
5560 { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), state_psizemin_w
}, WINED3D_GL_EXT_NONE
},
5561 { STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE
), { STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE
), state_pointsprite
}, ARB_POINT_SPRITE
},
5562 { STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE
), { STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE
), state_pointsprite_w
}, WINED3D_GL_EXT_NONE
},
5563 { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), state_pscale
}, WINED3D_GL_EXT_NONE
},
5564 { STATE_RENDER(WINED3D_RS_POINTSCALE_A
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5565 { STATE_RENDER(WINED3D_RS_POINTSCALE_B
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5566 { STATE_RENDER(WINED3D_RS_POINTSCALE_C
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5567 { STATE_RENDER(WINED3D_RS_POINTSIZE_MAX
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), NULL
}, ARB_POINT_PARAMETERS
},
5568 { STATE_RENDER(WINED3D_RS_POINTSIZE_MAX
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), NULL
}, EXT_POINT_PARAMETERS
},
5569 { STATE_RENDER(WINED3D_RS_POINTSIZE_MAX
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), NULL
}, WINED3D_GL_EXT_NONE
},
5570 { STATE_RENDER(WINED3D_RS_TWEENFACTOR
), { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), NULL
}, WINED3D_GL_EXT_NONE
},
5571 { STATE_RENDER(WINED3D_RS_INDEXEDVERTEXBLENDENABLE
), { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), NULL
}, WINED3D_GL_EXT_NONE
},
5573 /* Samplers for NP2 texture matrix adjustions. They are not needed if GL_ARB_texture_non_power_of_two is supported,
5574 * so register a NULL state handler in that case to get the vertex part of sampler() skipped(VTF is handled in the misc states.
5575 * otherwise, register sampler_texmatrix, which takes care of updating the texture matrix
5577 { STATE_SAMPLER(0), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5578 { STATE_SAMPLER(0), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5579 { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5580 { STATE_SAMPLER(1), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5581 { STATE_SAMPLER(1), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5582 { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5583 { STATE_SAMPLER(2), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5584 { STATE_SAMPLER(2), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5585 { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5586 { STATE_SAMPLER(3), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5587 { STATE_SAMPLER(3), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5588 { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5589 { STATE_SAMPLER(4), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5590 { STATE_SAMPLER(4), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5591 { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5592 { STATE_SAMPLER(5), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5593 { STATE_SAMPLER(5), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5594 { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5595 { STATE_SAMPLER(6), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5596 { STATE_SAMPLER(6), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5597 { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5598 { STATE_SAMPLER(7), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5599 { STATE_SAMPLER(7), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5600 { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5601 { STATE_POINT_ENABLE
, { STATE_POINT_ENABLE
, state_nop
}, WINED3D_GL_EXT_NONE
},
5602 {0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE
},
5605 static const struct StateEntryTemplate ffp_fragmentstate_template
[] = {
5606 { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5607 { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5608 { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5609 { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5610 { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5611 { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5612 { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5613 { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5614 { STATE_TEXTURESTAGE(0, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5615 { STATE_TEXTURESTAGE(0, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5616 { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5617 { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5618 { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5619 { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5620 { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5621 { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5622 { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5623 { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5624 { STATE_TEXTURESTAGE(1, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5625 { STATE_TEXTURESTAGE(1, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5626 { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5627 { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5628 { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5629 { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5630 { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5631 { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5632 { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5633 { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5634 { STATE_TEXTURESTAGE(2, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5635 { STATE_TEXTURESTAGE(2, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5636 { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5637 { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5638 { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5639 { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5640 { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5641 { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5642 { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5643 { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5644 { STATE_TEXTURESTAGE(3, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5645 { STATE_TEXTURESTAGE(3, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5646 { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5647 { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5648 { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5649 { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5650 { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5651 { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5652 { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5653 { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5654 { STATE_TEXTURESTAGE(4, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5655 { STATE_TEXTURESTAGE(4, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5656 { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5657 { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5658 { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5659 { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5660 { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5661 { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5662 { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5663 { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5664 { STATE_TEXTURESTAGE(5, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5665 { STATE_TEXTURESTAGE(5, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5666 { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5667 { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5668 { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5669 { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5670 { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5671 { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5672 { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5673 { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5674 { STATE_TEXTURESTAGE(6, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5675 { STATE_TEXTURESTAGE(6, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5676 { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5677 { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5678 { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5679 { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5680 { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5681 { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5682 { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5683 { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5684 { STATE_TEXTURESTAGE(7, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
5685 { STATE_TEXTURESTAGE(7, WINED3D_TSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5686 { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
), apply_pixelshader
}, WINED3D_GL_EXT_NONE
},
5687 { STATE_RENDER(WINED3D_RS_ALPHAFUNC
), { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5688 { STATE_RENDER(WINED3D_RS_ALPHAREF
), { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5689 { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), state_alpha_test
}, WINED3D_GL_EXT_NONE
},
5690 { STATE_RENDER(WINED3D_RS_COLORKEYENABLE
), { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5691 { STATE_COLOR_KEY
, { STATE_COLOR_KEY
, state_nop
}, WINED3D_GL_EXT_NONE
},
5692 { STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE
), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
), NULL
}, WINED3D_GL_EXT_NONE
},
5693 { STATE_RENDER(WINED3D_RS_TEXTUREFACTOR
), { STATE_RENDER(WINED3D_RS_TEXTUREFACTOR
), state_texfactor
}, WINED3D_GL_EXT_NONE
},
5694 { STATE_RENDER(WINED3D_RS_FOGCOLOR
), { STATE_RENDER(WINED3D_RS_FOGCOLOR
), state_fogcolor
}, WINED3D_GL_EXT_NONE
},
5695 { STATE_RENDER(WINED3D_RS_FOGDENSITY
), { STATE_RENDER(WINED3D_RS_FOGDENSITY
), state_fogdensity
}, WINED3D_GL_EXT_NONE
},
5696 { STATE_RENDER(WINED3D_RS_FOGENABLE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), state_fog_fragpart
}, WINED3D_GL_EXT_NONE
},
5697 { STATE_RENDER(WINED3D_RS_FOGTABLEMODE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5698 { STATE_RENDER(WINED3D_RS_FOGVERTEXMODE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5699 { STATE_RENDER(WINED3D_RS_FOGSTART
), { STATE_RENDER(WINED3D_RS_FOGSTART
), state_fogstartend
}, WINED3D_GL_EXT_NONE
},
5700 { STATE_RENDER(WINED3D_RS_FOGEND
), { STATE_RENDER(WINED3D_RS_FOGSTART
), NULL
}, WINED3D_GL_EXT_NONE
},
5701 { STATE_RENDER(WINED3D_RS_SHADEMODE
), { STATE_RENDER(WINED3D_RS_SHADEMODE
), state_shademode
}, WINED3D_GL_EXT_NONE
},
5702 { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5703 { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5704 { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5705 { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5706 { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5707 { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5708 { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5709 { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5710 {0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE
},
5713 /* Context activation is done by the caller. */
5714 static void ffp_enable(const struct wined3d_gl_info
*gl_info
, BOOL enable
) {}
5716 static void *ffp_alloc(const struct wined3d_shader_backend_ops
*shader_backend
, void *shader_priv
)
5721 static void ffp_free(struct wined3d_device
*device
) {}
5723 static void vp_ffp_get_caps(const struct wined3d_gl_info
*gl_info
, struct wined3d_vertex_caps
*caps
)
5725 caps
->xyzrhw
= FALSE
;
5726 caps
->ffp_generic_attributes
= FALSE
;
5727 caps
->max_active_lights
= gl_info
->limits
.lights
;
5728 caps
->max_vertex_blend_matrices
= gl_info
->limits
.blends
;
5729 caps
->max_vertex_blend_matrix_index
= 0;
5730 caps
->vertex_processing_caps
= WINED3DVTXPCAPS_DIRECTIONALLIGHTS
5731 | WINED3DVTXPCAPS_MATERIALSOURCE7
5732 | WINED3DVTXPCAPS_POSITIONALLIGHTS
5733 | WINED3DVTXPCAPS_LOCALVIEWER
5734 | WINED3DVTXPCAPS_VERTEXFOG
5735 | WINED3DVTXPCAPS_TEXGEN
5736 | WINED3DVTXPCAPS_TEXGEN_SPHEREMAP
;
5737 caps
->fvf_caps
= WINED3DFVFCAPS_PSIZE
| 0x0008; /* 8 texture coords */
5738 caps
->max_user_clip_planes
= gl_info
->limits
.user_clip_distances
;
5739 caps
->raster_caps
= 0;
5740 if (gl_info
->supported
[NV_FOG_DISTANCE
])
5741 caps
->raster_caps
|= WINED3DPRASTERCAPS_FOGRANGE
;
5744 static DWORD
vp_ffp_get_emul_mask(const struct wined3d_gl_info
*gl_info
)
5746 return GL_EXT_EMUL_ARB_MULTITEXTURE
| GL_EXT_EMUL_EXT_FOG_COORD
;
5749 const struct wined3d_vertex_pipe_ops ffp_vertex_pipe
=
5753 vp_ffp_get_emul_mask
,
5759 static void ffp_fragment_get_caps(const struct wined3d_gl_info
*gl_info
, struct fragment_caps
*caps
)
5761 caps
->wined3d_caps
= 0;
5762 caps
->PrimitiveMiscCaps
= 0;
5763 caps
->TextureOpCaps
= WINED3DTEXOPCAPS_ADD
5764 | WINED3DTEXOPCAPS_ADDSIGNED
5765 | WINED3DTEXOPCAPS_ADDSIGNED2X
5766 | WINED3DTEXOPCAPS_MODULATE
5767 | WINED3DTEXOPCAPS_MODULATE2X
5768 | WINED3DTEXOPCAPS_MODULATE4X
5769 | WINED3DTEXOPCAPS_SELECTARG1
5770 | WINED3DTEXOPCAPS_SELECTARG2
5771 | WINED3DTEXOPCAPS_DISABLE
;
5773 if (gl_info
->supported
[ARB_TEXTURE_ENV_COMBINE
]
5774 || gl_info
->supported
[EXT_TEXTURE_ENV_COMBINE
]
5775 || gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
5777 caps
->TextureOpCaps
|= WINED3DTEXOPCAPS_BLENDDIFFUSEALPHA
5778 | WINED3DTEXOPCAPS_BLENDTEXTUREALPHA
5779 | WINED3DTEXOPCAPS_BLENDFACTORALPHA
5780 | WINED3DTEXOPCAPS_BLENDCURRENTALPHA
5781 | WINED3DTEXOPCAPS_LERP
5782 | WINED3DTEXOPCAPS_SUBTRACT
;
5784 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
]
5785 || gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
5787 caps
->TextureOpCaps
|= WINED3DTEXOPCAPS_ADDSMOOTH
5788 | WINED3DTEXOPCAPS_MULTIPLYADD
5789 | WINED3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR
5790 | WINED3DTEXOPCAPS_MODULATECOLOR_ADDALPHA
5791 | WINED3DTEXOPCAPS_BLENDTEXTUREALPHAPM
;
5793 if (gl_info
->supported
[ARB_TEXTURE_ENV_DOT3
])
5794 caps
->TextureOpCaps
|= WINED3DTEXOPCAPS_DOTPRODUCT3
;
5796 caps
->MaxTextureBlendStages
= gl_info
->limits
.textures
;
5797 caps
->MaxSimultaneousTextures
= gl_info
->limits
.textures
;
5800 static DWORD
ffp_fragment_get_emul_mask(const struct wined3d_gl_info
*gl_info
)
5802 return GL_EXT_EMUL_ARB_MULTITEXTURE
| GL_EXT_EMUL_EXT_FOG_COORD
;
5805 static BOOL
ffp_color_fixup_supported(struct color_fixup_desc fixup
)
5809 TRACE("Checking support for fixup:\n");
5810 dump_color_fixup_desc(fixup
);
5813 /* We only support identity conversions. */
5814 if (is_identity_fixup(fixup
))
5820 TRACE("[FAILED]\n");
5824 static BOOL
ffp_none_context_alloc(struct wined3d_context
*context
)
5829 static void ffp_none_context_free(struct wined3d_context
*context
)
5833 const struct fragment_pipeline ffp_fragment_pipeline
= {
5835 ffp_fragment_get_caps
,
5836 ffp_fragment_get_emul_mask
,
5839 ffp_none_context_alloc
,
5840 ffp_none_context_free
,
5841 ffp_color_fixup_supported
,
5842 ffp_fragmentstate_template
,
5845 static void none_enable(const struct wined3d_gl_info
*gl_info
, BOOL enable
) {}
5847 static void *none_alloc(const struct wined3d_shader_backend_ops
*shader_backend
, void *shader_priv
)
5852 static void none_free(struct wined3d_device
*device
) {}
5854 static void vp_none_get_caps(const struct wined3d_gl_info
*gl_info
, struct wined3d_vertex_caps
*caps
)
5856 memset(caps
, 0, sizeof(*caps
));
5859 static DWORD
vp_none_get_emul_mask(const struct wined3d_gl_info
*gl_info
)
5864 const struct wined3d_vertex_pipe_ops none_vertex_pipe
=
5868 vp_none_get_emul_mask
,
5874 static void fp_none_get_caps(const struct wined3d_gl_info
*gl_info
, struct fragment_caps
*caps
)
5876 memset(caps
, 0, sizeof(*caps
));
5879 static DWORD
fp_none_get_emul_mask(const struct wined3d_gl_info
*gl_info
)
5884 static BOOL
fp_none_color_fixup_supported(struct color_fixup_desc fixup
)
5886 return is_identity_fixup(fixup
);
5889 const struct fragment_pipeline none_fragment_pipe
=
5893 fp_none_get_emul_mask
,
5896 ffp_none_context_alloc
,
5897 ffp_none_context_free
,
5898 fp_none_color_fixup_supported
,
5902 static unsigned int num_handlers(const APPLYSTATEFUNC
*funcs
)
5905 for(i
= 0; funcs
[i
]; i
++);
5909 static void multistate_apply_2(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
5911 context
->device
->multistate_funcs
[state_id
][0](context
, state
, state_id
);
5912 context
->device
->multistate_funcs
[state_id
][1](context
, state
, state_id
);
5915 static void multistate_apply_3(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
5917 context
->device
->multistate_funcs
[state_id
][0](context
, state
, state_id
);
5918 context
->device
->multistate_funcs
[state_id
][1](context
, state
, state_id
);
5919 context
->device
->multistate_funcs
[state_id
][2](context
, state
, state_id
);
5922 static void prune_invalid_states(struct StateEntry
*state_table
, const struct wined3d_gl_info
*gl_info
,
5923 const struct wined3d_d3d_info
*d3d_info
)
5925 unsigned int start
, last
, i
;
5927 start
= STATE_TEXTURESTAGE(d3d_info
->limits
.ffp_blend_stages
, 0);
5928 last
= STATE_TEXTURESTAGE(MAX_TEXTURES
- 1, WINED3D_HIGHEST_TEXTURE_STATE
);
5929 for (i
= start
; i
<= last
; ++i
)
5931 state_table
[i
].representative
= 0;
5932 state_table
[i
].apply
= state_undefined
;
5935 start
= STATE_TRANSFORM(WINED3D_TS_TEXTURE0
+ d3d_info
->limits
.ffp_blend_stages
);
5936 last
= STATE_TRANSFORM(WINED3D_TS_TEXTURE0
+ MAX_TEXTURES
- 1);
5937 for (i
= start
; i
<= last
; ++i
)
5939 state_table
[i
].representative
= 0;
5940 state_table
[i
].apply
= state_undefined
;
5943 start
= STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(d3d_info
->limits
.ffp_vertex_blend_matrices
));
5944 last
= STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255));
5945 for (i
= start
; i
<= last
; ++i
)
5947 state_table
[i
].representative
= 0;
5948 state_table
[i
].apply
= state_undefined
;
5952 static void validate_state_table(struct StateEntry
*state_table
)
5974 static const DWORD simple_states
[] =
5980 STATE_SHADER(WINED3D_SHADER_TYPE_VERTEX
),
5981 STATE_SHADER(WINED3D_SHADER_TYPE_GEOMETRY
),
5982 STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL
),
5983 STATE_SHADER(WINED3D_SHADER_TYPE_COMPUTE
),
5984 STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_VERTEX
),
5985 STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GEOMETRY
),
5986 STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_PIXEL
),
5987 STATE_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_COMPUTE
),
5988 STATE_SHADER_RESOURCE_BINDING
,
5993 STATE_POINTSPRITECOORDORIGIN
,
5994 STATE_BASEVERTEXINDEX
,
5999 unsigned int i
, current
;
6001 for (i
= STATE_RENDER(1), current
= 0; i
<= STATE_RENDER(WINEHIGHEST_RENDER_STATE
); ++i
)
6003 if (!rs_holes
[current
].first
|| i
< STATE_RENDER(rs_holes
[current
].first
))
6005 if (!state_table
[i
].representative
)
6006 ERR("State %s (%#x) should have a representative.\n", debug_d3dstate(i
), i
);
6008 else if (state_table
[i
].representative
)
6009 ERR("State %s (%#x) shouldn't have a representative.\n", debug_d3dstate(i
), i
);
6011 if (i
== STATE_RENDER(rs_holes
[current
].last
)) ++current
;
6014 for (i
= 0; i
< sizeof(simple_states
) / sizeof(*simple_states
); ++i
)
6016 if (!state_table
[simple_states
[i
]].representative
)
6017 ERR("State %s (%#x) should have a representative.\n",
6018 debug_d3dstate(simple_states
[i
]), simple_states
[i
]);
6021 for (i
= 0; i
< STATE_HIGHEST
+ 1; ++i
)
6023 DWORD rep
= state_table
[i
].representative
;
6026 if (state_table
[rep
].representative
!= rep
)
6028 ERR("State %s (%#x) has invalid representative %s (%#x).\n",
6029 debug_d3dstate(i
), i
, debug_d3dstate(rep
), rep
);
6030 state_table
[i
].representative
= 0;
6035 if (state_table
[i
].apply
)
6036 ERR("State %s (%#x) has both a handler and representative.\n", debug_d3dstate(i
), i
);
6038 else if (!state_table
[i
].apply
)
6040 ERR("Self representing state %s (%#x) has no handler.\n", debug_d3dstate(i
), i
);
6046 HRESULT
compile_state_table(struct StateEntry
*StateTable
, APPLYSTATEFUNC
**dev_multistate_funcs
,
6047 const struct wined3d_gl_info
*gl_info
, const struct wined3d_d3d_info
*d3d_info
,
6048 const struct wined3d_vertex_pipe_ops
*vertex
, const struct fragment_pipeline
*fragment
,
6049 const struct StateEntryTemplate
*misc
)
6051 unsigned int i
, type
, handlers
;
6052 APPLYSTATEFUNC multistate_funcs
[STATE_HIGHEST
+ 1][3];
6053 const struct StateEntryTemplate
*cur
;
6054 BOOL set
[STATE_HIGHEST
+ 1];
6056 memset(multistate_funcs
, 0, sizeof(multistate_funcs
));
6058 for(i
= 0; i
< STATE_HIGHEST
+ 1; i
++) {
6059 StateTable
[i
].representative
= 0;
6060 StateTable
[i
].apply
= state_undefined
;
6063 for(type
= 0; type
< 3; type
++) {
6064 /* This switch decides the order in which the states are applied */
6066 case 0: cur
= misc
; break;
6067 case 1: cur
= fragment
->states
; break;
6068 case 2: cur
= vertex
->vp_states
; break;
6069 default: cur
= NULL
; /* Stupid compiler */
6073 /* GL extension filtering should not prevent multiple handlers being applied from different
6076 memset(set
, 0, sizeof(set
));
6078 for(i
= 0; cur
[i
].state
; i
++) {
6079 APPLYSTATEFUNC
*funcs_array
;
6081 /* Only use the first matching state with the available extension from one template.
6083 * {D3DRS_FOOBAR, {D3DRS_FOOBAR, func1}, XYZ_FANCY},
6084 * {D3DRS_FOOBAR, {D3DRS_FOOBAR, func2}, 0 }
6086 * if GL_XYZ_fancy is supported, ignore the 2nd line
6088 if(set
[cur
[i
].state
]) continue;
6089 /* Skip state lines depending on unsupported extensions */
6090 if (!gl_info
->supported
[cur
[i
].extension
]) continue;
6091 set
[cur
[i
].state
] = TRUE
;
6092 /* In some cases having an extension means that nothing has to be
6093 * done for a state, e.g. if GL_ARB_texture_non_power_of_two is
6094 * supported, the texture coordinate fixup can be ignored. If the
6095 * apply function is used, mark the state set(done above) to prevent
6096 * applying later lines, but do not record anything in the state
6099 if (!cur
[i
].content
.representative
) continue;
6101 handlers
= num_handlers(multistate_funcs
[cur
[i
].state
]);
6102 multistate_funcs
[cur
[i
].state
][handlers
] = cur
[i
].content
.apply
;
6105 StateTable
[cur
[i
].state
].apply
= cur
[i
].content
.apply
;
6108 StateTable
[cur
[i
].state
].apply
= multistate_apply_2
;
6109 if (!(dev_multistate_funcs
[cur
[i
].state
] = wined3d_calloc(2, sizeof(**dev_multistate_funcs
))))
6112 dev_multistate_funcs
[cur
[i
].state
][0] = multistate_funcs
[cur
[i
].state
][0];
6113 dev_multistate_funcs
[cur
[i
].state
][1] = multistate_funcs
[cur
[i
].state
][1];
6116 StateTable
[cur
[i
].state
].apply
= multistate_apply_3
;
6117 funcs_array
= HeapReAlloc(GetProcessHeap(),
6119 dev_multistate_funcs
[cur
[i
].state
],
6120 sizeof(**dev_multistate_funcs
) * 3);
6125 dev_multistate_funcs
[cur
[i
].state
] = funcs_array
;
6126 dev_multistate_funcs
[cur
[i
].state
][2] = multistate_funcs
[cur
[i
].state
][2];
6129 ERR("Unexpected amount of state handlers for state %u: %u\n",
6130 cur
[i
].state
, handlers
+ 1);
6133 if (StateTable
[cur
[i
].state
].representative
6134 && StateTable
[cur
[i
].state
].representative
!= cur
[i
].content
.representative
)
6136 FIXME("State %s (%#x) has different representatives in different pipeline parts.\n",
6137 debug_d3dstate(cur
[i
].state
), cur
[i
].state
);
6139 StateTable
[cur
[i
].state
].representative
= cur
[i
].content
.representative
;
6143 prune_invalid_states(StateTable
, gl_info
, d3d_info
);
6144 validate_state_table(StateTable
);
6149 for (i
= 0; i
<= STATE_HIGHEST
; ++i
) {
6150 HeapFree(GetProcessHeap(), 0, dev_multistate_funcs
[i
]);
6153 memset(dev_multistate_funcs
, 0, (STATE_HIGHEST
+ 1)*sizeof(*dev_multistate_funcs
));
6155 return E_OUTOFMEMORY
;