Commit d9db4beb authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

d3dcompiler: Set the x-dimension for struct types.

parent c6c06013
......@@ -808,6 +808,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));
......@@ -822,13 +829,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;
......
......@@ -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},
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment