ReactOS 0.4.17-dev-966-gf06eace
asmparser.c
Go to the documentation of this file.
1/*
2 * Direct3D asm shader parser
3 *
4 * Copyright 2008 Stefan Dösinger
5 * Copyright 2009 Matteo Bruni
6 *
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.
11 *
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.
16 *
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
20 *
21 */
22
23#include "wine/debug.h"
24
25#include "d3dcompiler_private.h"
26
29
30
31/* How to map vs 1.0 and 2.0 varyings to 3.0 ones
32 * oTx is mapped to ox, which happens to be an
33 * identical mapping since BWRITERSPR_TEXCRDOUT == BWRITERSPR_OUTPUT
34 * oPos, oFog and point size are mapped to general output regs as well.
35 * the vs 1.x and 2.x parser functions add varying declarations
36 * to the shader, and the 1.x and 2.x output functions check those varyings
37 */
38#define OT0_REG 0
39#define OT1_REG 1
40#define OT2_REG 2
41#define OT3_REG 3
42#define OT4_REG 4
43#define OT5_REG 5
44#define OT6_REG 6
45#define OT7_REG 7
46#define OPOS_REG 8
47#define OFOG_REG 9
48#define OFOG_WRITEMASK BWRITERSP_WRITEMASK_0
49#define OPTS_REG 9
50#define OPTS_WRITEMASK BWRITERSP_WRITEMASK_1
51#define OD0_REG 10
52#define OD1_REG 11
53
54/* Input color registers 0-1 are identically mapped */
55#define C0_VARYING 0
56#define C1_VARYING 1
57#define T0_VARYING 2
58#define T1_VARYING 3
59#define T2_VARYING 4
60#define T3_VARYING 5
61#define T4_VARYING 6
62#define T5_VARYING 7
63#define T6_VARYING 8
64#define T7_VARYING 9
65
66/****************************************************************
67 * Common(non-version specific) shader parser control code *
68 ****************************************************************/
69
70static void asmparser_end(struct asm_parser *This) {
71 TRACE("Finalizing shader\n");
72}
73
74static void asmparser_constF(struct asm_parser *parser, uint32_t reg, float x, float y, float z, float w)
75{
76 if (!parser->shader)
77 return;
78 TRACE("Adding float constant %u at pos %u.\n", reg, parser->shader->num_cf);
79 TRACE_(parsed_shader)("def c%u, %f, %f, %f, %f\n", reg, x, y, z, w);
80 if (!add_constF(parser->shader, reg, x, y, z, w))
81 {
82 ERR("Out of memory.\n");
84 }
85}
86
88{
89 if (!parser->shader)
90 return;
91 TRACE("Adding boolean constant %u at pos %u.\n", reg, parser->shader->num_cb);
92 TRACE_(parsed_shader)("def b%u, %s\n", reg, x ? "true" : "false");
93 if (!add_constB(parser->shader, reg, x))
94 {
95 ERR("Out of memory.\n");
97 }
98}
99
100static void asmparser_constI(struct asm_parser *parser, uint32_t reg, int x, int y, int z, int w)
101{
102 if (!parser->shader)
103 return;
104 TRACE("Adding integer constant %u at pos %u.\n", reg, parser->shader->num_ci);
105 TRACE_(parsed_shader)("def i%u, %d, %d, %d, %d\n", reg, x, y, z, w);
106 if (!add_constI(parser->shader, reg, x, y, z, w))
107 {
108 ERR("Out of memory.\n");
110 }
111}
112
114 const struct shader_reg *reg)
115{
116 if (!parser->shader)
117 return;
118 if (parser->shader->type == ST_PIXEL)
119 {
120 asmparser_message(parser, "Line %u: Output register declared in a pixel shader\n", parser->line_no);
122 }
123 if (!record_declaration(parser->shader, usage, num, 0, TRUE, reg->regnum, reg->writemask, FALSE))
124 {
125 ERR("Out of memory\n");
127 }
128}
129
131 const struct shader_reg *reg)
132{
133 asmparser_message(parser, "Line %u: Output declaration unsupported in this shader version\n", parser->line_no);
135}
136
138 const struct shader_reg *reg)
139{
140 struct instruction instr;
141
142 if (!parser->shader)
143 return;
144 if (mod && (parser->shader->type != ST_PIXEL || parser->shader->major_version != 3
146 {
147 asmparser_message(parser, "Line %u: Unsupported modifier in dcl instruction\n", parser->line_no);
149 return;
150 }
151
152 /* Check register type and modifiers */
153 instr.dstmod = mod;
154 instr.shift = 0;
155 parser->funcs->dstreg(parser, &instr, reg);
156
157 if (!record_declaration(parser->shader, usage, num, mod, FALSE, reg->regnum, reg->writemask, FALSE))
158 {
159 ERR("Out of memory\n");
161 }
162}
163
165 const struct shader_reg *reg)
166{
167 struct instruction instr;
168
169 if (!parser->shader)
170 return;
171 instr.dstmod = mod;
172 instr.shift = 0;
173 parser->funcs->dstreg(parser, &instr, reg);
174 if (!record_declaration(parser->shader, usage, num, mod, FALSE, instr.dst.regnum, instr.dst.writemask, FALSE))
175 {
176 ERR("Out of memory\n");
178 }
179}
180
182 const struct shader_reg *reg)
183{
184 asmparser_message(parser, "Line %u: Input declaration unsupported in this shader version\n", parser->line_no);
186}
187
188static void asmparser_dcl_sampler(struct asm_parser *parser, uint32_t samptype, uint32_t mod, uint32_t regnum,
189 unsigned int line_no)
190{
191 if (!parser->shader)
192 return;
193 if (mod && (parser->shader->type != ST_PIXEL || parser->shader->major_version != 3
195 {
196 asmparser_message(parser, "Line %u: Unsupported modifier in dcl instruction\n", parser->line_no);
198 return;
199 }
200 if (!record_sampler(parser->shader, samptype, mod, regnum))
201 {
202 ERR("Out of memory\n");
204 }
205}
206
208 uint32_t regnum, unsigned int line_no)
209{
210 asmparser_message(parser, "Line %u: Sampler declaration unsupported in this shader version\n", parser->line_no);
212}
213
215 const struct src_regs *srcs)
216{
217 struct instruction *instr;
218
219 if (!srcs || srcs->count != 3)
220 {
221 asmparser_message(parser, "Line %u: sincos (vs 2) has an incorrect number of source registers\n", parser->line_no);
223 return;
224 }
225
226 instr = alloc_instr(3);
227 if (!instr)
228 {
229 ERR("Error allocating memory for the instruction\n");
231 return;
232 }
233
234 instr->opcode = BWRITERSIO_SINCOS;
235 instr->dstmod = mod;
236 instr->shift = shift;
237 instr->comptype = 0;
238
239 parser->funcs->dstreg(parser, instr, dst);
240 parser->funcs->srcreg(parser, instr, 0, &srcs->reg[0]);
241 parser->funcs->srcreg(parser, instr, 1, &srcs->reg[1]);
242 parser->funcs->srcreg(parser, instr, 2, &srcs->reg[2]);
243
244 if (!add_instruction(parser->shader, instr))
245 {
246 ERR("Out of memory\n");
248 }
249}
250
252{
253 struct shader_reg ret;
254
255 switch (reg->type)
256 {
258 if (tex_varying)
259 {
260 ret = *reg;
261 ret.type = BWRITERSPR_INPUT;
262 switch (reg->regnum)
263 {
264 case 0: ret.regnum = T0_VARYING; break;
265 case 1: ret.regnum = T1_VARYING; break;
266 case 2: ret.regnum = T2_VARYING; break;
267 case 3: ret.regnum = T3_VARYING; break;
268 case 4: ret.regnum = T4_VARYING; break;
269 case 5: ret.regnum = T5_VARYING; break;
270 case 6: ret.regnum = T6_VARYING; break;
271 case 7: ret.regnum = T7_VARYING; break;
272 default:
273 FIXME("Unexpected TEXTURE register t%u.\n", reg->regnum);
274 return *reg;
275 }
276 return ret;
277 }
278 else
279 {
280 ret = *reg;
281 ret.type = BWRITERSPR_TEMP;
282 switch(reg->regnum)
283 {
284 case 0: ret.regnum = T0_REG; break;
285 case 1: ret.regnum = T1_REG; break;
286 case 2: ret.regnum = T2_REG; break;
287 case 3: ret.regnum = T3_REG; break;
288 default:
289 FIXME("Unexpected TEXTURE register t%u.\n", reg->regnum);
290 return *reg;
291 }
292 return ret;
293 }
294
295 /* case BWRITERSPR_INPUT - Identical mapping of 1.x/2.0 color varyings
296 to 3.0 ones */
297
298 default: return *reg;
299 }
300}
301
303 const struct src_regs *srcs)
304{
305 struct instruction *instr;
306
307 if (srcs)
308 {
309 asmparser_message(parser, "Line %u: Source registers in texcoord instruction\n", parser->line_no);
311 return;
312 }
313
314 instr = alloc_instr(1);
315 if (!instr)
316 {
317 ERR("Error allocating memory for the instruction\n");
319 return;
320 }
321
322 /* texcoord copies the texture coord data into a temporary register-like
323 * readable form. In newer shader models this equals a MOV from v0 to r0,
324 * record it as this.
325 */
326 instr->opcode = BWRITERSIO_MOV;
327 instr->dstmod = mod | BWRITERSPDM_SATURATE; /* texcoord clamps to [0;1] */
328 instr->shift = shift;
329 instr->comptype = 0;
330
331 parser->funcs->dstreg(parser, instr, dst);
332 /* The src reg needs special care */
333 instr->src[0] = map_oldps_register(dst, TRUE);
334
335 if (!add_instruction(parser->shader, instr))
336 {
337 ERR("Out of memory\n");
339 }
340}
341
343 const struct src_regs *srcs)
344{
345 struct instruction *instr;
346
347 if (!srcs || srcs->count != 1)
348 {
349 asmparser_message(parser, "Line %u: Wrong number of source registers in texcrd instruction\n", parser->line_no);
351 return;
352 }
353
354 instr = alloc_instr(1);
355 if (!instr)
356 {
357 ERR("Error allocating memory for the instruction\n");
359 return;
360 }
361
362 /* The job of texcrd is done by mov in later shader versions */
363 instr->opcode = BWRITERSIO_MOV;
364 instr->dstmod = mod;
365 instr->shift = shift;
366 instr->comptype = 0;
367
368 parser->funcs->dstreg(parser, instr, dst);
369 parser->funcs->srcreg(parser, instr, 0, &srcs->reg[0]);
370
371 if (!add_instruction(parser->shader, instr))
372 {
373 ERR("Out of memory\n");
375 }
376}
377
378static void asmparser_texkill(struct asm_parser *parser, const struct shader_reg *dst)
379{
380 struct instruction *instr = alloc_instr(0);
381
382 if (!instr)
383 {
384 ERR("Error allocating memory for the instruction\n");
386 return;
387 }
388
389 instr->opcode = BWRITERSIO_TEXKILL;
390 instr->dstmod = 0;
391 instr->shift = 0;
392 instr->comptype = 0;
393
394 /* Do not run the dst register through the normal
395 * register conversion. If used with ps_1_0 to ps_1_3
396 * the texture coordinate from that register is used,
397 * not the temporary register value. In ps_1_4 and
398 * ps_2_0 t0 is always a varying and temporaries can
399 * be used with texkill.
400 */
401 instr->dst = map_oldps_register(dst, TRUE);
402 instr->has_dst = TRUE;
403
404 if (!add_instruction(parser->shader, instr))
405 {
406 ERR("Out of memory\n");
408 }
409}
410
412 const struct shader_reg *src0)
413{
414 struct instruction *instr = alloc_instr(2);
415
416 if (!instr)
417 {
418 ERR("Error allocating memory for the instruction\n");
420 return;
421 }
422
423 instr->opcode = BWRITERSIO_TEX;
424 instr->dstmod = mod;
425 instr->shift = shift;
426 instr->comptype = 0;
427 /* The dest register can be mapped normally to a temporary register */
428 parser->funcs->dstreg(parser, instr, dst);
429 /* Use the src passed as parameter by the specific instruction handler */
430 instr->src[0] = *src0;
431
432 /* The 2nd source register is the sampler register with the
433 * destination's regnum
434 */
435 ZeroMemory(&instr->src[1], sizeof(instr->src[1]));
436 instr->src[1].type = BWRITERSPR_SAMPLER;
437 instr->src[1].regnum = dst->regnum;
438 instr->src[1].swizzle = BWRITERVS_NOSWIZZLE;
439 instr->src[1].srcmod = BWRITERSPSM_NONE;
440 instr->src[1].rel_reg = NULL;
441
442 if (!add_instruction(parser->shader, instr))
443 {
444 ERR("Out of memory\n");
446 }
447}
448
450{
451 struct shader_reg src;
452
453 /* The first source register is the varying containing the coordinate */
456}
457
459 const struct src_regs *srcs)
460{
461 struct instruction *instr;
462
463 if (!srcs || srcs->count != 1)
464 {
465 asmparser_message(parser, "Line %u: texld (PS 1.4) has a wrong number of source registers\n", parser->line_no);
467 return;
468 }
469
470 instr = alloc_instr(2);
471 if (!instr)
472 {
473 ERR("Error allocating memory for the instruction\n");
475 return;
476 }
477
478 /* This code is recording a texld instruction, not tex. However,
479 * texld borrows the opcode of tex
480 */
481 instr->opcode = BWRITERSIO_TEX;
482 instr->dstmod = mod;
483 instr->shift = shift;
484 instr->comptype = 0;
485
486 parser->funcs->dstreg(parser, instr, dst);
487 parser->funcs->srcreg(parser, instr, 0, &srcs->reg[0]);
488
489 /* The 2nd source register is the sampler register with the
490 * destination's regnum
491 */
492 ZeroMemory(&instr->src[1], sizeof(instr->src[1]));
493 instr->src[1].type = BWRITERSPR_SAMPLER;
494 instr->src[1].regnum = dst->regnum;
495 instr->src[1].swizzle = BWRITERVS_NOSWIZZLE;
496 instr->src[1].srcmod = BWRITERSPSM_NONE;
497 instr->src[1].rel_reg = NULL;
498
499 if (!add_instruction(parser->shader, instr))
500 {
501 ERR("Out of memory\n");
503 }
504}
505
507 const struct shader_reg *src0)
508{
509 struct shader_reg src;
510
512 /* Supply the correct swizzle */
515}
516
518 const struct shader_reg *src0)
519{
520 struct shader_reg src;
521
523 /* Supply the correct swizzle */
526}
527
529 const struct shader_reg *src0)
530{
531 struct shader_reg src;
532
534 /* Supply the correct swizzle */
537}
538
539/* Complex pixel shader 1.3 instructions like texm3x3tex are tricky - the
540 * bytecode writer works instruction by instruction, so we can't properly
541 * convert these from/to equivalent ps_3_0 instructions. Then simply keep using
542 * the ps_1_3 opcodes and just adapt the registers in the common fashion (i.e.
543 * go through asmparser_instr).
544 */
545
547 enum bwriter_comparison_type comp, const struct shader_reg *dst,
548 const struct src_regs *srcs, int expectednsrcs)
549{
550 unsigned int src_count = srcs ? srcs->count : 0;
551 struct bwriter_shader *shader = parser->shader;
552 struct instruction *instr;
553 BOOL firstreg = TRUE;
554 unsigned int i;
555
556 if (!parser->shader)
557 return;
558
559 TRACE_(parsed_shader)("%s%s%s%s ", debug_print_opcode(opcode),
562 debug_print_comp(comp));
563 if (dst)
564 {
565 TRACE_(parsed_shader)("%s", debug_print_dstreg(dst));
566 firstreg = FALSE;
567 }
568 for (i = 0; i < src_count; i++)
569 {
570 if (!firstreg)
571 TRACE_(parsed_shader)(", ");
572 else firstreg = FALSE;
573 TRACE_(parsed_shader)("%s", debug_print_srcreg(&srcs->reg[i]));
574 }
575 TRACE_(parsed_shader)("\n");
576
577 /* Check for instructions with different syntaxes in different shader versions */
578 switch(opcode)
579 {
581 /* The syntax changes between vs 2 and the other shader versions */
582 if (parser->shader->type == ST_VERTEX && parser->shader->major_version == 2)
583 {
585 return;
586 }
587 /* Use the default handling */
588 break;
590 /* texcoord/texcrd are two instructions present only in PS <= 1.3 and PS 1.4 respectively */
591 if (shader->type == ST_PIXEL && shader->major_version == 1 && shader->minor_version == 4)
593 else
595 return;
596 case BWRITERSIO_TEX:
597 /* this encodes both the tex PS 1.x instruction and the
598 texld 1.4/2.0+ instruction */
599 if (shader->type == ST_PIXEL && shader->major_version == 1)
600 {
601 if (shader->minor_version < 4)
603 else
605 return;
606 }
607 /* else fallback to the standard behavior */
608 break;
609 }
610
611 if (src_count != expectednsrcs)
612 {
613 asmparser_message(parser, "Line %u: Wrong number of source registers\n", parser->line_no);
615 return;
616 }
617
618 /* Handle PS 1.x instructions, "regularizing" them */
619 switch(opcode)
620 {
623 return;
625 asmparser_texreg2ar(parser, mod, shift, dst, &srcs->reg[0]);
626 return;
628 asmparser_texreg2gb(parser, mod, shift, dst, &srcs->reg[0]);
629 return;
632 return;
633 }
634
635 instr = alloc_instr(src_count);
636 if (!instr)
637 {
638 ERR("Error allocating memory for the instruction\n");
640 return;
641 }
642
643 instr->opcode = opcode;
644 instr->dstmod = mod;
645 instr->shift = shift;
646 instr->comptype = comp;
647 if (dst)
648 parser->funcs->dstreg(parser, instr, dst);
649 for (i = 0; i < src_count; i++)
650 {
651 parser->funcs->srcreg(parser, instr, i, &srcs->reg[i]);
652 }
653
654 if (!add_instruction(parser->shader, instr))
655 {
656 ERR("Out of memory\n");
658 }
659}
660
662{
663 struct shader_reg ret;
664
665 switch(reg->type)
666 {
668 ret = *reg;
669 ret.type = BWRITERSPR_OUTPUT;
670 switch(reg->regnum)
671 {
673 ret.regnum = OPOS_REG;
674 break;
675 case BWRITERSRO_FOG:
676 ret.regnum = OFOG_REG;
677 ret.writemask = OFOG_WRITEMASK;
678 break;
680 ret.regnum = OPTS_REG;
681 ret.writemask = OPTS_WRITEMASK;
682 break;
683 default:
684 FIXME("Unhandled RASTOUT register %u.\n", reg->regnum);
685 return *reg;
686 }
687 return ret;
688
690 ret = *reg;
691 ret.type = BWRITERSPR_OUTPUT;
692 switch(reg->regnum)
693 {
694 case 0: ret.regnum = OT0_REG; break;
695 case 1: ret.regnum = OT1_REG; break;
696 case 2: ret.regnum = OT2_REG; break;
697 case 3: ret.regnum = OT3_REG; break;
698 case 4: ret.regnum = OT4_REG; break;
699 case 5: ret.regnum = OT5_REG; break;
700 case 6: ret.regnum = OT6_REG; break;
701 case 7: ret.regnum = OT7_REG; break;
702 default:
703 FIXME("Unhandled TEXCRDOUT regnum %u.\n", reg->regnum);
704 return *reg;
705 }
706 return ret;
707
709 ret = *reg;
710 ret.type = BWRITERSPR_OUTPUT;
711 switch(reg->regnum)
712 {
713 case 0: ret.regnum = OD0_REG; break;
714 case 1: ret.regnum = OD1_REG; break;
715 default:
716 FIXME("Unhandled ATTROUT regnum %u.\n", reg->regnum);
717 return *reg;
718 }
719 return ret;
720
721 default: return *reg;
722 }
723}
724
725/* Checks for unsupported source modifiers in VS (all versions) or
726 PS 2.0 and newer */
728{
734 {
735 asmparser_message(parser, "Line %u: Source modifier %s not supported in this shader version\n",
736 parser->line_no, debug_print_srcmod(srcmod));
738 }
739}
740
742{
744 {
745 asmparser_message(parser, "Line %u: Source modifier %s not supported in this shader version\n",
746 parser->line_no, debug_print_srcmod(srcmod));
748 }
749}
750
751static void check_loop_swizzle(struct asm_parser *parser, const struct shader_reg *src)
752{
753 if ((src->type == BWRITERSPR_LOOP && src->swizzle != BWRITERVS_NOSWIZZLE)
754 || (src->rel_reg && src->rel_reg->type == BWRITERSPR_LOOP &&
755 src->rel_reg->swizzle != BWRITERVS_NOSWIZZLE))
756 {
757 asmparser_message(parser, "Line %u: Swizzle not allowed on aL register\n", parser->line_no);
759 }
760}
761
763{
764 if (shift != 0)
765 {
766 asmparser_message(parser, "Line %u: Shift modifiers not supported in this shader version\n", parser->line_no);
768 }
769}
770
771static void check_ps_dstmod(struct asm_parser *parser, uint32_t dstmod)
772{
774 {
775 asmparser_message(parser, "Line %u: Instruction modifier %s not supported in this shader version\n",
776 parser->line_no, debug_print_dstmod(dstmod));
778 }
779}
780
782{
784 unsigned int count;
786};
787
788static BOOL check_reg_type(const struct shader_reg *reg, const struct allowed_reg_type *allowed)
789{
790 unsigned int i = 0;
791
792 while (allowed[i].type != ~0u)
793 {
794 if (reg->type == allowed[i].type)
795 {
796 if (reg->rel_reg)
797 {
798 /* The relative addressing register can have a negative value,
799 * we can't check the register index. */
800 if (allowed[i].reladdr)
801 return TRUE;
802 return FALSE;
803 }
804 if (reg->regnum < allowed[i].count)
805 return TRUE;
806 return FALSE;
807 }
808 i++;
809 }
810 return FALSE;
811}
812
813/* Native assembler doesn't do separate checks for src and dst registers */
814static const struct allowed_reg_type vs_1_reg_allowed[] =
815{
816 { BWRITERSPR_TEMP, 12, FALSE },
817 { BWRITERSPR_INPUT, 16, FALSE },
818 { BWRITERSPR_CONST, ~0u, TRUE },
819 { BWRITERSPR_ADDR, 1, FALSE },
820 { BWRITERSPR_RASTOUT, 3, FALSE }, /* oPos, oFog and oPts */
823 { ~0u, 0 } /* End tag */
824};
825
826/* struct instruction *asmparser_srcreg
827 *
828 * Records a source register in the instruction and does shader version
829 * specific checks and modifications on it
830 *
831 * Parameters:
832 * This: Shader parser instance
833 * instr: instruction to store the register in
834 * num: Number of source register
835 * src: Pointer to source the register structure. The caller can free
836 * it afterwards
837 */
838static void asmparser_srcreg_vs_1(struct asm_parser *parser, struct instruction *instr, int num,
839 const struct shader_reg *src)
840{
841 struct shader_reg reg;
842
844 {
845 asmparser_message(parser, "Line %u: Source register %s not supported in VS 1\n",
846 parser->line_no, debug_print_srcreg(src));
848 }
850 check_abs_srcmod(parser, src->srcmod);
852 instr->src[num] = reg;
853}
854
855static const struct allowed_reg_type vs_2_reg_allowed[] =
856{
857 { BWRITERSPR_TEMP, 12, FALSE },
858 { BWRITERSPR_INPUT, 16, FALSE },
859 { BWRITERSPR_CONST, ~0u, TRUE },
860 { BWRITERSPR_ADDR, 1, FALSE },
862 { BWRITERSPR_CONSTINT, 16, FALSE },
863 { BWRITERSPR_LOOP, 1, FALSE },
864 { BWRITERSPR_LABEL, 2048, FALSE },
866 { BWRITERSPR_RASTOUT, 3, FALSE }, /* oPos, oFog and oPts */
869 { ~0u, 0 } /* End tag */
870};
871
872static void asmparser_srcreg_vs_2(struct asm_parser *parser, struct instruction *instr, int num,
873 const struct shader_reg *src)
874{
875 struct shader_reg reg;
876
878 {
879 asmparser_message(parser, "Line %u: Source register %s not supported in VS 2\n",
880 parser->line_no, debug_print_srcreg(src));
882 }
885 check_abs_srcmod(parser, src->srcmod);
887 instr->src[num] = reg;
888}
889
890static const struct allowed_reg_type vs_3_reg_allowed[] =
891{
892 { BWRITERSPR_TEMP, 32, FALSE },
893 { BWRITERSPR_INPUT, 16, TRUE },
894 { BWRITERSPR_CONST, ~0u, TRUE },
895 { BWRITERSPR_ADDR, 1, FALSE },
897 { BWRITERSPR_CONSTINT, 16, FALSE },
898 { BWRITERSPR_LOOP, 1, FALSE },
899 { BWRITERSPR_LABEL, 2048, FALSE },
902 { BWRITERSPR_OUTPUT, 12, TRUE },
903 { ~0u, 0 } /* End tag */
904};
905
906static void asmparser_srcreg_vs_3(struct asm_parser *parser, struct instruction *instr, int num,
907 const struct shader_reg *src)
908{
910 {
911 asmparser_message(parser, "Line %u: Source register %s not supported in VS 3.0\n",
912 parser->line_no, debug_print_srcreg(src));
914 }
917 instr->src[num] = *src;
918}
919
921{
922 { BWRITERSPR_CONST, 8, FALSE },
923 { BWRITERSPR_TEMP, 2, FALSE },
925 { BWRITERSPR_INPUT, 2, FALSE },
926 { ~0u, 0 } /* End tag */
927};
928
929static void asmparser_srcreg_ps_1_0123(struct asm_parser *parser, struct instruction *instr, int num,
930 const struct shader_reg *src)
931{
932 struct shader_reg reg;
933
935 {
936 asmparser_message(parser, "Line %u: Source register %s not supported in <== PS 1.3\n",
937 parser->line_no, debug_print_srcreg(src));
939 }
940 check_abs_srcmod(parser, src->srcmod);
942 instr->src[num] = reg;
943}
944
946{
947 { BWRITERSPR_CONST, 8, FALSE },
948 { BWRITERSPR_TEMP, 6, FALSE },
950 { BWRITERSPR_INPUT, 2, FALSE },
951 { ~0u, 0 } /* End tag */
952};
953
954static void asmparser_srcreg_ps_1_4(struct asm_parser *parser, struct instruction *instr, int num,
955 const struct shader_reg *src)
956{
957 struct shader_reg reg;
958
960 {
961 asmparser_message(parser, "Line %u: Source register %s not supported in PS 1.4\n",
962 parser->line_no, debug_print_srcreg(src));
964 }
965 check_abs_srcmod(parser, src->srcmod);
967 instr->src[num] = reg;
968}
969
971{
972 { BWRITERSPR_INPUT, 2, FALSE },
973 { BWRITERSPR_TEMP, 32, FALSE },
974 { BWRITERSPR_CONST, 32, FALSE },
975 { BWRITERSPR_CONSTINT, 16, FALSE },
977 { BWRITERSPR_SAMPLER, 16, FALSE },
981 { ~0u, 0 } /* End tag */
982};
983
984static void asmparser_srcreg_ps_2(struct asm_parser *parser, struct instruction *instr, int num,
985 const struct shader_reg *src)
986{
987 struct shader_reg reg;
988
990 {
991 asmparser_message(parser, "Line %u: Source register %s not supported in PS 2.0\n",
992 parser->line_no, debug_print_srcreg(src));
994 }
996 check_abs_srcmod(parser, src->srcmod);
998 instr->src[num] = reg;
999}
1000
1002{
1003 { BWRITERSPR_INPUT, 2, FALSE },
1004 { BWRITERSPR_TEMP, 32, FALSE },
1005 { BWRITERSPR_CONST, 32, FALSE },
1006 { BWRITERSPR_CONSTINT, 16, FALSE },
1007 { BWRITERSPR_CONSTBOOL, 16, FALSE },
1009 { BWRITERSPR_SAMPLER, 16, FALSE },
1010 { BWRITERSPR_TEXTURE, 8, FALSE },
1011 { BWRITERSPR_LABEL, 2048, FALSE },
1012 { BWRITERSPR_COLOROUT, 4, FALSE },
1013 { BWRITERSPR_DEPTHOUT, 1, FALSE },
1014 { ~0u, 0 } /* End tag */
1015};
1016
1017static void asmparser_srcreg_ps_2_x(struct asm_parser *parser, struct instruction *instr, int num,
1018 const struct shader_reg *src)
1019{
1020 struct shader_reg reg;
1021
1023 {
1024 asmparser_message(parser, "Line %u: Source register %s not supported in PS 2.x\n",
1025 parser->line_no, debug_print_srcreg(src));
1027 }
1028 check_legacy_srcmod(parser, src->srcmod);
1029 check_abs_srcmod(parser, src->srcmod);
1031 instr->src[num] = reg;
1032}
1033
1034static const struct allowed_reg_type ps_3_reg_allowed[] =
1035{
1036 { BWRITERSPR_INPUT, 10, TRUE },
1037 { BWRITERSPR_TEMP, 32, FALSE },
1038 { BWRITERSPR_CONST, 224, FALSE },
1039 { BWRITERSPR_CONSTINT, 16, FALSE },
1040 { BWRITERSPR_CONSTBOOL, 16, FALSE },
1042 { BWRITERSPR_SAMPLER, 16, FALSE },
1043 { BWRITERSPR_MISCTYPE, 2, FALSE }, /* vPos and vFace */
1044 { BWRITERSPR_LOOP, 1, FALSE },
1045 { BWRITERSPR_LABEL, 2048, FALSE },
1046 { BWRITERSPR_COLOROUT, 4, FALSE },
1047 { BWRITERSPR_DEPTHOUT, 1, FALSE },
1048 { ~0u, 0 } /* End tag */
1049};
1050
1051static void asmparser_srcreg_ps_3(struct asm_parser *parser,struct instruction *instr, int num,
1052 const struct shader_reg *src)
1053{
1055 {
1056 asmparser_message(parser, "Line %u: Source register %s not supported in PS 3.0\n",
1057 parser->line_no, debug_print_srcreg(src));
1059 }
1061 check_legacy_srcmod(parser, src->srcmod);
1062 instr->src[num] = *src;
1063}
1064
1065static void asmparser_dstreg_vs_1(struct asm_parser *parser, struct instruction *instr,
1066 const struct shader_reg *dst)
1067{
1068 struct shader_reg reg;
1069
1071 {
1072 asmparser_message(parser, "Line %u: Destination register %s not supported in VS 1\n",
1073 parser->line_no, debug_print_dstreg(dst));
1075 }
1076 check_ps_dstmod(parser, instr->dstmod);
1079 instr->dst = reg;
1080 instr->has_dst = TRUE;
1081}
1082
1083static void asmparser_dstreg_vs_2(struct asm_parser *parser, struct instruction *instr,
1084 const struct shader_reg *dst)
1085{
1086 struct shader_reg reg;
1087
1089 {
1090 asmparser_message(parser, "Line %u: Destination register %s not supported in VS 2.0\n",
1091 parser->line_no, debug_print_dstreg(dst));
1093 }
1094 check_ps_dstmod(parser, instr->dstmod);
1097 instr->dst = reg;
1098 instr->has_dst = TRUE;
1099}
1100
1101static void asmparser_dstreg_vs_3(struct asm_parser *parser,struct instruction *instr,
1102 const struct shader_reg *dst)
1103{
1105 {
1106 asmparser_message(parser, "Line %u: Destination register %s not supported in VS 3.0\n",
1107 parser->line_no, debug_print_dstreg(dst));
1109 }
1110 check_ps_dstmod(parser, instr->dstmod);
1112 instr->dst = *dst;
1113 instr->has_dst = TRUE;
1114}
1115
1116static void asmparser_dstreg_ps_1_0123(struct asm_parser *parser, struct instruction *instr,
1117 const struct shader_reg *dst)
1118{
1119 struct shader_reg reg;
1120
1122 {
1123 asmparser_message(parser, "Line %u: Destination register %s not supported in PS 1\n",
1124 parser->line_no, debug_print_dstreg(dst));
1126 }
1128 instr->dst = reg;
1129 instr->has_dst = TRUE;
1130}
1131
1132static void asmparser_dstreg_ps_1_4(struct asm_parser *parser, struct instruction *instr,
1133 const struct shader_reg *dst)
1134{
1135 struct shader_reg reg;
1136
1138 {
1139 asmparser_message(parser, "Line %u: Destination register %s not supported in PS 1\n",
1140 parser->line_no, debug_print_dstreg(dst));
1142 }
1144 instr->dst = reg;
1145 instr->has_dst = TRUE;
1146}
1147
1148static void asmparser_dstreg_ps_2(struct asm_parser *parser, struct instruction *instr,
1149 const struct shader_reg *dst)
1150{
1151 struct shader_reg reg;
1152
1154 {
1155 asmparser_message(parser, "Line %u: Destination register %s not supported in PS 2.0\n",
1156 parser->line_no, debug_print_dstreg(dst));
1158 }
1161 instr->dst = reg;
1162 instr->has_dst = TRUE;
1163}
1164
1165static void asmparser_dstreg_ps_2_x(struct asm_parser *parser, struct instruction *instr,
1166 const struct shader_reg *dst)
1167{
1168 struct shader_reg reg;
1169
1171 {
1172 asmparser_message(parser, "Line %u: Destination register %s not supported in PS 2.x\n",
1173 parser->line_no, debug_print_dstreg(dst));
1175 }
1178 instr->dst = reg;
1179 instr->has_dst = TRUE;
1180}
1181
1182static void asmparser_dstreg_ps_3(struct asm_parser *parser, struct instruction *instr,
1183 const struct shader_reg *dst)
1184{
1186 {
1187 asmparser_message(parser, "Line %u: Destination register %s not supported in PS 3.0\n",
1188 parser->line_no, debug_print_dstreg(dst));
1190 }
1192 instr->dst = *dst;
1193 instr->has_dst = TRUE;
1194}
1195
1196static void asmparser_predicate_supported(struct asm_parser *parser, const struct shader_reg *predicate)
1197{
1198 if (!parser->shader)
1199 return;
1200 if (parser->shader->num_instrs == 0)
1201 ERR("Predicate without an instruction.\n");
1202 /* Set the predicate of the last instruction added to the shader. */
1203 parser->shader->instr[parser->shader->num_instrs - 1]->has_predicate = TRUE;
1204 parser->shader->instr[parser->shader->num_instrs - 1]->predicate = *predicate;
1205}
1206
1207static void asmparser_predicate_unsupported(struct asm_parser *parser, const struct shader_reg *predicate)
1208{
1209 asmparser_message(parser, "Line %u: Predicate not supported in < VS 2.0 or PS 2.x\n", parser->line_no);
1211}
1212
1214{
1215 if (!parser->shader)
1216 return;
1217 if (parser->shader->num_instrs == 0)
1218 {
1219 asmparser_message(parser, "Line %u: Coissue flag on the first shader instruction\n", parser->line_no);
1221 }
1222 /* Set the coissue flag of the last instruction added to the shader. */
1223 parser->shader->instr[parser->shader->num_instrs - 1]->coissue = TRUE;
1224}
1225
1227{
1228 asmparser_message(parser, "Line %u: Coissue is only supported in pixel shaders versions <= 1.4\n", parser->line_no);
1230}
1231
1232static const struct asmparser_backend parser_vs_1 = {
1236
1239
1242
1246
1248
1250};
1251
1252static const struct asmparser_backend parser_vs_2 = {
1256
1259
1262
1266
1268
1270};
1271
1272static const struct asmparser_backend parser_vs_3 = {
1276
1279
1282
1286
1288
1290};
1291
1296
1299
1302
1306
1308
1310};
1311
1312static const struct asmparser_backend parser_ps_1_4 = {
1316
1319
1322
1326
1328
1330};
1331
1332static const struct asmparser_backend parser_ps_2 = {
1336
1339
1342
1346
1348
1350};
1351
1352static const struct asmparser_backend parser_ps_2_x = {
1356
1359
1362
1366
1368
1370};
1371
1372static const struct asmparser_backend parser_ps_3 = {
1376
1379
1382
1386
1388
1390};
1391
1406}
1407
1408static void gen_oldps_input(struct bwriter_shader *shader, uint32_t texcoords)
1409{
1410 switch(texcoords)
1411 {
1413 /* fall through */
1415 /* fall through */
1417 /* fall through */
1419 /* fall through */
1421 /* fall through */
1423 /* fall through */
1425 /* fall through */
1427 };
1430}
1431
1433 TRACE_(parsed_shader)("vs_1_0\n");
1434
1435 ret->shader = calloc(1, sizeof(*ret->shader));
1436 if(!ret->shader) {
1437 ERR("Failed to allocate memory for the shader\n");
1438 set_parse_status(&ret->status, PARSE_ERR);
1439 return;
1440 }
1441
1442 ret->shader->type = ST_VERTEX;
1443 ret->shader->major_version = 1;
1444 ret->shader->minor_version = 0;
1445 ret->funcs = &parser_vs_1;
1446 gen_oldvs_output(ret->shader);
1447}
1448
1450 TRACE_(parsed_shader)("vs_1_1\n");
1451
1452 ret->shader = calloc(1, sizeof(*ret->shader));
1453 if(!ret->shader) {
1454 ERR("Failed to allocate memory for the shader\n");
1455 set_parse_status(&ret->status, PARSE_ERR);
1456 return;
1457 }
1458
1459 ret->shader->type = ST_VERTEX;
1460 ret->shader->major_version = 1;
1461 ret->shader->minor_version = 1;
1462 ret->funcs = &parser_vs_1;
1463 gen_oldvs_output(ret->shader);
1464}
1465
1467 TRACE_(parsed_shader)("vs_2_0\n");
1468
1469 ret->shader = calloc(1, sizeof(*ret->shader));
1470 if(!ret->shader) {
1471 ERR("Failed to allocate memory for the shader\n");
1472 set_parse_status(&ret->status, PARSE_ERR);
1473 return;
1474 }
1475
1476 ret->shader->type = ST_VERTEX;
1477 ret->shader->major_version = 2;
1478 ret->shader->minor_version = 0;
1479 ret->funcs = &parser_vs_2;
1480 gen_oldvs_output(ret->shader);
1481}
1482
1484 TRACE_(parsed_shader)("vs_2_x\n");
1485
1486 ret->shader = calloc(1, sizeof(*ret->shader));
1487 if(!ret->shader) {
1488 ERR("Failed to allocate memory for the shader\n");
1489 set_parse_status(&ret->status, PARSE_ERR);
1490 return;
1491 }
1492
1493 ret->shader->type = ST_VERTEX;
1494 ret->shader->major_version = 2;
1495 ret->shader->minor_version = 1;
1496 ret->funcs = &parser_vs_2;
1497 gen_oldvs_output(ret->shader);
1498}
1499
1501 TRACE_(parsed_shader)("vs_3_0\n");
1502
1503 ret->shader = calloc(1, sizeof(*ret->shader));
1504 if(!ret->shader) {
1505 ERR("Failed to allocate memory for the shader\n");
1506 set_parse_status(&ret->status, PARSE_ERR);
1507 return;
1508 }
1509
1510 ret->shader->type = ST_VERTEX;
1511 ret->shader->major_version = 3;
1512 ret->shader->minor_version = 0;
1513 ret->funcs = &parser_vs_3;
1514}
1515
1517 TRACE_(parsed_shader)("ps_1_0\n");
1518
1519 ret->shader = calloc(1, sizeof(*ret->shader));
1520 if(!ret->shader) {
1521 ERR("Failed to allocate memory for the shader\n");
1522 set_parse_status(&ret->status, PARSE_ERR);
1523 return;
1524 }
1525
1526 ret->shader->type = ST_PIXEL;
1527 ret->shader->major_version = 1;
1528 ret->shader->minor_version = 0;
1529 ret->funcs = &parser_ps_1_0123;
1530 gen_oldps_input(ret->shader, 4);
1531}
1532
1534 TRACE_(parsed_shader)("ps_1_1\n");
1535
1536 ret->shader = calloc(1, sizeof(*ret->shader));
1537 if(!ret->shader) {
1538 ERR("Failed to allocate memory for the shader\n");
1539 set_parse_status(&ret->status, PARSE_ERR);
1540 return;
1541 }
1542
1543 ret->shader->type = ST_PIXEL;
1544 ret->shader->major_version = 1;
1545 ret->shader->minor_version = 1;
1546 ret->funcs = &parser_ps_1_0123;
1547 gen_oldps_input(ret->shader, 4);
1548}
1549
1551 TRACE_(parsed_shader)("ps_1_2\n");
1552
1553 ret->shader = calloc(1, sizeof(*ret->shader));
1554 if(!ret->shader) {
1555 ERR("Failed to allocate memory for the shader\n");
1556 set_parse_status(&ret->status, PARSE_ERR);
1557 return;
1558 }
1559
1560 ret->shader->type = ST_PIXEL;
1561 ret->shader->major_version = 1;
1562 ret->shader->minor_version = 2;
1563 ret->funcs = &parser_ps_1_0123;
1564 gen_oldps_input(ret->shader, 4);
1565}
1566
1568 TRACE_(parsed_shader)("ps_1_3\n");
1569
1570 ret->shader = calloc(1, sizeof(*ret->shader));
1571 if(!ret->shader) {
1572 ERR("Failed to allocate memory for the shader\n");
1573 set_parse_status(&ret->status, PARSE_ERR);
1574 return;
1575 }
1576
1577 ret->shader->type = ST_PIXEL;
1578 ret->shader->major_version = 1;
1579 ret->shader->minor_version = 3;
1580 ret->funcs = &parser_ps_1_0123;
1581 gen_oldps_input(ret->shader, 4);
1582}
1583
1585 TRACE_(parsed_shader)("ps_1_4\n");
1586
1587 ret->shader = calloc(1, sizeof(*ret->shader));
1588 if(!ret->shader) {
1589 ERR("Failed to allocate memory for the shader\n");
1590 set_parse_status(&ret->status, PARSE_ERR);
1591 return;
1592 }
1593
1594 ret->shader->type = ST_PIXEL;
1595 ret->shader->major_version = 1;
1596 ret->shader->minor_version = 4;
1597 ret->funcs = &parser_ps_1_4;
1598 gen_oldps_input(ret->shader, 6);
1599}
1600
1602 TRACE_(parsed_shader)("ps_2_0\n");
1603
1604 ret->shader = calloc(1, sizeof(*ret->shader));
1605 if(!ret->shader) {
1606 ERR("Failed to allocate memory for the shader\n");
1607 set_parse_status(&ret->status, PARSE_ERR);
1608 return;
1609 }
1610
1611 ret->shader->type = ST_PIXEL;
1612 ret->shader->major_version = 2;
1613 ret->shader->minor_version = 0;
1614 ret->funcs = &parser_ps_2;
1615 gen_oldps_input(ret->shader, 8);
1616}
1617
1619 TRACE_(parsed_shader)("ps_2_x\n");
1620
1621 ret->shader = calloc(1, sizeof(*ret->shader));
1622 if(!ret->shader) {
1623 ERR("Failed to allocate memory for the shader\n");
1624 set_parse_status(&ret->status, PARSE_ERR);
1625 return;
1626 }
1627
1628 ret->shader->type = ST_PIXEL;
1629 ret->shader->major_version = 2;
1630 ret->shader->minor_version = 1;
1631 ret->funcs = &parser_ps_2_x;
1632 gen_oldps_input(ret->shader, 8);
1633}
1634
1636 TRACE_(parsed_shader)("ps_3_0\n");
1637
1638 ret->shader = calloc(1, sizeof(*ret->shader));
1639 if(!ret->shader) {
1640 ERR("Failed to allocate memory for the shader\n");
1641 set_parse_status(&ret->status, PARSE_ERR);
1642 return;
1643 }
1644
1645 ret->shader->type = ST_PIXEL;
1646 ret->shader->major_version = 3;
1647 ret->shader->minor_version = 0;
1648 ret->funcs = &parser_ps_3;
1649}
std::map< E_MODULE, HMODULE > mod
Definition: LocaleTests.cpp:68
static void asmparser_srcreg_ps_1_0123(struct asm_parser *parser, struct instruction *instr, int num, const struct shader_reg *src)
Definition: asmparser.c:929
static void asmparser_texreg2rgb(struct asm_parser *parser, uint32_t mod, uint32_t shift, const struct shader_reg *dst, const struct shader_reg *src0)
Definition: asmparser.c:528
static void check_shift_dstmod(struct asm_parser *parser, uint32_t shift)
Definition: asmparser.c:762
void create_vs11_parser(struct asm_parser *ret)
Definition: asmparser.c:1449
static const struct allowed_reg_type ps_3_reg_allowed[]
Definition: asmparser.c:1034
static const struct allowed_reg_type vs_1_reg_allowed[]
Definition: asmparser.c:814
static void asmparser_srcreg_ps_2_x(struct asm_parser *parser, struct instruction *instr, int num, const struct shader_reg *src)
Definition: asmparser.c:1017
#define T5_VARYING
Definition: asmparser.c:62
void create_ps12_parser(struct asm_parser *ret)
Definition: asmparser.c:1550
static const struct allowed_reg_type ps_1_4_reg_allowed[]
Definition: asmparser.c:945
static void asmparser_constB(struct asm_parser *parser, uint32_t reg, BOOL x)
Definition: asmparser.c:87
#define OT2_REG
Definition: asmparser.c:40
void create_vs2x_parser(struct asm_parser *ret)
Definition: asmparser.c:1483
static const struct asmparser_backend parser_ps_1_0123
Definition: asmparser.c:1292
static void check_legacy_srcmod(struct asm_parser *parser, uint32_t srcmod)
Definition: asmparser.c:727
static struct shader_reg map_oldvs_register(const struct shader_reg *reg)
Definition: asmparser.c:661
#define OT6_REG
Definition: asmparser.c:44
static const struct allowed_reg_type ps_1_0123_reg_allowed[]
Definition: asmparser.c:920
static void asmparser_dcl_input(struct asm_parser *parser, uint32_t usage, uint32_t num, uint32_t mod, const struct shader_reg *reg)
Definition: asmparser.c:137
#define OT0_REG
Definition: asmparser.c:38
#define OPTS_WRITEMASK
Definition: asmparser.c:50
static void asmparser_dstreg_vs_1(struct asm_parser *parser, struct instruction *instr, const struct shader_reg *dst)
Definition: asmparser.c:1065
static void asmparser_instr(struct asm_parser *parser, uint32_t opcode, uint32_t mod, uint32_t shift, enum bwriter_comparison_type comp, const struct shader_reg *dst, const struct src_regs *srcs, int expectednsrcs)
Definition: asmparser.c:546
static void asmparser_dstreg_ps_1_0123(struct asm_parser *parser, struct instruction *instr, const struct shader_reg *dst)
Definition: asmparser.c:1116
static void asmparser_texkill(struct asm_parser *parser, const struct shader_reg *dst)
Definition: asmparser.c:378
static void asmparser_dcl_output(struct asm_parser *parser, uint32_t usage, uint32_t num, const struct shader_reg *reg)
Definition: asmparser.c:113
static void asmparser_constI(struct asm_parser *parser, uint32_t reg, int x, int y, int z, int w)
Definition: asmparser.c:100
static BOOL check_reg_type(const struct shader_reg *reg, const struct allowed_reg_type *allowed)
Definition: asmparser.c:788
static void asmparser_dcl_input_unsupported(struct asm_parser *parser, uint32_t usage, uint32_t num, uint32_t mod, const struct shader_reg *reg)
Definition: asmparser.c:181
static const struct allowed_reg_type vs_3_reg_allowed[]
Definition: asmparser.c:890
static const struct asmparser_backend parser_vs_1
Definition: asmparser.c:1232
static void asmparser_end(struct asm_parser *This)
Definition: asmparser.c:70
#define OD1_REG
Definition: asmparser.c:52
static void asmparser_texreg2gb(struct asm_parser *parser, uint32_t mod, uint32_t shift, const struct shader_reg *dst, const struct shader_reg *src0)
Definition: asmparser.c:517
static void check_abs_srcmod(struct asm_parser *parser, uint32_t srcmod)
Definition: asmparser.c:741
static void asmparser_dstreg_ps_1_4(struct asm_parser *parser, struct instruction *instr, const struct shader_reg *dst)
Definition: asmparser.c:1132
void create_vs10_parser(struct asm_parser *ret)
Definition: asmparser.c:1432
static void gen_oldvs_output(struct bwriter_shader *shader)
Definition: asmparser.c:1392
static void asmparser_predicate_supported(struct asm_parser *parser, const struct shader_reg *predicate)
Definition: asmparser.c:1196
void create_ps30_parser(struct asm_parser *ret)
Definition: asmparser.c:1635
#define OFOG_WRITEMASK
Definition: asmparser.c:48
static void asmparser_texreg2ar(struct asm_parser *parser, uint32_t mod, uint32_t shift, const struct shader_reg *dst, const struct shader_reg *src0)
Definition: asmparser.c:506
#define T2_VARYING
Definition: asmparser.c:59
static void asmparser_constF(struct asm_parser *parser, uint32_t reg, float x, float y, float z, float w)
Definition: asmparser.c:74
#define OPTS_REG
Definition: asmparser.c:49
#define OT4_REG
Definition: asmparser.c:42
static struct shader_reg map_oldps_register(const struct shader_reg *reg, BOOL tex_varying)
Definition: asmparser.c:251
#define T1_VARYING
Definition: asmparser.c:58
static void asmparser_texhelper(struct asm_parser *parser, uint32_t mod, uint32_t shift, const struct shader_reg *dst, const struct shader_reg *src0)
Definition: asmparser.c:411
static void asmparser_dcl_sampler(struct asm_parser *parser, uint32_t samptype, uint32_t mod, uint32_t regnum, unsigned int line_no)
Definition: asmparser.c:188
static void asmparser_dcl_sampler_unsupported(struct asm_parser *parser, uint32_t samptype, uint32_t mod, uint32_t regnum, unsigned int line_no)
Definition: asmparser.c:207
#define T0_VARYING
Definition: asmparser.c:57
static void asmparser_texcrd(struct asm_parser *parser, uint32_t mod, uint32_t shift, const struct shader_reg *dst, const struct src_regs *srcs)
Definition: asmparser.c:342
static void asmparser_tex(struct asm_parser *parser, uint32_t mod, uint32_t shift, const struct shader_reg *dst)
Definition: asmparser.c:449
#define OFOG_REG
Definition: asmparser.c:47
static const struct asmparser_backend parser_ps_2_x
Definition: asmparser.c:1352
static void asmparser_dcl_output_unsupported(struct asm_parser *parser, uint32_t usage, uint32_t num, const struct shader_reg *reg)
Definition: asmparser.c:130
static void asmparser_srcreg_vs_1(struct asm_parser *parser, struct instruction *instr, int num, const struct shader_reg *src)
Definition: asmparser.c:838
static void asmparser_dstreg_vs_3(struct asm_parser *parser, struct instruction *instr, const struct shader_reg *dst)
Definition: asmparser.c:1101
void create_ps11_parser(struct asm_parser *ret)
Definition: asmparser.c:1533
static void asmparser_texcoord(struct asm_parser *parser, uint32_t mod, uint32_t shift, const struct shader_reg *dst, const struct src_regs *srcs)
Definition: asmparser.c:302
static void asmparser_srcreg_vs_2(struct asm_parser *parser, struct instruction *instr, int num, const struct shader_reg *src)
Definition: asmparser.c:872
static void asmparser_srcreg_ps_3(struct asm_parser *parser, struct instruction *instr, int num, const struct shader_reg *src)
Definition: asmparser.c:1051
#define T7_VARYING
Definition: asmparser.c:64
void create_ps10_parser(struct asm_parser *ret)
Definition: asmparser.c:1516
static void asmparser_sincos(struct asm_parser *parser, uint32_t mod, uint32_t shift, const struct shader_reg *dst, const struct src_regs *srcs)
Definition: asmparser.c:214
static const struct allowed_reg_type ps_2_0_reg_allowed[]
Definition: asmparser.c:970
static const struct allowed_reg_type vs_2_reg_allowed[]
Definition: asmparser.c:855
#define C0_VARYING
Definition: asmparser.c:55
static void check_ps_dstmod(struct asm_parser *parser, uint32_t dstmod)
Definition: asmparser.c:771
static const struct asmparser_backend parser_vs_3
Definition: asmparser.c:1272
static void asmparser_predicate_unsupported(struct asm_parser *parser, const struct shader_reg *predicate)
Definition: asmparser.c:1207
static void asmparser_dstreg_ps_2_x(struct asm_parser *parser, struct instruction *instr, const struct shader_reg *dst)
Definition: asmparser.c:1165
static void asmparser_srcreg_vs_3(struct asm_parser *parser, struct instruction *instr, int num, const struct shader_reg *src)
Definition: asmparser.c:906
static void asmparser_dcl_input_ps_2(struct asm_parser *parser, uint32_t usage, uint32_t num, uint32_t mod, const struct shader_reg *reg)
Definition: asmparser.c:164
void create_ps20_parser(struct asm_parser *ret)
Definition: asmparser.c:1601
static void asmparser_coissue_supported(struct asm_parser *parser)
Definition: asmparser.c:1213
static const struct asmparser_backend parser_ps_1_4
Definition: asmparser.c:1312
void create_ps14_parser(struct asm_parser *ret)
Definition: asmparser.c:1584
void create_vs30_parser(struct asm_parser *ret)
Definition: asmparser.c:1500
#define OD0_REG
Definition: asmparser.c:51
#define C1_VARYING
Definition: asmparser.c:56
static void asmparser_dstreg_vs_2(struct asm_parser *parser, struct instruction *instr, const struct shader_reg *dst)
Definition: asmparser.c:1083
#define T3_VARYING
Definition: asmparser.c:60
static void check_loop_swizzle(struct asm_parser *parser, const struct shader_reg *src)
Definition: asmparser.c:751
static const struct asmparser_backend parser_ps_2
Definition: asmparser.c:1332
#define OT5_REG
Definition: asmparser.c:43
static void gen_oldps_input(struct bwriter_shader *shader, uint32_t texcoords)
Definition: asmparser.c:1408
static void asmparser_texld14(struct asm_parser *parser, uint32_t mod, uint32_t shift, const struct shader_reg *dst, const struct src_regs *srcs)
Definition: asmparser.c:458
static const struct asmparser_backend parser_vs_2
Definition: asmparser.c:1252
static const struct allowed_reg_type ps_2_x_reg_allowed[]
Definition: asmparser.c:1001
#define OPOS_REG
Definition: asmparser.c:46
static void asmparser_coissue_unsupported(struct asm_parser *parser)
Definition: asmparser.c:1226
void create_vs20_parser(struct asm_parser *ret)
Definition: asmparser.c:1466
static void asmparser_dstreg_ps_2(struct asm_parser *parser, struct instruction *instr, const struct shader_reg *dst)
Definition: asmparser.c:1148
#define T4_VARYING
Definition: asmparser.c:61
void create_ps13_parser(struct asm_parser *ret)
Definition: asmparser.c:1567
#define OT1_REG
Definition: asmparser.c:39
#define OT7_REG
Definition: asmparser.c:45
static const struct asmparser_backend parser_ps_3
Definition: asmparser.c:1372
#define T6_VARYING
Definition: asmparser.c:63
#define OT3_REG
Definition: asmparser.c:41
static void asmparser_dstreg_ps_3(struct asm_parser *parser, struct instruction *instr, const struct shader_reg *dst)
Definition: asmparser.c:1182
static void asmparser_srcreg_ps_2(struct asm_parser *parser, struct instruction *instr, int num, const struct shader_reg *src)
Definition: asmparser.c:984
static void asmparser_srcreg_ps_1_4(struct asm_parser *parser, struct instruction *instr, int num, const struct shader_reg *src)
Definition: asmparser.c:954
void create_ps2x_parser(struct asm_parser *ret)
Definition: asmparser.c:1618
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define FIXME(fmt,...)
Definition: precomp.h:53
#define ERR(fmt,...)
Definition: precomp.h:57
BOOL add_constB(struct bwriter_shader *shader, uint32_t reg, BOOL x)
BOOL add_constF(struct bwriter_shader *shader, uint32_t reg, float x, float y, float z, float w)
BOOL record_sampler(struct bwriter_shader *shader, uint32_t samptype, uint32_t mod, uint32_t regnum)
struct instruction * alloc_instr(unsigned int srcs)
BOOL record_declaration(struct bwriter_shader *shader, uint32_t usage, uint32_t usage_idx, uint32_t mod, BOOL output, uint32_t regnum, uint32_t writemask, BOOL builtin)
BOOL add_constI(struct bwriter_shader *shader, uint32_t reg, int x, int y, int z, int w)
BOOL add_instruction(struct bwriter_shader *shader, struct instruction *instr)
@ BWRITERSRO_POSITION
@ BWRITERSRO_FOG
@ BWRITERSRO_POINT_SIZE
const char * debug_print_srcmod(uint32_t mod)
Definition: utils.c:134
@ BWRITERSPSM_COMP
@ BWRITERSPSM_X2
@ BWRITERSPSM_ABS
@ BWRITERSPSM_NONE
@ BWRITERSPSM_BIAS
@ BWRITERSPSM_X2NEG
@ BWRITERSPSM_SIGNNEG
@ BWRITERSPSM_BIASNEG
@ BWRITERSPSM_DZ
@ BWRITERSPSM_ABSNEG
@ BWRITERSPSM_SIGN
@ BWRITERSPSM_DW
#define BWRITERVS_Z_Z
bwriter_comparison_type
#define BWRITERVS_X_X
#define T3_REG
@ BWRITERSPDM_SATURATE
@ BWRITERSPDM_PARTIALPRECISION
@ BWRITERSPDM_MSAMPCENTROID
#define BWRITERVS_Y_Y
@ BWRITERDECLUSAGE_FOG
@ BWRITERDECLUSAGE_PSIZE
@ BWRITERDECLUSAGE_COLOR
@ BWRITERDECLUSAGE_POSITION
@ BWRITERDECLUSAGE_TEXCOORD
const char * debug_print_shift(uint32_t shift)
Definition: utils.c:184
const char * debug_print_comp(uint32_t comp)
Definition: utils.c:407
#define BWRITERSP_WRITEMASK_ALL
#define BWRITERVS_Y_X
#define BWRITERVS_W_X
#define BWRITERVS_Z_X
#define BWRITERVS_Y_Z
#define T1_REG
void WINAPIV static void set_parse_status(enum parse_status *current, enum parse_status update)
#define BWRITERVS_NOSWIZZLE
#define BWRITERVS_W_Z
const char * debug_print_dstreg(const struct shader_reg *reg)
Definition: utils.c:336
#define T0_REG
@ ST_VERTEX
@ ST_PIXEL
const char * debug_print_dstmod(uint32_t mod)
Definition: utils.c:159
@ BWRITERSPR_TEXCRDOUT
@ BWRITERSPR_CONSTINT
@ BWRITERSPR_MISCTYPE
@ BWRITERSPR_RASTOUT
@ BWRITERSPR_LOOP
@ BWRITERSPR_CONSTBOOL
@ BWRITERSPR_COLOROUT
@ BWRITERSPR_SAMPLER
@ BWRITERSPR_CONST
@ BWRITERSPR_TEXTURE
@ BWRITERSPR_DEPTHOUT
@ BWRITERSPR_ADDR
@ BWRITERSPR_ATTROUT
@ BWRITERSPR_TEMP
@ BWRITERSPR_INPUT
@ BWRITERSPR_PREDICATE
@ BWRITERSPR_LABEL
@ BWRITERSPR_OUTPUT
#define BWRITERVS_X_Y
void WINAPIV asmparser_message(struct asm_parser *ctx, const char *fmt,...) PRINTF_ATTR(2
@ BWRITERSIO_MOV
@ BWRITERSIO_TEX
@ BWRITERSIO_TEXREG2AR
@ BWRITERSIO_TEXCOORD
@ BWRITERSIO_TEXREG2RGB
@ BWRITERSIO_SINCOS
@ BWRITERSIO_TEXKILL
@ BWRITERSIO_TEXREG2GB
#define BWRITERVS_X_W
#define T2_REG
const char * debug_print_srcreg(const struct shader_reg *reg)
Definition: utils.c:343
const char * debug_print_opcode(uint32_t opcode)
Definition: utils.c:422
@ PARSE_ERR
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
UINT32 uint32_t
Definition: types.h:75
#define TRACE_(x)
Definition: compat.h:76
#define WINE_DECLARE_DEBUG_CHANNEL(x)
Definition: compat.h:45
return ret
Definition: mutex.c:147
unsigned int BOOL
Definition: ntddk_ex.h:94
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLenum src
Definition: glext.h:6340
GLuint shader
Definition: glext.h:6030
GLenum GLenum dst
Definition: glext.h:6340
GLuint GLuint num
Definition: glext.h:9618
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
GLdouble GLdouble z
Definition: glext.h:5874
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
static int reg
Definition: i386-dis.c:1290
#define ZeroMemory
Definition: minwinbase.h:31
#define shift
Definition: input.c:3280
#define calloc
Definition: rosglue.h:14
#define TRACE(s)
Definition: solgame.cpp:4
uint32_t type
Definition: asmparser.c:783
unsigned int count
Definition: asmparser.c:784
enum bwriter_comparison_type comptype
struct shader_reg * src
struct shader_reg dst
Definition: import.c:81
unsigned int count
struct shader_reg reg[MAX_SRC_REGS]
#define const
Definition: zconf.h:233