Commit bc3a69f2 authored by Matteo Bruni's avatar Matteo Bruni Committed by Alexandre Julliard

d3dcompiler/asm: Parse negative numbers with a whitespace after the sign.

parent 0c7090a1
...@@ -96,7 +96,7 @@ NEWLINE (\n)|(\r\n) ...@@ -96,7 +96,7 @@ NEWLINE (\n)|(\r\n)
COMMA "," COMMA ","
IMMVAL \-?(([0-9]+\.?)|([0-9]*\.[0-9]+))(f)? IMMVAL (([0-9]+\.?)|([0-9]*\.[0-9]+))(f)?
ANY (.) ANY (.)
......
...@@ -304,6 +304,8 @@ int asmshader_lex(void); ...@@ -304,6 +304,8 @@ int asmshader_lex(void);
%type <rel_reg> rel_reg %type <rel_reg> rel_reg
%type <reg> predicate %type <reg> predicate
%type <immval> immsum %type <immval> immsum
%type <immval> signed_integer
%type <immval> signed_float
%type <sregs> sregs %type <sregs> sregs
%% %%
...@@ -713,11 +715,11 @@ instruction: INSTR_ADD omods dreg ',' sregs ...@@ -713,11 +715,11 @@ instruction: INSTR_ADD omods dreg ',' sregs
asm_ctx.line_no); asm_ctx.line_no);
set_parse_status(&asm_ctx.status, PARSE_WARN); 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); 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); asm_ctx.funcs->constI(&asm_ctx, $2, $4.val, $6.val, $8.val, $10.val);
} }
...@@ -1387,23 +1389,46 @@ rel_reg: /* empty */ ...@@ -1387,23 +1389,46 @@ rel_reg: /* empty */
$$.swizzle = $5; $$.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", 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); set_parse_status(&asm_ctx.status, PARSE_ERR);
} }
$$.val = $1.val; $$.val = $1.val;
} }
| immsum '+' IMMVAL | '-' IMMVAL
{ {
if(!$3.integer) { if (!$2.integer)
{
asmparser_message(&asm_ctx, "Line %u: Unexpected float %f\n", 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); 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 smod: SMOD_BIAS
......
...@@ -34,7 +34,6 @@ HRESULT WINAPI D3DAssemble(const void *data, SIZE_T datasize, const char *filena ...@@ -34,7 +34,6 @@ HRESULT WINAPI D3DAssemble(const void *data, SIZE_T datasize, const char *filena
struct shader_test { struct shader_test {
const char *text; const char *text;
const DWORD bytes[128]; const DWORD bytes[128];
BOOL todo;
}; };
static void dump_shader(DWORD *shader) { static void dump_shader(DWORD *shader) {
...@@ -60,7 +59,6 @@ static void exec_tests(const char *name, struct shader_test tests[], unsigned in ...@@ -60,7 +59,6 @@ static void exec_tests(const char *name, struct shader_test tests[], unsigned in
messages = NULL; messages = NULL;
hr = D3DAssemble(tests[i].text, strlen(tests[i].text), NULL, NULL, hr = D3DAssemble(tests[i].text, strlen(tests[i].text), NULL, NULL,
NULL, D3DCOMPILE_SKIP_VALIDATION, &shader, &messages); 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); ok(hr == S_OK, "Test %s, shader %u: D3DAssemble failed with error %#lx - %ld.\n", name, i, hr, hr & 0xffff);
if(messages) { if(messages) {
trace("D3DAssemble messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages)); trace("D3DAssemble messages:\n%s", (char *)ID3D10Blob_GetBufferPointer(messages));
...@@ -214,7 +212,6 @@ static void vs_1_1_test(void) { ...@@ -214,7 +212,6 @@ static void vs_1_1_test(void) {
"def c12, 0, -1, -0.5, 1024\n", "def c12, 0, -1, -0.5, 1024\n",
{0xfffe0101, 0x00000051, 0xa00f000c, 0x00000000, 0xbf800000, 0xbf000000, {0xfffe0101, 0x00000051, 0xa00f000c, 0x00000000, 0xbf800000, 0xbf000000,
0x44800000, 0x0000ffff}, 0x44800000, 0x0000ffff},
TRUE
}, },
{ /* shader 14: writemasks, swizzles */ { /* shader 14: writemasks, swizzles */
"vs_1_1\n" "vs_1_1\n"
...@@ -758,12 +755,11 @@ static void vs_2_0_test(void) { ...@@ -758,12 +755,11 @@ static void vs_2_0_test(void) {
}, },
{ /* shader 22 */ { /* shader 22 */
"vs_2_0\n" "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", "defi i1, 0, 40, 30, 10\n",
{0xfffe0200, 0x05000030, 0xf00f0000, 0xffffffff, 0x00000001, 0x0000000a, {0xfffe0200, 0x05000030, 0xf00f0000, 0xffffffff, 0x00000001, 0x0000000a,
0x00000000, 0x05000030, 0xf00f0001, 0x00000000, 0x00000028, 0x0000001e, 0x00000000, 0x05000030, 0xf00f0001, 0x00000000, 0x00000028, 0x0000001e,
0x0000000a, 0x0000ffff}, 0x0000000a, 0x0000ffff},
TRUE
}, },
{ /* shader 23 */ { /* shader 23 */
"vs_2_0\n" "vs_2_0\n"
...@@ -976,7 +972,6 @@ static void ps_2_x_test(void) { ...@@ -976,7 +972,6 @@ static void ps_2_x_test(void) {
{0xffff0201, 0x05000030, 0xf00f0000, 0xffffffff, 0x00000001, 0x0000000a, {0xffff0201, 0x05000030, 0xf00f0000, 0xffffffff, 0x00000001, 0x0000000a,
0x00000000, 0x05000030, 0xf00f0001, 0x00000000, 0x00000028, 0x0000001e, 0x00000000, 0x05000030, 0xf00f0001, 0x00000000, 0x00000028, 0x0000001e,
0x0000000a, 0x0000ffff}, 0x0000000a, 0x0000ffff},
TRUE
}, },
{ /* shader 2 */ { /* shader 2 */
"ps_2_x\n" "ps_2_x\n"
...@@ -1177,7 +1172,12 @@ static void vs_3_0_test(void) { ...@@ -1177,7 +1172,12 @@ static void vs_3_0_test(void) {
{0xfffe0300, 0x04000002, 0x800f0000, 0x90e42014, 0xf0e40800, 0x80e40002, {0xfffe0300, 0x04000002, 0x800f0000, 0x90e42014, 0xf0e40800, 0x80e40002,
0x0000ffff} 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)); exec_tests("vs_3_0", tests, ARRAY_SIZE(tests));
...@@ -1408,6 +1408,20 @@ static void failure_test(void) { ...@@ -1408,6 +1408,20 @@ static void failure_test(void) {
/* shader 43: */ /* shader 43: */
"ps_2_0\n" "ps_2_0\n"
"texm3x3vspec t3, t0\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: float constants in defi */
"vs_2_0\n"
"defi i0, 1.0, 1.1, 10.2, 0.3\n"
"defi i1, 0, 40, 30, 10\n",
/* shader 47: double '-' sign */
"vs.3.0\n"
"defi c0, -1, --1, 0, 0\n",
}; };
HRESULT hr; HRESULT hr;
unsigned int i; unsigned int i;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment