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
24 #include "wine/port.h"
25 #include "wine/debug.h"
27 #include "d3dcompiler_private.h"
29 WINE_DEFAULT_DEBUG_CHANNEL
(asmshader
);
31 struct asm_parser asm_ctx
;
33 void asmparser_message
(struct asm_parser
*ctx
, const char *fmt
, ...
)
38 compilation_message
(&ctx
->messages
, fmt
, args
);
42 static void asmshader_error
(char const *s
) {
43 asmparser_message
(&asm_ctx
, "Line %u: Error \"%s\" from bison\n", asm_ctx.line_no
, s
);
44 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
47 static void set_rel_reg
(struct shader_reg
*reg
, struct rel_reg
*rel
) {
48 /* We can have an additional offset without true relative addressing
50 reg
->regnum
+= rel
->additional_offset
;
51 if
(!rel
->has_rel_reg
) {
54 reg
->rel_reg
= d3dcompiler_alloc
(sizeof
(*reg
->rel_reg
));
58 reg
->rel_reg
->type
= rel
->type
;
59 reg
->rel_reg
->u.swizzle
= rel
->swizzle
;
60 reg
->rel_reg
->regnum
= rel
->rel_regnum
;
64 /* Needed lexer functions declarations */
65 int asmshader_lex
(void);
77 struct shader_reg reg
;
95 enum bwriter_comparison_type comptype
;
100 enum bwritersampler_texture_type samplertype
;
101 struct rel_reg rel_reg
;
102 struct src_regs sregs
;
105 /* Common instructions between vertex and pixel shaders */
158 /* Vertex shader only instructions */
162 /* Pixel shader only instructions */
166 %token INSTR_TEXCOORD
173 %token INSTR_TEXREG2AR
174 %token INSTR_TEXREG2GB
175 %token INSTR_TEXREG2RGB
176 %token INSTR_TEXM3x2PAD
177 %token INSTR_TEXM3x2TEX
178 %token INSTR_TEXM3x3PAD
179 %token INSTR_TEXM3x3SPEC
180 %token INSTR_TEXM3x3VSPEC
181 %token INSTR_TEXM3x3TEX
182 %token INSTR_TEXDP3TEX
183 %token INSTR_TEXM3x2DEPTH
186 %token INSTR_TEXDEPTH
196 %token
<regnum
> REG_TEMP
197 %token
<regnum
> REG_OUTPUT
198 %token
<regnum
> REG_INPUT
199 %token
<regnum
> REG_CONSTFLOAT
200 %token
<regnum
> REG_CONSTINT
201 %token
<regnum
> REG_CONSTBOOL
202 %token
<regnum
> REG_TEXTURE
203 %token
<regnum
> REG_SAMPLER
204 %token
<regnum
> REG_TEXCRDOUT
208 %token
<regnum
> REG_VERTEXCOLOR
209 %token
<regnum
> REG_FRAGCOLOR
216 %token
<regnum
> REG_LABEL
234 /* Output modifiers */
253 /* Source register modifiers */
255 %token SMOD_SCALEBIAS
265 %token SAMPTYPE_VOLUME
267 /* Usage declaration tokens */
268 %token
<regnum
> USAGE_POSITION
269 %token
<regnum
> USAGE_BLENDWEIGHT
270 %token
<regnum
> USAGE_BLENDINDICES
271 %token
<regnum
> USAGE_NORMAL
272 %token
<regnum
> USAGE_PSIZE
273 %token
<regnum
> USAGE_TEXCOORD
274 %token
<regnum
> USAGE_TANGENT
275 %token
<regnum
> USAGE_BINORMAL
276 %token
<regnum
> USAGE_TESSFACTOR
277 %token
<regnum
> USAGE_POSITIONT
278 %token
<regnum
> USAGE_COLOR
279 %token
<regnum
> USAGE_FOG
280 %token
<regnum
> USAGE_DEPTH
281 %token
<regnum
> USAGE_SAMPLE
284 %token
<component
> COMPONENT
285 %token
<immval
> IMMVAL
286 %token
<immbool
> IMMBOOL
288 %type
<reg
> dreg_name
290 %type
<reg
> sreg_name
291 %type
<reg
> relreg_name
294 %type
<writemask
> writemask
295 %type
<wm_components
> wm_components
296 %type
<swizzle
> swizzle
297 %type
<sw_components
> sw_components
298 %type
<modshift
> omods
299 %type
<modshift
> omodifier
300 %type
<comptype
> comp
301 %type
<declaration
> dclusage
302 %type
<reg
> dcl_inputreg
303 %type
<samplertype
> sampdcl
304 %type
<rel_reg
> rel_reg
305 %type
<reg
> predicate
306 %type
<immval
> immsum
311 shader: version_marker instructions
313 asm_ctx.funcs
->end
(&asm_ctx
);
316 version_marker: VER_VS10
318 TRACE
("Vertex shader 1.0\n");
319 create_vs10_parser
(&asm_ctx
);
323 TRACE
("Vertex shader 1.1\n");
324 create_vs11_parser
(&asm_ctx
);
328 TRACE
("Vertex shader 2.0\n");
329 create_vs20_parser
(&asm_ctx
);
333 TRACE
("Vertex shader 2.x\n");
334 create_vs2x_parser
(&asm_ctx
);
338 TRACE
("Vertex shader 3.0\n");
339 create_vs30_parser
(&asm_ctx
);
343 TRACE
("Pixel shader 1.0\n");
344 create_ps10_parser
(&asm_ctx
);
348 TRACE
("Pixel shader 1.1\n");
349 create_ps11_parser
(&asm_ctx
);
353 TRACE
("Pixel shader 1.2\n");
354 create_ps12_parser
(&asm_ctx
);
358 TRACE
("Pixel shader 1.3\n");
359 create_ps13_parser
(&asm_ctx
);
363 TRACE
("Pixel shader 1.4\n");
364 create_ps14_parser
(&asm_ctx
);
368 TRACE
("Pixel shader 2.0\n");
369 create_ps20_parser
(&asm_ctx
);
373 TRACE
("Pixel shader 2.x\n");
374 create_ps2x_parser
(&asm_ctx
);
378 TRACE
("Pixel shader 3.0\n");
379 create_ps30_parser
(&asm_ctx
);
382 instructions: /* empty */
383 | instructions complexinstr
388 complexinstr: instruction
392 | predicate instruction
394 TRACE
("predicate\n");
395 asm_ctx.funcs
->predicate
(&asm_ctx
, &$1);
400 asm_ctx.funcs
->coissue
(&asm_ctx
);
403 instruction: INSTR_ADD omods dreg
',' sregs
406 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_ADD
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
411 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_NOP
, 0, 0, 0, 0, 0, 0);
413 | INSTR_MOV omods dreg
',' sregs
416 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_MOV
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
418 | INSTR_SUB omods dreg
',' sregs
421 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_SUB
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
423 | INSTR_MAD omods dreg
',' sregs
426 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_MAD
, $2.mod
, $2.shift
, 0, &$3, &$5, 3);
428 | INSTR_MUL omods dreg
',' sregs
431 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_MUL
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
433 | INSTR_RCP omods dreg
',' sregs
436 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_RCP
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
438 | INSTR_RSQ omods dreg
',' sregs
441 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_RSQ
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
443 | INSTR_DP3 omods dreg
',' sregs
446 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_DP3
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
448 | INSTR_DP4 omods dreg
',' sregs
451 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_DP4
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
453 | INSTR_MIN omods dreg
',' sregs
456 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_MIN
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
458 | INSTR_MAX omods dreg
',' sregs
461 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_MAX
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
463 | INSTR_SLT omods dreg
',' sregs
466 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_SLT
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
468 | INSTR_SGE omods dreg
',' sregs
471 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_SGE
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
473 | INSTR_ABS omods dreg
',' sregs
476 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_ABS
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
478 | INSTR_EXP omods dreg
',' sregs
481 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_EXP
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
483 | INSTR_LOG omods dreg
',' sregs
486 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_LOG
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
488 | INSTR_LOGP omods dreg
',' sregs
491 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_LOGP
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
493 | INSTR_EXPP omods dreg
',' sregs
496 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_EXPP
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
498 | INSTR_DST omods dreg
',' sregs
501 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_DST
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
503 | INSTR_LRP omods dreg
',' sregs
506 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_LRP
, $2.mod
, $2.shift
, 0, &$3, &$5, 3);
508 | INSTR_FRC omods dreg
',' sregs
511 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_FRC
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
513 | INSTR_POW omods dreg
',' sregs
516 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_POW
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
518 | INSTR_CRS omods dreg
',' sregs
521 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_CRS
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
523 | INSTR_SGN omods dreg
',' sregs
526 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_SGN
, $2.mod
, $2.shift
, 0, &$3, &$5, 3);
528 | INSTR_NRM omods dreg
',' sregs
531 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_NRM
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
533 | INSTR_SINCOS omods dreg
',' sregs
536 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_SINCOS
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
538 | INSTR_M4x4 omods dreg
',' sregs
541 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_M4x4
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
543 | INSTR_M4x3 omods dreg
',' sregs
546 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_M4x3
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
548 | INSTR_M3x4 omods dreg
',' sregs
551 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_M3x4
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
553 | INSTR_M3x3 omods dreg
',' sregs
556 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_M3x3
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
558 | INSTR_M3x2 omods dreg
',' sregs
561 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_M3x2
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
563 | INSTR_DCL dclusage REG_OUTPUT
565 struct shader_reg reg
;
566 TRACE
("Output reg declaration\n");
567 ZeroMemory
(®
, sizeof
(reg
));
568 reg.type
= BWRITERSPR_OUTPUT
;
572 reg.u.writemask
= BWRITERSP_WRITEMASK_ALL
;
573 asm_ctx.funcs
->dcl_output
(&asm_ctx
, $2.dclusage
, $2.regnum
, ®
);
575 | INSTR_DCL dclusage REG_OUTPUT writemask
577 struct shader_reg reg
;
578 TRACE
("Output reg declaration\n");
579 ZeroMemory
(®
, sizeof
(reg
));
580 reg.type
= BWRITERSPR_OUTPUT
;
584 reg.u.writemask
= $4;
585 asm_ctx.funcs
->dcl_output
(&asm_ctx
, $2.dclusage
, $2.regnum
, ®
);
587 | INSTR_DCL dclusage omods dcl_inputreg
589 struct shader_reg reg
;
590 TRACE
("Input reg declaration\n");
592 asmparser_message
(&asm_ctx
, "Line %u: Shift modifier not allowed here\n",
594 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
596 if
(asm_ctx.shader
->version
== BWRITERPS_VERSION
(2, 0) ||
597 asm_ctx.shader
->version
== BWRITERPS_VERSION
(2, 1)) {
598 asmparser_message
(&asm_ctx
, "Line %u: Declaration not supported in PS 2\n",
600 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
602 ZeroMemory
(®
, sizeof
(reg
));
604 reg.regnum
= $4.regnum
;
607 reg.u.writemask
= BWRITERSP_WRITEMASK_ALL
;
608 asm_ctx.funcs
->dcl_input
(&asm_ctx
, $2.dclusage
, $2.regnum
, $3.mod
, ®
);
610 | INSTR_DCL dclusage omods dcl_inputreg writemask
612 struct shader_reg reg
;
613 TRACE
("Input reg declaration\n");
615 asmparser_message
(&asm_ctx
, "Line %u: Shift modifier not allowed here\n",
617 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
619 if
(asm_ctx.shader
->version
== BWRITERPS_VERSION
(2, 0) ||
620 asm_ctx.shader
->version
== BWRITERPS_VERSION
(2, 1)) {
621 asmparser_message
(&asm_ctx
, "Line %u: Declaration not supported in PS 2\n",
623 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
625 ZeroMemory
(®
, sizeof
(reg
));
627 reg.regnum
= $4.regnum
;
630 reg.u.writemask
= $5;
631 asm_ctx.funcs
->dcl_input
(&asm_ctx
, $2.dclusage
, $2.regnum
, $3.mod
, ®
);
633 | INSTR_DCL omods dcl_inputreg
635 struct shader_reg reg
;
636 TRACE
("Input reg declaration\n");
638 asmparser_message
(&asm_ctx
, "Line %u: Shift modifier not allowed here\n",
640 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
642 if
(asm_ctx.shader
->type
!= ST_PIXEL
) {
643 asmparser_message
(&asm_ctx
, "Line %u: Declaration needs a semantic\n",
645 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
647 ZeroMemory
(®
, sizeof
(reg
));
649 reg.regnum
= $3.regnum
;
652 reg.u.writemask
= BWRITERSP_WRITEMASK_ALL
;
653 asm_ctx.funcs
->dcl_input
(&asm_ctx
, 0, 0, $2.mod
, ®
);
655 | INSTR_DCL omods dcl_inputreg writemask
657 struct shader_reg reg
;
658 TRACE
("Input reg declaration\n");
660 asmparser_message
(&asm_ctx
, "Line %u: Shift modifier not allowed here\n",
662 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
664 if
(asm_ctx.shader
->type
!= ST_PIXEL
) {
665 asmparser_message
(&asm_ctx
, "Line %u: Declaration needs a semantic\n",
667 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
669 ZeroMemory
(®
, sizeof
(reg
));
671 reg.regnum
= $3.regnum
;
674 reg.u.writemask
= $4;
675 asm_ctx.funcs
->dcl_input
(&asm_ctx
, 0, 0, $2.mod
, ®
);
677 | INSTR_DCL sampdcl omods REG_SAMPLER
679 TRACE
("Sampler declared\n");
681 asmparser_message
(&asm_ctx
, "Line %u: Shift modifier not allowed here\n",
683 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
685 asm_ctx.funcs
->dcl_sampler
(&asm_ctx
, $2, $3.mod
, $4, asm_ctx.line_no
);
687 | INSTR_DCL omods REG_SAMPLER
689 TRACE
("Sampler declared\n");
691 asmparser_message
(&asm_ctx
, "Line %u: Shift modifier not allowed here\n",
693 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
695 if
(asm_ctx.shader
->type
!= ST_PIXEL
) {
696 asmparser_message
(&asm_ctx
, "Line %u: Declaration needs a sampler type\n",
698 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
700 asm_ctx.funcs
->dcl_sampler
(&asm_ctx
, BWRITERSTT_UNKNOWN
, $2.mod
, $3, asm_ctx.line_no
);
702 | INSTR_DCL sampdcl omods dcl_inputreg
704 TRACE
("Error rule: sampler decl of input reg\n");
705 asmparser_message
(&asm_ctx
, "Line %u: Sampler declarations of input regs is not valid\n",
707 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
709 | INSTR_DCL sampdcl omods REG_OUTPUT
711 TRACE
("Error rule: sampler decl of output reg\n");
712 asmparser_message
(&asm_ctx
, "Line %u: Sampler declarations of output regs is not valid\n",
714 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
716 | INSTR_DEF REG_CONSTFLOAT
',' IMMVAL
',' IMMVAL
',' IMMVAL
',' IMMVAL
718 asm_ctx.funcs
->constF
(&asm_ctx
, $2, $4.val
, $6.val
, $8.val
, $10.val
);
720 | INSTR_DEFI REG_CONSTINT
',' IMMVAL
',' IMMVAL
',' IMMVAL
',' IMMVAL
722 asm_ctx.funcs
->constI
(&asm_ctx
, $2, $4.val
, $6.val
, $8.val
, $10.val
);
724 | INSTR_DEFB REG_CONSTBOOL
',' IMMBOOL
726 asm_ctx.funcs
->constB
(&asm_ctx
, $2, $4);
731 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_REP
, 0, 0, 0, 0, &$2, 1);
736 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_ENDREP
, 0, 0, 0, 0, 0, 0);
741 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_IF
, 0, 0, 0, 0, &$2, 1);
743 | INSTR_IF comp sregs
746 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_IFC
, 0, 0, $2, 0, &$3, 2);
751 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_ELSE
, 0, 0, 0, 0, 0, 0);
756 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_ENDIF
, 0, 0, 0, 0, 0, 0);
761 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_BREAK
, 0, 0, 0, 0, 0, 0);
763 | INSTR_BREAK comp sregs
766 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_BREAKC
, 0, 0, $2, 0, &$3, 2);
771 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_BREAKP
, 0, 0, 0, 0, &$2, 1);
776 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_CALL
, 0, 0, 0, 0, &$2, 1);
781 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_CALLNZ
, 0, 0, 0, 0, &$2, 2);
786 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_LOOP
, 0, 0, 0, 0, &$2, 2);
791 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_RET
, 0, 0, 0, 0, 0, 0);
796 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_ENDLOOP
, 0, 0, 0, 0, 0, 0);
801 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_LABEL
, 0, 0, 0, 0, &$2, 1);
803 | INSTR_SETP comp dreg
',' sregs
806 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_SETP
, 0, 0, $2, &$3, &$5, 2);
808 | INSTR_TEXLDL omods dreg
',' sregs
811 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXLDL
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
813 | INSTR_LIT omods dreg
',' sregs
816 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_LIT
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
818 | INSTR_MOVA omods dreg
',' sregs
821 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_MOVA
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
823 | INSTR_CND omods dreg
',' sregs
826 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_CND
, $2.mod
, $2.shift
, 0, &$3, &$5, 3);
828 | INSTR_CMP omods dreg
',' sregs
831 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_CMP
, $2.mod
, $2.shift
, 0, &$3, &$5, 3);
833 | INSTR_DP2ADD omods dreg
',' sregs
836 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_DP2ADD
, $2.mod
, $2.shift
, 0, &$3, &$5, 3);
838 | INSTR_TEXCOORD omods dreg
841 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXCOORD
, $2.mod
, $2.shift
, 0, &$3, 0, 0);
843 | INSTR_TEXCRD omods dreg
',' sregs
846 /* texcoord and texcrd share the same opcode */
847 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXCOORD
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
852 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXKILL
, 0, 0, 0, &$2, 0, 0);
854 | INSTR_TEX omods dreg
857 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEX
, $2.mod
, $2.shift
, 0, &$3, 0, 0);
859 | INSTR_TEXDEPTH omods dreg
862 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXDEPTH
, $2.mod
, $2.shift
, 0, &$3, 0, 0);
864 | INSTR_TEXLD omods dreg
',' sregs
867 /* There is more than one acceptable syntax for texld:
868 with 1 sreg (PS 1.4) or
869 with 2 sregs (PS 2.0+)
870 Moreover, texld shares the same opcode as the tex instruction,
871 so there are a total of 3 valid syntaxes
872 These variations are handled in asmparser.c */
873 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEX
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
875 | INSTR_TEXLDP omods dreg
',' sregs
878 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXLDP
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
880 | INSTR_TEXLDB omods dreg
',' sregs
883 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXLDB
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
885 | INSTR_TEXBEM omods dreg
',' sregs
888 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXBEM
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
890 | INSTR_TEXBEML omods dreg
',' sregs
893 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXBEML
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
895 | INSTR_TEXREG2AR omods dreg
',' sregs
897 TRACE
("TEXREG2AR\n");
898 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXREG2AR
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
900 | INSTR_TEXREG2GB omods dreg
',' sregs
902 TRACE
("TEXREG2GB\n");
903 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXREG2GB
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
905 | INSTR_TEXREG2RGB omods dreg
',' sregs
907 TRACE
("TEXREG2RGB\n");
908 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXREG2RGB
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
910 | INSTR_TEXM3x2PAD omods dreg
',' sregs
912 TRACE
("TEXM3x2PAD\n");
913 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXM3x2PAD
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
915 | INSTR_TEXM3x3PAD omods dreg
',' sregs
917 TRACE
("INSTR_TEXM3x3PAD\n");
918 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXM3x3PAD
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
920 | INSTR_TEXM3x3SPEC omods dreg
',' sregs
922 TRACE
("TEXM3x3SPEC\n");
923 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXM3x3SPEC
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
925 | INSTR_TEXM3x3VSPEC omods dreg
',' sregs
927 TRACE
("TEXM3x3VSPEC\n");
928 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXM3x3VSPEC
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
930 | INSTR_TEXM3x3TEX omods dreg
',' sregs
932 TRACE
("TEXM3x3TEX\n");
933 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXM3x3TEX
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
935 | INSTR_TEXDP3TEX omods dreg
',' sregs
937 TRACE
("TEXDP3TEX\n");
938 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXDP3TEX
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
940 | INSTR_TEXM3x2DEPTH omods dreg
',' sregs
942 TRACE
("TEXM3x2DEPTH\n");
943 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXM3x2DEPTH
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
945 | INSTR_TEXM3x2TEX omods dreg
',' sregs
947 TRACE
("TEXM3x2TEX\n");
948 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXM3x2TEX
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
950 | INSTR_TEXDP3 omods dreg
',' sregs
953 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXDP3
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
955 | INSTR_TEXM3x3 omods dreg
',' sregs
958 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXM3x3
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
960 | INSTR_BEM omods dreg
',' sregs
963 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_BEM
, $2.mod
, $2.shift
, 0, &$3, &$5, 2);
965 | INSTR_DSX omods dreg
',' sregs
968 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_DSX
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
970 | INSTR_DSY omods dreg
',' sregs
973 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_DSY
, $2.mod
, $2.shift
, 0, &$3, &$5, 1);
975 | INSTR_TEXLDD omods dreg
',' sregs
978 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_TEXLDD
, $2.mod
, $2.shift
, 0, &$3, &$5, 4);
983 asm_ctx.funcs
->instr
(&asm_ctx
, BWRITERSIO_PHASE
, 0, 0, 0, 0, 0, 0);
987 dreg: dreg_name rel_reg
989 $$.regnum
= $1.regnum
;
991 $$.u.writemask
= BWRITERSP_WRITEMASK_ALL
;
992 $$.srcmod
= BWRITERSPSM_NONE
;
993 set_rel_reg
(&$$
, &$2);
995 | dreg_name writemask
997 $$.regnum
= $1.regnum
;
1000 $$.srcmod
= BWRITERSPSM_NONE
;
1006 $$.regnum
= $1; $$.type
= BWRITERSPR_TEMP
;
1010 $$.regnum
= $1; $$.type
= BWRITERSPR_OUTPUT
;
1014 $$.regnum
= $1; $$.type
= BWRITERSPR_INPUT
;
1018 asmparser_message
(&asm_ctx
, "Line %u: Register c%u is not a valid destination register\n",
1019 asm_ctx.line_no
, $1);
1020 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
1024 asmparser_message
(&asm_ctx
, "Line %u: Register i%u is not a valid destination register\n",
1025 asm_ctx.line_no
, $1);
1026 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
1030 asmparser_message
(&asm_ctx
, "Line %u: Register b%u is not a valid destination register\n",
1031 asm_ctx.line_no
, $1);
1032 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
1036 $$.regnum
= $1; $$.type
= BWRITERSPR_TEXTURE
;
1040 $$.regnum
= $1; $$.type
= BWRITERSPR_TEXCRDOUT
;
1044 asmparser_message
(&asm_ctx
, "Line %u: Register s%u is not a valid destination register\n",
1045 asm_ctx.line_no
, $1);
1046 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
1050 $$.regnum
= BWRITERSRO_POSITION
; $$.type
= BWRITERSPR_RASTOUT
;
1054 $$.regnum
= BWRITERSRO_POINT_SIZE
; $$.type
= BWRITERSPR_RASTOUT
;
1058 $$.regnum
= BWRITERSRO_FOG
; $$.type
= BWRITERSPR_RASTOUT
;
1062 $$.regnum
= $1; $$.type
= BWRITERSPR_ATTROUT
;
1066 $$.regnum
= $1; $$.type
= BWRITERSPR_COLOROUT
;
1070 $$.regnum
= 0; $$.type
= BWRITERSPR_DEPTHOUT
;
1074 $$.regnum
= 0; $$.type
= BWRITERSPR_PREDICATE
;
1078 asmparser_message
(&asm_ctx
, "Line %u: Register vPos is not a valid destination register\n",
1080 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
1084 asmparser_message
(&asm_ctx
, "Line %u: Register vFace is not a valid destination register\n",
1086 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
1090 /* index 0 is hardcoded for the addr register */
1091 $$.regnum
= 0; $$.type
= BWRITERSPR_ADDR
;
1095 asmparser_message
(&asm_ctx
, "Line %u: Register aL is not a valid destination register\n",
1097 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
1100 writemask: '.' wm_components
1102 if
($2.writemask
== SWIZZLE_ERR
) {
1103 asmparser_message
(&asm_ctx
, "Line %u: Invalid writemask specified\n",
1105 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
1106 /* Provide a correct writemask to prevent following complaints */
1107 $$
= BWRITERSP_WRITEMASK_ALL
;
1111 TRACE
("Writemask: %x\n", $$
);
1115 wm_components: COMPONENT
1117 $$.writemask
= 1 << $1;
1121 | wm_components COMPONENT
1123 if
($1.writemask
== SWIZZLE_ERR ||
$1.idx
== 4)
1124 /* Wrong writemask */
1125 $$.writemask
= SWIZZLE_ERR
;
1128 $$.writemask
= SWIZZLE_ERR
;
1130 $$.writemask
= $1.writemask |
(1 << $2);
1131 $$.idx
= $1.idx
+ 1;
1136 swizzle: /* empty */
1138 $$
= BWRITERVS_NOSWIZZLE
;
1139 TRACE
("Default swizzle: %08x\n", $$
);
1143 if
($2.swizzle
== SWIZZLE_ERR
) {
1144 asmparser_message
(&asm_ctx
, "Line %u: Invalid swizzle\n",
1146 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
1147 /* Provide a correct swizzle to prevent following complaints */
1148 $$
= BWRITERVS_NOSWIZZLE
;
1153 $$
= $2.swizzle
<< BWRITERVS_SWIZZLE_SHIFT
;
1154 /* Fill the swizzle by extending the last component */
1155 last
= ($2.swizzle
>> 2 * ($2.idx
- 1)) & 0x03;
1156 for
(i
= $2.idx
; i
< 4; i
++){
1157 $$ |
= last
<< (BWRITERVS_SWIZZLE_SHIFT
+ 2 * i
);
1159 TRACE
("Got a swizzle: %08x\n", $$
);
1163 sw_components: COMPONENT
1168 | sw_components COMPONENT
1171 /* Too many sw_components */
1172 $$.swizzle
= SWIZZLE_ERR
;
1176 $$.swizzle
= $1.swizzle |
($2 << 2 * $1.idx
);
1177 $$.idx
= $1.idx
+ 1;
1188 $$.mod
= $1.mod |
$2.mod
;
1189 if
($1.shift
&& $2.shift
) {
1190 asmparser_message
(&asm_ctx
, "Line %u: More than one shift flag\n",
1192 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
1193 $$.shift
= $1.shift
;
1195 $$.shift
= $1.shift |
$2.shift
;
1231 $$.mod
= BWRITERSPDM_SATURATE
;
1236 $$.mod
= BWRITERSPDM_PARTIALPRECISION
;
1241 $$.mod
= BWRITERSPDM_MSAMPCENTROID
;
1252 if
($$.count
== MAX_SRC_REGS
){
1253 asmparser_message
(&asm_ctx
, "Line %u: Too many source registers in this instruction\n",
1255 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
1258 $$.reg
[$$.count
++] = $3;
1261 sreg: sreg_name rel_reg swizzle
1264 $$.regnum
= $1.regnum
;
1266 $$.srcmod
= BWRITERSPSM_NONE
;
1267 set_rel_reg
(&$$
, &$2);
1269 | sreg_name rel_reg smod swizzle
1272 $$.regnum
= $1.regnum
;
1273 set_rel_reg
(&$$
, &$2);
1277 |
'-' sreg_name rel_reg swizzle
1280 $$.regnum
= $2.regnum
;
1281 $$.srcmod
= BWRITERSPSM_NEG
;
1282 set_rel_reg
(&$$
, &$3);
1285 |
'-' sreg_name rel_reg smod swizzle
1288 $$.regnum
= $2.regnum
;
1289 set_rel_reg
(&$$
, &$3);
1291 case BWRITERSPSM_BIAS
: $$.srcmod
= BWRITERSPSM_BIASNEG
; break
;
1292 case BWRITERSPSM_X2
: $$.srcmod
= BWRITERSPSM_X2NEG
; break
;
1293 case BWRITERSPSM_SIGN
: $$.srcmod
= BWRITERSPSM_SIGNNEG
; break
;
1294 case BWRITERSPSM_ABS
: $$.srcmod
= BWRITERSPSM_ABSNEG
; break
;
1295 case BWRITERSPSM_DZ
:
1296 asmparser_message
(&asm_ctx
, "Line %u: Incompatible source modifiers: NEG and DZ\n",
1298 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
1300 case BWRITERSPSM_DW
:
1301 asmparser_message
(&asm_ctx
, "Line %u: Incompatible source modifiers: NEG and DW\n",
1303 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
1306 FIXME
("Unhandled combination of NEGATE and %u\n", $4);
1310 | IMMVAL
'-' sreg_name rel_reg swizzle
1312 if
($1.val
!= 1.0 ||
(!$1.integer
)) {
1313 asmparser_message
(&asm_ctx
, "Line %u: Only \"1 - reg\" is valid for D3DSPSM_COMP, "
1314 "%g - reg found\n", asm_ctx.line_no
, $1.val
);
1315 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
1317 /* Complement - not compatible with other source modifiers */
1319 $$.regnum
= $3.regnum
;
1320 $$.srcmod
= BWRITERSPSM_COMP
;
1321 set_rel_reg
(&$$
, &$4);
1324 | IMMVAL
'-' sreg_name rel_reg smod swizzle
1326 /* For nicer error reporting */
1327 if
($1.val
!= 1.0 ||
(!$1.integer
)) {
1328 asmparser_message
(&asm_ctx
, "Line %u: Only \"1 - reg\" is valid for D3DSPSM_COMP\n",
1330 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
1332 asmparser_message
(&asm_ctx
, "Line %u: Incompatible source modifiers: D3DSPSM_COMP and %s\n",
1334 debug_print_srcmod
($5));
1335 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
1338 | SMOD_NOT sreg_name swizzle
1341 $$.regnum
= $2.regnum
;
1343 $$.srcmod
= BWRITERSPSM_NOT
;
1347 rel_reg: /* empty */
1349 $$.has_rel_reg
= FALSE
;
1350 $$.additional_offset
= 0;
1354 $$.has_rel_reg
= FALSE
;
1355 $$.additional_offset
= $2.val
;
1357 |
'[' relreg_name swizzle
']'
1359 $$.has_rel_reg
= TRUE
;
1361 $$.additional_offset
= 0;
1362 $$.rel_regnum
= $2.regnum
;
1365 |
'[' immsum
'+' relreg_name swizzle
']'
1367 $$.has_rel_reg
= TRUE
;
1369 $$.additional_offset
= $2.val
;
1370 $$.rel_regnum
= $4.regnum
;
1373 |
'[' relreg_name swizzle
'+' immsum
']'
1375 $$.has_rel_reg
= TRUE
;
1377 $$.additional_offset
= $5.val
;
1378 $$.rel_regnum
= $2.regnum
;
1381 |
'[' immsum
'+' relreg_name swizzle
'+' immsum
']'
1383 $$.has_rel_reg
= TRUE
;
1385 $$.additional_offset
= $2.val
+ $7.val
;
1386 $$.rel_regnum
= $4.regnum
;
1393 asmparser_message
(&asm_ctx
, "Line %u: Unexpected float %f\n",
1394 asm_ctx.line_no
, $1.val
);
1395 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
1402 asmparser_message
(&asm_ctx
, "Line %u: Unexpected float %f\n",
1403 asm_ctx.line_no
, $3.val
);
1404 set_parse_status
(&asm_ctx.status
, PARSE_ERR
);
1406 $$.val
= $1.val
+ $3.val
;
1411 $$
= BWRITERSPSM_BIAS
;
1415 $$
= BWRITERSPSM_X2
;
1419 $$
= BWRITERSPSM_SIGN
;
1423 $$
= BWRITERSPSM_DZ
;
1427 $$
= BWRITERSPSM_DW
;
1431 $$
= BWRITERSPSM_ABS
;
1434 relreg_name: REG_ADDRESS
1436 $$.regnum
= 0; $$.type
= BWRITERSPR_ADDR
;
1440 $$.regnum
= 0; $$.type
= BWRITERSPR_LOOP
;
1445 $$.regnum
= $1; $$.type
= BWRITERSPR_TEMP
;
1449 asmparser_message
(&asm_ctx
, "Line %u: Register o%u is not a valid source register\n",
1450 asm_ctx.line_no
, $1);
1451 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
1455 $$.regnum
= $1; $$.type
= BWRITERSPR_INPUT
;
1459 $$.regnum
= $1; $$.type
= BWRITERSPR_CONST
;
1463 $$.regnum
= $1; $$.type
= BWRITERSPR_CONSTINT
;
1467 $$.regnum
= $1; $$.type
= BWRITERSPR_CONSTBOOL
;
1471 $$.regnum
= $1; $$.type
= BWRITERSPR_TEXTURE
;
1475 asmparser_message
(&asm_ctx
, "Line %u: Register oT%u is not a valid source register\n",
1476 asm_ctx.line_no
, $1);
1477 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
1481 $$.regnum
= $1; $$.type
= BWRITERSPR_SAMPLER
;
1485 asmparser_message
(&asm_ctx
, "Line %u: Register oPos is not a valid source register\n",
1487 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
1491 asmparser_message
(&asm_ctx
, "Line %u: Register oFog is not a valid source register\n",
1493 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
1497 asmparser_message
(&asm_ctx
, "Line %u: Register oD%u is not a valid source register\n",
1498 asm_ctx.line_no
, $1);
1499 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
1503 asmparser_message
(&asm_ctx
, "Line %u: Register oC%u is not a valid source register\n",
1504 asm_ctx.line_no
, $1);
1505 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
1509 asmparser_message
(&asm_ctx
, "Line %u: Register oDepth is not a valid source register\n",
1511 set_parse_status
(&asm_ctx.status
, PARSE_WARN
);
1515 $$.regnum
= 0; $$.type
= BWRITERSPR_PREDICATE
;
1519 $$.regnum
= 0; $$.type
= BWRITERSPR_MISCTYPE
;
1523 $$.regnum
= 1; $$.type
= BWRITERSPR_MISCTYPE
;
1527 $$.regnum
= 0; $$.type
= BWRITERSPR_ADDR
;
1531 $$.regnum
= 0; $$.type
= BWRITERSPR_LOOP
;
1535 $$.regnum
= $1; $$.type
= BWRITERSPR_LABEL
;
1538 comp: COMP_GT
{ $$
= BWRITER_COMPARISON_GT
; }
1539 | COMP_LT
{ $$
= BWRITER_COMPARISON_LT
; }
1540 | COMP_GE
{ $$
= BWRITER_COMPARISON_GE
; }
1541 | COMP_LE
{ $$
= BWRITER_COMPARISON_LE
; }
1542 | COMP_EQ
{ $$
= BWRITER_COMPARISON_EQ
; }
1543 | COMP_NE
{ $$
= BWRITER_COMPARISON_NE
; }
1545 dclusage: USAGE_POSITION
1547 TRACE
("dcl_position%u\n", $1);
1549 $$.dclusage
= BWRITERDECLUSAGE_POSITION
;
1553 TRACE
("dcl_blendweight%u\n", $1);
1555 $$.dclusage
= BWRITERDECLUSAGE_BLENDWEIGHT
;
1557 | USAGE_BLENDINDICES
1559 TRACE
("dcl_blendindices%u\n", $1);
1561 $$.dclusage
= BWRITERDECLUSAGE_BLENDINDICES
;
1565 TRACE
("dcl_normal%u\n", $1);
1567 $$.dclusage
= BWRITERDECLUSAGE_NORMAL
;
1571 TRACE
("dcl_psize%u\n", $1);
1573 $$.dclusage
= BWRITERDECLUSAGE_PSIZE
;
1577 TRACE
("dcl_texcoord%u\n", $1);
1579 $$.dclusage
= BWRITERDECLUSAGE_TEXCOORD
;
1583 TRACE
("dcl_tangent%u\n", $1);
1585 $$.dclusage
= BWRITERDECLUSAGE_TANGENT
;
1589 TRACE
("dcl_binormal%u\n", $1);
1591 $$.dclusage
= BWRITERDECLUSAGE_BINORMAL
;
1595 TRACE
("dcl_tessfactor%u\n", $1);
1597 $$.dclusage
= BWRITERDECLUSAGE_TESSFACTOR
;
1601 TRACE
("dcl_positiont%u\n", $1);
1603 $$.dclusage
= BWRITERDECLUSAGE_POSITIONT
;
1607 TRACE
("dcl_color%u\n", $1);
1609 $$.dclusage
= BWRITERDECLUSAGE_COLOR
;
1613 TRACE
("dcl_fog%u\n", $1);
1615 $$.dclusage
= BWRITERDECLUSAGE_FOG
;
1619 TRACE
("dcl_depth%u\n", $1);
1621 $$.dclusage
= BWRITERDECLUSAGE_DEPTH
;
1625 TRACE
("dcl_sample%u\n", $1);
1627 $$.dclusage
= BWRITERDECLUSAGE_SAMPLE
;
1630 dcl_inputreg: REG_INPUT
1632 $$.regnum
= $1; $$.type
= BWRITERSPR_INPUT
;
1636 $$.regnum
= $1; $$.type
= BWRITERSPR_TEXTURE
;
1639 sampdcl: SAMPTYPE_1D
1649 $$
= BWRITERSTT_CUBE
;
1653 $$
= BWRITERSTT_VOLUME
;
1656 predicate: '(' REG_PREDICATE swizzle
')'
1658 $$.type
= BWRITERSPR_PREDICATE
;
1661 $$.srcmod
= BWRITERSPSM_NONE
;
1664 |
'(' SMOD_NOT REG_PREDICATE swizzle
')'
1666 $$.type
= BWRITERSPR_PREDICATE
;
1669 $$.srcmod
= BWRITERSPSM_NOT
;
1675 struct bwriter_shader
*parse_asm_shader
(char **messages
)
1677 struct bwriter_shader
*ret
= NULL
;
1679 asm_ctx.shader
= NULL
;
1680 asm_ctx.status
= PARSE_SUCCESS
;
1681 asm_ctx.messages.size
= asm_ctx.messages.capacity
= 0;
1682 asm_ctx.line_no
= 1;
1686 if
(asm_ctx.status
!= PARSE_ERR
)
1687 ret
= asm_ctx.shader
;
1688 else if
(asm_ctx.shader
)
1689 SlDeleteShader
(asm_ctx.shader
);
1693 if
(asm_ctx.messages.size
)
1695 /* Shrink the buffer to the used size */
1696 *messages
= d3dcompiler_realloc
(asm_ctx.messages.
string, asm_ctx.messages.size
+ 1);
1699 ERR
("Out of memory, no messages reported\n");
1700 d3dcompiler_free
(asm_ctx.messages.
string);
1710 if
(asm_ctx.messages.capacity
)
1711 d3dcompiler_free
(asm_ctx.messages.
string);