wined3d: Add support for EXT_vertex_array_bgra.
[wine] / dlls / wined3d / baseshader.c
1 /*
2  * shaders implementation
3  *
4  * Copyright 2002-2003 Jason Edmeades
5  * Copyright 2002-2003 Raphael Junqueira
6  * Copyright 2004 Christian Costa
7  * Copyright 2005 Oliver Stieber
8  * Copyright 2006 Ivan Gyurdiev
9  * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with this library; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25
26 #include "config.h"
27 #include <string.h>
28 #include <stdio.h>
29 #include "wined3d_private.h"
30
31 WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
32 WINE_DECLARE_DEBUG_CHANNEL(d3d);
33
34 #define GLNAME_REQUIRE_GLSL  ((const char *)1)
35
36 static void shader_dump_param(const DWORD param, const DWORD addr_token, int input, DWORD shader_version);
37
38 static inline BOOL shader_is_version_token(DWORD token) {
39     return shader_is_pshader_version(token) ||
40            shader_is_vshader_version(token);
41 }
42
43 void shader_buffer_init(struct SHADER_BUFFER *buffer)
44 {
45     buffer->buffer = HeapAlloc(GetProcessHeap(), 0, SHADER_PGMSIZE);
46     buffer->buffer[0] = '\0';
47     buffer->bsize = 0;
48     buffer->lineNo = 0;
49     buffer->newline = TRUE;
50 }
51
52 void shader_buffer_free(struct SHADER_BUFFER *buffer)
53 {
54     HeapFree(GetProcessHeap(), 0, buffer->buffer);
55 }
56
57 int shader_addline(
58     SHADER_BUFFER* buffer,  
59     const char *format, ...) {
60
61     char* base = buffer->buffer + buffer->bsize;
62     int rc;
63
64     va_list args;
65     va_start(args, format);
66     rc = vsnprintf(base, SHADER_PGMSIZE - 1 - buffer->bsize, format, args);
67     va_end(args);
68
69     if (rc < 0 ||                                   /* C89 */ 
70         rc > SHADER_PGMSIZE - 1 - buffer->bsize) {  /* C99 */
71
72         ERR("The buffer allocated for the shader program string "
73             "is too small at %d bytes.\n", SHADER_PGMSIZE);
74         buffer->bsize = SHADER_PGMSIZE - 1;
75         return -1;
76     }
77
78     if (buffer->newline) {
79         TRACE("GL HW (%u, %u) : %s", buffer->lineNo + 1, buffer->bsize, base);
80         buffer->newline = FALSE;
81     } else {
82         TRACE("%s", base);
83     }
84
85     buffer->bsize += rc;
86     if (buffer->buffer[buffer->bsize-1] == '\n') {
87         buffer->lineNo++;
88         buffer->newline = TRUE;
89     }
90     return 0;
91 }
92
93 const SHADER_OPCODE *shader_get_opcode(const SHADER_OPCODE *opcode_table, DWORD shader_version, DWORD code)
94 {
95     DWORD i = 0;
96
97     /** TODO: use dichotomic search */
98     while (opcode_table[i].name)
99     {
100         if ((code & WINED3DSI_OPCODE_MASK) == opcode_table[i].opcode
101                 && shader_version >= opcode_table[i].min_version
102                 && (!opcode_table[i].max_version || shader_version <= opcode_table[i].max_version))
103         {
104             return &opcode_table[i];
105         }
106         ++i;
107     }
108
109     FIXME("Unsupported opcode %#x(%d) masked %#x, shader version %#x\n",
110             code, code, code & WINED3DSI_OPCODE_MASK, shader_version);
111
112     return NULL;
113 }
114
115 /* Read a parameter opcode from the input stream,
116  * and possibly a relative addressing token.
117  * Return the number of tokens read */
118 static int shader_get_param(const DWORD *pToken, DWORD shader_version, DWORD *param, DWORD *addr_token)
119 {
120     /* PS >= 3.0 have relative addressing (with token)
121      * VS >= 2.0 have relative addressing (with token)
122      * VS >= 1.0 < 2.0 have relative addressing (without token)
123      * The version check below should work in general */
124
125     char rel_token = WINED3DSHADER_VERSION_MAJOR(shader_version) >= 2 &&
126         ((*pToken & WINED3DSHADER_ADDRESSMODE_MASK) == WINED3DSHADER_ADDRMODE_RELATIVE);
127
128     *param = *pToken;
129     *addr_token = rel_token? *(pToken + 1): 0;
130     return rel_token? 2:1;
131 }
132
133 /* Return the number of parameters to skip for an opcode */
134 static inline int shader_skip_opcode(const SHADER_OPCODE *curOpcode, DWORD opcode_token, DWORD shader_version)
135 {
136    /* Shaders >= 2.0 may contain address tokens, but fortunately they
137     * have a useful length mask - use it here. Shaders 1.0 contain no such tokens */
138     return (WINED3DSHADER_VERSION_MAJOR(shader_version) >= 2)
139             ? ((opcode_token & WINED3DSI_INSTLENGTH_MASK) >> WINED3DSI_INSTLENGTH_SHIFT) : curOpcode->num_params;
140 }
141
142 /* Read the parameters of an unrecognized opcode from the input stream
143  * Return the number of tokens read. 
144  * 
145  * Note: This function assumes source or destination token format.
146  * It will not work with specially-formatted tokens like DEF or DCL, 
147  * but hopefully those would be recognized */
148 static int shader_skip_unrecognized(const DWORD *pToken, DWORD shader_version)
149 {
150     int tokens_read = 0;
151     int i = 0;
152
153     /* TODO: Think of a good name for 0x80000000 and replace it with a constant */
154     while (*pToken & 0x80000000) {
155
156         DWORD param, addr_token;
157         tokens_read += shader_get_param(pToken, shader_version, &param, &addr_token);
158         pToken += tokens_read;
159
160         FIXME("Unrecognized opcode param: token=0x%08x "
161             "addr_token=0x%08x name=", param, addr_token);
162         shader_dump_param(param, addr_token, i, shader_version);
163         FIXME("\n");
164         ++i;
165     }
166     return tokens_read;
167 }
168
169 /* Convert floating point offset relative
170  * to a register file to an absolute offset for float constants */
171 static unsigned int shader_get_float_offset(const DWORD reg)
172 {
173      unsigned int regnum = reg & WINED3DSP_REGNUM_MASK;
174      int regtype = shader_get_regtype(reg);
175
176      switch (regtype) {
177         case WINED3DSPR_CONST: return regnum;
178         case WINED3DSPR_CONST2: return 2048 + regnum;
179         case WINED3DSPR_CONST3: return 4096 + regnum;
180         case WINED3DSPR_CONST4: return 6144 + regnum;
181         default:
182             FIXME("Unsupported register type: %d\n", regtype);
183             return regnum;
184      }
185 }
186
187 static void shader_delete_constant_list(struct list* clist) {
188
189     struct list *ptr;
190     struct local_constant* constant;
191
192     ptr = list_head(clist);
193     while (ptr) {
194         constant = LIST_ENTRY(ptr, struct local_constant, entry);
195         ptr = list_next(clist, ptr);
196         HeapFree(GetProcessHeap(), 0, constant);
197     }
198     list_init(clist);
199 }
200
201 /* Note that this does not count the loop register
202  * as an address register. */
203
204 HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, struct shader_reg_maps *reg_maps,
205         struct semantic *semantics_in, struct semantic *semantics_out, const DWORD *byte_code)
206 {
207     IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
208     const SHADER_OPCODE *shader_ins = This->baseShader.shader_ins;
209     DWORD shader_version;
210     unsigned int cur_loop_depth = 0, max_loop_depth = 0;
211     const DWORD* pToken = byte_code;
212     char pshader;
213
214     /* There are some minor differences between pixel and vertex shaders */
215
216     memset(reg_maps->bumpmat, 0, sizeof(reg_maps->bumpmat));
217     memset(reg_maps->luminanceparams, 0, sizeof(reg_maps->luminanceparams));
218
219     /* get_registers_used is called on every compile on some 1.x shaders, which can result
220      * in stacking up a collection of local constants. Delete the old constants if existing
221      */
222     shader_delete_constant_list(&This->baseShader.constantsF);
223     shader_delete_constant_list(&This->baseShader.constantsB);
224     shader_delete_constant_list(&This->baseShader.constantsI);
225
226     /* The version token is supposed to be the first token */
227     if (!shader_is_version_token(*pToken))
228     {
229         FIXME("First token is not a version token, invalid shader.\n");
230         return WINED3DERR_INVALIDCALL;
231     }
232     reg_maps->shader_version = shader_version = *pToken++;
233     pshader = shader_is_pshader_version(shader_version);
234
235     while (WINED3DVS_END() != *pToken) {
236         CONST SHADER_OPCODE* curOpcode;
237         DWORD opcode_token;
238
239         /* Skip comments */
240         if (shader_is_comment(*pToken))
241         {
242              DWORD comment_len = (*pToken & WINED3DSI_COMMENTSIZE_MASK) >> WINED3DSI_COMMENTSIZE_SHIFT;
243              ++pToken;
244              pToken += comment_len;
245              continue;
246         }
247
248         /* Fetch opcode */
249         opcode_token = *pToken++;
250         curOpcode = shader_get_opcode(shader_ins, shader_version, opcode_token);
251
252         /* Unhandled opcode, and its parameters */
253         if (NULL == curOpcode) {
254            while (*pToken & 0x80000000)
255                ++pToken;
256
257         /* Handle declarations */
258         } else if (WINED3DSIO_DCL == curOpcode->opcode) {
259
260             DWORD usage = *pToken++;
261             DWORD param = *pToken++;
262             DWORD regtype = shader_get_regtype(param);
263             unsigned int regnum = param & WINED3DSP_REGNUM_MASK;
264
265             /* Vshader: mark attributes used
266                Pshader: mark 3.0 input registers used, save token */
267             if (WINED3DSPR_INPUT == regtype) {
268
269                 if (!pshader)
270                     reg_maps->attributes[regnum] = 1;
271                 else
272                     reg_maps->packed_input[regnum] = 1;
273
274                 semantics_in[regnum].usage = usage;
275                 semantics_in[regnum].reg = param;
276
277             /* Vshader: mark 3.0 output registers used, save token */
278             } else if (WINED3DSPR_OUTPUT == regtype) {
279                 reg_maps->packed_output[regnum] = 1;
280                 semantics_out[regnum].usage = usage;
281                 semantics_out[regnum].reg = param;
282                 if (usage & (WINED3DDECLUSAGE_FOG << WINED3DSP_DCL_USAGE_SHIFT))
283                     reg_maps->fog = 1;
284
285             /* Save sampler usage token */
286             } else if (WINED3DSPR_SAMPLER == regtype)
287                 reg_maps->samplers[regnum] = usage;
288
289         } else if (WINED3DSIO_DEF == curOpcode->opcode) {
290
291             local_constant* lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant));
292             if (!lconst) return E_OUTOFMEMORY;
293             lconst->idx = *pToken & WINED3DSP_REGNUM_MASK;
294             memcpy(lconst->value, pToken + 1, 4 * sizeof(DWORD));
295
296             /* In pixel shader 1.X shaders, the constants are clamped between [-1;1] */
297             if (WINED3DSHADER_VERSION_MAJOR(shader_version) == 1 && pshader)
298             {
299                 float *value = (float *) lconst->value;
300                 if(value[0] < -1.0) value[0] = -1.0;
301                 else if(value[0] >  1.0) value[0] =  1.0;
302                 if(value[1] < -1.0) value[1] = -1.0;
303                 else if(value[1] >  1.0) value[1] =  1.0;
304                 if(value[2] < -1.0) value[2] = -1.0;
305                 else if(value[2] >  1.0) value[2] =  1.0;
306                 if(value[3] < -1.0) value[3] = -1.0;
307                 else if(value[3] >  1.0) value[3] =  1.0;
308             }
309
310             list_add_head(&This->baseShader.constantsF, &lconst->entry);
311             pToken += curOpcode->num_params;
312
313         } else if (WINED3DSIO_DEFI == curOpcode->opcode) {
314
315             local_constant* lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant));
316             if (!lconst) return E_OUTOFMEMORY;
317             lconst->idx = *pToken & WINED3DSP_REGNUM_MASK;
318             memcpy(lconst->value, pToken + 1, 4 * sizeof(DWORD));
319             list_add_head(&This->baseShader.constantsI, &lconst->entry);
320             pToken += curOpcode->num_params;
321
322         } else if (WINED3DSIO_DEFB == curOpcode->opcode) {
323
324             local_constant* lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant));
325             if (!lconst) return E_OUTOFMEMORY;
326             lconst->idx = *pToken & WINED3DSP_REGNUM_MASK;
327             memcpy(lconst->value, pToken + 1, 1 * sizeof(DWORD));
328             list_add_head(&This->baseShader.constantsB, &lconst->entry);
329             pToken += curOpcode->num_params;
330
331         /* If there's a loop in the shader */
332         } else if (WINED3DSIO_LOOP == curOpcode->opcode ||
333                    WINED3DSIO_REP == curOpcode->opcode) {
334             cur_loop_depth++;
335             if(cur_loop_depth > max_loop_depth)
336                 max_loop_depth = cur_loop_depth;
337             pToken += curOpcode->num_params;
338
339             /* Rep and Loop always use an integer constant for the control parameters */
340             This->baseShader.uses_int_consts = TRUE;
341         } else if (WINED3DSIO_ENDLOOP == curOpcode->opcode ||
342                    WINED3DSIO_ENDREP == curOpcode->opcode) {
343             cur_loop_depth--;
344
345         /* For subroutine prototypes */
346         } else if (WINED3DSIO_LABEL == curOpcode->opcode) {
347
348             DWORD snum = *pToken & WINED3DSP_REGNUM_MASK; 
349             reg_maps->labels[snum] = 1;
350             pToken += curOpcode->num_params;
351
352         /* Set texture, address, temporary registers */
353         } else {
354             int i, limit;
355
356             /* Declare 1.X samplers implicitly, based on the destination reg. number */
357             if (WINED3DSHADER_VERSION_MAJOR(shader_version) == 1
358                     && pshader /* Filter different instructions with the same enum values in VS */
359                     && (WINED3DSIO_TEX == curOpcode->opcode
360                         || WINED3DSIO_TEXBEM == curOpcode->opcode
361                         || WINED3DSIO_TEXBEML == curOpcode->opcode
362                         || WINED3DSIO_TEXDP3TEX == curOpcode->opcode
363                         || WINED3DSIO_TEXM3x2TEX == curOpcode->opcode
364                         || WINED3DSIO_TEXM3x3SPEC == curOpcode->opcode
365                         || WINED3DSIO_TEXM3x3TEX == curOpcode->opcode
366                         || WINED3DSIO_TEXM3x3VSPEC == curOpcode->opcode
367                         || WINED3DSIO_TEXREG2AR == curOpcode->opcode
368                         || WINED3DSIO_TEXREG2GB == curOpcode->opcode
369                         || WINED3DSIO_TEXREG2RGB == curOpcode->opcode))
370             {
371                 /* Fake sampler usage, only set reserved bit and ttype */
372                 DWORD sampler_code = *pToken & WINED3DSP_REGNUM_MASK;
373
374                 TRACE("Setting fake 2D sampler for 1.x pixelshader\n");
375                 reg_maps->samplers[sampler_code] = (0x1 << 31) | WINED3DSTT_2D;
376
377                 /* texbem is only valid with < 1.4 pixel shaders */
378                 if(WINED3DSIO_TEXBEM  == curOpcode->opcode ||
379                     WINED3DSIO_TEXBEML == curOpcode->opcode) {
380                     reg_maps->bumpmat[sampler_code] = TRUE;
381                     if(WINED3DSIO_TEXBEML == curOpcode->opcode) {
382                         reg_maps->luminanceparams[sampler_code] = TRUE;
383                     }
384                 }
385             }
386             if(WINED3DSIO_NRM  == curOpcode->opcode) {
387                 reg_maps->usesnrm = 1;
388             } else if(WINED3DSIO_BEM == curOpcode->opcode && pshader) {
389                 DWORD regnum = *pToken & WINED3DSP_REGNUM_MASK;
390                 reg_maps->bumpmat[regnum] = TRUE;
391             } else if(WINED3DSIO_DSY  == curOpcode->opcode) {
392                 reg_maps->usesdsy = 1;
393             }
394
395             /* This will loop over all the registers and try to
396              * make a bitmask of the ones we're interested in. 
397              *
398              * Relative addressing tokens are ignored, but that's 
399              * okay, since we'll catch any address registers when 
400              * they are initialized (required by spec) */
401
402             limit = (opcode_token & WINED3DSHADER_INSTRUCTION_PREDICATED)?
403                 curOpcode->num_params + 1: curOpcode->num_params;
404
405             for (i = 0; i < limit; ++i) {
406
407                 DWORD param, addr_token, reg, regtype;
408                 pToken += shader_get_param(pToken, shader_version, &param, &addr_token);
409
410                 regtype = shader_get_regtype(param);
411                 reg = param & WINED3DSP_REGNUM_MASK;
412
413                 if (WINED3DSPR_TEXTURE == regtype) { /* vs: WINED3DSPR_ADDR */
414
415                     if (pshader)
416                         reg_maps->texcoord[reg] = 1;
417                     else
418                         reg_maps->address[reg] = 1;
419                 }
420
421                 else if (WINED3DSPR_TEMP == regtype)
422                     reg_maps->temporary[reg] = 1;
423
424                 else if (WINED3DSPR_INPUT == regtype) {
425                     if( !pshader)
426                         reg_maps->attributes[reg] = 1;
427                     else {
428                         if(param & WINED3DSHADER_ADDRMODE_RELATIVE) {
429                             /* If relative addressing is used, we must assume that all registers
430                              * are used. Even if it is a construct like v3[aL], we can't assume
431                              * that v0, v1 and v2 aren't read because aL can be negative
432                              */
433                             unsigned int i;
434                             for(i = 0; i < MAX_REG_INPUT; i++) {
435                                 ((IWineD3DPixelShaderImpl *) This)->input_reg_used[i] = TRUE;
436                             }
437                         } else {
438                             ((IWineD3DPixelShaderImpl *) This)->input_reg_used[reg] = TRUE;
439                         }
440                     }
441                 }
442
443                 else if (WINED3DSPR_RASTOUT == regtype && reg == 1)
444                     reg_maps->fog = 1;
445
446                 else if (WINED3DSPR_MISCTYPE == regtype && reg == 0 && pshader)
447                     reg_maps->vpos = 1;
448
449                 else if(WINED3DSPR_CONST == regtype) {
450                     if(param & WINED3DSHADER_ADDRMODE_RELATIVE) {
451                         if(!pshader) {
452                             if(reg <= ((IWineD3DVertexShaderImpl *) This)->min_rel_offset) {
453                                 ((IWineD3DVertexShaderImpl *) This)->min_rel_offset = reg;
454                             } else if(reg >= ((IWineD3DVertexShaderImpl *) This)->max_rel_offset) {
455                                 ((IWineD3DVertexShaderImpl *) This)->max_rel_offset = reg;
456                             }
457                         }
458                         reg_maps->usesrelconstF = TRUE;
459                     }
460                 }
461                 else if(WINED3DSPR_CONSTINT == regtype) {
462                     This->baseShader.uses_int_consts = TRUE;
463                 }
464                 else if(WINED3DSPR_CONSTBOOL == regtype) {
465                     This->baseShader.uses_bool_consts = TRUE;
466                 }
467
468                 /* WINED3DSPR_TEXCRDOUT is the same as WINED3DSPR_OUTPUT. _OUTPUT can be > MAX_REG_TEXCRD and is used
469                  * in >= 3.0 shaders. Filter 3.0 shaders to prevent overflows, and also filter pixel shaders because TECRDOUT
470                  * isn't used in them, but future register types might cause issues
471                  */
472                 else if (WINED3DSPR_TEXCRDOUT == regtype && i == 0 /* Only look at writes */
473                         && !pshader && WINED3DSHADER_VERSION_MAJOR(shader_version) < 3)
474                 {
475                     reg_maps->texcoord_mask[reg] |= shader_get_writemask(param);
476                 }
477             }
478         }
479     }
480     ++pToken;
481     reg_maps->loop_depth = max_loop_depth;
482
483     This->baseShader.functionLength = ((char *)pToken - (char *)byte_code);
484
485     return WINED3D_OK;
486 }
487
488 static void shader_dump_decl_usage(DWORD decl, DWORD param, DWORD shader_version)
489 {
490     DWORD regtype = shader_get_regtype(param);
491
492     TRACE("dcl");
493
494     if (regtype == WINED3DSPR_SAMPLER) {
495         DWORD ttype = decl & WINED3DSP_TEXTURETYPE_MASK;
496
497         switch (ttype) {
498             case WINED3DSTT_2D: TRACE("_2d"); break;
499             case WINED3DSTT_CUBE: TRACE("_cube"); break;
500             case WINED3DSTT_VOLUME: TRACE("_volume"); break;
501             default: TRACE("_unknown_ttype(0x%08x)", ttype);
502        }
503
504     } else { 
505
506         DWORD usage = decl & WINED3DSP_DCL_USAGE_MASK;
507         DWORD idx = (decl & WINED3DSP_DCL_USAGEINDEX_MASK) >> WINED3DSP_DCL_USAGEINDEX_SHIFT;
508
509         /* Pixel shaders 3.0 don't have usage semantics */
510         if (shader_is_pshader_version(shader_version) && shader_version < WINED3DPS_VERSION(3,0))
511             return;
512         else
513             TRACE("_");
514
515         switch(usage) {
516         case WINED3DDECLUSAGE_POSITION:
517             TRACE("position%d", idx);
518             break;
519         case WINED3DDECLUSAGE_BLENDINDICES:
520             TRACE("blend");
521             break;
522         case WINED3DDECLUSAGE_BLENDWEIGHT:
523             TRACE("weight");
524             break;
525         case WINED3DDECLUSAGE_NORMAL:
526             TRACE("normal%d", idx);
527             break;
528         case WINED3DDECLUSAGE_PSIZE:
529             TRACE("psize");
530             break;
531         case WINED3DDECLUSAGE_COLOR:
532             if(idx == 0)  {
533                 TRACE("color");
534             } else {
535                 TRACE("specular%d", (idx - 1));
536             }
537             break;
538         case WINED3DDECLUSAGE_TEXCOORD:
539             TRACE("texture%d", idx);
540             break;
541         case WINED3DDECLUSAGE_TANGENT:
542             TRACE("tangent");
543             break;
544         case WINED3DDECLUSAGE_BINORMAL:
545             TRACE("binormal");
546             break;
547         case WINED3DDECLUSAGE_TESSFACTOR:
548             TRACE("tessfactor");
549             break;
550         case WINED3DDECLUSAGE_POSITIONT:
551             TRACE("positionT%d", idx);
552             break;
553         case WINED3DDECLUSAGE_FOG:
554             TRACE("fog");
555             break;
556         case WINED3DDECLUSAGE_DEPTH:
557             TRACE("depth");
558             break;
559         case WINED3DDECLUSAGE_SAMPLE:
560             TRACE("sample");
561             break;
562         default:
563             FIXME("unknown_semantics(0x%08x)", usage);
564         }
565     }
566 }
567
568 static void shader_dump_arr_entry(const DWORD param, const DWORD addr_token,
569         unsigned int reg, int input, DWORD shader_version)
570 {
571     char relative =
572         ((param & WINED3DSHADER_ADDRESSMODE_MASK) == WINED3DSHADER_ADDRMODE_RELATIVE);
573
574     if (relative) {
575         TRACE("[");
576         if (addr_token)
577             shader_dump_param(addr_token, 0, input, shader_version);
578         else
579             TRACE("a0.x");
580         TRACE(" + ");
581      }
582      TRACE("%u", reg);
583      if (relative)
584          TRACE("]");
585 }
586
587 static void shader_dump_param(const DWORD param, const DWORD addr_token, int input, DWORD shader_version)
588 {
589     static const char * const rastout_reg_names[] = { "oPos", "oFog", "oPts" };
590     static const char * const misctype_reg_names[] = { "vPos", "vFace"};
591     const char *swizzle_reg_chars = "xyzw";
592
593     DWORD reg = param & WINED3DSP_REGNUM_MASK;
594     DWORD regtype = shader_get_regtype(param);
595     DWORD modifier = param & WINED3DSP_SRCMOD_MASK;
596
597     /* There are some minor differences between pixel and vertex shaders */
598     char pshader = shader_is_pshader_version(shader_version);
599
600     if (input) {
601         if ( (modifier == WINED3DSPSM_NEG) ||
602              (modifier == WINED3DSPSM_BIASNEG) ||
603              (modifier == WINED3DSPSM_SIGNNEG) ||
604              (modifier == WINED3DSPSM_X2NEG) ||
605              (modifier == WINED3DSPSM_ABSNEG) )
606             TRACE("-");
607         else if (modifier == WINED3DSPSM_COMP)
608             TRACE("1-");
609         else if (modifier == WINED3DSPSM_NOT)
610             TRACE("!");
611
612         if (modifier == WINED3DSPSM_ABS || modifier == WINED3DSPSM_ABSNEG) 
613             TRACE("abs(");
614     }
615
616     switch (regtype) {
617         case WINED3DSPR_TEMP:
618             TRACE("r%u", reg);
619             break;
620         case WINED3DSPR_INPUT:
621             TRACE("v");
622             shader_dump_arr_entry(param, addr_token, reg, input, shader_version);
623             break;
624         case WINED3DSPR_CONST:
625         case WINED3DSPR_CONST2:
626         case WINED3DSPR_CONST3:
627         case WINED3DSPR_CONST4:
628             TRACE("c");
629             shader_dump_arr_entry(param, addr_token, shader_get_float_offset(param), input, shader_version);
630             break;
631         case WINED3DSPR_TEXTURE: /* vs: case D3DSPR_ADDR */
632             TRACE("%c%u", (pshader? 't':'a'), reg);
633             break;        
634         case WINED3DSPR_RASTOUT:
635             TRACE("%s", rastout_reg_names[reg]);
636             break;
637         case WINED3DSPR_COLOROUT:
638             TRACE("oC%u", reg);
639             break;
640         case WINED3DSPR_DEPTHOUT:
641             TRACE("oDepth");
642             break;
643         case WINED3DSPR_ATTROUT:
644             TRACE("oD%u", reg);
645             break;
646         case WINED3DSPR_TEXCRDOUT: 
647
648             /* Vertex shaders >= 3.0 use general purpose output registers
649              * (WINED3DSPR_OUTPUT), which can include an address token */
650
651             if (WINED3DSHADER_VERSION_MAJOR(shader_version) >= 3) {
652                 TRACE("o");
653                 shader_dump_arr_entry(param, addr_token, reg, input, shader_version);
654             }
655             else 
656                TRACE("oT%u", reg);
657             break;
658         case WINED3DSPR_CONSTINT:
659             TRACE("i");
660             shader_dump_arr_entry(param, addr_token, reg, input, shader_version);
661             break;
662         case WINED3DSPR_CONSTBOOL:
663             TRACE("b");
664             shader_dump_arr_entry(param, addr_token, reg, input, shader_version);
665             break;
666         case WINED3DSPR_LABEL:
667             TRACE("l%u", reg);
668             break;
669         case WINED3DSPR_LOOP:
670             TRACE("aL");
671             break;
672         case WINED3DSPR_SAMPLER:
673             TRACE("s%u", reg);
674             break;
675         case WINED3DSPR_MISCTYPE:
676             if (reg > 1) {
677                 FIXME("Unhandled misctype register %d\n", reg);
678             } else {
679                 TRACE("%s", misctype_reg_names[reg]);
680             }
681             break;
682         case WINED3DSPR_PREDICATE:
683             TRACE("p%u", reg);
684             break;
685         default:
686             TRACE("unhandled_rtype(%#x)", regtype);
687             break;
688    }
689
690    if (!input) {
691        /* operand output (for modifiers and shift, see dump_ins_modifiers) */
692
693        if ((param & WINED3DSP_WRITEMASK_ALL) != WINED3DSP_WRITEMASK_ALL) {
694            TRACE(".");
695            if (param & WINED3DSP_WRITEMASK_0) TRACE("%c", swizzle_reg_chars[0]);
696            if (param & WINED3DSP_WRITEMASK_1) TRACE("%c", swizzle_reg_chars[1]);
697            if (param & WINED3DSP_WRITEMASK_2) TRACE("%c", swizzle_reg_chars[2]);
698            if (param & WINED3DSP_WRITEMASK_3) TRACE("%c", swizzle_reg_chars[3]);
699        }
700
701    } else {
702         /** operand input */
703         DWORD swizzle = (param & WINED3DSP_SWIZZLE_MASK) >> WINED3DSP_SWIZZLE_SHIFT;
704         DWORD swizzle_x = swizzle & 0x03;
705         DWORD swizzle_y = (swizzle >> 2) & 0x03;
706         DWORD swizzle_z = (swizzle >> 4) & 0x03;
707         DWORD swizzle_w = (swizzle >> 6) & 0x03;
708
709         if (0 != modifier) {
710             switch (modifier) {
711                 case WINED3DSPSM_NONE:    break;
712                 case WINED3DSPSM_NEG:     break;
713                 case WINED3DSPSM_NOT:     break;
714                 case WINED3DSPSM_BIAS:    TRACE("_bias"); break;
715                 case WINED3DSPSM_BIASNEG: TRACE("_bias"); break;
716                 case WINED3DSPSM_SIGN:    TRACE("_bx2"); break;
717                 case WINED3DSPSM_SIGNNEG: TRACE("_bx2"); break;
718                 case WINED3DSPSM_COMP:    break;
719                 case WINED3DSPSM_X2:      TRACE("_x2"); break;
720                 case WINED3DSPSM_X2NEG:   TRACE("_x2"); break;
721                 case WINED3DSPSM_DZ:      TRACE("_dz"); break;
722                 case WINED3DSPSM_DW:      TRACE("_dw"); break;
723                 case WINED3DSPSM_ABSNEG:  TRACE(")"); break;
724                 case WINED3DSPSM_ABS:     TRACE(")"); break;
725                 default:
726                     TRACE("_unknown_modifier(%#x)", modifier >> WINED3DSP_SRCMOD_SHIFT);
727             }
728         }
729
730         /**
731         * swizzle bits fields:
732         *  RRGGBBAA
733         */
734         if ((WINED3DVS_NOSWIZZLE >> WINED3DVS_SWIZZLE_SHIFT) != swizzle) {
735             if (swizzle_x == swizzle_y &&
736                 swizzle_x == swizzle_z &&
737                 swizzle_x == swizzle_w) {
738                     TRACE(".%c", swizzle_reg_chars[swizzle_x]);
739             } else {
740                 TRACE(".%c%c%c%c",
741                 swizzle_reg_chars[swizzle_x],
742                 swizzle_reg_chars[swizzle_y],
743                 swizzle_reg_chars[swizzle_z],
744                 swizzle_reg_chars[swizzle_w]);
745             }
746         }
747     }
748 }
749
750 static void shader_color_correction(IWineD3DBaseShaderImpl *shader,
751         IWineD3DDeviceImpl *device, const struct SHADER_OPCODE_ARG *arg, DWORD shader_version)
752 {
753     IWineD3DBaseTextureImpl *texture;
754     struct color_fixup_desc fixup;
755     BOOL recorded = FALSE;
756     DWORD sampler_idx;
757     UINT i;
758
759     switch(arg->opcode->opcode)
760     {
761         case WINED3DSIO_TEX:
762             if (WINED3DSHADER_VERSION_MAJOR(shader_version) < 2) sampler_idx = arg->dst & WINED3DSP_REGNUM_MASK;
763             else sampler_idx = arg->src[1] & WINED3DSP_REGNUM_MASK;
764             break;
765
766         case WINED3DSIO_TEXLDL:
767             FIXME("Add color fixup for vertex texture WINED3DSIO_TEXLDL\n");
768             return;
769
770         case WINED3DSIO_TEXDP3TEX:
771         case WINED3DSIO_TEXM3x3TEX:
772         case WINED3DSIO_TEXM3x3SPEC:
773         case WINED3DSIO_TEXM3x3VSPEC:
774         case WINED3DSIO_TEXBEM:
775         case WINED3DSIO_TEXREG2AR:
776         case WINED3DSIO_TEXREG2GB:
777         case WINED3DSIO_TEXREG2RGB:
778             sampler_idx = arg->dst & WINED3DSP_REGNUM_MASK;
779             break;
780
781         default:
782             /* Not a texture sampling instruction, nothing to do */
783             return;
784     };
785
786     texture = (IWineD3DBaseTextureImpl *)device->stateBlock->textures[sampler_idx];
787     if (texture) fixup = texture->baseTexture.shader_color_fixup;
788     else fixup = COLOR_FIXUP_IDENTITY;
789
790     /* before doing anything, record the sampler with the format in the format conversion list,
791      * but check if it's not there already */
792     for (i = 0; i < shader->baseShader.num_sampled_samplers; ++i)
793     {
794         if (shader->baseShader.sampled_samplers[i] == sampler_idx)
795         {
796             recorded = TRUE;
797             break;
798         }
799     }
800
801     if (!recorded)
802     {
803         shader->baseShader.sampled_samplers[shader->baseShader.num_sampled_samplers] = sampler_idx;
804         ++shader->baseShader.num_sampled_samplers;
805     }
806
807     device->shader_backend->shader_color_correction(arg, fixup);
808 }
809
810 /* Shared code in order to generate the bulk of the shader string.
811  * NOTE: A description of how to parse tokens can be found on msdn */
812 void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER* buffer,
813         const shader_reg_maps* reg_maps, CONST DWORD* pFunction)
814 {
815     IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
816     IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device; /* To access shader backend callbacks */
817     const SHADER_OPCODE *opcode_table = This->baseShader.shader_ins;
818     const SHADER_HANDLER *handler_table = device->shader_backend->shader_instruction_handler_table;
819     DWORD shader_version = reg_maps->shader_version;
820     const DWORD *pToken = pFunction;
821     const SHADER_OPCODE *curOpcode;
822     SHADER_HANDLER hw_fct;
823     DWORD i;
824     SHADER_OPCODE_ARG hw_arg;
825
826     /* Initialize current parsing state */
827     hw_arg.shader = iface;
828     hw_arg.buffer = buffer;
829     hw_arg.reg_maps = reg_maps;
830     This->baseShader.parse_state.current_row = 0;
831
832     while (WINED3DPS_END() != *pToken)
833     {
834         /* Skip version token */
835         if (shader_is_version_token(*pToken))
836         {
837             ++pToken;
838             continue;
839         }
840
841         /* Skip comment tokens */
842         if (shader_is_comment(*pToken))
843         {
844             pToken += (*pToken & WINED3DSI_COMMENTSIZE_MASK) >> WINED3DSI_COMMENTSIZE_SHIFT;
845             ++pToken;
846             continue;
847         }
848
849         /* Read opcode */
850         hw_arg.opcode_token = *pToken++;
851         curOpcode = shader_get_opcode(opcode_table, shader_version, hw_arg.opcode_token);
852
853         /* Unknown opcode and its parameters */
854         if (!curOpcode)
855         {
856             FIXME("Unrecognized opcode: token=0x%08x\n", hw_arg.opcode_token);
857             pToken += shader_skip_unrecognized(pToken, shader_version);
858             continue;
859         }
860
861         /* Nothing to do */
862         if (WINED3DSIO_DCL == curOpcode->opcode
863                 || WINED3DSIO_NOP == curOpcode->opcode
864                 || WINED3DSIO_DEF == curOpcode->opcode
865                 || WINED3DSIO_DEFI == curOpcode->opcode
866                 || WINED3DSIO_DEFB == curOpcode->opcode
867                 || WINED3DSIO_PHASE == curOpcode->opcode
868                 || WINED3DSIO_RET == curOpcode->opcode)
869         {
870             pToken += shader_skip_opcode(curOpcode, hw_arg.opcode_token, shader_version);
871             continue;
872         }
873
874         /* Select handler */
875         hw_fct = handler_table[curOpcode->handler_idx];
876
877         /* Unhandled opcode */
878         if (!hw_fct)
879         {
880             FIXME("Can't handle opcode %s in hwShader\n", curOpcode->name);
881             pToken += shader_skip_opcode(curOpcode, hw_arg.opcode_token, shader_version);
882             continue;
883         }
884
885         hw_arg.opcode = curOpcode;
886
887         /* Destination token */
888         if (curOpcode->dst_token)
889         {
890             DWORD param, addr_token = 0;
891             pToken += shader_get_param(pToken, shader_version, &param, &addr_token);
892             hw_arg.dst = param;
893             hw_arg.dst_addr = addr_token;
894         }
895
896         /* Predication token */
897         if (hw_arg.opcode_token & WINED3DSHADER_INSTRUCTION_PREDICATED) hw_arg.predicate = *pToken++;
898
899         /* Other source tokens */
900         for (i = 0; i < (curOpcode->num_params - curOpcode->dst_token); ++i)
901         {
902             DWORD param, addr_token = 0;
903             pToken += shader_get_param(pToken, shader_version, &param, &addr_token);
904             hw_arg.src[i] = param;
905             hw_arg.src_addr[i] = addr_token;
906         }
907
908         /* Call appropriate function for output target */
909         hw_fct(&hw_arg);
910
911         /* Add color correction if needed */
912         shader_color_correction(This, device, &hw_arg, shader_version);
913
914         /* Process instruction modifiers for GLSL apps ( _sat, etc. ) */
915         /* FIXME: This should be internal to the shader backend.
916          * Also, right now this is the only reason "shader_mode" exists. */
917         if (This->baseShader.shader_mode == SHADER_GLSL) shader_glsl_add_instruction_modifiers(&hw_arg);
918     }
919 }
920
921 static void shader_dump_ins_modifiers(const DWORD output)
922 {
923     DWORD shift = (output & WINED3DSP_DSTSHIFT_MASK) >> WINED3DSP_DSTSHIFT_SHIFT;
924     DWORD mmask = output & WINED3DSP_DSTMOD_MASK;
925
926     switch (shift) {
927         case 0: break;
928         case 13: TRACE("_d8"); break;
929         case 14: TRACE("_d4"); break;
930         case 15: TRACE("_d2"); break;
931         case 1: TRACE("_x2"); break;
932         case 2: TRACE("_x4"); break;
933         case 3: TRACE("_x8"); break;
934         default: TRACE("_unhandled_shift(%d)", shift); break;
935     }
936
937     if (mmask & WINED3DSPDM_SATURATE)         TRACE("_sat");
938     if (mmask & WINED3DSPDM_PARTIALPRECISION) TRACE("_pp");
939     if (mmask & WINED3DSPDM_MSAMPCENTROID)    TRACE("_centroid");
940
941     mmask &= ~(WINED3DSPDM_SATURATE | WINED3DSPDM_PARTIALPRECISION | WINED3DSPDM_MSAMPCENTROID);
942     if (mmask)
943         FIXME("_unrecognized_modifier(%#x)", mmask >> WINED3DSP_DSTMOD_SHIFT);
944 }
945
946 void shader_trace_init(const DWORD *pFunction, const SHADER_OPCODE *opcode_table)
947 {
948     const DWORD* pToken = pFunction;
949     const SHADER_OPCODE* curOpcode = NULL;
950     DWORD shader_version;
951     DWORD opcode_token;
952     DWORD i;
953
954     TRACE("Parsing %p\n", pFunction);
955
956     /* The version token is supposed to be the first token */
957     if (!shader_is_version_token(*pToken))
958     {
959         FIXME("First token is not a version token, invalid shader.\n");
960         return;
961     }
962     shader_version = *pToken++;
963     TRACE("%s_%u_%u\n", shader_is_pshader_version(shader_version) ? "ps": "vs",
964             WINED3DSHADER_VERSION_MAJOR(shader_version), WINED3DSHADER_VERSION_MINOR(shader_version));
965
966     while (WINED3DVS_END() != *pToken)
967     {
968         if (shader_is_comment(*pToken)) /* comment */
969         {
970             DWORD comment_len = (*pToken & WINED3DSI_COMMENTSIZE_MASK) >> WINED3DSI_COMMENTSIZE_SHIFT;
971             ++pToken;
972             TRACE("//%s\n", (const char*)pToken);
973             pToken += comment_len;
974             continue;
975         }
976         opcode_token = *pToken++;
977         curOpcode = shader_get_opcode(opcode_table, shader_version, opcode_token);
978
979         if (!curOpcode)
980         {
981             int tokens_read;
982             FIXME("Unrecognized opcode: token=0x%08x\n", opcode_token);
983             tokens_read = shader_skip_unrecognized(pToken, shader_version);
984             pToken += tokens_read;
985         }
986         else
987         {
988             if (curOpcode->opcode == WINED3DSIO_DCL)
989             {
990                 DWORD usage = *pToken;
991                 DWORD param = *(pToken + 1);
992
993                 shader_dump_decl_usage(usage, param, shader_version);
994                 shader_dump_ins_modifiers(param);
995                 TRACE(" ");
996                 shader_dump_param(param, 0, 0, shader_version);
997                 pToken += 2;
998             }
999             else if (curOpcode->opcode == WINED3DSIO_DEF)
1000             {
1001                 unsigned int offset = shader_get_float_offset(*pToken);
1002
1003                 TRACE("def c%u = %f, %f, %f, %f", offset,
1004                         *(const float *)(pToken + 1),
1005                         *(const float *)(pToken + 2),
1006                         *(const float *)(pToken + 3),
1007                         *(const float *)(pToken + 4));
1008                 pToken += 5;
1009             }
1010             else if (curOpcode->opcode == WINED3DSIO_DEFI)
1011             {
1012                 TRACE("defi i%u = %d, %d, %d, %d", *pToken & WINED3DSP_REGNUM_MASK,
1013                         *(pToken + 1),
1014                         *(pToken + 2),
1015                         *(pToken + 3),
1016                         *(pToken + 4));
1017                 pToken += 5;
1018             }
1019             else if (curOpcode->opcode == WINED3DSIO_DEFB)
1020             {
1021                 TRACE("defb b%u = %s", *pToken & WINED3DSP_REGNUM_MASK,
1022                         *(pToken + 1)? "true": "false");
1023                 pToken += 2;
1024             }
1025             else
1026             {
1027                 DWORD param, addr_token;
1028                 int tokens_read;
1029
1030                 /* Print out predication source token first - it follows
1031                  * the destination token. */
1032                 if (opcode_token & WINED3DSHADER_INSTRUCTION_PREDICATED)
1033                 {
1034                     TRACE("(");
1035                     shader_dump_param(*(pToken + 2), 0, 1, shader_version);
1036                     TRACE(") ");
1037                 }
1038                 if (opcode_token & WINED3DSI_COISSUE)
1039                 {
1040                     /* PixWin marks instructions with the coissue flag with a '+' */
1041                     TRACE("+");
1042                 }
1043
1044                 TRACE("%s", curOpcode->name);
1045
1046                 if (curOpcode->opcode == WINED3DSIO_IFC
1047                         || curOpcode->opcode == WINED3DSIO_BREAKC)
1048                 {
1049                     DWORD op = (opcode_token & INST_CONTROLS_MASK) >> INST_CONTROLS_SHIFT;
1050
1051                     switch (op)
1052                     {
1053                         case COMPARISON_GT: TRACE("_gt"); break;
1054                         case COMPARISON_EQ: TRACE("_eq"); break;
1055                         case COMPARISON_GE: TRACE("_ge"); break;
1056                         case COMPARISON_LT: TRACE("_lt"); break;
1057                         case COMPARISON_NE: TRACE("_ne"); break;
1058                         case COMPARISON_LE: TRACE("_le"); break;
1059                         default: TRACE("_(%u)", op);
1060                     }
1061                 }
1062                 else if (curOpcode->opcode == WINED3DSIO_TEX
1063                         && shader_version >= WINED3DPS_VERSION(2,0)
1064                         && (opcode_token & WINED3DSI_TEXLD_PROJECT))
1065                 {
1066                     TRACE("p");
1067                 }
1068
1069                 /* Destination token */
1070                 if (curOpcode->dst_token)
1071                 {
1072                     tokens_read = shader_get_param(pToken, shader_version, &param, &addr_token);
1073                     pToken += tokens_read;
1074
1075                     shader_dump_ins_modifiers(param);
1076                     TRACE(" ");
1077                     shader_dump_param(param, addr_token, 0, shader_version);
1078                 }
1079
1080                 /* Predication token - already printed out, just skip it */
1081                 if (opcode_token & WINED3DSHADER_INSTRUCTION_PREDICATED)
1082                 {
1083                     pToken++;
1084                 }
1085
1086                 /* Other source tokens */
1087                 for (i = curOpcode->dst_token; i < curOpcode->num_params; ++i)
1088                 {
1089                     tokens_read = shader_get_param(pToken, shader_version, &param, &addr_token);
1090                     pToken += tokens_read;
1091
1092                     TRACE((i == 0)? " " : ", ");
1093                     shader_dump_param(param, addr_token, 1, shader_version);
1094                 }
1095             }
1096             TRACE("\n");
1097         }
1098     }
1099 }
1100
1101 void shader_cleanup(IWineD3DBaseShader *iface)
1102 {
1103     IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)iface;
1104
1105     ((IWineD3DDeviceImpl *)This->baseShader.device)->shader_backend->shader_destroy(iface);
1106     HeapFree(GetProcessHeap(), 0, This->baseShader.function);
1107     shader_delete_constant_list(&This->baseShader.constantsF);
1108     shader_delete_constant_list(&This->baseShader.constantsB);
1109     shader_delete_constant_list(&This->baseShader.constantsI);
1110     list_remove(&This->baseShader.shader_list_entry);
1111 }
1112
1113 static const SHADER_HANDLER shader_none_instruction_handler_table[WINED3DSIH_TABLE_SIZE] = {0};
1114 static void shader_none_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {}
1115 static void shader_none_select_depth_blt(IWineD3DDevice *iface, enum tex_types tex_type) {}
1116 static void shader_none_deselect_depth_blt(IWineD3DDevice *iface) {}
1117 static void shader_none_update_float_vertex_constants(IWineD3DDevice *iface, UINT start, UINT count) {}
1118 static void shader_none_update_float_pixel_constants(IWineD3DDevice *iface, UINT start, UINT count) {}
1119 static void shader_none_load_constants(IWineD3DDevice *iface, char usePS, char useVS) {}
1120 static void shader_none_color_correction(const struct SHADER_OPCODE_ARG *arg, struct color_fixup_desc fixup) {}
1121 static void shader_none_destroy(IWineD3DBaseShader *iface) {}
1122 static HRESULT shader_none_alloc(IWineD3DDevice *iface) {return WINED3D_OK;}
1123 static void shader_none_free(IWineD3DDevice *iface) {}
1124 static BOOL shader_none_dirty_const(IWineD3DDevice *iface) {return FALSE;}
1125 static GLuint shader_none_generate_pshader(IWineD3DPixelShader *iface, SHADER_BUFFER *buffer, const struct ps_compile_args *args) {
1126     FIXME("NONE shader backend asked to generate a pixel shader\n");
1127     return 0;
1128 }
1129 static void shader_none_generate_vshader(IWineD3DVertexShader *iface, SHADER_BUFFER *buffer) {
1130     FIXME("NONE shader backend asked to generate a vertex shader\n");
1131 }
1132
1133 #define GLINFO_LOCATION      (*gl_info)
1134 static void shader_none_get_caps(WINED3DDEVTYPE devtype, const WineD3D_GL_Info *gl_info, struct shader_caps *pCaps)
1135 {
1136     /* Set the shader caps to 0 for the none shader backend */
1137     pCaps->VertexShaderVersion  = 0;
1138     pCaps->PixelShaderVersion    = 0;
1139     pCaps->PixelShader1xMaxValue = 0.0;
1140 }
1141 #undef GLINFO_LOCATION
1142 static BOOL shader_none_color_fixup_supported(struct color_fixup_desc fixup)
1143 {
1144     if (TRACE_ON(d3d_shader) && TRACE_ON(d3d))
1145     {
1146         TRACE("Checking support for fixup:\n");
1147         dump_color_fixup_desc(fixup);
1148     }
1149
1150     /* Faked to make some apps happy. */
1151     if (!is_yuv_fixup(fixup))
1152     {
1153         TRACE("[OK]\n");
1154         return TRUE;
1155     }
1156
1157     TRACE("[FAILED]\n");
1158     return FALSE;
1159 }
1160
1161 const shader_backend_t none_shader_backend = {
1162     shader_none_instruction_handler_table,
1163     shader_none_select,
1164     shader_none_select_depth_blt,
1165     shader_none_deselect_depth_blt,
1166     shader_none_update_float_vertex_constants,
1167     shader_none_update_float_pixel_constants,
1168     shader_none_load_constants,
1169     shader_none_color_correction,
1170     shader_none_destroy,
1171     shader_none_alloc,
1172     shader_none_free,
1173     shader_none_dirty_const,
1174     shader_none_generate_pshader,
1175     shader_none_generate_vshader,
1176     shader_none_get_caps,
1177     shader_none_color_fixup_supported,
1178 };