Module: wine Branch: master Commit: c2b0f200fa576674cad3e443c41d0b977448fcdc URL: http://source.winehq.org/git/wine.git/?a=commit;h=c2b0f200fa576674cad3e443c4...
Author: Matteo Bruni matteo.mystral@gmail.com Date: Sat Jul 17 21:57:38 2010 +0200
d3dx9: Check dcl input instruction syntax against shader version.
---
dlls/d3dx9_36/asmparser.c | 5 ----- dlls/d3dx9_36/asmshader.y | 22 ++++++++++++++++++++++ dlls/d3dx9_36/tests/asm.c | 12 ++++++++++++ 3 files changed, 34 insertions(+), 5 deletions(-)
diff --git a/dlls/d3dx9_36/asmparser.c b/dlls/d3dx9_36/asmparser.c index b04325c..e9d0ea0 100644 --- a/dlls/d3dx9_36/asmparser.c +++ b/dlls/d3dx9_36/asmparser.c @@ -152,11 +152,6 @@ static void asmparser_dcl_input_ps_2(struct asm_parser *This, DWORD usage, DWORD struct instruction instr;
if(!This->shader) return; - if(usage != 0) { - asmparser_message(This, "Line %u: Unsupported usage in dcl instruction\n", This->line_no); - set_parse_status(This, PARSE_ERR); - return; - } instr.dstmod = mod; instr.shift = 0; This->funcs->dstreg(This, &instr, reg); diff --git a/dlls/d3dx9_36/asmshader.y b/dlls/d3dx9_36/asmshader.y index 689a8fd..501354d 100644 --- a/dlls/d3dx9_36/asmshader.y +++ b/dlls/d3dx9_36/asmshader.y @@ -549,6 +549,12 @@ instruction: INSTR_ADD omods dreg ',' sregs asm_ctx.line_no); set_parse_status(&asm_ctx, PARSE_ERR); } + if(asm_ctx.shader->version == BWRITERPS_VERSION(2, 0) || + asm_ctx.shader->version == BWRITERPS_VERSION(2, 1)) { + asmparser_message(&asm_ctx, "Line %u: Declaration not supported in PS 2\n", + asm_ctx.line_no); + set_parse_status(&asm_ctx, PARSE_ERR); + } ZeroMemory(®, sizeof(reg)); reg.type = $4.type; reg.regnum = $4.regnum; @@ -566,6 +572,12 @@ instruction: INSTR_ADD omods dreg ',' sregs asm_ctx.line_no); set_parse_status(&asm_ctx, PARSE_ERR); } + if(asm_ctx.shader->version == BWRITERPS_VERSION(2, 0) || + asm_ctx.shader->version == BWRITERPS_VERSION(2, 1)) { + asmparser_message(&asm_ctx, "Line %u: Declaration not supported in PS 2\n", + asm_ctx.line_no); + set_parse_status(&asm_ctx, PARSE_ERR); + } ZeroMemory(®, sizeof(reg)); reg.type = $4.type; reg.regnum = $4.regnum; @@ -583,6 +595,11 @@ instruction: INSTR_ADD omods dreg ',' sregs asm_ctx.line_no); set_parse_status(&asm_ctx, PARSE_ERR); } + if(asm_ctx.shader->type != ST_PIXEL) { + asmparser_message(&asm_ctx, "Line %u: Declaration needs a semantic\n", + asm_ctx.line_no); + set_parse_status(&asm_ctx, PARSE_ERR); + } ZeroMemory(®, sizeof(reg)); reg.type = $3.type; reg.regnum = $3.regnum; @@ -600,6 +617,11 @@ instruction: INSTR_ADD omods dreg ',' sregs asm_ctx.line_no); set_parse_status(&asm_ctx, PARSE_ERR); } + if(asm_ctx.shader->type != ST_PIXEL) { + asmparser_message(&asm_ctx, "Line %u: Declaration needs a semantic\n", + asm_ctx.line_no); + set_parse_status(&asm_ctx, PARSE_ERR); + } ZeroMemory(®, sizeof(reg)); reg.type = $3.type; reg.regnum = $3.regnum; diff --git a/dlls/d3dx9_36/tests/asm.c b/dlls/d3dx9_36/tests/asm.c index 23ec484..0b8b777 100644 --- a/dlls/d3dx9_36/tests/asm.c +++ b/dlls/d3dx9_36/tests/asm.c @@ -1377,6 +1377,18 @@ static void failure_test(void) { /* shader 47: no samplers in vs_2_0 */ "vs_2_0\n" "dcl_2d s2\n", + /* shader 48: semantic required in vs dcl input instruction */ + "vs_2_0\n" + "dcl v0\n", + /* shader 49: semantic not allowed in ps dcl input instruction*/ + "ps_2_0\n" + "dcl_position0 v0\n", + /* shader 50: dcl instruction not in ps_1_x */ + "ps_1_4\n" + "dcl_position0 v0\n", + /* shader 51: no dcl output instruction in < vs 3.0 */ + "vs_2_0\n" + "dcl_positiont0 o0\n", }; HRESULT hr; unsigned int i;