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