2 * Fixed function pipeline replacement using GL_ATI_fragment_shader
4 * Copyright 2008 Stefan Dösinger(for CodeWeavers)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wined3d_private.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader
);
29 WINE_DECLARE_DEBUG_CHANNEL(d3d
);
31 /* GL locking for state handlers is done by the caller. */
33 /* Some private defines, Constant associations, etc.
34 * Env bump matrix and per stage constant should be independent,
35 * a stage that bump maps can't read the per state constant
37 #define ATI_FFP_CONST_BUMPMAT(i) (GL_CON_0_ATI + i)
38 #define ATI_FFP_CONST_CONSTANT0 GL_CON_0_ATI
39 #define ATI_FFP_CONST_CONSTANT1 GL_CON_1_ATI
40 #define ATI_FFP_CONST_CONSTANT2 GL_CON_2_ATI
41 #define ATI_FFP_CONST_CONSTANT3 GL_CON_3_ATI
42 #define ATI_FFP_CONST_CONSTANT4 GL_CON_4_ATI
43 #define ATI_FFP_CONST_CONSTANT5 GL_CON_5_ATI
44 #define ATI_FFP_CONST_TFACTOR GL_CON_6_ATI
46 /* GL_ATI_fragment_shader specific fixed function pipeline description. "Inherits" from the common one */
49 struct ffp_frag_desc parent
;
51 unsigned int num_textures_used
;
54 struct atifs_private_data
56 struct wine_rb_tree fragment_shaders
; /* A rb-tree to track fragment pipeline replacement shaders */
59 static const char *debug_dstmod(GLuint mod
) {
61 case GL_NONE
: return "GL_NONE";
62 case GL_2X_BIT_ATI
: return "GL_2X_BIT_ATI";
63 case GL_4X_BIT_ATI
: return "GL_4X_BIT_ATI";
64 case GL_8X_BIT_ATI
: return "GL_8X_BIT_ATI";
65 case GL_HALF_BIT_ATI
: return "GL_HALF_BIT_ATI";
66 case GL_QUARTER_BIT_ATI
: return "GL_QUARTER_BIT_ATI";
67 case GL_EIGHTH_BIT_ATI
: return "GL_EIGHTH_BIT_ATI";
68 case GL_SATURATE_BIT_ATI
: return "GL_SATURATE_BIT_ATI";
69 default: return "Unexpected modifier\n";
73 static const char *debug_argmod(GLuint mod
) {
79 return "GL_2X_BIT_ATI";
81 return "GL_COMP_BIT_ATI";
82 case GL_NEGATE_BIT_ATI
:
83 return "GL_NEGATE_BIT_ATI";
85 return "GL_BIAS_BIT_ATI";
87 case GL_2X_BIT_ATI
| GL_COMP_BIT_ATI
:
88 return "GL_2X_BIT_ATI | GL_COMP_BIT_ATI";
89 case GL_2X_BIT_ATI
| GL_NEGATE_BIT_ATI
:
90 return "GL_2X_BIT_ATI | GL_NEGATE_BIT_ATI";
91 case GL_2X_BIT_ATI
| GL_BIAS_BIT_ATI
:
92 return "GL_2X_BIT_ATI | GL_BIAS_BIT_ATI";
93 case GL_COMP_BIT_ATI
| GL_NEGATE_BIT_ATI
:
94 return "GL_COMP_BIT_ATI | GL_NEGATE_BIT_ATI";
95 case GL_COMP_BIT_ATI
| GL_BIAS_BIT_ATI
:
96 return "GL_COMP_BIT_ATI | GL_BIAS_BIT_ATI";
97 case GL_NEGATE_BIT_ATI
| GL_BIAS_BIT_ATI
:
98 return "GL_NEGATE_BIT_ATI | GL_BIAS_BIT_ATI";
100 case GL_COMP_BIT_ATI
| GL_NEGATE_BIT_ATI
| GL_BIAS_BIT_ATI
:
101 return "GL_COMP_BIT_ATI | GL_NEGATE_BIT_ATI | GL_BIAS_BIT_ATI";
102 case GL_2X_BIT_ATI
| GL_NEGATE_BIT_ATI
| GL_BIAS_BIT_ATI
:
103 return "GL_2X_BIT_ATI | GL_NEGATE_BIT_ATI | GL_BIAS_BIT_ATI";
104 case GL_2X_BIT_ATI
| GL_COMP_BIT_ATI
| GL_BIAS_BIT_ATI
:
105 return "GL_2X_BIT_ATI | GL_COMP_BIT_ATI | GL_BIAS_BIT_ATI";
106 case GL_2X_BIT_ATI
| GL_COMP_BIT_ATI
| GL_NEGATE_BIT_ATI
:
107 return "GL_2X_BIT_ATI | GL_COMP_BIT_ATI | GL_NEGATE_BIT_ATI";
109 case GL_2X_BIT_ATI
| GL_COMP_BIT_ATI
| GL_NEGATE_BIT_ATI
| GL_BIAS_BIT_ATI
:
110 return "GL_2X_BIT_ATI | GL_COMP_BIT_ATI | GL_NEGATE_BIT_ATI | GL_BIAS_BIT_ATI";
113 return "Unexpected argmod combination\n";
116 static const char *debug_register(GLuint reg
) {
118 case GL_REG_0_ATI
: return "GL_REG_0_ATI";
119 case GL_REG_1_ATI
: return "GL_REG_1_ATI";
120 case GL_REG_2_ATI
: return "GL_REG_2_ATI";
121 case GL_REG_3_ATI
: return "GL_REG_3_ATI";
122 case GL_REG_4_ATI
: return "GL_REG_4_ATI";
123 case GL_REG_5_ATI
: return "GL_REG_5_ATI";
125 case GL_CON_0_ATI
: return "GL_CON_0_ATI";
126 case GL_CON_1_ATI
: return "GL_CON_1_ATI";
127 case GL_CON_2_ATI
: return "GL_CON_2_ATI";
128 case GL_CON_3_ATI
: return "GL_CON_3_ATI";
129 case GL_CON_4_ATI
: return "GL_CON_4_ATI";
130 case GL_CON_5_ATI
: return "GL_CON_5_ATI";
131 case GL_CON_6_ATI
: return "GL_CON_6_ATI";
132 case GL_CON_7_ATI
: return "GL_CON_7_ATI";
134 case GL_ZERO
: return "GL_ZERO";
135 case GL_ONE
: return "GL_ONE";
136 case GL_PRIMARY_COLOR
: return "GL_PRIMARY_COLOR";
137 case GL_SECONDARY_INTERPOLATOR_ATI
: return "GL_SECONDARY_INTERPOLATOR_ATI";
139 default: return "Unknown register\n";
143 static const char *debug_swizzle(GLuint swizzle
) {
145 case GL_SWIZZLE_STR_ATI
: return "GL_SWIZZLE_STR_ATI";
146 case GL_SWIZZLE_STQ_ATI
: return "GL_SWIZZLE_STQ_ATI";
147 case GL_SWIZZLE_STR_DR_ATI
: return "GL_SWIZZLE_STR_DR_ATI";
148 case GL_SWIZZLE_STQ_DQ_ATI
: return "GL_SWIZZLE_STQ_DQ_ATI";
149 default: return "unknown swizzle";
153 static const char *debug_rep(GLuint rep
) {
155 case GL_NONE
: return "GL_NONE";
156 case GL_RED
: return "GL_RED";
157 case GL_GREEN
: return "GL_GREEN";
158 case GL_BLUE
: return "GL_BLUE";
159 default: return "unknown argrep";
163 static const char *debug_op(GLuint op
) {
165 case GL_MOV_ATI
: return "GL_MOV_ATI";
166 case GL_ADD_ATI
: return "GL_ADD_ATI";
167 case GL_MUL_ATI
: return "GL_MUL_ATI";
168 case GL_SUB_ATI
: return "GL_SUB_ATI";
169 case GL_DOT3_ATI
: return "GL_DOT3_ATI";
170 case GL_DOT4_ATI
: return "GL_DOT4_ATI";
171 case GL_MAD_ATI
: return "GL_MAD_ATI";
172 case GL_LERP_ATI
: return "GL_LERP_ATI";
173 case GL_CND_ATI
: return "GL_CND_ATI";
174 case GL_CND0_ATI
: return "GL_CND0_ATI";
175 case GL_DOT2_ADD_ATI
: return "GL_DOT2_ADD_ATI";
176 default: return "unexpected op";
180 static const char *debug_mask(GLuint mask
) {
182 case GL_NONE
: return "GL_NONE";
183 case GL_RED_BIT_ATI
: return "GL_RED_BIT_ATI";
184 case GL_GREEN_BIT_ATI
: return "GL_GREEN_BIT_ATI";
185 case GL_BLUE_BIT_ATI
: return "GL_BLUE_BIT_ATI";
186 case GL_RED_BIT_ATI
| GL_GREEN_BIT_ATI
: return "GL_RED_BIT_ATI | GL_GREEN_BIT_ATI";
187 case GL_RED_BIT_ATI
| GL_BLUE_BIT_ATI
: return "GL_RED_BIT_ATI | GL_BLUE_BIT_ATI";
188 case GL_GREEN_BIT_ATI
| GL_BLUE_BIT_ATI
:return "GL_GREEN_BIT_ATI | GL_BLUE_BIT_ATI";
189 case GL_RED_BIT_ATI
| GL_GREEN_BIT_ATI
| GL_BLUE_BIT_ATI
:return "GL_RED_BIT_ATI | GL_GREEN_BIT_ATI | GL_BLUE_BIT_ATI";
190 default: return "Unexpected writemask";
194 static void wrap_op1(const struct wined3d_gl_info
*gl_info
, GLuint op
, GLuint dst
, GLuint dstMask
, GLuint dstMod
,
195 GLuint arg1
, GLuint arg1Rep
, GLuint arg1Mod
)
197 if(dstMask
== GL_ALPHA
) {
198 TRACE("glAlphaFragmentOp1ATI(%s, %s, %s, %s, %s, %s)\n", debug_op(op
), debug_register(dst
), debug_dstmod(dstMod
),
199 debug_register(arg1
), debug_rep(arg1Rep
), debug_argmod(arg1Mod
));
200 GL_EXTCALL(glAlphaFragmentOp1ATI(op
, dst
, dstMod
, arg1
, arg1Rep
, arg1Mod
));
202 TRACE("glColorFragmentOp1ATI(%s, %s, %s, %s, %s, %s, %s)\n", debug_op(op
), debug_register(dst
),
203 debug_mask(dstMask
), debug_dstmod(dstMod
),
204 debug_register(arg1
), debug_rep(arg1Rep
), debug_argmod(arg1Mod
));
205 GL_EXTCALL(glColorFragmentOp1ATI(op
, dst
, dstMask
, dstMod
, arg1
, arg1Rep
, arg1Mod
));
209 static void wrap_op2(const struct wined3d_gl_info
*gl_info
, GLuint op
, GLuint dst
, GLuint dstMask
, GLuint dstMod
,
210 GLuint arg1
, GLuint arg1Rep
, GLuint arg1Mod
, GLuint arg2
, GLuint arg2Rep
, GLuint arg2Mod
)
212 if(dstMask
== GL_ALPHA
) {
213 TRACE("glAlphaFragmentOp2ATI(%s, %s, %s, %s, %s, %s, %s, %s, %s)\n", debug_op(op
), debug_register(dst
), debug_dstmod(dstMod
),
214 debug_register(arg1
), debug_rep(arg1Rep
), debug_argmod(arg1Mod
),
215 debug_register(arg2
), debug_rep(arg2Rep
), debug_argmod(arg2Mod
));
216 GL_EXTCALL(glAlphaFragmentOp2ATI(op
, dst
, dstMod
, arg1
, arg1Rep
, arg1Mod
, arg2
, arg2Rep
, arg2Mod
));
218 TRACE("glColorFragmentOp2ATI(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)\n", debug_op(op
), debug_register(dst
),
219 debug_mask(dstMask
), debug_dstmod(dstMod
),
220 debug_register(arg1
), debug_rep(arg1Rep
), debug_argmod(arg1Mod
),
221 debug_register(arg2
), debug_rep(arg2Rep
), debug_argmod(arg2Mod
));
222 GL_EXTCALL(glColorFragmentOp2ATI(op
, dst
, dstMask
, dstMod
, arg1
, arg1Rep
, arg1Mod
, arg2
, arg2Rep
, arg2Mod
));
226 static void wrap_op3(const struct wined3d_gl_info
*gl_info
, GLuint op
, GLuint dst
, GLuint dstMask
, GLuint dstMod
,
227 GLuint arg1
, GLuint arg1Rep
, GLuint arg1Mod
, GLuint arg2
, GLuint arg2Rep
, GLuint arg2Mod
,
228 GLuint arg3
, GLuint arg3Rep
, GLuint arg3Mod
)
230 if(dstMask
== GL_ALPHA
) {
231 /* Leave some free space to fit "GL_NONE, " in to align most alpha and color op lines */
232 TRACE("glAlphaFragmentOp3ATI(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)\n", debug_op(op
), debug_register(dst
), debug_dstmod(dstMod
),
233 debug_register(arg1
), debug_rep(arg1Rep
), debug_argmod(arg1Mod
),
234 debug_register(arg2
), debug_rep(arg2Rep
), debug_argmod(arg2Mod
),
235 debug_register(arg3
), debug_rep(arg3Rep
), debug_argmod(arg3Mod
));
236 GL_EXTCALL(glAlphaFragmentOp3ATI(op
, dst
, dstMod
,
237 arg1
, arg1Rep
, arg1Mod
,
238 arg2
, arg2Rep
, arg2Mod
,
239 arg3
, arg3Rep
, arg3Mod
));
241 TRACE("glColorFragmentOp3ATI(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)\n", debug_op(op
), debug_register(dst
),
242 debug_mask(dstMask
), debug_dstmod(dstMod
),
243 debug_register(arg1
), debug_rep(arg1Rep
), debug_argmod(arg1Mod
),
244 debug_register(arg2
), debug_rep(arg2Rep
), debug_argmod(arg2Mod
),
245 debug_register(arg3
), debug_rep(arg3Rep
), debug_argmod(arg3Mod
));
246 GL_EXTCALL(glColorFragmentOp3ATI(op
, dst
, dstMask
, dstMod
,
247 arg1
, arg1Rep
, arg1Mod
,
248 arg2
, arg2Rep
, arg2Mod
,
249 arg3
, arg3Rep
, arg3Mod
));
253 static GLuint
register_for_arg(DWORD arg
, const struct wined3d_gl_info
*gl_info
,
254 unsigned int stage
, GLuint
*mod
, GLuint
*rep
, GLuint tmparg
)
258 if(mod
) *mod
= GL_NONE
;
259 if(arg
== ARG_UNUSED
)
261 if (rep
) *rep
= GL_NONE
;
262 return -1; /* This is the marker for unused registers */
265 switch(arg
& WINED3DTA_SELECTMASK
) {
266 case WINED3DTA_DIFFUSE
:
267 ret
= GL_PRIMARY_COLOR
;
270 case WINED3DTA_CURRENT
:
271 /* Note that using GL_REG_0_ATI for the passed on register is safe because
272 * texture0 is read at stage0, so in the worst case it is read in the
273 * instruction writing to reg0. Afterwards texture0 is not used any longer.
274 * If we're reading from current
276 ret
= stage
? GL_REG_0_ATI
: GL_PRIMARY_COLOR
;
279 case WINED3DTA_TEXTURE
:
280 ret
= GL_REG_0_ATI
+ stage
;
283 case WINED3DTA_TFACTOR
:
284 ret
= ATI_FFP_CONST_TFACTOR
;
287 case WINED3DTA_SPECULAR
:
288 ret
= GL_SECONDARY_INTERPOLATOR_ATI
;
295 case WINED3DTA_CONSTANT
:
296 FIXME("Unhandled source argument WINED3DTA_TEMP\n");
301 FIXME("Unknown source argument %d\n", arg
);
305 if(arg
& WINED3DTA_COMPLEMENT
) {
306 if(mod
) *mod
|= GL_COMP_BIT_ATI
;
308 if(arg
& WINED3DTA_ALPHAREPLICATE
) {
309 if(rep
) *rep
= GL_ALPHA
;
311 if(rep
) *rep
= GL_NONE
;
316 static GLuint
find_tmpreg(const struct texture_stage_op op
[MAX_TEXTURES
])
318 int lowest_read
= -1;
319 int lowest_write
= -1;
321 BOOL tex_used
[MAX_TEXTURES
];
323 memset(tex_used
, 0, sizeof(tex_used
));
324 for (i
= 0; i
< MAX_TEXTURES
; ++i
)
326 if (op
[i
].cop
== WINED3D_TOP_DISABLE
)
329 if(lowest_read
== -1 &&
330 (op
[i
].carg1
== WINED3DTA_TEMP
|| op
[i
].carg2
== WINED3DTA_TEMP
|| op
[i
].carg0
== WINED3DTA_TEMP
||
331 op
[i
].aarg1
== WINED3DTA_TEMP
|| op
[i
].aarg2
== WINED3DTA_TEMP
|| op
[i
].aarg0
== WINED3DTA_TEMP
)) {
335 if(lowest_write
== -1 && op
[i
].dst
== tempreg
) {
339 if(op
[i
].carg1
== WINED3DTA_TEXTURE
|| op
[i
].carg2
== WINED3DTA_TEXTURE
|| op
[i
].carg0
== WINED3DTA_TEXTURE
||
340 op
[i
].aarg1
== WINED3DTA_TEXTURE
|| op
[i
].aarg2
== WINED3DTA_TEXTURE
|| op
[i
].aarg0
== WINED3DTA_TEXTURE
) {
345 /* Temp reg not read? We don't need it, return GL_NONE */
346 if(lowest_read
== -1) return GL_NONE
;
348 if(lowest_write
>= lowest_read
) {
349 FIXME("Temp register read before being written\n");
352 if(lowest_write
== -1) {
353 /* This needs a test. Maybe we are supposed to return 0.0/0.0/0.0/0.0, or fail drawprim, or whatever */
354 FIXME("Temp register read without being written\n");
356 } else if(lowest_write
>= 1) {
357 /* If we're writing to the temp reg at earliest in stage 1, we can use register 1 for the temp result.
358 * there may be texture data stored in reg 1, but we do not need it any longer since stage 1 already
363 /* Search for a free texture register. We have 6 registers available. GL_REG_0_ATI is already used
364 * for the regular result
366 for(i
= 1; i
< 6; i
++) {
368 return GL_REG_0_ATI
+ i
;
371 /* What to do here? Report it in ValidateDevice? */
372 FIXME("Could not find a register for the temporary register\n");
377 static GLuint
gen_ati_shader(const struct texture_stage_op op
[MAX_TEXTURES
], const struct wined3d_gl_info
*gl_info
)
379 GLuint ret
= GL_EXTCALL(glGenFragmentShadersATI(1));
381 GLuint arg0
, arg1
, arg2
, extrarg
;
382 GLuint dstmod
, argmod0
, argmod1
, argmod2
, argmodextra
;
383 GLuint rep0
, rep1
, rep2
;
385 GLuint tmparg
= find_tmpreg(op
);
389 ERR("Failed to generate a GL_ATI_fragment_shader shader id\n");
392 GL_EXTCALL(glBindFragmentShaderATI(ret
));
393 checkGLcall("GL_EXTCALL(glBindFragmentShaderATI(ret))");
395 TRACE("glBeginFragmentShaderATI()\n");
396 GL_EXTCALL(glBeginFragmentShaderATI());
397 checkGLcall("GL_EXTCALL(glBeginFragmentShaderATI())");
399 /* Pass 1: Generate sampling instructions for perturbation maps */
400 for (stage
= 0; stage
< gl_info
->limits
.textures
; ++stage
)
402 if (op
[stage
].cop
== WINED3D_TOP_DISABLE
)
404 if (op
[stage
].cop
!= WINED3D_TOP_BUMPENVMAP
405 && op
[stage
].cop
!= WINED3D_TOP_BUMPENVMAP_LUMINANCE
)
408 TRACE("glSampleMapATI(GL_REG_%d_ATI, GL_TEXTURE_%d_ARB, GL_SWIZZLE_STR_ATI)\n",
410 GL_EXTCALL(glSampleMapATI(GL_REG_0_ATI
+ stage
,
411 GL_TEXTURE0_ARB
+ stage
,
412 GL_SWIZZLE_STR_ATI
));
413 if(op
[stage
+ 1].projected
== proj_none
) {
414 swizzle
= GL_SWIZZLE_STR_ATI
;
415 } else if(op
[stage
+ 1].projected
== proj_count4
) {
416 swizzle
= GL_SWIZZLE_STQ_DQ_ATI
;
418 swizzle
= GL_SWIZZLE_STR_DR_ATI
;
420 TRACE("glPassTexCoordATI(GL_REG_%d_ATI, GL_TEXTURE_%d_ARB, %s)\n",
421 stage
+ 1, stage
+ 1, debug_swizzle(swizzle
));
422 GL_EXTCALL(glPassTexCoordATI(GL_REG_0_ATI
+ stage
+ 1,
423 GL_TEXTURE0_ARB
+ stage
+ 1,
427 /* Pass 2: Generate perturbation calculations */
428 for (stage
= 0; stage
< gl_info
->limits
.textures
; ++stage
)
430 GLuint argmodextra_x
, argmodextra_y
;
431 struct color_fixup_desc fixup
;
433 if (op
[stage
].cop
== WINED3D_TOP_DISABLE
)
435 if (op
[stage
].cop
!= WINED3D_TOP_BUMPENVMAP
436 && op
[stage
].cop
!= WINED3D_TOP_BUMPENVMAP_LUMINANCE
)
439 fixup
= op
[stage
].color_fixup
;
440 if (fixup
.x_source
!= CHANNEL_SOURCE_X
|| fixup
.y_source
!= CHANNEL_SOURCE_Y
)
442 FIXME("Swizzles not implemented\n");
443 argmodextra_x
= GL_NONE
;
444 argmodextra_y
= GL_NONE
;
448 /* Nice thing, we get the color correction for free :-) */
449 argmodextra_x
= fixup
.x_sign_fixup
? GL_2X_BIT_ATI
| GL_BIAS_BIT_ATI
: GL_NONE
;
450 argmodextra_y
= fixup
.y_sign_fixup
? GL_2X_BIT_ATI
| GL_BIAS_BIT_ATI
: GL_NONE
;
453 wrap_op3(gl_info
, GL_DOT2_ADD_ATI
, GL_REG_0_ATI
+ stage
+ 1, GL_RED_BIT_ATI
, GL_NONE
,
454 GL_REG_0_ATI
+ stage
, GL_NONE
, argmodextra_x
,
455 ATI_FFP_CONST_BUMPMAT(stage
), GL_NONE
, GL_2X_BIT_ATI
| GL_BIAS_BIT_ATI
,
456 GL_REG_0_ATI
+ stage
+ 1, GL_RED
, GL_NONE
);
458 /* Don't use GL_DOT2_ADD_ATI here because we cannot configure it to read the blue and alpha
459 * component of the bump matrix. Instead do this with two MADs:
461 * coord.a = tex.r * bump.b + coord.g
462 * coord.g = tex.g * bump.a + coord.a
464 * The first instruction writes to alpha so it can be coissued with the above DOT2_ADD.
465 * coord.a is unused. If the perturbed texture is projected, this was already handled
466 * in the glPassTexCoordATI above.
468 wrap_op3(gl_info
, GL_MAD_ATI
, GL_REG_0_ATI
+ stage
+ 1, GL_ALPHA
, GL_NONE
,
469 GL_REG_0_ATI
+ stage
, GL_RED
, argmodextra_y
,
470 ATI_FFP_CONST_BUMPMAT(stage
), GL_BLUE
, GL_NONE
,
471 GL_REG_0_ATI
+ stage
+ 1, GL_GREEN
, GL_NONE
);
472 wrap_op3(gl_info
, GL_MAD_ATI
, GL_REG_0_ATI
+ stage
+ 1, GL_GREEN_BIT_ATI
, GL_NONE
,
473 GL_REG_0_ATI
+ stage
, GL_GREEN
, argmodextra_y
,
474 ATI_FFP_CONST_BUMPMAT(stage
), GL_ALPHA
, GL_NONE
,
475 GL_REG_0_ATI
+ stage
+ 1, GL_ALPHA
, GL_NONE
);
478 /* Pass 3: Generate sampling instructions for regular textures */
479 for (stage
= 0; stage
< gl_info
->limits
.textures
; ++stage
)
481 if (op
[stage
].cop
== WINED3D_TOP_DISABLE
)
484 if(op
[stage
].projected
== proj_none
) {
485 swizzle
= GL_SWIZZLE_STR_ATI
;
486 } else if(op
[stage
].projected
== proj_count3
) {
487 swizzle
= GL_SWIZZLE_STR_DR_ATI
;
489 swizzle
= GL_SWIZZLE_STQ_DQ_ATI
;
492 if ((op
[stage
].carg0
& WINED3DTA_SELECTMASK
) == WINED3DTA_TEXTURE
493 || (op
[stage
].carg1
& WINED3DTA_SELECTMASK
) == WINED3DTA_TEXTURE
494 || (op
[stage
].carg2
& WINED3DTA_SELECTMASK
) == WINED3DTA_TEXTURE
495 || (op
[stage
].aarg0
& WINED3DTA_SELECTMASK
) == WINED3DTA_TEXTURE
496 || (op
[stage
].aarg1
& WINED3DTA_SELECTMASK
) == WINED3DTA_TEXTURE
497 || (op
[stage
].aarg2
& WINED3DTA_SELECTMASK
) == WINED3DTA_TEXTURE
498 || op
[stage
].cop
== WINED3D_TOP_BLEND_TEXTURE_ALPHA
)
501 && (op
[stage
- 1].cop
== WINED3D_TOP_BUMPENVMAP
502 || op
[stage
- 1].cop
== WINED3D_TOP_BUMPENVMAP_LUMINANCE
))
504 TRACE("glSampleMapATI(GL_REG_%d_ATI, GL_REG_%d_ATI, GL_SWIZZLE_STR_ATI)\n",
506 GL_EXTCALL(glSampleMapATI(GL_REG_0_ATI
+ stage
,
507 GL_REG_0_ATI
+ stage
,
508 GL_SWIZZLE_STR_ATI
));
510 TRACE("glSampleMapATI(GL_REG_%d_ATI, GL_TEXTURE_%d_ARB, %s)\n",
511 stage
, stage
, debug_swizzle(swizzle
));
512 GL_EXTCALL(glSampleMapATI(GL_REG_0_ATI
+ stage
,
513 GL_TEXTURE0_ARB
+ stage
,
519 /* Pass 4: Generate the arithmetic instructions */
520 for (stage
= 0; stage
< MAX_TEXTURES
; ++stage
)
522 if (op
[stage
].cop
== WINED3D_TOP_DISABLE
)
526 /* Handle complete texture disabling gracefully */
527 wrap_op1(gl_info
, GL_MOV_ATI
, GL_REG_0_ATI
, GL_NONE
, GL_NONE
,
528 GL_PRIMARY_COLOR
, GL_NONE
, GL_NONE
);
529 wrap_op1(gl_info
, GL_MOV_ATI
, GL_REG_0_ATI
, GL_ALPHA
, GL_NONE
,
530 GL_PRIMARY_COLOR
, GL_NONE
, GL_NONE
);
535 if(op
[stage
].dst
== tempreg
) {
536 /* If we're writing to D3DTA_TEMP, but never reading from it we don't have to write there in the first place.
537 * skip the entire stage, this saves some GPU time
539 if(tmparg
== GL_NONE
) continue;
543 dstreg
= GL_REG_0_ATI
;
546 arg0
= register_for_arg(op
[stage
].carg0
, gl_info
, stage
, &argmod0
, &rep0
, tmparg
);
547 arg1
= register_for_arg(op
[stage
].carg1
, gl_info
, stage
, &argmod1
, &rep1
, tmparg
);
548 arg2
= register_for_arg(op
[stage
].carg2
, gl_info
, stage
, &argmod2
, &rep2
, tmparg
);
550 argmodextra
= GL_NONE
;
553 switch (op
[stage
].cop
)
555 case WINED3D_TOP_SELECT_ARG2
:
560 case WINED3D_TOP_SELECT_ARG1
:
561 wrap_op1(gl_info
, GL_MOV_ATI
, dstreg
, GL_NONE
, GL_NONE
,
562 arg1
, rep1
, argmod1
);
565 case WINED3D_TOP_MODULATE_4X
:
566 if(dstmod
== GL_NONE
) dstmod
= GL_4X_BIT_ATI
;
568 case WINED3D_TOP_MODULATE_2X
:
569 if(dstmod
== GL_NONE
) dstmod
= GL_2X_BIT_ATI
;
570 dstmod
|= GL_SATURATE_BIT_ATI
;
572 case WINED3D_TOP_MODULATE
:
573 wrap_op2(gl_info
, GL_MUL_ATI
, dstreg
, GL_NONE
, dstmod
,
575 arg2
, rep2
, argmod2
);
578 case WINED3D_TOP_ADD_SIGNED_2X
:
579 dstmod
= GL_2X_BIT_ATI
;
581 case WINED3D_TOP_ADD_SIGNED
:
582 argmodextra
= GL_BIAS_BIT_ATI
;
584 case WINED3D_TOP_ADD
:
585 dstmod
|= GL_SATURATE_BIT_ATI
;
586 wrap_op2(gl_info
, GL_ADD_ATI
, GL_REG_0_ATI
, GL_NONE
, dstmod
,
588 arg2
, rep2
, argmodextra
| argmod2
);
591 case WINED3D_TOP_SUBTRACT
:
592 dstmod
|= GL_SATURATE_BIT_ATI
;
593 wrap_op2(gl_info
, GL_SUB_ATI
, dstreg
, GL_NONE
, dstmod
,
595 arg2
, rep2
, argmod2
);
598 case WINED3D_TOP_ADD_SMOOTH
:
599 argmodextra
= argmod1
& GL_COMP_BIT_ATI
? argmod1
& ~GL_COMP_BIT_ATI
: argmod1
| GL_COMP_BIT_ATI
;
600 /* Dst = arg1 + * arg2(1 -arg 1)
601 * = arg2 * (1 - arg1) + arg1
603 wrap_op3(gl_info
, GL_MAD_ATI
, dstreg
, GL_NONE
, GL_SATURATE_BIT_ATI
,
605 arg1
, rep1
, argmodextra
,
606 arg1
, rep1
, argmod1
);
609 case WINED3D_TOP_BLEND_CURRENT_ALPHA
:
610 if (extrarg
== GL_NONE
)
611 extrarg
= register_for_arg(WINED3DTA_CURRENT
, gl_info
, stage
, NULL
, NULL
, -1);
613 case WINED3D_TOP_BLEND_FACTOR_ALPHA
:
614 if (extrarg
== GL_NONE
)
615 extrarg
= register_for_arg(WINED3DTA_TFACTOR
, gl_info
, stage
, NULL
, NULL
, -1);
617 case WINED3D_TOP_BLEND_TEXTURE_ALPHA
:
618 if (extrarg
== GL_NONE
)
619 extrarg
= register_for_arg(WINED3DTA_TEXTURE
, gl_info
, stage
, NULL
, NULL
, -1);
621 case WINED3D_TOP_BLEND_DIFFUSE_ALPHA
:
622 if (extrarg
== GL_NONE
)
623 extrarg
= register_for_arg(WINED3DTA_DIFFUSE
, gl_info
, stage
, NULL
, NULL
, -1);
624 wrap_op3(gl_info
, GL_LERP_ATI
, dstreg
, GL_NONE
, GL_NONE
,
625 extrarg
, GL_ALPHA
, GL_NONE
,
627 arg2
, rep2
, argmod2
);
630 case WINED3D_TOP_BLEND_TEXTURE_ALPHA_PM
:
631 arg0
= register_for_arg(WINED3DTA_TEXTURE
, gl_info
, stage
, NULL
, NULL
, -1);
632 wrap_op3(gl_info
, GL_MAD_ATI
, dstreg
, GL_NONE
, GL_NONE
,
634 arg0
, GL_ALPHA
, GL_COMP_BIT_ATI
,
635 arg1
, rep1
, argmod1
);
638 /* D3DTOP_PREMODULATE ???? */
640 case WINED3D_TOP_MODULATE_INVALPHA_ADD_COLOR
:
641 argmodextra
= argmod1
& GL_COMP_BIT_ATI
? argmod1
& ~GL_COMP_BIT_ATI
: argmod1
| GL_COMP_BIT_ATI
;
643 case WINED3D_TOP_MODULATE_ALPHA_ADD_COLOR
:
645 argmodextra
= argmod1
;
646 wrap_op3(gl_info
, GL_MAD_ATI
, dstreg
, GL_NONE
, GL_SATURATE_BIT_ATI
,
648 arg1
, GL_ALPHA
, argmodextra
,
649 arg1
, rep1
, argmod1
);
652 case WINED3D_TOP_MODULATE_INVCOLOR_ADD_ALPHA
:
653 argmodextra
= argmod1
& GL_COMP_BIT_ATI
? argmod1
& ~GL_COMP_BIT_ATI
: argmod1
| GL_COMP_BIT_ATI
;
655 case WINED3D_TOP_MODULATE_COLOR_ADD_ALPHA
:
657 argmodextra
= argmod1
;
658 wrap_op3(gl_info
, GL_MAD_ATI
, dstreg
, GL_NONE
, GL_SATURATE_BIT_ATI
,
660 arg1
, rep1
, argmodextra
,
661 arg1
, GL_ALPHA
, argmod1
);
664 case WINED3D_TOP_DOTPRODUCT3
:
665 wrap_op2(gl_info
, GL_DOT3_ATI
, dstreg
, GL_NONE
, GL_4X_BIT_ATI
| GL_SATURATE_BIT_ATI
,
666 arg1
, rep1
, argmod1
| GL_BIAS_BIT_ATI
,
667 arg2
, rep2
, argmod2
| GL_BIAS_BIT_ATI
);
670 case WINED3D_TOP_MULTIPLY_ADD
:
671 wrap_op3(gl_info
, GL_MAD_ATI
, dstreg
, GL_NONE
, GL_SATURATE_BIT_ATI
,
674 arg0
, rep0
, argmod0
);
677 case WINED3D_TOP_LERP
:
678 wrap_op3(gl_info
, GL_LERP_ATI
, dstreg
, GL_NONE
, GL_NONE
,
681 arg2
, rep2
, argmod2
);
684 case WINED3D_TOP_BUMPENVMAP
:
685 case WINED3D_TOP_BUMPENVMAP_LUMINANCE
:
686 /* Those are handled in the first pass of the shader(generation pass 1 and 2) already */
689 default: FIXME("Unhandled color operation %d on stage %d\n", op
[stage
].cop
, stage
);
692 arg0
= register_for_arg(op
[stage
].aarg0
, gl_info
, stage
, &argmod0
, NULL
, tmparg
);
693 arg1
= register_for_arg(op
[stage
].aarg1
, gl_info
, stage
, &argmod1
, NULL
, tmparg
);
694 arg2
= register_for_arg(op
[stage
].aarg2
, gl_info
, stage
, &argmod2
, NULL
, tmparg
);
696 argmodextra
= GL_NONE
;
699 switch (op
[stage
].aop
)
701 case WINED3D_TOP_DISABLE
:
702 /* Get the primary color to the output if on stage 0, otherwise leave register 0 untouched */
705 wrap_op1(gl_info
, GL_MOV_ATI
, GL_REG_0_ATI
, GL_ALPHA
, GL_NONE
,
706 GL_PRIMARY_COLOR
, GL_NONE
, GL_NONE
);
710 case WINED3D_TOP_SELECT_ARG2
:
714 case WINED3D_TOP_SELECT_ARG1
:
715 wrap_op1(gl_info
, GL_MOV_ATI
, dstreg
, GL_ALPHA
, GL_NONE
,
716 arg1
, GL_NONE
, argmod1
);
719 case WINED3D_TOP_MODULATE_4X
:
720 if (dstmod
== GL_NONE
)
721 dstmod
= GL_4X_BIT_ATI
;
723 case WINED3D_TOP_MODULATE_2X
:
724 if (dstmod
== GL_NONE
)
725 dstmod
= GL_2X_BIT_ATI
;
726 dstmod
|= GL_SATURATE_BIT_ATI
;
728 case WINED3D_TOP_MODULATE
:
729 wrap_op2(gl_info
, GL_MUL_ATI
, dstreg
, GL_ALPHA
, dstmod
,
730 arg1
, GL_NONE
, argmod1
,
731 arg2
, GL_NONE
, argmod2
);
734 case WINED3D_TOP_ADD_SIGNED_2X
:
735 dstmod
= GL_2X_BIT_ATI
;
737 case WINED3D_TOP_ADD_SIGNED
:
738 argmodextra
= GL_BIAS_BIT_ATI
;
740 case WINED3D_TOP_ADD
:
741 dstmod
|= GL_SATURATE_BIT_ATI
;
742 wrap_op2(gl_info
, GL_ADD_ATI
, dstreg
, GL_ALPHA
, dstmod
,
743 arg1
, GL_NONE
, argmod1
,
744 arg2
, GL_NONE
, argmodextra
| argmod2
);
747 case WINED3D_TOP_SUBTRACT
:
748 dstmod
|= GL_SATURATE_BIT_ATI
;
749 wrap_op2(gl_info
, GL_SUB_ATI
, dstreg
, GL_ALPHA
, dstmod
,
750 arg1
, GL_NONE
, argmod1
,
751 arg2
, GL_NONE
, argmod2
);
754 case WINED3D_TOP_ADD_SMOOTH
:
755 argmodextra
= argmod1
& GL_COMP_BIT_ATI
? argmod1
& ~GL_COMP_BIT_ATI
: argmod1
| GL_COMP_BIT_ATI
;
756 /* Dst = arg1 + * arg2(1 -arg 1)
757 * = arg2 * (1 - arg1) + arg1
759 wrap_op3(gl_info
, GL_MAD_ATI
, dstreg
, GL_ALPHA
, GL_SATURATE_BIT_ATI
,
760 arg2
, GL_NONE
, argmod2
,
761 arg1
, GL_NONE
, argmodextra
,
762 arg1
, GL_NONE
, argmod1
);
765 case WINED3D_TOP_BLEND_CURRENT_ALPHA
:
766 if (extrarg
== GL_NONE
)
767 extrarg
= register_for_arg(WINED3DTA_CURRENT
, gl_info
, stage
, NULL
, NULL
, -1);
769 case WINED3D_TOP_BLEND_FACTOR_ALPHA
:
770 if (extrarg
== GL_NONE
)
771 extrarg
= register_for_arg(WINED3DTA_TFACTOR
, gl_info
, stage
, NULL
, NULL
, -1);
773 case WINED3D_TOP_BLEND_TEXTURE_ALPHA
:
774 if (extrarg
== GL_NONE
)
775 extrarg
= register_for_arg(WINED3DTA_TEXTURE
, gl_info
, stage
, NULL
, NULL
, -1);
777 case WINED3D_TOP_BLEND_DIFFUSE_ALPHA
:
778 if (extrarg
== GL_NONE
)
779 extrarg
= register_for_arg(WINED3DTA_DIFFUSE
, gl_info
, stage
, NULL
, NULL
, -1);
780 wrap_op3(gl_info
, GL_LERP_ATI
, dstreg
, GL_ALPHA
, GL_NONE
,
781 extrarg
, GL_ALPHA
, GL_NONE
,
782 arg1
, GL_NONE
, argmod1
,
783 arg2
, GL_NONE
, argmod2
);
786 case WINED3D_TOP_BLEND_TEXTURE_ALPHA_PM
:
787 arg0
= register_for_arg(WINED3DTA_TEXTURE
, gl_info
, stage
, NULL
, NULL
, -1);
788 wrap_op3(gl_info
, GL_MAD_ATI
, dstreg
, GL_ALPHA
, GL_NONE
,
789 arg2
, GL_NONE
, argmod2
,
790 arg0
, GL_ALPHA
, GL_COMP_BIT_ATI
,
791 arg1
, GL_NONE
, argmod1
);
794 /* D3DTOP_PREMODULATE ???? */
796 case WINED3D_TOP_DOTPRODUCT3
:
797 wrap_op2(gl_info
, GL_DOT3_ATI
, dstreg
, GL_ALPHA
, GL_4X_BIT_ATI
| GL_SATURATE_BIT_ATI
,
798 arg1
, GL_NONE
, argmod1
| GL_BIAS_BIT_ATI
,
799 arg2
, GL_NONE
, argmod2
| GL_BIAS_BIT_ATI
);
802 case WINED3D_TOP_MULTIPLY_ADD
:
803 wrap_op3(gl_info
, GL_MAD_ATI
, dstreg
, GL_ALPHA
, GL_SATURATE_BIT_ATI
,
804 arg1
, GL_NONE
, argmod1
,
805 arg2
, GL_NONE
, argmod2
,
806 arg0
, GL_NONE
, argmod0
);
809 case WINED3D_TOP_LERP
:
810 wrap_op3(gl_info
, GL_LERP_ATI
, dstreg
, GL_ALPHA
, GL_SATURATE_BIT_ATI
,
811 arg1
, GL_NONE
, argmod1
,
812 arg2
, GL_NONE
, argmod2
,
813 arg0
, GL_NONE
, argmod0
);
816 case WINED3D_TOP_MODULATE_INVALPHA_ADD_COLOR
:
817 case WINED3D_TOP_MODULATE_ALPHA_ADD_COLOR
:
818 case WINED3D_TOP_MODULATE_COLOR_ADD_ALPHA
:
819 case WINED3D_TOP_MODULATE_INVCOLOR_ADD_ALPHA
:
820 case WINED3D_TOP_BUMPENVMAP
:
821 case WINED3D_TOP_BUMPENVMAP_LUMINANCE
:
822 ERR("Application uses an invalid alpha operation\n");
825 default: FIXME("Unhandled alpha operation %d on stage %d\n", op
[stage
].aop
, stage
);
829 TRACE("glEndFragmentShaderATI()\n");
830 GL_EXTCALL(glEndFragmentShaderATI());
831 checkGLcall("GL_EXTCALL(glEndFragmentShaderATI())");
835 static void set_tex_op_atifs(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
837 const struct wined3d_device
*device
= context
->swapchain
->device
;
838 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
839 const struct atifs_ffp_desc
*desc
;
840 struct ffp_frag_settings settings
;
841 struct atifs_private_data
*priv
= device
->fragment_priv
;
845 gen_ffp_frag_op(device
, state
, &settings
, TRUE
);
846 desc
= (const struct atifs_ffp_desc
*)find_ffp_frag_shader(&priv
->fragment_shaders
, &settings
);
848 struct atifs_ffp_desc
*new_desc
= HeapAlloc(GetProcessHeap(), 0, sizeof(*new_desc
));
851 ERR("Out of memory\n");
854 new_desc
->num_textures_used
= 0;
855 for (i
= 0; i
< gl_info
->limits
.texture_stages
; ++i
)
857 if (settings
.op
[i
].cop
== WINED3D_TOP_DISABLE
)
859 new_desc
->num_textures_used
= i
;
862 memcpy(&new_desc
->parent
.settings
, &settings
, sizeof(settings
));
863 new_desc
->shader
= gen_ati_shader(settings
.op
, gl_info
);
864 add_ffp_frag_shader(&priv
->fragment_shaders
, &new_desc
->parent
);
865 TRACE("Allocated fixed function replacement shader descriptor %p\n", new_desc
);
869 /* GL_ATI_fragment_shader depends on the GL_TEXTURE_xD enable settings. Update the texture stages
870 * used by this shader
872 for (i
= 0; i
< desc
->num_textures_used
; ++i
)
874 mapped_stage
= device
->texUnitMap
[i
];
875 if (mapped_stage
!= WINED3D_UNMAPPED_STAGE
)
877 context_active_texture(context
, gl_info
, mapped_stage
);
878 texture_activate_dimensions(state
->textures
[i
], gl_info
);
882 GL_EXTCALL(glBindFragmentShaderATI(desc
->shader
));
885 static void state_texfactor_atifs(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
887 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
890 D3DCOLORTOGLFLOAT4(state
->render_states
[WINED3D_RS_TEXTUREFACTOR
], col
);
891 GL_EXTCALL(glSetFragmentShaderConstantATI(ATI_FFP_CONST_TFACTOR
, col
));
892 checkGLcall("glSetFragmentShaderConstantATI(ATI_FFP_CONST_TFACTOR, col)");
895 static void set_bumpmat(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
897 DWORD stage
= (state_id
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
898 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
901 mat
[0][0] = *((float *)&state
->texture_states
[stage
][WINED3D_TSS_BUMPENV_MAT00
]);
902 mat
[1][0] = *((float *)&state
->texture_states
[stage
][WINED3D_TSS_BUMPENV_MAT01
]);
903 mat
[0][1] = *((float *)&state
->texture_states
[stage
][WINED3D_TSS_BUMPENV_MAT10
]);
904 mat
[1][1] = *((float *)&state
->texture_states
[stage
][WINED3D_TSS_BUMPENV_MAT11
]);
905 /* GL_ATI_fragment_shader allows only constants from 0.0 to 1.0, but the bumpmat
906 * constants can be in any range. While they should stay between [-1.0 and 1.0] because
907 * Shader Model 1.x pixel shaders are clamped to that range negative values are used occasionally,
908 * for example by our d3d9 test. So to get negative values scale -1;1 to 0;1 and undo that in the
909 * shader(it is free). This might potentially reduce precision. However, if the hardware does
910 * support proper floats it shouldn't, and if it doesn't we can't get anything better anyway
912 mat
[0][0] = (mat
[0][0] + 1.0f
) * 0.5f
;
913 mat
[1][0] = (mat
[1][0] + 1.0f
) * 0.5f
;
914 mat
[0][1] = (mat
[0][1] + 1.0f
) * 0.5f
;
915 mat
[1][1] = (mat
[1][1] + 1.0f
) * 0.5f
;
916 GL_EXTCALL(glSetFragmentShaderConstantATI(ATI_FFP_CONST_BUMPMAT(stage
), (float *) mat
));
917 checkGLcall("glSetFragmentShaderConstantATI(ATI_FFP_CONST_BUMPMAT(stage), mat)");
920 static void textransform(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
922 if (!isStateDirty(context
, STATE_PIXELSHADER
))
923 set_tex_op_atifs(context
, state
, state_id
);
926 static void atifs_apply_pixelshader(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
928 const struct wined3d_device
*device
= context
->swapchain
->device
;
929 BOOL use_vshader
= use_vs(state
);
931 context
->last_was_pshader
= use_ps(state
);
932 /* The ATIFS code does not support pixel shaders currently, but we have to
933 * provide a state handler to call shader_select to select a vertex shader
934 * if one is applied because the vertex shader state may defer calling the
935 * shader backend if the pshader state is dirty.
937 * In theory the application should not be able to mark the pixel shader
938 * dirty because it cannot create a shader, and thus has no way to set the
939 * state to something != NULL. However, a different pipeline part may link
940 * a different state to its pixelshader handler, thus a pshader state
941 * exists and can be dirtified. Also the pshader is always dirtified at
942 * startup, and blitting disables all shaders and dirtifies all shader
943 * states. If atifs can deal with this it keeps the rest of the code
945 if (!isStateDirty(context
, context
->state_table
[STATE_VSHADER
].representative
))
947 device
->shader_backend
->shader_select(context
, FALSE
, use_vshader
);
949 if (!isStateDirty(context
, STATE_VERTEXSHADERCONSTANT
) && use_vshader
)
950 context_apply_state(context
, state
, STATE_VERTEXSHADERCONSTANT
);
954 static void atifs_srgbwriteenable(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
956 if (state
->render_states
[WINED3D_RS_SRGBWRITEENABLE
])
957 WARN("sRGB writes are not supported by this fragment pipe.\n");
960 static const struct StateEntryTemplate atifs_fragmentstate_template
[] = {
961 {STATE_RENDER(WINED3D_RS_TEXTUREFACTOR
), { STATE_RENDER(WINED3D_RS_TEXTUREFACTOR
), state_texfactor_atifs
}, WINED3D_GL_EXT_NONE
},
962 {STATE_RENDER(WINED3D_RS_FOGCOLOR
), { STATE_RENDER(WINED3D_RS_FOGCOLOR
), state_fogcolor
}, WINED3D_GL_EXT_NONE
},
963 {STATE_RENDER(WINED3D_RS_FOGDENSITY
), { STATE_RENDER(WINED3D_RS_FOGDENSITY
), state_fogdensity
}, WINED3D_GL_EXT_NONE
},
964 {STATE_RENDER(WINED3D_RS_FOGENABLE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), state_fog_fragpart
}, WINED3D_GL_EXT_NONE
},
965 {STATE_RENDER(WINED3D_RS_FOGTABLEMODE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
966 {STATE_RENDER(WINED3D_RS_FOGVERTEXMODE
), { STATE_RENDER(WINED3D_RS_FOGENABLE
), NULL
}, WINED3D_GL_EXT_NONE
},
967 {STATE_RENDER(WINED3D_RS_FOGSTART
), { STATE_RENDER(WINED3D_RS_FOGSTART
), state_fogstartend
}, WINED3D_GL_EXT_NONE
},
968 {STATE_RENDER(WINED3D_RS_FOGEND
), { STATE_RENDER(WINED3D_RS_FOGSTART
), NULL
}, WINED3D_GL_EXT_NONE
},
969 {STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE
), { STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE
), atifs_srgbwriteenable
}, WINED3D_GL_EXT_NONE
},
970 {STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), set_tex_op_atifs
}, WINED3D_GL_EXT_NONE
},
971 {STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
972 {STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
973 {STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
974 {STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
975 {STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
976 {STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
977 {STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
978 {STATE_TEXTURESTAGE(0, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
979 {STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), set_bumpmat
}, WINED3D_GL_EXT_NONE
},
980 {STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
981 {STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
982 {STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
983 {STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
984 {STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
985 {STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
986 {STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
987 {STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
988 {STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
989 {STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
990 {STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
991 {STATE_TEXTURESTAGE(1, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
992 {STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), set_bumpmat
}, WINED3D_GL_EXT_NONE
},
993 {STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
994 {STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
995 {STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
996 {STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
997 {STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
998 {STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
999 {STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1000 {STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1001 {STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1002 {STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1003 {STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1004 {STATE_TEXTURESTAGE(2, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1005 {STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), set_bumpmat
}, WINED3D_GL_EXT_NONE
},
1006 {STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
1007 {STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
1008 {STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
1009 {STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1010 {STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1011 {STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1012 {STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1013 {STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1014 {STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1015 {STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1016 {STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1017 {STATE_TEXTURESTAGE(3, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1018 {STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), set_bumpmat
}, WINED3D_GL_EXT_NONE
},
1019 {STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
1020 {STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
1021 {STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
1022 {STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1023 {STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1024 {STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1025 {STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1026 {STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1027 {STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1028 {STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1029 {STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1030 {STATE_TEXTURESTAGE(4, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1031 {STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), set_bumpmat
}, WINED3D_GL_EXT_NONE
},
1032 {STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
1033 {STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
1034 {STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
1035 {STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1036 {STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1037 {STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1038 {STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1039 {STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1040 {STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1041 {STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1042 {STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1043 {STATE_TEXTURESTAGE(5, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1044 {STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), set_bumpmat
}, WINED3D_GL_EXT_NONE
},
1045 {STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
1046 {STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
1047 {STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
1048 {STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1049 {STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1050 {STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1051 {STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1052 {STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1053 {STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1054 {STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1055 {STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1056 {STATE_TEXTURESTAGE(6, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1057 {STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), set_bumpmat
}, WINED3D_GL_EXT_NONE
},
1058 {STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
1059 {STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
1060 {STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
1061 {STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1062 {STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_ARG1
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1063 {STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_ARG2
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1064 {STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_ARG0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1065 {STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1066 {STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_ARG1
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1067 {STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_ARG2
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1068 {STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_ARG0
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1069 {STATE_TEXTURESTAGE(7, WINED3D_TSS_RESULT_ARG
), { STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP
), NULL
}, WINED3D_GL_EXT_NONE
},
1070 {STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), set_bumpmat
}, WINED3D_GL_EXT_NONE
},
1071 {STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT01
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
1072 {STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT10
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
1073 {STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT11
), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00
), NULL
}, WINED3D_GL_EXT_NONE
},
1074 { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
1075 { STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
1076 { STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
1077 { STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
1078 { STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
1079 { STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
1080 { STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
1081 { STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texdim
}, WINED3D_GL_EXT_NONE
},
1082 {STATE_TEXTURESTAGE(0,WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), textransform
}, WINED3D_GL_EXT_NONE
},
1083 {STATE_TEXTURESTAGE(1,WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), textransform
}, WINED3D_GL_EXT_NONE
},
1084 {STATE_TEXTURESTAGE(2,WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), textransform
}, WINED3D_GL_EXT_NONE
},
1085 {STATE_TEXTURESTAGE(3,WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(3, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), textransform
}, WINED3D_GL_EXT_NONE
},
1086 {STATE_TEXTURESTAGE(4,WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(4, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), textransform
}, WINED3D_GL_EXT_NONE
},
1087 {STATE_TEXTURESTAGE(5,WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), textransform
}, WINED3D_GL_EXT_NONE
},
1088 {STATE_TEXTURESTAGE(6,WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), textransform
}, WINED3D_GL_EXT_NONE
},
1089 {STATE_TEXTURESTAGE(7,WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), {STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
), textransform
}, WINED3D_GL_EXT_NONE
},
1090 {STATE_PIXELSHADER
, { STATE_PIXELSHADER
, atifs_apply_pixelshader
}, WINED3D_GL_EXT_NONE
},
1091 {0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE
},
1094 /* Context activation and GL locking are done by the caller. */
1095 static void atifs_enable(BOOL enable
)
1098 glEnable(GL_FRAGMENT_SHADER_ATI
);
1099 checkGLcall("glEnable(GL_FRAGMENT_SHADER_ATI)");
1101 glDisable(GL_FRAGMENT_SHADER_ATI
);
1102 checkGLcall("glDisable(GL_FRAGMENT_SHADER_ATI)");
1106 static void atifs_get_caps(const struct wined3d_gl_info
*gl_info
, struct fragment_caps
*caps
)
1108 caps
->PrimitiveMiscCaps
= WINED3DPMISCCAPS_TSSARGTEMP
;
1109 caps
->TextureOpCaps
= WINED3DTEXOPCAPS_DISABLE
|
1110 WINED3DTEXOPCAPS_SELECTARG1
|
1111 WINED3DTEXOPCAPS_SELECTARG2
|
1112 WINED3DTEXOPCAPS_MODULATE4X
|
1113 WINED3DTEXOPCAPS_MODULATE2X
|
1114 WINED3DTEXOPCAPS_MODULATE
|
1115 WINED3DTEXOPCAPS_ADDSIGNED2X
|
1116 WINED3DTEXOPCAPS_ADDSIGNED
|
1117 WINED3DTEXOPCAPS_ADD
|
1118 WINED3DTEXOPCAPS_SUBTRACT
|
1119 WINED3DTEXOPCAPS_ADDSMOOTH
|
1120 WINED3DTEXOPCAPS_BLENDCURRENTALPHA
|
1121 WINED3DTEXOPCAPS_BLENDFACTORALPHA
|
1122 WINED3DTEXOPCAPS_BLENDTEXTUREALPHA
|
1123 WINED3DTEXOPCAPS_BLENDDIFFUSEALPHA
|
1124 WINED3DTEXOPCAPS_BLENDTEXTUREALPHAPM
|
1125 WINED3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR
|
1126 WINED3DTEXOPCAPS_MODULATECOLOR_ADDALPHA
|
1127 WINED3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA
|
1128 WINED3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR
|
1129 WINED3DTEXOPCAPS_DOTPRODUCT3
|
1130 WINED3DTEXOPCAPS_MULTIPLYADD
|
1131 WINED3DTEXOPCAPS_LERP
|
1132 WINED3DTEXOPCAPS_BUMPENVMAP
;
1134 /* TODO: Implement WINED3DTEXOPCAPS_BUMPENVMAPLUMINANCE
1135 and WINED3DTEXOPCAPS_PREMODULATE */
1137 /* GL_ATI_fragment_shader always supports 6 textures, which was the limit on r200 cards
1138 * which this extension is exclusively focused on(later cards have GL_ARB_fragment_program).
1139 * If the current card has more than 8 fixed function textures in OpenGL's regular fixed
1140 * function pipeline then the ATI_fragment_shader backend imposes a stricter limit. This
1141 * shouldn't be too hard since Nvidia cards have a limit of 4 textures with the default ffp
1142 * pipeline, and almost all games are happy with that. We can however support up to 8
1143 * texture stages because we have a 2nd pass limit of 8 instructions, and per stage we use
1144 * only 1 instruction.
1146 * The proper fix for this is not to use GL_ATI_fragment_shader on cards newer than the
1147 * r200 series and use an ARB or GLSL shader instead
1149 caps
->MaxTextureBlendStages
= 8;
1150 caps
->MaxSimultaneousTextures
= 6;
1153 static HRESULT
atifs_alloc(struct wined3d_device
*device
)
1155 struct atifs_private_data
*priv
;
1157 device
->fragment_priv
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(struct atifs_private_data
));
1158 if (!device
->fragment_priv
)
1160 ERR("Out of memory\n");
1161 return E_OUTOFMEMORY
;
1163 priv
= device
->fragment_priv
;
1164 if (wine_rb_init(&priv
->fragment_shaders
, &wined3d_ffp_frag_program_rb_functions
) == -1)
1166 ERR("Failed to initialize rbtree.\n");
1167 HeapFree(GetProcessHeap(), 0, device
->fragment_priv
);
1168 return E_OUTOFMEMORY
;
1173 /* Context activation is done by the caller. */
1174 static void atifs_free_ffpshader(struct wine_rb_entry
*entry
, void *context
)
1176 struct wined3d_device
*device
= context
;
1177 const struct wined3d_gl_info
*gl_info
= &device
->adapter
->gl_info
;
1178 struct atifs_ffp_desc
*entry_ati
= WINE_RB_ENTRY_VALUE(entry
, struct atifs_ffp_desc
, parent
.entry
);
1181 GL_EXTCALL(glDeleteFragmentShaderATI(entry_ati
->shader
));
1182 checkGLcall("glDeleteFragmentShaderATI(entry->shader)");
1183 HeapFree(GetProcessHeap(), 0, entry_ati
);
1187 /* Context activation is done by the caller. */
1188 static void atifs_free(struct wined3d_device
*device
)
1190 struct atifs_private_data
*priv
= device
->fragment_priv
;
1192 wine_rb_destroy(&priv
->fragment_shaders
, atifs_free_ffpshader
, device
);
1194 HeapFree(GetProcessHeap(), 0, priv
);
1195 device
->fragment_priv
= NULL
;
1198 static BOOL
atifs_color_fixup_supported(struct color_fixup_desc fixup
)
1200 if (TRACE_ON(d3d_shader
) && TRACE_ON(d3d
))
1202 TRACE("Checking support for fixup:\n");
1203 dump_color_fixup_desc(fixup
);
1206 /* We only support sign fixup of the first two channels. */
1207 if (fixup
.x_source
== CHANNEL_SOURCE_X
&& fixup
.y_source
== CHANNEL_SOURCE_Y
1208 && fixup
.z_source
== CHANNEL_SOURCE_Z
&& fixup
.w_source
== CHANNEL_SOURCE_W
1209 && !fixup
.z_sign_fixup
&& !fixup
.w_sign_fixup
)
1215 TRACE("[FAILED]\n");
1219 const struct fragment_pipeline atifs_fragment_pipeline
= {
1224 atifs_color_fixup_supported
,
1225 atifs_fragmentstate_template
,
1226 TRUE
/* We can disable projected textures */