Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/d3dcompiler_private.h | 4 ++-- dlls/d3dcompiler_43/hlsl.y | 8 ++++---- dlls/d3dcompiler_43/utils.c | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h index 830434c9ff1..957fc24e201 100644 --- a/dlls/d3dcompiler_43/d3dcompiler_private.h +++ b/dlls/d3dcompiler_43/d3dcompiler_private.h @@ -734,8 +734,8 @@ struct hlsl_ir_node #define HLSL_MODIFIER_CONST 0x00000100 #define HLSL_MODIFIER_ROW_MAJOR 0x00000200 #define HLSL_MODIFIER_COLUMN_MAJOR 0x00000400 -#define HLSL_MODIFIER_IN 0x00000800 -#define HLSL_MODIFIER_OUT 0x00001000 +#define HLSL_STORAGE_IN 0x00000800 +#define HLSL_STORAGE_OUT 0x00001000
#define HLSL_TYPE_MODIFIERS_MASK (HLSL_MODIFIER_PRECISE | HLSL_STORAGE_VOLATILE | \ HLSL_MODIFIER_CONST | HLSL_MODIFIER_ROW_MAJOR | \ diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index 6a5dddf5d40..fca4ebc5296 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -1489,7 +1489,7 @@ parameter: input_mods var_modifiers type any_identifier colon_att if (!(type = apply_type_modifiers($3, &modifiers, get_location(&@2)))) YYABORT;
- $$.modifiers = $1 ? $1 : HLSL_MODIFIER_IN; + $$.modifiers = $1 ? $1 : HLSL_STORAGE_IN; $$.modifiers |= modifiers; $$.type = type; $$.name = $4; @@ -1514,15 +1514,15 @@ input_mods: /* Empty */
input_mod: KW_IN { - $$ = HLSL_MODIFIER_IN; + $$ = HLSL_STORAGE_IN; } | KW_OUT { - $$ = HLSL_MODIFIER_OUT; + $$ = HLSL_STORAGE_OUT; } | KW_INOUT { - $$ = HLSL_MODIFIER_IN | HLSL_MODIFIER_OUT; + $$ = HLSL_STORAGE_IN | HLSL_STORAGE_OUT; }
type: base_type diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c index 29b35c3d7eb..3e8e229c8c1 100644 --- a/dlls/d3dcompiler_43/utils.c +++ b/dlls/d3dcompiler_43/utils.c @@ -1808,11 +1808,11 @@ const char *debug_modifiers(DWORD modifiers) strcat(string, " row_major"); /* 10 */ if (modifiers & HLSL_MODIFIER_COLUMN_MAJOR) strcat(string, " column_major"); /* 13 */ - if ((modifiers & (HLSL_MODIFIER_IN | HLSL_MODIFIER_OUT)) == (HLSL_MODIFIER_IN | HLSL_MODIFIER_OUT)) + if ((modifiers & (HLSL_STORAGE_IN | HLSL_STORAGE_OUT)) == (HLSL_STORAGE_IN | HLSL_STORAGE_OUT)) strcat(string, " inout"); /* 6 */ - else if (modifiers & HLSL_MODIFIER_IN) + else if (modifiers & HLSL_STORAGE_IN) strcat(string, " in"); /* 3 */ - else if (modifiers & HLSL_MODIFIER_OUT) + else if (modifiers & HLSL_STORAGE_OUT) strcat(string, " out"); /* 4 */
return wine_dbg_sprintf("%s", string[0] ? string + 1 : "");
So that storage classes will be stored in the relevant hlsl_ir_var instead of in the type.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/hlsl.y | 62 ++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 30 deletions(-)
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index fca4ebc5296..556c03b11fe 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -771,7 +771,7 @@ static struct list *gen_struct_fields(struct hlsl_type *type, DWORD modifiers, s return list; }
-static struct hlsl_type *new_struct_type(const char *name, DWORD modifiers, struct list *fields) +static struct hlsl_type *new_struct_type(const char *name, struct list *fields) { struct hlsl_type *type = d3dcompiler_alloc(sizeof(*type));
@@ -783,7 +783,6 @@ static struct hlsl_type *new_struct_type(const char *name, DWORD modifiers, stru type->type = HLSL_CLASS_STRUCT; type->name = name; type->dimx = type->dimy = 1; - type->modifiers = modifiers; type->e.elements = fields;
list_add_tail(&hlsl_ctx.types, &type->entry); @@ -1127,6 +1126,8 @@ static unsigned int evaluate_array_dimension(struct hlsl_ir_node *node) %type <type> struct_spec %type <type> named_struct_spec %type <type> unnamed_struct_spec +%type <type> field_type +%type <type> typedef_type %type <list> type_specs %type <variable_def> type_spec %type <initializer> complex_initializer @@ -1248,56 +1249,60 @@ preproc_directive: PRE_LINE STRING } }
-struct_declaration: struct_spec variables_def_optional ';' +struct_declaration: var_modifiers struct_spec variables_def_optional ';' { - if (!$2) + struct hlsl_type *type; + DWORD modifiers = $1; + + if (!$3) { - if (!$1->name) + if (!$2->name) { hlsl_report_message(get_location(&@1), HLSL_LEVEL_ERROR, "anonymous struct declaration with no variables"); } - if ($1->modifiers) + if (modifiers) { hlsl_report_message(get_location(&@1), HLSL_LEVEL_ERROR, "modifier not allowed on struct type declaration"); } } - $$ = declare_vars($1, 0, $2); + + if (!(type = apply_type_modifiers($2, &modifiers, get_location(&@1)))) + YYABORT; + $$ = declare_vars(type, modifiers, $3); }
struct_spec: named_struct_spec | unnamed_struct_spec
-named_struct_spec: var_modifiers KW_STRUCT any_identifier '{' fields_list '}' +named_struct_spec: KW_STRUCT any_identifier '{' fields_list '}' { BOOL ret;
- TRACE("Structure %s declaration.\n", debugstr_a($3)); - check_invalid_matrix_modifiers($1, get_location(&@1)); - $$ = new_struct_type($3, $1, $5); + TRACE("Structure %s declaration.\n", debugstr_a($2)); + $$ = new_struct_type($2, $4);
- if (get_variable(hlsl_ctx.cur_scope, $3)) + if (get_variable(hlsl_ctx.cur_scope, $2)) { - hlsl_report_message(get_location(&@3), - HLSL_LEVEL_ERROR, "redefinition of '%s'", $3); + hlsl_report_message(get_location(&@2), + HLSL_LEVEL_ERROR, "redefinition of '%s'", $2); YYABORT; }
ret = add_type_to_scope(hlsl_ctx.cur_scope, $$); if (!ret) { - hlsl_report_message(get_location(&@3), - HLSL_LEVEL_ERROR, "redefinition of struct '%s'", $3); + hlsl_report_message(get_location(&@2), + HLSL_LEVEL_ERROR, "redefinition of struct '%s'", $2); YYABORT; } }
-unnamed_struct_spec: var_modifiers KW_STRUCT '{' fields_list '}' +unnamed_struct_spec: KW_STRUCT '{' fields_list '}' { TRACE("Anonymous structure declaration.\n"); - check_invalid_matrix_modifiers($1, get_location(&@1)); - $$ = new_struct_type(NULL, $1, $4); + $$ = new_struct_type(NULL, $3); }
any_identifier: VAR_IDENTIFIER @@ -1328,7 +1333,10 @@ fields_list: /* Empty */ d3dcompiler_free($2); }
-field: var_modifiers type variables_def ';' +field_type: type + | unnamed_struct_spec + +field: var_modifiers field_type variables_def ';' { struct hlsl_type *type; DWORD modifiers = $1; @@ -1337,10 +1345,6 @@ field: var_modifiers type variables_def ';' YYABORT; $$ = gen_struct_fields(type, modifiers, $3); } - | unnamed_struct_spec variables_def ';' - { - $$ = gen_struct_fields($1, 0, $2); - }
func_declaration: func_prototype compound_statement { @@ -1636,7 +1640,10 @@ declaration_statement: declaration list_init($$); }
-typedef: KW_TYPEDEF var_modifiers type type_specs ';' +typedef_type: type + | struct_spec + +typedef: KW_TYPEDEF var_modifiers typedef_type type_specs ';' { if ($2 & ~HLSL_TYPE_MODIFIERS_MASK) { @@ -1651,11 +1658,6 @@ typedef: KW_TYPEDEF var_modifiers type type_specs ';' if (!add_typedef($2, $3, $4)) YYABORT; } - | KW_TYPEDEF struct_spec type_specs ';' - { - if (!add_typedef(0, $2, $3)) - YYABORT; - }
type_specs: type_spec {
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
On Sun, Mar 15, 2020 at 10:25 PM Zebediah Figura z.figura12@gmail.com wrote:
So that storage classes will be stored in the relevant hlsl_ir_var instead of in the type.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
dlls/d3dcompiler_43/hlsl.y | 62 ++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 30 deletions(-)
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index fca4ebc5296..556c03b11fe 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -771,7 +771,7 @@ static struct list *gen_struct_fields(struct hlsl_type *type, DWORD modifiers, s return list; }
-static struct hlsl_type *new_struct_type(const char *name, DWORD modifiers, struct list *fields) +static struct hlsl_type *new_struct_type(const char *name, struct list *fields) { struct hlsl_type *type = d3dcompiler_alloc(sizeof(*type));
@@ -783,7 +783,6 @@ static struct hlsl_type *new_struct_type(const char *name, DWORD modifiers, stru type->type = HLSL_CLASS_STRUCT; type->name = name; type->dimx = type->dimy = 1;
type->modifiers = modifiers; type->e.elements = fields;
list_add_tail(&hlsl_ctx.types, &type->entry);
@@ -1127,6 +1126,8 @@ static unsigned int evaluate_array_dimension(struct hlsl_ir_node *node) %type <type> struct_spec %type <type> named_struct_spec %type <type> unnamed_struct_spec +%type <type> field_type +%type <type> typedef_type %type <list> type_specs %type <variable_def> type_spec %type <initializer> complex_initializer @@ -1248,56 +1249,60 @@ preproc_directive: PRE_LINE STRING } }
-struct_declaration: struct_spec variables_def_optional ';' +struct_declaration: var_modifiers struct_spec variables_def_optional ';' {
if (!$2)
struct hlsl_type *type;
DWORD modifiers = $1;
if (!$3) {
if (!$1->name)
if (!$2->name) { hlsl_report_message(get_location(&@1), HLSL_LEVEL_ERROR, "anonymous struct declaration with no variables"); }
Tiny nitpick, probably &@2 is a better location for this message.
On 3/19/20 3:21 PM, Matteo Bruni wrote:
On Sun, Mar 15, 2020 at 10:25 PM Zebediah Figura z.figura12@gmail.com wrote:
So that storage classes will be stored in the relevant hlsl_ir_var instead of in the type.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
dlls/d3dcompiler_43/hlsl.y | 62 ++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 30 deletions(-)
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index fca4ebc5296..556c03b11fe 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -771,7 +771,7 @@ static struct list *gen_struct_fields(struct hlsl_type *type, DWORD modifiers, s return list; }
-static struct hlsl_type *new_struct_type(const char *name, DWORD modifiers, struct list *fields) +static struct hlsl_type *new_struct_type(const char *name, struct list *fields) { struct hlsl_type *type = d3dcompiler_alloc(sizeof(*type));
@@ -783,7 +783,6 @@ static struct hlsl_type *new_struct_type(const char *name, DWORD modifiers, stru type->type = HLSL_CLASS_STRUCT; type->name = name; type->dimx = type->dimy = 1;
type->modifiers = modifiers; type->e.elements = fields;
list_add_tail(&hlsl_ctx.types, &type->entry);
@@ -1127,6 +1126,8 @@ static unsigned int evaluate_array_dimension(struct hlsl_ir_node *node) %type <type> struct_spec %type <type> named_struct_spec %type <type> unnamed_struct_spec +%type <type> field_type +%type <type> typedef_type %type <list> type_specs %type <variable_def> type_spec %type <initializer> complex_initializer @@ -1248,56 +1249,60 @@ preproc_directive: PRE_LINE STRING } }
-struct_declaration: struct_spec variables_def_optional ';' +struct_declaration: var_modifiers struct_spec variables_def_optional ';' {
if (!$2)
struct hlsl_type *type;
DWORD modifiers = $1;
if (!$3) {
if (!$1->name)
if (!$2->name) { hlsl_report_message(get_location(&@1), HLSL_LEVEL_ERROR, "anonymous struct declaration with no variables"); }
Tiny nitpick, probably &@2 is a better location for this message.
Yes, you're right; it looks like I missed replacing that one. I'll send a patch to fix it up.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/d3dcompiler_private.h | 2 +- dlls/d3dcompiler_43/hlsl.y | 5 ++--- dlls/d3dcompiler_43/utils.c | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h index 957fc24e201..1a9d68e7206 100644 --- a/dlls/d3dcompiler_43/d3dcompiler_private.h +++ b/dlls/d3dcompiler_43/d3dcompiler_private.h @@ -741,7 +741,7 @@ struct hlsl_ir_node HLSL_MODIFIER_CONST | HLSL_MODIFIER_ROW_MAJOR | \ HLSL_MODIFIER_COLUMN_MAJOR)
-#define HLSL_MODIFIERS_COMPARISON_MASK (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR) +#define HLSL_MODIFIERS_MAJORITY_MASK (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR)
struct reg_reservation { diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index 556c03b11fe..4f5a7b1782c 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -117,7 +117,7 @@ static void debug_dump_decl(struct hlsl_type *type, DWORD modifiers, const char
static void check_invalid_matrix_modifiers(DWORD modifiers, struct source_location loc) { - if (modifiers & (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR)) + if (modifiers & HLSL_MODIFIERS_MAJORITY_MASK) { hlsl_report_message(loc, HLSL_LEVEL_ERROR, "'row_major' or 'column_major' modifiers are only allowed for matrices"); @@ -175,8 +175,7 @@ static DWORD add_modifiers(DWORD modifiers, DWORD mod, const struct source_locat hlsl_report_message(loc, HLSL_LEVEL_ERROR, "modifier '%s' already specified", debug_modifiers(mod)); return modifiers; } - if (mod & (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR) - && modifiers & (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR)) + if ((mod & HLSL_MODIFIERS_MAJORITY_MASK) && (modifiers & HLSL_MODIFIERS_MAJORITY_MASK)) { hlsl_report_message(loc, HLSL_LEVEL_ERROR, "more than one matrix majority keyword"); return modifiers; diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c index 3e8e229c8c1..921ef7c2c7b 100644 --- a/dlls/d3dcompiler_43/utils.c +++ b/dlls/d3dcompiler_43/utils.c @@ -892,8 +892,8 @@ BOOL compare_hlsl_types(const struct hlsl_type *t1, const struct hlsl_type *t2) return FALSE; if (t1->base_type == HLSL_TYPE_SAMPLER && t1->sampler_dim != t2->sampler_dim) return FALSE; - if ((t1->modifiers & HLSL_MODIFIERS_COMPARISON_MASK) - != (t2->modifiers & HLSL_MODIFIERS_COMPARISON_MASK)) + if ((t1->modifiers & HLSL_MODIFIERS_MAJORITY_MASK) + != (t2->modifiers & HLSL_MODIFIERS_MAJORITY_MASK)) return FALSE; if (t1->dimx != t2->dimx) return FALSE;
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- I have no idea how the previous name came to be...
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/tests/hlsl_d3d9.c | 167 ++++++++++++++++---------- 1 file changed, 106 insertions(+), 61 deletions(-)
diff --git a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c index 3edee34d8de..b96ab166796 100644 --- a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c +++ b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c @@ -294,78 +294,123 @@ static void test_swizzle(void) ID3DXConstantTable *constants; ID3D10Blob *ps_code = NULL; IDirect3DDevice9 *device; + unsigned int i; struct vec4 v; HRESULT hr;
- static const char ps_source[] = - "uniform float4 color;\n" - "float4 main() : COLOR\n" - "{\n" - " float4 ret = color;\n" - " ret.gb = ret.ra;\n" - " ret.ra = float2(0.0101, 0.0404);\n" - " return ret;\n" - "}"; - - static const char ps_multiple_lhs_source[] = - "float4 main() : COLOR\n" - "{\n" - " float4 ret = float4(0.1, 0.2, 0.3, 0.4);\n" - " ret.wyz.yx = float2(0.5, 0.6).yx;\n" - " return ret;\n" - "}"; - - static const char ps_multiple_rhs_source[] = - "float4 main() : COLOR\n" - "{\n" - " float4 ret = float4(0.1, 0.2, 0.3, 0.4).ywxz.zyyz;\n" - " return ret;\n" - "}"; - - if (!init_test_context(&test_context)) - return; - device = test_context.device; - - todo_wine ps_code = compile_shader(ps_source, "ps_2_0"); - if (ps_code) + static const struct { - hr = pD3DXGetShaderConstantTable(ID3D10Blob_GetBufferPointer(ps_code), &constants); - ok(hr == D3D_OK, "Failed to get constant table, hr %#x.\n", hr); - hr = ID3DXConstantTable_SetVector(constants, device, "color", &color); - ok(hr == D3D_OK, "Failed to set constant, hr %#x.\n", hr); - ID3DXConstantTable_Release(constants); - - draw_quad(device, ps_code); - - v = get_color_vec4(device, 0, 0); - ok(compare_vec4(&v, 0.0101f, 0.0303f, 0.0202f, 0.0404f, 0), - "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v.x, v.y, v.z, v.w); - - ID3D10Blob_Release(ps_code); + const char *source; + struct vec4 color; } - - todo_wine ps_code = compile_shader(ps_multiple_lhs_source, "ps_2_0"); - if (ps_code) + tests[] = { - draw_quad(device, ps_code); - - v = get_color_vec4(device, 0, 0); - ok(compare_vec4(&v, 0.1f, 0.6f, 0.3f, 0.5f, 0), - "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v.x, v.y, v.z, v.w); + { + "uniform float4 color;\n" + "float4 main() : COLOR\n" + "{\n" + " float4 ret = color;\n" + " ret.gb = ret.ra;\n" + " ret.ra = float2(0.0101, 0.0404);\n" + " return ret;\n" + "}", + {0.0101f, 0.0303f, 0.0202f, 0.0404f} + }, + { + "float4 main() : COLOR\n" + "{\n" + " float4 ret = float4(0.1, 0.2, 0.3, 0.4);\n" + " ret.wyz.yx = float2(0.5, 0.6).yx;\n" + " return ret;\n" + "}", + {0.1f, 0.6f, 0.3f, 0.5f} + }, + { + "float4 main() : COLOR\n" + "{\n" + " float4 ret;\n" + " ret.zwyx = float4(0.1, 0.2, 0.3, 0.4);\n" + " return ret;\n" + "}", + {0.4f, 0.3f, 0.1f, 0.2f} + }, + { + "float4 main() : COLOR\n" + "{\n" + " float4 ret;\n" + " ret.yw.y = 0.1;\n" + " ret.xzy.yz.y.x = 0.2;\n" + " ret.yzwx.yzwx.wz.y = 0.3;\n" + " ret.zxy.xyz.zxy.xy.y = 0.4;\n" + " return ret;\n" + "}", + {0.3f, 0.2f, 0.4f, 0.1f} + }, + { + "float4 main() : COLOR\n" + "{\n" + " float4 ret;\n" + " ret.yxz.yx = float2(0.1, 0.2);\n" + " ret.w.x = 0.3;\n" + " ret.wzyx.zyx.yx.x = 0.4;\n" + " return ret;\n" + "}", + {0.1f, 0.2f, 0.4f, 0.3f} + }, + { + "float4 main() : COLOR\n" + "{\n" + " float4 ret = float4(0.1, 0.2, 0.3, 0.4).ywxz.zyyz;\n" + " return ret;\n" + "}", + {0.1f, 0.4f, 0.4f, 0.1f} + }, + { + "float4 main() : COLOR\n" + "{\n" + " float4 ret = float4(0.1, 0.2, 0.3, 0.4);\n" + " ret.yxwz = ret;\n" + " ret = ret.wyzx;\n" + " return ret;\n" + "}", + {0.3f, 0.1f, 0.4f, 0.2f} + }, + { + "float4 main() : COLOR\n" + "{\n" + " float4 ret;\n" + " ret.xyzw.xyzw = float4(0.1, 0.2, 0.3, 0.4);\n" + " return ret;\n" + "}", + {0.1f, 0.2f, 0.3f, 0.4f} + }, + };
- ID3D10Blob_Release(ps_code); - } + if (!init_test_context(&test_context)) + return; + device = test_context.device;
- todo_wine ps_code = compile_shader(ps_multiple_rhs_source, "ps_2_0"); - if (ps_code) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { - draw_quad(device, ps_code); + todo_wine ps_code = compile_shader(tests[i].source, "ps_2_0"); + if (ps_code) + { + if (i == 0) + { + hr = pD3DXGetShaderConstantTable(ID3D10Blob_GetBufferPointer(ps_code), &constants); + ok(hr == D3D_OK, "Failed to get constant table, hr %#x.\n", hr); + hr = ID3DXConstantTable_SetVector(constants, device, "color", &color); + ok(hr == D3D_OK, "Failed to set constant, hr %#x.\n", hr); + ID3DXConstantTable_Release(constants); + } + draw_quad(device, ps_code);
- v = get_color_vec4(device, 0, 0); - ok(compare_vec4(&v, 0.1f, 0.4f, 0.4f, 0.1f, 0), - "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v.x, v.y, v.z, v.w); + v = get_color_vec4(device, 0, 0); + ok(compare_vec4(&v, tests[i].color.x, tests[i].color.y, tests[i].color.z, tests[i].color.w, 0), + "Test %u: Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", i, v.x, v.y, v.z, v.w);
- ID3D10Blob_Release(ps_code); + ID3D10Blob_Release(ps_code); + } }
release_test_context(&test_context);
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/utils.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c index 921ef7c2c7b..6e9bb593e00 100644 --- a/dlls/d3dcompiler_43/utils.c +++ b/dlls/d3dcompiler_43/utils.c @@ -1456,6 +1456,29 @@ static unsigned int invert_swizzle(unsigned int *swizzle, unsigned int writemask return new_writemask; }
+static BOOL validate_lhs_deref(const struct hlsl_ir_node *lhs) +{ + struct hlsl_ir_deref *deref; + + if (lhs->type != HLSL_IR_DEREF) + { + hlsl_report_message(lhs->loc, HLSL_LEVEL_ERROR, "invalid lvalue"); + return FALSE; + } + + deref = deref_from_node(lhs); + + if (deref->src.type == HLSL_IR_DEREF_VAR) + return TRUE; + if (deref->src.type == HLSL_IR_DEREF_ARRAY) + return validate_lhs_deref(deref->src.v.array.array); + if (deref->src.type == HLSL_IR_DEREF_RECORD) + return validate_lhs_deref(deref->src.v.record.record); + + assert(0); + return FALSE; +} + struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *lhs, enum parse_assign_op assign_op, struct hlsl_ir_node *rhs) { @@ -1509,6 +1532,12 @@ struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *lhs, enum parse_assign lhs = lhs_inner; }
+ if (!validate_lhs_deref(lhs)) + { + d3dcompiler_free(assign); + return NULL; + } + TRACE("Creating proper assignment expression.\n"); if (writemask == BWRITERSP_WRITEMASK_ALL) type = lhs->data_type;
Signed-off-by: Matteo Bruni mbruni@codeweavers.com