[4/4] d3dx9: Check dcl input instruction syntax against shader version.
Matteo Bruni
matteo.mystral at gmail.com
Sat Jul 17 15:07:59 CDT 2010
-------------- next part --------------
From a5bf35968757cfd5268fe7fbd850eb217d4ac114 Mon Sep 17 00:00:00 2001
From: Matteo Bruni <matteo.mystral at gmail.com>
Date: Sat, 17 Jul 2010 21:57:38 +0200
Subject: 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;
--
1.7.1
More information about the wine-patches
mailing list