Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3dcompiler_43/asmshader.l | 2 +- dlls/d3dcompiler_43/asmshader.y | 43 ++++++++++++++++++++++++++------- dlls/d3dcompiler_43/tests/asm.c | 25 +++++++++++++------ 3 files changed, 53 insertions(+), 17 deletions(-)
diff --git a/dlls/d3dcompiler_43/asmshader.l b/dlls/d3dcompiler_43/asmshader.l index 63ecddd1899..81718556787 100644 --- a/dlls/d3dcompiler_43/asmshader.l +++ b/dlls/d3dcompiler_43/asmshader.l @@ -96,7 +96,7 @@ NEWLINE (\n)|(\r\n)
COMMA ","
-IMMVAL -?(([0-9]+.?)|([0-9]*.[0-9]+))(f)? +IMMVAL (([0-9]+.?)|([0-9]*.[0-9]+))(f)?
ANY (.)
diff --git a/dlls/d3dcompiler_43/asmshader.y b/dlls/d3dcompiler_43/asmshader.y index 00c98b1dbc3..cdc75c18a3e 100644 --- a/dlls/d3dcompiler_43/asmshader.y +++ b/dlls/d3dcompiler_43/asmshader.y @@ -304,6 +304,8 @@ int asmshader_lex(void); %type <rel_reg> rel_reg %type <reg> predicate %type <immval> immsum +%type <immval> signed_integer +%type <immval> signed_float %type <sregs> sregs
%% @@ -713,11 +715,11 @@ instruction: INSTR_ADD omods dreg ',' sregs asm_ctx.line_no); set_parse_status(&asm_ctx.status, PARSE_WARN); } - | INSTR_DEF REG_CONSTFLOAT ',' IMMVAL ',' IMMVAL ',' IMMVAL ',' IMMVAL + | INSTR_DEF REG_CONSTFLOAT ',' signed_float ',' signed_float ',' signed_float ',' signed_float { asm_ctx.funcs->constF(&asm_ctx, $2, $4.val, $6.val, $8.val, $10.val); } - | INSTR_DEFI REG_CONSTINT ',' IMMVAL ',' IMMVAL ',' IMMVAL ',' IMMVAL + | INSTR_DEFI REG_CONSTINT ',' signed_integer ',' signed_integer ',' signed_integer ',' signed_integer { asm_ctx.funcs->constI(&asm_ctx, $2, $4.val, $6.val, $8.val, $10.val); } @@ -1387,23 +1389,46 @@ rel_reg: /* empty */ $$.swizzle = $5; }
-immsum: IMMVAL +immsum: signed_integer + | immsum '+' signed_integer { - if(!$1.integer) { + $$.val = $1.val + $3.val; + } + | immsum '-' signed_integer + { + $$.val = $1.val - $3.val; + } + +signed_integer: + IMMVAL + { + if (!$1.integer) + { asmparser_message(&asm_ctx, "Line %u: Unexpected float %f\n", - asm_ctx.line_no, $1.val); + asm_ctx.line_no, $1.val); set_parse_status(&asm_ctx.status, PARSE_ERR); } $$.val = $1.val; } - | immsum '+' IMMVAL + | '-' IMMVAL { - if(!$3.integer) { + if (!$2.integer) + { asmparser_message(&asm_ctx, "Line %u: Unexpected float %f\n", - asm_ctx.line_no, $3.val); + asm_ctx.line_no, $2.val); set_parse_status(&asm_ctx.status, PARSE_ERR); } - $$.val = $1.val + $3.val; + $$.val = -$2.val; + } + +signed_float: + IMMVAL + { + $$.val = $1.val; + } + | '-' IMMVAL + { + $$.val = -$2.val; }
smod: SMOD_BIAS diff --git a/dlls/d3dcompiler_43/tests/asm.c b/dlls/d3dcompiler_43/tests/asm.c index 25471b51673..d4826ed0771 100644 --- a/dlls/d3dcompiler_43/tests/asm.c +++ b/dlls/d3dcompiler_43/tests/asm.c @@ -34,7 +34,6 @@ HRESULT WINAPI D3DAssemble(const void *data, SIZE_T datasize, const char *filena struct shader_test { const char *text; const DWORD bytes[128]; - BOOL todo; };
static void dump_shader(DWORD *shader) { @@ -60,7 +59,6 @@ static void exec_tests(const char *name, struct shader_test tests[], unsigned in messages = NULL; hr = D3DAssemble(tests[i].text, strlen(tests[i].text), NULL, NULL, NULL, D3DCOMPILE_SKIP_VALIDATION, &shader, &messages); - todo_wine_if(tests[i].todo) ok(hr == S_OK, "Test %s, shader %u: D3DAssemble failed with error %#lx - %ld.\n", name, i, hr, hr & 0xffff); if(messages) { trace("D3DAssemble messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages)); @@ -214,7 +212,6 @@ static void vs_1_1_test(void) { "def c12, 0, -1, -0.5, 1024\n", {0xfffe0101, 0x00000051, 0xa00f000c, 0x00000000, 0xbf800000, 0xbf000000, 0x44800000, 0x0000ffff}, - TRUE }, { /* shader 14: writemasks, swizzles */ "vs_1_1\n" @@ -758,12 +755,11 @@ static void vs_2_0_test(void) { }, { /* shader 22 */ "vs_2_0\n" - "defi i0, -1, 1, 10, 0\n" + "defi i0, - 1, 1, 10, 0\n" "defi i1, 0, 40, 30, 10\n", {0xfffe0200, 0x05000030, 0xf00f0000, 0xffffffff, 0x00000001, 0x0000000a, 0x00000000, 0x05000030, 0xf00f0001, 0x00000000, 0x00000028, 0x0000001e, 0x0000000a, 0x0000ffff}, - TRUE }, { /* shader 23 */ "vs_2_0\n" @@ -976,7 +972,6 @@ static void ps_2_x_test(void) { {0xffff0201, 0x05000030, 0xf00f0000, 0xffffffff, 0x00000001, 0x0000000a, 0x00000000, 0x05000030, 0xf00f0001, 0x00000000, 0x00000028, 0x0000001e, 0x0000000a, 0x0000ffff}, - TRUE }, { /* shader 2 */ "ps_2_x\n" @@ -1177,7 +1172,12 @@ static void vs_3_0_test(void) { {0xfffe0300, 0x04000002, 0x800f0000, 0x90e42014, 0xf0e40800, 0x80e40002, 0x0000ffff} }, - + { /* shader 15 */ + "vs.3.0\n" + "add r0, v0[aL + 1 + 3], r2\n", + {0xfffe0300, 0x04000002, 0x800f0000, 0x90e42004, 0xf0e40800, 0x80e40002, + 0x0000ffff} + }, };
exec_tests("vs_3_0", tests, ARRAY_SIZE(tests)); @@ -1408,6 +1408,17 @@ static void failure_test(void) { /* shader 43: */ "ps_2_0\n" "texm3x3vspec t3, t0\n", + /* shader 44: expression in defi not allowed */ + "vs_2_0\n" + "defi i0, -1 - 1, 1, 10, 0\n" + "defi i1, 0, 40, 30, 10\n", + /* shader 45: '-' not allowed inside relative addressing operands */ + "vs.3.0\n" + "add r0, v0[aL - 3 + 5], r2\n", + /* shader 46 */ + "vs_2_0\n" + "defi i0, 1.0, 1.1, 10.2, 0.3\n" + "defi i1, 0, 40, 30, 10\n", }; HRESULT hr; unsigned int i;