This adds support for nested structs and implicit casting of initializer arguments.
Signed-off-by: Francisco Casas fcasas@codeweavers.com --- libs/vkd3d-shader/hlsl.y | 42 ++++++++-------------------------------- 1 file changed, 8 insertions(+), 34 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 69ae48a1..6fb4eb78 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1326,39 +1326,6 @@ static void numeric_var_initializer(struct hlsl_ctx *ctx, struct hlsl_ir_var *va } }
-static void struct_var_initializer(struct hlsl_ctx *ctx, struct hlsl_ir_var *var, - struct parse_initializer *initializer) -{ - struct hlsl_type *type = var->data_type; - struct hlsl_struct_field *field; - unsigned int i = 0; - - LIST_FOR_EACH_ENTRY(field, type->e.elements, struct hlsl_struct_field, entry) - { - struct hlsl_ir_node *node = initializer->args[i]; - struct hlsl_ir_store *store; - struct hlsl_ir_constant *c; - - if (i++ >= initializer->args_count) - break; - - if (hlsl_type_component_count(field->type) == hlsl_type_component_count(node->data_type)) - { - if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset, node->loc))) - break; - list_add_tail(initializer->instrs, &c->node.entry); - - if (!(store = hlsl_new_store(ctx, var, &c->node, node, 0, node->loc))) - break; - list_add_tail(initializer->instrs, &store->node.entry); - } - else - { - hlsl_fixme(ctx, &node->loc, "Implicit cast in structure initializer."); - } - } -} - static void generic_var_initializer(struct hlsl_ctx *ctx, struct hlsl_ir_var *var, struct parse_variable_def *v, unsigned int reg_offset, struct hlsl_type *type, unsigned int *initializer_i, struct list *instrs) @@ -1369,7 +1336,14 @@ static void generic_var_initializer(struct hlsl_ctx *ctx, struct hlsl_ir_var *va } else if (type->type == HLSL_CLASS_STRUCT) { - struct_var_initializer(ctx, var, &v->initializer); + struct hlsl_struct_field *field; + + LIST_FOR_EACH_ENTRY(field, type->e.elements, struct hlsl_struct_field, entry) + { + generic_var_initializer(ctx, var, v, reg_offset + field->reg_offset, field->type, + initializer_i, instrs); + } + return; } else if (type->type == HLSL_CLASS_ARRAY) {