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