msctf: Implement ITfClientId.
[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  * Copyright 2009 Henri Verbeet for CodeWeavers
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public
14  * License as published by the Free Software Foundation; either
15  * version 2.1 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this library; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26
27 #include "config.h"
28 #include <string.h>
29 #include <stdio.h>
30 #include "wined3d_private.h"
31
32 WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
33 WINE_DECLARE_DEBUG_CHANNEL(d3d);
34
35 static const char *shader_opcode_names[] =
36 {
37     /* WINED3DSIH_ABS           */ "abs",
38     /* WINED3DSIH_ADD           */ "add",
39     /* WINED3DSIH_BEM           */ "bem",
40     /* WINED3DSIH_BREAK         */ "break",
41     /* WINED3DSIH_BREAKC        */ "breakc",
42     /* WINED3DSIH_BREAKP        */ "breakp",
43     /* WINED3DSIH_CALL          */ "call",
44     /* WINED3DSIH_CALLNZ        */ "callnz",
45     /* WINED3DSIH_CMP           */ "cmp",
46     /* WINED3DSIH_CND           */ "cnd",
47     /* WINED3DSIH_CRS           */ "crs",
48     /* WINED3DSIH_DCL           */ "dcl",
49     /* WINED3DSIH_DEF           */ "def",
50     /* WINED3DSIH_DEFB          */ "defb",
51     /* WINED3DSIH_DEFI          */ "defi",
52     /* WINED3DSIH_DP2ADD        */ "dp2add",
53     /* WINED3DSIH_DP3           */ "dp3",
54     /* WINED3DSIH_DP4           */ "dp4",
55     /* WINED3DSIH_DST           */ "dst",
56     /* WINED3DSIH_DSX           */ "dsx",
57     /* WINED3DSIH_DSY           */ "dsy",
58     /* WINED3DSIH_ELSE          */ "else",
59     /* WINED3DSIH_ENDIF         */ "endif",
60     /* WINED3DSIH_ENDLOOP       */ "endloop",
61     /* WINED3DSIH_ENDREP        */ "endrep",
62     /* WINED3DSIH_EXP           */ "exp",
63     /* WINED3DSIH_EXPP          */ "expp",
64     /* WINED3DSIH_FRC           */ "frc",
65     /* WINED3DSIH_IF            */ "if",
66     /* WINED3DSIH_IFC           */ "ifc",
67     /* WINED3DSIH_LABEL         */ "label",
68     /* WINED3DSIH_LIT           */ "lit",
69     /* WINED3DSIH_LOG           */ "log",
70     /* WINED3DSIH_LOGP          */ "logp",
71     /* WINED3DSIH_LOOP          */ "loop",
72     /* WINED3DSIH_LRP           */ "lrp",
73     /* WINED3DSIH_M3x2          */ "m3x2",
74     /* WINED3DSIH_M3x3          */ "m3x3",
75     /* WINED3DSIH_M3x4          */ "m3x4",
76     /* WINED3DSIH_M4x3          */ "m4x3",
77     /* WINED3DSIH_M4x4          */ "m4x4",
78     /* WINED3DSIH_MAD           */ "mad",
79     /* WINED3DSIH_MAX           */ "max",
80     /* WINED3DSIH_MIN           */ "min",
81     /* WINED3DSIH_MOV           */ "mov",
82     /* WINED3DSIH_MOVA          */ "mova",
83     /* WINED3DSIH_MUL           */ "mul",
84     /* WINED3DSIH_NOP           */ "nop",
85     /* WINED3DSIH_NRM           */ "nrm",
86     /* WINED3DSIH_PHASE         */ "phase",
87     /* WINED3DSIH_POW           */ "pow",
88     /* WINED3DSIH_RCP           */ "rcp",
89     /* WINED3DSIH_REP           */ "rep",
90     /* WINED3DSIH_RET           */ "ret",
91     /* WINED3DSIH_RSQ           */ "rsq",
92     /* WINED3DSIH_SETP          */ "setp",
93     /* WINED3DSIH_SGE           */ "sge",
94     /* WINED3DSIH_SGN           */ "sgn",
95     /* WINED3DSIH_SINCOS        */ "sincos",
96     /* WINED3DSIH_SLT           */ "slt",
97     /* WINED3DSIH_SUB           */ "sub",
98     /* WINED3DSIH_TEX           */ "texld",
99     /* WINED3DSIH_TEXBEM        */ "texbem",
100     /* WINED3DSIH_TEXBEML       */ "texbeml",
101     /* WINED3DSIH_TEXCOORD      */ "texcrd",
102     /* WINED3DSIH_TEXDEPTH      */ "texdepth",
103     /* WINED3DSIH_TEXDP3        */ "texdp3",
104     /* WINED3DSIH_TEXDP3TEX     */ "texdp3tex",
105     /* WINED3DSIH_TEXKILL       */ "texkill",
106     /* WINED3DSIH_TEXLDD        */ "texldd",
107     /* WINED3DSIH_TEXLDL        */ "texldl",
108     /* WINED3DSIH_TEXM3x2DEPTH  */ "texm3x2depth",
109     /* WINED3DSIH_TEXM3x2PAD    */ "texm3x2pad",
110     /* WINED3DSIH_TEXM3x2TEX    */ "texm3x2tex",
111     /* WINED3DSIH_TEXM3x3       */ "texm3x3",
112     /* WINED3DSIH_TEXM3x3DIFF   */ "texm3x3diff",
113     /* WINED3DSIH_TEXM3x3PAD    */ "texm3x3pad",
114     /* WINED3DSIH_TEXM3x3SPEC   */ "texm3x3spec",
115     /* WINED3DSIH_TEXM3x3TEX    */ "texm3x3tex",
116     /* WINED3DSIH_TEXM3x3VSPEC  */ "texm3x3vspec",
117     /* WINED3DSIH_TEXREG2AR     */ "texreg2ar",
118     /* WINED3DSIH_TEXREG2GB     */ "texreg2gb",
119     /* WINED3DSIH_TEXREG2RGB    */ "texreg2rgb",
120 };
121
122 const struct wined3d_shader_frontend *shader_select_frontend(DWORD version_token)
123 {
124     switch (version_token >> 16)
125     {
126         case WINED3D_SM1_VS:
127         case WINED3D_SM1_PS:
128             return &sm1_shader_frontend;
129
130         case WINED3D_SM4_PS:
131         case WINED3D_SM4_VS:
132         case WINED3D_SM4_GS:
133             return &sm4_shader_frontend;
134
135         default:
136             FIXME("Unrecognised version token %#x\n", version_token);
137             return NULL;
138     }
139 }
140
141 static inline BOOL shader_is_version_token(DWORD token) {
142     return shader_is_pshader_version(token) ||
143            shader_is_vshader_version(token);
144 }
145
146 void shader_buffer_init(struct SHADER_BUFFER *buffer)
147 {
148     buffer->buffer = HeapAlloc(GetProcessHeap(), 0, SHADER_PGMSIZE);
149     buffer->buffer[0] = '\0';
150     buffer->bsize = 0;
151     buffer->lineNo = 0;
152     buffer->newline = TRUE;
153 }
154
155 void shader_buffer_free(struct SHADER_BUFFER *buffer)
156 {
157     HeapFree(GetProcessHeap(), 0, buffer->buffer);
158 }
159
160 int shader_vaddline(SHADER_BUFFER* buffer, const char *format, va_list args)
161 {
162     char* base = buffer->buffer + buffer->bsize;
163     int rc;
164
165     rc = vsnprintf(base, SHADER_PGMSIZE - 1 - buffer->bsize, format, args);
166
167     if (rc < 0 ||                                   /* C89 */ 
168         rc > SHADER_PGMSIZE - 1 - buffer->bsize) {  /* C99 */
169
170         ERR("The buffer allocated for the shader program string "
171             "is too small at %d bytes.\n", SHADER_PGMSIZE);
172         buffer->bsize = SHADER_PGMSIZE - 1;
173         return -1;
174     }
175
176     if (buffer->newline) {
177         TRACE("GL HW (%u, %u) : %s", buffer->lineNo + 1, buffer->bsize, base);
178         buffer->newline = FALSE;
179     } else {
180         TRACE("%s", base);
181     }
182
183     buffer->bsize += rc;
184     if (buffer->buffer[buffer->bsize-1] == '\n') {
185         buffer->lineNo++;
186         buffer->newline = TRUE;
187     }
188     return 0;
189 }
190
191 int shader_addline(SHADER_BUFFER* buffer, const char *format, ...)
192 {
193     int ret;
194     va_list args;
195
196     va_start(args, format);
197     ret = shader_vaddline(buffer, format, args);
198     va_end(args);
199
200     return ret;
201 }
202
203 void shader_init(struct IWineD3DBaseShaderClass *shader, IWineD3DDevice *device)
204 {
205     shader->ref = 1;
206     shader->device = device;
207     list_init(&shader->linked_programs);
208 }
209
210 /* Convert floating point offset relative
211  * to a register file to an absolute offset for float constants */
212 static unsigned int shader_get_float_offset(WINED3DSHADER_PARAM_REGISTER_TYPE register_type, UINT register_idx)
213 {
214     switch (register_type)
215     {
216         case WINED3DSPR_CONST: return register_idx;
217         case WINED3DSPR_CONST2: return 2048 + register_idx;
218         case WINED3DSPR_CONST3: return 4096 + register_idx;
219         case WINED3DSPR_CONST4: return 6144 + register_idx;
220         default:
221             FIXME("Unsupported register type: %d\n", register_type);
222             return register_idx;
223     }
224 }
225
226 static void shader_delete_constant_list(struct list* clist) {
227
228     struct list *ptr;
229     struct local_constant* constant;
230
231     ptr = list_head(clist);
232     while (ptr) {
233         constant = LIST_ENTRY(ptr, struct local_constant, entry);
234         ptr = list_next(clist, ptr);
235         HeapFree(GetProcessHeap(), 0, constant);
236     }
237     list_init(clist);
238 }
239
240 static void shader_record_register_usage(IWineD3DBaseShaderImpl *This, struct shader_reg_maps *reg_maps,
241         DWORD register_type, UINT register_idx, BOOL has_rel_addr, BOOL pshader)
242 {
243     switch (register_type)
244     {
245         case WINED3DSPR_TEXTURE: /* WINED3DSPR_ADDR */
246             if (pshader) reg_maps->texcoord[register_idx] = 1;
247             else reg_maps->address[register_idx] = 1;
248             break;
249
250         case WINED3DSPR_TEMP:
251             reg_maps->temporary[register_idx] = 1;
252             break;
253
254         case WINED3DSPR_INPUT:
255             if (!pshader) reg_maps->attributes[register_idx] = 1;
256             else
257             {
258                 if (has_rel_addr)
259                 {
260                     /* If relative addressing is used, we must assume that all registers
261                      * are used. Even if it is a construct like v3[aL], we can't assume
262                      * that v0, v1 and v2 aren't read because aL can be negative */
263                     unsigned int i;
264                     for (i = 0; i < MAX_REG_INPUT; ++i)
265                     {
266                         ((IWineD3DPixelShaderImpl *)This)->input_reg_used[i] = TRUE;
267                     }
268                 }
269                 else
270                 {
271                     ((IWineD3DPixelShaderImpl *)This)->input_reg_used[register_idx] = TRUE;
272                 }
273             }
274             break;
275
276         case WINED3DSPR_RASTOUT:
277             if (register_idx == 1) reg_maps->fog = 1;
278             break;
279
280         case WINED3DSPR_MISCTYPE:
281             if (pshader && register_idx == 0) reg_maps->vpos = 1;
282             break;
283
284         case WINED3DSPR_CONST:
285             if (has_rel_addr)
286             {
287                 if (!pshader)
288                 {
289                     if (register_idx <= ((IWineD3DVertexShaderImpl *)This)->min_rel_offset)
290                         ((IWineD3DVertexShaderImpl *)This)->min_rel_offset = register_idx;
291                     else if (register_idx >= ((IWineD3DVertexShaderImpl *)This)->max_rel_offset)
292                         ((IWineD3DVertexShaderImpl *)This)->max_rel_offset = register_idx;
293                 }
294                 reg_maps->usesrelconstF = TRUE;
295             }
296             break;
297
298         case WINED3DSPR_CONSTINT:
299             reg_maps->integer_constants |= (1 << register_idx);
300             break;
301
302         case WINED3DSPR_CONSTBOOL:
303             reg_maps->boolean_constants |= (1 << register_idx);
304             break;
305
306         default:
307             TRACE("Not recording register of type %#x and idx %u\n", register_type, register_idx);
308             break;
309     }
310 }
311
312 /* Note that this does not count the loop register
313  * as an address register. */
314
315 HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3d_shader_frontend *fe,
316         struct shader_reg_maps *reg_maps, struct wined3d_shader_semantic *semantics_in,
317         struct wined3d_shader_semantic *semantics_out, const DWORD *byte_code)
318 {
319     IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
320     void *fe_data = This->baseShader.frontend_data;
321     DWORD shader_version;
322     unsigned int cur_loop_depth = 0, max_loop_depth = 0;
323     const DWORD* pToken = byte_code;
324     char pshader;
325
326     /* There are some minor differences between pixel and vertex shaders */
327
328     memset(reg_maps, 0, sizeof(*reg_maps));
329
330     /* get_registers_used is called on every compile on some 1.x shaders, which can result
331      * in stacking up a collection of local constants. Delete the old constants if existing
332      */
333     shader_delete_constant_list(&This->baseShader.constantsF);
334     shader_delete_constant_list(&This->baseShader.constantsB);
335     shader_delete_constant_list(&This->baseShader.constantsI);
336
337     fe->shader_read_header(fe_data, &pToken, &shader_version);
338     reg_maps->shader_version = shader_version;
339     pshader = shader_is_pshader_version(shader_version);
340
341     while (!fe->shader_is_end(fe_data, &pToken))
342     {
343         struct wined3d_shader_instruction ins;
344         const char *comment;
345         UINT param_size;
346
347         /* Skip comments */
348         fe->shader_read_comment(&pToken, &comment);
349         if (comment) continue;
350
351         /* Fetch opcode */
352         fe->shader_read_opcode(fe_data, &pToken, &ins, &param_size, shader_version);
353
354         /* Unhandled opcode, and its parameters */
355         if (ins.handler_idx == WINED3DSIH_TABLE_SIZE)
356         {
357             TRACE("Skipping unrecognized instruction.\n");
358             pToken += param_size;
359             continue;
360         }
361
362         /* Handle declarations */
363         if (ins.handler_idx == WINED3DSIH_DCL)
364         {
365             struct wined3d_shader_semantic semantic;
366
367             fe->shader_read_semantic(&pToken, &semantic);
368
369             switch (semantic.reg.register_type)
370             {
371                 /* Vshader: mark attributes used
372                  * Pshader: mark 3.0 input registers used, save token */
373                 case WINED3DSPR_INPUT:
374                     if (!pshader) reg_maps->attributes[semantic.reg.register_idx] = 1;
375                     else reg_maps->packed_input[semantic.reg.register_idx] = 1;
376                     semantics_in[semantic.reg.register_idx] = semantic;
377                     break;
378
379                 /* Vshader: mark 3.0 output registers used, save token */
380                 case WINED3DSPR_OUTPUT:
381                     reg_maps->packed_output[semantic.reg.register_idx] = 1;
382                     semantics_out[semantic.reg.register_idx] = semantic;
383                     if (semantic.usage == WINED3DDECLUSAGE_FOG) reg_maps->fog = 1;
384                     break;
385
386                 /* Save sampler usage token */
387                 case WINED3DSPR_SAMPLER:
388                     reg_maps->sampler_type[semantic.reg.register_idx] = semantic.sampler_type;
389                     break;
390
391                 default:
392                     TRACE("Not recording DCL register type %#x.\n", semantic.reg.register_type);
393                     break;
394             }
395         }
396         else if (ins.handler_idx == WINED3DSIH_DEF)
397         {
398             struct wined3d_shader_dst_param dst;
399             struct wined3d_shader_src_param rel_addr;
400
401             local_constant* lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant));
402             if (!lconst) return E_OUTOFMEMORY;
403
404             fe->shader_read_dst_param(&pToken, &dst, &rel_addr, shader_version);
405             lconst->idx = dst.register_idx;
406
407             memcpy(lconst->value, pToken, 4 * sizeof(DWORD));
408             pToken += 4;
409
410             /* In pixel shader 1.X shaders, the constants are clamped between [-1;1] */
411             if (WINED3DSHADER_VERSION_MAJOR(shader_version) == 1 && pshader)
412             {
413                 float *value = (float *) lconst->value;
414                 if(value[0] < -1.0) value[0] = -1.0;
415                 else if(value[0] >  1.0) value[0] =  1.0;
416                 if(value[1] < -1.0) value[1] = -1.0;
417                 else if(value[1] >  1.0) value[1] =  1.0;
418                 if(value[2] < -1.0) value[2] = -1.0;
419                 else if(value[2] >  1.0) value[2] =  1.0;
420                 if(value[3] < -1.0) value[3] = -1.0;
421                 else if(value[3] >  1.0) value[3] =  1.0;
422             }
423
424             list_add_head(&This->baseShader.constantsF, &lconst->entry);
425         }
426         else if (ins.handler_idx == WINED3DSIH_DEFI)
427         {
428             struct wined3d_shader_dst_param dst;
429             struct wined3d_shader_src_param rel_addr;
430
431             local_constant* lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant));
432             if (!lconst) return E_OUTOFMEMORY;
433
434             fe->shader_read_dst_param(&pToken, &dst, &rel_addr, shader_version);
435             lconst->idx = dst.register_idx;
436
437             memcpy(lconst->value, pToken, 4 * sizeof(DWORD));
438             pToken += 4;
439
440             list_add_head(&This->baseShader.constantsI, &lconst->entry);
441         }
442         else if (ins.handler_idx == WINED3DSIH_DEFB)
443         {
444             struct wined3d_shader_dst_param dst;
445             struct wined3d_shader_src_param rel_addr;
446
447             local_constant* lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant));
448             if (!lconst) return E_OUTOFMEMORY;
449
450             fe->shader_read_dst_param(&pToken, &dst, &rel_addr, shader_version);
451             lconst->idx = dst.register_idx;
452
453             memcpy(lconst->value, pToken, sizeof(DWORD));
454             ++pToken;
455
456             list_add_head(&This->baseShader.constantsB, &lconst->entry);
457         }
458         /* If there's a loop in the shader */
459         else if (ins.handler_idx == WINED3DSIH_LOOP
460                 || ins.handler_idx == WINED3DSIH_REP)
461         {
462             struct wined3d_shader_src_param src, rel_addr;
463
464             fe->shader_read_src_param(&pToken, &src, &rel_addr, shader_version);
465
466             /* Rep and Loop always use an integer constant for the control parameters */
467             if (ins.handler_idx == WINED3DSIH_REP)
468             {
469                 reg_maps->integer_constants |= 1 << src.register_idx;
470             }
471             else
472             {
473                 fe->shader_read_src_param(&pToken, &src, &rel_addr, shader_version);
474                 reg_maps->integer_constants |= 1 << src.register_idx;
475             }
476
477             cur_loop_depth++;
478             if(cur_loop_depth > max_loop_depth)
479                 max_loop_depth = cur_loop_depth;
480         }
481         else if (ins.handler_idx == WINED3DSIH_ENDLOOP
482                 || ins.handler_idx == WINED3DSIH_ENDREP)
483         {
484             cur_loop_depth--;
485         }
486         /* For subroutine prototypes */
487         else if (ins.handler_idx == WINED3DSIH_LABEL)
488         {
489             struct wined3d_shader_src_param src, rel_addr;
490
491             fe->shader_read_src_param(&pToken, &src, &rel_addr, shader_version);
492             reg_maps->labels[src.register_idx] = 1;
493         }
494         /* Set texture, address, temporary registers */
495         else
496         {
497             int i, limit;
498
499             /* This will loop over all the registers and try to
500              * make a bitmask of the ones we're interested in.
501              *
502              * Relative addressing tokens are ignored, but that's
503              * okay, since we'll catch any address registers when
504              * they are initialized (required by spec) */
505
506             if (ins.dst_count)
507             {
508                 struct wined3d_shader_dst_param dst_param;
509                 struct wined3d_shader_src_param dst_rel_addr;
510
511                 fe->shader_read_dst_param(&pToken, &dst_param, &dst_rel_addr, shader_version);
512
513                 /* WINED3DSPR_TEXCRDOUT is the same as WINED3DSPR_OUTPUT. _OUTPUT can be > MAX_REG_TEXCRD and
514                  * is used in >= 3.0 shaders. Filter 3.0 shaders to prevent overflows, and also filter pixel
515                  * shaders because TECRDOUT isn't used in them, but future register types might cause issues */
516                 if (!pshader && WINED3DSHADER_VERSION_MAJOR(shader_version) < 3
517                         && dst_param.register_type == WINED3DSPR_TEXCRDOUT)
518                 {
519                     reg_maps->texcoord_mask[dst_param.register_type] |= dst_param.write_mask;
520                 }
521                 else
522                 {
523                     shader_record_register_usage(This, reg_maps, dst_param.register_type,
524                             dst_param.register_idx, !!dst_param.rel_addr, pshader);
525                 }
526
527                 /* Declare 1.X samplers implicitly, based on the destination reg. number */
528                 if (WINED3DSHADER_VERSION_MAJOR(shader_version) == 1
529                         && pshader /* Filter different instructions with the same enum values in VS */
530                         && (ins.handler_idx == WINED3DSIH_TEX
531                             || ins.handler_idx == WINED3DSIH_TEXBEM
532                             || ins.handler_idx == WINED3DSIH_TEXBEML
533                             || ins.handler_idx == WINED3DSIH_TEXDP3TEX
534                             || ins.handler_idx == WINED3DSIH_TEXM3x2TEX
535                             || ins.handler_idx == WINED3DSIH_TEXM3x3SPEC
536                             || ins.handler_idx == WINED3DSIH_TEXM3x3TEX
537                             || ins.handler_idx == WINED3DSIH_TEXM3x3VSPEC
538                             || ins.handler_idx == WINED3DSIH_TEXREG2AR
539                             || ins.handler_idx == WINED3DSIH_TEXREG2GB
540                             || ins.handler_idx == WINED3DSIH_TEXREG2RGB))
541                 {
542                     /* Fake sampler usage, only set reserved bit and ttype */
543                     DWORD sampler_code = dst_param.register_idx;
544
545                     TRACE("Setting fake 2D sampler for 1.x pixelshader\n");
546                     reg_maps->sampler_type[sampler_code] = WINED3DSTT_2D;
547
548                     /* texbem is only valid with < 1.4 pixel shaders */
549                     if (ins.handler_idx == WINED3DSIH_TEXBEM
550                             || ins.handler_idx == WINED3DSIH_TEXBEML)
551                     {
552                         reg_maps->bumpmat[sampler_code] = TRUE;
553                         if (ins.handler_idx == WINED3DSIH_TEXBEML)
554                         {
555                             reg_maps->luminanceparams[sampler_code] = TRUE;
556                         }
557                     }
558                 }
559                 else if (pshader && ins.handler_idx == WINED3DSIH_BEM)
560                 {
561                     reg_maps->bumpmat[dst_param.register_idx] = TRUE;
562                 }
563             }
564
565             if (ins.handler_idx == WINED3DSIH_NRM)
566             {
567                 reg_maps->usesnrm = 1;
568             }
569             else if (ins.handler_idx == WINED3DSIH_DSY)
570             {
571                 reg_maps->usesdsy = 1;
572             }
573             else if(ins.handler_idx == WINED3DSIH_TEXLDD)
574             {
575                 reg_maps->usestexldd = 1;
576             }
577
578             limit = ins.src_count + (ins.predicate ? 1 : 0);
579             for (i = 0; i < limit; ++i)
580             {
581                 struct wined3d_shader_src_param src_param, src_rel_addr;
582
583                 fe->shader_read_src_param(&pToken, &src_param, &src_rel_addr, shader_version);
584                 shader_record_register_usage(This, reg_maps, src_param.register_type,
585                         src_param.register_idx, !!src_param.rel_addr, pshader);
586             }
587         }
588     }
589     reg_maps->loop_depth = max_loop_depth;
590
591     This->baseShader.functionLength = ((char *)pToken - (char *)byte_code);
592
593     return WINED3D_OK;
594 }
595
596 static void shader_dump_decl_usage(const struct wined3d_shader_semantic *semantic, DWORD shader_version)
597 {
598     TRACE("dcl");
599
600     if (semantic->reg.register_type == WINED3DSPR_SAMPLER)
601     {
602         switch (semantic->sampler_type)
603         {
604             case WINED3DSTT_2D: TRACE("_2d"); break;
605             case WINED3DSTT_CUBE: TRACE("_cube"); break;
606             case WINED3DSTT_VOLUME: TRACE("_volume"); break;
607             default: TRACE("_unknown_ttype(0x%08x)", semantic->sampler_type);
608         }
609     }
610     else
611     {
612         /* Pixel shaders 3.0 don't have usage semantics */
613         if (shader_is_pshader_version(shader_version) && shader_version < WINED3DPS_VERSION(3,0))
614             return;
615         else
616             TRACE("_");
617
618         switch (semantic->usage)
619         {
620             case WINED3DDECLUSAGE_POSITION:
621                 TRACE("position%d", semantic->usage_idx);
622                 break;
623             case WINED3DDECLUSAGE_BLENDINDICES:
624                 TRACE("blend");
625                 break;
626             case WINED3DDECLUSAGE_BLENDWEIGHT:
627                 TRACE("weight");
628                 break;
629             case WINED3DDECLUSAGE_NORMAL:
630                 TRACE("normal%d", semantic->usage_idx);
631                 break;
632             case WINED3DDECLUSAGE_PSIZE:
633                 TRACE("psize");
634                 break;
635             case WINED3DDECLUSAGE_COLOR:
636                 if (semantic->usage_idx == 0) TRACE("color");
637                 else TRACE("specular%d", (semantic->usage_idx - 1));
638                 break;
639             case WINED3DDECLUSAGE_TEXCOORD:
640                 TRACE("texture%d", semantic->usage_idx);
641                 break;
642             case WINED3DDECLUSAGE_TANGENT:
643                 TRACE("tangent");
644                 break;
645             case WINED3DDECLUSAGE_BINORMAL:
646                 TRACE("binormal");
647                 break;
648             case WINED3DDECLUSAGE_TESSFACTOR:
649                 TRACE("tessfactor");
650                 break;
651             case WINED3DDECLUSAGE_POSITIONT:
652                 TRACE("positionT%d", semantic->usage_idx);
653                 break;
654             case WINED3DDECLUSAGE_FOG:
655                 TRACE("fog");
656                 break;
657             case WINED3DDECLUSAGE_DEPTH:
658                 TRACE("depth");
659                 break;
660             case WINED3DDECLUSAGE_SAMPLE:
661                 TRACE("sample");
662                 break;
663             default:
664                 FIXME("unknown_semantics(0x%08x)", semantic->usage);
665         }
666     }
667 }
668
669 static void shader_dump_register(WINED3DSHADER_PARAM_REGISTER_TYPE register_type, UINT register_idx,
670         const struct wined3d_shader_src_param *rel_addr, DWORD shader_version)
671 {
672     static const char * const rastout_reg_names[] = {"oPos", "oFog", "oPts"};
673     static const char * const misctype_reg_names[] = {"vPos", "vFace"};
674     UINT offset = register_idx;
675
676     switch (register_type)
677     {
678         case WINED3DSPR_TEMP:
679             TRACE("r");
680             break;
681
682         case WINED3DSPR_INPUT:
683             TRACE("v");
684             break;
685
686         case WINED3DSPR_CONST:
687         case WINED3DSPR_CONST2:
688         case WINED3DSPR_CONST3:
689         case WINED3DSPR_CONST4:
690             TRACE("c");
691             offset = shader_get_float_offset(register_type, register_idx);
692             break;
693
694         case WINED3DSPR_TEXTURE: /* vs: case WINED3DSPR_ADDR */
695             TRACE("%c", shader_is_pshader_version(shader_version) ? 't' : 'a');
696             break;
697
698         case WINED3DSPR_RASTOUT:
699             TRACE("%s", rastout_reg_names[register_idx]);
700             break;
701
702         case WINED3DSPR_COLOROUT:
703             TRACE("oC");
704             break;
705
706         case WINED3DSPR_DEPTHOUT:
707             TRACE("oDepth");
708             break;
709
710         case WINED3DSPR_ATTROUT:
711             TRACE("oD");
712             break;
713
714         case WINED3DSPR_TEXCRDOUT:
715             /* Vertex shaders >= 3.0 use general purpose output registers
716              * (WINED3DSPR_OUTPUT), which can include an address token */
717             if (WINED3DSHADER_VERSION_MAJOR(shader_version) >= 3) TRACE("o");
718             else TRACE("oT");
719             break;
720
721         case WINED3DSPR_CONSTINT:
722             TRACE("i");
723             break;
724
725         case WINED3DSPR_CONSTBOOL:
726             TRACE("b");
727             break;
728
729         case WINED3DSPR_LABEL:
730             TRACE("l");
731             break;
732
733         case WINED3DSPR_LOOP:
734             TRACE("aL");
735             break;
736
737         case WINED3DSPR_SAMPLER:
738             TRACE("s");
739             break;
740
741         case WINED3DSPR_MISCTYPE:
742             if (register_idx > 1) FIXME("Unhandled misctype register %d\n", register_idx);
743             else TRACE("%s", misctype_reg_names[register_idx]);
744             break;
745
746         case WINED3DSPR_PREDICATE:
747             TRACE("p");
748             break;
749
750         default:
751             TRACE("unhandled_rtype(%#x)", register_type);
752             break;
753     }
754
755     if (register_type != WINED3DSPR_RASTOUT && register_type != WINED3DSPR_MISCTYPE)
756     {
757         if (rel_addr)
758         {
759             TRACE("[");
760             shader_dump_src_param(rel_addr, shader_version);
761             TRACE(" + ");
762         }
763         TRACE("%u", offset);
764         if (rel_addr) TRACE("]");
765     }
766 }
767
768 void shader_dump_dst_param(const struct wined3d_shader_dst_param *param, DWORD shader_version)
769 {
770     DWORD write_mask = param->write_mask;
771
772     shader_dump_register(param->register_type, param->register_idx, param->rel_addr, shader_version);
773
774     if (write_mask != WINED3DSP_WRITEMASK_ALL)
775     {
776         static const char *write_mask_chars = "xyzw";
777
778         TRACE(".");
779         if (write_mask & WINED3DSP_WRITEMASK_0) TRACE("%c", write_mask_chars[0]);
780         if (write_mask & WINED3DSP_WRITEMASK_1) TRACE("%c", write_mask_chars[1]);
781         if (write_mask & WINED3DSP_WRITEMASK_2) TRACE("%c", write_mask_chars[2]);
782         if (write_mask & WINED3DSP_WRITEMASK_3) TRACE("%c", write_mask_chars[3]);
783     }
784 }
785
786 void shader_dump_src_param(const struct wined3d_shader_src_param *param, DWORD shader_version)
787 {
788     DWORD src_modifier = param->modifiers;
789     DWORD swizzle = param->swizzle;
790
791     if (src_modifier == WINED3DSPSM_NEG
792             || src_modifier == WINED3DSPSM_BIASNEG
793             || src_modifier == WINED3DSPSM_SIGNNEG
794             || src_modifier == WINED3DSPSM_X2NEG
795             || src_modifier == WINED3DSPSM_ABSNEG)
796         TRACE("-");
797     else if (src_modifier == WINED3DSPSM_COMP)
798         TRACE("1-");
799     else if (src_modifier == WINED3DSPSM_NOT)
800         TRACE("!");
801
802     if (src_modifier == WINED3DSPSM_ABS || src_modifier == WINED3DSPSM_ABSNEG)
803         TRACE("abs(");
804
805     shader_dump_register(param->register_type, param->register_idx, param->rel_addr, shader_version);
806
807     if (src_modifier)
808     {
809         switch (src_modifier)
810         {
811             case WINED3DSPSM_NONE:    break;
812             case WINED3DSPSM_NEG:     break;
813             case WINED3DSPSM_NOT:     break;
814             case WINED3DSPSM_BIAS:    TRACE("_bias"); break;
815             case WINED3DSPSM_BIASNEG: TRACE("_bias"); break;
816             case WINED3DSPSM_SIGN:    TRACE("_bx2"); break;
817             case WINED3DSPSM_SIGNNEG: TRACE("_bx2"); break;
818             case WINED3DSPSM_COMP:    break;
819             case WINED3DSPSM_X2:      TRACE("_x2"); break;
820             case WINED3DSPSM_X2NEG:   TRACE("_x2"); break;
821             case WINED3DSPSM_DZ:      TRACE("_dz"); break;
822             case WINED3DSPSM_DW:      TRACE("_dw"); break;
823             case WINED3DSPSM_ABSNEG:  TRACE(")"); break;
824             case WINED3DSPSM_ABS:     TRACE(")"); break;
825             default:
826                                       TRACE("_unknown_modifier(%#x)", src_modifier);
827         }
828     }
829
830     if (swizzle != WINED3DSP_NOSWIZZLE)
831     {
832         static const char *swizzle_chars = "xyzw";
833         DWORD swizzle_x = swizzle & 0x03;
834         DWORD swizzle_y = (swizzle >> 2) & 0x03;
835         DWORD swizzle_z = (swizzle >> 4) & 0x03;
836         DWORD swizzle_w = (swizzle >> 6) & 0x03;
837
838         if (swizzle_x == swizzle_y
839                 && swizzle_x == swizzle_z
840                 && swizzle_x == swizzle_w)
841         {
842             TRACE(".%c", swizzle_chars[swizzle_x]);
843         }
844         else
845         {
846             TRACE(".%c%c%c%c", swizzle_chars[swizzle_x], swizzle_chars[swizzle_y],
847                     swizzle_chars[swizzle_z], swizzle_chars[swizzle_w]);
848         }
849     }
850 }
851
852 /* Shared code in order to generate the bulk of the shader string.
853  * NOTE: A description of how to parse tokens can be found on msdn */
854 void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER *buffer,
855         const shader_reg_maps *reg_maps, const DWORD *pFunction)
856 {
857     IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
858     IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device; /* To access shader backend callbacks */
859     const SHADER_HANDLER *handler_table = device->shader_backend->shader_instruction_handler_table;
860     const struct wined3d_shader_frontend *fe = This->baseShader.frontend;
861     void *fe_data = This->baseShader.frontend_data;
862     struct wined3d_shader_src_param src_rel_addr[4];
863     struct wined3d_shader_src_param src_param[4];
864     struct wined3d_shader_src_param dst_rel_addr;
865     struct wined3d_shader_dst_param dst_param;
866     struct wined3d_shader_instruction ins;
867     struct wined3d_shader_context ctx;
868     const DWORD *pToken = pFunction;
869     SHADER_HANDLER hw_fct;
870     DWORD shader_version;
871     DWORD i;
872
873     /* Initialize current parsing state */
874     ctx.shader = iface;
875     ctx.reg_maps = reg_maps;
876     ctx.buffer = buffer;
877
878     ins.ctx = &ctx;
879     ins.dst = &dst_param;
880     ins.src = src_param;
881     This->baseShader.parse_state.current_row = 0;
882
883     fe->shader_read_header(fe_data, &pToken, &shader_version);
884
885     while (!fe->shader_is_end(fe_data, &pToken))
886     {
887         const char *comment;
888         UINT param_size;
889
890         /* Skip comment tokens */
891         fe->shader_read_comment(&pToken, &comment);
892         if (comment) continue;
893
894         /* Read opcode */
895         fe->shader_read_opcode(fe_data, &pToken, &ins, &param_size, shader_version);
896
897         /* Unknown opcode and its parameters */
898         if (ins.handler_idx == WINED3DSIH_TABLE_SIZE)
899         {
900             TRACE("Skipping unrecognized instruction.\n");
901             pToken += param_size;
902             continue;
903         }
904
905         /* Nothing to do */
906         if (ins.handler_idx == WINED3DSIH_DCL
907                 || ins.handler_idx == WINED3DSIH_NOP
908                 || ins.handler_idx == WINED3DSIH_DEF
909                 || ins.handler_idx == WINED3DSIH_DEFI
910                 || ins.handler_idx == WINED3DSIH_DEFB
911                 || ins.handler_idx == WINED3DSIH_PHASE
912                 || ins.handler_idx == WINED3DSIH_RET)
913         {
914             pToken += param_size;
915             continue;
916         }
917
918         /* Select handler */
919         hw_fct = handler_table[ins.handler_idx];
920
921         /* Unhandled opcode */
922         if (!hw_fct)
923         {
924             FIXME("Backend can't handle opcode %#x\n", ins.handler_idx);
925             pToken += param_size;
926             continue;
927         }
928
929         /* Destination token */
930         if (ins.dst_count) fe->shader_read_dst_param(&pToken, &dst_param, &dst_rel_addr, shader_version);
931
932         /* Predication token */
933         if (ins.predicate) ins.predicate = *pToken++;
934
935         /* Other source tokens */
936         for (i = 0; i < ins.src_count; ++i)
937         {
938             fe->shader_read_src_param(&pToken, &src_param[i], &src_rel_addr[i], shader_version);
939         }
940
941         /* Call appropriate function for output target */
942         hw_fct(&ins);
943
944         /* Process instruction modifiers for GLSL apps ( _sat, etc. ) */
945         /* FIXME: This should be internal to the shader backend.
946          * Also, right now this is the only reason "shader_mode" exists. */
947         if (This->baseShader.shader_mode == SHADER_GLSL) shader_glsl_add_instruction_modifiers(&ins);
948     }
949 }
950
951 static void shader_dump_ins_modifiers(const struct wined3d_shader_dst_param *dst)
952 {
953     DWORD mmask = dst->modifiers;
954
955     switch (dst->shift)
956     {
957         case 0: break;
958         case 13: TRACE("_d8"); break;
959         case 14: TRACE("_d4"); break;
960         case 15: TRACE("_d2"); break;
961         case 1: TRACE("_x2"); break;
962         case 2: TRACE("_x4"); break;
963         case 3: TRACE("_x8"); break;
964         default: TRACE("_unhandled_shift(%d)", dst->shift); break;
965     }
966
967     if (mmask & WINED3DSPDM_SATURATE)         TRACE("_sat");
968     if (mmask & WINED3DSPDM_PARTIALPRECISION) TRACE("_pp");
969     if (mmask & WINED3DSPDM_MSAMPCENTROID)    TRACE("_centroid");
970
971     mmask &= ~(WINED3DSPDM_SATURATE | WINED3DSPDM_PARTIALPRECISION | WINED3DSPDM_MSAMPCENTROID);
972     if (mmask)
973         FIXME("_unrecognized_modifier(%#x)", mmask);
974 }
975
976 void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data, const DWORD *pFunction)
977 {
978     const DWORD* pToken = pFunction;
979     DWORD shader_version;
980     DWORD i;
981
982     TRACE("Parsing %p\n", pFunction);
983
984     fe->shader_read_header(fe_data, &pToken, &shader_version);
985
986     TRACE("%s_%u_%u\n", shader_is_pshader_version(shader_version) ? "ps": "vs",
987             WINED3DSHADER_VERSION_MAJOR(shader_version), WINED3DSHADER_VERSION_MINOR(shader_version));
988
989     while (!fe->shader_is_end(fe_data, &pToken))
990     {
991         struct wined3d_shader_instruction ins;
992         const char *comment;
993         UINT param_size;
994
995         /* comment */
996         fe->shader_read_comment(&pToken, &comment);
997         if (comment)
998         {
999             TRACE("//%s\n", comment);
1000             continue;
1001         }
1002
1003         fe->shader_read_opcode(fe_data, &pToken, &ins, &param_size, shader_version);
1004         if (ins.handler_idx == WINED3DSIH_TABLE_SIZE)
1005         {
1006             TRACE("Skipping unrecognized instruction.\n");
1007             pToken += param_size;
1008             continue;
1009         }
1010
1011         if (ins.handler_idx == WINED3DSIH_DCL)
1012         {
1013             struct wined3d_shader_semantic semantic;
1014
1015             fe->shader_read_semantic(&pToken, &semantic);
1016
1017             shader_dump_decl_usage(&semantic, shader_version);
1018             shader_dump_ins_modifiers(&semantic.reg);
1019             TRACE(" ");
1020             shader_dump_dst_param(&semantic.reg, shader_version);
1021         }
1022         else if (ins.handler_idx == WINED3DSIH_DEF)
1023         {
1024             struct wined3d_shader_dst_param dst;
1025             struct wined3d_shader_src_param rel_addr;
1026
1027             fe->shader_read_dst_param(&pToken, &dst, &rel_addr, shader_version);
1028
1029             TRACE("def c%u = %f, %f, %f, %f", shader_get_float_offset(dst.register_type, dst.register_idx),
1030                     *(const float *)(pToken),
1031                     *(const float *)(pToken + 1),
1032                     *(const float *)(pToken + 2),
1033                     *(const float *)(pToken + 3));
1034             pToken += 4;
1035         }
1036         else if (ins.handler_idx == WINED3DSIH_DEFI)
1037         {
1038             struct wined3d_shader_dst_param dst;
1039             struct wined3d_shader_src_param rel_addr;
1040
1041             fe->shader_read_dst_param(&pToken, &dst, &rel_addr, shader_version);
1042
1043             TRACE("defi i%u = %d, %d, %d, %d", dst.register_idx,
1044                     *(pToken),
1045                     *(pToken + 1),
1046                     *(pToken + 2),
1047                     *(pToken + 3));
1048             pToken += 4;
1049         }
1050         else if (ins.handler_idx == WINED3DSIH_DEFB)
1051         {
1052             struct wined3d_shader_dst_param dst;
1053             struct wined3d_shader_src_param rel_addr;
1054
1055             fe->shader_read_dst_param(&pToken, &dst, &rel_addr, shader_version);
1056
1057             TRACE("defb b%u = %s", dst.register_idx, *pToken ? "true" : "false");
1058             ++pToken;
1059         }
1060         else
1061         {
1062             struct wined3d_shader_src_param dst_rel_addr, src_rel_addr;
1063             struct wined3d_shader_dst_param dst_param;
1064             struct wined3d_shader_src_param src_param;
1065
1066             if (ins.dst_count)
1067             {
1068                 fe->shader_read_dst_param(&pToken, &dst_param, &dst_rel_addr, shader_version);
1069             }
1070
1071             /* Print out predication source token first - it follows
1072              * the destination token. */
1073             if (ins.predicate)
1074             {
1075                 fe->shader_read_src_param(&pToken, &src_param, &src_rel_addr, shader_version);
1076                 TRACE("(");
1077                 shader_dump_src_param(&src_param, shader_version);
1078                 TRACE(") ");
1079             }
1080
1081             /* PixWin marks instructions with the coissue flag with a '+' */
1082             if (ins.coissue) TRACE("+");
1083
1084             TRACE("%s", shader_opcode_names[ins.handler_idx]);
1085
1086             if (ins.handler_idx == WINED3DSIH_IFC
1087                     || ins.handler_idx == WINED3DSIH_BREAKC)
1088             {
1089                 switch (ins.flags)
1090                 {
1091                     case COMPARISON_GT: TRACE("_gt"); break;
1092                     case COMPARISON_EQ: TRACE("_eq"); break;
1093                     case COMPARISON_GE: TRACE("_ge"); break;
1094                     case COMPARISON_LT: TRACE("_lt"); break;
1095                     case COMPARISON_NE: TRACE("_ne"); break;
1096                     case COMPARISON_LE: TRACE("_le"); break;
1097                     default: TRACE("_(%u)", ins.flags);
1098                 }
1099             }
1100             else if (ins.handler_idx == WINED3DSIH_TEX
1101                     && shader_version >= WINED3DPS_VERSION(2,0)
1102                     && (ins.flags & WINED3DSI_TEXLD_PROJECT))
1103             {
1104                 TRACE("p");
1105             }
1106
1107             /* We already read the destination token, print it. */
1108             if (ins.dst_count)
1109             {
1110                 shader_dump_ins_modifiers(&dst_param);
1111                 TRACE(" ");
1112                 shader_dump_dst_param(&dst_param, shader_version);
1113             }
1114
1115             /* Other source tokens */
1116             for (i = ins.dst_count; i < (ins.dst_count + ins.src_count); ++i)
1117             {
1118                 fe->shader_read_src_param(&pToken, &src_param, &src_rel_addr, shader_version);
1119                 TRACE(!i ? " " : ", ");
1120                 shader_dump_src_param(&src_param, shader_version);
1121             }
1122         }
1123         TRACE("\n");
1124     }
1125 }
1126
1127 void shader_cleanup(IWineD3DBaseShader *iface)
1128 {
1129     IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)iface;
1130
1131     ((IWineD3DDeviceImpl *)This->baseShader.device)->shader_backend->shader_destroy(iface);
1132     HeapFree(GetProcessHeap(), 0, This->baseShader.function);
1133     shader_delete_constant_list(&This->baseShader.constantsF);
1134     shader_delete_constant_list(&This->baseShader.constantsB);
1135     shader_delete_constant_list(&This->baseShader.constantsI);
1136     list_remove(&This->baseShader.shader_list_entry);
1137
1138     if (This->baseShader.frontend && This->baseShader.frontend_data)
1139     {
1140         This->baseShader.frontend->shader_free(This->baseShader.frontend_data);
1141     }
1142 }
1143
1144 static const SHADER_HANDLER shader_none_instruction_handler_table[WINED3DSIH_TABLE_SIZE] = {0};
1145 static void shader_none_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {}
1146 static void shader_none_select_depth_blt(IWineD3DDevice *iface, enum tex_types tex_type) {}
1147 static void shader_none_deselect_depth_blt(IWineD3DDevice *iface) {}
1148 static void shader_none_update_float_vertex_constants(IWineD3DDevice *iface, UINT start, UINT count) {}
1149 static void shader_none_update_float_pixel_constants(IWineD3DDevice *iface, UINT start, UINT count) {}
1150 static void shader_none_load_constants(IWineD3DDevice *iface, char usePS, char useVS) {}
1151 static void shader_none_load_np2fixup_constants(IWineD3DDevice *iface, char usePS, char useVS) {}
1152 static void shader_none_destroy(IWineD3DBaseShader *iface) {}
1153 static HRESULT shader_none_alloc(IWineD3DDevice *iface) {return WINED3D_OK;}
1154 static void shader_none_free(IWineD3DDevice *iface) {}
1155 static BOOL shader_none_dirty_const(IWineD3DDevice *iface) {return FALSE;}
1156 static GLuint shader_none_generate_pshader(IWineD3DPixelShader *iface,
1157         SHADER_BUFFER *buffer, const struct ps_compile_args *args)
1158 {
1159     FIXME("NONE shader backend asked to generate a pixel shader\n");
1160     return 0;
1161 }
1162 static GLuint shader_none_generate_vshader(IWineD3DVertexShader *iface,
1163         SHADER_BUFFER *buffer, const struct vs_compile_args *args)
1164 {
1165     FIXME("NONE shader backend asked to generate a vertex shader\n");
1166     return 0;
1167 }
1168
1169 #define GLINFO_LOCATION      (*gl_info)
1170 static void shader_none_get_caps(WINED3DDEVTYPE devtype, const WineD3D_GL_Info *gl_info, struct shader_caps *pCaps)
1171 {
1172     /* Set the shader caps to 0 for the none shader backend */
1173     pCaps->VertexShaderVersion  = 0;
1174     pCaps->PixelShaderVersion    = 0;
1175     pCaps->PixelShader1xMaxValue = 0.0;
1176 }
1177 #undef GLINFO_LOCATION
1178 static BOOL shader_none_color_fixup_supported(struct color_fixup_desc fixup)
1179 {
1180     if (TRACE_ON(d3d_shader) && TRACE_ON(d3d))
1181     {
1182         TRACE("Checking support for fixup:\n");
1183         dump_color_fixup_desc(fixup);
1184     }
1185
1186     /* Faked to make some apps happy. */
1187     if (!is_yuv_fixup(fixup))
1188     {
1189         TRACE("[OK]\n");
1190         return TRUE;
1191     }
1192
1193     TRACE("[FAILED]\n");
1194     return FALSE;
1195 }
1196
1197 const shader_backend_t none_shader_backend = {
1198     shader_none_instruction_handler_table,
1199     shader_none_select,
1200     shader_none_select_depth_blt,
1201     shader_none_deselect_depth_blt,
1202     shader_none_update_float_vertex_constants,
1203     shader_none_update_float_pixel_constants,
1204     shader_none_load_constants,
1205     shader_none_load_np2fixup_constants,
1206     shader_none_destroy,
1207     shader_none_alloc,
1208     shader_none_free,
1209     shader_none_dirty_const,
1210     shader_none_generate_pshader,
1211     shader_none_generate_vshader,
1212     shader_none_get_caps,
1213     shader_none_color_fixup_supported,
1214 };