Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/hlsl.y | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index 1b6e31e4964..5a4e9077d5f 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -214,7 +214,7 @@ static void declare_predefined_types(struct hlsl_scope *scope) { for (x = 1; x <= 4; ++x) { - sprintf(name, "%s%ux%u", names[bt], x, y); + sprintf(name, "%s%ux%u", names[bt], y, x); type = new_hlsl_type(d3dcompiler_strdup(name), HLSL_CLASS_MATRIX, bt, x, y); add_type_to_scope(scope, type);
@@ -425,13 +425,13 @@ static struct hlsl_ir_swizzle *get_swizzle(struct hlsl_ir_node *value, const cha { if (swizzle[i + 1] != 'm') return NULL; - x = swizzle[i + 2] - '0'; - y = swizzle[i + 3] - '0'; + y = swizzle[i + 2] - '0'; + x = swizzle[i + 3] - '0'; } else { - x = swizzle[i + 1] - '1'; - y = swizzle[i + 2] - '1'; + y = swizzle[i + 1] - '1'; + x = swizzle[i + 2] - '1'; }
if (x >= value->data_type->dimx || y >= value->data_type->dimy)
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/hlsl.y | 1 + 1 file changed, 1 insertion(+)
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index 5a4e9077d5f..47889704edc 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -848,6 +848,7 @@ static struct hlsl_type *new_struct_type(const char *name, struct list *fields) return NULL; } type->type = HLSL_CLASS_STRUCT; + type->base_type = HLSL_TYPE_VOID; type->name = name; type->dimx = type->dimy = 1; type->e.elements = fields;
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/hlsl.y | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index 47889704edc..a33ea588ccf 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -820,7 +820,10 @@ static struct list *gen_struct_fields(struct hlsl_type *type, DWORD modifiers, s d3dcompiler_free(v); return list; } - field->type = type; + if (v->array_size) + field->type = new_array_type(type, v->array_size); + else + field->type = type; field->name = v->name; field->modifiers = modifiers; field->semantic = v->semantic;
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/tests/hlsl_d3d9.c | 6 +++--- dlls/d3dcompiler_43/utils.c | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c index 9ebc42147e3..093e6b3010d 100644 --- a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c +++ b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c @@ -894,12 +894,12 @@ static void test_constant_table(void) "#pragma pack_matrix(row_major)\n" " float2x2 d;\n" "} f;\n" - "uniform float g[5];\n" + "uniform float2 g[5];\n" "uniform matrix_t i;\n" "uniform struct matrix_record j;\n" "float4 main(uniform float4 h) : COLOR\n" "{\n" - " return a + b + c._31 + d._31 + f.d._22 + g[e] + h + i._33 + j.a._33;\n" + " return a + b + c._31 + d._31 + f.d._22 + g[e].x + h + i._33 + j.a._33;\n" "}";
D3DXCONSTANTTABLE_DESC table_desc; @@ -920,7 +920,7 @@ static void test_constant_table(void) {"d", D3DXRS_FLOAT4, 0, 3, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 3, 1, 1, 0, 12}, {"e", D3DXRS_FLOAT4, 0, 1, D3DXPC_SCALAR, D3DXPT_INT, 1, 1, 1, 0, 4}, {"f", D3DXRS_FLOAT4, 0, 6, D3DXPC_STRUCT, D3DXPT_VOID, 1, 10, 1, 4, 40}, - {"g", D3DXRS_FLOAT4, 0, 5, D3DXPC_SCALAR, D3DXPT_FLOAT, 1, 1, 5, 0, 20}, + {"g", D3DXRS_FLOAT4, 0, 5, D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 2, 5, 0, 40}, {"i", D3DXRS_FLOAT4, 0, 3, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 3, 3, 1, 0, 36}, {"j", D3DXRS_FLOAT4, 0, 3, D3DXPC_STRUCT, D3DXPT_VOID, 1, 9, 1, 1, 36}, }; diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c index 8537e193db4..c1bd51dcba0 100644 --- a/dlls/d3dcompiler_43/utils.c +++ b/dlls/d3dcompiler_43/utils.c @@ -841,6 +841,8 @@ struct hlsl_type *new_array_type(struct hlsl_type *basic_type, unsigned int arra type->e.array.elements_count = array_size; type->e.array.type = basic_type; type->reg_size = basic_type->reg_size * array_size; + type->dimx = basic_type->dimx; + type->dimy = basic_type->dimy; return type; }
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/hlsl.y | 11 ++++++++++- dlls/d3dcompiler_43/tests/hlsl_d3d9.c | 6 +++--- 2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index a33ea588ccf..9ef0b130d3d 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -839,6 +839,13 @@ static struct list *gen_struct_fields(struct hlsl_type *type, DWORD modifiers, s return list; }
+static DWORD get_array_size(const struct hlsl_type *type) +{ + if (type->type == HLSL_CLASS_ARRAY) + return get_array_size(type->e.array.type) * type->e.array.elements_count; + return 1; +} + static struct hlsl_type *new_struct_type(const char *name, struct list *fields) { struct hlsl_type *type = d3dcompiler_alloc(sizeof(*type)); @@ -853,13 +860,15 @@ static struct hlsl_type *new_struct_type(const char *name, struct list *fields) type->type = HLSL_CLASS_STRUCT; type->base_type = HLSL_TYPE_VOID; type->name = name; - type->dimx = type->dimy = 1; + type->dimx = 0; + type->dimy = 1; type->e.elements = fields;
LIST_FOR_EACH_ENTRY(field, fields, struct hlsl_struct_field, entry) { field->reg_offset = reg_size; reg_size += field->type->reg_size; + type->dimx += field->type->dimx * field->type->dimy * get_array_size(field->type); } type->reg_size = reg_size;
diff --git a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c index 093e6b3010d..c8cf86d05c4 100644 --- a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c +++ b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c @@ -889,7 +889,7 @@ static void test_constant_table(void) "uniform struct\n" "{\n" " float2x2 a;\n" - " float b;\n" + " float b[2];\n" " float c;\n" "#pragma pack_matrix(row_major)\n" " float2x2 d;\n" @@ -919,7 +919,7 @@ static void test_constant_table(void) {"c", D3DXRS_FLOAT4, 0, 1, D3DXPC_MATRIX_COLUMNS, D3DXPT_FLOAT, 3, 1, 1, 0, 12}, {"d", D3DXRS_FLOAT4, 0, 3, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 3, 1, 1, 0, 12}, {"e", D3DXRS_FLOAT4, 0, 1, D3DXPC_SCALAR, D3DXPT_INT, 1, 1, 1, 0, 4}, - {"f", D3DXRS_FLOAT4, 0, 6, D3DXPC_STRUCT, D3DXPT_VOID, 1, 10, 1, 4, 40}, + {"f", D3DXRS_FLOAT4, 0, 7, D3DXPC_STRUCT, D3DXPT_VOID, 1, 11, 1, 4, 44}, {"g", D3DXRS_FLOAT4, 0, 5, D3DXPC_VECTOR, D3DXPT_FLOAT, 1, 2, 5, 0, 40}, {"i", D3DXRS_FLOAT4, 0, 3, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 3, 3, 1, 0, 36}, {"j", D3DXRS_FLOAT4, 0, 3, D3DXPC_STRUCT, D3DXPT_VOID, 1, 9, 1, 1, 36}, @@ -928,7 +928,7 @@ static void test_constant_table(void) static const D3DXCONSTANT_DESC expect_fields_f[] = { {"a", D3DXRS_FLOAT4, 0, 2, D3DXPC_MATRIX_COLUMNS, D3DXPT_FLOAT, 2, 2, 1, 0, 16}, - {"b", D3DXRS_FLOAT4, 0, 1, D3DXPC_SCALAR, D3DXPT_FLOAT, 1, 1, 1, 0, 4}, + {"b", D3DXRS_FLOAT4, 0, 2, D3DXPC_SCALAR, D3DXPT_FLOAT, 1, 1, 2, 0, 8}, {"c", D3DXRS_FLOAT4, 0, 1, D3DXPC_SCALAR, D3DXPT_FLOAT, 1, 1, 1, 0, 4}, {"d", D3DXRS_FLOAT4, 0, 2, D3DXPC_MATRIX_ROWS, D3DXPT_FLOAT, 2, 2, 1, 0, 16}, };
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
On Thu, Apr 30, 2020 at 4:55 AM Zebediah Figura z.figura12@gmail.com wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
dlls/d3dcompiler_43/hlsl.y | 11 ++++++++++- dlls/d3dcompiler_43/tests/hlsl_d3d9.c | 6 +++--- 2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index a33ea588ccf..9ef0b130d3d 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -839,6 +839,13 @@ static struct list *gen_struct_fields(struct hlsl_type *type, DWORD modifiers, s return list; }
+static DWORD get_array_size(const struct hlsl_type *type) +{
- if (type->type == HLSL_CLASS_ARRAY)
return get_array_size(type->e.array.type) * type->e.array.elements_count;
Are arrays of arrays supported in HLSL?
On 4/30/20 8:11 AM, Matteo Bruni wrote:
On Thu, Apr 30, 2020 at 4:55 AM Zebediah Figura z.figura12@gmail.com wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
dlls/d3dcompiler_43/hlsl.y | 11 ++++++++++- dlls/d3dcompiler_43/tests/hlsl_d3d9.c | 6 +++--- 2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index a33ea588ccf..9ef0b130d3d 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -839,6 +839,13 @@ static struct list *gen_struct_fields(struct hlsl_type *type, DWORD modifiers, s return list; }
+static DWORD get_array_size(const struct hlsl_type *type) +{
- if (type->type == HLSL_CLASS_ARRAY)
return get_array_size(type->e.array.type) * type->e.array.elements_count;
Are arrays of arrays supported in HLSL?
Yes, and they get written into the constant table as a single array. That does deserve a test, of course...
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- AKA two wrongs don't make a right...