2 * Direct3D shader library utility routines
4 * Copyright 2008 Stefan Dösinger
5 * Copyright 2009 Matteo Bruni
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wine/debug.h"
26 #include "d3dx9_36_private.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(asmshader);
30 /* bwriter -> d3d9 conversion functions */
31 DWORD d3d9_swizzle(DWORD bwriter_swizzle) {
32 /* Currently a NOP, but this allows changing the internal definitions
33 * without side effects
37 if((bwriter_swizzle & BWRITERVS_X_X) == BWRITERVS_X_X) ret |= D3DVS_X_X;
38 if((bwriter_swizzle & BWRITERVS_X_Y) == BWRITERVS_X_Y) ret |= D3DVS_X_Y;
39 if((bwriter_swizzle & BWRITERVS_X_Z) == BWRITERVS_X_Z) ret |= D3DVS_X_Z;
40 if((bwriter_swizzle & BWRITERVS_X_W) == BWRITERVS_X_W) ret |= D3DVS_X_W;
42 if((bwriter_swizzle & BWRITERVS_Y_X) == BWRITERVS_Y_X) ret |= D3DVS_Y_X;
43 if((bwriter_swizzle & BWRITERVS_Y_Y) == BWRITERVS_Y_Y) ret |= D3DVS_Y_Y;
44 if((bwriter_swizzle & BWRITERVS_Y_Z) == BWRITERVS_Y_Z) ret |= D3DVS_Y_Z;
45 if((bwriter_swizzle & BWRITERVS_Y_W) == BWRITERVS_Y_W) ret |= D3DVS_Y_W;
47 if((bwriter_swizzle & BWRITERVS_Z_X) == BWRITERVS_Z_X) ret |= D3DVS_Z_X;
48 if((bwriter_swizzle & BWRITERVS_Z_Y) == BWRITERVS_Z_Y) ret |= D3DVS_Z_Y;
49 if((bwriter_swizzle & BWRITERVS_Z_Z) == BWRITERVS_Z_Z) ret |= D3DVS_Z_Z;
50 if((bwriter_swizzle & BWRITERVS_Z_W) == BWRITERVS_Z_W) ret |= D3DVS_Z_W;
52 if((bwriter_swizzle & BWRITERVS_W_X) == BWRITERVS_W_X) ret |= D3DVS_W_X;
53 if((bwriter_swizzle & BWRITERVS_W_Y) == BWRITERVS_W_Y) ret |= D3DVS_W_Y;
54 if((bwriter_swizzle & BWRITERVS_W_Z) == BWRITERVS_W_Z) ret |= D3DVS_W_Z;
55 if((bwriter_swizzle & BWRITERVS_W_W) == BWRITERVS_W_W) ret |= D3DVS_W_W;
60 DWORD d3d9_writemask(DWORD bwriter_writemask) {
63 if(bwriter_writemask & BWRITERSP_WRITEMASK_0) ret |= D3DSP_WRITEMASK_0;
64 if(bwriter_writemask & BWRITERSP_WRITEMASK_1) ret |= D3DSP_WRITEMASK_1;
65 if(bwriter_writemask & BWRITERSP_WRITEMASK_2) ret |= D3DSP_WRITEMASK_2;
66 if(bwriter_writemask & BWRITERSP_WRITEMASK_3) ret |= D3DSP_WRITEMASK_3;
71 DWORD d3d9_srcmod(DWORD bwriter_srcmod) {
72 switch(bwriter_srcmod) {
73 case BWRITERSPSM_NONE: return D3DSPSM_NONE;
74 case BWRITERSPSM_NEG: return D3DSPSM_NEG;
75 case BWRITERSPSM_BIAS: return D3DSPSM_BIAS;
76 case BWRITERSPSM_BIASNEG: return D3DSPSM_BIASNEG;
77 case BWRITERSPSM_SIGN: return D3DSPSM_SIGN;
78 case BWRITERSPSM_SIGNNEG: return D3DSPSM_SIGNNEG;
79 case BWRITERSPSM_COMP: return D3DSPSM_COMP;
80 case BWRITERSPSM_X2: return D3DSPSM_X2;
81 case BWRITERSPSM_X2NEG: return D3DSPSM_X2NEG;
82 case BWRITERSPSM_DZ: return D3DSPSM_DZ;
83 case BWRITERSPSM_DW: return D3DSPSM_DW;
84 case BWRITERSPSM_ABS: return D3DSPSM_ABS;
85 case BWRITERSPSM_ABSNEG: return D3DSPSM_ABSNEG;
86 case BWRITERSPSM_NOT: return D3DSPSM_NOT;
88 FIXME("Unhandled BWRITERSPSM token %u\n", bwriter_srcmod);
93 DWORD d3d9_dstmod(DWORD bwriter_mod) {
96 if(bwriter_mod & BWRITERSPDM_SATURATE) ret |= D3DSPDM_SATURATE;
97 if(bwriter_mod & BWRITERSPDM_PARTIALPRECISION) ret |= D3DSPDM_PARTIALPRECISION;
98 if(bwriter_mod & BWRITERSPDM_MSAMPCENTROID) ret |= D3DSPDM_MSAMPCENTROID;
103 DWORD d3d9_comparetype(DWORD asmshader_comparetype) {
104 switch(asmshader_comparetype) {
105 case BWRITER_COMPARISON_GT: return D3DSPC_GT;
106 case BWRITER_COMPARISON_EQ: return D3DSPC_EQ;
107 case BWRITER_COMPARISON_GE: return D3DSPC_GE;
108 case BWRITER_COMPARISON_LT: return D3DSPC_LT;
109 case BWRITER_COMPARISON_NE: return D3DSPC_NE;
110 case BWRITER_COMPARISON_LE: return D3DSPC_LE;
112 FIXME("Unexpected BWRITER_COMPARISON type %u\n", asmshader_comparetype);
117 DWORD d3d9_sampler(DWORD bwriter_sampler) {
118 if(bwriter_sampler == BWRITERSTT_UNKNOWN) return D3DSTT_UNKNOWN;
119 if(bwriter_sampler == BWRITERSTT_1D) return D3DSTT_1D;
120 if(bwriter_sampler == BWRITERSTT_2D) return D3DSTT_2D;
121 if(bwriter_sampler == BWRITERSTT_CUBE) return D3DSTT_CUBE;
122 if(bwriter_sampler == BWRITERSTT_VOLUME) return D3DSTT_VOLUME;
123 FIXME("Unexpected BWRITERSAMPLER_TEXTURE_TYPE type %u\n", bwriter_sampler);
128 DWORD d3d9_register(DWORD bwriter_register) {
129 if(bwriter_register == BWRITERSPR_TEMP) return D3DSPR_TEMP;
130 if(bwriter_register == BWRITERSPR_INPUT) return D3DSPR_INPUT;
131 if(bwriter_register == BWRITERSPR_CONST) return D3DSPR_CONST;
132 if(bwriter_register == BWRITERSPR_ADDR) return D3DSPR_ADDR;
133 if(bwriter_register == BWRITERSPR_TEXTURE) return D3DSPR_TEXTURE;
134 if(bwriter_register == BWRITERSPR_RASTOUT) return D3DSPR_RASTOUT;
135 if(bwriter_register == BWRITERSPR_ATTROUT) return D3DSPR_ATTROUT;
136 if(bwriter_register == BWRITERSPR_TEXCRDOUT) return D3DSPR_TEXCRDOUT;
137 if(bwriter_register == BWRITERSPR_OUTPUT) return D3DSPR_OUTPUT;
138 if(bwriter_register == BWRITERSPR_CONSTINT) return D3DSPR_CONSTINT;
139 if(bwriter_register == BWRITERSPR_COLOROUT) return D3DSPR_COLOROUT;
140 if(bwriter_register == BWRITERSPR_DEPTHOUT) return D3DSPR_DEPTHOUT;
141 if(bwriter_register == BWRITERSPR_SAMPLER) return D3DSPR_SAMPLER;
142 if(bwriter_register == BWRITERSPR_CONSTBOOL) return D3DSPR_CONSTBOOL;
143 if(bwriter_register == BWRITERSPR_LOOP) return D3DSPR_LOOP;
144 if(bwriter_register == BWRITERSPR_MISCTYPE) return D3DSPR_MISCTYPE;
145 if(bwriter_register == BWRITERSPR_LABEL) return D3DSPR_LABEL;
146 if(bwriter_register == BWRITERSPR_PREDICATE) return D3DSPR_PREDICATE;
148 FIXME("Unexpected BWRITERSPR %u\n", bwriter_register);
152 DWORD d3d9_opcode(DWORD bwriter_opcode) {
153 switch(bwriter_opcode) {
154 case BWRITERSIO_NOP: return D3DSIO_NOP;
155 case BWRITERSIO_MOV: return D3DSIO_MOV;
156 case BWRITERSIO_ADD: return D3DSIO_ADD;
157 case BWRITERSIO_SUB: return D3DSIO_SUB;
158 case BWRITERSIO_MAD: return D3DSIO_MAD;
159 case BWRITERSIO_MUL: return D3DSIO_MUL;
160 case BWRITERSIO_RCP: return D3DSIO_RCP;
161 case BWRITERSIO_RSQ: return D3DSIO_RSQ;
162 case BWRITERSIO_DP3: return D3DSIO_DP3;
163 case BWRITERSIO_DP4: return D3DSIO_DP4;
164 case BWRITERSIO_MIN: return D3DSIO_MIN;
165 case BWRITERSIO_MAX: return D3DSIO_MAX;
166 case BWRITERSIO_SLT: return D3DSIO_SLT;
167 case BWRITERSIO_SGE: return D3DSIO_SGE;
168 case BWRITERSIO_EXP: return D3DSIO_EXP;
169 case BWRITERSIO_LOG: return D3DSIO_LOG;
170 case BWRITERSIO_LIT: return D3DSIO_LIT;
171 case BWRITERSIO_DST: return D3DSIO_DST;
172 case BWRITERSIO_LRP: return D3DSIO_LRP;
173 case BWRITERSIO_FRC: return D3DSIO_FRC;
174 case BWRITERSIO_M4x4: return D3DSIO_M4x4;
175 case BWRITERSIO_M4x3: return D3DSIO_M4x3;
176 case BWRITERSIO_M3x4: return D3DSIO_M3x4;
177 case BWRITERSIO_M3x3: return D3DSIO_M3x3;
178 case BWRITERSIO_M3x2: return D3DSIO_M3x2;
179 case BWRITERSIO_CALL: return D3DSIO_CALL;
180 case BWRITERSIO_CALLNZ: return D3DSIO_CALLNZ;
181 case BWRITERSIO_LOOP: return D3DSIO_LOOP;
182 case BWRITERSIO_RET: return D3DSIO_RET;
183 case BWRITERSIO_ENDLOOP: return D3DSIO_ENDLOOP;
184 case BWRITERSIO_LABEL: return D3DSIO_LABEL;
185 case BWRITERSIO_DCL: return D3DSIO_DCL;
186 case BWRITERSIO_POW: return D3DSIO_POW;
187 case BWRITERSIO_CRS: return D3DSIO_CRS;
188 case BWRITERSIO_SGN: return D3DSIO_SGN;
189 case BWRITERSIO_ABS: return D3DSIO_ABS;
190 case BWRITERSIO_NRM: return D3DSIO_NRM;
191 case BWRITERSIO_SINCOS: return D3DSIO_SINCOS;
192 case BWRITERSIO_REP: return D3DSIO_REP;
193 case BWRITERSIO_ENDREP: return D3DSIO_ENDREP;
194 case BWRITERSIO_IF: return D3DSIO_IF;
195 case BWRITERSIO_IFC: return D3DSIO_IFC;
196 case BWRITERSIO_ELSE: return D3DSIO_ELSE;
197 case BWRITERSIO_ENDIF: return D3DSIO_ENDIF;
198 case BWRITERSIO_BREAK: return D3DSIO_BREAK;
199 case BWRITERSIO_BREAKC: return D3DSIO_BREAKC;
200 case BWRITERSIO_MOVA: return D3DSIO_MOVA;
201 case BWRITERSIO_DEFB: return D3DSIO_DEFB;
202 case BWRITERSIO_DEFI: return D3DSIO_DEFI;
204 case BWRITERSIO_TEXCOORD: return D3DSIO_TEXCOORD;
205 case BWRITERSIO_TEXKILL: return D3DSIO_TEXKILL;
206 case BWRITERSIO_TEX: return D3DSIO_TEX;
207 case BWRITERSIO_TEXBEM: return D3DSIO_TEXBEM;
208 case BWRITERSIO_TEXBEML: return D3DSIO_TEXBEML;
209 case BWRITERSIO_TEXREG2AR: return D3DSIO_TEXREG2AR;
210 case BWRITERSIO_TEXREG2GB: return D3DSIO_TEXREG2GB;
211 case BWRITERSIO_TEXM3x2PAD: return D3DSIO_TEXM3x2PAD;
212 case BWRITERSIO_TEXM3x2TEX: return D3DSIO_TEXM3x2TEX;
213 case BWRITERSIO_TEXM3x3PAD: return D3DSIO_TEXM3x3PAD;
214 case BWRITERSIO_TEXM3x3TEX: return D3DSIO_TEXM3x3TEX;
215 case BWRITERSIO_TEXM3x3SPEC: return D3DSIO_TEXM3x3SPEC;
216 case BWRITERSIO_TEXM3x3VSPEC:return D3DSIO_TEXM3x3VSPEC;
217 case BWRITERSIO_EXPP: return D3DSIO_EXPP;
218 case BWRITERSIO_LOGP: return D3DSIO_LOGP;
219 case BWRITERSIO_CND: return D3DSIO_CND;
220 case BWRITERSIO_DEF: return D3DSIO_DEF;
221 case BWRITERSIO_TEXREG2RGB: return D3DSIO_TEXREG2RGB;
222 case BWRITERSIO_TEXDP3TEX: return D3DSIO_TEXDP3TEX;
223 case BWRITERSIO_TEXM3x2DEPTH:return D3DSIO_TEXM3x2DEPTH;
224 case BWRITERSIO_TEXDP3: return D3DSIO_TEXDP3;
225 case BWRITERSIO_TEXM3x3: return D3DSIO_TEXM3x3;
226 case BWRITERSIO_TEXDEPTH: return D3DSIO_TEXDEPTH;
227 case BWRITERSIO_CMP: return D3DSIO_CMP;
228 case BWRITERSIO_BEM: return D3DSIO_BEM;
229 case BWRITERSIO_DP2ADD: return D3DSIO_DP2ADD;
230 case BWRITERSIO_DSX: return D3DSIO_DSX;
231 case BWRITERSIO_DSY: return D3DSIO_DSY;
232 case BWRITERSIO_TEXLDD: return D3DSIO_TEXLDD;
233 case BWRITERSIO_SETP: return D3DSIO_SETP;
234 case BWRITERSIO_TEXLDL: return D3DSIO_TEXLDL;
235 case BWRITERSIO_BREAKP: return D3DSIO_BREAKP;
237 case BWRITERSIO_PHASE: return D3DSIO_PHASE;
238 case BWRITERSIO_COMMENT: return D3DSIO_COMMENT;
239 case BWRITERSIO_END: return D3DSIO_END;
241 case BWRITERSIO_TEXLDP: return D3DSIO_TEX | D3DSI_TEXLD_PROJECT;
242 case BWRITERSIO_TEXLDB: return D3DSIO_TEX | D3DSI_TEXLD_BIAS;
245 FIXME("Unhandled BWRITERSIO token %u\n", bwriter_opcode);
250 /* Debug print functions */
251 const char *debug_print_srcmod(DWORD mod) {
253 case BWRITERSPSM_NEG: return "D3DSPSM_NEG";
254 case BWRITERSPSM_BIAS: return "D3DSPSM_BIAS";
255 case BWRITERSPSM_BIASNEG: return "D3DSPSM_BIASNEG";
256 case BWRITERSPSM_SIGN: return "D3DSPSM_SIGN";
257 case BWRITERSPSM_SIGNNEG: return "D3DSPSM_SIGNNEG";
258 case BWRITERSPSM_COMP: return "D3DSPSM_COMP";
259 case BWRITERSPSM_X2: return "D3DSPSM_X2";
260 case BWRITERSPSM_X2NEG: return "D3DSPSM_X2NEG";
261 case BWRITERSPSM_DZ: return "D3DSPSM_DZ";
262 case BWRITERSPSM_DW: return "D3DSPSM_DW";
263 case BWRITERSPSM_ABS: return "D3DSPSM_ABS";
264 case BWRITERSPSM_ABSNEG: return "D3DSPSM_ABSNEG";
265 case BWRITERSPSM_NOT: return "D3DSPSM_NOT";
266 default: return "Unknown source modifier\n";
270 const char *debug_print_dstmod(DWORD mod) {
275 case BWRITERSPDM_SATURATE:
277 case BWRITERSPDM_PARTIALPRECISION:
279 case BWRITERSPDM_MSAMPCENTROID:
282 case BWRITERSPDM_SATURATE | BWRITERSPDM_PARTIALPRECISION:
284 case BWRITERSPDM_SATURATE | BWRITERSPDM_MSAMPCENTROID:
285 return "_sat_centroid";
286 case BWRITERSPDM_PARTIALPRECISION | BWRITERSPDM_MSAMPCENTROID:
287 return "_pp_centroid";
289 case BWRITERSPDM_SATURATE | BWRITERSPDM_PARTIALPRECISION | BWRITERSPDM_MSAMPCENTROID:
290 return "_sat_pp_centroid";
293 return "Unexpected modifier\n";
297 const char *debug_print_shift(DWORD shift) {
298 static const char * const shiftstrings[] = {
316 return shiftstrings[shift];
319 static const char *get_regname(const struct shader_reg *reg) {
321 case BWRITERSPR_TEMP:
322 return wine_dbg_sprintf("r%u", reg->regnum);
323 case BWRITERSPR_INPUT:
324 return wine_dbg_sprintf("v%u", reg->regnum);
325 case BWRITERSPR_CONST:
326 return wine_dbg_sprintf("c%u", reg->regnum);
327 case BWRITERSPR_ADDR:
328 return wine_dbg_sprintf("a%u", reg->regnum);
329 case BWRITERSPR_TEXTURE:
330 return wine_dbg_sprintf("t%u", reg->regnum);
331 case BWRITERSPR_RASTOUT:
332 switch(reg->regnum) {
333 case BWRITERSRO_POSITION: return "oPos";
334 case BWRITERSRO_FOG: return "oFog";
335 case BWRITERSRO_POINT_SIZE: return "oPts";
336 default: return "Unexpected RASTOUT";
338 case BWRITERSPR_ATTROUT:
339 return wine_dbg_sprintf("oD%u", reg->regnum);
340 case BWRITERSPR_TEXCRDOUT:
341 return wine_dbg_sprintf("oT%u", reg->regnum);
342 case BWRITERSPR_OUTPUT:
343 return wine_dbg_sprintf("o%u", reg->regnum);
344 case BWRITERSPR_CONSTINT:
345 return wine_dbg_sprintf("i%u", reg->regnum);
346 case BWRITERSPR_COLOROUT:
347 return wine_dbg_sprintf("oC%u", reg->regnum);
348 case BWRITERSPR_DEPTHOUT:
350 case BWRITERSPR_SAMPLER:
351 return wine_dbg_sprintf("s%u", reg->regnum);
352 case BWRITERSPR_CONSTBOOL:
353 return wine_dbg_sprintf("b%u", reg->regnum);
354 case BWRITERSPR_LOOP:
356 case BWRITERSPR_MISCTYPE:
357 switch(reg->regnum) {
358 case 0: return "vPos";
359 case 1: return "vFace";
360 case 2: return "unexpected misctype";
362 case BWRITERSPR_LABEL:
363 return wine_dbg_sprintf("l%u", reg->regnum);
364 case BWRITERSPR_PREDICATE:
365 return wine_dbg_sprintf("p%u", reg->regnum);
367 return wine_dbg_sprintf("unknown regname %#x", reg->type);
371 const char *debug_print_writemask(DWORD mask) {
373 unsigned char pos = 1;
375 if(mask == BWRITERSP_WRITEMASK_ALL) return "";
377 if(mask & BWRITERSP_WRITEMASK_0) ret[pos++] = 'x';
378 if(mask & BWRITERSP_WRITEMASK_1) ret[pos++] = 'y';
379 if(mask & BWRITERSP_WRITEMASK_2) ret[pos++] = 'z';
380 if(mask & BWRITERSP_WRITEMASK_3) ret[pos++] = 'w';
382 return wine_dbg_sprintf("%s", ret);
385 const char *debug_print_relarg(const struct shader_reg *reg) {
386 const char *short_swizzle;
387 if(!reg->rel_reg) return "";
389 short_swizzle = debug_print_swizzle(reg->rel_reg->swizzle);
391 if(reg->rel_reg->type == BWRITERSPR_ADDR) {
392 return wine_dbg_sprintf("[a%u%s]", reg->rel_reg->regnum, short_swizzle);
393 } else if(reg->rel_reg->type == BWRITERSPR_LOOP && reg->rel_reg->regnum == 0) {
394 return wine_dbg_sprintf("[aL%s]", short_swizzle);
396 return "Unexpected relative addressing argument";
400 const char *debug_print_dstreg(const struct shader_reg *reg) {
401 return wine_dbg_sprintf("%s%s%s", get_regname(reg),
402 debug_print_relarg(reg),
403 debug_print_writemask(reg->writemask));
406 const char *debug_print_swizzle(DWORD arg) {
412 case BWRITERVS_NOSWIZZLE:
414 case BWRITERVS_SWIZZLE_X:
416 case BWRITERVS_SWIZZLE_Y:
418 case BWRITERVS_SWIZZLE_Z:
420 case BWRITERVS_SWIZZLE_W:
424 swizzle[0] = (arg >> (BWRITERVS_SWIZZLE_SHIFT + 0)) & 0x03;
425 swizzle[1] = (arg >> (BWRITERVS_SWIZZLE_SHIFT + 2)) & 0x03;
426 swizzle[2] = (arg >> (BWRITERVS_SWIZZLE_SHIFT + 4)) & 0x03;
427 swizzle[3] = (arg >> (BWRITERVS_SWIZZLE_SHIFT + 6)) & 0x03;
430 for(i = 0; i < 4; i++) {
432 case 0: ret[1 + i] = 'x'; break;
433 case 1: ret[1 + i] = 'y'; break;
434 case 2: ret[1 + i] = 'z'; break;
435 case 3: ret[1 + i] = 'w'; break;
439 return wine_dbg_sprintf("%s", ret);
442 const char *debug_print_srcreg(const struct shader_reg *reg) {
443 switch(reg->srcmod) {
444 case BWRITERSPSM_NONE:
445 return wine_dbg_sprintf("%s%s%s", get_regname(reg),
446 debug_print_relarg(reg),
447 debug_print_swizzle(reg->swizzle));
448 case BWRITERSPSM_NEG:
449 return wine_dbg_sprintf("-%s%s%s", get_regname(reg),
450 debug_print_relarg(reg),
451 debug_print_swizzle(reg->swizzle));
452 case BWRITERSPSM_BIAS:
453 return wine_dbg_sprintf("%s%s_bias%s", get_regname(reg),
454 debug_print_relarg(reg),
455 debug_print_swizzle(reg->swizzle));
456 case BWRITERSPSM_BIASNEG:
457 return wine_dbg_sprintf("-%s%s_bias%s", get_regname(reg),
458 debug_print_relarg(reg),
459 debug_print_swizzle(reg->swizzle));
460 case BWRITERSPSM_SIGN:
461 return wine_dbg_sprintf("%s%s_bx2%s", get_regname(reg),
462 debug_print_relarg(reg),
463 debug_print_swizzle(reg->swizzle));
464 case BWRITERSPSM_SIGNNEG:
465 return wine_dbg_sprintf("-%s%s_bx2%s", get_regname(reg),
466 debug_print_relarg(reg),
467 debug_print_swizzle(reg->swizzle));
468 case BWRITERSPSM_COMP:
469 return wine_dbg_sprintf("1 - %s%s%s", get_regname(reg),
470 debug_print_relarg(reg),
471 debug_print_swizzle(reg->swizzle));
473 return wine_dbg_sprintf("%s%s_x2%s", get_regname(reg),
474 debug_print_relarg(reg),
475 debug_print_swizzle(reg->swizzle));
476 case BWRITERSPSM_X2NEG:
477 return wine_dbg_sprintf("-%s%s_x2%s", get_regname(reg),
478 debug_print_relarg(reg),
479 debug_print_swizzle(reg->swizzle));
481 return wine_dbg_sprintf("%s%s_dz%s", get_regname(reg),
482 debug_print_relarg(reg),
483 debug_print_swizzle(reg->swizzle));
485 return wine_dbg_sprintf("%s%s_dw%s", get_regname(reg),
486 debug_print_relarg(reg),
487 debug_print_swizzle(reg->swizzle));
488 case BWRITERSPSM_ABS:
489 return wine_dbg_sprintf("%s%s_abs%s", get_regname(reg),
490 debug_print_relarg(reg),
491 debug_print_swizzle(reg->swizzle));
492 case BWRITERSPSM_ABSNEG:
493 return wine_dbg_sprintf("-%s%s_abs%s", get_regname(reg),
494 debug_print_relarg(reg),
495 debug_print_swizzle(reg->swizzle));
496 case BWRITERSPSM_NOT:
497 return wine_dbg_sprintf("!%s%s%s", get_regname(reg),
498 debug_print_relarg(reg),
499 debug_print_swizzle(reg->swizzle));
501 return "Unknown modifier";
504 const char *debug_print_comp(DWORD comp) {
506 case BWRITER_COMPARISON_NONE: return "";
507 case BWRITER_COMPARISON_GT: return "_gt";
508 case BWRITER_COMPARISON_EQ: return "_eq";
509 case BWRITER_COMPARISON_GE: return "_ge";
510 case BWRITER_COMPARISON_LT: return "_lt";
511 case BWRITER_COMPARISON_NE: return "_ne";
512 case BWRITER_COMPARISON_LE: return "_le";
513 default: return "_unknown";
517 const char *debug_print_opcode(DWORD opcode) {
519 case BWRITERSIO_NOP: return "nop";
520 case BWRITERSIO_MOV: return "mov";
521 case BWRITERSIO_ADD: return "add";
522 case BWRITERSIO_SUB: return "sub";
523 case BWRITERSIO_MAD: return "mad";
524 case BWRITERSIO_MUL: return "mul";
525 case BWRITERSIO_RCP: return "rcp";
526 case BWRITERSIO_RSQ: return "rsq";
527 case BWRITERSIO_DP3: return "dp3";
528 case BWRITERSIO_DP4: return "dp4";
529 case BWRITERSIO_MIN: return "min";
530 case BWRITERSIO_MAX: return "max";
531 case BWRITERSIO_SLT: return "slt";
532 case BWRITERSIO_SGE: return "sge";
533 case BWRITERSIO_EXP: return "exp";
534 case BWRITERSIO_LOG: return "log";
535 case BWRITERSIO_LIT: return "lit";
536 case BWRITERSIO_DST: return "dst";
537 case BWRITERSIO_LRP: return "lrp";
538 case BWRITERSIO_FRC: return "frc";
539 case BWRITERSIO_M4x4: return "m4x4";
540 case BWRITERSIO_M4x3: return "m4x3";
541 case BWRITERSIO_M3x4: return "m3x4";
542 case BWRITERSIO_M3x3: return "m3x3";
543 case BWRITERSIO_M3x2: return "m3x2";
544 case BWRITERSIO_CALL: return "call";
545 case BWRITERSIO_CALLNZ: return "callnz";
546 case BWRITERSIO_LOOP: return "loop";
547 case BWRITERSIO_RET: return "ret";
548 case BWRITERSIO_ENDLOOP: return "endloop";
549 case BWRITERSIO_LABEL: return "label";
550 case BWRITERSIO_DCL: return "dcl";
551 case BWRITERSIO_POW: return "pow";
552 case BWRITERSIO_CRS: return "crs";
553 case BWRITERSIO_SGN: return "sgn";
554 case BWRITERSIO_ABS: return "abs";
555 case BWRITERSIO_NRM: return "nrm";
556 case BWRITERSIO_SINCOS: return "sincos";
557 case BWRITERSIO_REP: return "rep";
558 case BWRITERSIO_ENDREP: return "endrep";
559 case BWRITERSIO_IF: return "if";
560 case BWRITERSIO_IFC: return "ifc";
561 case BWRITERSIO_ELSE: return "else";
562 case BWRITERSIO_ENDIF: return "endif";
563 case BWRITERSIO_BREAK: return "break";
564 case BWRITERSIO_BREAKC: return "breakc";
565 case BWRITERSIO_MOVA: return "mova";
566 case BWRITERSIO_DEFB: return "defb";
567 case BWRITERSIO_DEFI: return "defi";
568 case BWRITERSIO_TEXCOORD: return "texcoord";
569 case BWRITERSIO_TEXKILL: return "texkill";
570 case BWRITERSIO_TEX: return "tex";
571 case BWRITERSIO_TEXBEM: return "texbem";
572 case BWRITERSIO_TEXBEML: return "texbeml";
573 case BWRITERSIO_TEXREG2AR: return "texreg2ar";
574 case BWRITERSIO_TEXREG2GB: return "texreg2gb";
575 case BWRITERSIO_TEXM3x2PAD: return "texm3x2pad";
576 case BWRITERSIO_TEXM3x2TEX: return "texm3x2tex";
577 case BWRITERSIO_TEXM3x3PAD: return "texm3x3pad";
578 case BWRITERSIO_TEXM3x3TEX: return "texm3x3tex";
579 case BWRITERSIO_TEXM3x3SPEC: return "texm3x3vspec";
580 case BWRITERSIO_TEXM3x3VSPEC: return "texm3x3vspec";
581 case BWRITERSIO_EXPP: return "expp";
582 case BWRITERSIO_LOGP: return "logp";
583 case BWRITERSIO_CND: return "cnd";
584 case BWRITERSIO_DEF: return "def";
585 case BWRITERSIO_TEXREG2RGB: return "texreg2rgb";
586 case BWRITERSIO_TEXDP3TEX: return "texdp3tex";
587 case BWRITERSIO_TEXM3x2DEPTH: return "texm3x2depth";
588 case BWRITERSIO_TEXDP3: return "texdp3";
589 case BWRITERSIO_TEXM3x3: return "texm3x3";
590 case BWRITERSIO_TEXDEPTH: return "texdepth";
591 case BWRITERSIO_CMP: return "cmp";
592 case BWRITERSIO_BEM: return "bem";
593 case BWRITERSIO_DP2ADD: return "dp2add";
594 case BWRITERSIO_DSX: return "dsx";
595 case BWRITERSIO_DSY: return "dsy";
596 case BWRITERSIO_TEXLDD: return "texldd";
597 case BWRITERSIO_SETP: return "setp";
598 case BWRITERSIO_TEXLDL: return "texldl";
599 case BWRITERSIO_BREAKP: return "breakp";
600 case BWRITERSIO_PHASE: return "phase";
602 case BWRITERSIO_TEXLDP: return "texldp";
603 case BWRITERSIO_TEXLDB: return "texldb";
605 default: return "unknown";