[PATCH 5/5] d3dcompiler: Set the x-dimension for struct types.
Zebediah Figura
z.figura12 at gmail.com
Wed Apr 29 21:54:43 CDT 2020
Signed-off-by: Zebediah Figura <zfigura at 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},
};
--
2.26.2
More information about the wine-devel
mailing list