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
33 #include "wined3d_private.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(d3d
);
36 WINE_DECLARE_DEBUG_CHANNEL(d3d_shader
);
38 /* GL locking for state handlers is done by the caller. */
40 static void state_undefined(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
42 ERR("Undefined state.\n");
45 static void state_nop(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
47 TRACE("%s: nop in current pipe config.\n", debug_d3dstate(state_id
));
50 static void state_fillmode(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
52 enum wined3d_fill_mode mode
= state
->render_states
[WINED3D_RS_FILLMODE
];
56 case WINED3D_FILL_POINT
:
57 glPolygonMode(GL_FRONT_AND_BACK
, GL_POINT
);
58 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_POINT)");
60 case WINED3D_FILL_WIREFRAME
:
61 glPolygonMode(GL_FRONT_AND_BACK
, GL_LINE
);
62 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)");
64 case WINED3D_FILL_SOLID
:
65 glPolygonMode(GL_FRONT_AND_BACK
, GL_FILL
);
66 checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)");
69 FIXME("Unrecognized fill mode %#x.\n", mode
);
73 static void state_lighting(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
75 /* Lighting is not enabled if transformed vertices are drawn, but lighting
76 * does not affect the stream sources, so it is not grouped for
77 * performance reasons. This state reads the decoded vertex declaration,
78 * so if it is dirty don't do anything. The vertex declaration applying
79 * function calls this function for updating. */
80 if (isStateDirty(context
, STATE_VDECL
))
83 if (state
->render_states
[WINED3D_RS_LIGHTING
]
84 && !context
->swapchain
->device
->strided_streams
.position_transformed
)
86 glEnable(GL_LIGHTING
);
87 checkGLcall("glEnable GL_LIGHTING");
89 glDisable(GL_LIGHTING
);
90 checkGLcall("glDisable GL_LIGHTING");
94 static void state_zenable(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
96 /* No z test without depth stencil buffers */
97 if (!state
->fb
->depth_stencil
)
99 TRACE("No Z buffer - disabling depth test\n");
100 glDisable(GL_DEPTH_TEST
); /* This also disables z writing in gl */
101 checkGLcall("glDisable GL_DEPTH_TEST");
105 switch (state
->render_states
[WINED3D_RS_ZENABLE
])
107 case WINED3D_ZB_FALSE
:
108 glDisable(GL_DEPTH_TEST
);
109 checkGLcall("glDisable GL_DEPTH_TEST");
111 case WINED3D_ZB_TRUE
:
112 glEnable(GL_DEPTH_TEST
);
113 checkGLcall("glEnable GL_DEPTH_TEST");
115 case WINED3D_ZB_USEW
:
116 glEnable(GL_DEPTH_TEST
);
117 checkGLcall("glEnable GL_DEPTH_TEST");
118 FIXME("W buffer is not well handled\n");
121 FIXME("Unrecognized depth buffer type %#x.\n",
122 state
->render_states
[WINED3D_RS_ZENABLE
]);
126 static void state_cullmode(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
128 /* glFrontFace() is set in context.c at context init and on an
129 * offscreen / onscreen rendering switch. */
130 switch (state
->render_states
[WINED3D_RS_CULLMODE
])
132 case WINED3D_CULL_NONE
:
133 glDisable(GL_CULL_FACE
);
134 checkGLcall("glDisable GL_CULL_FACE");
136 case WINED3D_CULL_CW
:
137 glEnable(GL_CULL_FACE
);
138 checkGLcall("glEnable GL_CULL_FACE");
139 glCullFace(GL_FRONT
);
140 checkGLcall("glCullFace(GL_FRONT)");
142 case WINED3D_CULL_CCW
:
143 glEnable(GL_CULL_FACE
);
144 checkGLcall("glEnable GL_CULL_FACE");
146 checkGLcall("glCullFace(GL_BACK)");
149 FIXME("Unrecognized cull mode %#x.\n",
150 state
->render_states
[WINED3D_RS_CULLMODE
]);
154 static void state_shademode(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
156 switch (state
->render_states
[WINED3D_RS_SHADEMODE
])
158 case WINED3D_SHADE_FLAT
:
159 glShadeModel(GL_FLAT
);
160 checkGLcall("glShadeModel(GL_FLAT)");
162 case WINED3D_SHADE_GOURAUD
:
163 glShadeModel(GL_SMOOTH
);
164 checkGLcall("glShadeModel(GL_SMOOTH)");
166 case WINED3D_SHADE_PHONG
:
167 FIXME("WINED3D_SHADE_PHONG isn't supported.\n");
170 FIXME("Unrecognized shade mode %#x.\n",
171 state
->render_states
[WINED3D_RS_SHADEMODE
]);
175 static void state_ditherenable(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
177 if (state
->render_states
[WINED3D_RS_DITHERENABLE
])
180 checkGLcall("glEnable GL_DITHER");
184 glDisable(GL_DITHER
);
185 checkGLcall("glDisable GL_DITHER");
189 static void state_zwritenable(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
191 /* TODO: Test if in d3d z writing is enabled even if ZENABLE is off.
192 * If yes, this has to be merged with ZENABLE and ZFUNC. */
193 if (state
->render_states
[WINED3D_RS_ZWRITEENABLE
])
196 checkGLcall("glDepthMask(1)");
201 checkGLcall("glDepthMask(0)");
205 static GLenum
gl_compare_func(enum wined3d_cmp_func f
)
209 case WINED3D_CMP_NEVER
:
211 case WINED3D_CMP_LESS
:
213 case WINED3D_CMP_EQUAL
:
215 case WINED3D_CMP_LESSEQUAL
:
217 case WINED3D_CMP_GREATER
:
219 case WINED3D_CMP_NOTEQUAL
:
221 case WINED3D_CMP_GREATEREQUAL
:
223 case WINED3D_CMP_ALWAYS
:
226 FIXME("Unrecognized compare function %#x.\n", f
);
231 static void state_zfunc(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
233 GLenum depth_func
= gl_compare_func(state
->render_states
[WINED3D_RS_ZFUNC
]);
235 if (!depth_func
) return;
237 if (depth_func
== GL_EQUAL
|| depth_func
== GL_NOTEQUAL
)
240 /* There are a few issues with this: First, our inability to
241 * select a proper Z depth, most of the time we're stuck with
242 * D24S8, even if the app selects D32 or D16. There seem to be
243 * some other precision problems which have to be debugged to
244 * make NOTEQUAL and EQUAL work properly. */
248 FIXME("D3DCMP_NOTEQUAL and D3DCMP_EQUAL do not work correctly yet.\n");
252 glDepthFunc(depth_func
);
253 checkGLcall("glDepthFunc");
256 static void state_ambient(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
260 D3DCOLORTOGLFLOAT4(state
->render_states
[WINED3D_RS_AMBIENT
], col
);
261 TRACE("Setting ambient to (%f,%f,%f,%f)\n", col
[0], col
[1], col
[2], col
[3]);
262 glLightModelfv(GL_LIGHT_MODEL_AMBIENT
, col
);
263 checkGLcall("glLightModel for MODEL_AMBIENT");
266 static void state_blendop_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
268 WARN("Unsupported in local OpenGL implementation: glBlendEquation\n");
271 static GLenum
gl_blend_op(enum wined3d_blend_op op
)
275 case WINED3D_BLEND_OP_ADD
:
276 return GL_FUNC_ADD_EXT
;
277 case WINED3D_BLEND_OP_SUBTRACT
:
278 return GL_FUNC_SUBTRACT_EXT
;
279 case WINED3D_BLEND_OP_REVSUBTRACT
:
280 return GL_FUNC_REVERSE_SUBTRACT_EXT
;
281 case WINED3D_BLEND_OP_MIN
:
283 case WINED3D_BLEND_OP_MAX
:
286 FIXME("Unhandled blend op %#x.\n", op
);
291 static void state_blendop(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
293 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
294 GLenum blend_equation_alpha
= GL_FUNC_ADD_EXT
;
295 GLenum blend_equation
= GL_FUNC_ADD_EXT
;
297 /* BLENDOPALPHA requires GL_EXT_blend_equation_separate, so make sure it is around */
298 if (state
->render_states
[WINED3D_RS_BLENDOPALPHA
]
299 && !gl_info
->supported
[EXT_BLEND_EQUATION_SEPARATE
])
301 WARN("Unsupported in local OpenGL implementation: glBlendEquationSeparateEXT\n");
305 blend_equation
= gl_blend_op(state
->render_states
[WINED3D_RS_BLENDOP
]);
306 blend_equation_alpha
= gl_blend_op(state
->render_states
[WINED3D_RS_BLENDOPALPHA
]);
307 TRACE("blend_equation %#x, blend_equation_alpha %#x.\n", blend_equation
, blend_equation_alpha
);
309 if (state
->render_states
[WINED3D_RS_SEPARATEALPHABLENDENABLE
])
311 GL_EXTCALL(glBlendEquationSeparateEXT(blend_equation
, blend_equation_alpha
));
312 checkGLcall("glBlendEquationSeparateEXT");
316 GL_EXTCALL(glBlendEquationEXT(blend_equation
));
317 checkGLcall("glBlendEquation");
321 static GLenum
gl_blend_factor(enum wined3d_blend factor
, const struct wined3d_format
*dst_format
)
325 case WINED3D_BLEND_ZERO
:
327 case WINED3D_BLEND_ONE
:
329 case WINED3D_BLEND_SRCCOLOR
:
331 case WINED3D_BLEND_INVSRCCOLOR
:
332 return GL_ONE_MINUS_SRC_COLOR
;
333 case WINED3D_BLEND_SRCALPHA
:
335 case WINED3D_BLEND_INVSRCALPHA
:
336 return GL_ONE_MINUS_SRC_ALPHA
;
337 case WINED3D_BLEND_DESTCOLOR
:
339 case WINED3D_BLEND_INVDESTCOLOR
:
340 return GL_ONE_MINUS_DST_COLOR
;
341 /* To compensate for the lack of format switching with backbuffer
342 * offscreen rendering, and with onscreen rendering, we modify the
343 * alpha test parameters for (INV)DESTALPHA if the render target
344 * doesn't support alpha blending. A nonexistent alpha channel
345 * returns 1.0, so WINED3D_BLEND_DESTALPHA becomes GL_ONE, and
346 * WINED3D_BLEND_INVDESTALPHA becomes GL_ZERO. */
347 case WINED3D_BLEND_DESTALPHA
:
348 return dst_format
->alpha_mask
? GL_DST_ALPHA
: GL_ONE
;
349 case WINED3D_BLEND_INVDESTALPHA
:
350 return dst_format
->alpha_mask
? GL_ONE_MINUS_DST_ALPHA
: GL_ZERO
;
351 case WINED3D_BLEND_SRCALPHASAT
:
352 return GL_SRC_ALPHA_SATURATE
;
353 case WINED3D_BLEND_BLENDFACTOR
:
354 return GL_CONSTANT_COLOR_EXT
;
355 case WINED3D_BLEND_INVBLENDFACTOR
:
356 return GL_ONE_MINUS_CONSTANT_COLOR_EXT
;
358 FIXME("Unhandled blend factor %#x.\n", factor
);
363 static void state_blend(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
365 const struct wined3d_surface
*target
= state
->fb
->render_targets
[0];
366 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
367 GLenum srcBlend
, dstBlend
;
368 enum wined3d_blend d3d_blend
;
370 /* According to the red book, GL_LINE_SMOOTH needs GL_BLEND with specific
371 * blending parameters to work. */
372 if (state
->render_states
[WINED3D_RS_ALPHABLENDENABLE
]
373 || state
->render_states
[WINED3D_RS_EDGEANTIALIAS
]
374 || state
->render_states
[WINED3D_RS_ANTIALIASEDLINEENABLE
])
376 /* Disable blending in all cases even without pixelshaders.
377 * With blending on we could face a big performance penalty.
378 * The d3d9 visual test confirms the behavior. */
379 if (context
->render_offscreen
380 && !(target
->resource
.format
->flags
& WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
))
383 checkGLcall("glDisable GL_BLEND");
387 checkGLcall("glEnable GL_BLEND");
391 checkGLcall("glDisable GL_BLEND");
392 /* Nothing more to do - get out */
396 /* WINED3D_BLEND_BOTHSRCALPHA and WINED3D_BLEND_BOTHINVSRCALPHA are legacy
397 * source blending values which are still valid up to d3d9. They should
398 * not occur as dest blend values. */
399 d3d_blend
= state
->render_states
[WINED3D_RS_SRCBLEND
];
400 if (d3d_blend
== WINED3D_BLEND_BOTHSRCALPHA
)
402 srcBlend
= GL_SRC_ALPHA
;
403 dstBlend
= GL_ONE_MINUS_SRC_ALPHA
;
405 else if (d3d_blend
== WINED3D_BLEND_BOTHINVSRCALPHA
)
407 srcBlend
= GL_ONE_MINUS_SRC_ALPHA
;
408 dstBlend
= GL_SRC_ALPHA
;
412 srcBlend
= gl_blend_factor(d3d_blend
, target
->resource
.format
);
413 dstBlend
= gl_blend_factor(state
->render_states
[WINED3D_RS_DESTBLEND
],
414 target
->resource
.format
);
417 if (state
->render_states
[WINED3D_RS_EDGEANTIALIAS
]
418 || state
->render_states
[WINED3D_RS_ANTIALIASEDLINEENABLE
])
420 glEnable(GL_LINE_SMOOTH
);
421 checkGLcall("glEnable(GL_LINE_SMOOTH)");
422 if(srcBlend
!= GL_SRC_ALPHA
) {
423 WARN("WINED3D_RS_EDGEANTIALIAS enabled, but unexpected src blending param\n");
425 if(dstBlend
!= GL_ONE_MINUS_SRC_ALPHA
&& dstBlend
!= GL_ONE
) {
426 WARN("WINED3D_RS_EDGEANTIALIAS enabled, but unexpected dst blending param\n");
429 glDisable(GL_LINE_SMOOTH
);
430 checkGLcall("glDisable(GL_LINE_SMOOTH)");
433 /* Re-apply BLENDOP(ALPHA) because of a possible SEPARATEALPHABLENDENABLE change */
434 if (!isStateDirty(context
, STATE_RENDER(WINED3D_RS_BLENDOP
)))
435 state_blendop(context
, state
, STATE_RENDER(WINED3D_RS_BLENDOPALPHA
));
437 if (state
->render_states
[WINED3D_RS_SEPARATEALPHABLENDENABLE
])
439 GLenum srcBlendAlpha
, dstBlendAlpha
;
441 /* Separate alpha blending requires GL_EXT_blend_function_separate, so make sure it is around */
442 if (!context
->gl_info
->supported
[EXT_BLEND_FUNC_SEPARATE
])
444 WARN("Unsupported in local OpenGL implementation: glBlendFuncSeparateEXT\n");
448 /* WINED3D_BLEND_BOTHSRCALPHA and WINED3D_BLEND_BOTHINVSRCALPHA are legacy
449 * source blending values which are still valid up to d3d9. They should
450 * not occur as dest blend values. */
451 d3d_blend
= state
->render_states
[WINED3D_RS_SRCBLENDALPHA
];
452 if (d3d_blend
== WINED3D_BLEND_BOTHSRCALPHA
)
454 srcBlendAlpha
= GL_SRC_ALPHA
;
455 dstBlendAlpha
= GL_ONE_MINUS_SRC_ALPHA
;
457 else if (d3d_blend
== WINED3D_BLEND_BOTHINVSRCALPHA
)
459 srcBlendAlpha
= GL_ONE_MINUS_SRC_ALPHA
;
460 dstBlendAlpha
= GL_SRC_ALPHA
;
464 srcBlendAlpha
= gl_blend_factor(d3d_blend
, target
->resource
.format
);
465 dstBlendAlpha
= gl_blend_factor(state
->render_states
[WINED3D_RS_DESTBLENDALPHA
],
466 target
->resource
.format
);
469 GL_EXTCALL(glBlendFuncSeparateEXT(srcBlend
, dstBlend
, srcBlendAlpha
, dstBlendAlpha
));
470 checkGLcall("glBlendFuncSeparateEXT");
472 TRACE("glBlendFunc src=%x, dst=%x\n", srcBlend
, dstBlend
);
473 glBlendFunc(srcBlend
, dstBlend
);
474 checkGLcall("glBlendFunc");
477 /* Colorkey fixup for stage 0 alphaop depends on
478 * WINED3D_RS_ALPHABLENDENABLE state, so it may need updating. */
479 if (state
->render_states
[WINED3D_RS_COLORKEYENABLE
])
480 context_apply_state(context
, state
, STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
));
483 static void state_blendfactor_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
485 WARN("Unsupported in local OpenGL implementation: glBlendColorEXT\n");
488 static void state_blendfactor(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
490 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
493 TRACE("Setting blend factor to %#x.\n", state
->render_states
[WINED3D_RS_BLENDFACTOR
]);
495 D3DCOLORTOGLFLOAT4(state
->render_states
[WINED3D_RS_BLENDFACTOR
], col
);
496 GL_EXTCALL(glBlendColorEXT (col
[0],col
[1],col
[2],col
[3]));
497 checkGLcall("glBlendColor");
500 static void state_alpha(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
504 BOOL enable_ckey
= FALSE
;
506 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
508 /* Find out if the texture on the first stage has a ckey set
509 * The alpha state func reads the texture settings, even though alpha and texture are not grouped
510 * together. This is to avoid making a huge alpha+texture+texture stage+ckey block due to the hardly
511 * used WINED3D_RS_COLORKEYENABLE state(which is d3d <= 3 only). The texture function will call alpha
512 * in case it finds some texture+colorkeyenable combination which needs extra care.
514 if (state
->textures
[0])
516 struct wined3d_texture
*texture
= state
->textures
[0];
517 GLenum texture_dimensions
= texture
->target
;
519 if (texture_dimensions
== GL_TEXTURE_2D
|| texture_dimensions
== GL_TEXTURE_RECTANGLE_ARB
)
521 struct wined3d_surface
*surf
= surface_from_resource(texture
->sub_resources
[0]);
523 if (surf
->CKeyFlags
& WINEDDSD_CKSRCBLT
)
525 /* The surface conversion does not do color keying conversion for surfaces that have an alpha
526 * channel on their own. Likewise, the alpha test shouldn't be set up for color keying if the
527 * surface has alpha bits */
528 if (!surf
->resource
.format
->alpha_mask
) enable_ckey
= TRUE
;
533 if (enable_ckey
|| context
->last_was_ckey
)
534 context_apply_state(context
, state
, STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
));
535 context
->last_was_ckey
= enable_ckey
;
537 if (state
->render_states
[WINED3D_RS_ALPHATESTENABLE
]
538 || (state
->render_states
[WINED3D_RS_COLORKEYENABLE
] && enable_ckey
))
540 glEnable(GL_ALPHA_TEST
);
541 checkGLcall("glEnable GL_ALPHA_TEST");
543 glDisable(GL_ALPHA_TEST
);
544 checkGLcall("glDisable GL_ALPHA_TEST");
545 /* Alpha test is disabled, don't bother setting the params - it will happen on the next
551 if (state
->render_states
[WINED3D_RS_COLORKEYENABLE
] && enable_ckey
)
553 glParm
= GL_NOTEQUAL
;
558 ref
= ((float)state
->render_states
[WINED3D_RS_ALPHAREF
]) / 255.0f
;
559 glParm
= gl_compare_func(state
->render_states
[WINED3D_RS_ALPHAFUNC
]);
562 glAlphaFunc(glParm
, ref
);
563 checkGLcall("glAlphaFunc");
567 static void shaderconstant(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
569 const struct wined3d_device
*device
= context
->swapchain
->device
;
571 /* Vertex and pixel shader states will call a shader upload, don't do
572 * anything as long one of them has an update pending. */
573 if (isStateDirty(context
, STATE_VDECL
)
574 || isStateDirty(context
, STATE_PIXELSHADER
))
577 device
->shader_backend
->shader_load_constants(context
, use_ps(state
), use_vs(state
));
580 static void state_clipping(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
582 DWORD enable
= 0xFFFFFFFF;
583 DWORD disable
= 0x00000000;
587 const struct wined3d_device
*device
= context
->swapchain
->device
;
589 if (!device
->vs_clipping
)
591 /* The spec says that opengl clipping planes are disabled when using shaders. Direct3D planes aren't,
592 * so that is an issue. The MacOS ATI driver keeps clipping planes activated with shaders in some
593 * conditions I got sick of tracking down. The shader state handler disables all clip planes because
594 * of that - don't do anything here and keep them disabled
596 if (state
->render_states
[WINED3D_RS_CLIPPLANEENABLE
])
598 static BOOL warned
= FALSE
;
600 FIXME("Clipping not supported with vertex shaders\n");
607 /* glEnable(GL_CLIP_PLANEx) doesn't apply to vertex shaders. The enabled / disabled planes are
608 * hardcoded into the shader. Update the shader to update the enabled clipplanes */
609 if (!isStateDirty(context
, context
->state_table
[STATE_VSHADER
].representative
))
611 device
->shader_backend
->shader_select(context
, use_ps(state
), TRUE
);
612 if (!isStateDirty(context
, STATE_VERTEXSHADERCONSTANT
))
613 shaderconstant(context
, state
, STATE_VERTEXSHADERCONSTANT
);
617 /* TODO: Keep track of previously enabled clipplanes to avoid unnecessary resetting
618 * of already set values
621 /* If enabling / disabling all
622 * TODO: Is this correct? Doesn't D3DRS_CLIPPING disable clipping on the viewport frustrum?
624 if (state
->render_states
[WINED3D_RS_CLIPPING
])
626 enable
= state
->render_states
[WINED3D_RS_CLIPPLANEENABLE
];
627 disable
= ~state
->render_states
[WINED3D_RS_CLIPPLANEENABLE
];
631 disable
= 0xffffffff;
635 if (enable
& WINED3DCLIPPLANE0
) { glEnable(GL_CLIP_PLANE0
); checkGLcall("glEnable(clip plane 0)"); }
636 if (enable
& WINED3DCLIPPLANE1
) { glEnable(GL_CLIP_PLANE1
); checkGLcall("glEnable(clip plane 1)"); }
637 if (enable
& WINED3DCLIPPLANE2
) { glEnable(GL_CLIP_PLANE2
); checkGLcall("glEnable(clip plane 2)"); }
638 if (enable
& WINED3DCLIPPLANE3
) { glEnable(GL_CLIP_PLANE3
); checkGLcall("glEnable(clip plane 3)"); }
639 if (enable
& WINED3DCLIPPLANE4
) { glEnable(GL_CLIP_PLANE4
); checkGLcall("glEnable(clip plane 4)"); }
640 if (enable
& WINED3DCLIPPLANE5
) { glEnable(GL_CLIP_PLANE5
); checkGLcall("glEnable(clip plane 5)"); }
642 if (disable
& WINED3DCLIPPLANE0
) { glDisable(GL_CLIP_PLANE0
); checkGLcall("glDisable(clip plane 0)"); }
643 if (disable
& WINED3DCLIPPLANE1
) { glDisable(GL_CLIP_PLANE1
); checkGLcall("glDisable(clip plane 1)"); }
644 if (disable
& WINED3DCLIPPLANE2
) { glDisable(GL_CLIP_PLANE2
); checkGLcall("glDisable(clip plane 2)"); }
645 if (disable
& WINED3DCLIPPLANE3
) { glDisable(GL_CLIP_PLANE3
); checkGLcall("glDisable(clip plane 3)"); }
646 if (disable
& WINED3DCLIPPLANE4
) { glDisable(GL_CLIP_PLANE4
); checkGLcall("glDisable(clip plane 4)"); }
647 if (disable
& WINED3DCLIPPLANE5
) { glDisable(GL_CLIP_PLANE5
); checkGLcall("glDisable(clip plane 5)"); }
650 static void state_specularenable(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
652 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
653 /* Originally this used glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR)
654 * and (GL_LIGHT_MODEL_COLOR_CONTROL,GL_SINGLE_COLOR) to swap between enabled/disabled
655 * specular color. This is wrong:
656 * Separate specular color means the specular colour is maintained separately, whereas
657 * single color means it is merged in. However in both cases they are being used to
659 * To disable specular color, set it explicitly to black and turn off GL_COLOR_SUM_EXT
660 * NOTE: If not supported don't give FIXMEs the impact is really minimal and very few people are
664 * If register combiners are enabled, enabling / disabling GL_COLOR_SUM has no effect.
665 * Instead, we need to setup the FinalCombiner properly.
667 * The default setup for the FinalCombiner is:
669 * <variable> <input> <mapping> <usage>
670 * GL_VARIABLE_A_NV GL_FOG, GL_UNSIGNED_IDENTITY_NV GL_ALPHA
671 * GL_VARIABLE_B_NV GL_SPARE0_PLUS_SECONDARY_COLOR_NV GL_UNSIGNED_IDENTITY_NV GL_RGB
672 * GL_VARIABLE_C_NV GL_FOG GL_UNSIGNED_IDENTITY_NV GL_RGB
673 * GL_VARIABLE_D_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
674 * GL_VARIABLE_E_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
675 * GL_VARIABLE_F_NV GL_ZERO GL_UNSIGNED_IDENTITY_NV GL_RGB
676 * GL_VARIABLE_G_NV GL_SPARE0_NV GL_UNSIGNED_IDENTITY_NV GL_ALPHA
678 * That's pretty much fine as it is, except for variable B, which needs to take
679 * either GL_SPARE0_PLUS_SECONDARY_COLOR_NV or GL_SPARE0_NV, depending on
680 * whether WINED3D_RS_SPECULARENABLE is enabled or not.
683 TRACE("Setting specular enable state and materials\n");
684 if (state
->render_states
[WINED3D_RS_SPECULARENABLE
])
686 glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, (float *)&state
->material
.specular
);
687 checkGLcall("glMaterialfv");
689 if (state
->material
.power
> gl_info
->limits
.shininess
)
691 /* glMaterialf man page says that the material says that GL_SHININESS must be between 0.0
692 * and 128.0, although in d3d neither -1 nor 129 produce an error. GL_NV_max_light_exponent
693 * allows bigger values. If the extension is supported, gl_info->limits.shininess contains the
694 * value reported by the extension, otherwise 128. For values > gl_info->limits.shininess clamp
695 * them, it should be safe to do so without major visual distortions.
697 WARN("Material power = %.8e, limit %.8e\n", state
->material
.power
, gl_info
->limits
.shininess
);
698 glMaterialf(GL_FRONT_AND_BACK
, GL_SHININESS
, gl_info
->limits
.shininess
);
702 glMaterialf(GL_FRONT_AND_BACK
, GL_SHININESS
, state
->material
.power
);
704 checkGLcall("glMaterialf(GL_SHININESS)");
706 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
708 glEnable(GL_COLOR_SUM_EXT
);
712 TRACE("Specular colors cannot be enabled in this version of opengl\n");
714 checkGLcall("glEnable(GL_COLOR_SUM)");
716 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
718 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV
, GL_SPARE0_PLUS_SECONDARY_COLOR_NV
, GL_UNSIGNED_IDENTITY_NV
, GL_RGB
));
719 checkGLcall("glFinalCombinerInputNV()");
722 static const GLfloat black
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
724 /* for the case of enabled lighting: */
725 glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, &black
[0]);
726 checkGLcall("glMaterialfv");
728 /* for the case of disabled lighting: */
729 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
731 glDisable(GL_COLOR_SUM_EXT
);
735 TRACE("Specular colors cannot be disabled in this version of opengl\n");
737 checkGLcall("glDisable(GL_COLOR_SUM)");
739 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
741 GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV
, GL_SPARE0_NV
, GL_UNSIGNED_IDENTITY_NV
, GL_RGB
));
742 checkGLcall("glFinalCombinerInputNV()");
746 TRACE("diffuse {%.8e, %.8e, %.8e, %.8e}\n",
747 state
->material
.diffuse
.r
, state
->material
.diffuse
.g
,
748 state
->material
.diffuse
.b
, state
->material
.diffuse
.a
);
749 TRACE("ambient {%.8e, %.8e, %.8e, %.8e}\n",
750 state
->material
.ambient
.r
, state
->material
.ambient
.g
,
751 state
->material
.ambient
.b
, state
->material
.ambient
.a
);
752 TRACE("specular {%.8e, %.8e, %.8e, %.8e}\n",
753 state
->material
.specular
.r
, state
->material
.specular
.g
,
754 state
->material
.specular
.b
, state
->material
.specular
.a
);
755 TRACE("emissive {%.8e, %.8e, %.8e, %.8e}\n",
756 state
->material
.emissive
.r
, state
->material
.emissive
.g
,
757 state
->material
.emissive
.b
, state
->material
.emissive
.a
);
759 glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float *)&state
->material
.ambient
);
760 checkGLcall("glMaterialfv(GL_AMBIENT)");
761 glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float *)&state
->material
.diffuse
);
762 checkGLcall("glMaterialfv(GL_DIFFUSE)");
763 glMaterialfv(GL_FRONT_AND_BACK
, GL_EMISSION
, (float *)&state
->material
.emissive
);
764 checkGLcall("glMaterialfv(GL_EMISSION)");
767 static void state_texfactor(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
769 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
772 /* Note the texture color applies to all textures whereas
773 * GL_TEXTURE_ENV_COLOR applies to active only. */
775 D3DCOLORTOGLFLOAT4(state
->render_states
[WINED3D_RS_TEXTUREFACTOR
], col
);
777 /* And now the default texture color as well */
778 for (i
= 0; i
< gl_info
->limits
.texture_stages
; ++i
)
780 /* Note the WINED3D_RS value applies to all textures, but GL has one
781 * per texture, so apply it now ready to be used! */
782 context_active_texture(context
, gl_info
, i
);
784 glTexEnvfv(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_COLOR
, &col
[0]);
785 checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);");
789 static void renderstate_stencil_twosided(struct wined3d_context
*context
, GLint face
,
790 GLint func
, GLint ref
, GLuint mask
, GLint stencilFail
, GLint depthFail
, GLint stencilPass
)
792 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
794 glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT
);
795 checkGLcall("glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT)");
796 GL_EXTCALL(glActiveStencilFaceEXT(face
));
797 checkGLcall("glActiveStencilFaceEXT(...)");
798 glStencilFunc(func
, ref
, mask
);
799 checkGLcall("glStencilFunc(...)");
800 glStencilOp(stencilFail
, depthFail
, stencilPass
);
801 checkGLcall("glStencilOp(...)");
804 static GLenum
gl_stencil_op(enum wined3d_stencil_op op
)
808 case WINED3D_STENCIL_OP_KEEP
:
810 case WINED3D_STENCIL_OP_ZERO
:
812 case WINED3D_STENCIL_OP_REPLACE
:
814 case WINED3D_STENCIL_OP_INCR_SAT
:
816 case WINED3D_STENCIL_OP_DECR_SAT
:
818 case WINED3D_STENCIL_OP_INVERT
:
820 case WINED3D_STENCIL_OP_INCR
:
821 return GL_INCR_WRAP_EXT
;
822 case WINED3D_STENCIL_OP_DECR
:
823 return GL_DECR_WRAP_EXT
;
825 FIXME("Unrecognized stencil op %#x.\n", op
);
830 static void state_stencil(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
832 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
833 DWORD onesided_enable
= FALSE
;
834 DWORD twosided_enable
= FALSE
;
835 GLint func
= GL_ALWAYS
;
836 GLint func_ccw
= GL_ALWAYS
;
839 GLint stencilFail
= GL_KEEP
;
840 GLint depthFail
= GL_KEEP
;
841 GLint stencilPass
= GL_KEEP
;
842 GLint stencilFail_ccw
= GL_KEEP
;
843 GLint depthFail_ccw
= GL_KEEP
;
844 GLint stencilPass_ccw
= GL_KEEP
;
846 /* No stencil test without a stencil buffer. */
847 if (!state
->fb
->depth_stencil
)
849 glDisable(GL_STENCIL_TEST
);
850 checkGLcall("glDisable GL_STENCIL_TEST");
854 onesided_enable
= state
->render_states
[WINED3D_RS_STENCILENABLE
];
855 twosided_enable
= state
->render_states
[WINED3D_RS_TWOSIDEDSTENCILMODE
];
856 if (!(func
= gl_compare_func(state
->render_states
[WINED3D_RS_STENCILFUNC
])))
858 if (!(func_ccw
= gl_compare_func(state
->render_states
[WINED3D_RS_CCW_STENCILFUNC
])))
859 func_ccw
= GL_ALWAYS
;
860 ref
= state
->render_states
[WINED3D_RS_STENCILREF
];
861 mask
= state
->render_states
[WINED3D_RS_STENCILMASK
];
862 stencilFail
= gl_stencil_op(state
->render_states
[WINED3D_RS_STENCILFAIL
]);
863 depthFail
= gl_stencil_op(state
->render_states
[WINED3D_RS_STENCILZFAIL
]);
864 stencilPass
= gl_stencil_op(state
->render_states
[WINED3D_RS_STENCILPASS
]);
865 stencilFail_ccw
= gl_stencil_op(state
->render_states
[WINED3D_RS_CCW_STENCILFAIL
]);
866 depthFail_ccw
= gl_stencil_op(state
->render_states
[WINED3D_RS_CCW_STENCILZFAIL
]);
867 stencilPass_ccw
= gl_stencil_op(state
->render_states
[WINED3D_RS_CCW_STENCILPASS
]);
869 TRACE("(onesided %d, twosided %d, ref %x, mask %x, "
870 "GL_FRONT: func: %x, fail %x, zfail %x, zpass %x "
871 "GL_BACK: func: %x, fail %x, zfail %x, zpass %x )\n",
872 onesided_enable
, twosided_enable
, ref
, mask
,
873 func
, stencilFail
, depthFail
, stencilPass
,
874 func_ccw
, stencilFail_ccw
, depthFail_ccw
, stencilPass_ccw
);
876 if (twosided_enable
&& onesided_enable
) {
877 glEnable(GL_STENCIL_TEST
);
878 checkGLcall("glEnable GL_STENCIL_TEST");
880 if (gl_info
->supported
[EXT_STENCIL_TWO_SIDE
])
882 /* Apply back first, then front. This function calls glActiveStencilFaceEXT,
883 * which has an effect on the code below too. If we apply the front face
884 * afterwards, we are sure that the active stencil face is set to front,
885 * and other stencil functions which do not use two sided stencil do not have
888 renderstate_stencil_twosided(context
, GL_BACK
,
889 func_ccw
, ref
, mask
, stencilFail_ccw
, depthFail_ccw
, stencilPass_ccw
);
890 renderstate_stencil_twosided(context
, GL_FRONT
,
891 func
, ref
, mask
, stencilFail
, depthFail
, stencilPass
);
893 else if (gl_info
->supported
[ATI_SEPARATE_STENCIL
])
895 GL_EXTCALL(glStencilFuncSeparateATI(func
, func_ccw
, ref
, mask
));
896 checkGLcall("glStencilFuncSeparateATI(...)");
897 GL_EXTCALL(glStencilOpSeparateATI(GL_FRONT
, stencilFail
, depthFail
, stencilPass
));
898 checkGLcall("glStencilOpSeparateATI(GL_FRONT, ...)");
899 GL_EXTCALL(glStencilOpSeparateATI(GL_BACK
, stencilFail_ccw
, depthFail_ccw
, stencilPass_ccw
));
900 checkGLcall("glStencilOpSeparateATI(GL_BACK, ...)");
902 ERR("Separate (two sided) stencil not supported on this version of opengl. Caps weren't honored?\n");
905 else if(onesided_enable
)
907 if (gl_info
->supported
[EXT_STENCIL_TWO_SIDE
])
909 glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT
);
910 checkGLcall("glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT)");
913 /* This code disables the ATI extension as well, since the standard stencil functions are equal
914 * to calling the ATI functions with GL_FRONT_AND_BACK as face parameter
916 glEnable(GL_STENCIL_TEST
);
917 checkGLcall("glEnable GL_STENCIL_TEST");
918 glStencilFunc(func
, ref
, mask
);
919 checkGLcall("glStencilFunc(...)");
920 glStencilOp(stencilFail
, depthFail
, stencilPass
);
921 checkGLcall("glStencilOp(...)");
923 glDisable(GL_STENCIL_TEST
);
924 checkGLcall("glDisable GL_STENCIL_TEST");
928 static void state_stencilwrite2s(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
930 DWORD mask
= state
->fb
->depth_stencil
? state
->render_states
[WINED3D_RS_STENCILWRITEMASK
] : 0;
931 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
933 GL_EXTCALL(glActiveStencilFaceEXT(GL_BACK
));
934 checkGLcall("glActiveStencilFaceEXT(GL_BACK)");
936 checkGLcall("glStencilMask");
937 GL_EXTCALL(glActiveStencilFaceEXT(GL_FRONT
));
938 checkGLcall("glActiveStencilFaceEXT(GL_FRONT)");
942 static void state_stencilwrite(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
944 DWORD mask
= state
->fb
->depth_stencil
? state
->render_states
[WINED3D_RS_STENCILWRITEMASK
] : 0;
947 checkGLcall("glStencilMask");
950 static void state_fog_vertexpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
953 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
954 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
956 if (!state
->render_states
[WINED3D_RS_FOGENABLE
])
959 /* Table fog on: Never use fog coords, and use per-fragment fog */
960 if (state
->render_states
[WINED3D_RS_FOGTABLEMODE
] != WINED3D_FOG_NONE
)
962 glHint(GL_FOG_HINT
, GL_NICEST
);
963 if(context
->fog_coord
) {
964 glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FRAGMENT_DEPTH_EXT
);
965 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT)");
966 context
->fog_coord
= FALSE
;
969 /* Range fog is only used with per-vertex fog in d3d */
970 if (gl_info
->supported
[NV_FOG_DISTANCE
])
972 glFogi(GL_FOG_DISTANCE_MODE_NV
, GL_EYE_PLANE_ABSOLUTE_NV
);
973 checkGLcall("glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_PLANE_ABSOLUTE_NV)");
978 /* Otherwise use per-vertex fog in any case */
979 glHint(GL_FOG_HINT
, GL_FASTEST
);
981 if (state
->render_states
[WINED3D_RS_FOGVERTEXMODE
] == WINED3D_FOG_NONE
|| context
->last_was_rhw
)
983 /* No fog at all, or transformed vertices: Use fog coord */
984 if(!context
->fog_coord
) {
985 glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FOG_COORDINATE_EXT
);
986 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT)");
987 context
->fog_coord
= TRUE
;
992 /* Otherwise, use the fragment depth */
993 if(context
->fog_coord
) {
994 glFogi(GL_FOG_COORDINATE_SOURCE_EXT
, GL_FRAGMENT_DEPTH_EXT
);
995 checkGLcall("glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT)");
996 context
->fog_coord
= FALSE
;
999 if (state
->render_states
[WINED3D_RS_RANGEFOGENABLE
])
1001 if (gl_info
->supported
[NV_FOG_DISTANCE
])
1003 glFogi(GL_FOG_DISTANCE_MODE_NV
, GL_EYE_RADIAL_NV
);
1004 checkGLcall("glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_RADIAL_NV)");
1008 WARN("Range fog enabled, but not supported by this GL implementation.\n");
1011 else if (gl_info
->supported
[NV_FOG_DISTANCE
])
1013 glFogi(GL_FOG_DISTANCE_MODE_NV
, GL_EYE_PLANE_ABSOLUTE_NV
);
1014 checkGLcall("glFogi(GL_FOG_DISTANCE_MODE_NV, GL_EYE_PLANE_ABSOLUTE_NV)");
1019 void state_fogstartend(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1021 float fogstart
, fogend
;
1027 switch(context
->fog_source
) {
1033 case FOGSOURCE_COORD
:
1039 tmpvalue
.d
= state
->render_states
[WINED3D_RS_FOGSTART
];
1040 fogstart
= tmpvalue
.f
;
1041 tmpvalue
.d
= state
->render_states
[WINED3D_RS_FOGEND
];
1042 fogend
= tmpvalue
.f
;
1043 /* In GL, fogstart == fogend disables fog, in D3D everything's fogged.*/
1044 if(fogstart
== fogend
) {
1045 fogstart
= -1.0f
/ 0.0f
;
1051 /* This should not happen.context->fog_source is set in wined3d, not the app.
1052 * Still this is needed to make the compiler happy
1054 ERR("Unexpected fog coordinate source\n");
1059 glFogf(GL_FOG_START
, fogstart
);
1060 checkGLcall("glFogf(GL_FOG_START, fogstart)");
1061 TRACE("Fog Start == %f\n", fogstart
);
1063 glFogf(GL_FOG_END
, fogend
);
1064 checkGLcall("glFogf(GL_FOG_END, fogend)");
1065 TRACE("Fog End == %f\n", fogend
);
1068 void state_fog_fragpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1070 enum fogsource new_source
;
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 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 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 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 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 the specular
1173 * color contains a fog factor. Set it in drawStridedSlow.
1174 * Same happens with Vertexfog on transformed vertices
1176 new_source
= FOGSOURCE_COORD
;
1177 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 glFogi(GL_FOG_MODE
, GL_EXP
);
1194 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP)");
1197 case WINED3D_FOG_EXP2
:
1198 glFogi(GL_FOG_MODE
, GL_EXP2
);
1199 checkGLcall("glFogi(GL_FOG_MODE, GL_EXP2)");
1202 case WINED3D_FOG_LINEAR
:
1203 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
)
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
)
1227 D3DCOLORTOGLFLOAT4(state
->render_states
[WINED3D_RS_FOGCOLOR
], col
);
1228 glFogfv(GL_FOG_COLOR
, &col
[0]);
1229 checkGLcall("glFog GL_FOG_COLOR");
1232 void state_fogdensity(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1239 tmpvalue
.d
= state
->render_states
[WINED3D_RS_FOGDENSITY
];
1240 glFogfv(GL_FOG_DENSITY
, &tmpvalue
.f
);
1241 checkGLcall("glFogf(GL_FOG_DENSITY, (float) Value)");
1244 static void state_colormat(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1246 const struct wined3d_device
*device
= context
->swapchain
->device
;
1249 /* Depends on the decoded vertex declaration to read the existence of diffuse data.
1250 * The vertex declaration will call this function if the fixed function pipeline is used.
1253 if(isStateDirty(context
, STATE_VDECL
)) {
1257 context
->num_untracked_materials
= 0;
1258 if ((device
->strided_streams
.use_map
& (1 << WINED3D_FFP_DIFFUSE
))
1259 && state
->render_states
[WINED3D_RS_COLORVERTEX
])
1261 TRACE("diff %d, amb %d, emis %d, spec %d\n",
1262 state
->render_states
[WINED3D_RS_DIFFUSEMATERIALSOURCE
],
1263 state
->render_states
[WINED3D_RS_AMBIENTMATERIALSOURCE
],
1264 state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
],
1265 state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
]);
1267 if (state
->render_states
[WINED3D_RS_DIFFUSEMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1269 if (state
->render_states
[WINED3D_RS_AMBIENTMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1270 Parm
= GL_AMBIENT_AND_DIFFUSE
;
1273 if (state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1275 context
->untracked_materials
[context
->num_untracked_materials
] = GL_EMISSION
;
1276 context
->num_untracked_materials
++;
1278 if (state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1280 context
->untracked_materials
[context
->num_untracked_materials
] = GL_SPECULAR
;
1281 context
->num_untracked_materials
++;
1284 else if (state
->render_states
[WINED3D_RS_AMBIENTMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1287 if (state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1289 context
->untracked_materials
[context
->num_untracked_materials
] = GL_EMISSION
;
1290 context
->num_untracked_materials
++;
1292 if (state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1294 context
->untracked_materials
[context
->num_untracked_materials
] = GL_SPECULAR
;
1295 context
->num_untracked_materials
++;
1298 else if (state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1301 if (state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1303 context
->untracked_materials
[context
->num_untracked_materials
] = GL_SPECULAR
;
1304 context
->num_untracked_materials
++;
1307 else if (state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
] == WINED3D_MCS_COLOR1
)
1313 /* Nothing changed, return. */
1314 if (Parm
== context
->tracking_parm
) return;
1317 glDisable(GL_COLOR_MATERIAL
);
1318 checkGLcall("glDisable GL_COLOR_MATERIAL");
1320 glColorMaterial(GL_FRONT_AND_BACK
, Parm
);
1321 checkGLcall("glColorMaterial(GL_FRONT_AND_BACK, Parm)");
1322 glEnable(GL_COLOR_MATERIAL
);
1323 checkGLcall("glEnable(GL_COLOR_MATERIAL)");
1326 /* Apparently calls to glMaterialfv are ignored for properties we're
1327 * tracking with glColorMaterial, so apply those here. */
1328 switch (context
->tracking_parm
) {
1329 case GL_AMBIENT_AND_DIFFUSE
:
1330 glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float *)&state
->material
.ambient
);
1331 glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float *)&state
->material
.diffuse
);
1332 checkGLcall("glMaterialfv");
1336 glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, (float *)&state
->material
.diffuse
);
1337 checkGLcall("glMaterialfv");
1341 glMaterialfv(GL_FRONT_AND_BACK
, GL_AMBIENT
, (float *)&state
->material
.ambient
);
1342 checkGLcall("glMaterialfv");
1346 glMaterialfv(GL_FRONT_AND_BACK
, GL_EMISSION
, (float *)&state
->material
.emissive
);
1347 checkGLcall("glMaterialfv");
1351 /* Only change material color if specular is enabled, otherwise it is set to black */
1352 if (state
->render_states
[WINED3D_RS_SPECULARENABLE
])
1354 glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, (float *)&state
->material
.specular
);
1355 checkGLcall("glMaterialfv");
1359 static const GLfloat black
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
1360 glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, &black
[0]);
1361 checkGLcall("glMaterialfv");
1366 context
->tracking_parm
= Parm
;
1369 static void state_linepattern(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1374 struct wined3d_line_pattern lp
;
1376 tmppattern
.d
= state
->render_states
[WINED3D_RS_LINEPATTERN
];
1378 TRACE("Line pattern: repeat %d bits %x.\n", tmppattern
.lp
.repeat_factor
, tmppattern
.lp
.line_pattern
);
1380 if (tmppattern
.lp
.repeat_factor
)
1382 glLineStipple(tmppattern
.lp
.repeat_factor
, tmppattern
.lp
.line_pattern
);
1383 checkGLcall("glLineStipple(repeat, linepattern)");
1384 glEnable(GL_LINE_STIPPLE
);
1385 checkGLcall("glEnable(GL_LINE_STIPPLE);");
1389 glDisable(GL_LINE_STIPPLE
);
1390 checkGLcall("glDisable(GL_LINE_STIPPLE);");
1394 static void state_normalize(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1396 if (isStateDirty(context
, STATE_VDECL
))
1399 /* Without vertex normals, we set the current normal to 0/0/0 to remove the diffuse factor
1400 * from the opengl lighting equation, as d3d does. Normalization of 0/0/0 can lead to a division
1401 * by zero and is not properly defined in opengl, so avoid it
1403 if (state
->render_states
[WINED3D_RS_NORMALIZENORMALS
]
1404 && (context
->swapchain
->device
->strided_streams
.use_map
& (1 << WINED3D_FFP_NORMAL
)))
1406 glEnable(GL_NORMALIZE
);
1407 checkGLcall("glEnable(GL_NORMALIZE);");
1411 glDisable(GL_NORMALIZE
);
1412 checkGLcall("glDisable(GL_NORMALIZE);");
1416 static void state_psizemin_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1423 tmpvalue
.d
= state
->render_states
[WINED3D_RS_POINTSIZE_MIN
];
1424 if (tmpvalue
.f
!= 1.0f
)
1426 FIXME("WINED3D_RS_POINTSIZE_MIN not supported on this opengl, value is %f\n", tmpvalue
.f
);
1428 tmpvalue
.d
= state
->render_states
[WINED3D_RS_POINTSIZE_MAX
];
1429 if (tmpvalue
.f
!= 64.0f
)
1431 FIXME("WINED3D_RS_POINTSIZE_MAX not supported on this opengl, value is %f\n", tmpvalue
.f
);
1436 static void state_psizemin_ext(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1438 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1445 min
.d
= state
->render_states
[WINED3D_RS_POINTSIZE_MIN
];
1446 max
.d
= state
->render_states
[WINED3D_RS_POINTSIZE_MAX
];
1448 /* Max point size trumps min point size */
1453 GL_EXTCALL(glPointParameterfEXT
)(GL_POINT_SIZE_MIN_EXT
, min
.f
);
1454 checkGLcall("glPointParameterfEXT(...)");
1455 GL_EXTCALL(glPointParameterfEXT
)(GL_POINT_SIZE_MAX_EXT
, max
.f
);
1456 checkGLcall("glPointParameterfEXT(...)");
1459 static void state_psizemin_arb(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1461 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1468 min
.d
= state
->render_states
[WINED3D_RS_POINTSIZE_MIN
];
1469 max
.d
= state
->render_states
[WINED3D_RS_POINTSIZE_MAX
];
1471 /* Max point size trumps min point size */
1476 GL_EXTCALL(glPointParameterfARB
)(GL_POINT_SIZE_MIN_ARB
, min
.f
);
1477 checkGLcall("glPointParameterfARB(...)");
1478 GL_EXTCALL(glPointParameterfARB
)(GL_POINT_SIZE_MAX_ARB
, max
.f
);
1479 checkGLcall("glPointParameterfARB(...)");
1482 static void state_pscale(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1484 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1485 /* TODO: Group this with the viewport */
1487 * POINTSCALEENABLE controls how point size value is treated. If set to
1488 * true, the point size is scaled with respect to height of viewport.
1489 * When set to false point size is in pixels.
1492 /* Default values */
1493 GLfloat att
[3] = {1.0f
, 0.0f
, 0.0f
};
1497 } pointSize
, A
, B
, C
;
1499 pointSize
.d
= state
->render_states
[WINED3D_RS_POINTSIZE
];
1500 A
.d
= state
->render_states
[WINED3D_RS_POINTSCALE_A
];
1501 B
.d
= state
->render_states
[WINED3D_RS_POINTSCALE_B
];
1502 C
.d
= state
->render_states
[WINED3D_RS_POINTSCALE_C
];
1504 if (state
->render_states
[WINED3D_RS_POINTSCALEENABLE
])
1506 DWORD h
= state
->viewport
.height
;
1507 GLfloat scaleFactor
;
1509 if (pointSize
.f
< gl_info
->limits
.pointsize_min
)
1511 /* Minimum valid point size for OpenGL is driver specific. For Direct3D it is
1512 * 0.0f. This means that OpenGL will clamp really small point sizes to the
1513 * driver minimum. To correct for this we need to multiply by the scale factor when sizes
1514 * are less than 1.0f. scale_factor = 1.0f / point_size.
1516 scaleFactor
= pointSize
.f
/ gl_info
->limits
.pointsize_min
;
1517 /* Clamp the point size, don't rely on the driver to do it. MacOS says min point size
1518 * is 1.0, but then accepts points below that and draws too small points
1520 pointSize
.f
= gl_info
->limits
.pointsize_min
;
1522 else if(pointSize
.f
> gl_info
->limits
.pointsize_max
)
1524 /* gl already scales the input to glPointSize,
1525 * d3d scales the result after the point size scale.
1526 * If the point size is bigger than the max size, use the
1527 * scaling to scale it bigger, and set the gl point size to max
1529 scaleFactor
= pointSize
.f
/ gl_info
->limits
.pointsize_max
;
1530 TRACE("scale: %f\n", scaleFactor
);
1531 pointSize
.f
= gl_info
->limits
.pointsize_max
;
1535 scaleFactor
= powf(h
* scaleFactor
, 2);
1537 att
[0] = A
.f
/ scaleFactor
;
1538 att
[1] = B
.f
/ scaleFactor
;
1539 att
[2] = C
.f
/ scaleFactor
;
1542 if (gl_info
->supported
[ARB_POINT_PARAMETERS
])
1544 GL_EXTCALL(glPointParameterfvARB
)(GL_POINT_DISTANCE_ATTENUATION_ARB
, att
);
1545 checkGLcall("glPointParameterfvARB(GL_DISTANCE_ATTENUATION_ARB, ...)");
1547 else if (gl_info
->supported
[EXT_POINT_PARAMETERS
])
1549 GL_EXTCALL(glPointParameterfvEXT
)(GL_DISTANCE_ATTENUATION_EXT
, att
);
1550 checkGLcall("glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, ...)");
1552 else if (state
->render_states
[WINED3D_RS_POINTSCALEENABLE
])
1554 WARN("POINT_PARAMETERS not supported in this version of opengl\n");
1557 glPointSize(pointSize
.f
);
1558 checkGLcall("glPointSize(...);");
1561 static void state_debug_monitor(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1563 WARN("token: %#x.\n", state
->render_states
[WINED3D_RS_DEBUGMONITORTOKEN
]);
1566 static void state_colorwrite(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1568 DWORD mask0
= state
->render_states
[WINED3D_RS_COLORWRITEENABLE
];
1569 DWORD mask1
= state
->render_states
[WINED3D_RS_COLORWRITEENABLE1
];
1570 DWORD mask2
= state
->render_states
[WINED3D_RS_COLORWRITEENABLE2
];
1571 DWORD mask3
= state
->render_states
[WINED3D_RS_COLORWRITEENABLE3
];
1573 TRACE("Color mask: r(%d) g(%d) b(%d) a(%d)\n",
1574 mask0
& WINED3DCOLORWRITEENABLE_RED
? 1 : 0,
1575 mask0
& WINED3DCOLORWRITEENABLE_GREEN
? 1 : 0,
1576 mask0
& WINED3DCOLORWRITEENABLE_BLUE
? 1 : 0,
1577 mask0
& WINED3DCOLORWRITEENABLE_ALPHA
? 1 : 0);
1578 glColorMask(mask0
& WINED3DCOLORWRITEENABLE_RED
? GL_TRUE
: GL_FALSE
,
1579 mask0
& WINED3DCOLORWRITEENABLE_GREEN
? GL_TRUE
: GL_FALSE
,
1580 mask0
& WINED3DCOLORWRITEENABLE_BLUE
? GL_TRUE
: GL_FALSE
,
1581 mask0
& WINED3DCOLORWRITEENABLE_ALPHA
? GL_TRUE
: GL_FALSE
);
1582 checkGLcall("glColorMask(...)");
1584 if (!((mask1
== mask0
&& mask2
== mask0
&& mask3
== mask0
)
1585 || (mask1
== 0xf && mask2
== 0xf && mask3
== 0xf)))
1587 FIXME("WINED3D_RS_COLORWRITEENABLE/1/2/3, %#x/%#x/%#x/%#x not yet implemented.\n",
1588 mask0
, mask1
, mask2
, mask3
);
1589 FIXME("Missing of cap D3DPMISCCAPS_INDEPENDENTWRITEMASKS wasn't honored?\n");
1593 static void set_color_mask(const struct wined3d_gl_info
*gl_info
, UINT index
, DWORD mask
)
1595 GL_EXTCALL(glColorMaskIndexedEXT(index
,
1596 mask
& WINED3DCOLORWRITEENABLE_RED
? GL_TRUE
: GL_FALSE
,
1597 mask
& WINED3DCOLORWRITEENABLE_GREEN
? GL_TRUE
: GL_FALSE
,
1598 mask
& WINED3DCOLORWRITEENABLE_BLUE
? GL_TRUE
: GL_FALSE
,
1599 mask
& WINED3DCOLORWRITEENABLE_ALPHA
? GL_TRUE
: GL_FALSE
));
1602 static void state_colorwrite0(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1604 set_color_mask(context
->gl_info
, 0, state
->render_states
[WINED3D_RS_COLORWRITEENABLE
]);
1607 static void state_colorwrite1(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1609 set_color_mask(context
->gl_info
, 1, state
->render_states
[WINED3D_RS_COLORWRITEENABLE1
]);
1612 static void state_colorwrite2(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1614 set_color_mask(context
->gl_info
, 2, state
->render_states
[WINED3D_RS_COLORWRITEENABLE2
]);
1617 static void state_colorwrite3(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1619 set_color_mask(context
->gl_info
, 3, state
->render_states
[WINED3D_RS_COLORWRITEENABLE3
]);
1622 static void state_localviewer(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1624 if (state
->render_states
[WINED3D_RS_LOCALVIEWER
])
1626 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER
, 1);
1627 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1)");
1629 glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER
, 0);
1630 checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 0)");
1634 static void state_lastpixel(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1636 if (state
->render_states
[WINED3D_RS_LASTPIXEL
])
1638 TRACE("Last Pixel Drawing Enabled\n");
1644 FIXME("Last Pixel Drawing Disabled, not handled yet\n");
1647 TRACE("Last Pixel Drawing Disabled, not handled yet\n");
1652 static void state_pointsprite_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1656 /* TODO: NV_POINT_SPRITE */
1657 if (!warned
&& state
->render_states
[WINED3D_RS_POINTSPRITEENABLE
])
1659 /* A FIXME, not a WARN because point sprites should be software emulated if not supported by HW */
1660 FIXME("Point sprites not supported\n");
1665 static void state_pointsprite(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1667 if (state
->render_states
[WINED3D_RS_POINTSPRITEENABLE
])
1669 glEnable(GL_POINT_SPRITE_ARB
);
1670 checkGLcall("glEnable(GL_POINT_SPRITE_ARB)");
1672 glDisable(GL_POINT_SPRITE_ARB
);
1673 checkGLcall("glDisable(GL_POINT_SPRITE_ARB)");
1677 static void state_wrap(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1679 if (state
->render_states
[WINED3D_RS_WRAP0
]
1680 || state
->render_states
[WINED3D_RS_WRAP1
]
1681 || state
->render_states
[WINED3D_RS_WRAP2
]
1682 || state
->render_states
[WINED3D_RS_WRAP3
]
1683 || state
->render_states
[WINED3D_RS_WRAP4
]
1684 || state
->render_states
[WINED3D_RS_WRAP5
]
1685 || state
->render_states
[WINED3D_RS_WRAP6
]
1686 || state
->render_states
[WINED3D_RS_WRAP7
]
1687 || state
->render_states
[WINED3D_RS_WRAP8
]
1688 || state
->render_states
[WINED3D_RS_WRAP9
]
1689 || state
->render_states
[WINED3D_RS_WRAP10
]
1690 || state
->render_states
[WINED3D_RS_WRAP11
]
1691 || state
->render_states
[WINED3D_RS_WRAP12
]
1692 || state
->render_states
[WINED3D_RS_WRAP13
]
1693 || state
->render_states
[WINED3D_RS_WRAP14
]
1694 || state
->render_states
[WINED3D_RS_WRAP15
])
1695 FIXME("(WINED3D_RS_WRAP0) Texture wrapping not yet supported.\n");
1698 static void state_msaa_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1700 if (state
->render_states
[WINED3D_RS_MULTISAMPLEANTIALIAS
])
1701 WARN("Multisample antialiasing not supported by GL.\n");
1704 static void state_msaa(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1706 if (state
->render_states
[WINED3D_RS_MULTISAMPLEANTIALIAS
])
1708 glEnable(GL_MULTISAMPLE_ARB
);
1709 checkGLcall("glEnable(GL_MULTISAMPLE_ARB)");
1711 glDisable(GL_MULTISAMPLE_ARB
);
1712 checkGLcall("glDisable(GL_MULTISAMPLE_ARB)");
1716 static void state_scissor(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1718 if (state
->render_states
[WINED3D_RS_SCISSORTESTENABLE
])
1720 glEnable(GL_SCISSOR_TEST
);
1721 checkGLcall("glEnable(GL_SCISSOR_TEST)");
1723 glDisable(GL_SCISSOR_TEST
);
1724 checkGLcall("glDisable(GL_SCISSOR_TEST)");
1728 /* The Direct3D depth bias is specified in normalized depth coordinates. In
1729 * OpenGL the bias is specified in units of "the smallest value that is
1730 * guaranteed to produce a resolvable offset for a given implementation". To
1731 * convert from D3D to GL we need to divide the D3D depth bias by that value.
1732 * There's no practical way to retrieve that value from a given GL
1733 * implementation, but the D3D application has essentially the same problem,
1734 * which makes a guess of the depth buffer format's highest possible value a
1735 * reasonable guess. Note that SLOPESCALEDEPTHBIAS is a scaling factor for the
1736 * depth slope, and doesn't need to be scaled. */
1737 static void state_depthbias(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1739 if (state
->render_states
[WINED3D_RS_SLOPESCALEDEPTHBIAS
]
1740 || state
->render_states
[WINED3D_RS_DEPTHBIAS
])
1742 const struct wined3d_surface
*depth
= state
->fb
->depth_stencil
;
1749 } scale_bias
, const_bias
;
1751 scale_bias
.d
= state
->render_states
[WINED3D_RS_SLOPESCALEDEPTHBIAS
];
1752 const_bias
.d
= state
->render_states
[WINED3D_RS_DEPTHBIAS
];
1754 glEnable(GL_POLYGON_OFFSET_FILL
);
1755 checkGLcall("glEnable(GL_POLYGON_OFFSET_FILL)");
1757 if (context
->swapchain
->device
->wined3d
->flags
& WINED3D_LEGACY_DEPTH_BIAS
)
1759 float bias
= -(float)const_bias
.d
;
1760 glPolygonOffset(bias
, bias
);
1761 checkGLcall("glPolygonOffset");
1767 const struct wined3d_format
*fmt
= depth
->resource
.format
;
1768 scale
= powf(2, fmt
->depth_size
) - 1;
1769 TRACE("Depth format %s, using depthbias scale of %.8e.\n",
1770 debug_d3dformat(fmt
->id
), scale
);
1774 /* The context manager will reapply this state on a depth stencil change */
1775 TRACE("No depth stencil, using depthbias scale of 0.0.\n");
1779 glPolygonOffset(scale_bias
.f
, const_bias
.f
* scale
);
1780 checkGLcall("glPolygonOffset(...)");
1785 glDisable(GL_POLYGON_OFFSET_FILL
);
1786 checkGLcall("glDisable(GL_POLYGON_OFFSET_FILL)");
1790 static void state_zvisible(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1792 if (state
->render_states
[WINED3D_RS_ZVISIBLE
])
1793 FIXME("WINED3D_RS_ZVISIBLE not implemented.\n");
1796 static void state_perspective(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1798 if (state
->render_states
[WINED3D_RS_TEXTUREPERSPECTIVE
])
1800 glHint(GL_PERSPECTIVE_CORRECTION_HINT
, GL_NICEST
);
1801 checkGLcall("glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)");
1803 glHint(GL_PERSPECTIVE_CORRECTION_HINT
, GL_FASTEST
);
1804 checkGLcall("glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST)");
1808 static void state_stippledalpha(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1810 if (state
->render_states
[WINED3D_RS_STIPPLEDALPHA
])
1811 FIXME("Stippled Alpha not supported yet.\n");
1814 static void state_antialias(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1816 if (state
->render_states
[WINED3D_RS_ANTIALIAS
])
1817 FIXME("Antialias not supported yet.\n");
1820 static void state_multisampmask(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1822 if (state
->render_states
[WINED3D_RS_MULTISAMPLEMASK
] != 0xffffffff)
1823 FIXME("WINED3D_RS_MULTISAMPLEMASK %#x not yet implemented.\n",
1824 state
->render_states
[WINED3D_RS_MULTISAMPLEMASK
]);
1827 static void state_patchedgestyle(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1829 if (state
->render_states
[WINED3D_RS_PATCHEDGESTYLE
] != WINED3D_PATCH_EDGE_DISCRETE
)
1830 FIXME("WINED3D_RS_PATCHEDGESTYLE %#x not yet implemented.\n",
1831 state
->render_states
[WINED3D_RS_PATCHEDGESTYLE
]);
1834 static void state_patchsegments(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1842 if (state
->render_states
[WINED3D_RS_PATCHSEGMENTS
] != tmpvalue
.d
)
1844 static BOOL displayed
= FALSE
;
1846 tmpvalue
.d
= state
->render_states
[WINED3D_RS_PATCHSEGMENTS
];
1848 FIXME("(WINED3D_RS_PATCHSEGMENTS,%f) not yet implemented\n", tmpvalue
.f
);
1854 static void state_positiondegree(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1856 if (state
->render_states
[WINED3D_RS_POSITIONDEGREE
] != WINED3D_DEGREE_CUBIC
)
1857 FIXME("WINED3D_RS_POSITIONDEGREE %#x not yet implemented.\n",
1858 state
->render_states
[WINED3D_RS_POSITIONDEGREE
]);
1861 static void state_normaldegree(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1863 if (state
->render_states
[WINED3D_RS_NORMALDEGREE
] != WINED3D_DEGREE_LINEAR
)
1864 FIXME("WINED3D_RS_NORMALDEGREE %#x not yet implemented.\n",
1865 state
->render_states
[WINED3D_RS_NORMALDEGREE
]);
1868 static void state_tessellation(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1870 if (state
->render_states
[WINED3D_RS_ENABLEADAPTIVETESSELLATION
])
1871 FIXME("WINED3D_RS_ENABLEADAPTIVETESSELLATION %#x not yet implemented.\n",
1872 state
->render_states
[WINED3D_RS_ENABLEADAPTIVETESSELLATION
]);
1875 static void state_nvdb(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1882 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
1884 if (state
->render_states
[WINED3D_RS_ADAPTIVETESS_X
] == WINED3DFMT_NVDB
)
1886 zmin
.d
= state
->render_states
[WINED3D_RS_ADAPTIVETESS_Z
];
1887 zmax
.d
= state
->render_states
[WINED3D_RS_ADAPTIVETESS_W
];
1889 /* If zmin is larger than zmax INVALID_VALUE error is generated.
1890 * In d3d9 test is not performed in this case*/
1891 if (zmin
.f
<= zmax
.f
)
1893 glEnable(GL_DEPTH_BOUNDS_TEST_EXT
);
1894 checkGLcall("glEnable(GL_DEPTH_BOUNDS_TEST_EXT)");
1895 GL_EXTCALL(glDepthBoundsEXT(zmin
.f
, zmax
.f
));
1896 checkGLcall("glDepthBoundsEXT(...)");
1899 glDisable(GL_DEPTH_BOUNDS_TEST_EXT
);
1900 checkGLcall("glDisable(GL_DEPTH_BOUNDS_TEST_EXT)");
1904 glDisable(GL_DEPTH_BOUNDS_TEST_EXT
);
1905 checkGLcall("glDisable(GL_DEPTH_BOUNDS_TEST_EXT)");
1908 state_tessellation(context
, state
, STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
));
1911 static void state_wrapu(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1913 if (state
->render_states
[WINED3D_RS_WRAPU
])
1914 FIXME("Render state WINED3D_RS_WRAPU not implemented yet.\n");
1917 static void state_wrapv(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1919 if (state
->render_states
[WINED3D_RS_WRAPV
])
1920 FIXME("Render state WINED3D_RS_WRAPV not implemented yet.\n");
1923 static void state_monoenable(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1925 if (state
->render_states
[WINED3D_RS_MONOENABLE
])
1926 FIXME("Render state WINED3D_RS_MONOENABLE not implemented yet.\n");
1929 static void state_rop2(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1931 if (state
->render_states
[WINED3D_RS_ROP2
])
1932 FIXME("Render state WINED3D_RS_ROP2 not implemented yet.\n");
1935 static void state_planemask(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1937 if (state
->render_states
[WINED3D_RS_PLANEMASK
])
1938 FIXME("Render state WINED3D_RS_PLANEMASK not implemented yet.\n");
1941 static void state_subpixel(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1943 if (state
->render_states
[WINED3D_RS_SUBPIXEL
])
1944 FIXME("Render state WINED3D_RS_SUBPIXEL not implemented yet.\n");
1947 static void state_subpixelx(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1949 if (state
->render_states
[WINED3D_RS_SUBPIXELX
])
1950 FIXME("Render state WINED3D_RS_SUBPIXELX not implemented yet.\n");
1953 static void state_stippleenable(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1955 if (state
->render_states
[WINED3D_RS_STIPPLEENABLE
])
1956 FIXME("Render state WINED3D_RS_STIPPLEENABLE not implemented yet.\n");
1959 static void state_mipmaplodbias(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1961 if (state
->render_states
[WINED3D_RS_MIPMAPLODBIAS
])
1962 FIXME("Render state WINED3D_RS_MIPMAPLODBIAS not implemented yet.\n");
1965 static void state_anisotropy(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1967 if (state
->render_states
[WINED3D_RS_ANISOTROPY
])
1968 FIXME("Render state WINED3D_RS_ANISOTROPY not implemented yet.\n");
1971 static void state_flushbatch(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1973 if (state
->render_states
[WINED3D_RS_FLUSHBATCH
])
1974 FIXME("Render state WINED3D_RS_FLUSHBATCH not implemented yet.\n");
1977 static void state_translucentsi(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1979 if (state
->render_states
[WINED3D_RS_TRANSLUCENTSORTINDEPENDENT
])
1980 FIXME("Render state WINED3D_RS_TRANSLUCENTSORTINDEPENDENT not implemented yet.\n");
1983 static void state_extents(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1985 if (state
->render_states
[WINED3D_RS_EXTENTS
])
1986 FIXME("Render state WINED3D_RS_EXTENTS not implemented yet.\n");
1989 static void state_ckeyblend(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1991 if (state
->render_states
[WINED3D_RS_COLORKEYBLENDENABLE
])
1992 FIXME("Render state WINED3D_RS_COLORKEYBLENDENABLE not implemented yet.\n");
1995 static void state_swvp(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
1997 if (state
->render_states
[WINED3D_RS_SOFTWAREVERTEXPROCESSING
])
1998 FIXME("Software vertex processing not implemented.\n");
2001 static void get_src_and_opr(DWORD arg
, BOOL is_alpha
, GLenum
* source
, GLenum
* operand
) {
2002 /* The WINED3DTA_ALPHAREPLICATE flag specifies the alpha component of the
2003 * input should be used for all input components. The WINED3DTA_COMPLEMENT
2004 * flag specifies the complement of the input should be used. */
2005 BOOL from_alpha
= is_alpha
|| arg
& WINED3DTA_ALPHAREPLICATE
;
2006 BOOL complement
= arg
& WINED3DTA_COMPLEMENT
;
2008 /* Calculate the operand */
2010 if (from_alpha
) *operand
= GL_ONE_MINUS_SRC_ALPHA
;
2011 else *operand
= GL_ONE_MINUS_SRC_COLOR
;
2013 if (from_alpha
) *operand
= GL_SRC_ALPHA
;
2014 else *operand
= GL_SRC_COLOR
;
2017 /* Calculate the source */
2018 switch (arg
& WINED3DTA_SELECTMASK
) {
2019 case WINED3DTA_CURRENT
: *source
= GL_PREVIOUS_EXT
; break;
2020 case WINED3DTA_DIFFUSE
: *source
= GL_PRIMARY_COLOR_EXT
; break;
2021 case WINED3DTA_TEXTURE
: *source
= GL_TEXTURE
; break;
2022 case WINED3DTA_TFACTOR
: *source
= GL_CONSTANT_EXT
; break;
2023 case WINED3DTA_SPECULAR
:
2025 * According to the GL_ARB_texture_env_combine specs, SPECULAR is
2026 * 'Secondary color' and isn't supported until base GL supports it
2027 * There is no concept of temp registers as far as I can tell
2029 FIXME("Unhandled texture arg WINED3DTA_SPECULAR\n");
2030 *source
= GL_TEXTURE
;
2033 FIXME("Unrecognized texture arg %#x\n", arg
);
2034 *source
= GL_TEXTURE
;
2039 /* Setup the texture operations texture stage states */
2040 static void set_tex_op(const struct wined3d_gl_info
*gl_info
, const struct wined3d_state
*state
,
2041 BOOL isAlpha
, int Stage
, WINED3DTEXTUREOP op
, DWORD arg1
, DWORD arg2
, DWORD arg3
)
2043 GLenum src1
, src2
, src3
;
2044 GLenum opr1
, opr2
, opr3
;
2046 GLenum src0_target
, src1_target
, src2_target
;
2047 GLenum opr0_target
, opr1_target
, opr2_target
;
2049 GLenum opr
=0, invopr
, src3_target
, opr3_target
;
2050 BOOL Handled
= FALSE
;
2052 TRACE("Alpha?(%d), Stage:%d Op(%s), a1(%d), a2(%d), a3(%d)\n", isAlpha
, Stage
, debug_d3dtop(op
), arg1
, arg2
, arg3
);
2054 /* This is called by a state handler which has the gl lock held and a context for the thread */
2056 /* Note: Operations usually involve two ars, src0 and src1 and are operations of
2057 the form (a1 <operation> a2). However, some of the more complex operations
2058 take 3 parameters. Instead of the (sensible) addition of a3, Microsoft added
2059 in a third parameter called a0. Therefore these are operations of the form
2060 a0 <operation> a1 <operation> a2, i.e., the new parameter goes to the front.
2062 However, below we treat the new (a0) parameter as src2/opr2, so in the actual
2063 functions below, expect their syntax to differ slightly to those listed in the
2064 manuals, i.e., replace arg1 with arg3, arg2 with arg1 and arg3 with arg2
2065 This affects WINED3DTOP_MULTIPLYADD and WINED3DTOP_LERP */
2069 comb_target
= GL_COMBINE_ALPHA
;
2070 src0_target
= GL_SOURCE0_ALPHA
;
2071 src1_target
= GL_SOURCE1_ALPHA
;
2072 src2_target
= GL_SOURCE2_ALPHA
;
2073 opr0_target
= GL_OPERAND0_ALPHA
;
2074 opr1_target
= GL_OPERAND1_ALPHA
;
2075 opr2_target
= GL_OPERAND2_ALPHA
;
2076 scal_target
= GL_ALPHA_SCALE
;
2080 comb_target
= GL_COMBINE_RGB
;
2081 src0_target
= GL_SOURCE0_RGB
;
2082 src1_target
= GL_SOURCE1_RGB
;
2083 src2_target
= GL_SOURCE2_RGB
;
2084 opr0_target
= GL_OPERAND0_RGB
;
2085 opr1_target
= GL_OPERAND1_RGB
;
2086 opr2_target
= GL_OPERAND2_RGB
;
2087 scal_target
= GL_RGB_SCALE
;
2090 /* If a texture stage references an invalid texture unit the stage just
2091 * passes through the result from the previous stage */
2092 if (is_invalid_op(state
, Stage
, op
, arg1
, arg2
, arg3
))
2094 arg1
= WINED3DTA_CURRENT
;
2095 op
= WINED3DTOP_SELECTARG1
;
2098 if (isAlpha
&& !state
->textures
[Stage
] && arg1
== WINED3DTA_TEXTURE
)
2100 get_src_and_opr(WINED3DTA_DIFFUSE
, isAlpha
, &src1
, &opr1
);
2102 get_src_and_opr(arg1
, isAlpha
, &src1
, &opr1
);
2104 get_src_and_opr(arg2
, isAlpha
, &src2
, &opr2
);
2105 get_src_and_opr(arg3
, isAlpha
, &src3
, &opr3
);
2107 TRACE("ct(%x), 1:(%x,%x), 2:(%x,%x), 3:(%x,%x)\n", comb_target
, src1
, opr1
, src2
, opr2
, src3
, opr3
);
2109 Handled
= TRUE
; /* Assume will be handled */
2111 /* Other texture operations require special extensions: */
2112 if (gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
2116 invopr
= GL_ONE_MINUS_SRC_ALPHA
;
2117 src3_target
= GL_SOURCE3_ALPHA_NV
;
2118 opr3_target
= GL_OPERAND3_ALPHA_NV
;
2121 invopr
= GL_ONE_MINUS_SRC_COLOR
;
2122 src3_target
= GL_SOURCE3_RGB_NV
;
2123 opr3_target
= GL_OPERAND3_RGB_NV
;
2126 case WINED3DTOP_DISABLE
: /* Only for alpha */
2127 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2128 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2129 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_PREVIOUS_EXT
);
2130 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2131 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_SRC_ALPHA
);
2132 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2133 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2134 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2135 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2136 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2137 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2138 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_ZERO");
2139 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2140 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2141 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2142 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2143 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2144 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2146 case WINED3DTOP_SELECTARG1
: /* = a1 * 1 + 0 * 0 */
2147 case WINED3DTOP_SELECTARG2
: /* = a2 * 1 + 0 * 0 */
2148 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2149 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2150 if (op
== WINED3DTOP_SELECTARG1
) {
2151 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2152 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2153 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2154 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2156 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src2
);
2157 checkGLcall("GL_TEXTURE_ENV, src0_target, src2");
2158 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr2
);
2159 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr2");
2161 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2162 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2163 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2164 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2165 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2166 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_ZERO");
2167 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2168 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2169 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2170 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2171 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2172 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2175 case WINED3DTOP_MODULATE
:
2176 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2177 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2178 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2179 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2180 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2181 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2182 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2183 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2184 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2185 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2186 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2187 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2188 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2189 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2190 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2191 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2192 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2193 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2194 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2195 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2197 case WINED3DTOP_MODULATE2X
:
2198 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2199 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2200 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2201 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2202 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2203 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2204 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2205 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2206 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2207 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2208 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2209 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2210 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2211 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2212 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2213 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2214 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2215 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2216 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2217 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2219 case WINED3DTOP_MODULATE4X
:
2220 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2221 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2222 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2223 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2224 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2225 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2226 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2227 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2228 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2229 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2230 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_ZERO
);
2231 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2232 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2233 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2234 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2235 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2236 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2237 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr1");
2238 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 4);
2239 checkGLcall("GL_TEXTURE_ENV, scal_target, 4");
2242 case WINED3DTOP_ADD
:
2243 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2244 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2245 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2246 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2247 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2248 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2249 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2250 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2251 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2252 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2253 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2254 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2255 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2256 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2257 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2258 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2259 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2260 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2261 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2262 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2265 case WINED3DTOP_ADDSIGNED
:
2266 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD_SIGNED
);
2267 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2268 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2269 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2270 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2271 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2272 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2273 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2274 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2275 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2276 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2277 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2278 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2279 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2280 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2281 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2282 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2283 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2284 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2285 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2288 case WINED3DTOP_ADDSIGNED2X
:
2289 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD_SIGNED
);
2290 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2291 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2292 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2293 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2294 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2295 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2296 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2297 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2298 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2299 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2300 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2301 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2302 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2303 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2304 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2305 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2306 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2307 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2308 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2311 case WINED3DTOP_ADDSMOOTH
:
2312 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2313 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2314 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2315 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2316 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2317 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2318 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2319 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2320 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2321 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2322 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2323 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2324 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2325 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2326 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
2327 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2329 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2330 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2331 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2332 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2334 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2335 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2336 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2337 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2340 case WINED3DTOP_BLENDDIFFUSEALPHA
:
2341 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2342 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2343 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2344 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2345 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2346 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2347 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_PRIMARY_COLOR
);
2348 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_PRIMARY_COLOR");
2349 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2350 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2351 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2352 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2353 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2354 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2355 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_PRIMARY_COLOR
);
2356 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_PRIMARY_COLOR");
2357 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2358 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2359 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2360 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2362 case WINED3DTOP_BLENDTEXTUREALPHA
:
2363 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2364 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2365 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2366 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2367 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2368 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2369 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_TEXTURE
);
2370 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_TEXTURE");
2371 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2372 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2373 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2374 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2375 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2376 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2377 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_TEXTURE
);
2378 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_TEXTURE");
2379 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2380 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2381 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2382 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2384 case WINED3DTOP_BLENDFACTORALPHA
:
2385 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2386 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2387 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2388 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2389 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2390 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2391 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_CONSTANT
);
2392 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_CONSTANT");
2393 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2394 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2395 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2396 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2397 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2398 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2399 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_CONSTANT
);
2400 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_CONSTANT");
2401 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2402 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2403 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2404 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2406 case WINED3DTOP_BLENDTEXTUREALPHAPM
:
2407 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2408 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2409 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2410 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2411 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2412 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2413 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2414 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2415 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2416 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2417 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2418 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2419 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2420 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2421 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_TEXTURE
);
2422 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_TEXTURE");
2423 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, GL_ONE_MINUS_SRC_ALPHA
);
2424 checkGLcall("GL_TEXTURE_ENV, opr3_target, GL_ONE_MINUS_SRC_ALPHA");
2425 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2426 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2428 case WINED3DTOP_MODULATEALPHA_ADDCOLOR
:
2429 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2430 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD"); /* Add = a0*a1 + a2*a3 */
2431 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
); /* a0 = src1/opr1 */
2432 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2433 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2434 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1"); /* a1 = 1 (see docs) */
2435 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2436 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2437 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2438 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2439 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
); /* a2 = arg2 */
2440 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2441 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2442 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2"); /* a3 = src1 alpha */
2443 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
2444 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2446 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2447 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2449 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2450 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2451 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2452 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2454 case WINED3DTOP_MODULATECOLOR_ADDALPHA
:
2455 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2456 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2457 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2458 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2459 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2460 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2461 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2462 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2463 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2464 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2465 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
2466 checkGLcall("GL_TEXTURE_ENV, src2_target, src1");
2468 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2469 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2471 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2472 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2473 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2474 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2475 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2476 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2477 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2478 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2480 case WINED3DTOP_MODULATEINVALPHA_ADDCOLOR
:
2481 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2482 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2483 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2484 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2485 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2486 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2487 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2488 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2489 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2490 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2491 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2492 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2493 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2494 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2495 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src1
);
2496 checkGLcall("GL_TEXTURE_ENV, src3_target, src1");
2498 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2499 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2500 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2501 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2503 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr
);
2504 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr");
2505 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2506 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2508 case WINED3DTOP_MODULATEINVCOLOR_ADDALPHA
:
2509 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2510 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2511 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2512 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2514 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2515 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2516 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2517 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2519 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2520 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2521 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2522 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2523 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2524 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2525 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
2526 checkGLcall("GL_TEXTURE_ENV, src2_target, src1");
2528 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2529 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2531 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr
);
2532 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr");
2533 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, GL_ZERO
);
2534 checkGLcall("GL_TEXTURE_ENV, src3_target, GL_ZERO");
2535 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, invopr
);
2536 checkGLcall("GL_TEXTURE_ENV, opr3_target, invopr");
2537 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2538 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2540 case WINED3DTOP_MULTIPLYADD
:
2541 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2542 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2543 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src3
);
2544 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2545 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr3
);
2546 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2547 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, GL_ZERO
);
2548 checkGLcall("GL_TEXTURE_ENV, src1_target, GL_ZERO");
2549 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, invopr
);
2550 checkGLcall("GL_TEXTURE_ENV, opr1_target, invopr");
2551 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src1
);
2552 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2553 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr1
);
2554 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2555 glTexEnvi(GL_TEXTURE_ENV
, src3_target
, src2
);
2556 checkGLcall("GL_TEXTURE_ENV, src3_target, src3");
2557 glTexEnvi(GL_TEXTURE_ENV
, opr3_target
, opr2
);
2558 checkGLcall("GL_TEXTURE_ENV, opr3_target, opr3");
2559 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2560 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2563 case WINED3DTOP_BUMPENVMAP
:
2567 case WINED3DTOP_BUMPENVMAPLUMINANCE
:
2568 FIXME("Implement bump environment mapping in GL_NV_texture_env_combine4 path\n");
2574 glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_COMBINE4_NV
);
2575 checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE4_NV");
2579 } /* GL_NV_texture_env_combine4 */
2581 Handled
= TRUE
; /* Again, assume handled */
2583 case WINED3DTOP_DISABLE
: /* Only for alpha */
2584 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
2585 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2586 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_PREVIOUS_EXT
);
2587 checkGLcall("GL_TEXTURE_ENV, src0_target, GL_PREVIOUS_EXT");
2588 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_SRC_ALPHA
);
2589 checkGLcall("GL_TEXTURE_ENV, opr0_target, GL_SRC_ALPHA");
2590 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2591 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2593 case WINED3DTOP_SELECTARG1
:
2594 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
2595 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2596 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2597 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2598 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2599 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2600 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2601 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2603 case WINED3DTOP_SELECTARG2
:
2604 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_REPLACE
);
2605 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_REPLACE");
2606 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src2
);
2607 checkGLcall("GL_TEXTURE_ENV, src0_target, src2");
2608 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr2
);
2609 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr2");
2610 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2611 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2613 case WINED3DTOP_MODULATE
:
2614 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
2615 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2616 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2617 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2618 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2619 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2620 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2621 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2622 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2623 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2624 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2625 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2627 case WINED3DTOP_MODULATE2X
:
2628 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
2629 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2630 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2631 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2632 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2633 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2634 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2635 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2636 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2637 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2638 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2639 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2641 case WINED3DTOP_MODULATE4X
:
2642 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE
);
2643 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE");
2644 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2645 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2646 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2647 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2648 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2649 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2650 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2651 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2652 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 4);
2653 checkGLcall("GL_TEXTURE_ENV, scal_target, 4");
2655 case WINED3DTOP_ADD
:
2656 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD
);
2657 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD");
2658 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2659 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2660 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2661 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2662 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2663 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2664 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2665 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2666 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2667 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2669 case WINED3DTOP_ADDSIGNED
:
2670 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD_SIGNED
);
2671 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2672 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2673 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2674 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2675 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2676 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2677 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2678 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2679 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2680 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2681 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2683 case WINED3DTOP_ADDSIGNED2X
:
2684 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_ADD_SIGNED
);
2685 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_ADD_SIGNED");
2686 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2687 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2688 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2689 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2690 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2691 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2692 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2693 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2694 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 2);
2695 checkGLcall("GL_TEXTURE_ENV, scal_target, 2");
2697 case WINED3DTOP_SUBTRACT
:
2698 if (gl_info
->supported
[ARB_TEXTURE_ENV_COMBINE
])
2700 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_SUBTRACT
);
2701 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_SUBTRACT");
2702 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2703 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2704 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2705 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2706 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2707 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2708 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2709 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2710 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2711 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2713 FIXME("This version of opengl does not support GL_SUBTRACT\n");
2717 case WINED3DTOP_BLENDDIFFUSEALPHA
:
2718 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2719 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2720 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2721 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2722 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2723 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2724 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2725 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2726 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2727 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2728 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_PRIMARY_COLOR
);
2729 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_PRIMARY_COLOR");
2730 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2731 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2732 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2733 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2735 case WINED3DTOP_BLENDTEXTUREALPHA
:
2736 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2737 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2738 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2739 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2740 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2741 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2742 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2743 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2744 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2745 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2746 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_TEXTURE
);
2747 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_TEXTURE");
2748 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2749 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2750 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2751 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2753 case WINED3DTOP_BLENDFACTORALPHA
:
2754 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2755 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2756 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2757 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2758 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2759 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2760 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2761 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2762 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2763 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2764 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_CONSTANT
);
2765 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_CONSTANT");
2766 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2767 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2768 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2769 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2771 case WINED3DTOP_BLENDCURRENTALPHA
:
2772 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2773 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2774 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2775 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2776 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2777 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2778 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2779 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2780 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2781 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2782 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, GL_PREVIOUS
);
2783 checkGLcall("GL_TEXTURE_ENV, src2_target, GL_PREVIOUS");
2784 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, GL_SRC_ALPHA
);
2785 checkGLcall("GL_TEXTURE_ENV, opr2_target, GL_SRC_ALPHA");
2786 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2787 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2789 case WINED3DTOP_DOTPRODUCT3
:
2790 if (gl_info
->supported
[ARB_TEXTURE_ENV_DOT3
])
2792 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_DOT3_RGBA_ARB
);
2793 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_ARB");
2795 else if (gl_info
->supported
[EXT_TEXTURE_ENV_DOT3
])
2797 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_DOT3_RGBA_EXT
);
2798 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_EXT");
2800 FIXME("This version of opengl does not support GL_DOT3\n");
2802 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2803 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2804 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2805 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2806 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2807 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2808 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2809 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2810 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2811 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2813 case WINED3DTOP_LERP
:
2814 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_INTERPOLATE
);
2815 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_INTERPOLATE");
2816 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2817 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2818 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2819 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2820 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src2
);
2821 checkGLcall("GL_TEXTURE_ENV, src1_target, src2");
2822 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr2
);
2823 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr2");
2824 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src3
);
2825 checkGLcall("GL_TEXTURE_ENV, src2_target, src3");
2826 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr3
);
2827 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr3");
2828 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2829 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2831 case WINED3DTOP_ADDSMOOTH
:
2832 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2834 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2835 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2836 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2837 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2839 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2840 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2841 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2842 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2844 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2845 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2846 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2847 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2848 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2849 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2850 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2851 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2852 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2853 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2854 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2855 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2859 case WINED3DTOP_BLENDTEXTUREALPHAPM
:
2860 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2862 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2863 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2864 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, GL_TEXTURE
);
2865 checkGLcall("GL_TEXTURE_ENV, src0_target, GL_TEXTURE");
2866 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, GL_ONE_MINUS_SRC_ALPHA
);
2867 checkGLcall("GL_TEXTURE_ENV, opr0_target, GL_ONE_MINUS_SRC_APHA");
2868 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2869 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2870 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2871 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2872 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2873 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2874 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2875 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2876 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2877 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2881 case WINED3DTOP_MODULATEALPHA_ADDCOLOR
:
2882 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2884 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2885 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2886 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2887 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2889 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2890 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2891 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2892 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2894 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2895 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2896 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2897 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2898 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2899 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2900 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2901 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2902 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2903 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2904 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2905 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2909 case WINED3DTOP_MODULATECOLOR_ADDALPHA
:
2910 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2912 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2913 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2914 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2915 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2916 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
2917 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
2918 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2919 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2921 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2922 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2923 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2924 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2926 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr
);
2927 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr");
2928 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2929 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2930 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2931 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2932 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2933 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2937 case WINED3DTOP_MODULATEINVALPHA_ADDCOLOR
:
2938 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2940 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2941 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2942 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2943 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2945 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2946 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2947 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2948 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2950 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2951 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2952 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2953 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2954 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr1
);
2955 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
2956 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2957 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2958 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2959 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2960 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2961 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2965 case WINED3DTOP_MODULATEINVCOLOR_ADDALPHA
:
2966 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
2968 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
2969 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
2970 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
2971 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
2973 case GL_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_COLOR
; break;
2974 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_SRC_COLOR
; break;
2975 case GL_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2976 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2978 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr
);
2979 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr");
2980 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src1
);
2981 checkGLcall("GL_TEXTURE_ENV, src1_target, src1");
2983 case GL_SRC_COLOR
: opr
= GL_SRC_ALPHA
; break;
2984 case GL_ONE_MINUS_SRC_COLOR
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2985 case GL_SRC_ALPHA
: opr
= GL_SRC_ALPHA
; break;
2986 case GL_ONE_MINUS_SRC_ALPHA
: opr
= GL_ONE_MINUS_SRC_ALPHA
; break;
2988 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr
);
2989 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr");
2990 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
2991 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
2992 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
2993 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
2994 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
2995 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
2999 case WINED3DTOP_MULTIPLYADD
:
3000 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
])
3002 glTexEnvi(GL_TEXTURE_ENV
, comb_target
, GL_MODULATE_ADD_ATI
);
3003 checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI");
3004 glTexEnvi(GL_TEXTURE_ENV
, src0_target
, src1
);
3005 checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
3006 glTexEnvi(GL_TEXTURE_ENV
, opr0_target
, opr1
);
3007 checkGLcall("GL_TEXTURE_ENV, opr0_target, opr1");
3008 glTexEnvi(GL_TEXTURE_ENV
, src1_target
, src3
);
3009 checkGLcall("GL_TEXTURE_ENV, src1_target, src3");
3010 glTexEnvi(GL_TEXTURE_ENV
, opr1_target
, opr3
);
3011 checkGLcall("GL_TEXTURE_ENV, opr1_target, opr3");
3012 glTexEnvi(GL_TEXTURE_ENV
, src2_target
, src2
);
3013 checkGLcall("GL_TEXTURE_ENV, src2_target, src2");
3014 glTexEnvi(GL_TEXTURE_ENV
, opr2_target
, opr2
);
3015 checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
3016 glTexEnvi(GL_TEXTURE_ENV
, scal_target
, 1);
3017 checkGLcall("GL_TEXTURE_ENV, scal_target, 1");
3021 case WINED3DTOP_BUMPENVMAPLUMINANCE
:
3022 case WINED3DTOP_BUMPENVMAP
:
3023 if (gl_info
->supported
[NV_TEXTURE_SHADER2
])
3025 /* Technically texture shader support without register combiners is possible, but not expected to occur
3026 * on real world cards, so for now a fixme should be enough
3028 FIXME("Implement bump mapping with GL_NV_texture_shader in non register combiner path\n");
3035 BOOL combineOK
= TRUE
;
3036 if (gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
3041 op2
= state
->texture_states
[Stage
][WINED3DTSS_COLOROP
];
3043 op2
= state
->texture_states
[Stage
][WINED3DTSS_ALPHAOP
];
3045 /* Note: If COMBINE4 in effect can't go back to combine! */
3047 case WINED3DTOP_ADDSMOOTH
:
3048 case WINED3DTOP_BLENDTEXTUREALPHAPM
:
3049 case WINED3DTOP_MODULATEALPHA_ADDCOLOR
:
3050 case WINED3DTOP_MODULATECOLOR_ADDALPHA
:
3051 case WINED3DTOP_MODULATEINVALPHA_ADDCOLOR
:
3052 case WINED3DTOP_MODULATEINVCOLOR_ADDALPHA
:
3053 case WINED3DTOP_MULTIPLYADD
:
3054 /* Ignore those implemented in both cases */
3056 case WINED3DTOP_SELECTARG1
:
3057 case WINED3DTOP_SELECTARG2
:
3062 FIXME("Can't use COMBINE4 and COMBINE together, thisop=%s, otherop=%s, isAlpha(%d)\n", debug_d3dtop(op
), debug_d3dtop(op2
), isAlpha
);
3070 glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_COMBINE
);
3071 checkGLcall("GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE");
3077 /* After all the extensions, if still unhandled, report fixme */
3078 FIXME("Unhandled texture operation %s\n", debug_d3dtop(op
));
3082 static void tex_colorop(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3084 DWORD stage
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3085 const struct wined3d_device
*device
= context
->swapchain
->device
;
3086 BOOL tex_used
= device
->fixed_function_usage_map
& (1 << stage
);
3087 DWORD mapped_stage
= device
->texUnitMap
[stage
];
3088 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3090 TRACE("Setting color op for stage %d\n", stage
);
3092 /* Using a pixel shader? Don't care for anything here, the shader applying does it */
3093 if (use_ps(state
)) return;
3095 if (stage
!= mapped_stage
) WARN("Using non 1:1 mapping: %d -> %d!\n", stage
, mapped_stage
);
3097 if (mapped_stage
!= WINED3D_UNMAPPED_STAGE
)
3099 if (tex_used
&& mapped_stage
>= gl_info
->limits
.textures
)
3101 FIXME("Attempt to enable unsupported stage!\n");
3104 context_active_texture(context
, gl_info
, mapped_stage
);
3107 if (stage
>= state
->lowest_disabled_stage
)
3109 TRACE("Stage disabled\n");
3110 if (mapped_stage
!= WINED3D_UNMAPPED_STAGE
)
3112 /* Disable everything here */
3113 glDisable(GL_TEXTURE_2D
);
3114 checkGLcall("glDisable(GL_TEXTURE_2D)");
3115 glDisable(GL_TEXTURE_3D
);
3116 checkGLcall("glDisable(GL_TEXTURE_3D)");
3117 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
3119 glDisable(GL_TEXTURE_CUBE_MAP_ARB
);
3120 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
3122 if (gl_info
->supported
[ARB_TEXTURE_RECTANGLE
])
3124 glDisable(GL_TEXTURE_RECTANGLE_ARB
);
3125 checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)");
3132 /* The sampler will also activate the correct texture dimensions, so no
3133 * need to do it here if the sampler for this stage is dirty. */
3134 if (!isStateDirty(context
, STATE_SAMPLER(stage
)) && tex_used
)
3135 texture_activate_dimensions(state
->textures
[stage
], gl_info
);
3137 set_tex_op(gl_info
, state
, FALSE
, stage
,
3138 state
->texture_states
[stage
][WINED3DTSS_COLOROP
],
3139 state
->texture_states
[stage
][WINED3DTSS_COLORARG1
],
3140 state
->texture_states
[stage
][WINED3DTSS_COLORARG2
],
3141 state
->texture_states
[stage
][WINED3DTSS_COLORARG0
]);
3144 void tex_alphaop(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3146 DWORD stage
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3147 const struct wined3d_device
*device
= context
->swapchain
->device
;
3148 BOOL tex_used
= device
->fixed_function_usage_map
& (1 << stage
);
3149 DWORD mapped_stage
= device
->texUnitMap
[stage
];
3150 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3151 DWORD op
, arg1
, arg2
, arg0
;
3153 TRACE("Setting alpha op for stage %d\n", stage
);
3154 /* Do not care for enabled / disabled stages, just assign the settings. colorop disables / enables required stuff */
3155 if (mapped_stage
!= WINED3D_UNMAPPED_STAGE
)
3157 if (tex_used
&& mapped_stage
>= gl_info
->limits
.textures
)
3159 FIXME("Attempt to enable unsupported stage!\n");
3162 context_active_texture(context
, gl_info
, mapped_stage
);
3165 op
= state
->texture_states
[stage
][WINED3DTSS_ALPHAOP
];
3166 arg1
= state
->texture_states
[stage
][WINED3DTSS_ALPHAARG1
];
3167 arg2
= state
->texture_states
[stage
][WINED3DTSS_ALPHAARG2
];
3168 arg0
= state
->texture_states
[stage
][WINED3DTSS_ALPHAARG0
];
3170 if (state
->render_states
[WINED3D_RS_COLORKEYENABLE
] && !stage
&& state
->textures
[0])
3172 struct wined3d_texture
*texture
= state
->textures
[0];
3173 GLenum texture_dimensions
= texture
->target
;
3175 if (texture_dimensions
== GL_TEXTURE_2D
|| texture_dimensions
== GL_TEXTURE_RECTANGLE_ARB
)
3177 struct wined3d_surface
*surf
= surface_from_resource(texture
->sub_resources
[0]);
3179 if (surf
->CKeyFlags
& WINEDDSD_CKSRCBLT
&& !surf
->resource
.format
->alpha_mask
)
3181 /* Color keying needs to pass alpha values from the texture through to have the alpha test work
3182 * properly. On the other hand applications can still use texture combiners apparently. This code
3183 * takes care that apps cannot remove the texture's alpha channel entirely.
3185 * The fixup is required for Prince of Persia 3D(prison bars), while Moto racer 2 requires
3186 * D3DTOP_MODULATE to work on color keyed surfaces. Aliens vs Predator 1 uses color keyed textures
3187 * and alpha component of diffuse color to draw things like translucent text and perform other
3190 * Aliens vs Predator 1 relies on diffuse alpha having an effect, so it cannot be ignored. To
3191 * provide the behavior expected by the game, while emulating the colorkey, diffuse alpha must be
3192 * modulated with texture alpha. OTOH, Moto racer 2 at some points sets alphaop/alphaarg to
3193 * SELECTARG/CURRENT, yet puts garbage in diffuse alpha (zeroes). This works on native, because the
3194 * game disables alpha test and alpha blending. Alpha test is overwritten by wine's for purposes of
3195 * color-keying though, so this will lead to missing geometry if texture alpha is modulated (pixels
3196 * fail alpha test). To get around this, ALPHABLENDENABLE state is checked: if the app enables alpha
3197 * blending, it can be expected to provide meaningful values in diffuse alpha, so it should be
3198 * modulated with texture alpha; otherwise, selecting diffuse alpha is ignored in favour of texture
3201 * What to do with multitexturing? So far no app has been found that uses color keying with
3203 if (op
== WINED3DTOP_DISABLE
)
3205 arg1
= WINED3DTA_TEXTURE
;
3206 op
= WINED3DTOP_SELECTARG1
;
3208 else if(op
== WINED3DTOP_SELECTARG1
&& arg1
!= WINED3DTA_TEXTURE
)
3210 if (state
->render_states
[WINED3D_RS_ALPHABLENDENABLE
])
3212 arg2
= WINED3DTA_TEXTURE
;
3213 op
= WINED3DTOP_MODULATE
;
3215 else arg1
= WINED3DTA_TEXTURE
;
3217 else if(op
== WINED3DTOP_SELECTARG2
&& arg2
!= WINED3DTA_TEXTURE
)
3219 if (state
->render_states
[WINED3D_RS_ALPHABLENDENABLE
])
3221 arg1
= WINED3DTA_TEXTURE
;
3222 op
= WINED3DTOP_MODULATE
;
3224 else arg2
= WINED3DTA_TEXTURE
;
3230 /* tex_alphaop is shared between the ffp and nvrc because the difference only comes down to
3231 * this if block here, and the other code(color keying, texture unit selection) are the same
3233 TRACE("Setting alpha op for stage %d\n", stage
);
3234 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
3236 set_tex_op_nvrc(gl_info
, state
, TRUE
, stage
, op
, arg1
, arg2
, arg0
,
3237 mapped_stage
, state
->texture_states
[stage
][WINED3DTSS_RESULTARG
]);
3241 set_tex_op(gl_info
, state
, TRUE
, stage
, op
, arg1
, arg2
, arg0
);
3245 static void transform_texture(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3247 DWORD texUnit
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3248 const struct wined3d_device
*device
= context
->swapchain
->device
;
3249 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3250 DWORD mapped_stage
= device
->texUnitMap
[texUnit
];
3254 /* Ignore this when a vertex shader is used, or if the streams aren't sorted out yet */
3255 if (use_vs(state
) || isStateDirty(context
, STATE_VDECL
))
3257 TRACE("Using a vertex shader, or stream sources not sorted out yet, skipping\n");
3261 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
) return;
3262 if (mapped_stage
>= gl_info
->limits
.textures
) return;
3264 context_active_texture(context
, gl_info
, mapped_stage
);
3265 generated
= (state
->texture_states
[texUnit
][WINED3DTSS_TEXCOORDINDEX
] & 0xffff0000) != WINED3DTSS_TCI_PASSTHRU
;
3266 coordIdx
= min(state
->texture_states
[texUnit
][WINED3DTSS_TEXCOORDINDEX
& 0x0000ffff], MAX_TEXTURES
- 1);
3268 set_texture_matrix(&state
->transforms
[WINED3DTS_TEXTURE0
+ texUnit
].u
.m
[0][0],
3269 state
->texture_states
[texUnit
][WINED3DTSS_TEXTURETRANSFORMFLAGS
],
3270 generated
, context
->last_was_rhw
,
3271 device
->strided_streams
.use_map
& (1 << (WINED3D_FFP_TEXCOORD0
+ coordIdx
))
3272 ? device
->strided_streams
.elements
[WINED3D_FFP_TEXCOORD0
+ coordIdx
].format
->id
3273 : WINED3DFMT_UNKNOWN
,
3274 device
->frag_pipe
->ffp_proj_control
);
3276 /* The sampler applying function calls us if this changes */
3277 if ((context
->lastWasPow2Texture
& (1 << texUnit
)) && state
->textures
[texUnit
])
3280 FIXME("Non-power2 texture being used with generated texture coords\n");
3282 /* NP2 texcoord fixup is implemented for pixelshaders so only enable the
3283 fixed-function-pipeline fixup via pow2Matrix when no PS is used. */
3286 TRACE("Non power two matrix multiply fixup\n");
3287 glMultMatrixf(state
->textures
[texUnit
]->pow2_matrix
);
3292 static void unload_tex_coords(const struct wined3d_gl_info
*gl_info
)
3294 unsigned int texture_idx
;
3296 for (texture_idx
= 0; texture_idx
< gl_info
->limits
.texture_coords
; ++texture_idx
)
3298 GL_EXTCALL(glClientActiveTextureARB(GL_TEXTURE0_ARB
+ texture_idx
));
3299 glDisableClientState(GL_TEXTURE_COORD_ARRAY
);
3303 static void load_tex_coords(const struct wined3d_context
*context
, const struct wined3d_stream_info
*si
,
3304 GLuint
*curVBO
, const struct wined3d_state
*state
)
3306 const struct wined3d_device
*device
= context
->swapchain
->device
;
3307 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3308 unsigned int mapped_stage
= 0;
3309 unsigned int textureNo
= 0;
3311 for (textureNo
= 0; textureNo
< gl_info
->limits
.texture_stages
; ++textureNo
)
3313 int coordIdx
= state
->texture_states
[textureNo
][WINED3DTSS_TEXCOORDINDEX
];
3315 mapped_stage
= device
->texUnitMap
[textureNo
];
3316 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
) continue;
3318 if (mapped_stage
>= gl_info
->limits
.texture_coords
)
3320 FIXME("Attempted to load unsupported texture coordinate %u\n", mapped_stage
);
3324 if (coordIdx
< MAX_TEXTURES
&& (si
->use_map
& (1 << (WINED3D_FFP_TEXCOORD0
+ coordIdx
))))
3326 const struct wined3d_stream_info_element
*e
= &si
->elements
[WINED3D_FFP_TEXCOORD0
+ coordIdx
];
3328 TRACE("Setting up texture %u, idx %d, coordindx %u, data {%#x:%p}.\n",
3329 textureNo
, mapped_stage
, coordIdx
, e
->data
.buffer_object
, e
->data
.addr
);
3331 if (*curVBO
!= e
->data
.buffer_object
)
3333 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, e
->data
.buffer_object
));
3334 checkGLcall("glBindBufferARB");
3335 *curVBO
= e
->data
.buffer_object
;
3338 GL_EXTCALL(glClientActiveTextureARB(GL_TEXTURE0_ARB
+ mapped_stage
));
3339 checkGLcall("glClientActiveTextureARB");
3341 /* The coords to supply depend completely on the fvf / vertex shader */
3342 glTexCoordPointer(e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
3343 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
3344 glEnableClientState(GL_TEXTURE_COORD_ARRAY
);
3348 GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB
+ mapped_stage
, 0, 0, 0, 1));
3351 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
3353 /* The number of the mapped stages increases monotonically, so it's fine to use the last used one. */
3354 for (textureNo
= mapped_stage
+ 1; textureNo
< gl_info
->limits
.textures
; ++textureNo
)
3356 GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB
+ textureNo
, 0, 0, 0, 1));
3360 checkGLcall("loadTexCoords");
3363 static void tex_coordindex(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3365 DWORD stage
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3366 const struct wined3d_device
*device
= context
->swapchain
->device
;
3367 static const GLfloat s_plane
[] = { 1.0f
, 0.0f
, 0.0f
, 0.0f
};
3368 static const GLfloat t_plane
[] = { 0.0f
, 1.0f
, 0.0f
, 0.0f
};
3369 static const GLfloat r_plane
[] = { 0.0f
, 0.0f
, 1.0f
, 0.0f
};
3370 static const GLfloat q_plane
[] = { 0.0f
, 0.0f
, 0.0f
, 1.0f
};
3371 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3372 DWORD mapped_stage
= device
->texUnitMap
[stage
];
3374 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
)
3376 TRACE("No texture unit mapped to stage %d. Skipping texture coordinates.\n", stage
);
3380 if (mapped_stage
>= gl_info
->limits
.fragment_samplers
)
3382 WARN("stage %u not mapped to a valid texture unit (%u)\n", stage
, mapped_stage
);
3385 context_active_texture(context
, gl_info
, mapped_stage
);
3387 /* Values 0-7 are indexes into the FVF tex coords - See comments in DrawPrimitive
3389 * FIXME: When using generated texture coordinates, the index value is used to specify the wrapping mode.
3390 * eg. SetTextureStageState( 0, WINED3DTSS_TEXCOORDINDEX, WINED3DTSS_TCI_CAMERASPACEPOSITION | 1 );
3391 * means use the vertex position (camera-space) as the input texture coordinates
3392 * for this texture stage, and the wrap mode set in the WINED3D_RS_WRAP1 render
3393 * state. We do not (yet) support the WINED3DRENDERSTATE_WRAPx values, nor tie them up
3394 * to the TEXCOORDINDEX value
3396 switch (state
->texture_states
[stage
][WINED3DTSS_TEXCOORDINDEX
] & 0xffff0000)
3398 case WINED3DTSS_TCI_PASSTHRU
:
3399 /* Use the specified texture coordinates contained within the
3400 * vertex format. This value resolves to zero. */
3401 glDisable(GL_TEXTURE_GEN_S
);
3402 glDisable(GL_TEXTURE_GEN_T
);
3403 glDisable(GL_TEXTURE_GEN_R
);
3404 glDisable(GL_TEXTURE_GEN_Q
);
3405 checkGLcall("WINED3DTSS_TCI_PASSTHRU - Disable texgen.");
3408 case WINED3DTSS_TCI_CAMERASPACEPOSITION
:
3409 /* CameraSpacePosition means use the vertex position, transformed to camera space,
3410 * as the input texture coordinates for this stage's texture transformation. This
3411 * equates roughly to EYE_LINEAR */
3413 glMatrixMode(GL_MODELVIEW
);
3416 glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
3417 glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
3418 glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
3419 glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
3421 checkGLcall("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set eye plane.");
3423 glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
3424 glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
3425 glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_EYE_LINEAR
);
3426 checkGLcall("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set texgen mode.");
3428 glEnable(GL_TEXTURE_GEN_S
);
3429 glEnable(GL_TEXTURE_GEN_T
);
3430 glEnable(GL_TEXTURE_GEN_R
);
3431 checkGLcall("WINED3DTSS_TCI_CAMERASPACEPOSITION - Enable texgen.");
3435 case WINED3DTSS_TCI_CAMERASPACENORMAL
:
3436 /* Note that NV_TEXGEN_REFLECTION support is implied when
3437 * ARB_TEXTURE_CUBE_MAP is supported */
3438 if (!gl_info
->supported
[NV_TEXGEN_REFLECTION
])
3440 FIXME("WINED3DTSS_TCI_CAMERASPACENORMAL not supported.\n");
3444 glMatrixMode(GL_MODELVIEW
);
3447 glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
3448 glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
3449 glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
3450 glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
3452 checkGLcall("WINED3DTSS_TCI_CAMERASPACENORMAL - Set eye plane.");
3454 glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
3455 glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
3456 glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_NORMAL_MAP_NV
);
3457 checkGLcall("WINED3DTSS_TCI_CAMERASPACENORMAL - Set texgen mode.");
3459 glEnable(GL_TEXTURE_GEN_S
);
3460 glEnable(GL_TEXTURE_GEN_T
);
3461 glEnable(GL_TEXTURE_GEN_R
);
3462 checkGLcall("WINED3DTSS_TCI_CAMERASPACENORMAL - Enable texgen.");
3466 case WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR
:
3467 /* Note that NV_TEXGEN_REFLECTION support is implied when
3468 * ARB_TEXTURE_CUBE_MAP is supported */
3469 if (!gl_info
->supported
[NV_TEXGEN_REFLECTION
])
3471 FIXME("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR not supported.\n");
3475 glMatrixMode(GL_MODELVIEW
);
3478 glTexGenfv(GL_S
, GL_EYE_PLANE
, s_plane
);
3479 glTexGenfv(GL_T
, GL_EYE_PLANE
, t_plane
);
3480 glTexGenfv(GL_R
, GL_EYE_PLANE
, r_plane
);
3481 glTexGenfv(GL_Q
, GL_EYE_PLANE
, q_plane
);
3483 checkGLcall("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Set eye plane.");
3485 glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
3486 glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
3487 glTexGeni(GL_R
, GL_TEXTURE_GEN_MODE
, GL_REFLECTION_MAP_NV
);
3488 checkGLcall("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Set texgen mode.");
3490 glEnable(GL_TEXTURE_GEN_S
);
3491 glEnable(GL_TEXTURE_GEN_T
);
3492 glEnable(GL_TEXTURE_GEN_R
);
3493 checkGLcall("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Enable texgen.");
3497 case WINED3DTSS_TCI_SPHEREMAP
:
3498 glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_SPHERE_MAP
);
3499 glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_SPHERE_MAP
);
3500 checkGLcall("WINED3DTSS_TCI_SPHEREMAP - Set texgen mode.");
3502 glEnable(GL_TEXTURE_GEN_S
);
3503 glEnable(GL_TEXTURE_GEN_T
);
3504 glDisable(GL_TEXTURE_GEN_R
);
3505 checkGLcall("WINED3DTSS_TCI_SPHEREMAP - Enable texgen.");
3510 FIXME("Unhandled WINED3DTSS_TEXCOORDINDEX %#x.\n",
3511 state
->texture_states
[stage
][WINED3DTSS_TEXCOORDINDEX
]);
3512 glDisable(GL_TEXTURE_GEN_S
);
3513 glDisable(GL_TEXTURE_GEN_T
);
3514 glDisable(GL_TEXTURE_GEN_R
);
3515 glDisable(GL_TEXTURE_GEN_Q
);
3516 checkGLcall("Disable texgen.");
3521 /* Update the texture matrix. */
3522 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_TEXTURE0
+ stage
)))
3523 transform_texture(context
, state
, STATE_TEXTURESTAGE(stage
, WINED3DTSS_TEXTURETRANSFORMFLAGS
));
3525 if(!isStateDirty(context
, STATE_VDECL
) && context
->namedArraysLoaded
) {
3526 /* Reload the arrays if we are using fixed function arrays to reflect the selected coord input
3527 * source. Call loadTexCoords directly because there is no need to reparse the vertex declaration
3528 * and do all the things linked to it
3529 * TODO: Tidy that up to reload only the arrays of the changed unit
3531 GLuint curVBO
= gl_info
->supported
[ARB_VERTEX_BUFFER_OBJECT
] ? ~0U : 0;
3533 unload_tex_coords(gl_info
);
3534 load_tex_coords(context
, &device
->strided_streams
, &curVBO
, state
);
3538 static void tex_bumpenvlscale(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3540 DWORD stage
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3541 const struct wined3d_shader
*ps
= state
->pixel_shader
;
3543 if (ps
&& stage
&& (ps
->reg_maps
.luminanceparams
& (1 << stage
)))
3545 /* The pixel shader has to know the luminance scale. Do a constants
3546 * update if it isn't scheduled anyway. */
3547 if (!isStateDirty(context
, STATE_PIXELSHADERCONSTANT
)
3548 && !isStateDirty(context
, STATE_PIXELSHADER
))
3549 shaderconstant(context
, state
, STATE_PIXELSHADERCONSTANT
);
3553 static void sampler_texmatrix(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3555 const DWORD sampler
= state_id
- STATE_SAMPLER(0);
3556 const struct wined3d_texture
*texture
= state
->textures
[sampler
];
3558 TRACE("context %p, state %p, state_id %#x.\n", context
, state
, state_id
);
3560 if(!texture
) return;
3561 /* The fixed function np2 texture emulation uses the texture matrix to fix up the coordinates
3562 * wined3d_texture_apply_state_changes() multiplies the set matrix with a fixup matrix. Before the
3563 * scaling is reapplied or removed, the texture matrix has to be reapplied
3565 * The mapped stage is already active because the sampler() function below, which is part of the
3568 if (sampler
< MAX_TEXTURES
)
3570 const BOOL texIsPow2
= !(texture
->flags
& WINED3D_TEXTURE_POW2_MAT_IDENT
);
3572 if (texIsPow2
|| (context
->lastWasPow2Texture
& (1 << sampler
)))
3574 const struct wined3d_device
*device
= context
->swapchain
->device
;
3577 context
->lastWasPow2Texture
|= 1 << sampler
;
3579 context
->lastWasPow2Texture
&= ~(1 << sampler
);
3581 transform_texture(context
, state
,
3582 STATE_TEXTURESTAGE(device
->texUnitMap
[sampler
], WINED3DTSS_TEXTURETRANSFORMFLAGS
));
3587 static void sampler(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3589 const struct wined3d_device
*device
= context
->swapchain
->device
;
3590 DWORD sampler
= state_id
- STATE_SAMPLER(0);
3591 DWORD mapped_stage
= device
->texUnitMap
[sampler
];
3592 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3598 TRACE("Sampler: %d\n", sampler
);
3599 /* Enabling and disabling texture dimensions is done by texture stage state / pixel shader setup, this function
3600 * only has to bind textures and set the per texture states
3603 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
)
3605 TRACE("No sampler mapped to stage %d. Returning.\n", sampler
);
3609 if (mapped_stage
>= gl_info
->limits
.combined_samplers
)
3613 context_active_texture(context
, gl_info
, mapped_stage
);
3615 if (state
->textures
[sampler
])
3617 struct wined3d_texture
*texture
= state
->textures
[sampler
];
3618 BOOL srgb
= state
->sampler_states
[sampler
][WINED3D_SAMP_SRGB_TEXTURE
];
3620 texture
->texture_ops
->texture_bind(texture
, context
, srgb
);
3621 wined3d_texture_apply_state_changes(texture
, state
->sampler_states
[sampler
], gl_info
);
3623 if (gl_info
->supported
[EXT_TEXTURE_LOD_BIAS
])
3625 tmpvalue
.d
= state
->sampler_states
[sampler
][WINED3D_SAMP_MIPMAP_LOD_BIAS
];
3626 glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT
,
3627 GL_TEXTURE_LOD_BIAS_EXT
,
3629 checkGLcall("glTexEnvf(GL_TEXTURE_LOD_BIAS_EXT, ...)");
3632 if (!use_ps(state
) && sampler
< state
->lowest_disabled_stage
)
3634 if (state
->render_states
[WINED3D_RS_COLORKEYENABLE
] && !sampler
)
3636 /* If color keying is enabled update the alpha test, it
3637 * depends on the existence of a color key in stage 0. */
3638 state_alpha(context
, state
, WINED3D_RS_COLORKEYENABLE
);
3642 /* Trigger shader constant reloading (for NP2 texcoord fixup) */
3643 if (!(texture
->flags
& WINED3D_TEXTURE_POW2_MAT_IDENT
))
3644 device
->shader_backend
->shader_load_np2fixup_constants(device
->shader_priv
, gl_info
, state
);
3648 if (sampler
< state
->lowest_disabled_stage
)
3650 /* TODO: What should I do with pixel shaders here ??? */
3651 if (state
->render_states
[WINED3D_RS_COLORKEYENABLE
] && !sampler
)
3653 /* If color keying is enabled update the alpha test, it
3654 * depends on the existence of a color key in stage 0. */
3655 state_alpha(context
, state
, WINED3D_RS_COLORKEYENABLE
);
3657 } /* Otherwise tex_colorop disables the stage */
3658 context_bind_texture(context
, GL_NONE
, 0);
3662 void apply_pixelshader(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3664 const struct wined3d_device
*device
= context
->swapchain
->device
;
3665 BOOL use_vshader
= use_vs(state
);
3666 BOOL use_pshader
= use_ps(state
);
3671 if (!context
->last_was_pshader
)
3673 /* Former draw without a pixel shader, some samplers may be
3674 * disabled because of WINED3DTSS_COLOROP = WINED3DTOP_DISABLE
3675 * make sure to enable them. */
3676 for (i
= 0; i
< MAX_FRAGMENT_SAMPLERS
; ++i
)
3678 if (!isStateDirty(context
, STATE_SAMPLER(i
)))
3679 sampler(context
, state
, STATE_SAMPLER(i
));
3681 context
->last_was_pshader
= TRUE
;
3685 /* Otherwise all samplers were activated by the code above in
3686 * earlier draws, or by sampler() if a different texture was
3687 * bound. I don't have to do anything. */
3692 /* Disabled the pixel shader - color ops weren't applied while it was
3693 * enabled, so re-apply them. */
3694 for (i
= 0; i
< context
->gl_info
->limits
.texture_stages
; ++i
)
3696 if (!isStateDirty(context
, STATE_TEXTURESTAGE(i
, WINED3DTSS_COLOROP
)))
3697 context_apply_state(context
, state
, STATE_TEXTURESTAGE(i
, WINED3DTSS_COLOROP
));
3699 context
->last_was_pshader
= FALSE
;
3702 if (!isStateDirty(context
, context
->state_table
[STATE_VSHADER
].representative
))
3704 device
->shader_backend
->shader_select(context
, use_pshader
, use_vshader
);
3706 if (!isStateDirty(context
, STATE_VERTEXSHADERCONSTANT
) && (use_vshader
|| use_pshader
))
3707 shaderconstant(context
, state
, STATE_VERTEXSHADERCONSTANT
);
3711 static void shader_bumpenvmat(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3713 DWORD stage
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
3714 const struct wined3d_shader
*ps
= state
->pixel_shader
;
3716 if (ps
&& stage
&& (ps
->reg_maps
.bumpmat
& (1 << stage
)))
3718 /* The pixel shader has to know the bump env matrix. Do a constants
3719 * update if it isn't scheduled anyway. */
3720 if (!isStateDirty(context
, STATE_PIXELSHADERCONSTANT
)
3721 && !isStateDirty(context
, STATE_PIXELSHADER
))
3722 shaderconstant(context
, state
, STATE_PIXELSHADERCONSTANT
);
3726 static void transform_world(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3728 /* This function is called by transform_view below if the view matrix was changed too
3730 * Deliberately no check if the vertex declaration is dirty because the vdecl state
3731 * does not always update the world matrix, only on a switch between transformed
3732 * and untransformed draws. It *may* happen that the world matrix is set 2 times during one
3733 * draw, but that should be rather rare and cheaper in total.
3735 glMatrixMode(GL_MODELVIEW
);
3736 checkGLcall("glMatrixMode");
3738 if(context
->last_was_rhw
) {
3740 checkGLcall("glLoadIdentity()");
3744 /* In the general case, the view matrix is the identity matrix */
3745 if (context
->swapchain
->device
->view_ident
)
3747 glLoadMatrixf(&state
->transforms
[WINED3DTS_WORLDMATRIX(0)].u
.m
[0][0]);
3748 checkGLcall("glLoadMatrixf");
3752 glLoadMatrixf(&state
->transforms
[WINED3DTS_VIEW
].u
.m
[0][0]);
3753 checkGLcall("glLoadMatrixf");
3754 glMultMatrixf(&state
->transforms
[WINED3DTS_WORLDMATRIX(0)].u
.m
[0][0]);
3755 checkGLcall("glMultMatrixf");
3760 static void clipplane(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3762 UINT index
= state_id
- STATE_CLIPPLANE(0);
3764 if (isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_VIEW
)) || index
>= context
->gl_info
->limits
.clipplanes
)
3769 glMatrixMode(GL_MODELVIEW
);
3772 /* Clip Plane settings are affected by the model view in OpenGL, the View transform in direct3d */
3774 glLoadMatrixf(&state
->transforms
[WINED3DTS_VIEW
].u
.m
[0][0]);
3776 /* with vertex shaders, clip planes are not transformed in direct3d,
3777 * in OpenGL they are still transformed by the model view.
3781 TRACE("Clipplane [%.8e, %.8e, %.8e, %.8e]\n",
3782 state
->clip_planes
[index
][0],
3783 state
->clip_planes
[index
][1],
3784 state
->clip_planes
[index
][2],
3785 state
->clip_planes
[index
][3]);
3786 glClipPlane(GL_CLIP_PLANE0
+ index
, state
->clip_planes
[index
]);
3787 checkGLcall("glClipPlane");
3792 static void transform_worldex(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3794 UINT matrix
= state_id
- STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0));
3796 TRACE("Setting world matrix %d\n", matrix
);
3798 if (matrix
>= context
->gl_info
->limits
.blends
)
3800 WARN("Unsupported blend matrix set\n");
3802 } else if(isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_VIEW
))) {
3806 /* GL_MODELVIEW0_ARB: 0x1700
3807 * GL_MODELVIEW1_ARB: 0x850a
3808 * GL_MODELVIEW2_ARB: 0x8722
3809 * GL_MODELVIEW3_ARB: 0x8723
3811 * GL_MODELVIEW31_ARB: 0x873F
3813 if(matrix
== 1) glMat
= GL_MODELVIEW1_ARB
;
3814 else glMat
= GL_MODELVIEW2_ARB
- 2 + matrix
;
3816 glMatrixMode(glMat
);
3817 checkGLcall("glMatrixMode(glMat)");
3819 /* World matrix 0 is multiplied with the view matrix because d3d uses 3
3820 * matrices while gl uses only 2. To avoid weighting the view matrix
3821 * incorrectly it has to be multiplied into every GL modelview matrix. */
3822 if (context
->swapchain
->device
->view_ident
)
3824 glLoadMatrixf(&state
->transforms
[WINED3DTS_WORLDMATRIX(matrix
)].u
.m
[0][0]);
3825 checkGLcall("glLoadMatrixf");
3829 glLoadMatrixf(&state
->transforms
[WINED3DTS_VIEW
].u
.m
[0][0]);
3830 checkGLcall("glLoadMatrixf");
3831 glMultMatrixf(&state
->transforms
[WINED3DTS_WORLDMATRIX(matrix
)].u
.m
[0][0]);
3832 checkGLcall("glMultMatrixf");
3836 static void state_vertexblend_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3838 enum wined3d_vertex_blend_flags f
= state
->render_states
[WINED3D_RS_VERTEXBLEND
];
3839 static unsigned int once
;
3841 if (f
== WINED3D_VBF_DISABLE
)
3844 if (!once
++) FIXME("Vertex blend flags %#x not supported.\n", f
);
3845 else WARN("Vertex blend flags %#x not supported.\n", f
);
3848 static void state_vertexblend(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3850 enum wined3d_vertex_blend_flags val
= state
->render_states
[WINED3D_RS_VERTEXBLEND
];
3851 struct wined3d_device
*device
= context
->swapchain
->device
;
3852 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3853 static unsigned int once
;
3857 case WINED3D_VBF_1WEIGHTS
:
3858 case WINED3D_VBF_2WEIGHTS
:
3859 case WINED3D_VBF_3WEIGHTS
:
3860 glEnable(GL_VERTEX_BLEND_ARB
);
3861 checkGLcall("glEnable(GL_VERTEX_BLEND_ARB)");
3863 /* D3D adds one more matrix which has weight (1 - sum(weights)).
3864 * This is enabled at context creation with enabling
3865 * GL_WEIGHT_SUM_UNITY_ARB. */
3866 GL_EXTCALL(glVertexBlendARB(state
->render_states
[WINED3D_RS_VERTEXBLEND
] + 1));
3868 if (!device
->vertexBlendUsed
)
3871 for (i
= 1; i
< gl_info
->limits
.blends
; ++i
)
3873 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(i
))))
3874 transform_worldex(context
, state
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(i
)));
3876 device
->vertexBlendUsed
= TRUE
;
3880 case WINED3D_VBF_TWEENING
:
3881 case WINED3D_VBF_0WEIGHTS
: /* Indexed vertex blending, not supported. */
3882 if (!once
++) FIXME("Vertex blend flags %#x not supported.\n", val
);
3883 else WARN("Vertex blend flags %#x not supported.\n", val
);
3885 case WINED3D_VBF_DISABLE
:
3886 glDisable(GL_VERTEX_BLEND_ARB
);
3887 checkGLcall("glDisable(GL_VERTEX_BLEND_ARB)");
3892 static void transform_view(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3894 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3895 const struct wined3d_light_info
*light
= NULL
;
3898 /* If we are changing the View matrix, reset the light and clipping planes to the new view
3899 * NOTE: We have to reset the positions even if the light/plane is not currently
3900 * enabled, since the call to enable it will not reset the position.
3901 * NOTE2: Apparently texture transforms do NOT need reapplying
3904 glMatrixMode(GL_MODELVIEW
);
3905 checkGLcall("glMatrixMode(GL_MODELVIEW)");
3906 glLoadMatrixf(&state
->transforms
[WINED3DTS_VIEW
].u
.m
[0][0]);
3907 checkGLcall("glLoadMatrixf(...)");
3909 /* Reset lights. TODO: Call light apply func */
3910 for (k
= 0; k
< gl_info
->limits
.lights
; ++k
)
3912 if (!(light
= state
->lights
[k
]))
3914 glLightfv(GL_LIGHT0
+ light
->glIndex
, GL_POSITION
, light
->lightPosn
);
3915 checkGLcall("glLightfv posn");
3916 glLightfv(GL_LIGHT0
+ light
->glIndex
, GL_SPOT_DIRECTION
, light
->lightDirn
);
3917 checkGLcall("glLightfv dirn");
3920 /* Reset Clipping Planes */
3921 for (k
= 0; k
< gl_info
->limits
.clipplanes
; ++k
)
3923 if (!isStateDirty(context
, STATE_CLIPPLANE(k
)))
3924 clipplane(context
, state
, STATE_CLIPPLANE(k
));
3927 if(context
->last_was_rhw
) {
3929 checkGLcall("glLoadIdentity()");
3930 /* No need to update the world matrix, the identity is fine */
3934 /* Call the world matrix state, this will apply the combined WORLD + VIEW matrix
3935 * No need to do it here if the state is scheduled for update. */
3936 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0))))
3937 transform_world(context
, state
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)));
3939 /* Avoid looping over a number of matrices if the app never used the functionality */
3940 if (context
->swapchain
->device
->vertexBlendUsed
)
3942 for (k
= 1; k
< gl_info
->limits
.blends
; ++k
)
3944 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(k
))))
3945 transform_worldex(context
, state
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(k
)));
3950 static void transform_projection(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3952 glMatrixMode(GL_PROJECTION
);
3953 checkGLcall("glMatrixMode(GL_PROJECTION)");
3955 /* There are a couple of additional things we have to take into account
3956 * here besides the projection transformation itself:
3957 * - We need to flip along the y-axis in case of offscreen rendering.
3958 * - OpenGL Z range is {-Wc,...,Wc} while D3D Z range is {0,...,Wc}.
3959 * - D3D coordinates refer to pixel centers while GL coordinates refer
3961 * - D3D has a top-left filling convention. We need to maintain this
3962 * even after the y-flip mentioned above.
3963 * In order to handle the last two points, we translate by
3964 * (63.0 / 128.0) / VPw and (63.0 / 128.0) / VPh. This is equivalent to
3965 * translating slightly less than half a pixel. We want the difference to
3966 * be large enough that it doesn't get lost due to rounding inside the
3967 * driver, but small enough to prevent it from interfering with any
3970 if (context
->last_was_rhw
)
3972 /* Transform D3D RHW coordinates to OpenGL clip coordinates. */
3973 double x
= state
->viewport
.x
;
3974 double y
= state
->viewport
.y
;
3975 double w
= state
->viewport
.width
;
3976 double h
= state
->viewport
.height
;
3977 double x_scale
= 2.0 / w
;
3978 double x_offset
= ((63.0 / 64.0) - (2.0 * x
) - w
) / w
;
3979 double y_scale
= context
->render_offscreen
? 2.0 / h
: 2.0 / -h
;
3980 double y_offset
= context
->render_offscreen
3981 ? ((63.0 / 64.0) - (2.0 * y
) - h
) / h
3982 : ((63.0 / 64.0) - (2.0 * y
) - h
) / -h
;
3983 const GLdouble projection
[] =
3985 x_scale
, 0.0, 0.0, 0.0,
3986 0.0, y_scale
, 0.0, 0.0,
3988 x_offset
, y_offset
, -1.0, 1.0,
3991 glLoadMatrixd(projection
);
3992 checkGLcall("glLoadMatrixd");
3996 double y_scale
= context
->render_offscreen
? -1.0 : 1.0;
3997 double x_offset
= (63.0 / 64.0) / state
->viewport
.width
;
3998 double y_offset
= context
->render_offscreen
3999 ? (63.0 / 64.0) / state
->viewport
.height
4000 : -(63.0 / 64.0) / state
->viewport
.height
;
4001 const GLdouble projection
[] =
4004 0.0, y_scale
, 0.0, 0.0,
4006 x_offset
, y_offset
, -1.0, 1.0,
4009 glLoadMatrixd(projection
);
4010 checkGLcall("glLoadMatrixd");
4012 glMultMatrixf(&state
->transforms
[WINED3DTS_PROJECTION
].u
.m
[0][0]);
4013 checkGLcall("glLoadMatrixf");
4017 /* This should match any arrays loaded in load_vertex_data.
4018 * TODO: Only load / unload arrays if we have to. */
4019 static void unload_vertex_data(const struct wined3d_gl_info
*gl_info
)
4021 glDisableClientState(GL_VERTEX_ARRAY
);
4022 glDisableClientState(GL_NORMAL_ARRAY
);
4023 glDisableClientState(GL_COLOR_ARRAY
);
4024 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
4026 glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT
);
4028 if (gl_info
->supported
[ARB_VERTEX_BLEND
])
4030 glDisableClientState(GL_WEIGHT_ARRAY_ARB
);
4032 unload_tex_coords(gl_info
);
4035 static inline void unload_numbered_array(struct wined3d_context
*context
, int i
)
4037 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4039 GL_EXTCALL(glDisableVertexAttribArrayARB(i
));
4040 checkGLcall("glDisableVertexAttribArrayARB(reg)");
4042 context
->numbered_array_mask
&= ~(1 << i
);
4045 /* This should match any arrays loaded in loadNumberedArrays
4046 * TODO: Only load / unload arrays if we have to. */
4047 static void unload_numbered_arrays(struct wined3d_context
*context
)
4049 /* disable any attribs (this is the same for both GLSL and ARB modes) */
4052 for (i
= 0; i
< context
->gl_info
->limits
.vertex_attribs
; ++i
) {
4053 unload_numbered_array(context
, i
);
4057 static void load_numbered_arrays(struct wined3d_context
*context
,
4058 const struct wined3d_stream_info
*stream_info
, const struct wined3d_state
*state
)
4060 struct wined3d_device
*device
= context
->swapchain
->device
;
4061 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4062 GLuint curVBO
= gl_info
->supported
[ARB_VERTEX_BUFFER_OBJECT
] ? ~0U : 0;
4065 /* Default to no instancing */
4066 device
->instancedDraw
= FALSE
;
4068 for (i
= 0; i
< MAX_ATTRIBS
; i
++)
4070 const struct wined3d_stream_state
*stream
;
4072 if (!(stream_info
->use_map
& (1 << i
)))
4074 if (context
->numbered_array_mask
& (1 << i
)) unload_numbered_array(context
, i
);
4078 stream
= &state
->streams
[stream_info
->elements
[i
].stream_idx
];
4080 /* Do not load instance data. It will be specified using glTexCoord by drawprim */
4081 if (stream
->flags
& WINED3DSTREAMSOURCE_INSTANCEDATA
)
4083 if (context
->numbered_array_mask
& (1 << i
)) unload_numbered_array(context
, i
);
4084 device
->instancedDraw
= TRUE
;
4088 TRACE_(d3d_shader
)("Loading array %u [VBO=%u]\n", i
, stream_info
->elements
[i
].data
.buffer_object
);
4090 if (stream_info
->elements
[i
].stride
)
4092 if (curVBO
!= stream_info
->elements
[i
].data
.buffer_object
)
4094 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, stream_info
->elements
[i
].data
.buffer_object
));
4095 checkGLcall("glBindBufferARB");
4096 curVBO
= stream_info
->elements
[i
].data
.buffer_object
;
4098 /* Use the VBO to find out if a vertex buffer exists, not the vb
4099 * pointer. vb can point to a user pointer data blob. In that case
4100 * curVBO will be 0. If there is a vertex buffer but no vbo we
4101 * won't be load converted attributes anyway. */
4102 GL_EXTCALL(glVertexAttribPointerARB(i
, stream_info
->elements
[i
].format
->gl_vtx_format
,
4103 stream_info
->elements
[i
].format
->gl_vtx_type
,
4104 stream_info
->elements
[i
].format
->gl_normalized
,
4105 stream_info
->elements
[i
].stride
, stream_info
->elements
[i
].data
.addr
4106 + state
->load_base_vertex_index
* stream_info
->elements
[i
].stride
));
4108 if (!(context
->numbered_array_mask
& (1 << i
)))
4110 GL_EXTCALL(glEnableVertexAttribArrayARB(i
));
4111 context
->numbered_array_mask
|= (1 << i
);
4116 /* Stride = 0 means always the same values.
4117 * glVertexAttribPointerARB doesn't do that. Instead disable the
4118 * pointer and set up the attribute statically. But we have to
4119 * figure out the system memory address. */
4120 const BYTE
*ptr
= stream_info
->elements
[i
].data
.addr
;
4121 if (stream_info
->elements
[i
].data
.buffer_object
)
4123 ptr
+= (ULONG_PTR
)buffer_get_sysmem(stream
->buffer
, gl_info
);
4126 if (context
->numbered_array_mask
& (1 << i
)) unload_numbered_array(context
, i
);
4128 switch (stream_info
->elements
[i
].format
->id
)
4130 case WINED3DFMT_R32_FLOAT
:
4131 GL_EXTCALL(glVertexAttrib1fvARB(i
, (const GLfloat
*)ptr
));
4133 case WINED3DFMT_R32G32_FLOAT
:
4134 GL_EXTCALL(glVertexAttrib2fvARB(i
, (const GLfloat
*)ptr
));
4136 case WINED3DFMT_R32G32B32_FLOAT
:
4137 GL_EXTCALL(glVertexAttrib3fvARB(i
, (const GLfloat
*)ptr
));
4139 case WINED3DFMT_R32G32B32A32_FLOAT
:
4140 GL_EXTCALL(glVertexAttrib4fvARB(i
, (const GLfloat
*)ptr
));
4143 case WINED3DFMT_R8G8B8A8_UINT
:
4144 GL_EXTCALL(glVertexAttrib4NubvARB(i
, ptr
));
4146 case WINED3DFMT_B8G8R8A8_UNORM
:
4147 if (gl_info
->supported
[ARB_VERTEX_ARRAY_BGRA
])
4149 const DWORD
*src
= (const DWORD
*)ptr
;
4150 DWORD c
= *src
& 0xff00ff00;
4151 c
|= (*src
& 0xff0000) >> 16;
4152 c
|= (*src
& 0xff) << 16;
4153 GL_EXTCALL(glVertexAttrib4NubvARB(i
, (GLubyte
*)&c
));
4156 /* else fallthrough */
4157 case WINED3DFMT_R8G8B8A8_UNORM
:
4158 GL_EXTCALL(glVertexAttrib4NubvARB(i
, ptr
));
4161 case WINED3DFMT_R16G16_SINT
:
4162 GL_EXTCALL(glVertexAttrib4svARB(i
, (const GLshort
*)ptr
));
4164 case WINED3DFMT_R16G16B16A16_SINT
:
4165 GL_EXTCALL(glVertexAttrib4svARB(i
, (const GLshort
*)ptr
));
4168 case WINED3DFMT_R16G16_SNORM
:
4170 const GLshort s
[4] = {((const GLshort
*)ptr
)[0], ((const GLshort
*)ptr
)[1], 0, 1};
4171 GL_EXTCALL(glVertexAttrib4NsvARB(i
, s
));
4174 case WINED3DFMT_R16G16_UNORM
:
4176 const GLushort s
[4] = {((const GLushort
*)ptr
)[0], ((const GLushort
*)ptr
)[1], 0, 1};
4177 GL_EXTCALL(glVertexAttrib4NusvARB(i
, s
));
4180 case WINED3DFMT_R16G16B16A16_SNORM
:
4181 GL_EXTCALL(glVertexAttrib4NsvARB(i
, (const GLshort
*)ptr
));
4183 case WINED3DFMT_R16G16B16A16_UNORM
:
4184 GL_EXTCALL(glVertexAttrib4NusvARB(i
, (const GLushort
*)ptr
));
4187 case WINED3DFMT_R10G10B10A2_UINT
:
4188 FIXME("Unsure about WINED3DDECLTYPE_UDEC3\n");
4189 /*glVertexAttrib3usvARB(i, (const GLushort *)ptr); Does not exist */
4191 case WINED3DFMT_R10G10B10A2_SNORM
:
4192 FIXME("Unsure about WINED3DDECLTYPE_DEC3N\n");
4193 /*glVertexAttrib3NusvARB(i, (const GLushort *)ptr); Does not exist */
4196 case WINED3DFMT_R16G16_FLOAT
:
4197 /* Are those 16 bit floats. C doesn't have a 16 bit float type. I could read the single bits and calculate a 4
4198 * byte float according to the IEEE standard
4200 FIXME("Unsupported WINED3DDECLTYPE_FLOAT16_2\n");
4202 case WINED3DFMT_R16G16B16A16_FLOAT
:
4203 FIXME("Unsupported WINED3DDECLTYPE_FLOAT16_4\n");
4207 ERR("Unexpected declaration in stride 0 attributes\n");
4213 checkGLcall("Loading numbered arrays");
4216 static void load_vertex_data(const struct wined3d_context
*context
,
4217 const struct wined3d_stream_info
*si
, const struct wined3d_state
*state
)
4219 struct wined3d_device
*device
= context
->swapchain
->device
;
4220 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4221 GLuint curVBO
= gl_info
->supported
[ARB_VERTEX_BUFFER_OBJECT
] ? ~0U : 0;
4222 const struct wined3d_stream_info_element
*e
;
4224 TRACE("Using fast vertex array code\n");
4226 /* This is fixed function pipeline only, and the fixed function pipeline doesn't do instancing */
4227 device
->instancedDraw
= FALSE
;
4229 /* Blend Data ---------------------------------------------- */
4230 if ((si
->use_map
& (1 << WINED3D_FFP_BLENDWEIGHT
))
4231 || si
->use_map
& (1 << WINED3D_FFP_BLENDINDICES
))
4233 e
= &si
->elements
[WINED3D_FFP_BLENDWEIGHT
];
4235 if (gl_info
->supported
[ARB_VERTEX_BLEND
])
4237 TRACE("Blend %u %p %u\n", e
->format
->component_count
,
4238 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
, e
->stride
);
4240 glEnableClientState(GL_WEIGHT_ARRAY_ARB
);
4241 checkGLcall("glEnableClientState(GL_WEIGHT_ARRAY_ARB)");
4243 GL_EXTCALL(glVertexBlendARB(e
->format
->component_count
+ 1));
4245 if (curVBO
!= e
->data
.buffer_object
)
4247 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, e
->data
.buffer_object
));
4248 checkGLcall("glBindBufferARB");
4249 curVBO
= e
->data
.buffer_object
;
4252 TRACE("glWeightPointerARB(%#x, %#x, %#x, %p);\n",
4253 e
->format
->gl_vtx_format
,
4254 e
->format
->gl_vtx_type
,
4256 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4257 GL_EXTCALL(glWeightPointerARB(e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
4258 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
));
4260 checkGLcall("glWeightPointerARB");
4262 if (si
->use_map
& (1 << WINED3D_FFP_BLENDINDICES
))
4267 FIXME("blendMatrixIndices support\n");
4272 /* TODO: support blends in drawStridedSlow
4273 * No need to write a FIXME here, this is done after the general vertex decl decoding
4275 WARN("unsupported blending in openGl\n");
4280 if (gl_info
->supported
[ARB_VERTEX_BLEND
])
4282 static const GLbyte one
= 1;
4283 GL_EXTCALL(glWeightbvARB(1, &one
));
4284 checkGLcall("glWeightbvARB(gl_info->max_blends, weights)");
4288 /* Point Size ----------------------------------------------*/
4289 if (si
->use_map
& (1 << WINED3D_FFP_PSIZE
))
4291 /* no such functionality in the fixed function GL pipeline */
4292 TRACE("Cannot change ptSize here in openGl\n");
4293 /* TODO: Implement this function in using shaders if they are available */
4296 /* Vertex Pointers -----------------------------------------*/
4297 if (si
->use_map
& (1 << WINED3D_FFP_POSITION
))
4299 e
= &si
->elements
[WINED3D_FFP_POSITION
];
4301 if (curVBO
!= e
->data
.buffer_object
)
4303 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, e
->data
.buffer_object
));
4304 checkGLcall("glBindBufferARB");
4305 curVBO
= e
->data
.buffer_object
;
4308 /* min(WINED3D_ATR_FORMAT(position),3) to Disable RHW mode as 'w' coord
4309 handling for rhw mode should not impact screen position whereas in GL it does.
4310 This may result in very slightly distorted textures in rhw mode.
4311 There's always the other option of fixing the view matrix to
4312 prevent w from having any effect.
4314 This only applies to user pointer sources, in VBOs the vertices are fixed up
4316 if (!e
->data
.buffer_object
)
4318 TRACE("glVertexPointer(3, %#x, %#x, %p);\n", e
->format
->gl_vtx_type
, e
->stride
,
4319 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4320 glVertexPointer(3 /* min(e->format->gl_vtx_format, 3) */, e
->format
->gl_vtx_type
, e
->stride
,
4321 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4325 TRACE("glVertexPointer(%#x, %#x, %#x, %p);\n",
4326 e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
4327 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4328 glVertexPointer(e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
4329 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4331 checkGLcall("glVertexPointer(...)");
4332 glEnableClientState(GL_VERTEX_ARRAY
);
4333 checkGLcall("glEnableClientState(GL_VERTEX_ARRAY)");
4336 /* Normals -------------------------------------------------*/
4337 if (si
->use_map
& (1 << WINED3D_FFP_NORMAL
))
4339 e
= &si
->elements
[WINED3D_FFP_NORMAL
];
4341 if (curVBO
!= e
->data
.buffer_object
)
4343 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, e
->data
.buffer_object
));
4344 checkGLcall("glBindBufferARB");
4345 curVBO
= e
->data
.buffer_object
;
4348 TRACE("glNormalPointer(%#x, %#x, %p);\n", e
->format
->gl_vtx_type
, e
->stride
,
4349 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4350 glNormalPointer(e
->format
->gl_vtx_type
, e
->stride
,
4351 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4352 checkGLcall("glNormalPointer(...)");
4353 glEnableClientState(GL_NORMAL_ARRAY
);
4354 checkGLcall("glEnableClientState(GL_NORMAL_ARRAY)");
4357 glNormal3f(0, 0, 0);
4358 checkGLcall("glNormal3f(0, 0, 0)");
4361 /* Diffuse Colour --------------------------------------------*/
4362 /* WARNING: Data here MUST be in RGBA format, so cannot */
4363 /* go directly into fast mode from app pgm, because */
4364 /* directx requires data in BGRA format. */
4365 /* currently fixupVertices swizzles the format, but this isn't*/
4366 /* very practical when using VBOs */
4367 /* NOTE: Unless we write a vertex shader to swizzle the colour*/
4368 /* , or the user doesn't care and wants the speed advantage */
4370 if (si
->use_map
& (1 << WINED3D_FFP_DIFFUSE
))
4372 e
= &si
->elements
[WINED3D_FFP_DIFFUSE
];
4374 if (curVBO
!= e
->data
.buffer_object
)
4376 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, e
->data
.buffer_object
));
4377 checkGLcall("glBindBufferARB");
4378 curVBO
= e
->data
.buffer_object
;
4381 TRACE("glColorPointer(%#x, %#x %#x, %p);\n",
4382 e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
4383 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4384 glColorPointer(e
->format
->gl_vtx_format
, e
->format
->gl_vtx_type
, e
->stride
,
4385 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4386 checkGLcall("glColorPointer(4, GL_UNSIGNED_BYTE, ...)");
4387 glEnableClientState(GL_COLOR_ARRAY
);
4388 checkGLcall("glEnableClientState(GL_COLOR_ARRAY)");
4391 glColor4f(1.0f
, 1.0f
, 1.0f
, 1.0f
);
4392 checkGLcall("glColor4f(1, 1, 1, 1)");
4395 /* Specular Colour ------------------------------------------*/
4396 if (si
->use_map
& (1 << WINED3D_FFP_SPECULAR
))
4398 TRACE("setting specular colour\n");
4400 e
= &si
->elements
[WINED3D_FFP_SPECULAR
];
4402 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
4404 GLenum type
= e
->format
->gl_vtx_type
;
4405 GLint format
= e
->format
->gl_vtx_format
;
4407 if (curVBO
!= e
->data
.buffer_object
)
4409 GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB
, e
->data
.buffer_object
));
4410 checkGLcall("glBindBufferARB");
4411 curVBO
= e
->data
.buffer_object
;
4414 if (format
!= 4 || (gl_info
->quirks
& WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA
))
4416 /* Usually specular colors only allow 3 components, since they have no alpha. In D3D, the specular alpha
4417 * contains the fog coordinate, which is passed to GL with GL_EXT_fog_coord. However, the fixed function
4418 * vertex pipeline can pass the specular alpha through, and pixel shaders can read it. So it GL accepts
4419 * 4 component secondary colors use it
4421 TRACE("glSecondaryColorPointer(%#x, %#x, %#x, %p);\n", format
, type
, e
->stride
,
4422 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4423 GL_EXTCALL(glSecondaryColorPointerEXT(format
, type
, e
->stride
,
4424 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
));
4425 checkGLcall("glSecondaryColorPointerEXT(format, type, ...)");
4431 case GL_UNSIGNED_BYTE
:
4432 TRACE("glSecondaryColorPointer(3, GL_UNSIGNED_BYTE, %#x, %p);\n", e
->stride
,
4433 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4434 GL_EXTCALL(glSecondaryColorPointerEXT(3, GL_UNSIGNED_BYTE
, e
->stride
,
4435 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
));
4436 checkGLcall("glSecondaryColorPointerEXT(3, GL_UNSIGNED_BYTE, ...)");
4440 FIXME("Add 4 component specular color pointers for type %x\n", type
);
4441 /* Make sure that the right color component is dropped */
4442 TRACE("glSecondaryColorPointer(3, %#x, %#x, %p);\n", type
, e
->stride
,
4443 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
);
4444 GL_EXTCALL(glSecondaryColorPointerEXT(3, type
, e
->stride
,
4445 e
->data
.addr
+ state
->load_base_vertex_index
* e
->stride
));
4446 checkGLcall("glSecondaryColorPointerEXT(3, type, ...)");
4449 glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT
);
4450 checkGLcall("glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
4454 WARN("Specular colour is not supported in this GL implementation.\n");
4459 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
4461 GL_EXTCALL(glSecondaryColor3fEXT
)(0, 0, 0);
4462 checkGLcall("glSecondaryColor3fEXT(0, 0, 0)");
4466 WARN("Specular colour is not supported in this GL implementation.\n");
4470 /* Texture coords -------------------------------------------*/
4471 load_tex_coords(context
, si
, &curVBO
, state
);
4474 static void streamsrc(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4476 const struct wined3d_device
*device
= context
->swapchain
->device
;
4477 BOOL load_numbered
= use_vs(state
) && !device
->useDrawStridedSlow
;
4478 BOOL load_named
= !use_vs(state
) && !device
->useDrawStridedSlow
;
4480 if (isStateDirty(context
, STATE_VDECL
)) return;
4481 if (context
->numberedArraysLoaded
&& !load_numbered
)
4483 unload_numbered_arrays(context
);
4484 context
->numberedArraysLoaded
= FALSE
;
4485 context
->numbered_array_mask
= 0;
4487 else if (context
->namedArraysLoaded
)
4489 unload_vertex_data(context
->gl_info
);
4490 context
->namedArraysLoaded
= FALSE
;
4495 TRACE("Loading numbered arrays\n");
4496 load_numbered_arrays(context
, &device
->strided_streams
, state
);
4497 context
->numberedArraysLoaded
= TRUE
;
4499 else if (load_named
)
4501 TRACE("Loading vertex data\n");
4502 load_vertex_data(context
, &device
->strided_streams
, state
);
4503 context
->namedArraysLoaded
= TRUE
;
4507 static void vdecl_miscpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4509 if (isStateDirty(context
, STATE_STREAMSRC
))
4511 streamsrc(context
, state
, STATE_STREAMSRC
);
4514 static void vertexdeclaration(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4516 const struct wined3d_device
*device
= context
->swapchain
->device
;
4517 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4518 BOOL useVertexShaderFunction
= use_vs(state
);
4519 BOOL usePixelShaderFunction
= use_ps(state
);
4520 BOOL updateFog
= FALSE
;
4522 BOOL wasrhw
= context
->last_was_rhw
;
4525 transformed
= device
->strided_streams
.position_transformed
;
4526 if (transformed
!= context
->last_was_rhw
&& !useVertexShaderFunction
)
4529 context
->last_was_rhw
= transformed
;
4531 /* Don't have to apply the matrices when vertex shaders are used. When
4532 * vshaders are turned off this function will be called again anyway to
4533 * make sure they're properly set. */
4534 if (!useVertexShaderFunction
)
4536 /* TODO: Move this mainly to the viewport state and only apply when
4537 * the vp has changed or transformed / untransformed was switched. */
4538 if (wasrhw
!= context
->last_was_rhw
4539 && !isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_PROJECTION
))
4540 && !isStateDirty(context
, STATE_VIEWPORT
))
4541 transform_projection(context
, state
, STATE_TRANSFORM(WINED3DTS_PROJECTION
));
4542 /* World matrix needs reapplication here only if we're switching between rhw and non-rhw
4545 * If a vertex shader is used, the world matrix changed and then vertex shader unbound
4546 * this check will fail and the matrix not applied again. This is OK because a simple
4547 * world matrix change reapplies the matrix - These checks here are only to satisfy the
4548 * needs of the vertex declaration.
4550 * World and view matrix go into the same gl matrix, so only apply them when neither is
4553 if (transformed
!= wasrhw
&& !isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)))
4554 && !isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_VIEW
)))
4555 transform_world(context
, state
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)));
4556 if (!isStateDirty(context
, STATE_RENDER(WINED3D_RS_COLORVERTEX
)))
4557 state_colormat(context
, state
, STATE_RENDER(WINED3D_RS_COLORVERTEX
));
4558 if (!isStateDirty(context
, STATE_RENDER(WINED3D_RS_LIGHTING
)))
4559 state_lighting(context
, state
, STATE_RENDER(WINED3D_RS_LIGHTING
));
4561 if (context
->last_was_vshader
)
4565 if (!device
->vs_clipping
&& !isStateDirty(context
, STATE_RENDER(WINED3D_RS_CLIPPLANEENABLE
)))
4566 state_clipping(context
, state
, STATE_RENDER(WINED3D_RS_CLIPPLANEENABLE
));
4568 for (i
= 0; i
< gl_info
->limits
.clipplanes
; ++i
)
4570 clipplane(context
, state
, STATE_CLIPPLANE(i
));
4573 if (!isStateDirty(context
, STATE_RENDER(WINED3D_RS_NORMALIZENORMALS
)))
4574 state_normalize(context
, state
, STATE_RENDER(WINED3D_RS_NORMALIZENORMALS
));
4578 if(!context
->last_was_vshader
) {
4579 static BOOL warned
= FALSE
;
4580 if(!device
->vs_clipping
) {
4581 /* Disable all clip planes to get defined results on all drivers. See comment in the
4582 * state_clipping state handler
4584 for (i
= 0; i
< gl_info
->limits
.clipplanes
; ++i
)
4586 glDisable(GL_CLIP_PLANE0
+ i
);
4587 checkGLcall("glDisable(GL_CLIP_PLANE0 + i)");
4590 if (!warned
&& state
->render_states
[WINED3D_RS_CLIPPLANEENABLE
])
4592 FIXME("Clipping not supported with vertex shaders\n");
4598 /* Apply the transform matrices when switching from rhw
4599 * drawing to vertex shaders. Vertex shaders themselves do
4600 * not need it, but the matrices are not reapplied
4601 * automatically when switching back from vertex shaders to
4602 * fixed function processing. So make sure we leave the fixed
4603 * function vertex processing states back in a sane state
4604 * before switching to shaders. */
4605 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_PROJECTION
)))
4606 transform_projection(context
, state
, STATE_TRANSFORM(WINED3DTS_PROJECTION
));
4607 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0))))
4608 transform_world(context
, state
, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)));
4612 /* Vertex shader clipping ignores the view matrix. Update all clipplanes
4613 * (Note: ARB shaders can read the clip planes for clipping emulation even if
4614 * device->vs_clipping is false.
4616 for (i
= 0; i
< gl_info
->limits
.clipplanes
; ++i
)
4618 clipplane(context
, state
, STATE_CLIPPLANE(i
));
4623 /* Vertex and pixel shaders are applied together, so let the last dirty
4624 * state do the application. */
4625 if (!isStateDirty(context
, STATE_PIXELSHADER
))
4627 device
->shader_backend
->shader_select(context
, usePixelShaderFunction
, useVertexShaderFunction
);
4629 if (!isStateDirty(context
, STATE_VERTEXSHADERCONSTANT
)
4630 && (useVertexShaderFunction
|| usePixelShaderFunction
))
4631 shaderconstant(context
, state
, STATE_VERTEXSHADERCONSTANT
);
4634 context
->last_was_vshader
= useVertexShaderFunction
;
4637 context_apply_state(context
, state
, STATE_RENDER(WINED3D_RS_FOGVERTEXMODE
));
4639 if (!useVertexShaderFunction
)
4643 for (i
= 0; i
< MAX_TEXTURES
; ++i
)
4645 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_TEXTURE0
+ i
)))
4646 transform_texture(context
, state
, STATE_TEXTURESTAGE(i
, WINED3DTSS_TEXTURETRANSFORMFLAGS
));
4651 static void viewport_miscpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4653 const struct wined3d_surface
*target
= state
->fb
->render_targets
[0];
4654 struct wined3d_viewport vp
= state
->viewport
;
4656 if (vp
.width
> target
->resource
.width
)
4657 vp
.width
= target
->resource
.width
;
4658 if (vp
.height
> target
->resource
.height
)
4659 vp
.height
= target
->resource
.height
;
4661 glDepthRange(vp
.min_z
, vp
.max_z
);
4662 checkGLcall("glDepthRange");
4663 /* Note: GL requires lower left, DirectX supplies upper left. This is
4664 * reversed when using offscreen rendering. */
4665 if (context
->render_offscreen
)
4667 glViewport(vp
.x
, vp
.y
, vp
.width
, vp
.height
);
4673 target
->get_drawable_size(context
, &width
, &height
);
4674 glViewport(vp
.x
, (height
- (vp
.y
+ vp
.height
)),
4675 vp
.width
, vp
.height
);
4678 checkGLcall("glViewport");
4681 static void viewport_vertexpart(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4683 if (!isStateDirty(context
, STATE_TRANSFORM(WINED3DTS_PROJECTION
)))
4684 transform_projection(context
, state
, STATE_TRANSFORM(WINED3DTS_PROJECTION
));
4685 if (!isStateDirty(context
, STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
)))
4686 state_pscale(context
, state
, STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
));
4687 /* Update the position fixup. */
4688 if (!isStateDirty(context
, STATE_VERTEXSHADERCONSTANT
))
4689 shaderconstant(context
, state
, STATE_VERTEXSHADERCONSTANT
);
4692 static void light(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4694 UINT Index
= state_id
- STATE_ACTIVELIGHT(0);
4695 const struct wined3d_light_info
*lightInfo
= state
->lights
[Index
];
4699 glDisable(GL_LIGHT0
+ Index
);
4700 checkGLcall("glDisable(GL_LIGHT0 + Index)");
4705 float colRGBA
[] = {0.0f
, 0.0f
, 0.0f
, 0.0f
};
4707 /* Light settings are affected by the model view in OpenGL, the View transform in direct3d*/
4708 glMatrixMode(GL_MODELVIEW
);
4710 glLoadMatrixf(&state
->transforms
[WINED3DTS_VIEW
].u
.m
[0][0]);
4713 colRGBA
[0] = lightInfo
->OriginalParms
.diffuse
.r
;
4714 colRGBA
[1] = lightInfo
->OriginalParms
.diffuse
.g
;
4715 colRGBA
[2] = lightInfo
->OriginalParms
.diffuse
.b
;
4716 colRGBA
[3] = lightInfo
->OriginalParms
.diffuse
.a
;
4717 glLightfv(GL_LIGHT0
+ Index
, GL_DIFFUSE
, colRGBA
);
4718 checkGLcall("glLightfv");
4721 colRGBA
[0] = lightInfo
->OriginalParms
.specular
.r
;
4722 colRGBA
[1] = lightInfo
->OriginalParms
.specular
.g
;
4723 colRGBA
[2] = lightInfo
->OriginalParms
.specular
.b
;
4724 colRGBA
[3] = lightInfo
->OriginalParms
.specular
.a
;
4725 glLightfv(GL_LIGHT0
+ Index
, GL_SPECULAR
, colRGBA
);
4726 checkGLcall("glLightfv");
4729 colRGBA
[0] = lightInfo
->OriginalParms
.ambient
.r
;
4730 colRGBA
[1] = lightInfo
->OriginalParms
.ambient
.g
;
4731 colRGBA
[2] = lightInfo
->OriginalParms
.ambient
.b
;
4732 colRGBA
[3] = lightInfo
->OriginalParms
.ambient
.a
;
4733 glLightfv(GL_LIGHT0
+ Index
, GL_AMBIENT
, colRGBA
);
4734 checkGLcall("glLightfv");
4736 if ((lightInfo
->OriginalParms
.range
* lightInfo
->OriginalParms
.range
) >= FLT_MIN
)
4737 quad_att
= 1.4f
/ (lightInfo
->OriginalParms
.range
* lightInfo
->OriginalParms
.range
);
4739 quad_att
= 0.0f
; /* 0 or MAX? (0 seems to be ok) */
4741 /* Do not assign attenuation values for lights that do not use them. D3D apps are free to pass any junk,
4742 * but gl drivers use them and may crash due to bad Attenuation values. Need for Speed most wanted sets
4743 * Attenuation0 to NaN and crashes in the gl lib
4746 switch (lightInfo
->OriginalParms
.type
)
4748 case WINED3D_LIGHT_POINT
:
4750 glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->lightPosn
[0]);
4751 checkGLcall("glLightfv");
4752 glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
4753 checkGLcall("glLightf");
4754 /* Attenuation - Are these right? guessing... */
4755 glLightf(GL_LIGHT0
+ Index
, GL_CONSTANT_ATTENUATION
, lightInfo
->OriginalParms
.attenuation0
);
4756 checkGLcall("glLightf");
4757 glLightf(GL_LIGHT0
+ Index
, GL_LINEAR_ATTENUATION
, lightInfo
->OriginalParms
.attenuation1
);
4758 checkGLcall("glLightf");
4759 if (quad_att
< lightInfo
->OriginalParms
.attenuation2
)
4760 quad_att
= lightInfo
->OriginalParms
.attenuation2
;
4761 glLightf(GL_LIGHT0
+ Index
, GL_QUADRATIC_ATTENUATION
, quad_att
);
4762 checkGLcall("glLightf");
4766 case WINED3D_LIGHT_SPOT
:
4768 glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->lightPosn
[0]);
4769 checkGLcall("glLightfv");
4771 glLightfv(GL_LIGHT0
+ Index
, GL_SPOT_DIRECTION
, &lightInfo
->lightDirn
[0]);
4772 checkGLcall("glLightfv");
4773 glLightf(GL_LIGHT0
+ Index
, GL_SPOT_EXPONENT
, lightInfo
->exponent
);
4774 checkGLcall("glLightf");
4775 glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
4776 checkGLcall("glLightf");
4777 /* Attenuation - Are these right? guessing... */
4778 glLightf(GL_LIGHT0
+ Index
, GL_CONSTANT_ATTENUATION
, lightInfo
->OriginalParms
.attenuation0
);
4779 checkGLcall("glLightf");
4780 glLightf(GL_LIGHT0
+ Index
, GL_LINEAR_ATTENUATION
, lightInfo
->OriginalParms
.attenuation1
);
4781 checkGLcall("glLightf");
4782 if (quad_att
< lightInfo
->OriginalParms
.attenuation2
)
4783 quad_att
= lightInfo
->OriginalParms
.attenuation2
;
4784 glLightf(GL_LIGHT0
+ Index
, GL_QUADRATIC_ATTENUATION
, quad_att
);
4785 checkGLcall("glLightf");
4789 case WINED3D_LIGHT_DIRECTIONAL
:
4791 glLightfv(GL_LIGHT0
+ Index
, GL_POSITION
, &lightInfo
->lightPosn
[0]); /* Note gl uses w position of 0 for direction! */
4792 checkGLcall("glLightfv");
4793 glLightf(GL_LIGHT0
+ Index
, GL_SPOT_CUTOFF
, lightInfo
->cutoff
);
4794 checkGLcall("glLightf");
4795 glLightf(GL_LIGHT0
+ Index
, GL_SPOT_EXPONENT
, 0.0f
);
4796 checkGLcall("glLightf");
4800 FIXME("Unrecognized light type %#x.\n", lightInfo
->OriginalParms
.type
);
4803 /* Restore the modelview matrix */
4806 glEnable(GL_LIGHT0
+ Index
);
4807 checkGLcall("glEnable(GL_LIGHT0 + Index)");
4811 static void scissorrect(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4813 const RECT
*r
= &state
->scissor_rect
;
4815 /* Warning: glScissor uses window coordinates, not viewport coordinates,
4816 * so our viewport correction does not apply. Warning2: Even in windowed
4817 * mode the coords are relative to the window, not the screen. */
4818 TRACE("Setting new scissor rect to %s.\n", wine_dbgstr_rect(r
));
4820 if (context
->render_offscreen
)
4822 glScissor(r
->left
, r
->top
, r
->right
- r
->left
, r
->bottom
- r
->top
);
4826 const struct wined3d_surface
*target
= state
->fb
->render_targets
[0];
4830 target
->get_drawable_size(context
, &width
, &height
);
4831 glScissor(r
->left
, height
- r
->bottom
, r
->right
- r
->left
, r
->bottom
- r
->top
);
4833 checkGLcall("glScissor");
4836 static void indexbuffer(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4838 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4840 if (state
->user_stream
|| !state
->index_buffer
)
4842 GL_EXTCALL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB
, 0));
4846 struct wined3d_buffer
*ib
= state
->index_buffer
;
4847 GL_EXTCALL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB
, ib
->buffer_object
));
4851 static void frontface(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4853 if (context
->render_offscreen
)
4855 glFrontFace(GL_CCW
);
4856 checkGLcall("glFrontFace(GL_CCW)");
4859 checkGLcall("glFrontFace(GL_CW)");
4863 static void psorigin_w(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4869 WARN("Point sprite coordinate origin switching not supported.\n");
4874 static void psorigin(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
4876 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
4877 GLint origin
= context
->render_offscreen
? GL_LOWER_LEFT
: GL_UPPER_LEFT
;
4879 if (glPointParameteri
)
4881 glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN
, origin
);
4882 checkGLcall("glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, ...)");
4884 else if (gl_info
->supported
[NV_POINT_SPRITE
])
4886 GL_EXTCALL(glPointParameteriNV(GL_POINT_SPRITE_COORD_ORIGIN
, origin
));
4887 checkGLcall("glPointParameteriNV(GL_POINT_SPRITE_COORD_ORIGIN, ...)");
4891 const struct StateEntryTemplate misc_state_template
[] = {
4892 { STATE_RENDER(WINED3D_RS_SRCBLEND
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4893 { STATE_RENDER(WINED3D_RS_DESTBLEND
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4894 { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), state_blend
}, WINED3D_GL_EXT_NONE
},
4895 { STATE_RENDER(WINED3D_RS_EDGEANTIALIAS
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4896 { STATE_RENDER(WINED3D_RS_ANTIALIASEDLINEENABLE
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4897 { STATE_RENDER(WINED3D_RS_SEPARATEALPHABLENDENABLE
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4898 { STATE_RENDER(WINED3D_RS_SRCBLENDALPHA
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4899 { STATE_RENDER(WINED3D_RS_DESTBLENDALPHA
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4900 { STATE_RENDER(WINED3D_RS_DESTBLENDALPHA
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4901 { STATE_RENDER(WINED3D_RS_BLENDOPALPHA
), { STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4902 { STATE_STREAMSRC
, { STATE_STREAMSRC
, streamsrc
}, WINED3D_GL_EXT_NONE
},
4903 { STATE_VDECL
, { STATE_VDECL
, vdecl_miscpart
}, WINED3D_GL_EXT_NONE
},
4904 { STATE_FRONTFACE
, { STATE_FRONTFACE
, frontface
}, WINED3D_GL_EXT_NONE
},
4905 { STATE_SCISSORRECT
, { STATE_SCISSORRECT
, scissorrect
}, WINED3D_GL_EXT_NONE
},
4906 { STATE_POINTSPRITECOORDORIGIN
, { STATE_POINTSPRITECOORDORIGIN
, psorigin
}, WINED3D_GL_VERSION_2_0
},
4907 { STATE_POINTSPRITECOORDORIGIN
, { STATE_POINTSPRITECOORDORIGIN
, psorigin_w
}, WINED3D_GL_EXT_NONE
},
4909 /* TODO: Move shader constant loading to vertex and fragment pipeline respectively, as soon as the pshader and
4910 * vshader loadings are untied from each other
4912 { STATE_VERTEXSHADERCONSTANT
, { STATE_VERTEXSHADERCONSTANT
, shaderconstant
}, WINED3D_GL_EXT_NONE
},
4913 { STATE_PIXELSHADERCONSTANT
, { STATE_VERTEXSHADERCONSTANT
, NULL
}, WINED3D_GL_EXT_NONE
},
4914 { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4915 { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4916 { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4917 { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4918 { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4919 { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4920 { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4921 { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4922 { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4923 { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4924 { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4925 { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4926 { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4927 { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4928 { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4929 { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4930 { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4931 { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4932 { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4933 { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4934 { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4935 { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4936 { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4937 { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4938 { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4939 { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4940 { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4941 { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4942 { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00
), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00
), shader_bumpenvmat
}, WINED3D_GL_EXT_NONE
},
4943 { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT01
), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4944 { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT10
), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4945 { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT11
), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
4946 { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
4947 { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVLSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4948 { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
4949 { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVLSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4950 { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
4951 { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVLSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4952 { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
4953 { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVLSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4954 { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
4955 { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVLSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4956 { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
4957 { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVLSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4958 { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
4959 { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVLSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4960 { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLSCALE
), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLSCALE
), tex_bumpenvlscale
}, WINED3D_GL_EXT_NONE
},
4961 { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLOFFSET
), { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVLSCALE
), NULL
}, WINED3D_GL_EXT_NONE
},
4963 { STATE_VIEWPORT
, { STATE_VIEWPORT
, viewport_miscpart
}, WINED3D_GL_EXT_NONE
},
4964 { STATE_INDEXBUFFER
, { STATE_INDEXBUFFER
, indexbuffer
}, ARB_VERTEX_BUFFER_OBJECT
},
4965 { STATE_INDEXBUFFER
, { STATE_INDEXBUFFER
, state_nop
}, WINED3D_GL_EXT_NONE
},
4966 { STATE_RENDER(WINED3D_RS_ANTIALIAS
), { STATE_RENDER(WINED3D_RS_ANTIALIAS
), state_antialias
}, WINED3D_GL_EXT_NONE
},
4967 { STATE_RENDER(WINED3D_RS_TEXTUREPERSPECTIVE
), { STATE_RENDER(WINED3D_RS_TEXTUREPERSPECTIVE
), state_perspective
}, WINED3D_GL_EXT_NONE
},
4968 { STATE_RENDER(WINED3D_RS_ZENABLE
), { STATE_RENDER(WINED3D_RS_ZENABLE
), state_zenable
}, WINED3D_GL_EXT_NONE
},
4969 { STATE_RENDER(WINED3D_RS_WRAPU
), { STATE_RENDER(WINED3D_RS_WRAPU
), state_wrapu
}, WINED3D_GL_EXT_NONE
},
4970 { STATE_RENDER(WINED3D_RS_WRAPV
), { STATE_RENDER(WINED3D_RS_WRAPV
), state_wrapv
}, WINED3D_GL_EXT_NONE
},
4971 { STATE_RENDER(WINED3D_RS_FILLMODE
), { STATE_RENDER(WINED3D_RS_FILLMODE
), state_fillmode
}, WINED3D_GL_EXT_NONE
},
4972 { STATE_RENDER(WINED3D_RS_SHADEMODE
), { STATE_RENDER(WINED3D_RS_SHADEMODE
), state_shademode
}, WINED3D_GL_EXT_NONE
},
4973 { STATE_RENDER(WINED3D_RS_LINEPATTERN
), { STATE_RENDER(WINED3D_RS_LINEPATTERN
), state_linepattern
}, WINED3D_GL_EXT_NONE
},
4974 { STATE_RENDER(WINED3D_RS_MONOENABLE
), { STATE_RENDER(WINED3D_RS_MONOENABLE
), state_monoenable
}, WINED3D_GL_EXT_NONE
},
4975 { STATE_RENDER(WINED3D_RS_ROP2
), { STATE_RENDER(WINED3D_RS_ROP2
), state_rop2
}, WINED3D_GL_EXT_NONE
},
4976 { STATE_RENDER(WINED3D_RS_PLANEMASK
), { STATE_RENDER(WINED3D_RS_PLANEMASK
), state_planemask
}, WINED3D_GL_EXT_NONE
},
4977 { STATE_RENDER(WINED3D_RS_ZWRITEENABLE
), { STATE_RENDER(WINED3D_RS_ZWRITEENABLE
), state_zwritenable
}, WINED3D_GL_EXT_NONE
},
4978 { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), state_alpha
}, WINED3D_GL_EXT_NONE
},
4979 { STATE_RENDER(WINED3D_RS_ALPHAREF
), { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4980 { STATE_RENDER(WINED3D_RS_ALPHAFUNC
), { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4981 { STATE_RENDER(WINED3D_RS_COLORKEYENABLE
), { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4982 { STATE_RENDER(WINED3D_RS_LASTPIXEL
), { STATE_RENDER(WINED3D_RS_LASTPIXEL
), state_lastpixel
}, WINED3D_GL_EXT_NONE
},
4983 { STATE_RENDER(WINED3D_RS_CULLMODE
), { STATE_RENDER(WINED3D_RS_CULLMODE
), state_cullmode
}, WINED3D_GL_EXT_NONE
},
4984 { STATE_RENDER(WINED3D_RS_ZFUNC
), { STATE_RENDER(WINED3D_RS_ZFUNC
), state_zfunc
}, WINED3D_GL_EXT_NONE
},
4985 { STATE_RENDER(WINED3D_RS_DITHERENABLE
), { STATE_RENDER(WINED3D_RS_DITHERENABLE
), state_ditherenable
}, WINED3D_GL_EXT_NONE
},
4986 { STATE_RENDER(WINED3D_RS_SUBPIXEL
), { STATE_RENDER(WINED3D_RS_SUBPIXEL
), state_subpixel
}, WINED3D_GL_EXT_NONE
},
4987 { STATE_RENDER(WINED3D_RS_SUBPIXELX
), { STATE_RENDER(WINED3D_RS_SUBPIXELX
), state_subpixelx
}, WINED3D_GL_EXT_NONE
},
4988 { STATE_RENDER(WINED3D_RS_STIPPLEDALPHA
), { STATE_RENDER(WINED3D_RS_STIPPLEDALPHA
), state_stippledalpha
}, WINED3D_GL_EXT_NONE
},
4989 { STATE_RENDER(WINED3D_RS_STIPPLEENABLE
), { STATE_RENDER(WINED3D_RS_STIPPLEENABLE
), state_stippleenable
}, WINED3D_GL_EXT_NONE
},
4990 { STATE_RENDER(WINED3D_RS_MIPMAPLODBIAS
), { STATE_RENDER(WINED3D_RS_MIPMAPLODBIAS
), state_mipmaplodbias
}, WINED3D_GL_EXT_NONE
},
4991 { STATE_RENDER(WINED3D_RS_ANISOTROPY
), { STATE_RENDER(WINED3D_RS_ANISOTROPY
), state_anisotropy
}, WINED3D_GL_EXT_NONE
},
4992 { STATE_RENDER(WINED3D_RS_FLUSHBATCH
), { STATE_RENDER(WINED3D_RS_FLUSHBATCH
), state_flushbatch
}, WINED3D_GL_EXT_NONE
},
4993 { STATE_RENDER(WINED3D_RS_TRANSLUCENTSORTINDEPENDENT
),{ STATE_RENDER(WINED3D_RS_TRANSLUCENTSORTINDEPENDENT
),state_translucentsi
}, WINED3D_GL_EXT_NONE
},
4994 { STATE_RENDER(WINED3D_RS_STENCILENABLE
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), state_stencil
}, WINED3D_GL_EXT_NONE
},
4995 { STATE_RENDER(WINED3D_RS_STENCILFAIL
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4996 { STATE_RENDER(WINED3D_RS_STENCILZFAIL
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4997 { STATE_RENDER(WINED3D_RS_STENCILPASS
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4998 { STATE_RENDER(WINED3D_RS_STENCILFUNC
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
4999 { STATE_RENDER(WINED3D_RS_STENCILREF
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5000 { STATE_RENDER(WINED3D_RS_STENCILMASK
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5001 { STATE_RENDER(WINED3D_RS_STENCILWRITEMASK
), { STATE_RENDER(WINED3D_RS_STENCILWRITEMASK
), state_stencilwrite2s
}, EXT_STENCIL_TWO_SIDE
},
5002 { STATE_RENDER(WINED3D_RS_STENCILWRITEMASK
), { STATE_RENDER(WINED3D_RS_STENCILWRITEMASK
), state_stencilwrite
}, WINED3D_GL_EXT_NONE
},
5003 { STATE_RENDER(WINED3D_RS_TWOSIDEDSTENCILMODE
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5004 { STATE_RENDER(WINED3D_RS_CCW_STENCILFAIL
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5005 { STATE_RENDER(WINED3D_RS_CCW_STENCILZFAIL
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5006 { STATE_RENDER(WINED3D_RS_CCW_STENCILPASS
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5007 { STATE_RENDER(WINED3D_RS_CCW_STENCILFUNC
), { STATE_RENDER(WINED3D_RS_STENCILENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5008 { STATE_RENDER(WINED3D_RS_WRAP0
), { STATE_RENDER(WINED3D_RS_WRAP0
), state_wrap
}, WINED3D_GL_EXT_NONE
},
5009 { STATE_RENDER(WINED3D_RS_WRAP1
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5010 { STATE_RENDER(WINED3D_RS_WRAP2
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5011 { STATE_RENDER(WINED3D_RS_WRAP3
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5012 { STATE_RENDER(WINED3D_RS_WRAP4
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5013 { STATE_RENDER(WINED3D_RS_WRAP5
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5014 { STATE_RENDER(WINED3D_RS_WRAP6
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5015 { STATE_RENDER(WINED3D_RS_WRAP7
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5016 { STATE_RENDER(WINED3D_RS_WRAP8
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5017 { STATE_RENDER(WINED3D_RS_WRAP9
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5018 { STATE_RENDER(WINED3D_RS_WRAP10
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5019 { STATE_RENDER(WINED3D_RS_WRAP11
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5020 { STATE_RENDER(WINED3D_RS_WRAP12
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5021 { STATE_RENDER(WINED3D_RS_WRAP13
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5022 { STATE_RENDER(WINED3D_RS_WRAP14
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5023 { STATE_RENDER(WINED3D_RS_WRAP15
), { STATE_RENDER(WINED3D_RS_WRAP0
), NULL
}, WINED3D_GL_EXT_NONE
},
5024 { STATE_RENDER(WINED3D_RS_EXTENTS
), { STATE_RENDER(WINED3D_RS_EXTENTS
), state_extents
}, WINED3D_GL_EXT_NONE
},
5025 { STATE_RENDER(WINED3D_RS_COLORKEYBLENDENABLE
), { STATE_RENDER(WINED3D_RS_COLORKEYBLENDENABLE
), state_ckeyblend
}, WINED3D_GL_EXT_NONE
},
5026 { STATE_RENDER(WINED3D_RS_SOFTWAREVERTEXPROCESSING
), { STATE_RENDER(WINED3D_RS_SOFTWAREVERTEXPROCESSING
), state_swvp
}, WINED3D_GL_EXT_NONE
},
5027 { STATE_RENDER(WINED3D_RS_PATCHEDGESTYLE
), { STATE_RENDER(WINED3D_RS_PATCHEDGESTYLE
), state_patchedgestyle
}, WINED3D_GL_EXT_NONE
},
5028 { STATE_RENDER(WINED3D_RS_PATCHSEGMENTS
), { STATE_RENDER(WINED3D_RS_PATCHSEGMENTS
), state_patchsegments
}, WINED3D_GL_EXT_NONE
},
5029 { STATE_RENDER(WINED3D_RS_POSITIONDEGREE
), { STATE_RENDER(WINED3D_RS_POSITIONDEGREE
), state_positiondegree
}, WINED3D_GL_EXT_NONE
},
5030 { STATE_RENDER(WINED3D_RS_NORMALDEGREE
), { STATE_RENDER(WINED3D_RS_NORMALDEGREE
), state_normaldegree
}, WINED3D_GL_EXT_NONE
},
5031 { STATE_RENDER(WINED3D_RS_MINTESSELLATIONLEVEL
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
5032 { STATE_RENDER(WINED3D_RS_MAXTESSELLATIONLEVEL
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
5033 { STATE_RENDER(WINED3D_RS_ADAPTIVETESS_X
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
5034 { STATE_RENDER(WINED3D_RS_ADAPTIVETESS_Y
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
5035 { STATE_RENDER(WINED3D_RS_ADAPTIVETESS_Z
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
5036 { STATE_RENDER(WINED3D_RS_ADAPTIVETESS_W
), { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),NULL
}, WINED3D_GL_EXT_NONE
},
5037 { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),{ STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),state_nvdb
}, EXT_DEPTH_BOUNDS_TEST
},
5038 { STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),{ STATE_RENDER(WINED3D_RS_ENABLEADAPTIVETESSELLATION
),state_tessellation
}, WINED3D_GL_EXT_NONE
},
5039 { STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS
), { STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS
), state_msaa
}, ARB_MULTISAMPLE
},
5040 { STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS
), { STATE_RENDER(WINED3D_RS_MULTISAMPLEANTIALIAS
), state_msaa_w
}, WINED3D_GL_EXT_NONE
},
5041 { STATE_RENDER(WINED3D_RS_MULTISAMPLEMASK
), { STATE_RENDER(WINED3D_RS_MULTISAMPLEMASK
), state_multisampmask
}, WINED3D_GL_EXT_NONE
},
5042 { STATE_RENDER(WINED3D_RS_DEBUGMONITORTOKEN
), { STATE_RENDER(WINED3D_RS_DEBUGMONITORTOKEN
), state_debug_monitor
}, WINED3D_GL_EXT_NONE
},
5043 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE
), state_colorwrite0
}, EXT_DRAW_BUFFERS2
},
5044 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE
), state_colorwrite
}, WINED3D_GL_EXT_NONE
},
5045 { STATE_RENDER(WINED3D_RS_BLENDOP
), { STATE_RENDER(WINED3D_RS_BLENDOP
), state_blendop
}, EXT_BLEND_MINMAX
},
5046 { STATE_RENDER(WINED3D_RS_BLENDOP
), { STATE_RENDER(WINED3D_RS_BLENDOP
), state_blendop_w
}, WINED3D_GL_EXT_NONE
},
5047 { STATE_RENDER(WINED3D_RS_SCISSORTESTENABLE
), { STATE_RENDER(WINED3D_RS_SCISSORTESTENABLE
), state_scissor
}, WINED3D_GL_EXT_NONE
},
5048 { STATE_RENDER(WINED3D_RS_SLOPESCALEDEPTHBIAS
), { STATE_RENDER(WINED3D_RS_DEPTHBIAS
), NULL
}, WINED3D_GL_EXT_NONE
},
5049 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1
), state_colorwrite1
}, EXT_DRAW_BUFFERS2
},
5050 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5051 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2
), state_colorwrite2
}, EXT_DRAW_BUFFERS2
},
5052 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5053 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3
), state_colorwrite3
}, EXT_DRAW_BUFFERS2
},
5054 { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3
), { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5055 { STATE_RENDER(WINED3D_RS_BLENDFACTOR
), { STATE_RENDER(WINED3D_RS_BLENDFACTOR
), state_blendfactor
}, EXT_BLEND_COLOR
},
5056 { STATE_RENDER(WINED3D_RS_BLENDFACTOR
), { STATE_RENDER(WINED3D_RS_BLENDFACTOR
), state_blendfactor_w
}, WINED3D_GL_EXT_NONE
},
5057 { STATE_RENDER(WINED3D_RS_DEPTHBIAS
), { STATE_RENDER(WINED3D_RS_DEPTHBIAS
), state_depthbias
}, WINED3D_GL_EXT_NONE
},
5058 { STATE_RENDER(WINED3D_RS_ZVISIBLE
), { STATE_RENDER(WINED3D_RS_ZVISIBLE
), state_zvisible
}, WINED3D_GL_EXT_NONE
},
5060 { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler
}, WINED3D_GL_EXT_NONE
},
5061 { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler
}, WINED3D_GL_EXT_NONE
},
5062 { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler
}, WINED3D_GL_EXT_NONE
},
5063 { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler
}, WINED3D_GL_EXT_NONE
},
5064 { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler
}, WINED3D_GL_EXT_NONE
},
5065 { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler
}, WINED3D_GL_EXT_NONE
},
5066 { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler
}, WINED3D_GL_EXT_NONE
},
5067 { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler
}, WINED3D_GL_EXT_NONE
},
5068 { STATE_SAMPLER(8), { STATE_SAMPLER(8), sampler
}, WINED3D_GL_EXT_NONE
},
5069 { STATE_SAMPLER(9), { STATE_SAMPLER(9), sampler
}, WINED3D_GL_EXT_NONE
},
5070 { STATE_SAMPLER(10), { STATE_SAMPLER(10), sampler
}, WINED3D_GL_EXT_NONE
},
5071 { STATE_SAMPLER(11), { STATE_SAMPLER(11), sampler
}, WINED3D_GL_EXT_NONE
},
5072 { STATE_SAMPLER(12), { STATE_SAMPLER(12), sampler
}, WINED3D_GL_EXT_NONE
},
5073 { STATE_SAMPLER(13), { STATE_SAMPLER(13), sampler
}, WINED3D_GL_EXT_NONE
},
5074 { STATE_SAMPLER(14), { STATE_SAMPLER(14), sampler
}, WINED3D_GL_EXT_NONE
},
5075 { STATE_SAMPLER(15), { STATE_SAMPLER(15), sampler
}, WINED3D_GL_EXT_NONE
},
5076 { STATE_SAMPLER(16), /* Vertex sampler 0 */ { STATE_SAMPLER(16), sampler
}, WINED3D_GL_EXT_NONE
},
5077 { STATE_SAMPLER(17), /* Vertex sampler 1 */ { STATE_SAMPLER(17), sampler
}, WINED3D_GL_EXT_NONE
},
5078 { STATE_SAMPLER(18), /* Vertex sampler 2 */ { STATE_SAMPLER(18), sampler
}, WINED3D_GL_EXT_NONE
},
5079 { STATE_SAMPLER(19), /* Vertex sampler 3 */ { STATE_SAMPLER(19), sampler
}, WINED3D_GL_EXT_NONE
},
5080 { STATE_BASEVERTEXINDEX
, { STATE_BASEVERTEXINDEX
, state_nop
, }, ARB_DRAW_ELEMENTS_BASE_VERTEX
},
5081 { STATE_BASEVERTEXINDEX
, { STATE_STREAMSRC
, NULL
, }, WINED3D_GL_EXT_NONE
},
5082 { STATE_FRAMEBUFFER
, { STATE_FRAMEBUFFER
, context_state_fb
}, WINED3D_GL_EXT_NONE
},
5083 { STATE_PIXELSHADER
, { STATE_PIXELSHADER
, context_state_drawbuf
},WINED3D_GL_EXT_NONE
},
5084 {0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE
},
5087 const struct StateEntryTemplate ffp_vertexstate_template
[] = {
5088 { STATE_VDECL
, { STATE_VDECL
, vertexdeclaration
}, WINED3D_GL_EXT_NONE
},
5089 { STATE_VSHADER
, { STATE_VDECL
, NULL
}, WINED3D_GL_EXT_NONE
},
5090 { STATE_MATERIAL
, { STATE_RENDER(WINED3D_RS_SPECULARENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5091 { STATE_RENDER(WINED3D_RS_SPECULARENABLE
), { STATE_RENDER(WINED3D_RS_SPECULARENABLE
), state_specularenable
}, WINED3D_GL_EXT_NONE
},
5093 { STATE_CLIPPLANE(0), { STATE_CLIPPLANE(0), clipplane
}, WINED3D_GL_EXT_NONE
},
5094 { STATE_CLIPPLANE(1), { STATE_CLIPPLANE(1), clipplane
}, WINED3D_GL_EXT_NONE
},
5095 { STATE_CLIPPLANE(2), { STATE_CLIPPLANE(2), clipplane
}, WINED3D_GL_EXT_NONE
},
5096 { STATE_CLIPPLANE(3), { STATE_CLIPPLANE(3), clipplane
}, WINED3D_GL_EXT_NONE
},
5097 { STATE_CLIPPLANE(4), { STATE_CLIPPLANE(4), clipplane
}, WINED3D_GL_EXT_NONE
},
5098 { STATE_CLIPPLANE(5), { STATE_CLIPPLANE(5), clipplane
}, WINED3D_GL_EXT_NONE
},
5099 { STATE_CLIPPLANE(6), { STATE_CLIPPLANE(6), clipplane
}, WINED3D_GL_EXT_NONE
},
5100 { STATE_CLIPPLANE(7), { STATE_CLIPPLANE(7), clipplane
}, WINED3D_GL_EXT_NONE
},
5101 { STATE_CLIPPLANE(8), { STATE_CLIPPLANE(8), clipplane
}, WINED3D_GL_EXT_NONE
},
5102 { STATE_CLIPPLANE(9), { STATE_CLIPPLANE(9), clipplane
}, WINED3D_GL_EXT_NONE
},
5103 { STATE_CLIPPLANE(10), { STATE_CLIPPLANE(10), clipplane
}, WINED3D_GL_EXT_NONE
},
5104 { STATE_CLIPPLANE(11), { STATE_CLIPPLANE(11), clipplane
}, WINED3D_GL_EXT_NONE
},
5105 { STATE_CLIPPLANE(12), { STATE_CLIPPLANE(12), clipplane
}, WINED3D_GL_EXT_NONE
},
5106 { STATE_CLIPPLANE(13), { STATE_CLIPPLANE(13), clipplane
}, WINED3D_GL_EXT_NONE
},
5107 { STATE_CLIPPLANE(14), { STATE_CLIPPLANE(14), clipplane
}, WINED3D_GL_EXT_NONE
},
5108 { STATE_CLIPPLANE(15), { STATE_CLIPPLANE(15), clipplane
}, WINED3D_GL_EXT_NONE
},
5109 { STATE_CLIPPLANE(16), { STATE_CLIPPLANE(16), clipplane
}, WINED3D_GL_EXT_NONE
},
5110 { STATE_CLIPPLANE(17), { STATE_CLIPPLANE(17), clipplane
}, WINED3D_GL_EXT_NONE
},
5111 { STATE_CLIPPLANE(18), { STATE_CLIPPLANE(18), clipplane
}, WINED3D_GL_EXT_NONE
},
5112 { STATE_CLIPPLANE(19), { STATE_CLIPPLANE(19), clipplane
}, WINED3D_GL_EXT_NONE
},
5113 { STATE_CLIPPLANE(20), { STATE_CLIPPLANE(20), clipplane
}, WINED3D_GL_EXT_NONE
},
5114 { STATE_CLIPPLANE(21), { STATE_CLIPPLANE(21), clipplane
}, WINED3D_GL_EXT_NONE
},
5115 { STATE_CLIPPLANE(22), { STATE_CLIPPLANE(22), clipplane
}, WINED3D_GL_EXT_NONE
},
5116 { STATE_CLIPPLANE(23), { STATE_CLIPPLANE(23), clipplane
}, WINED3D_GL_EXT_NONE
},
5117 { STATE_CLIPPLANE(24), { STATE_CLIPPLANE(24), clipplane
}, WINED3D_GL_EXT_NONE
},
5118 { STATE_CLIPPLANE(25), { STATE_CLIPPLANE(25), clipplane
}, WINED3D_GL_EXT_NONE
},
5119 { STATE_CLIPPLANE(26), { STATE_CLIPPLANE(26), clipplane
}, WINED3D_GL_EXT_NONE
},
5120 { STATE_CLIPPLANE(27), { STATE_CLIPPLANE(27), clipplane
}, WINED3D_GL_EXT_NONE
},
5121 { STATE_CLIPPLANE(28), { STATE_CLIPPLANE(28), clipplane
}, WINED3D_GL_EXT_NONE
},
5122 { STATE_CLIPPLANE(29), { STATE_CLIPPLANE(29), clipplane
}, WINED3D_GL_EXT_NONE
},
5123 { STATE_CLIPPLANE(30), { STATE_CLIPPLANE(30), clipplane
}, WINED3D_GL_EXT_NONE
},
5124 { STATE_CLIPPLANE(31), { STATE_CLIPPLANE(31), clipplane
}, WINED3D_GL_EXT_NONE
},
5126 { STATE_ACTIVELIGHT(0), { STATE_ACTIVELIGHT(0), light
}, WINED3D_GL_EXT_NONE
},
5127 { STATE_ACTIVELIGHT(1), { STATE_ACTIVELIGHT(1), light
}, WINED3D_GL_EXT_NONE
},
5128 { STATE_ACTIVELIGHT(2), { STATE_ACTIVELIGHT(2), light
}, WINED3D_GL_EXT_NONE
},
5129 { STATE_ACTIVELIGHT(3), { STATE_ACTIVELIGHT(3), light
}, WINED3D_GL_EXT_NONE
},
5130 { STATE_ACTIVELIGHT(4), { STATE_ACTIVELIGHT(4), light
}, WINED3D_GL_EXT_NONE
},
5131 { STATE_ACTIVELIGHT(5), { STATE_ACTIVELIGHT(5), light
}, WINED3D_GL_EXT_NONE
},
5132 { STATE_ACTIVELIGHT(6), { STATE_ACTIVELIGHT(6), light
}, WINED3D_GL_EXT_NONE
},
5133 { STATE_ACTIVELIGHT(7), { STATE_ACTIVELIGHT(7), light
}, WINED3D_GL_EXT_NONE
},
5135 { STATE_VIEWPORT
, { STATE_VIEWPORT
, viewport_vertexpart
}, WINED3D_GL_EXT_NONE
},
5136 /* Transform states follow */
5137 { STATE_TRANSFORM(WINED3DTS_VIEW
), { STATE_TRANSFORM(WINED3DTS_VIEW
), transform_view
}, WINED3D_GL_EXT_NONE
},
5138 { STATE_TRANSFORM(WINED3DTS_PROJECTION
), { STATE_TRANSFORM(WINED3DTS_PROJECTION
), transform_projection
}, WINED3D_GL_EXT_NONE
},
5139 { STATE_TRANSFORM(WINED3DTS_TEXTURE0
), { STATE_TEXTURESTAGE(0,WINED3DTSS_TEXTURETRANSFORMFLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5140 { STATE_TRANSFORM(WINED3DTS_TEXTURE1
), { STATE_TEXTURESTAGE(1,WINED3DTSS_TEXTURETRANSFORMFLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5141 { STATE_TRANSFORM(WINED3DTS_TEXTURE2
), { STATE_TEXTURESTAGE(2,WINED3DTSS_TEXTURETRANSFORMFLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5142 { STATE_TRANSFORM(WINED3DTS_TEXTURE3
), { STATE_TEXTURESTAGE(3,WINED3DTSS_TEXTURETRANSFORMFLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5143 { STATE_TRANSFORM(WINED3DTS_TEXTURE4
), { STATE_TEXTURESTAGE(4,WINED3DTSS_TEXTURETRANSFORMFLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5144 { STATE_TRANSFORM(WINED3DTS_TEXTURE5
), { STATE_TEXTURESTAGE(5,WINED3DTSS_TEXTURETRANSFORMFLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5145 { STATE_TRANSFORM(WINED3DTS_TEXTURE6
), { STATE_TEXTURESTAGE(6,WINED3DTSS_TEXTURETRANSFORMFLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5146 { STATE_TRANSFORM(WINED3DTS_TEXTURE7
), { STATE_TEXTURESTAGE(7,WINED3DTSS_TEXTURETRANSFORMFLAGS
), NULL
}, WINED3D_GL_EXT_NONE
},
5147 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 0)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 0)), transform_world
}, WINED3D_GL_EXT_NONE
},
5148 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 1)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 1)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5149 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 2)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 2)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5150 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 3)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 3)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5151 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 4)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 4)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5152 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 5)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 5)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5153 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 6)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 6)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5154 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 7)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 7)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5155 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 8)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 8)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5156 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 9)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 9)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5157 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 10)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 10)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5158 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 11)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 11)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5159 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 12)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 12)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5160 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 13)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 13)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5161 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 14)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 14)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5162 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 15)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 15)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5163 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 16)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 16)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5164 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 17)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 17)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5165 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 18)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 18)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5166 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 19)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 19)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5167 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 20)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 20)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5168 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 21)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 21)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5169 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 22)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 22)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5170 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 23)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 23)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5171 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 24)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 24)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5172 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 25)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 25)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5173 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 26)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 26)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5174 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 27)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 27)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5175 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 28)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 28)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5176 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 29)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 29)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5177 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 30)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 30)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5178 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 31)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 31)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5179 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 32)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 32)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5180 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 33)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 33)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5181 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 34)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 34)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5182 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 35)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 35)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5183 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 36)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 36)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5184 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 37)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 37)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5185 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 38)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 38)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5186 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 39)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 39)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5187 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 40)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 40)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5188 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 41)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 41)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5189 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 42)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 42)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5190 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 43)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 43)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5191 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 44)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 44)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5192 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 45)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 45)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5193 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 46)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 46)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5194 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 47)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 47)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5195 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 48)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 48)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5196 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 49)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 49)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5197 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 50)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 50)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5198 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 51)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 51)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5199 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 52)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 52)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5200 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 53)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 53)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5201 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 54)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 54)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5202 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 55)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 55)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5203 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 56)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 56)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5204 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 57)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 57)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5205 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 58)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 58)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5206 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 59)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 59)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5207 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 60)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 60)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5208 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 61)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 61)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5209 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 62)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 62)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5210 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 63)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 63)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5211 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 64)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 64)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5212 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 65)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 65)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5213 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 66)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 66)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5214 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 67)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 67)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5215 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 68)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 68)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5216 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 69)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 69)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5217 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 70)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 70)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5218 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 71)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 71)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5219 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 72)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 72)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5220 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 73)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 73)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5221 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 74)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 74)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5222 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 75)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 75)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5223 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 76)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 76)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5224 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 77)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 77)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5225 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 78)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 78)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5226 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 79)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 79)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5227 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 80)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 80)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5228 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 81)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 81)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5229 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 82)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 82)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5230 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 83)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 83)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5231 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 84)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 84)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5232 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 85)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 85)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5233 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 86)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 86)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5234 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 87)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 87)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5235 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 88)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 88)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5236 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 89)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 89)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5237 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 90)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 90)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5238 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 91)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 91)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5239 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 92)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 92)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5240 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 93)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 93)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5241 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 94)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 94)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5242 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 95)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 95)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5243 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 96)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 96)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5244 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 97)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 97)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5245 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 98)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 98)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5246 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 99)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX( 99)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5247 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(100)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(100)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5248 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(101)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(101)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5249 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(102)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(102)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5250 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(103)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(103)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5251 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(104)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(104)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5252 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(105)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(105)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5253 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(106)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(106)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5254 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(107)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(107)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5255 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(108)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(108)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5256 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(109)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(109)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5257 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(110)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(110)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5258 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(111)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(111)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5259 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(112)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(112)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5260 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(113)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(113)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5261 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(114)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(114)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5262 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(115)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(115)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5263 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(116)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(116)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5264 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(117)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(117)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5265 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(118)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(118)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5266 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(119)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(119)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5267 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(120)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(120)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5268 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(121)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(121)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5269 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(122)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(122)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5270 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(123)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(123)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5271 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(124)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(124)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5272 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(125)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(125)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5273 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(126)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(126)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5274 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(127)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(127)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5275 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(128)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(128)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5276 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(129)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(129)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5277 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(130)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(130)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5278 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(131)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(131)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5279 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(132)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(132)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5280 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(133)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(133)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5281 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(134)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(134)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5282 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(135)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(135)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5283 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(136)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(136)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5284 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(137)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(137)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5285 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(138)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(138)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5286 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(139)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(139)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5287 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(140)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(140)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5288 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(141)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(141)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5289 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(142)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(142)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5290 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(143)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(143)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5291 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(144)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(144)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5292 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(145)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(145)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5293 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(146)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(146)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5294 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(147)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(147)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5295 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(148)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(148)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5296 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(149)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(149)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5297 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(150)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(150)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5298 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(151)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(151)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5299 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(152)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(152)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5300 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(153)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(153)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5301 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(154)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(154)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5302 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(155)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(155)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5303 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(156)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(156)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5304 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(157)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(157)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5305 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(158)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(158)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5306 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(159)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(159)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5307 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(160)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(160)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5308 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(161)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(161)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5309 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(162)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(162)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5310 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(163)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(163)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5311 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(164)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(164)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5312 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(165)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(165)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5313 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(166)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(166)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5314 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(167)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(167)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5315 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(168)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(168)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5316 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(169)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(169)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5317 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(170)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(170)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5318 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(171)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(171)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5319 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(172)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(172)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5320 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(173)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(173)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5321 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(174)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(174)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5322 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(175)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(175)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5323 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(176)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(176)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5324 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(177)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(177)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5325 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(178)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(178)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5326 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(179)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(179)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5327 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(180)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(180)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5328 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(181)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(181)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5329 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(182)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(182)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5330 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(183)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(183)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5331 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(184)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(184)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5332 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(185)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(185)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5333 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(186)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(186)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5334 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(187)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(187)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5335 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(188)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(188)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5336 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(189)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(189)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5337 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(190)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(190)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5338 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(191)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(191)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5339 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(192)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(192)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5340 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(193)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(193)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5341 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(194)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(194)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5342 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(195)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(195)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5343 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(196)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(196)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5344 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(197)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(197)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5345 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(198)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(198)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5346 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(199)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(199)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5347 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(200)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(200)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5348 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(201)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(201)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5349 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(202)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(202)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5350 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(203)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(203)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5351 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(204)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(204)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5352 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(205)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(205)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5353 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(206)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(206)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5354 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(207)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(207)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5355 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(208)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(208)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5356 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(209)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(209)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5357 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(210)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(210)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5358 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(211)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(211)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5359 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(212)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(212)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5360 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(213)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(213)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5361 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(214)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(214)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5362 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(215)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(215)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5363 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(216)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(216)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5364 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(217)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(217)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5365 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(218)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(218)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5366 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(219)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(219)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5367 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(220)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(220)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5368 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(221)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(221)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5369 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(222)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(222)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5370 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(223)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(223)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5371 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(224)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(224)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5372 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(225)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(225)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5373 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(226)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(226)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5374 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(227)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(227)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5375 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(228)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(228)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5376 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(229)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(229)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5377 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(230)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(230)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5378 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(231)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(231)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5379 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(232)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(232)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5380 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(233)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(233)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5381 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(234)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(234)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5382 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(235)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(235)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5383 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(236)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(236)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5384 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(237)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(237)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5385 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(238)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(238)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5386 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(239)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(239)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5387 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(240)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(240)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5388 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(241)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(241)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5389 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(242)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(242)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5390 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(243)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(243)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5391 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(244)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(244)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5392 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(245)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(245)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5393 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(246)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(246)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5394 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(247)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(247)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5395 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(248)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(248)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5396 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(249)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(249)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5397 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(250)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(250)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5398 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(251)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(251)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5399 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(252)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(252)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5400 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(253)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(253)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5401 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(254)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(254)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5402 { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(255)), { STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(255)), transform_worldex
}, WINED3D_GL_EXT_NONE
},
5403 { STATE_TEXTURESTAGE(0,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(0,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, WINED3D_GL_EXT_NONE
},
5404 { STATE_TEXTURESTAGE(1,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(1,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, WINED3D_GL_EXT_NONE
},
5405 { STATE_TEXTURESTAGE(2,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(2,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, WINED3D_GL_EXT_NONE
},
5406 { STATE_TEXTURESTAGE(3,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(3,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, WINED3D_GL_EXT_NONE
},
5407 { STATE_TEXTURESTAGE(4,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(4,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, WINED3D_GL_EXT_NONE
},
5408 { STATE_TEXTURESTAGE(5,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(5,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, WINED3D_GL_EXT_NONE
},
5409 { STATE_TEXTURESTAGE(6,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(6,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, WINED3D_GL_EXT_NONE
},
5410 { STATE_TEXTURESTAGE(7,WINED3DTSS_TEXTURETRANSFORMFLAGS
),{STATE_TEXTURESTAGE(7,WINED3DTSS_TEXTURETRANSFORMFLAGS
),transform_texture
}, WINED3D_GL_EXT_NONE
},
5411 { STATE_TEXTURESTAGE(0, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(0, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5412 { STATE_TEXTURESTAGE(1, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(1, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5413 { STATE_TEXTURESTAGE(2, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(2, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5414 { STATE_TEXTURESTAGE(3, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(3, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5415 { STATE_TEXTURESTAGE(4, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(4, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5416 { STATE_TEXTURESTAGE(5, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(5, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5417 { STATE_TEXTURESTAGE(6, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(6, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5418 { STATE_TEXTURESTAGE(7, WINED3DTSS_TEXCOORDINDEX
), { STATE_TEXTURESTAGE(7, WINED3DTSS_TEXCOORDINDEX
), tex_coordindex
}, WINED3D_GL_EXT_NONE
},
5420 { STATE_RENDER(WINED3D_RS_FOGENABLE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), state_fog_vertexpart
}, WINED3D_GL_EXT_NONE
},
5421 { STATE_RENDER(WINED3D_RS_FOGTABLEMODE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5422 { STATE_RENDER(WINED3D_RS_FOGVERTEXMODE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5423 { STATE_RENDER(WINED3D_RS_RANGEFOGENABLE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5424 { STATE_RENDER(WINED3D_RS_CLIPPING
), { STATE_RENDER(WINED3D_RS_CLIPPING
), state_clipping
}, WINED3D_GL_EXT_NONE
},
5425 { STATE_RENDER(WINED3D_RS_CLIPPLANEENABLE
), { STATE_RENDER(WINED3D_RS_CLIPPING
), NULL
}, WINED3D_GL_EXT_NONE
},
5426 { STATE_RENDER(WINED3D_RS_LIGHTING
), { STATE_RENDER(WINED3D_RS_LIGHTING
), state_lighting
}, WINED3D_GL_EXT_NONE
},
5427 { STATE_RENDER(WINED3D_RS_AMBIENT
), { STATE_RENDER(WINED3D_RS_AMBIENT
), state_ambient
}, WINED3D_GL_EXT_NONE
},
5428 { STATE_RENDER(WINED3D_RS_COLORVERTEX
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), state_colormat
}, WINED3D_GL_EXT_NONE
},
5429 { STATE_RENDER(WINED3D_RS_LOCALVIEWER
), { STATE_RENDER(WINED3D_RS_LOCALVIEWER
), state_localviewer
}, WINED3D_GL_EXT_NONE
},
5430 { STATE_RENDER(WINED3D_RS_NORMALIZENORMALS
), { STATE_RENDER(WINED3D_RS_NORMALIZENORMALS
), state_normalize
}, WINED3D_GL_EXT_NONE
},
5431 { STATE_RENDER(WINED3D_RS_DIFFUSEMATERIALSOURCE
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), NULL
}, WINED3D_GL_EXT_NONE
},
5432 { STATE_RENDER(WINED3D_RS_SPECULARMATERIALSOURCE
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), NULL
}, WINED3D_GL_EXT_NONE
},
5433 { STATE_RENDER(WINED3D_RS_AMBIENTMATERIALSOURCE
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), NULL
}, WINED3D_GL_EXT_NONE
},
5434 { STATE_RENDER(WINED3D_RS_EMISSIVEMATERIALSOURCE
), { STATE_RENDER(WINED3D_RS_COLORVERTEX
), NULL
}, WINED3D_GL_EXT_NONE
},
5435 { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), state_vertexblend
}, ARB_VERTEX_BLEND
},
5436 { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), state_vertexblend_w
}, WINED3D_GL_EXT_NONE
},
5437 { STATE_RENDER(WINED3D_RS_POINTSIZE
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5438 { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), state_psizemin_arb
}, ARB_POINT_PARAMETERS
},
5439 { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), state_psizemin_ext
}, EXT_POINT_PARAMETERS
},
5440 { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), state_psizemin_w
}, WINED3D_GL_EXT_NONE
},
5441 { STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE
), { STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE
), state_pointsprite
}, ARB_POINT_SPRITE
},
5442 { STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE
), { STATE_RENDER(WINED3D_RS_POINTSPRITEENABLE
), state_pointsprite_w
}, WINED3D_GL_EXT_NONE
},
5443 { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), state_pscale
}, WINED3D_GL_EXT_NONE
},
5444 { STATE_RENDER(WINED3D_RS_POINTSCALE_A
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5445 { STATE_RENDER(WINED3D_RS_POINTSCALE_B
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5446 { STATE_RENDER(WINED3D_RS_POINTSCALE_C
), { STATE_RENDER(WINED3D_RS_POINTSCALEENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5447 { STATE_RENDER(WINED3D_RS_POINTSIZE_MAX
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), NULL
}, ARB_POINT_PARAMETERS
},
5448 { STATE_RENDER(WINED3D_RS_POINTSIZE_MAX
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), NULL
}, EXT_POINT_PARAMETERS
},
5449 { STATE_RENDER(WINED3D_RS_POINTSIZE_MAX
), { STATE_RENDER(WINED3D_RS_POINTSIZE_MIN
), NULL
}, WINED3D_GL_EXT_NONE
},
5450 { STATE_RENDER(WINED3D_RS_TWEENFACTOR
), { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), NULL
}, WINED3D_GL_EXT_NONE
},
5451 { STATE_RENDER(WINED3D_RS_INDEXEDVERTEXBLENDENABLE
), { STATE_RENDER(WINED3D_RS_VERTEXBLEND
), NULL
}, WINED3D_GL_EXT_NONE
},
5453 /* Samplers for NP2 texture matrix adjustions. They are not needed if GL_ARB_texture_non_power_of_two is supported,
5454 * so register a NULL state handler in that case to get the vertex part of sampler() skipped(VTF is handled in the misc states.
5455 * otherwise, register sampler_texmatrix, which takes care of updating the texture matrix
5457 { STATE_SAMPLER(0), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5458 { STATE_SAMPLER(0), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5459 { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5460 { STATE_SAMPLER(1), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5461 { STATE_SAMPLER(1), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5462 { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5463 { STATE_SAMPLER(2), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5464 { STATE_SAMPLER(2), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5465 { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5466 { STATE_SAMPLER(3), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5467 { STATE_SAMPLER(3), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5468 { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5469 { STATE_SAMPLER(4), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5470 { STATE_SAMPLER(4), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5471 { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5472 { STATE_SAMPLER(5), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5473 { STATE_SAMPLER(5), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5474 { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5475 { STATE_SAMPLER(6), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5476 { STATE_SAMPLER(6), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5477 { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5478 { STATE_SAMPLER(7), { 0, NULL
}, ARB_TEXTURE_NON_POWER_OF_TWO
},
5479 { STATE_SAMPLER(7), { 0, NULL
}, WINED3D_GL_NORMALIZED_TEXRECT
},
5480 { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texmatrix
}, WINED3D_GL_EXT_NONE
},
5481 {0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE
},
5484 static const struct StateEntryTemplate ffp_fragmentstate_template
[] = {
5485 { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5486 { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5487 { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5488 { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5489 { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5490 { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5491 { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5492 { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5493 { STATE_TEXTURESTAGE(0, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5494 { STATE_TEXTURESTAGE(0, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5495 { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5496 { STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5497 { STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5498 { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5499 { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5500 { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5501 { STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5502 { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5503 { STATE_TEXTURESTAGE(1, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5504 { STATE_TEXTURESTAGE(1, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5505 { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5506 { STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5507 { STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5508 { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5509 { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5510 { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5511 { STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5512 { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5513 { STATE_TEXTURESTAGE(2, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5514 { STATE_TEXTURESTAGE(2, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5515 { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5516 { STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5517 { STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5518 { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5519 { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5520 { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5521 { STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5522 { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5523 { STATE_TEXTURESTAGE(3, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5524 { STATE_TEXTURESTAGE(3, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5525 { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5526 { STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5527 { STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5528 { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5529 { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5530 { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5531 { STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5532 { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5533 { STATE_TEXTURESTAGE(4, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5534 { STATE_TEXTURESTAGE(4, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5535 { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5536 { STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5537 { STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5538 { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5539 { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5540 { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5541 { STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5542 { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5543 { STATE_TEXTURESTAGE(5, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5544 { STATE_TEXTURESTAGE(5, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5545 { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5546 { STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5547 { STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5548 { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5549 { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5550 { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5551 { STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5552 { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5553 { STATE_TEXTURESTAGE(6, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5554 { STATE_TEXTURESTAGE(6, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5555 { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP
), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP
), tex_colorop
}, WINED3D_GL_EXT_NONE
},
5556 { STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG1
), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5557 { STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG2
), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5558 { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP
), { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP
), tex_alphaop
}, WINED3D_GL_EXT_NONE
},
5559 { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG1
), { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5560 { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG2
), { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5561 { STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG0
), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5562 { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG0
), { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP
), NULL
}, WINED3D_GL_EXT_NONE
},
5563 { STATE_TEXTURESTAGE(7, WINED3DTSS_RESULTARG
), { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP
), NULL
}, WINED3D_GL_EXT_NONE
},
5564 { STATE_TEXTURESTAGE(7, WINED3DTSS_CONSTANT
), { 0 /* As long as we don't support D3DTA_CONSTANT */, NULL
}, WINED3D_GL_EXT_NONE
},
5565 { STATE_PIXELSHADER
, { STATE_PIXELSHADER
, apply_pixelshader
}, WINED3D_GL_EXT_NONE
},
5566 { STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE
), { STATE_PIXELSHADER
, NULL
}, WINED3D_GL_EXT_NONE
},
5567 { STATE_RENDER(WINED3D_RS_TEXTUREFACTOR
), { STATE_RENDER(WINED3D_RS_TEXTUREFACTOR
), state_texfactor
}, WINED3D_GL_EXT_NONE
},
5568 { STATE_RENDER(WINED3D_RS_FOGCOLOR
), { STATE_RENDER(WINED3D_RS_FOGCOLOR
), state_fogcolor
}, WINED3D_GL_EXT_NONE
},
5569 { STATE_RENDER(WINED3D_RS_FOGDENSITY
), { STATE_RENDER(WINED3D_RS_FOGDENSITY
), state_fogdensity
}, WINED3D_GL_EXT_NONE
},
5570 { STATE_RENDER(WINED3D_RS_FOGENABLE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), state_fog_fragpart
}, WINED3D_GL_EXT_NONE
},
5571 { STATE_RENDER(WINED3D_RS_FOGTABLEMODE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5572 { STATE_RENDER(WINED3D_RS_FOGVERTEXMODE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
5573 { STATE_RENDER(WINED3D_RS_FOGSTART
), { STATE_RENDER(WINED3D_RS_FOGSTART
), state_fogstartend
}, WINED3D_GL_EXT_NONE
},
5574 { STATE_RENDER(WINED3D_RS_FOGEND
), { STATE_RENDER(WINED3D_RS_FOGSTART
), NULL
}, WINED3D_GL_EXT_NONE
},
5575 { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5576 { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5577 { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5578 { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5579 { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5580 { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5581 { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5582 { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
5583 {0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE
},
5586 /* Context activation and GL locking are done by the caller. */
5587 static void ffp_enable(BOOL enable
) {}
5589 static void ffp_fragment_get_caps(const struct wined3d_gl_info
*gl_info
, struct fragment_caps
*caps
)
5591 caps
->PrimitiveMiscCaps
= 0;
5592 caps
->TextureOpCaps
= WINED3DTEXOPCAPS_ADD
5593 | WINED3DTEXOPCAPS_ADDSIGNED
5594 | WINED3DTEXOPCAPS_ADDSIGNED2X
5595 | WINED3DTEXOPCAPS_MODULATE
5596 | WINED3DTEXOPCAPS_MODULATE2X
5597 | WINED3DTEXOPCAPS_MODULATE4X
5598 | WINED3DTEXOPCAPS_SELECTARG1
5599 | WINED3DTEXOPCAPS_SELECTARG2
5600 | WINED3DTEXOPCAPS_DISABLE
;
5602 if (gl_info
->supported
[ARB_TEXTURE_ENV_COMBINE
]
5603 || gl_info
->supported
[EXT_TEXTURE_ENV_COMBINE
]
5604 || gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
5606 caps
->TextureOpCaps
|= WINED3DTEXOPCAPS_BLENDDIFFUSEALPHA
5607 | WINED3DTEXOPCAPS_BLENDTEXTUREALPHA
5608 | WINED3DTEXOPCAPS_BLENDFACTORALPHA
5609 | WINED3DTEXOPCAPS_BLENDCURRENTALPHA
5610 | WINED3DTEXOPCAPS_LERP
5611 | WINED3DTEXOPCAPS_SUBTRACT
;
5613 if (gl_info
->supported
[ATI_TEXTURE_ENV_COMBINE3
]
5614 || gl_info
->supported
[NV_TEXTURE_ENV_COMBINE4
])
5616 caps
->TextureOpCaps
|= WINED3DTEXOPCAPS_ADDSMOOTH
5617 | WINED3DTEXOPCAPS_MULTIPLYADD
5618 | WINED3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR
5619 | WINED3DTEXOPCAPS_MODULATECOLOR_ADDALPHA
5620 | WINED3DTEXOPCAPS_BLENDTEXTUREALPHAPM
;
5622 if (gl_info
->supported
[ARB_TEXTURE_ENV_DOT3
])
5623 caps
->TextureOpCaps
|= WINED3DTEXOPCAPS_DOTPRODUCT3
;
5625 caps
->MaxTextureBlendStages
= gl_info
->limits
.textures
;
5626 caps
->MaxSimultaneousTextures
= gl_info
->limits
.textures
;
5629 static HRESULT
ffp_fragment_alloc(struct wined3d_device
*device
) { return WINED3D_OK
; }
5630 static void ffp_fragment_free(struct wined3d_device
*device
) {}
5631 static BOOL
ffp_color_fixup_supported(struct color_fixup_desc fixup
)
5635 TRACE("Checking support for fixup:\n");
5636 dump_color_fixup_desc(fixup
);
5639 /* We only support identity conversions. */
5640 if (is_identity_fixup(fixup
))
5646 TRACE("[FAILED]\n");
5650 const struct fragment_pipeline ffp_fragment_pipeline
= {
5652 ffp_fragment_get_caps
,
5655 ffp_color_fixup_supported
,
5656 ffp_fragmentstate_template
,
5657 FALSE
/* we cannot disable projected textures. The vertex pipe has to do it */
5660 static unsigned int num_handlers(const APPLYSTATEFUNC
*funcs
)
5663 for(i
= 0; funcs
[i
]; i
++);
5667 static void multistate_apply_2(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
5669 context
->swapchain
->device
->multistate_funcs
[state_id
][0](context
, state
, state_id
);
5670 context
->swapchain
->device
->multistate_funcs
[state_id
][1](context
, state
, state_id
);
5673 static void multistate_apply_3(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
5675 context
->swapchain
->device
->multistate_funcs
[state_id
][0](context
, state
, state_id
);
5676 context
->swapchain
->device
->multistate_funcs
[state_id
][1](context
, state
, state_id
);
5677 context
->swapchain
->device
->multistate_funcs
[state_id
][2](context
, state
, state_id
);
5680 static void prune_invalid_states(struct StateEntry
*state_table
, const struct wined3d_gl_info
*gl_info
)
5682 unsigned int start
, last
, i
;
5684 start
= STATE_TEXTURESTAGE(gl_info
->limits
.texture_stages
, 0);
5685 last
= STATE_TEXTURESTAGE(MAX_TEXTURES
- 1, WINED3D_HIGHEST_TEXTURE_STATE
);
5686 for (i
= start
; i
<= last
; ++i
)
5688 state_table
[i
].representative
= 0;
5689 state_table
[i
].apply
= state_undefined
;
5692 start
= STATE_TRANSFORM(WINED3DTS_TEXTURE0
+ gl_info
->limits
.texture_stages
);
5693 last
= STATE_TRANSFORM(WINED3DTS_TEXTURE0
+ MAX_TEXTURES
- 1);
5694 for (i
= start
; i
<= last
; ++i
)
5696 state_table
[i
].representative
= 0;
5697 state_table
[i
].apply
= state_undefined
;
5700 start
= STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(gl_info
->limits
.blends
));
5701 last
= STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(255));
5702 for (i
= start
; i
<= last
; ++i
)
5704 state_table
[i
].representative
= 0;
5705 state_table
[i
].apply
= state_undefined
;
5709 static void validate_state_table(struct StateEntry
*state_table
)
5731 static const DWORD simple_states
[] =
5737 STATE_VERTEXSHADERCONSTANT
,
5738 STATE_PIXELSHADERCONSTANT
,
5744 STATE_POINTSPRITECOORDORIGIN
,
5745 STATE_BASEVERTEXINDEX
,
5748 unsigned int i
, current
;
5750 for (i
= STATE_RENDER(1), current
= 0; i
<= STATE_RENDER(WINEHIGHEST_RENDER_STATE
); ++i
)
5752 if (!rs_holes
[current
].first
|| i
< STATE_RENDER(rs_holes
[current
].first
))
5754 if (!state_table
[i
].representative
)
5755 ERR("State %s (%#x) should have a representative.\n", debug_d3dstate(i
), i
);
5757 else if (state_table
[i
].representative
)
5758 ERR("State %s (%#x) shouldn't have a representative.\n", debug_d3dstate(i
), i
);
5760 if (i
== STATE_RENDER(rs_holes
[current
].last
)) ++current
;
5763 for (i
= 0; i
< sizeof(simple_states
) / sizeof(*simple_states
); ++i
)
5765 if (!state_table
[simple_states
[i
]].representative
)
5766 ERR("State %s (%#x) should have a representative.\n",
5767 debug_d3dstate(simple_states
[i
]), simple_states
[i
]);
5770 for (i
= 0; i
< STATE_HIGHEST
+ 1; ++i
)
5772 DWORD rep
= state_table
[i
].representative
;
5775 if (state_table
[rep
].representative
!= rep
)
5777 ERR("State %s (%#x) has invalid representative %s (%#x).\n",
5778 debug_d3dstate(i
), i
, debug_d3dstate(rep
), rep
);
5779 state_table
[i
].representative
= 0;
5784 if (state_table
[i
].apply
)
5785 ERR("State %s (%#x) has both a handler and representative.\n", debug_d3dstate(i
), i
);
5787 else if (!state_table
[i
].apply
)
5789 ERR("Self representing state %s (%#x) has no handler.\n", debug_d3dstate(i
), i
);
5795 HRESULT
compile_state_table(struct StateEntry
*StateTable
, APPLYSTATEFUNC
**dev_multistate_funcs
,
5796 const struct wined3d_gl_info
*gl_info
, const struct StateEntryTemplate
*vertex
,
5797 const struct fragment_pipeline
*fragment
, const struct StateEntryTemplate
*misc
)
5799 unsigned int i
, type
, handlers
;
5800 APPLYSTATEFUNC multistate_funcs
[STATE_HIGHEST
+ 1][3];
5801 const struct StateEntryTemplate
*cur
;
5802 BOOL set
[STATE_HIGHEST
+ 1];
5804 memset(multistate_funcs
, 0, sizeof(multistate_funcs
));
5806 for(i
= 0; i
< STATE_HIGHEST
+ 1; i
++) {
5807 StateTable
[i
].representative
= 0;
5808 StateTable
[i
].apply
= state_undefined
;
5811 for(type
= 0; type
< 3; type
++) {
5812 /* This switch decides the order in which the states are applied */
5814 case 0: cur
= misc
; break;
5815 case 1: cur
= fragment
->states
; break;
5816 case 2: cur
= vertex
; break;
5817 default: cur
= NULL
; /* Stupid compiler */
5821 /* GL extension filtering should not prevent multiple handlers being applied from different
5824 memset(set
, 0, sizeof(set
));
5826 for(i
= 0; cur
[i
].state
; i
++) {
5827 APPLYSTATEFUNC
*funcs_array
;
5829 /* Only use the first matching state with the available extension from one template.
5831 * {D3DRS_FOOBAR, {D3DRS_FOOBAR, func1}, XYZ_FANCY},
5832 * {D3DRS_FOOBAR, {D3DRS_FOOBAR, func2}, 0 }
5834 * if GL_XYZ_fancy is supported, ignore the 2nd line
5836 if(set
[cur
[i
].state
]) continue;
5837 /* Skip state lines depending on unsupported extensions */
5838 if (!gl_info
->supported
[cur
[i
].extension
]) continue;
5839 set
[cur
[i
].state
] = TRUE
;
5840 /* In some cases having an extension means that nothing has to be
5841 * done for a state, e.g. if GL_ARB_texture_non_power_of_two is
5842 * supported, the texture coordinate fixup can be ignored. If the
5843 * apply function is used, mark the state set(done above) to prevent
5844 * applying later lines, but do not record anything in the state
5847 if (!cur
[i
].content
.representative
) continue;
5849 handlers
= num_handlers(multistate_funcs
[cur
[i
].state
]);
5850 multistate_funcs
[cur
[i
].state
][handlers
] = cur
[i
].content
.apply
;
5853 StateTable
[cur
[i
].state
].apply
= cur
[i
].content
.apply
;
5856 StateTable
[cur
[i
].state
].apply
= multistate_apply_2
;
5857 dev_multistate_funcs
[cur
[i
].state
] = HeapAlloc(GetProcessHeap(),
5859 sizeof(**dev_multistate_funcs
) * 2);
5860 if (!dev_multistate_funcs
[cur
[i
].state
]) {
5864 dev_multistate_funcs
[cur
[i
].state
][0] = multistate_funcs
[cur
[i
].state
][0];
5865 dev_multistate_funcs
[cur
[i
].state
][1] = multistate_funcs
[cur
[i
].state
][1];
5868 StateTable
[cur
[i
].state
].apply
= multistate_apply_3
;
5869 funcs_array
= HeapReAlloc(GetProcessHeap(),
5871 dev_multistate_funcs
[cur
[i
].state
],
5872 sizeof(**dev_multistate_funcs
) * 3);
5877 dev_multistate_funcs
[cur
[i
].state
] = funcs_array
;
5878 dev_multistate_funcs
[cur
[i
].state
][2] = multistate_funcs
[cur
[i
].state
][2];
5881 ERR("Unexpected amount of state handlers for state %u: %u\n",
5882 cur
[i
].state
, handlers
+ 1);
5885 if(StateTable
[cur
[i
].state
].representative
&&
5886 StateTable
[cur
[i
].state
].representative
!= cur
[i
].content
.representative
) {
5887 FIXME("State %u has different representatives in different pipeline parts\n",
5890 StateTable
[cur
[i
].state
].representative
= cur
[i
].content
.representative
;
5894 prune_invalid_states(StateTable
, gl_info
);
5895 validate_state_table(StateTable
);
5900 for (i
= 0; i
<= STATE_HIGHEST
; ++i
) {
5901 HeapFree(GetProcessHeap(), 0, dev_multistate_funcs
[i
]);
5904 memset(dev_multistate_funcs
, 0, (STATE_HIGHEST
+ 1)*sizeof(*dev_multistate_funcs
));
5906 return E_OUTOFMEMORY
;