2 * Direct3D shader assembler
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
23 #include "wine/debug.h"
25 #include "d3dcompiler_private.h"
27 WINE_DEFAULT_DEBUG_CHANNEL
(asmshader
);
29 struct asm_parser asm_ctx
;
31 void WINAPIV asmparser_message
(struct asm_parser
*ctx
, const char *fmt
, ...
)
35 __ms_va_start
(args
, fmt
);
36 compilation_message
(&ctx
->messages
, fmt
, args
);
40 static void asmshader_error
(char const *s
) {
41 asmparser_message
(&asm_ctx
, "Line %u: Error \"%s\" from bison\n", asm_ctx.line_no
, s
);
42 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
45 static void set_rel_reg
(struct shader_reg
*reg
, struct rel_reg
*rel
) {
46 /* We can have an additional offset without true relative addressing
48 reg
->regnum
+= rel
->additional_offset
;
49 if
(!rel
->has_rel_reg
) {
52 reg
->rel_reg
= d3dcompiler_alloc
(sizeof
(*reg
->rel_reg
));
56 reg
->rel_reg
->type
= rel
->type
;
57 reg
->rel_reg
->u.swizzle
= rel
->swizzle
;
58 reg
->rel_reg
->regnum
= rel
->rel_regnum
;
62 /* Needed lexer functions declarations */
63 int asmshader_lex
(void);
75 struct shader_reg reg
;
93 enum bwriter_comparison_type comptype
;
98 enum bwritersampler_texture_type samplertype
;
99 struct rel_reg rel_reg
;
100 struct src_regs sregs
;
103 /* Common instructions between vertex and pixel shaders */
156 /* Vertex shader only instructions */
160 /* Pixel shader only instructions */
164 %token INSTR_TEXCOORD
171 %token INSTR_TEXREG2AR
172 %token INSTR_TEXREG2GB
173 %token INSTR_TEXREG2RGB
174 %token INSTR_TEXM3x2PAD
175 %token INSTR_TEXM3x2TEX
176 %token INSTR_TEXM3x3PAD
177 %token INSTR_TEXM3x3SPEC
178 %token INSTR_TEXM3x3VSPEC
179 %token INSTR_TEXM3x3TEX
180 %token INSTR_TEXDP3TEX
181 %token INSTR_TEXM3x2DEPTH
184 %token INSTR_TEXDEPTH
194 %token
<regnum
> REG_TEMP
195 %token
<regnum
> REG_OUTPUT
196 %token
<regnum
> REG_INPUT
197 %token
<regnum
> REG_CONSTFLOAT
198 %token
<regnum
> REG_CONSTINT
199 %token
<regnum
> REG_CONSTBOOL
200 %token
<regnum
> REG_TEXTURE
201 %token
<regnum
> REG_SAMPLER
202 %token
<regnum
> REG_TEXCRDOUT
206 %token
<regnum
> REG_VERTEXCOLOR
207 %token
<regnum
> REG_FRAGCOLOR
214 %token
<regnum
> REG_LABEL
232 /* Output modifiers */
251 /* Source register modifiers */
253 %token SMOD_SCALEBIAS
263 %token SAMPTYPE_VOLUME
265 /* Usage declaration tokens */
266 %token
<regnum
> USAGE_POSITION
267 %token
<regnum
> USAGE_BLENDWEIGHT
268 %token
<regnum
> USAGE_BLENDINDICES
269 %token
<regnum
> USAGE_NORMAL
270 %token
<regnum
> USAGE_PSIZE
271 %token
<regnum
> USAGE_TEXCOORD
272 %token
<regnum
> USAGE_TANGENT
273 %token
<regnum
> USAGE_BINORMAL
274 %token
<regnum
> USAGE_TESSFACTOR
275 %token
<regnum
> USAGE_POSITIONT
276 %token
<regnum
> USAGE_COLOR
277 %token
<regnum
> USAGE_FOG
278 %token
<regnum
> USAGE_DEPTH
279 %token
<regnum
> USAGE_SAMPLE
282 %token
<component
> COMPONENT
283 %token
<immval
> IMMVAL
284 %token
<immbool
> IMMBOOL
286 %type
<reg
> dreg_name
288 %type
<reg
> sreg_name
289 %type
<reg
> relreg_name
292 %type
<writemask
> writemask
293 %type
<wm_components
> wm_components
294 %type
<swizzle
> swizzle
295 %type
<sw_components
> sw_components
296 %type
<modshift
> omods
297 %type
<modshift
> omodifier
298 %type
<comptype
> comp
299 %type
<declaration
> dclusage
300 %type
<reg
> dcl_inputreg
301 %type
<samplertype
> sampdcl
302 %type
<rel_reg
> rel_reg
303 %type
<reg
> predicate
304 %type
<immval
> immsum
309 shader: version_marker instructions
311 asm_ctx.funcs
->end
(&asm_ctx
);
314 version_marker: VER_VS10
316 TRACE
("Vertex shader 1.0\n");
317 create_vs10_parser
(&asm_ctx
);
321 TRACE
("Vertex shader 1.1\n");
322 create_vs11_parser
(&asm_ctx
);
326 TRACE
("Vertex shader 2.0\n");
327 create_vs20_parser
(&asm_ctx
);
331 TRACE
("Vertex shader 2.x\n");
332 create_vs2x_parser
(&asm_ctx
);
336 TRACE
("Vertex shader 3.0\n");
337 create_vs30_parser
(&asm_ctx
);
341 TRACE
("Pixel shader 1.0\n");
342 create_ps10_parser
(&asm_ctx
);
346 TRACE
("Pixel shader 1.1\n");
347 create_ps11_parser
(&asm_ctx
);
351 TRACE
("Pixel shader 1.2\n");
352 create_ps12_parser
(&asm_ctx
);
356 TRACE
("Pixel shader 1.3\n");
357 create_ps13_parser
(&asm_ctx
);
361 TRACE
("Pixel shader 1.4\n");
362 create_ps14_parser
(&asm_ctx
);
366 TRACE
("Pixel shader 2.0\n");
367 create_ps20_parser
(&asm_ctx
);
371 TRACE
("Pixel shader 2.x\n");
372 create_ps2x_parser
(&asm_ctx
);
376 TRACE
("Pixel shader 3.0\n");
377 create_ps30_parser
(&asm_ctx
);
380 instructions: /* empty */
381 | instructions complexinstr
386 complexinstr: instruction
390 | predicate instruction
392 TRACE
("predicate\n");
393 asm_ctx.funcs
->predicate
(&asm_ctx
, &$1);
398 asm_ctx.funcs
->coissue
(&asm_ctx
);
401 instruction: INSTR_ADD omods dreg
',' sregs
404 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_ADD
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
409 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_NOP
, 0, 0, 0, 0, 0, 0);
411 | INSTR_MOV omods dreg
',' sregs
414 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_MOV
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
416 | INSTR_SUB omods dreg
',' sregs
419 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_SUB
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
421 | INSTR_MAD omods dreg
',' sregs
424 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_MAD
, $2.mod
, $2.shift
, 0, &$3, &$5, 3);
426 | INSTR_MUL omods dreg
',' sregs
429 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_MUL
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
431 | INSTR_RCP omods dreg
',' sregs
434 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_RCP
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
436 | INSTR_RSQ omods dreg
',' sregs
439 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_RSQ
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
441 | INSTR_DP3 omods dreg
',' sregs
444 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_DP3
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
446 | INSTR_DP4 omods dreg
',' sregs
449 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_DP4
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
451 | INSTR_MIN omods dreg
',' sregs
454 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_MIN
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
456 | INSTR_MAX omods dreg
',' sregs
459 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_MAX
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
461 | INSTR_SLT omods dreg
',' sregs
464 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_SLT
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
466 | INSTR_SGE omods dreg
',' sregs
469 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_SGE
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
471 | INSTR_ABS omods dreg
',' sregs
474 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_ABS
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
476 | INSTR_EXP omods dreg
',' sregs
479 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_EXP
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
481 | INSTR_LOG omods dreg
',' sregs
484 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_LOG
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
486 | INSTR_LOGP omods dreg
',' sregs
489 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_LOGP
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
491 | INSTR_EXPP omods dreg
',' sregs
494 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_EXPP
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
496 | INSTR_DST omods dreg
',' sregs
499 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_DST
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
501 | INSTR_LRP omods dreg
',' sregs
504 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_LRP
, $2.mod
, $2.shift
, 0, &$3, &$5, 3);
506 | INSTR_FRC omods dreg
',' sregs
509 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_FRC
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
511 | INSTR_POW omods dreg
',' sregs
514 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_POW
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
516 | INSTR_CRS omods dreg
',' sregs
519 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_CRS
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
521 | INSTR_SGN omods dreg
',' sregs
524 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_SGN
, $2.mod
, $2.shift
, 0, &$3, &$5, 3);
526 | INSTR_NRM omods dreg
',' sregs
529 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_NRM
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
531 | INSTR_SINCOS omods dreg
',' sregs
534 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_SINCOS
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
536 | INSTR_M4x4 omods dreg
',' sregs
539 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_M4x4
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
541 | INSTR_M4x3 omods dreg
',' sregs
544 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_M4x3
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
546 | INSTR_M3x4 omods dreg
',' sregs
549 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_M3x4
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
551 | INSTR_M3x3 omods dreg
',' sregs
554 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_M3x3
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
556 | INSTR_M3x2 omods dreg
',' sregs
559 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_M3x2
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
561 | INSTR_DCL dclusage REG_OUTPUT
563 struct shader_reg reg
;
564 TRACE
("Output reg declaration\n");
565 ZeroMemory
(®
, sizeof
(reg
));
566 reg.type
= BWRITERSPR_OUTPUT
;
570 reg.u.writemask
= BWRITERSP_WRITEMASK_ALL
;
571 asm_ctx.funcs
->dcl_output
(&asm_ctx
, $2.dclusage
, $2.regnum
, ®
);
573 | INSTR_DCL dclusage REG_OUTPUT writemask
575 struct shader_reg reg
;
576 TRACE
("Output reg declaration\n");
577 ZeroMemory
(®
, sizeof
(reg
));
578 reg.type
= BWRITERSPR_OUTPUT
;
582 reg.u.writemask
= $4;
583 asm_ctx.funcs
->dcl_output
(&asm_ctx
, $2.dclusage
, $2.regnum
, ®
);
585 | INSTR_DCL dclusage omods dcl_inputreg
587 struct shader_reg reg
;
588 TRACE
("Input reg declaration\n");
590 asmparser_message
(&asm_ctx
, "Line %u: Shift modifier not allowed here\n",
592 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
594 if
(asm_ctx.shader
->type
== ST_PIXEL
&& asm_ctx.shader
->major_version
== 2)
596 asmparser_message
(&asm_ctx
, "Line %u: Declaration not supported in PS 2\n",
598 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
600 ZeroMemory
(®
, sizeof
(reg
));
602 reg.regnum
= $4.regnum
;
605 reg.u.writemask
= BWRITERSP_WRITEMASK_ALL
;
606 asm_ctx.funcs
->dcl_input
(&asm_ctx
, $2.dclusage
, $2.regnum
, $3.mod
, ®
);
608 | INSTR_DCL dclusage omods dcl_inputreg writemask
610 struct shader_reg reg
;
611 TRACE
("Input reg declaration\n");
613 asmparser_message
(&asm_ctx
, "Line %u: Shift modifier not allowed here\n",
615 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
617 if
(asm_ctx.shader
->type
== ST_PIXEL
&& asm_ctx.shader
->major_version
== 2)
619 asmparser_message
(&asm_ctx
, "Line %u: Declaration not supported in PS 2\n",
621 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
623 ZeroMemory
(®
, sizeof
(reg
));
625 reg.regnum
= $4.regnum
;
628 reg.u.writemask
= $5;
629 asm_ctx.funcs
->dcl_input
(&asm_ctx
, $2.dclusage
, $2.regnum
, $3.mod
, ®
);
631 | INSTR_DCL omods dcl_inputreg
633 struct shader_reg reg
;
634 TRACE
("Input reg declaration\n");
636 asmparser_message
(&asm_ctx
, "Line %u: Shift modifier not allowed here\n",
638 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
640 if
(asm_ctx.shader
->type
!= ST_PIXEL
) {
641 asmparser_message
(&asm_ctx
, "Line %u: Declaration needs a semantic\n",
643 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
645 ZeroMemory
(®
, sizeof
(reg
));
647 reg.regnum
= $3.regnum
;
650 reg.u.writemask
= BWRITERSP_WRITEMASK_ALL
;
651 asm_ctx.funcs
->dcl_input
(&asm_ctx
, 0, 0, $2.mod
, ®
);
653 | INSTR_DCL omods dcl_inputreg writemask
655 struct shader_reg reg
;
656 TRACE
("Input reg declaration\n");
658 asmparser_message
(&asm_ctx
, "Line %u: Shift modifier not allowed here\n",
660 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
662 if
(asm_ctx.shader
->type
!= ST_PIXEL
) {
663 asmparser_message
(&asm_ctx
, "Line %u: Declaration needs a semantic\n",
665 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
667 ZeroMemory
(®
, sizeof
(reg
));
669 reg.regnum
= $3.regnum
;
672 reg.u.writemask
= $4;
673 asm_ctx.funcs
->dcl_input
(&asm_ctx
, 0, 0, $2.mod
, ®
);
675 | INSTR_DCL sampdcl omods REG_SAMPLER
677 TRACE
("Sampler declared\n");
679 asmparser_message
(&asm_ctx
, "Line %u: Shift modifier not allowed here\n",
681 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
683 asm_ctx.funcs
->dcl_sampler
(&asm_ctx
, $2, $3.mod
, $4, asm_ctx.line_no
);
685 | INSTR_DCL omods REG_SAMPLER
687 TRACE
("Sampler declared\n");
689 asmparser_message
(&asm_ctx
, "Line %u: Shift modifier not allowed here\n",
691 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
693 if
(asm_ctx.shader
->type
!= ST_PIXEL
) {
694 asmparser_message
(&asm_ctx
, "Line %u: Declaration needs a sampler type\n",
696 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
698 asm_ctx.funcs
->dcl_sampler
(&asm_ctx
, BWRITERSTT_UNKNOWN
, $2.mod
, $3, asm_ctx.line_no
);
700 | INSTR_DCL sampdcl omods dcl_inputreg
702 TRACE
("Error rule: sampler decl of input reg\n");
703 asmparser_message
(&asm_ctx
, "Line %u: Sampler declarations of input regs is not valid\n",
705 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
707 | INSTR_DCL sampdcl omods REG_OUTPUT
709 TRACE
("Error rule: sampler decl of output reg\n");
710 asmparser_message
(&asm_ctx
, "Line %u: Sampler declarations of output regs is not valid\n",
712 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
714 | INSTR_DEF REG_CONSTFLOAT
',' IMMVAL
',' IMMVAL
',' IMMVAL
',' IMMVAL
716 asm_ctx.funcs
->constF
(&asm_ctx
, $2, $4.val
, $6.val
, $8.val
, $10.val
);
718 | INSTR_DEFI REG_CONSTINT
',' IMMVAL
',' IMMVAL
',' IMMVAL
',' IMMVAL
720 asm_ctx.funcs
->constI
(&asm_ctx
, $2, $4.val
, $6.val
, $8.val
, $10.val
);
722 | INSTR_DEFB REG_CONSTBOOL
',' IMMBOOL
724 asm_ctx.funcs
->constB
(&asm_ctx
, $2, $4);
729 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_REP
, 0, 0, 0, 0, &$2, 1);
734 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_ENDREP
, 0, 0, 0, 0, 0, 0);
739 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_IF
, 0, 0, 0, 0, &$2, 1);
741 | INSTR_IF comp sregs
744 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_IFC
, 0, 0, $2, 0, &$3, 2);
749 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_ELSE
, 0, 0, 0, 0, 0, 0);
754 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_ENDIF
, 0, 0, 0, 0, 0, 0);
759 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_BREAK
, 0, 0, 0, 0, 0, 0);
761 | INSTR_BREAK comp sregs
764 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_BREAKC
, 0, 0, $2, 0, &$3, 2);
769 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_BREAKP
, 0, 0, 0, 0, &$2, 1);
774 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_CALL
, 0, 0, 0, 0, &$2, 1);
779 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_CALLNZ
, 0, 0, 0, 0, &$2, 2);
784 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_LOOP
, 0, 0, 0, 0, &$2, 2);
789 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_RET
, 0, 0, 0, 0, 0, 0);
794 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_ENDLOOP
, 0, 0, 0, 0, 0, 0);
799 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_LABEL
, 0, 0, 0, 0, &$2, 1);
801 | INSTR_SETP comp dreg
',' sregs
804 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_SETP
, 0, 0, $2, &$3, &$5, 2);
806 | INSTR_TEXLDL omods dreg
',' sregs
809 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXLDL
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
811 | INSTR_LIT omods dreg
',' sregs
814 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_LIT
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
816 | INSTR_MOVA omods dreg
',' sregs
819 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_MOVA
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
821 | INSTR_CND omods dreg
',' sregs
824 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_CND
, $2.mod
, $2.shift
, 0, &$3, &$5, 3);
826 | INSTR_CMP omods dreg
',' sregs
829 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_CMP
, $2.mod
, $2.shift
, 0, &$3, &$5, 3);
831 | INSTR_DP2ADD omods dreg
',' sregs
834 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_DP2ADD
, $2.mod
, $2.shift
, 0, &$3, &$5, 3);
836 | INSTR_TEXCOORD omods dreg
839 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXCOORD
, $2.mod
, $2.shift
, 0, &$3, 0, 0);
841 | INSTR_TEXCRD omods dreg
',' sregs
844 /* texcoord and texcrd share the same opcode */
845 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXCOORD
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
850 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXKILL
, 0, 0, 0, &$2, 0, 0);
852 | INSTR_TEX omods dreg
855 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEX
, $2.mod
, $2.shift
, 0, &$3, 0, 0);
857 | INSTR_TEXDEPTH omods dreg
860 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXDEPTH
, $2.mod
, $2.shift
, 0, &$3, 0, 0);
862 | INSTR_TEXLD omods dreg
',' sregs
865 /* There is more than one acceptable syntax for texld:
866 with 1 sreg (PS 1.4) or
867 with 2 sregs (PS 2.0+)
868 Moreover, texld shares the same opcode as the tex instruction,
869 so there are a total of 3 valid syntaxes
870 These variations are handled in asmparser.c */
871 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEX
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
873 | INSTR_TEXLDP omods dreg
',' sregs
876 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXLDP
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
878 | INSTR_TEXLDB omods dreg
',' sregs
881 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXLDB
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
883 | INSTR_TEXBEM omods dreg
',' sregs
886 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXBEM
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
888 | INSTR_TEXBEML omods dreg
',' sregs
891 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXBEML
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
893 | INSTR_TEXREG2AR omods dreg
',' sregs
895 TRACE
("TEXREG2AR\n");
896 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXREG2AR
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
898 | INSTR_TEXREG2GB omods dreg
',' sregs
900 TRACE
("TEXREG2GB\n");
901 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXREG2GB
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
903 | INSTR_TEXREG2RGB omods dreg
',' sregs
905 TRACE
("TEXREG2RGB\n");
906 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXREG2RGB
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
908 | INSTR_TEXM3x2PAD omods dreg
',' sregs
910 TRACE
("TEXM3x2PAD\n");
911 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXM3x2PAD
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
913 | INSTR_TEXM3x3PAD omods dreg
',' sregs
915 TRACE
("INSTR_TEXM3x3PAD\n");
916 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXM3x3PAD
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
918 | INSTR_TEXM3x3SPEC omods dreg
',' sregs
920 TRACE
("TEXM3x3SPEC\n");
921 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXM3x3SPEC
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
923 | INSTR_TEXM3x3VSPEC omods dreg
',' sregs
925 TRACE
("TEXM3x3VSPEC\n");
926 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXM3x3VSPEC
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
928 | INSTR_TEXM3x3TEX omods dreg
',' sregs
930 TRACE
("TEXM3x3TEX\n");
931 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXM3x3TEX
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
933 | INSTR_TEXDP3TEX omods dreg
',' sregs
935 TRACE
("TEXDP3TEX\n");
936 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXDP3TEX
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
938 | INSTR_TEXM3x2DEPTH omods dreg
',' sregs
940 TRACE
("TEXM3x2DEPTH\n");
941 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXM3x2DEPTH
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
943 | INSTR_TEXM3x2TEX omods dreg
',' sregs
945 TRACE
("TEXM3x2TEX\n");
946 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXM3x2TEX
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
948 | INSTR_TEXDP3 omods dreg
',' sregs
951 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXDP3
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
953 | INSTR_TEXM3x3 omods dreg
',' sregs
956 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXM3x3
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
958 | INSTR_BEM omods dreg
',' sregs
961 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_BEM
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
963 | INSTR_DSX omods dreg
',' sregs
966 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_DSX
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
968 | INSTR_DSY omods dreg
',' sregs
971 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_DSY
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
973 | INSTR_TEXLDD omods dreg
',' sregs
976 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXLDD
, $2.mod
, $2.shift
, 0, &$3, &$5, 4);
981 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_PHASE
, 0, 0, 0, 0, 0, 0);
985 dreg: dreg_name rel_reg
987 $$.regnum
= $1.regnum
;
989 $$.u.writemask
= BWRITERSP_WRITEMASK_ALL
;
990 $$.srcmod
= BWRITERSPSM_NONE
;
991 set_rel_reg
(&$$
, &$2);
993 | dreg_name writemask
995 $$.regnum
= $1.regnum
;
998 $$.srcmod
= BWRITERSPSM_NONE
;
1004 $$.regnum
= $1; $$.type
= BWRITERSPR_TEMP
;
1008 $$.regnum
= $1; $$.type
= BWRITERSPR_OUTPUT
;
1012 $$.regnum
= $1; $$.type
= BWRITERSPR_INPUT
;
1016 asmparser_message
(&asm_ctx
, "Line %u: Register c%u is not a valid destination register\n",
1017 asm_ctx.line_no
, $1);
1018 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
1022 asmparser_message
(&asm_ctx
, "Line %u: Register i%u is not a valid destination register\n",
1023 asm_ctx.line_no
, $1);
1024 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
1028 asmparser_message
(&asm_ctx
, "Line %u: Register b%u is not a valid destination register\n",
1029 asm_ctx.line_no
, $1);
1030 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
1034 $$.regnum
= $1; $$.type
= BWRITERSPR_TEXTURE
;
1038 $$.regnum
= $1; $$.type
= BWRITERSPR_TEXCRDOUT
;
1042 asmparser_message
(&asm_ctx
, "Line %u: Register s%u is not a valid destination register\n",
1043 asm_ctx.line_no
, $1);
1044 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
1048 $$.regnum
= BWRITERSRO_POSITION
; $$.type
= BWRITERSPR_RASTOUT
;
1052 $$.regnum
= BWRITERSRO_POINT_SIZE
; $$.type
= BWRITERSPR_RASTOUT
;
1056 $$.regnum
= BWRITERSRO_FOG
; $$.type
= BWRITERSPR_RASTOUT
;
1060 $$.regnum
= $1; $$.type
= BWRITERSPR_ATTROUT
;
1064 $$.regnum
= $1; $$.type
= BWRITERSPR_COLOROUT
;
1068 $$.regnum
= 0; $$.type
= BWRITERSPR_DEPTHOUT
;
1072 $$.regnum
= 0; $$.type
= BWRITERSPR_PREDICATE
;
1076 asmparser_message
(&asm_ctx
, "Line %u: Register vPos is not a valid destination register\n",
1078 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
1082 asmparser_message
(&asm_ctx
, "Line %u: Register vFace is not a valid destination register\n",
1084 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
1088 /* index 0 is hardcoded for the addr register */
1089 $$.regnum
= 0; $$.type
= BWRITERSPR_ADDR
;
1093 asmparser_message
(&asm_ctx
, "Line %u: Register aL is not a valid destination register\n",
1095 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
1098 writemask: '.' wm_components
1100 if
($2.writemask
== SWIZZLE_ERR
) {
1101 asmparser_message
(&asm_ctx
, "Line %u: Invalid writemask specified\n",
1103 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
1104 /* Provide a correct writemask to prevent following complaints */
1105 $$
= BWRITERSP_WRITEMASK_ALL
;
1109 TRACE
("Writemask: %x\n", $$
);
1113 wm_components: COMPONENT
1115 $$.writemask
= 1 << $1;
1119 | wm_components COMPONENT
1121 if
($1.writemask
== SWIZZLE_ERR ||
$1.idx
== 4)
1122 /* Wrong writemask */
1123 $$.writemask
= SWIZZLE_ERR
;
1126 $$.writemask
= SWIZZLE_ERR
;
1128 $$.writemask
= $1.writemask |
(1 << $2);
1129 $$.idx
= $1.idx
+ 1;
1134 swizzle: /* empty */
1136 $$
= BWRITERVS_NOSWIZZLE
;
1137 TRACE
("Default swizzle: %08x\n", $$
);
1141 if
($2.swizzle
== SWIZZLE_ERR
) {
1142 asmparser_message
(&asm_ctx
, "Line %u: Invalid swizzle\n",
1144 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
1145 /* Provide a correct swizzle to prevent following complaints */
1146 $$
= BWRITERVS_NOSWIZZLE
;
1152 /* Fill the swizzle by extending the last component */
1153 last
= ($2.swizzle
>> 2 * ($2.idx
- 1)) & 0x03;
1154 for
(i
= $2.idx
; i
< 4; i
++){
1155 $$ |
= last
<< (2 * i
);
1157 TRACE
("Got a swizzle: %08x\n", $$
);
1161 sw_components: COMPONENT
1166 | sw_components COMPONENT
1169 /* Too many sw_components */
1170 $$.swizzle
= SWIZZLE_ERR
;
1174 $$.swizzle
= $1.swizzle |
($2 << 2 * $1.idx
);
1175 $$.idx
= $1.idx
+ 1;
1186 $$.mod
= $1.mod |
$2.mod
;
1187 if
($1.shift
&& $2.shift
) {
1188 asmparser_message
(&asm_ctx
, "Line %u: More than one shift flag\n",
1190 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
1191 $$.shift
= $1.shift
;
1193 $$.shift
= $1.shift |
$2.shift
;
1229 $$.mod
= BWRITERSPDM_SATURATE
;
1234 $$.mod
= BWRITERSPDM_PARTIALPRECISION
;
1239 $$.mod
= BWRITERSPDM_MSAMPCENTROID
;
1250 if
($$.count
== MAX_SRC_REGS
){
1251 asmparser_message
(&asm_ctx
, "Line %u: Too many source registers in this instruction\n",
1253 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
1256 $$.reg
[$$.count
++] = $3;
1259 sreg: sreg_name rel_reg swizzle
1262 $$.regnum
= $1.regnum
;
1264 $$.srcmod
= BWRITERSPSM_NONE
;
1265 set_rel_reg
(&$$
, &$2);
1267 | sreg_name rel_reg smod swizzle
1270 $$.regnum
= $1.regnum
;
1271 set_rel_reg
(&$$
, &$2);
1275 |
'-' sreg_name rel_reg swizzle
1278 $$.regnum
= $2.regnum
;
1279 $$.srcmod
= BWRITERSPSM_NEG
;
1280 set_rel_reg
(&$$
, &$3);
1283 |
'-' sreg_name rel_reg smod swizzle
1286 $$.regnum
= $2.regnum
;
1287 set_rel_reg
(&$$
, &$3);
1289 case BWRITERSPSM_BIAS
: $$.srcmod
= BWRITERSPSM_BIASNEG
; break
;
1290 case BWRITERSPSM_X2
: $$.srcmod
= BWRITERSPSM_X2NEG
; break
;
1291 case BWRITERSPSM_SIGN
: $$.srcmod
= BWRITERSPSM_SIGNNEG
; break
;
1292 case BWRITERSPSM_ABS
: $$.srcmod
= BWRITERSPSM_ABSNEG
; break
;
1293 case BWRITERSPSM_DZ
:
1294 asmparser_message
(&asm_ctx
, "Line %u: Incompatible source modifiers: NEG and DZ\n",
1296 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
1298 case BWRITERSPSM_DW
:
1299 asmparser_message
(&asm_ctx
, "Line %u: Incompatible source modifiers: NEG and DW\n",
1301 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
1304 FIXME
("Unhandled combination of NEGATE and %u\n", $4);
1308 | IMMVAL
'-' sreg_name rel_reg swizzle
1310 if
($1.val
!= 1.0 ||
(!$1.integer
)) {
1311 asmparser_message
(&asm_ctx
, "Line %u: Only \"1 - reg\" is valid for D3DSPSM_COMP, "
1312 "%g - reg found\n", asm_ctx.line_no
, $1.val
);
1313 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
1315 /* Complement - not compatible with other source modifiers */
1317 $$.regnum
= $3.regnum
;
1318 $$.srcmod
= BWRITERSPSM_COMP
;
1319 set_rel_reg
(&$$
, &$4);
1322 | IMMVAL
'-' sreg_name rel_reg smod swizzle
1324 /* For nicer error reporting */
1325 if
($1.val
!= 1.0 ||
(!$1.integer
)) {
1326 asmparser_message
(&asm_ctx
, "Line %u: Only \"1 - reg\" is valid for D3DSPSM_COMP\n",
1328 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
1330 asmparser_message
(&asm_ctx
, "Line %u: Incompatible source modifiers: D3DSPSM_COMP and %s\n",
1332 debug_print_srcmod
($5));
1333 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
1336 | SMOD_NOT sreg_name swizzle
1339 $$.regnum
= $2.regnum
;
1341 $$.srcmod
= BWRITERSPSM_NOT
;
1345 rel_reg: /* empty */
1347 $$.has_rel_reg
= FALSE
;
1348 $$.additional_offset
= 0;
1352 $$.has_rel_reg
= FALSE
;
1353 $$.additional_offset
= $2.val
;
1355 |
'[' relreg_name swizzle
']'
1357 $$.has_rel_reg
= TRUE
;
1359 $$.additional_offset
= 0;
1360 $$.rel_regnum
= $2.regnum
;
1363 |
'[' immsum
'+' relreg_name swizzle
']'
1365 $$.has_rel_reg
= TRUE
;
1367 $$.additional_offset
= $2.val
;
1368 $$.rel_regnum
= $4.regnum
;
1371 |
'[' relreg_name swizzle
'+' immsum
']'
1373 $$.has_rel_reg
= TRUE
;
1375 $$.additional_offset
= $5.val
;
1376 $$.rel_regnum
= $2.regnum
;
1379 |
'[' immsum
'+' relreg_name swizzle
'+' immsum
']'
1381 $$.has_rel_reg
= TRUE
;
1383 $$.additional_offset
= $2.val
+ $7.val
;
1384 $$.rel_regnum
= $4.regnum
;
1391 asmparser_message
(&asm_ctx
, "Line %u: Unexpected float %f\n",
1392 asm_ctx.line_no
, $1.val
);
1393 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
1400 asmparser_message
(&asm_ctx
, "Line %u: Unexpected float %f\n",
1401 asm_ctx.line_no
, $3.val
);
1402 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
1404 $$.val
= $1.val
+ $3.val
;
1409 $$
= BWRITERSPSM_BIAS
;
1413 $$
= BWRITERSPSM_X2
;
1417 $$
= BWRITERSPSM_SIGN
;
1421 $$
= BWRITERSPSM_DZ
;
1425 $$
= BWRITERSPSM_DW
;
1429 $$
= BWRITERSPSM_ABS
;
1432 relreg_name: REG_ADDRESS
1434 $$.regnum
= 0; $$.type
= BWRITERSPR_ADDR
;
1438 $$.regnum
= 0; $$.type
= BWRITERSPR_LOOP
;
1443 $$.regnum
= $1; $$.type
= BWRITERSPR_TEMP
;
1447 asmparser_message
(&asm_ctx
, "Line %u: Register o%u is not a valid source register\n",
1448 asm_ctx.line_no
, $1);
1449 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
1453 $$.regnum
= $1; $$.type
= BWRITERSPR_INPUT
;
1457 $$.regnum
= $1; $$.type
= BWRITERSPR_CONST
;
1461 $$.regnum
= $1; $$.type
= BWRITERSPR_CONSTINT
;
1465 $$.regnum
= $1; $$.type
= BWRITERSPR_CONSTBOOL
;
1469 $$.regnum
= $1; $$.type
= BWRITERSPR_TEXTURE
;
1473 asmparser_message
(&asm_ctx
, "Line %u: Register oT%u is not a valid source register\n",
1474 asm_ctx.line_no
, $1);
1475 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
1479 $$.regnum
= $1; $$.type
= BWRITERSPR_SAMPLER
;
1483 asmparser_message
(&asm_ctx
, "Line %u: Register oPos is not a valid source register\n",
1485 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
1489 asmparser_message
(&asm_ctx
, "Line %u: Register oFog is not a valid source register\n",
1491 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
1495 asmparser_message
(&asm_ctx
, "Line %u: Register oD%u is not a valid source register\n",
1496 asm_ctx.line_no
, $1);
1497 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
1501 asmparser_message
(&asm_ctx
, "Line %u: Register oC%u is not a valid source register\n",
1502 asm_ctx.line_no
, $1);
1503 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
1507 asmparser_message
(&asm_ctx
, "Line %u: Register oDepth is not a valid source register\n",
1509 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
1513 $$.regnum
= 0; $$.type
= BWRITERSPR_PREDICATE
;
1517 $$.regnum
= 0; $$.type
= BWRITERSPR_MISCTYPE
;
1521 $$.regnum
= 1; $$.type
= BWRITERSPR_MISCTYPE
;
1525 $$.regnum
= 0; $$.type
= BWRITERSPR_ADDR
;
1529 $$.regnum
= 0; $$.type
= BWRITERSPR_LOOP
;
1533 $$.regnum
= $1; $$.type
= BWRITERSPR_LABEL
;
1536 comp: COMP_GT
{ $$
= BWRITER_COMPARISON_GT
; }
1537 | COMP_LT
{ $$
= BWRITER_COMPARISON_LT
; }
1538 | COMP_GE
{ $$
= BWRITER_COMPARISON_GE
; }
1539 | COMP_LE
{ $$
= BWRITER_COMPARISON_LE
; }
1540 | COMP_EQ
{ $$
= BWRITER_COMPARISON_EQ
; }
1541 | COMP_NE
{ $$
= BWRITER_COMPARISON_NE
; }
1543 dclusage: USAGE_POSITION
1545 TRACE
("dcl_position%u\n", $1);
1547 $$.dclusage
= BWRITERDECLUSAGE_POSITION
;
1551 TRACE
("dcl_blendweight%u\n", $1);
1553 $$.dclusage
= BWRITERDECLUSAGE_BLENDWEIGHT
;
1555 | USAGE_BLENDINDICES
1557 TRACE
("dcl_blendindices%u\n", $1);
1559 $$.dclusage
= BWRITERDECLUSAGE_BLENDINDICES
;
1563 TRACE
("dcl_normal%u\n", $1);
1565 $$.dclusage
= BWRITERDECLUSAGE_NORMAL
;
1569 TRACE
("dcl_psize%u\n", $1);
1571 $$.dclusage
= BWRITERDECLUSAGE_PSIZE
;
1575 TRACE
("dcl_texcoord%u\n", $1);
1577 $$.dclusage
= BWRITERDECLUSAGE_TEXCOORD
;
1581 TRACE
("dcl_tangent%u\n", $1);
1583 $$.dclusage
= BWRITERDECLUSAGE_TANGENT
;
1587 TRACE
("dcl_binormal%u\n", $1);
1589 $$.dclusage
= BWRITERDECLUSAGE_BINORMAL
;
1593 TRACE
("dcl_tessfactor%u\n", $1);
1595 $$.dclusage
= BWRITERDECLUSAGE_TESSFACTOR
;
1599 TRACE
("dcl_positiont%u\n", $1);
1601 $$.dclusage
= BWRITERDECLUSAGE_POSITIONT
;
1605 TRACE
("dcl_color%u\n", $1);
1607 $$.dclusage
= BWRITERDECLUSAGE_COLOR
;
1611 TRACE
("dcl_fog%u\n", $1);
1613 $$.dclusage
= BWRITERDECLUSAGE_FOG
;
1617 TRACE
("dcl_depth%u\n", $1);
1619 $$.dclusage
= BWRITERDECLUSAGE_DEPTH
;
1623 TRACE
("dcl_sample%u\n", $1);
1625 $$.dclusage
= BWRITERDECLUSAGE_SAMPLE
;
1628 dcl_inputreg: REG_INPUT
1630 $$.regnum
= $1; $$.type
= BWRITERSPR_INPUT
;
1634 $$.regnum
= $1; $$.type
= BWRITERSPR_TEXTURE
;
1637 sampdcl: SAMPTYPE_1D
1647 $$
= BWRITERSTT_CUBE
;
1651 $$
= BWRITERSTT_VOLUME
;
1654 predicate: '(' REG_PREDICATE swizzle
')'
1656 $$.type
= BWRITERSPR_PREDICATE
;
1659 $$.srcmod
= BWRITERSPSM_NONE
;
1662 |
'(' SMOD_NOT REG_PREDICATE swizzle
')'
1664 $$.type
= BWRITERSPR_PREDICATE
;
1667 $$.srcmod
= BWRITERSPSM_NOT
;
1673 struct bwriter_shader
*parse_asm_shader
(char **messages
)
1675 struct bwriter_shader
*ret
= NULL
;
1677 asm_ctx.shader
= NULL
;
1678 asm_ctx.status
= PARSE_SUCCESS
;
1679 asm_ctx.messages.size
= asm_ctx.messages.capacity
= 0;
1680 asm_ctx.line_no
= 1;
1684 if
(asm_ctx.status
!= PARSE_ERR
)
1685 ret
= asm_ctx.shader
;
1686 else if
(asm_ctx.shader
)
1687 SlDeleteShader
(asm_ctx.shader
);
1691 if
(asm_ctx.messages.size
)
1693 /* Shrink the buffer to the used size */
1694 *messages
= d3dcompiler_realloc
(asm_ctx.messages.
string, asm_ctx.messages.size
+ 1);
1697 ERR
("Out of memory, no messages reported\n");
1698 d3dcompiler_free
(asm_ctx.messages.
string);
1708 if
(asm_ctx.messages.capacity
)
1709 d3dcompiler_free
(asm_ctx.messages.
string);