wined3d: Introduce wined3d_event_query_issue.
[wine] / dlls / wined3d / nvidia_texture_shader.c
1 /*
2  * Fixed function pipeline replacement using GL_NV_register_combiners
3  * and GL_NV_texture_shader
4  *
5  * Copyright 2006 Henri Verbeet
6  * Copyright 2008 Stefan Dösinger(for CodeWeavers)
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  */
22 #include "config.h"
23
24 #include <math.h>
25 #include <stdio.h>
26
27 #include "wined3d_private.h"
28
29 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
30
31 #define GLINFO_LOCATION stateblock->device->adapter->gl_info
32
33 /* GL locking for state handlers is done by the caller. */
34
35 static void nvts_activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
36 {
37     BOOL bumpmap = FALSE;
38
39     if(stage > 0 && (stateblock->textureState[stage - 1][WINED3DTSS_COLOROP] == WINED3DTOP_BUMPENVMAPLUMINANCE ||
40                      stateblock->textureState[stage - 1][WINED3DTSS_COLOROP] == WINED3DTOP_BUMPENVMAP)) {
41         bumpmap = TRUE;
42         context->texShaderBumpMap |= (1 << stage);
43     } else {
44         context->texShaderBumpMap &= ~(1 << stage);
45     }
46
47     if(stateblock->textures[stage]) {
48         switch(IWineD3DBaseTexture_GetTextureDimensions(stateblock->textures[stage])) {
49             case GL_TEXTURE_2D:
50                 glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, bumpmap ? GL_OFFSET_TEXTURE_2D_NV : GL_TEXTURE_2D);
51                 checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, ...)");
52                 break;
53             case GL_TEXTURE_RECTANGLE_ARB:
54                 glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, bumpmap ? GL_OFFSET_TEXTURE_2D_NV : GL_TEXTURE_RECTANGLE_ARB);
55                 checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, ...)");
56                 break;
57             case GL_TEXTURE_3D:
58                 glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_3D);
59                 checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_3D)");
60                 break;
61             case GL_TEXTURE_CUBE_MAP_ARB:
62                 glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_CUBE_MAP_ARB);
63                 checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_CUBE_MAP_ARB)");
64                 break;
65         }
66     } else {
67         glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_NONE);
68         checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_NONE)");
69     }
70 }
71
72 typedef struct {
73     GLenum input[3];
74     GLenum mapping[3];
75     GLenum component_usage[3];
76 } tex_op_args;
77
78 static GLenum d3dta_to_combiner_input(DWORD d3dta, DWORD stage, INT texture_idx) {
79     switch (d3dta) {
80         case WINED3DTA_DIFFUSE:
81             return GL_PRIMARY_COLOR_NV;
82
83         case WINED3DTA_CURRENT:
84             if (stage) return GL_SPARE0_NV;
85             else return GL_PRIMARY_COLOR_NV;
86
87         case WINED3DTA_TEXTURE:
88             if (texture_idx > -1) return GL_TEXTURE0_ARB + texture_idx;
89             else return GL_PRIMARY_COLOR_NV;
90
91         case WINED3DTA_TFACTOR:
92             return GL_CONSTANT_COLOR0_NV;
93
94         case WINED3DTA_SPECULAR:
95             return GL_SECONDARY_COLOR_NV;
96
97         case WINED3DTA_TEMP:
98             return GL_SPARE1_NV;
99
100         case WINED3DTA_CONSTANT:
101             /* TODO: Support per stage constants (WINED3DTSS_CONSTANT, NV_register_combiners2) */
102             FIXME("WINED3DTA_CONSTANT, not properly supported.\n");
103             return GL_CONSTANT_COLOR1_NV;
104
105         default:
106             FIXME("Unrecognized texture arg %#x\n", d3dta);
107             return GL_TEXTURE;
108     }
109 }
110
111 static GLenum invert_mapping(GLenum mapping) {
112     if (mapping == GL_UNSIGNED_INVERT_NV) return GL_UNSIGNED_IDENTITY_NV;
113     else if (mapping == GL_UNSIGNED_IDENTITY_NV) return GL_UNSIGNED_INVERT_NV;
114
115     FIXME("Unhandled mapping %#x\n", mapping);
116     return mapping;
117 }
118
119 static void get_src_and_opr_nvrc(DWORD stage, DWORD arg, BOOL is_alpha, GLenum* input, GLenum* mapping, GLenum *component_usage, INT texture_idx) {
120     /* The WINED3DTA_COMPLEMENT flag specifies the complement of the input should
121     * be used. */
122     if (arg & WINED3DTA_COMPLEMENT) *mapping = GL_UNSIGNED_INVERT_NV;
123     else *mapping = GL_UNSIGNED_IDENTITY_NV; /* Clamp all values to positive ranges */
124
125     /* The WINED3DTA_ALPHAREPLICATE flag specifies the alpha component of the input
126     * should be used for all input components. */
127     if (is_alpha || arg & WINED3DTA_ALPHAREPLICATE) *component_usage = GL_ALPHA;
128     else *component_usage = GL_RGB;
129
130     *input = d3dta_to_combiner_input(arg & WINED3DTA_SELECTMASK, stage, texture_idx);
131 }
132
133 void set_tex_op_nvrc(IWineD3DDevice *iface, BOOL is_alpha, int stage, WINED3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3, INT texture_idx, DWORD dst) {
134     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl*)iface;
135     const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
136     tex_op_args tex_op_args = {{0}, {0}, {0}};
137     GLenum portion = is_alpha ? GL_ALPHA : GL_RGB;
138     GLenum target = GL_COMBINER0_NV + stage;
139     GLenum output;
140     IWineD3DStateBlockImpl *stateblock = This->stateBlock; /* For GLINFO_LOCATION */
141
142     TRACE("stage %d, is_alpha %d, op %s, arg1 %#x, arg2 %#x, arg3 %#x, texture_idx %d\n",
143           stage, is_alpha, debug_d3dtop(op), arg1, arg2, arg3, texture_idx);
144
145     /* If a texture stage references an invalid texture unit the stage just
146     * passes through the result from the previous stage */
147     if (is_invalid_op(This, stage, op, arg1, arg2, arg3)) {
148         arg1 = WINED3DTA_CURRENT;
149         op = WINED3DTOP_SELECTARG1;
150     }
151
152     get_src_and_opr_nvrc(stage, arg1, is_alpha, &tex_op_args.input[0],
153                          &tex_op_args.mapping[0], &tex_op_args.component_usage[0], texture_idx);
154     get_src_and_opr_nvrc(stage, arg2, is_alpha, &tex_op_args.input[1],
155                          &tex_op_args.mapping[1], &tex_op_args.component_usage[1], texture_idx);
156     get_src_and_opr_nvrc(stage, arg3, is_alpha, &tex_op_args.input[2],
157                          &tex_op_args.mapping[2], &tex_op_args.component_usage[2], texture_idx);
158
159
160     if(dst == WINED3DTA_TEMP) {
161         output = GL_SPARE1_NV;
162     } else {
163         output = GL_SPARE0_NV;
164     }
165
166     /* This is called by a state handler which has the gl lock held and a context for the thread */
167     switch(op)
168     {
169         case WINED3DTOP_DISABLE:
170             /* Only for alpha */
171             if (!is_alpha) ERR("Shouldn't be called for WINED3DTSS_COLOROP (WINED3DTOP_DISABLE)\n");
172             /* Input, prev_alpha*1 */
173             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV,
174                        GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_ALPHA));
175             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV,
176                        GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_ALPHA));
177
178             /* Output */
179             GL_EXTCALL(glCombinerOutputNV(target, portion, GL_SPARE0_NV, GL_DISCARD_NV,
180                        GL_DISCARD_NV, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE));
181             break;
182
183         case WINED3DTOP_SELECTARG1:
184         case WINED3DTOP_SELECTARG2:
185             /* Input, arg*1 */
186             if (op == WINED3DTOP_SELECTARG1) {
187                 GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV,
188                            tex_op_args.input[0], tex_op_args.mapping[0], tex_op_args.component_usage[0]));
189             } else {
190                 GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV,
191                            tex_op_args.input[1], tex_op_args.mapping[1], tex_op_args.component_usage[1]));
192             }
193             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV,
194                        GL_ZERO, GL_UNSIGNED_INVERT_NV, portion));
195
196             /* Output */
197             GL_EXTCALL(glCombinerOutputNV(target, portion, output, GL_DISCARD_NV,
198                        GL_DISCARD_NV, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE));
199             break;
200
201         case WINED3DTOP_MODULATE:
202         case WINED3DTOP_MODULATE2X:
203         case WINED3DTOP_MODULATE4X:
204             /* Input, arg1*arg2 */
205             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV,
206                        tex_op_args.input[0], tex_op_args.mapping[0], tex_op_args.component_usage[0]));
207             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV,
208                        tex_op_args.input[1], tex_op_args.mapping[1], tex_op_args.component_usage[1]));
209
210             /* Output */
211             if (op == WINED3DTOP_MODULATE) {
212                 GL_EXTCALL(glCombinerOutputNV(target, portion, output, GL_DISCARD_NV,
213                            GL_DISCARD_NV, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE));
214             } else if (op == WINED3DTOP_MODULATE2X) {
215                 GL_EXTCALL(glCombinerOutputNV(target, portion, output, GL_DISCARD_NV,
216                            GL_DISCARD_NV, GL_SCALE_BY_TWO_NV, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE));
217             } else if (op == WINED3DTOP_MODULATE4X) {
218                 GL_EXTCALL(glCombinerOutputNV(target, portion, output, GL_DISCARD_NV,
219                            GL_DISCARD_NV, GL_SCALE_BY_FOUR_NV, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE));
220             }
221             break;
222
223         case WINED3DTOP_ADD:
224         case WINED3DTOP_ADDSIGNED:
225         case WINED3DTOP_ADDSIGNED2X:
226             /* Input, arg1*1+arg2*1 */
227             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV,
228                        tex_op_args.input[0], tex_op_args.mapping[0], tex_op_args.component_usage[0]));
229             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV,
230                        GL_ZERO, GL_UNSIGNED_INVERT_NV, portion));
231             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_C_NV,
232                        tex_op_args.input[1], tex_op_args.mapping[1], tex_op_args.component_usage[1]));
233             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_D_NV,
234                        GL_ZERO, GL_UNSIGNED_INVERT_NV, portion));
235
236             /* Output */
237             if (op == WINED3DTOP_ADD) {
238                 GL_EXTCALL(glCombinerOutputNV(target, portion, GL_DISCARD_NV, GL_DISCARD_NV,
239                            output, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE));
240             } else if (op == WINED3DTOP_ADDSIGNED) {
241                 GL_EXTCALL(glCombinerOutputNV(target, portion, GL_DISCARD_NV, GL_DISCARD_NV,
242                            output, GL_NONE, GL_BIAS_BY_NEGATIVE_ONE_HALF_NV, GL_FALSE, GL_FALSE, GL_FALSE));
243             } else if (op == WINED3DTOP_ADDSIGNED2X) {
244                 GL_EXTCALL(glCombinerOutputNV(target, portion, GL_DISCARD_NV, GL_DISCARD_NV,
245                            output, GL_SCALE_BY_TWO_NV, GL_BIAS_BY_NEGATIVE_ONE_HALF_NV, GL_FALSE, GL_FALSE, GL_FALSE));
246             }
247             break;
248
249         case WINED3DTOP_SUBTRACT:
250             /* Input, arg1*1+-arg2*1 */
251             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV,
252                        tex_op_args.input[0], tex_op_args.mapping[0], tex_op_args.component_usage[0]));
253             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV,
254                        GL_ZERO, GL_UNSIGNED_INVERT_NV, portion));
255             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_C_NV,
256                        tex_op_args.input[1], GL_SIGNED_NEGATE_NV, tex_op_args.component_usage[1]));
257             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_D_NV,
258                        GL_ZERO, GL_UNSIGNED_INVERT_NV, portion));
259
260             /* Output */
261             GL_EXTCALL(glCombinerOutputNV(target, portion, GL_DISCARD_NV, GL_DISCARD_NV,
262                        output, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE));
263             break;
264
265         case WINED3DTOP_ADDSMOOTH:
266             /* Input, arg1*1+(1-arg1)*arg2 */
267             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV,
268                        tex_op_args.input[0], tex_op_args.mapping[0], tex_op_args.component_usage[0]));
269             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV,
270                        GL_ZERO, GL_UNSIGNED_INVERT_NV, portion));
271             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_C_NV,
272                        tex_op_args.input[0], invert_mapping(tex_op_args.mapping[0]), tex_op_args.component_usage[0]));
273             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_D_NV,
274                        tex_op_args.input[1], tex_op_args.mapping[1], tex_op_args.component_usage[1]));
275
276             /* Output */
277             GL_EXTCALL(glCombinerOutputNV(target, portion, GL_DISCARD_NV, GL_DISCARD_NV,
278                        output, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE));
279             break;
280
281         case WINED3DTOP_BLENDDIFFUSEALPHA:
282         case WINED3DTOP_BLENDTEXTUREALPHA:
283         case WINED3DTOP_BLENDFACTORALPHA:
284         case WINED3DTOP_BLENDTEXTUREALPHAPM:
285         case WINED3DTOP_BLENDCURRENTALPHA:
286         {
287             GLenum alpha_src = GL_PRIMARY_COLOR_NV;
288             if (op == WINED3DTOP_BLENDDIFFUSEALPHA) alpha_src = d3dta_to_combiner_input(WINED3DTA_DIFFUSE, stage, texture_idx);
289             else if (op == WINED3DTOP_BLENDTEXTUREALPHA) alpha_src = d3dta_to_combiner_input(WINED3DTA_TEXTURE, stage, texture_idx);
290             else if (op == WINED3DTOP_BLENDFACTORALPHA) alpha_src = d3dta_to_combiner_input(WINED3DTA_TFACTOR, stage, texture_idx);
291             else if (op == WINED3DTOP_BLENDTEXTUREALPHAPM) alpha_src = d3dta_to_combiner_input(WINED3DTA_TEXTURE, stage, texture_idx);
292             else if (op == WINED3DTOP_BLENDCURRENTALPHA) alpha_src = d3dta_to_combiner_input(WINED3DTA_CURRENT, stage, texture_idx);
293             else FIXME("Unhandled WINED3DTOP %s, shouldn't happen\n", debug_d3dtop(op));
294
295             /* Input, arg1*alpha_src+arg2*(1-alpha_src) */
296             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV,
297                        tex_op_args.input[0], tex_op_args.mapping[0], tex_op_args.component_usage[0]));
298             if (op == WINED3DTOP_BLENDTEXTUREALPHAPM)
299             {
300                 GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV,
301                            GL_ZERO, GL_UNSIGNED_INVERT_NV, portion));
302             } else {
303                 GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV,
304                            alpha_src, GL_UNSIGNED_IDENTITY_NV, GL_ALPHA));
305             }
306             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_C_NV,
307                        tex_op_args.input[1], tex_op_args.mapping[1], tex_op_args.component_usage[1]));
308             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_D_NV,
309                        alpha_src, GL_UNSIGNED_INVERT_NV, GL_ALPHA));
310
311             /* Output */
312             GL_EXTCALL(glCombinerOutputNV(target, portion, GL_DISCARD_NV, GL_DISCARD_NV,
313                        output, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE));
314             break;
315         }
316
317         case WINED3DTOP_MODULATEALPHA_ADDCOLOR:
318             /* Input, arg1_alpha*arg2_rgb+arg1_rgb*1 */
319             if (is_alpha) ERR("Only supported for WINED3DTSS_COLOROP (WINED3DTOP_MODULATEALPHA_ADDCOLOR)\n");
320             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV,
321                        tex_op_args.input[0], tex_op_args.mapping[0], GL_ALPHA));
322             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV,
323                        tex_op_args.input[1], tex_op_args.mapping[1], tex_op_args.component_usage[1]));
324             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_C_NV,
325                        tex_op_args.input[0], tex_op_args.mapping[0], tex_op_args.component_usage[0]));
326             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_D_NV,
327                        GL_ZERO, GL_UNSIGNED_INVERT_NV, portion));
328
329             /* Output */
330             GL_EXTCALL(glCombinerOutputNV(target, portion, GL_DISCARD_NV, GL_DISCARD_NV,
331                        output, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE));
332             break;
333
334         case WINED3DTOP_MODULATECOLOR_ADDALPHA:
335             /* Input, arg1_rgb*arg2_rgb+arg1_alpha*1 */
336             if (is_alpha) ERR("Only supported for WINED3DTSS_COLOROP (WINED3DTOP_MODULATECOLOR_ADDALPHA)\n");
337             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV,
338                        tex_op_args.input[0], tex_op_args.mapping[0], tex_op_args.component_usage[0]));
339             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV,
340                        tex_op_args.input[1], tex_op_args.mapping[1], tex_op_args.component_usage[1]));
341             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_C_NV,
342                        tex_op_args.input[0], tex_op_args.mapping[0], GL_ALPHA));
343             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_D_NV,
344                        GL_ZERO, GL_UNSIGNED_INVERT_NV, portion));
345
346             /* Output */
347             GL_EXTCALL(glCombinerOutputNV(target, portion, GL_DISCARD_NV, GL_DISCARD_NV,
348                        output, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE));
349             break;
350
351         case WINED3DTOP_MODULATEINVALPHA_ADDCOLOR:
352             /* Input, (1-arg1_alpha)*arg2_rgb+arg1_rgb*1 */
353             if (is_alpha) ERR("Only supported for WINED3DTSS_COLOROP (WINED3DTOP_MODULATEINVALPHA_ADDCOLOR)\n");
354             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV,
355                        tex_op_args.input[0], invert_mapping(tex_op_args.mapping[0]), GL_ALPHA));
356             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV,
357                        tex_op_args.input[1], tex_op_args.mapping[1], tex_op_args.component_usage[1]));
358             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_C_NV,
359                        tex_op_args.input[0], tex_op_args.mapping[0], tex_op_args.component_usage[0]));
360             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_D_NV,
361                        GL_ZERO, GL_UNSIGNED_INVERT_NV, portion));
362
363             /* Output */
364             GL_EXTCALL(glCombinerOutputNV(target, portion, GL_DISCARD_NV, GL_DISCARD_NV,
365                        output, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE));
366             break;
367
368         case WINED3DTOP_MODULATEINVCOLOR_ADDALPHA:
369             /* Input, (1-arg1_rgb)*arg2_rgb+arg1_alpha*1 */
370             if (is_alpha) ERR("Only supported for WINED3DTSS_COLOROP (WINED3DTOP_MODULATEINVCOLOR_ADDALPHA)\n");
371             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV,
372                        tex_op_args.input[0], invert_mapping(tex_op_args.mapping[0]), tex_op_args.component_usage[0]));
373             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV,
374                        tex_op_args.input[1], tex_op_args.mapping[1], tex_op_args.component_usage[1]));
375             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_C_NV,
376                        tex_op_args.input[0], tex_op_args.mapping[0], GL_ALPHA));
377             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_D_NV,
378                        GL_ZERO, GL_UNSIGNED_INVERT_NV, portion));
379
380             /* Output */
381             GL_EXTCALL(glCombinerOutputNV(target, portion, GL_DISCARD_NV, GL_DISCARD_NV,
382                        output, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE));
383             break;
384
385         case WINED3DTOP_DOTPRODUCT3:
386             /* Input, arg1 . arg2 */
387             /* FIXME: DX7 uses a different calculation? */
388             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV,
389                        tex_op_args.input[0], GL_EXPAND_NORMAL_NV, tex_op_args.component_usage[0]));
390             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV,
391                        tex_op_args.input[1], GL_EXPAND_NORMAL_NV, tex_op_args.component_usage[1]));
392
393             /* Output */
394             GL_EXTCALL(glCombinerOutputNV(target, portion, output, GL_DISCARD_NV,
395                        GL_DISCARD_NV, GL_NONE, GL_NONE, GL_TRUE, GL_FALSE, GL_FALSE));
396             break;
397
398         case WINED3DTOP_MULTIPLYADD:
399             /* Input, arg3*1+arg1*arg2 */
400             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV,
401                        tex_op_args.input[2], tex_op_args.mapping[2], tex_op_args.component_usage[2]));
402             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV,
403                        GL_ZERO, GL_UNSIGNED_INVERT_NV, portion));
404             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_C_NV,
405                        tex_op_args.input[0], tex_op_args.mapping[0], tex_op_args.component_usage[0]));
406             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_D_NV,
407                        tex_op_args.input[1], tex_op_args.mapping[1], tex_op_args.component_usage[1]));
408
409             /* Output */
410             GL_EXTCALL(glCombinerOutputNV(target, portion, GL_DISCARD_NV, GL_DISCARD_NV,
411                        output, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE));
412             break;
413
414         case WINED3DTOP_LERP:
415             /* Input, arg3*arg1+(1-arg3)*arg2 */
416             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV,
417                        tex_op_args.input[2], tex_op_args.mapping[2], tex_op_args.component_usage[2]));
418             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV,
419                        tex_op_args.input[0], tex_op_args.mapping[0], tex_op_args.component_usage[0]));
420             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_C_NV,
421                        tex_op_args.input[2], invert_mapping(tex_op_args.mapping[2]), tex_op_args.component_usage[2]));
422             GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_D_NV,
423                        tex_op_args.input[1], tex_op_args.mapping[1], tex_op_args.component_usage[1]));
424
425             /* Output */
426             GL_EXTCALL(glCombinerOutputNV(target, portion, GL_DISCARD_NV, GL_DISCARD_NV,
427                        output, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE));
428             break;
429
430         case WINED3DTOP_BUMPENVMAPLUMINANCE:
431         case WINED3DTOP_BUMPENVMAP:
432             if (gl_info->supported[NV_TEXTURE_SHADER])
433             {
434                 /* The bump map stage itself isn't exciting, just read the texture. But tell the next stage to
435                  * perform bump mapping and source from the current stage. Pretty much a SELECTARG2.
436                  * ARG2 is passed through unmodified(apps will most likely use D3DTA_CURRENT for arg2, arg1
437                  * (which will most likely be D3DTA_TEXTURE) is available as a texture shader input for the next stage
438                  */
439                 GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_A_NV,
440                            tex_op_args.input[1], tex_op_args.mapping[1], tex_op_args.component_usage[1]));
441                 GL_EXTCALL(glCombinerInputNV(target, portion, GL_VARIABLE_B_NV,
442                            GL_ZERO, GL_UNSIGNED_INVERT_NV, portion));
443                 /* Always pass through to CURRENT, ignore temp arg */
444                 GL_EXTCALL(glCombinerOutputNV(target, portion, GL_SPARE0_NV, GL_DISCARD_NV,
445                            GL_DISCARD_NV, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE));
446                 break;
447             }
448
449         default:
450             FIXME("Unhandled WINED3DTOP: stage %d, is_alpha %d, op %s (%#x), arg1 %#x, arg2 %#x, arg3 %#x, texture_idx %d\n",
451                   stage, is_alpha, debug_d3dtop(op), op, arg1, arg2, arg3, texture_idx);
452     }
453
454     checkGLcall("set_tex_op_nvrc()");
455 }
456
457
458 static void nvrc_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
459 {
460     DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
461     BOOL tex_used = stateblock->device->fixed_function_usage_map & (1 << stage);
462     DWORD mapped_stage = stateblock->device->texUnitMap[stage];
463     const struct wined3d_gl_info *gl_info = context->gl_info;
464
465     TRACE("Setting color op for stage %d\n", stage);
466
467     /* Using a pixel shader? Don't care for anything here, the shader applying does it */
468     if (use_ps(stateblock)) return;
469
470     if (stage != mapped_stage) WARN("Using non 1:1 mapping: %d -> %d!\n", stage, mapped_stage);
471
472     if (mapped_stage != WINED3D_UNMAPPED_STAGE)
473     {
474         if (tex_used && mapped_stage >= gl_info->limits.textures)
475         {
476             FIXME("Attempt to enable unsupported stage!\n");
477             return;
478         }
479         GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
480         checkGLcall("glActiveTextureARB");
481     }
482
483     if(stateblock->lowest_disabled_stage > 0) {
484         glEnable(GL_REGISTER_COMBINERS_NV);
485         GL_EXTCALL(glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, stateblock->lowest_disabled_stage));
486     } else {
487         glDisable(GL_REGISTER_COMBINERS_NV);
488     }
489     if(stage >= stateblock->lowest_disabled_stage) {
490         TRACE("Stage disabled\n");
491         if (mapped_stage != WINED3D_UNMAPPED_STAGE)
492         {
493             /* Disable everything here */
494             glDisable(GL_TEXTURE_2D);
495             checkGLcall("glDisable(GL_TEXTURE_2D)");
496             glDisable(GL_TEXTURE_3D);
497             checkGLcall("glDisable(GL_TEXTURE_3D)");
498             if (gl_info->supported[ARB_TEXTURE_CUBE_MAP])
499             {
500                 glDisable(GL_TEXTURE_CUBE_MAP_ARB);
501                 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
502             }
503             if (gl_info->supported[ARB_TEXTURE_RECTANGLE])
504             {
505                 glDisable(GL_TEXTURE_RECTANGLE_ARB);
506                 checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)");
507             }
508             if (gl_info->supported[NV_TEXTURE_SHADER2] && mapped_stage < gl_info->limits.textures)
509             {
510                 glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_NONE);
511             }
512         }
513         /* All done */
514         return;
515     }
516
517     /* The sampler will also activate the correct texture dimensions, so no need to do it here
518      * if the sampler for this stage is dirty
519      */
520     if (!isStateDirty(context, STATE_SAMPLER(stage)))
521     {
522         if (tex_used)
523         {
524             if (gl_info->supported[NV_TEXTURE_SHADER2])
525             {
526                 nvts_activate_dimensions(stage, stateblock, context);
527             }
528             else
529             {
530                 texture_activate_dimensions(stage, stateblock, context);
531             }
532         }
533     }
534
535     /* Set the texture combiners */
536     set_tex_op_nvrc((IWineD3DDevice *)stateblock->device, FALSE, stage,
537                         stateblock->textureState[stage][WINED3DTSS_COLOROP],
538                         stateblock->textureState[stage][WINED3DTSS_COLORARG1],
539                         stateblock->textureState[stage][WINED3DTSS_COLORARG2],
540                         stateblock->textureState[stage][WINED3DTSS_COLORARG0],
541                         mapped_stage,
542                         stateblock->textureState[stage][WINED3DTSS_RESULTARG]);
543
544     /* In register combiners bump mapping is done in the stage AFTER the one that has the bump map operation set,
545      * thus the texture shader may have to be updated
546      */
547     if (gl_info->supported[NV_TEXTURE_SHADER2])
548     {
549         BOOL usesBump = (stateblock->textureState[stage][WINED3DTSS_COLOROP] == WINED3DTOP_BUMPENVMAPLUMINANCE ||
550                             stateblock->textureState[stage][WINED3DTSS_COLOROP] == WINED3DTOP_BUMPENVMAP) ? TRUE : FALSE;
551         BOOL usedBump = (context->texShaderBumpMap & 1 << (stage + 1)) ? TRUE : FALSE;
552         if(usesBump != usedBump) {
553             GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage + 1));
554             checkGLcall("glActiveTextureARB");
555             nvts_activate_dimensions(stage + 1, stateblock, context);
556             GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
557             checkGLcall("glActiveTextureARB");
558         }
559     }
560 }
561
562 static void nvts_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
563 {
564     DWORD sampler = state - STATE_SAMPLER(0);
565     DWORD mapped_stage = stateblock->device->texUnitMap[sampler];
566
567     /* No need to enable / disable anything here for unused samplers. The tex_colorop
568     * handler takes care. Also no action is needed with pixel shaders, or if tex_colorop
569     * will take care of this business
570     */
571     if (mapped_stage == WINED3D_UNMAPPED_STAGE || mapped_stage >= context->gl_info->limits.textures) return;
572     if(sampler >= stateblock->lowest_disabled_stage) return;
573     if(isStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3DTSS_COLOROP))) return;
574
575     nvts_activate_dimensions(sampler, stateblock, context);
576 }
577
578 static void nvts_bumpenvmat(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
579 {
580     DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
581     DWORD mapped_stage = stateblock->device->texUnitMap[stage + 1];
582     float mat[2][2];
583
584     /* Direct3D sets the matrix in the stage reading the perturbation map. The result is used to
585      * offset the destination stage(always stage + 1 in d3d). In GL_NV_texture_shader, the bump
586      * map offsetting is done in the stage reading the bump mapped texture, and the perturbation
587      * map is read from a specified source stage(always stage - 1 for d3d). Thus set the matrix
588      * for stage + 1. Keep the nvrc tex unit mapping in mind too
589      */
590     if (mapped_stage < context->gl_info->limits.textures)
591     {
592         GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
593         checkGLcall("GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage))");
594
595         /* We can't just pass a pointer to the stateblock to GL due to the different matrix
596          * format(column major vs row major)
597          */
598         mat[0][0] = *((float *) &stateblock->textureState[stage][WINED3DTSS_BUMPENVMAT00]);
599         mat[1][0] = *((float *) &stateblock->textureState[stage][WINED3DTSS_BUMPENVMAT01]);
600         mat[0][1] = *((float *) &stateblock->textureState[stage][WINED3DTSS_BUMPENVMAT10]);
601         mat[1][1] = *((float *) &stateblock->textureState[stage][WINED3DTSS_BUMPENVMAT11]);
602         glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, (float *) mat);
603         checkGLcall("glTexEnvfv(GL_TEXTURE_SHADER_NV, GL_OFFSET_TEXTURE_MATRIX_NV, mat)");
604     }
605 }
606
607 static void nvrc_texfactor(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
608 {
609     float col[4];
610     D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_TEXTUREFACTOR], col);
611     GL_EXTCALL(glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV, &col[0]));
612 }
613
614 /* Context activation is done by the caller. */
615 static void nvrc_enable(IWineD3DDevice *iface, BOOL enable) { }
616
617 /* Context activation is done by the caller. */
618 static void nvts_enable(IWineD3DDevice *iface, BOOL enable) {
619     ENTER_GL();
620     if(enable) {
621         glEnable(GL_TEXTURE_SHADER_NV);
622         checkGLcall("glEnable(GL_TEXTURE_SHADER_NV)");
623     } else {
624         glDisable(GL_TEXTURE_SHADER_NV);
625         checkGLcall("glDisable(GL_TEXTURE_SHADER_NV)");
626     }
627     LEAVE_GL();
628 }
629
630 static void nvrc_fragment_get_caps(const struct wined3d_gl_info *gl_info, struct fragment_caps *pCaps)
631 {
632     pCaps->TextureOpCaps =  WINED3DTEXOPCAPS_ADD                        |
633                             WINED3DTEXOPCAPS_ADDSIGNED                  |
634                             WINED3DTEXOPCAPS_ADDSIGNED2X                |
635                             WINED3DTEXOPCAPS_MODULATE                   |
636                             WINED3DTEXOPCAPS_MODULATE2X                 |
637                             WINED3DTEXOPCAPS_MODULATE4X                 |
638                             WINED3DTEXOPCAPS_SELECTARG1                 |
639                             WINED3DTEXOPCAPS_SELECTARG2                 |
640                             WINED3DTEXOPCAPS_DISABLE                    |
641                             WINED3DTEXOPCAPS_BLENDDIFFUSEALPHA          |
642                             WINED3DTEXOPCAPS_BLENDTEXTUREALPHA          |
643                             WINED3DTEXOPCAPS_BLENDFACTORALPHA           |
644                             WINED3DTEXOPCAPS_BLENDCURRENTALPHA          |
645                             WINED3DTEXOPCAPS_LERP                       |
646                             WINED3DTEXOPCAPS_SUBTRACT                   |
647                             WINED3DTEXOPCAPS_ADDSMOOTH                  |
648                             WINED3DTEXOPCAPS_MULTIPLYADD                |
649                             WINED3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR     |
650                             WINED3DTEXOPCAPS_MODULATECOLOR_ADDALPHA     |
651                             WINED3DTEXOPCAPS_BLENDTEXTUREALPHAPM        |
652                             WINED3DTEXOPCAPS_DOTPRODUCT3                |
653                             WINED3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR  |
654                             WINED3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA;
655
656     if (gl_info->supported[NV_TEXTURE_SHADER2])
657     {
658         /* Bump mapping is supported already in NV_TEXTURE_SHADER, but that extension does
659          * not support 3D textures. This asks for trouble if an app uses both bump mapping
660          * and 3D textures. It also allows us to keep the code simpler by having texture
661          * shaders constantly enabled.
662          */
663         pCaps->TextureOpCaps |= WINED3DTEXOPCAPS_BUMPENVMAP;
664         /* TODO: Luminance bump map? */
665     }
666
667 #if 0
668     /* FIXME: Add
669             pCaps->TextureOpCaps |= WINED3DTEXOPCAPS_BUMPENVMAPLUMINANCE
670             WINED3DTEXOPCAPS_PREMODULATE */
671 #endif
672
673     pCaps->MaxTextureBlendStages = min(MAX_TEXTURES, gl_info->limits.general_combiners);
674     pCaps->MaxSimultaneousTextures = gl_info->limits.textures;
675
676     pCaps->PrimitiveMiscCaps |=  WINED3DPMISCCAPS_TSSARGTEMP;
677
678     /* The caps below can be supported but aren't handled yet in utils.c 'd3dta_to_combiner_input', disable them until support is fixed */
679 #if 0
680     if (gl_info->supported[NV_REGISTER_COMBINERS2])
681     pCaps->PrimitiveMiscCaps |=  WINED3DPMISCCAPS_PERSTAGECONSTANT;
682 #endif
683 }
684
685 static HRESULT nvrc_fragment_alloc(IWineD3DDevice *iface) { return WINED3D_OK; }
686 /* Context activation is done by the caller. */
687 static void nvrc_fragment_free(IWineD3DDevice *iface) {}
688
689 /* Two fixed function pipeline implementations using GL_NV_register_combiners and
690  * GL_NV_texture_shader. The nvts_fragment_pipeline assumes that both extensions
691  * are available(geforce 3 and newer), while nvrc_fragment_pipeline uses only the
692  * register combiners extension(Pre-GF3).
693  */
694
695 static BOOL nvts_color_fixup_supported(struct color_fixup_desc fixup)
696 {
697     if (TRACE_ON(d3d))
698     {
699         TRACE("Checking support for fixup:\n");
700         dump_color_fixup_desc(fixup);
701     }
702
703     /* We only support identity conversions. */
704     if (is_identity_fixup(fixup))
705     {
706         TRACE("[OK]\n");
707         return TRUE;
708     }
709
710     TRACE("[FAILED]\n");
711     return FALSE;
712 }
713
714 static const struct StateEntryTemplate nvrc_fragmentstate_template[] = {
715     { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
716     { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
717     { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
718     { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP),          { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
719     { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
720     { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
721     { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
722     { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
723     { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
724     { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(0, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
725     { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
726     { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
727     { STATE_TEXTURESTAGE(0, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
728     { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),          { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
729     { STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
730     { STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
731     { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP),          { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
732     { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
733     { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
734     { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
735     { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
736     { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
737     { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(1, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
738     { STATE_TEXTURESTAGE(1, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
739     { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(1, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
740     { STATE_TEXTURESTAGE(1, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(1, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
741     { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),          { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
742     { STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
743     { STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
744     { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP),          { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
745     { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
746     { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
747     { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
748     { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
749     { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
750     { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(2, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
751     { STATE_TEXTURESTAGE(2, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
752     { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(2, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
753     { STATE_TEXTURESTAGE(2, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(2, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
754     { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),          { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
755     { STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
756     { STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
757     { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP),          { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
758     { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
759     { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
760     { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
761     { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
762     { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
763     { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(3, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
764     { STATE_TEXTURESTAGE(3, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
765     { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(3, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
766     { STATE_TEXTURESTAGE(3, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(3, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
767     { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),          { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
768     { STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
769     { STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
770     { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP),          { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
771     { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
772     { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
773     { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
774     { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
775     { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
776     { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(4, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
777     { STATE_TEXTURESTAGE(4, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
778     { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(4, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
779     { STATE_TEXTURESTAGE(4, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(4, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
780     { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),          { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
781     { STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
782     { STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
783     { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP),          { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
784     { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
785     { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
786     { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
787     { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
788     { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
789     { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(5, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
790     { STATE_TEXTURESTAGE(5, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
791     { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(5, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
792     { STATE_TEXTURESTAGE(5, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(5, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
793     { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),          { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
794     { STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
795     { STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
796     { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP),          { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
797     { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
798     { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
799     { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
800     { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
801     { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
802     { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(6, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
803     { STATE_TEXTURESTAGE(6, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
804     { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(6, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
805     { STATE_TEXTURESTAGE(6, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(6, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
806     { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),          { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
807     { STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
808     { STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
809     { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP),          { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
810     { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG1),        { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
811     { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG2),        { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
812     { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
813     { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT01),     { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
814     { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT10),     { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
815     { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT11),     { STATE_TEXTURESTAGE(7, WINED3DTSS_BUMPENVMAT00),     nvts_bumpenvmat     }, NV_TEXTURE_SHADER2              },
816     { STATE_TEXTURESTAGE(7, WINED3DTSS_COLORARG0),        { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
817     { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAARG0),        { STATE_TEXTURESTAGE(7, WINED3DTSS_ALPHAOP),          tex_alphaop         }, WINED3D_GL_EXT_NONE             },
818     { STATE_TEXTURESTAGE(7, WINED3DTSS_RESULTARG),        { STATE_TEXTURESTAGE(7, WINED3DTSS_COLOROP),          nvrc_colorop        }, WINED3D_GL_EXT_NONE             },
819     { STATE_PIXELSHADER,                                  { STATE_PIXELSHADER,                                  apply_pixelshader   }, WINED3D_GL_EXT_NONE             },
820     { STATE_RENDER(WINED3DRS_SRGBWRITEENABLE),            { STATE_PIXELSHADER,                                  apply_pixelshader   }, WINED3D_GL_EXT_NONE             },
821     { STATE_RENDER(WINED3DRS_TEXTUREFACTOR),              { STATE_RENDER(WINED3DRS_TEXTUREFACTOR),              nvrc_texfactor      }, WINED3D_GL_EXT_NONE             },
822     { STATE_RENDER(WINED3DRS_FOGCOLOR),                   { STATE_RENDER(WINED3DRS_FOGCOLOR),                   state_fogcolor      }, WINED3D_GL_EXT_NONE             },
823     { STATE_RENDER(WINED3DRS_FOGDENSITY),                 { STATE_RENDER(WINED3DRS_FOGDENSITY),                 state_fogdensity    }, WINED3D_GL_EXT_NONE             },
824     { STATE_RENDER(WINED3DRS_FOGENABLE),                  { STATE_RENDER(WINED3DRS_FOGENABLE),                  state_fog_fragpart  }, WINED3D_GL_EXT_NONE             },
825     { STATE_RENDER(WINED3DRS_FOGTABLEMODE),               { STATE_RENDER(WINED3DRS_FOGENABLE),                  state_fog_fragpart  }, WINED3D_GL_EXT_NONE             },
826     { STATE_RENDER(WINED3DRS_FOGVERTEXMODE),              { STATE_RENDER(WINED3DRS_FOGENABLE),                  state_fog_fragpart  }, WINED3D_GL_EXT_NONE             },
827     { STATE_RENDER(WINED3DRS_FOGSTART),                   { STATE_RENDER(WINED3DRS_FOGSTART),                   state_fogstartend   }, WINED3D_GL_EXT_NONE             },
828     { STATE_RENDER(WINED3DRS_FOGEND),                     { STATE_RENDER(WINED3DRS_FOGSTART),                   state_fogstartend   }, WINED3D_GL_EXT_NONE             },
829     { STATE_SAMPLER(0),                                   { STATE_SAMPLER(0),                                   nvts_texdim         }, NV_TEXTURE_SHADER2              },
830     { STATE_SAMPLER(0),                                   { STATE_SAMPLER(0),                                   sampler_texdim      }, WINED3D_GL_EXT_NONE             },
831     { STATE_SAMPLER(1),                                   { STATE_SAMPLER(1),                                   nvts_texdim         }, NV_TEXTURE_SHADER2              },
832     { STATE_SAMPLER(1),                                   { STATE_SAMPLER(1),                                   sampler_texdim      }, WINED3D_GL_EXT_NONE             },
833     { STATE_SAMPLER(2),                                   { STATE_SAMPLER(2),                                   nvts_texdim         }, NV_TEXTURE_SHADER2              },
834     { STATE_SAMPLER(2),                                   { STATE_SAMPLER(2),                                   sampler_texdim      }, WINED3D_GL_EXT_NONE             },
835     { STATE_SAMPLER(3),                                   { STATE_SAMPLER(3),                                   nvts_texdim         }, NV_TEXTURE_SHADER2              },
836     { STATE_SAMPLER(3),                                   { STATE_SAMPLER(3),                                   sampler_texdim      }, WINED3D_GL_EXT_NONE             },
837     { STATE_SAMPLER(4),                                   { STATE_SAMPLER(4),                                   nvts_texdim         }, NV_TEXTURE_SHADER2              },
838     { STATE_SAMPLER(4),                                   { STATE_SAMPLER(4),                                   sampler_texdim      }, WINED3D_GL_EXT_NONE             },
839     { STATE_SAMPLER(5),                                   { STATE_SAMPLER(5),                                   nvts_texdim         }, NV_TEXTURE_SHADER2              },
840     { STATE_SAMPLER(5),                                   { STATE_SAMPLER(5),                                   sampler_texdim      }, WINED3D_GL_EXT_NONE             },
841     { STATE_SAMPLER(6),                                   { STATE_SAMPLER(6),                                   nvts_texdim         }, NV_TEXTURE_SHADER2              },
842     { STATE_SAMPLER(6),                                   { STATE_SAMPLER(6),                                   sampler_texdim      }, WINED3D_GL_EXT_NONE             },
843     { STATE_SAMPLER(7),                                   { STATE_SAMPLER(7),                                   nvts_texdim         }, NV_TEXTURE_SHADER2              },
844     { STATE_SAMPLER(7),                                   { STATE_SAMPLER(7),                                   sampler_texdim      }, WINED3D_GL_EXT_NONE             },
845     {0 /* Terminate */,                                   { 0,                                                  0                   }, WINED3D_GL_EXT_NONE             },
846 };
847
848 const struct fragment_pipeline nvts_fragment_pipeline = {
849     nvts_enable,
850     nvrc_fragment_get_caps,
851     nvrc_fragment_alloc,
852     nvrc_fragment_free,
853     nvts_color_fixup_supported,
854     nvrc_fragmentstate_template,
855     FALSE /* we cannot disable projected textures. The vertex pipe has to do it */
856 };
857
858 const struct fragment_pipeline nvrc_fragment_pipeline = {
859     nvrc_enable,
860     nvrc_fragment_get_caps,
861     nvrc_fragment_alloc,
862     nvrc_fragment_free,
863     nvts_color_fixup_supported,
864     nvrc_fragmentstate_template,
865     FALSE /* we cannot disable projected textures. The vertex pipe has to do it */
866 };