[1/3] d3dx9: Support all the remaining register types in the shader assembler.
Matteo Bruni
matteo.mystral at gmail.com
Wed May 5 14:00:29 CDT 2010
-------------- next part --------------
From a46ea1b198fba3c2e16013f9a489b9c1c07616ba Mon Sep 17 00:00:00 2001
From: Matteo Bruni <matteo.mystral at gmail.com>
Date: Wed, 5 May 2010 16:56:09 +0200
Subject: d3dx9: Support all the remaining register types in the shader assembler.
---
dlls/d3dx9_36/asmshader.l | 70 +++++++++++++
dlls/d3dx9_36/asmshader.y | 198 ++++++++++++++++++++++++++++++++++++++
dlls/d3dx9_36/asmutils.c | 59 +++++++++++
dlls/d3dx9_36/d3dx9_36_private.h | 27 +++++-
4 files changed, 352 insertions(+), 2 deletions(-)
diff --git a/dlls/d3dx9_36/asmshader.l b/dlls/d3dx9_36/asmshader.l
index 65ecfa5..b0a1e9e 100644
--- a/dlls/d3dx9_36/asmshader.l
+++ b/dlls/d3dx9_36/asmshader.l
@@ -44,7 +44,27 @@ COMPONENT [xyzw]|[rgba]
/* Registers */
REG_TEMP r[0-9]+
/* for relative addressing in the form o[x], v[x] and c[x] */
+REG_OUTPUT o[0-9]*
+REG_INPUT v[0-9]*
REG_CONSTFLOAT c[0-9]*
+REG_CONSTINT i[0-9]+
+REG_CONSTBOOL b[0-9]+
+REG_TEXTURE t[0-9]+
+REG_TEXCRDOUT oT[0-9]+
+REG_SAMPLER s[0-9]+
+REG_OPOS oPos
+REG_OFOG oFog
+REG_OPTS oPts
+REG_VERTEXCOLOR oD[01]
+REG_FRAGCOLOR oC[0-9]+
+REG_FRAGDEPTH oDepth
+REG_VPOS vPos
+REG_VFACE vFace
+REG_ADDRESS a0
+REG_LOOP aL
+REG_PREDICATE p0
+/* Not really a register, but it is considered as such */
+REG_LABEL l[0-9]+
PREPROCESSORDIRECTIVE #[^\n]*\n
@@ -71,10 +91,60 @@ mov {return INSTR_MOV; }
asmshader_lval.regnum = atoi(yytext + 1);
return REG_TEMP;
}
+{REG_OUTPUT} {
+ asmshader_lval.regnum = atoi(yytext + 1);
+ return REG_OUTPUT;
+ }
+{REG_INPUT} {
+ asmshader_lval.regnum = atoi(yytext + 1);
+ return REG_INPUT;
+ }
{REG_CONSTFLOAT} {
asmshader_lval.regnum = atoi(yytext + 1);
return REG_CONSTFLOAT;
}
+{REG_CONSTINT} {
+ asmshader_lval.regnum = atoi(yytext + 1);
+ return REG_CONSTINT;
+ }
+{REG_CONSTBOOL} {
+ asmshader_lval.regnum = atoi(yytext + 1);
+ return REG_CONSTBOOL;
+ }
+{REG_TEXTURE} {
+ asmshader_lval.regnum = atoi(yytext + 1);
+ return REG_TEXTURE;
+ }
+{REG_TEXCRDOUT} {
+ asmshader_lval.regnum = atoi(yytext + 2);
+ return REG_TEXCRDOUT;
+ }
+{REG_SAMPLER} {
+ asmshader_lval.regnum = atoi(yytext + 1);
+ return REG_SAMPLER;
+ }
+{REG_OPOS} {return REG_OPOS; }
+{REG_OFOG} {return REG_OFOG; }
+{REG_OPTS} {return REG_OPTS; }
+{REG_VERTEXCOLOR} {
+ asmshader_lval.regnum = atoi(yytext + 2);
+ return REG_VERTEXCOLOR;
+ }
+{REG_FRAGCOLOR} {
+ asmshader_lval.regnum = atoi(yytext + 2);
+ return REG_FRAGCOLOR;
+ }
+{REG_FRAGDEPTH} {return REG_FRAGDEPTH; }
+{REG_VPOS} {return REG_VPOS; }
+{REG_VFACE} {return REG_VFACE; }
+{REG_ADDRESS} {return REG_ADDRESS; }
+{REG_LOOP} {return REG_LOOP; }
+{REG_PREDICATE} {return REG_PREDICATE; }
+
+{REG_LABEL} {
+ asmshader_lval.regnum = atoi(yytext + 1);
+ return REG_LABEL;
+ }
/* Shader versions. These are important to select the correct
* parser profile.
diff --git a/dlls/d3dx9_36/asmshader.y b/dlls/d3dx9_36/asmshader.y
index 2c801fc..3f65fb3 100644
--- a/dlls/d3dx9_36/asmshader.y
+++ b/dlls/d3dx9_36/asmshader.y
@@ -71,7 +71,26 @@ void set_rel_reg(struct shader_reg *reg, struct rel_reg *rel) {
/* Registers */
%token <regnum> REG_TEMP
+%token <regnum> REG_OUTPUT
+%token <regnum> REG_INPUT
%token <regnum> REG_CONSTFLOAT
+%token <regnum> REG_CONSTINT
+%token <regnum> REG_CONSTBOOL
+%token <regnum> REG_TEXTURE
+%token <regnum> REG_SAMPLER
+%token <regnum> REG_TEXCRDOUT
+%token REG_OPOS
+%token REG_OFOG
+%token REG_OPTS
+%token <regnum> REG_VERTEXCOLOR
+%token <regnum> REG_FRAGCOLOR
+%token REG_FRAGDEPTH
+%token REG_VPOS
+%token REG_VFACE
+%token REG_ADDRESS
+%token REG_LOOP
+%token REG_PREDICATE
+%token <regnum> REG_LABEL
/* Version tokens */
%token VER_VS10
@@ -237,6 +256,99 @@ dreg_name: REG_TEMP
{
$$.regnum = $1; $$.type = BWRITERSPR_TEMP;
}
+ | REG_OUTPUT
+ {
+ $$.regnum = $1; $$.type = BWRITERSPR_OUTPUT;
+ }
+ | REG_INPUT
+ {
+ asmparser_message(&asm_ctx, "Line %u: Register v%u is not a valid destination register\n",
+ asm_ctx.line_no, $1);
+ set_parse_status(&asm_ctx, PARSE_WARN);
+ }
+ | REG_CONSTFLOAT
+ {
+ asmparser_message(&asm_ctx, "Line %u: Register c%u is not a valid destination register\n",
+ asm_ctx.line_no, $1);
+ set_parse_status(&asm_ctx, PARSE_WARN);
+ }
+ | REG_CONSTINT
+ {
+ asmparser_message(&asm_ctx, "Line %u: Register i%u is not a valid destination register\n",
+ asm_ctx.line_no, $1);
+ set_parse_status(&asm_ctx, PARSE_WARN);
+ }
+ | REG_CONSTBOOL
+ {
+ asmparser_message(&asm_ctx, "Line %u: Register b%u is not a valid destination register\n",
+ asm_ctx.line_no, $1);
+ set_parse_status(&asm_ctx, PARSE_WARN);
+ }
+ | REG_TEXTURE
+ {
+ $$.regnum = $1; $$.type = BWRITERSPR_TEXTURE;
+ }
+ | REG_TEXCRDOUT
+ {
+ $$.regnum = $1; $$.type = BWRITERSPR_TEXCRDOUT;
+ }
+ | REG_SAMPLER
+ {
+ asmparser_message(&asm_ctx, "Line %u: Register s%u is not a valid destination register\n",
+ asm_ctx.line_no, $1);
+ set_parse_status(&asm_ctx, PARSE_WARN);
+ }
+ | REG_OPOS
+ {
+ $$.regnum = BWRITERSRO_POSITION; $$.type = BWRITERSPR_RASTOUT;
+ }
+ | REG_OPTS
+ {
+ $$.regnum = BWRITERSRO_POINT_SIZE; $$.type = BWRITERSPR_RASTOUT;
+ }
+ | REG_OFOG
+ {
+ $$.regnum = BWRITERSRO_FOG; $$.type = BWRITERSPR_RASTOUT;
+ }
+ | REG_VERTEXCOLOR
+ {
+ $$.regnum = $1; $$.type = BWRITERSPR_ATTROUT;
+ }
+ | REG_FRAGCOLOR
+ {
+ $$.regnum = $1; $$.type = BWRITERSPR_COLOROUT;
+ }
+ | REG_FRAGDEPTH
+ {
+ $$.regnum = 0; $$.type = BWRITERSPR_DEPTHOUT;
+ }
+ | REG_PREDICATE
+ {
+ $$.regnum = 0; $$.type = BWRITERSPR_PREDICATE;
+ }
+ | REG_VPOS
+ {
+ asmparser_message(&asm_ctx, "Line %u: Register vPos is not a valid destination register\n",
+ asm_ctx.line_no);
+ set_parse_status(&asm_ctx, PARSE_WARN);
+ }
+ | REG_VFACE
+ {
+ asmparser_message(&asm_ctx, "Line %u: Register vFace is not a valid destination register\n",
+ asm_ctx.line_no);
+ set_parse_status(&asm_ctx, PARSE_WARN);
+ }
+ | REG_ADDRESS
+ {
+ /* index 0 is hardcoded for the addr register */
+ $$.regnum = 0; $$.type = BWRITERSPR_ADDR;
+ }
+ | REG_LOOP
+ {
+ asmparser_message(&asm_ctx, "Line %u: Register aL is not a valid destination register\n",
+ asm_ctx.line_no);
+ set_parse_status(&asm_ctx, PARSE_WARN);
+ }
writemask: '.' wm_components
{
@@ -421,10 +533,96 @@ sreg_name: REG_TEMP
{
$$.regnum = $1; $$.type = BWRITERSPR_TEMP;
}
+ | REG_OUTPUT
+ {
+ asmparser_message(&asm_ctx, "Line %u: Register o%u is not a valid source register\n",
+ asm_ctx.line_no, $1);
+ set_parse_status(&asm_ctx, PARSE_WARN);
+ }
+ | REG_INPUT
+ {
+ $$.regnum = $1; $$.type = BWRITERSPR_INPUT;
+ }
| REG_CONSTFLOAT
{
$$.regnum = $1; $$.type = BWRITERSPR_CONST;
}
+ | REG_CONSTINT
+ {
+ $$.regnum = $1; $$.type = BWRITERSPR_CONSTINT;
+ }
+ | REG_CONSTBOOL
+ {
+ $$.regnum = $1; $$.type = BWRITERSPR_CONSTBOOL;
+ }
+ | REG_TEXTURE
+ {
+ $$.regnum = $1; $$.type = BWRITERSPR_TEXTURE;
+ }
+ | REG_TEXCRDOUT
+ {
+ asmparser_message(&asm_ctx, "Line %u: Register oT%u is not a valid source register\n",
+ asm_ctx.line_no, $1);
+ set_parse_status(&asm_ctx, PARSE_WARN);
+ }
+ | REG_SAMPLER
+ {
+ $$.regnum = $1; $$.type = BWRITERSPR_SAMPLER;
+ }
+ | REG_OPOS
+ {
+ asmparser_message(&asm_ctx, "Line %u: Register oPos is not a valid source register\n",
+ asm_ctx.line_no);
+ set_parse_status(&asm_ctx, PARSE_WARN);
+ }
+ | REG_OFOG
+ {
+ asmparser_message(&asm_ctx, "Line %u: Register oFog is not a valid source register\n",
+ asm_ctx.line_no);
+ set_parse_status(&asm_ctx, PARSE_WARN);
+ }
+ | REG_VERTEXCOLOR
+ {
+ asmparser_message(&asm_ctx, "Line %u: Register oD%u is not a valid source register\n",
+ asm_ctx.line_no, $1);
+ set_parse_status(&asm_ctx, PARSE_WARN);
+ }
+ | REG_FRAGCOLOR
+ {
+ asmparser_message(&asm_ctx, "Line %u: Register oC%u is not a valid source register\n",
+ asm_ctx.line_no, $1);
+ set_parse_status(&asm_ctx, PARSE_WARN);
+ }
+ | REG_FRAGDEPTH
+ {
+ asmparser_message(&asm_ctx, "Line %u: Register oDepth is not a valid source register\n",
+ asm_ctx.line_no);
+ set_parse_status(&asm_ctx, PARSE_WARN);
+ }
+ | REG_PREDICATE
+ {
+ $$.regnum = 0; $$.type = BWRITERSPR_PREDICATE;
+ }
+ | REG_VPOS
+ {
+ $$.regnum = 0; $$.type = BWRITERSPR_MISCTYPE;
+ }
+ | REG_VFACE
+ {
+ $$.regnum = 1; $$.type = BWRITERSPR_MISCTYPE;
+ }
+ | REG_ADDRESS
+ {
+ $$.regnum = 0; $$.type = BWRITERSPR_ADDR;
+ }
+ | REG_LOOP
+ {
+ $$.regnum = 0; $$.type = BWRITERSPR_LOOP;
+ }
+ | REG_LABEL
+ {
+ $$.regnum = $1; $$.type = BWRITERSPR_LABEL;
+ }
%%
diff --git a/dlls/d3dx9_36/asmutils.c b/dlls/d3dx9_36/asmutils.c
index 6a366a4..87f948b 100644
--- a/dlls/d3dx9_36/asmutils.c
+++ b/dlls/d3dx9_36/asmutils.c
@@ -92,7 +92,23 @@ DWORD d3d9_dstmod(DWORD bwriter_mod) {
DWORD d3d9_register(DWORD bwriter_register) {
if(bwriter_register == BWRITERSPR_TEMP) return D3DSPR_TEMP;
+ if(bwriter_register == BWRITERSPR_INPUT) return D3DSPR_INPUT;
if(bwriter_register == BWRITERSPR_CONST) return D3DSPR_CONST;
+ if(bwriter_register == BWRITERSPR_ADDR) return D3DSPR_ADDR;
+ if(bwriter_register == BWRITERSPR_TEXTURE) return D3DSPR_TEXTURE;
+ if(bwriter_register == BWRITERSPR_RASTOUT) return D3DSPR_RASTOUT;
+ if(bwriter_register == BWRITERSPR_ATTROUT) return D3DSPR_ATTROUT;
+ if(bwriter_register == BWRITERSPR_TEXCRDOUT) return D3DSPR_TEXCRDOUT;
+ if(bwriter_register == BWRITERSPR_OUTPUT) return D3DSPR_OUTPUT;
+ if(bwriter_register == BWRITERSPR_CONSTINT) return D3DSPR_CONSTINT;
+ if(bwriter_register == BWRITERSPR_COLOROUT) return D3DSPR_COLOROUT;
+ if(bwriter_register == BWRITERSPR_DEPTHOUT) return D3DSPR_DEPTHOUT;
+ if(bwriter_register == BWRITERSPR_SAMPLER) return D3DSPR_SAMPLER;
+ if(bwriter_register == BWRITERSPR_CONSTBOOL) return D3DSPR_CONSTBOOL;
+ if(bwriter_register == BWRITERSPR_LOOP) return D3DSPR_LOOP;
+ if(bwriter_register == BWRITERSPR_MISCTYPE) return D3DSPR_MISCTYPE;
+ if(bwriter_register == BWRITERSPR_LABEL) return D3DSPR_LABEL;
+ if(bwriter_register == BWRITERSPR_PREDICATE) return D3DSPR_PREDICATE;
FIXME("Unexpected BWRITERSPR %u\n", bwriter_register);
return -1;
@@ -152,8 +168,51 @@ static const char *get_regname(const struct shader_reg *reg, shader_type st) {
switch(reg->type) {
case BWRITERSPR_TEMP:
return wine_dbg_sprintf("r%u", reg->regnum);
+ case BWRITERSPR_INPUT:
+ return wine_dbg_sprintf("v%u", reg->regnum);
case BWRITERSPR_CONST:
return wine_dbg_sprintf("c%u", reg->regnum);
+ /* case BWRITERSPR_ADDR: */
+ case BWRITERSPR_TEXTURE:
+ if(st == ST_VERTEX) {
+ return wine_dbg_sprintf("a%u", reg->regnum);
+ } else {
+ return wine_dbg_sprintf("t%u", reg->regnum);
+ }
+ case BWRITERSPR_RASTOUT:
+ switch(reg->regnum) {
+ case BWRITERSRO_POSITION: return "oPos";
+ case BWRITERSRO_FOG: return "oFog";
+ case BWRITERSRO_POINT_SIZE: return "oPts";
+ default: return "Unexpected RASTOUT";
+ }
+ case BWRITERSPR_ATTROUT:
+ return wine_dbg_sprintf("oD%u", reg->regnum);
+ /* case BWRITERSPR_TEXCRDOUT: */
+ case BWRITERSPR_OUTPUT:
+ return wine_dbg_sprintf("o[T]%u", reg->regnum);
+ case BWRITERSPR_CONSTINT:
+ return wine_dbg_sprintf("i%u", reg->regnum);
+ case BWRITERSPR_COLOROUT:
+ return wine_dbg_sprintf("oC%u", reg->regnum);
+ case BWRITERSPR_DEPTHOUT:
+ return "oDepth";
+ case BWRITERSPR_SAMPLER:
+ return wine_dbg_sprintf("s%u", reg->regnum);
+ case BWRITERSPR_CONSTBOOL:
+ return wine_dbg_sprintf("b%u", reg->regnum);
+ case BWRITERSPR_LOOP:
+ return "aL";
+ case BWRITERSPR_MISCTYPE:
+ switch(reg->regnum) {
+ case 0: return "vPos";
+ case 1: return "vFace";
+ case 2: return "unexpected misctype";
+ }
+ case BWRITERSPR_LABEL:
+ return wine_dbg_sprintf("l%u", reg->regnum);
+ case BWRITERSPR_PREDICATE:
+ return wine_dbg_sprintf("p%u", reg->regnum);
default: return "unknown regname";
}
}
diff --git a/dlls/d3dx9_36/d3dx9_36_private.h b/dlls/d3dx9_36/d3dx9_36_private.h
index dc8c5ad..ec08e63 100644
--- a/dlls/d3dx9_36/d3dx9_36_private.h
+++ b/dlls/d3dx9_36/d3dx9_36_private.h
@@ -370,10 +370,33 @@ typedef enum _BWRITERSHADER_INSTRUCTION_OPCODE_TYPE {
} BWRITERSHADER_INSTRUCTION_OPCODE_TYPE;
typedef enum _BWRITERSHADER_PARAM_REGISTER_TYPE {
- BWRITERSPR_TEMP = 0,
- BWRITERSPR_CONST = 2,
+ BWRITERSPR_TEMP,
+ BWRITERSPR_INPUT,
+ BWRITERSPR_CONST,
+ BWRITERSPR_ADDR,
+ BWRITERSPR_TEXTURE,
+ BWRITERSPR_RASTOUT,
+ BWRITERSPR_ATTROUT,
+ BWRITERSPR_TEXCRDOUT,
+ BWRITERSPR_OUTPUT,
+ BWRITERSPR_CONSTINT,
+ BWRITERSPR_COLOROUT,
+ BWRITERSPR_DEPTHOUT,
+ BWRITERSPR_SAMPLER,
+ BWRITERSPR_CONSTBOOL,
+ BWRITERSPR_LOOP,
+ BWRITERSPR_MISCTYPE,
+ BWRITERSPR_LABEL,
+ BWRITERSPR_PREDICATE
} BWRITERSHADER_PARAM_REGISTER_TYPE;
+typedef enum _BWRITERVS_RASTOUT_OFFSETS
+{
+ BWRITERSRO_POSITION,
+ BWRITERSRO_FOG,
+ BWRITERSRO_POINT_SIZE
+} BWRITERVS_RASTOUT_OFFSETS;
+
#define BWRITERSP_WRITEMASK_0 0x1 /* .x r */
#define BWRITERSP_WRITEMASK_1 0x2 /* .y g */
#define BWRITERSP_WRITEMASK_2 0x4 /* .z b */
--
1.6.4.4
More information about the wine-patches
mailing list