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 "d3d9types.h"
27 #include "d3dcompiler_private.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(asmshader
);
31 /* bwriter -> d3d9 conversion functions */
32 DWORD
d3d9_swizzle(DWORD bwriter_swizzle
) {
33 /* Currently a NOP, but this allows changing the internal definitions
34 * without side effects
38 if((bwriter_swizzle
& BWRITERVS_X_X
) == BWRITERVS_X_X
) ret
|= D3DVS_X_X
;
39 if((bwriter_swizzle
& BWRITERVS_X_Y
) == BWRITERVS_X_Y
) ret
|= D3DVS_X_Y
;
40 if((bwriter_swizzle
& BWRITERVS_X_Z
) == BWRITERVS_X_Z
) ret
|= D3DVS_X_Z
;
41 if((bwriter_swizzle
& BWRITERVS_X_W
) == BWRITERVS_X_W
) ret
|= D3DVS_X_W
;
43 if((bwriter_swizzle
& BWRITERVS_Y_X
) == BWRITERVS_Y_X
) ret
|= D3DVS_Y_X
;
44 if((bwriter_swizzle
& BWRITERVS_Y_Y
) == BWRITERVS_Y_Y
) ret
|= D3DVS_Y_Y
;
45 if((bwriter_swizzle
& BWRITERVS_Y_Z
) == BWRITERVS_Y_Z
) ret
|= D3DVS_Y_Z
;
46 if((bwriter_swizzle
& BWRITERVS_Y_W
) == BWRITERVS_Y_W
) ret
|= D3DVS_Y_W
;
48 if((bwriter_swizzle
& BWRITERVS_Z_X
) == BWRITERVS_Z_X
) ret
|= D3DVS_Z_X
;
49 if((bwriter_swizzle
& BWRITERVS_Z_Y
) == BWRITERVS_Z_Y
) ret
|= D3DVS_Z_Y
;
50 if((bwriter_swizzle
& BWRITERVS_Z_Z
) == BWRITERVS_Z_Z
) ret
|= D3DVS_Z_Z
;
51 if((bwriter_swizzle
& BWRITERVS_Z_W
) == BWRITERVS_Z_W
) ret
|= D3DVS_Z_W
;
53 if((bwriter_swizzle
& BWRITERVS_W_X
) == BWRITERVS_W_X
) ret
|= D3DVS_W_X
;
54 if((bwriter_swizzle
& BWRITERVS_W_Y
) == BWRITERVS_W_Y
) ret
|= D3DVS_W_Y
;
55 if((bwriter_swizzle
& BWRITERVS_W_Z
) == BWRITERVS_W_Z
) ret
|= D3DVS_W_Z
;
56 if((bwriter_swizzle
& BWRITERVS_W_W
) == BWRITERVS_W_W
) ret
|= D3DVS_W_W
;
61 DWORD
d3d9_writemask(DWORD bwriter_writemask
) {
64 if(bwriter_writemask
& BWRITERSP_WRITEMASK_0
) ret
|= D3DSP_WRITEMASK_0
;
65 if(bwriter_writemask
& BWRITERSP_WRITEMASK_1
) ret
|= D3DSP_WRITEMASK_1
;
66 if(bwriter_writemask
& BWRITERSP_WRITEMASK_2
) ret
|= D3DSP_WRITEMASK_2
;
67 if(bwriter_writemask
& BWRITERSP_WRITEMASK_3
) ret
|= D3DSP_WRITEMASK_3
;
72 DWORD
d3d9_srcmod(DWORD bwriter_srcmod
) {
73 switch(bwriter_srcmod
) {
74 case BWRITERSPSM_NONE
: return D3DSPSM_NONE
;
75 case BWRITERSPSM_NEG
: return D3DSPSM_NEG
;
76 case BWRITERSPSM_BIAS
: return D3DSPSM_BIAS
;
77 case BWRITERSPSM_BIASNEG
: return D3DSPSM_BIASNEG
;
78 case BWRITERSPSM_SIGN
: return D3DSPSM_SIGN
;
79 case BWRITERSPSM_SIGNNEG
: return D3DSPSM_SIGNNEG
;
80 case BWRITERSPSM_COMP
: return D3DSPSM_COMP
;
81 case BWRITERSPSM_X2
: return D3DSPSM_X2
;
82 case BWRITERSPSM_X2NEG
: return D3DSPSM_X2NEG
;
83 case BWRITERSPSM_DZ
: return D3DSPSM_DZ
;
84 case BWRITERSPSM_DW
: return D3DSPSM_DW
;
85 case BWRITERSPSM_ABS
: return D3DSPSM_ABS
;
86 case BWRITERSPSM_ABSNEG
: return D3DSPSM_ABSNEG
;
87 case BWRITERSPSM_NOT
: return D3DSPSM_NOT
;
89 FIXME("Unhandled BWRITERSPSM token %u\n", bwriter_srcmod
);
94 DWORD
d3d9_dstmod(DWORD bwriter_mod
) {
97 if(bwriter_mod
& BWRITERSPDM_SATURATE
) ret
|= D3DSPDM_SATURATE
;
98 if(bwriter_mod
& BWRITERSPDM_PARTIALPRECISION
) ret
|= D3DSPDM_PARTIALPRECISION
;
99 if(bwriter_mod
& BWRITERSPDM_MSAMPCENTROID
) ret
|= D3DSPDM_MSAMPCENTROID
;
104 DWORD
d3d9_comparetype(DWORD asmshader_comparetype
) {
105 switch(asmshader_comparetype
) {
106 case BWRITER_COMPARISON_GT
: return D3DSPC_GT
;
107 case BWRITER_COMPARISON_EQ
: return D3DSPC_EQ
;
108 case BWRITER_COMPARISON_GE
: return D3DSPC_GE
;
109 case BWRITER_COMPARISON_LT
: return D3DSPC_LT
;
110 case BWRITER_COMPARISON_NE
: return D3DSPC_NE
;
111 case BWRITER_COMPARISON_LE
: return D3DSPC_LE
;
113 FIXME("Unexpected BWRITER_COMPARISON type %u\n", asmshader_comparetype
);
118 DWORD
d3d9_sampler(DWORD bwriter_sampler
) {
119 if(bwriter_sampler
== BWRITERSTT_UNKNOWN
) return D3DSTT_UNKNOWN
;
120 if(bwriter_sampler
== BWRITERSTT_1D
) return D3DSTT_1D
;
121 if(bwriter_sampler
== BWRITERSTT_2D
) return D3DSTT_2D
;
122 if(bwriter_sampler
== BWRITERSTT_CUBE
) return D3DSTT_CUBE
;
123 if(bwriter_sampler
== BWRITERSTT_VOLUME
) return D3DSTT_VOLUME
;
124 FIXME("Unexpected BWRITERSAMPLER_TEXTURE_TYPE type %u\n", bwriter_sampler
);
129 DWORD
d3d9_register(DWORD bwriter_register
) {
130 if(bwriter_register
== BWRITERSPR_TEMP
) return D3DSPR_TEMP
;
131 if(bwriter_register
== BWRITERSPR_INPUT
) return D3DSPR_INPUT
;
132 if(bwriter_register
== BWRITERSPR_CONST
) return D3DSPR_CONST
;
133 if(bwriter_register
== BWRITERSPR_ADDR
) return D3DSPR_ADDR
;
134 if(bwriter_register
== BWRITERSPR_TEXTURE
) return D3DSPR_TEXTURE
;
135 if(bwriter_register
== BWRITERSPR_RASTOUT
) return D3DSPR_RASTOUT
;
136 if(bwriter_register
== BWRITERSPR_ATTROUT
) return D3DSPR_ATTROUT
;
137 if(bwriter_register
== BWRITERSPR_TEXCRDOUT
) return D3DSPR_TEXCRDOUT
;
138 if(bwriter_register
== BWRITERSPR_OUTPUT
) return D3DSPR_OUTPUT
;
139 if(bwriter_register
== BWRITERSPR_CONSTINT
) return D3DSPR_CONSTINT
;
140 if(bwriter_register
== BWRITERSPR_COLOROUT
) return D3DSPR_COLOROUT
;
141 if(bwriter_register
== BWRITERSPR_DEPTHOUT
) return D3DSPR_DEPTHOUT
;
142 if(bwriter_register
== BWRITERSPR_SAMPLER
) return D3DSPR_SAMPLER
;
143 if(bwriter_register
== BWRITERSPR_CONSTBOOL
) return D3DSPR_CONSTBOOL
;
144 if(bwriter_register
== BWRITERSPR_LOOP
) return D3DSPR_LOOP
;
145 if(bwriter_register
== BWRITERSPR_MISCTYPE
) return D3DSPR_MISCTYPE
;
146 if(bwriter_register
== BWRITERSPR_LABEL
) return D3DSPR_LABEL
;
147 if(bwriter_register
== BWRITERSPR_PREDICATE
) return D3DSPR_PREDICATE
;
149 FIXME("Unexpected BWRITERSPR %u\n", bwriter_register
);
153 DWORD
d3d9_opcode(DWORD bwriter_opcode
) {
154 switch(bwriter_opcode
) {
155 case BWRITERSIO_NOP
: return D3DSIO_NOP
;
156 case BWRITERSIO_MOV
: return D3DSIO_MOV
;
157 case BWRITERSIO_ADD
: return D3DSIO_ADD
;
158 case BWRITERSIO_SUB
: return D3DSIO_SUB
;
159 case BWRITERSIO_MAD
: return D3DSIO_MAD
;
160 case BWRITERSIO_MUL
: return D3DSIO_MUL
;
161 case BWRITERSIO_RCP
: return D3DSIO_RCP
;
162 case BWRITERSIO_RSQ
: return D3DSIO_RSQ
;
163 case BWRITERSIO_DP3
: return D3DSIO_DP3
;
164 case BWRITERSIO_DP4
: return D3DSIO_DP4
;
165 case BWRITERSIO_MIN
: return D3DSIO_MIN
;
166 case BWRITERSIO_MAX
: return D3DSIO_MAX
;
167 case BWRITERSIO_SLT
: return D3DSIO_SLT
;
168 case BWRITERSIO_SGE
: return D3DSIO_SGE
;
169 case BWRITERSIO_EXP
: return D3DSIO_EXP
;
170 case BWRITERSIO_LOG
: return D3DSIO_LOG
;
171 case BWRITERSIO_LIT
: return D3DSIO_LIT
;
172 case BWRITERSIO_DST
: return D3DSIO_DST
;
173 case BWRITERSIO_LRP
: return D3DSIO_LRP
;
174 case BWRITERSIO_FRC
: return D3DSIO_FRC
;
175 case BWRITERSIO_M4x4
: return D3DSIO_M4x4
;
176 case BWRITERSIO_M4x3
: return D3DSIO_M4x3
;
177 case BWRITERSIO_M3x4
: return D3DSIO_M3x4
;
178 case BWRITERSIO_M3x3
: return D3DSIO_M3x3
;
179 case BWRITERSIO_M3x2
: return D3DSIO_M3x2
;
180 case BWRITERSIO_CALL
: return D3DSIO_CALL
;
181 case BWRITERSIO_CALLNZ
: return D3DSIO_CALLNZ
;
182 case BWRITERSIO_LOOP
: return D3DSIO_LOOP
;
183 case BWRITERSIO_RET
: return D3DSIO_RET
;
184 case BWRITERSIO_ENDLOOP
: return D3DSIO_ENDLOOP
;
185 case BWRITERSIO_LABEL
: return D3DSIO_LABEL
;
186 case BWRITERSIO_DCL
: return D3DSIO_DCL
;
187 case BWRITERSIO_POW
: return D3DSIO_POW
;
188 case BWRITERSIO_CRS
: return D3DSIO_CRS
;
189 case BWRITERSIO_SGN
: return D3DSIO_SGN
;
190 case BWRITERSIO_ABS
: return D3DSIO_ABS
;
191 case BWRITERSIO_NRM
: return D3DSIO_NRM
;
192 case BWRITERSIO_SINCOS
: return D3DSIO_SINCOS
;
193 case BWRITERSIO_REP
: return D3DSIO_REP
;
194 case BWRITERSIO_ENDREP
: return D3DSIO_ENDREP
;
195 case BWRITERSIO_IF
: return D3DSIO_IF
;
196 case BWRITERSIO_IFC
: return D3DSIO_IFC
;
197 case BWRITERSIO_ELSE
: return D3DSIO_ELSE
;
198 case BWRITERSIO_ENDIF
: return D3DSIO_ENDIF
;
199 case BWRITERSIO_BREAK
: return D3DSIO_BREAK
;
200 case BWRITERSIO_BREAKC
: return D3DSIO_BREAKC
;
201 case BWRITERSIO_MOVA
: return D3DSIO_MOVA
;
202 case BWRITERSIO_DEFB
: return D3DSIO_DEFB
;
203 case BWRITERSIO_DEFI
: return D3DSIO_DEFI
;
205 case BWRITERSIO_TEXCOORD
: return D3DSIO_TEXCOORD
;
206 case BWRITERSIO_TEXKILL
: return D3DSIO_TEXKILL
;
207 case BWRITERSIO_TEX
: return D3DSIO_TEX
;
208 case BWRITERSIO_TEXBEM
: return D3DSIO_TEXBEM
;
209 case BWRITERSIO_TEXBEML
: return D3DSIO_TEXBEML
;
210 case BWRITERSIO_TEXREG2AR
: return D3DSIO_TEXREG2AR
;
211 case BWRITERSIO_TEXREG2GB
: return D3DSIO_TEXREG2GB
;
212 case BWRITERSIO_TEXM3x2PAD
: return D3DSIO_TEXM3x2PAD
;
213 case BWRITERSIO_TEXM3x2TEX
: return D3DSIO_TEXM3x2TEX
;
214 case BWRITERSIO_TEXM3x3PAD
: return D3DSIO_TEXM3x3PAD
;
215 case BWRITERSIO_TEXM3x3TEX
: return D3DSIO_TEXM3x3TEX
;
216 case BWRITERSIO_TEXM3x3SPEC
: return D3DSIO_TEXM3x3SPEC
;
217 case BWRITERSIO_TEXM3x3VSPEC
:return D3DSIO_TEXM3x3VSPEC
;
218 case BWRITERSIO_EXPP
: return D3DSIO_EXPP
;
219 case BWRITERSIO_LOGP
: return D3DSIO_LOGP
;
220 case BWRITERSIO_CND
: return D3DSIO_CND
;
221 case BWRITERSIO_DEF
: return D3DSIO_DEF
;
222 case BWRITERSIO_TEXREG2RGB
: return D3DSIO_TEXREG2RGB
;
223 case BWRITERSIO_TEXDP3TEX
: return D3DSIO_TEXDP3TEX
;
224 case BWRITERSIO_TEXM3x2DEPTH
:return D3DSIO_TEXM3x2DEPTH
;
225 case BWRITERSIO_TEXDP3
: return D3DSIO_TEXDP3
;
226 case BWRITERSIO_TEXM3x3
: return D3DSIO_TEXM3x3
;
227 case BWRITERSIO_TEXDEPTH
: return D3DSIO_TEXDEPTH
;
228 case BWRITERSIO_CMP
: return D3DSIO_CMP
;
229 case BWRITERSIO_BEM
: return D3DSIO_BEM
;
230 case BWRITERSIO_DP2ADD
: return D3DSIO_DP2ADD
;
231 case BWRITERSIO_DSX
: return D3DSIO_DSX
;
232 case BWRITERSIO_DSY
: return D3DSIO_DSY
;
233 case BWRITERSIO_TEXLDD
: return D3DSIO_TEXLDD
;
234 case BWRITERSIO_SETP
: return D3DSIO_SETP
;
235 case BWRITERSIO_TEXLDL
: return D3DSIO_TEXLDL
;
236 case BWRITERSIO_BREAKP
: return D3DSIO_BREAKP
;
238 case BWRITERSIO_PHASE
: return D3DSIO_PHASE
;
239 case BWRITERSIO_COMMENT
: return D3DSIO_COMMENT
;
240 case BWRITERSIO_END
: return D3DSIO_END
;
242 case BWRITERSIO_TEXLDP
: return D3DSIO_TEX
| D3DSI_TEXLD_PROJECT
;
243 case BWRITERSIO_TEXLDB
: return D3DSIO_TEX
| D3DSI_TEXLD_BIAS
;
246 FIXME("Unhandled BWRITERSIO token %u\n", bwriter_opcode
);
251 /* Debug print functions */
252 const char *debug_print_srcmod(DWORD mod
) {
254 case BWRITERSPSM_NEG
: return "D3DSPSM_NEG";
255 case BWRITERSPSM_BIAS
: return "D3DSPSM_BIAS";
256 case BWRITERSPSM_BIASNEG
: return "D3DSPSM_BIASNEG";
257 case BWRITERSPSM_SIGN
: return "D3DSPSM_SIGN";
258 case BWRITERSPSM_SIGNNEG
: return "D3DSPSM_SIGNNEG";
259 case BWRITERSPSM_COMP
: return "D3DSPSM_COMP";
260 case BWRITERSPSM_X2
: return "D3DSPSM_X2";
261 case BWRITERSPSM_X2NEG
: return "D3DSPSM_X2NEG";
262 case BWRITERSPSM_DZ
: return "D3DSPSM_DZ";
263 case BWRITERSPSM_DW
: return "D3DSPSM_DW";
264 case BWRITERSPSM_ABS
: return "D3DSPSM_ABS";
265 case BWRITERSPSM_ABSNEG
: return "D3DSPSM_ABSNEG";
266 case BWRITERSPSM_NOT
: return "D3DSPSM_NOT";
267 default: return "Unknown source modifier\n";
271 const char *debug_print_dstmod(DWORD mod
) {
276 case BWRITERSPDM_SATURATE
:
278 case BWRITERSPDM_PARTIALPRECISION
:
280 case BWRITERSPDM_MSAMPCENTROID
:
283 case BWRITERSPDM_SATURATE
| BWRITERSPDM_PARTIALPRECISION
:
285 case BWRITERSPDM_SATURATE
| BWRITERSPDM_MSAMPCENTROID
:
286 return "_sat_centroid";
287 case BWRITERSPDM_PARTIALPRECISION
| BWRITERSPDM_MSAMPCENTROID
:
288 return "_pp_centroid";
290 case BWRITERSPDM_SATURATE
| BWRITERSPDM_PARTIALPRECISION
| BWRITERSPDM_MSAMPCENTROID
:
291 return "_sat_pp_centroid";
294 return "Unexpected modifier\n";
298 const char *debug_print_shift(DWORD shift
) {
299 static const char * const shiftstrings
[] = {
317 return shiftstrings
[shift
];
320 static const char *get_regname(const struct shader_reg
*reg
) {
322 case BWRITERSPR_TEMP
:
323 return wine_dbg_sprintf("r%u", reg
->regnum
);
324 case BWRITERSPR_INPUT
:
325 return wine_dbg_sprintf("v%u", reg
->regnum
);
326 case BWRITERSPR_CONST
:
327 return wine_dbg_sprintf("c%u", reg
->regnum
);
328 case BWRITERSPR_ADDR
:
329 return wine_dbg_sprintf("a%u", reg
->regnum
);
330 case BWRITERSPR_TEXTURE
:
331 return wine_dbg_sprintf("t%u", reg
->regnum
);
332 case BWRITERSPR_RASTOUT
:
333 switch(reg
->regnum
) {
334 case BWRITERSRO_POSITION
: return "oPos";
335 case BWRITERSRO_FOG
: return "oFog";
336 case BWRITERSRO_POINT_SIZE
: return "oPts";
337 default: return "Unexpected RASTOUT";
339 case BWRITERSPR_ATTROUT
:
340 return wine_dbg_sprintf("oD%u", reg
->regnum
);
341 case BWRITERSPR_TEXCRDOUT
:
342 return wine_dbg_sprintf("oT%u", reg
->regnum
);
343 case BWRITERSPR_OUTPUT
:
344 return wine_dbg_sprintf("o%u", reg
->regnum
);
345 case BWRITERSPR_CONSTINT
:
346 return wine_dbg_sprintf("i%u", reg
->regnum
);
347 case BWRITERSPR_COLOROUT
:
348 return wine_dbg_sprintf("oC%u", reg
->regnum
);
349 case BWRITERSPR_DEPTHOUT
:
351 case BWRITERSPR_SAMPLER
:
352 return wine_dbg_sprintf("s%u", reg
->regnum
);
353 case BWRITERSPR_CONSTBOOL
:
354 return wine_dbg_sprintf("b%u", reg
->regnum
);
355 case BWRITERSPR_LOOP
:
357 case BWRITERSPR_MISCTYPE
:
358 switch(reg
->regnum
) {
359 case 0: return "vPos";
360 case 1: return "vFace";
361 case 2: return "unexpected misctype";
363 case BWRITERSPR_LABEL
:
364 return wine_dbg_sprintf("l%u", reg
->regnum
);
365 case BWRITERSPR_PREDICATE
:
366 return wine_dbg_sprintf("p%u", reg
->regnum
);
368 return wine_dbg_sprintf("unknown regname %#x", reg
->type
);
372 static const char *debug_print_writemask(DWORD mask
) {
374 unsigned char pos
= 1;
376 if(mask
== BWRITERSP_WRITEMASK_ALL
) return "";
378 if(mask
& BWRITERSP_WRITEMASK_0
) ret
[pos
++] = 'x';
379 if(mask
& BWRITERSP_WRITEMASK_1
) ret
[pos
++] = 'y';
380 if(mask
& BWRITERSP_WRITEMASK_2
) ret
[pos
++] = 'z';
381 if(mask
& BWRITERSP_WRITEMASK_3
) ret
[pos
++] = 'w';
383 return wine_dbg_sprintf("%s", ret
);
386 static const char *debug_print_swizzle(DWORD arg
) {
392 case BWRITERVS_NOSWIZZLE
:
394 case BWRITERVS_SWIZZLE_X
:
396 case BWRITERVS_SWIZZLE_Y
:
398 case BWRITERVS_SWIZZLE_Z
:
400 case BWRITERVS_SWIZZLE_W
:
404 swizzle
[0] = (arg
>> (BWRITERVS_SWIZZLE_SHIFT
+ 0)) & 0x03;
405 swizzle
[1] = (arg
>> (BWRITERVS_SWIZZLE_SHIFT
+ 2)) & 0x03;
406 swizzle
[2] = (arg
>> (BWRITERVS_SWIZZLE_SHIFT
+ 4)) & 0x03;
407 swizzle
[3] = (arg
>> (BWRITERVS_SWIZZLE_SHIFT
+ 6)) & 0x03;
410 for(i
= 0; i
< 4; i
++) {
412 case 0: ret
[1 + i
] = 'x'; break;
413 case 1: ret
[1 + i
] = 'y'; break;
414 case 2: ret
[1 + i
] = 'z'; break;
415 case 3: ret
[1 + i
] = 'w'; break;
419 return wine_dbg_sprintf("%s", ret
);
422 static const char *debug_print_relarg(const struct shader_reg
*reg
) {
423 const char *short_swizzle
;
424 if(!reg
->rel_reg
) return "";
426 short_swizzle
= debug_print_swizzle(reg
->rel_reg
->swizzle
);
428 if(reg
->rel_reg
->type
== BWRITERSPR_ADDR
) {
429 return wine_dbg_sprintf("[a%u%s]", reg
->rel_reg
->regnum
, short_swizzle
);
430 } else if(reg
->rel_reg
->type
== BWRITERSPR_LOOP
&& reg
->rel_reg
->regnum
== 0) {
431 return wine_dbg_sprintf("[aL%s]", short_swizzle
);
433 return "Unexpected relative addressing argument";
437 const char *debug_print_dstreg(const struct shader_reg
*reg
) {
438 return wine_dbg_sprintf("%s%s%s", get_regname(reg
),
439 debug_print_relarg(reg
),
440 debug_print_writemask(reg
->writemask
));
443 const char *debug_print_srcreg(const struct shader_reg
*reg
) {
444 switch(reg
->srcmod
) {
445 case BWRITERSPSM_NONE
:
446 return wine_dbg_sprintf("%s%s%s", get_regname(reg
),
447 debug_print_relarg(reg
),
448 debug_print_swizzle(reg
->swizzle
));
449 case BWRITERSPSM_NEG
:
450 return wine_dbg_sprintf("-%s%s%s", get_regname(reg
),
451 debug_print_relarg(reg
),
452 debug_print_swizzle(reg
->swizzle
));
453 case BWRITERSPSM_BIAS
:
454 return wine_dbg_sprintf("%s%s_bias%s", get_regname(reg
),
455 debug_print_relarg(reg
),
456 debug_print_swizzle(reg
->swizzle
));
457 case BWRITERSPSM_BIASNEG
:
458 return wine_dbg_sprintf("-%s%s_bias%s", get_regname(reg
),
459 debug_print_relarg(reg
),
460 debug_print_swizzle(reg
->swizzle
));
461 case BWRITERSPSM_SIGN
:
462 return wine_dbg_sprintf("%s%s_bx2%s", get_regname(reg
),
463 debug_print_relarg(reg
),
464 debug_print_swizzle(reg
->swizzle
));
465 case BWRITERSPSM_SIGNNEG
:
466 return wine_dbg_sprintf("-%s%s_bx2%s", get_regname(reg
),
467 debug_print_relarg(reg
),
468 debug_print_swizzle(reg
->swizzle
));
469 case BWRITERSPSM_COMP
:
470 return wine_dbg_sprintf("1 - %s%s%s", get_regname(reg
),
471 debug_print_relarg(reg
),
472 debug_print_swizzle(reg
->swizzle
));
474 return wine_dbg_sprintf("%s%s_x2%s", get_regname(reg
),
475 debug_print_relarg(reg
),
476 debug_print_swizzle(reg
->swizzle
));
477 case BWRITERSPSM_X2NEG
:
478 return wine_dbg_sprintf("-%s%s_x2%s", get_regname(reg
),
479 debug_print_relarg(reg
),
480 debug_print_swizzle(reg
->swizzle
));
482 return wine_dbg_sprintf("%s%s_dz%s", get_regname(reg
),
483 debug_print_relarg(reg
),
484 debug_print_swizzle(reg
->swizzle
));
486 return wine_dbg_sprintf("%s%s_dw%s", get_regname(reg
),
487 debug_print_relarg(reg
),
488 debug_print_swizzle(reg
->swizzle
));
489 case BWRITERSPSM_ABS
:
490 return wine_dbg_sprintf("%s%s_abs%s", get_regname(reg
),
491 debug_print_relarg(reg
),
492 debug_print_swizzle(reg
->swizzle
));
493 case BWRITERSPSM_ABSNEG
:
494 return wine_dbg_sprintf("-%s%s_abs%s", get_regname(reg
),
495 debug_print_relarg(reg
),
496 debug_print_swizzle(reg
->swizzle
));
497 case BWRITERSPSM_NOT
:
498 return wine_dbg_sprintf("!%s%s%s", get_regname(reg
),
499 debug_print_relarg(reg
),
500 debug_print_swizzle(reg
->swizzle
));
502 return "Unknown modifier";
505 const char *debug_print_comp(DWORD comp
) {
507 case BWRITER_COMPARISON_NONE
: return "";
508 case BWRITER_COMPARISON_GT
: return "_gt";
509 case BWRITER_COMPARISON_EQ
: return "_eq";
510 case BWRITER_COMPARISON_GE
: return "_ge";
511 case BWRITER_COMPARISON_LT
: return "_lt";
512 case BWRITER_COMPARISON_NE
: return "_ne";
513 case BWRITER_COMPARISON_LE
: return "_le";
514 default: return "_unknown";
518 const char *debug_print_opcode(DWORD opcode
) {
520 case BWRITERSIO_NOP
: return "nop";
521 case BWRITERSIO_MOV
: return "mov";
522 case BWRITERSIO_ADD
: return "add";
523 case BWRITERSIO_SUB
: return "sub";
524 case BWRITERSIO_MAD
: return "mad";
525 case BWRITERSIO_MUL
: return "mul";
526 case BWRITERSIO_RCP
: return "rcp";
527 case BWRITERSIO_RSQ
: return "rsq";
528 case BWRITERSIO_DP3
: return "dp3";
529 case BWRITERSIO_DP4
: return "dp4";
530 case BWRITERSIO_MIN
: return "min";
531 case BWRITERSIO_MAX
: return "max";
532 case BWRITERSIO_SLT
: return "slt";
533 case BWRITERSIO_SGE
: return "sge";
534 case BWRITERSIO_EXP
: return "exp";
535 case BWRITERSIO_LOG
: return "log";
536 case BWRITERSIO_LIT
: return "lit";
537 case BWRITERSIO_DST
: return "dst";
538 case BWRITERSIO_LRP
: return "lrp";
539 case BWRITERSIO_FRC
: return "frc";
540 case BWRITERSIO_M4x4
: return "m4x4";
541 case BWRITERSIO_M4x3
: return "m4x3";
542 case BWRITERSIO_M3x4
: return "m3x4";
543 case BWRITERSIO_M3x3
: return "m3x3";
544 case BWRITERSIO_M3x2
: return "m3x2";
545 case BWRITERSIO_CALL
: return "call";
546 case BWRITERSIO_CALLNZ
: return "callnz";
547 case BWRITERSIO_LOOP
: return "loop";
548 case BWRITERSIO_RET
: return "ret";
549 case BWRITERSIO_ENDLOOP
: return "endloop";
550 case BWRITERSIO_LABEL
: return "label";
551 case BWRITERSIO_DCL
: return "dcl";
552 case BWRITERSIO_POW
: return "pow";
553 case BWRITERSIO_CRS
: return "crs";
554 case BWRITERSIO_SGN
: return "sgn";
555 case BWRITERSIO_ABS
: return "abs";
556 case BWRITERSIO_NRM
: return "nrm";
557 case BWRITERSIO_SINCOS
: return "sincos";
558 case BWRITERSIO_REP
: return "rep";
559 case BWRITERSIO_ENDREP
: return "endrep";
560 case BWRITERSIO_IF
: return "if";
561 case BWRITERSIO_IFC
: return "ifc";
562 case BWRITERSIO_ELSE
: return "else";
563 case BWRITERSIO_ENDIF
: return "endif";
564 case BWRITERSIO_BREAK
: return "break";
565 case BWRITERSIO_BREAKC
: return "breakc";
566 case BWRITERSIO_MOVA
: return "mova";
567 case BWRITERSIO_DEFB
: return "defb";
568 case BWRITERSIO_DEFI
: return "defi";
569 case BWRITERSIO_TEXCOORD
: return "texcoord";
570 case BWRITERSIO_TEXKILL
: return "texkill";
571 case BWRITERSIO_TEX
: return "tex";
572 case BWRITERSIO_TEXBEM
: return "texbem";
573 case BWRITERSIO_TEXBEML
: return "texbeml";
574 case BWRITERSIO_TEXREG2AR
: return "texreg2ar";
575 case BWRITERSIO_TEXREG2GB
: return "texreg2gb";
576 case BWRITERSIO_TEXM3x2PAD
: return "texm3x2pad";
577 case BWRITERSIO_TEXM3x2TEX
: return "texm3x2tex";
578 case BWRITERSIO_TEXM3x3PAD
: return "texm3x3pad";
579 case BWRITERSIO_TEXM3x3TEX
: return "texm3x3tex";
580 case BWRITERSIO_TEXM3x3SPEC
: return "texm3x3vspec";
581 case BWRITERSIO_TEXM3x3VSPEC
: return "texm3x3vspec";
582 case BWRITERSIO_EXPP
: return "expp";
583 case BWRITERSIO_LOGP
: return "logp";
584 case BWRITERSIO_CND
: return "cnd";
585 case BWRITERSIO_DEF
: return "def";
586 case BWRITERSIO_TEXREG2RGB
: return "texreg2rgb";
587 case BWRITERSIO_TEXDP3TEX
: return "texdp3tex";
588 case BWRITERSIO_TEXM3x2DEPTH
: return "texm3x2depth";
589 case BWRITERSIO_TEXDP3
: return "texdp3";
590 case BWRITERSIO_TEXM3x3
: return "texm3x3";
591 case BWRITERSIO_TEXDEPTH
: return "texdepth";
592 case BWRITERSIO_CMP
: return "cmp";
593 case BWRITERSIO_BEM
: return "bem";
594 case BWRITERSIO_DP2ADD
: return "dp2add";
595 case BWRITERSIO_DSX
: return "dsx";
596 case BWRITERSIO_DSY
: return "dsy";
597 case BWRITERSIO_TEXLDD
: return "texldd";
598 case BWRITERSIO_SETP
: return "setp";
599 case BWRITERSIO_TEXLDL
: return "texldl";
600 case BWRITERSIO_BREAKP
: return "breakp";
601 case BWRITERSIO_PHASE
: return "phase";
603 case BWRITERSIO_TEXLDP
: return "texldp";
604 case BWRITERSIO_TEXLDB
: return "texldb";
606 default: return "unknown";