On 1/10/22 13:33, Francisco Casas wrote:
Signed-off-by: Francisco Casas fcasas@codeweavers.com
libs/vkd3d-shader/hlsl.y | 98 +++++++++++++++------------------------- 1 file changed, 37 insertions(+), 61 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index a89e4432..69ae48a1 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1326,25 +1326,13 @@ static void numeric_var_initializer(struct hlsl_ctx *ctx, struct hlsl_ir_var *va } }
-static void struct_var_initializer(struct hlsl_ctx *ctx, struct list *list, struct hlsl_ir_var *var, +static void struct_var_initializer(struct hlsl_ctx *ctx, struct hlsl_ir_var *var, struct parse_initializer *initializer)
Getting rid of the "list" parameter is fine but should probably be a separate patch. Note that it also makes the "statements_list" variable redundant, so that should probably just be removed entirely.
{ struct hlsl_type *type = var->data_type; struct hlsl_struct_field *field; unsigned int i = 0;
- if (initializer_size(initializer) != hlsl_type_component_count(type))
- {
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
"Expected %u components in initializer, but got %u.",
hlsl_type_component_count(type), initializer_size(initializer));
free_parse_initializer(initializer);
return;
- }
- list_move_tail(list, initializer->instrs);
- vkd3d_free(initializer->instrs);
LIST_FOR_EACH_ENTRY(field, type->e.elements, struct hlsl_struct_field, entry) { struct hlsl_ir_node *node = initializer->args[i];
@@ -1358,19 +1346,41 @@ static void struct_var_initializer(struct hlsl_ctx *ctx, struct list *list, stru { if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset, node->loc))) break;
list_add_tail(list, &c->node.entry);
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(list, &store->node.entry);
list_add_tail(initializer->instrs, &store->node.entry); } else { hlsl_fixme(ctx, &node->loc, "Implicit cast in structure initializer."); } }
+}
- vkd3d_free(initializer->args);
+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)
+{
- if (type->type <= HLSL_CLASS_LAST_NUMERIC)
- {
numeric_var_initializer(ctx, var, v, reg_offset, type, initializer_i, v->initializer.instrs);
- }
- else if (type->type == HLSL_CLASS_STRUCT)
- {
struct_var_initializer(ctx, var, &v->initializer);
- }
- else if (type->type == HLSL_CLASS_ARRAY)
- {
hlsl_fixme(ctx, &v->loc, "Initializers for arrays not supported yet.");
return;
These "return" statements are redundant.
- }
- else if (type->type == HLSL_CLASS_OBJECT)
- {
hlsl_fixme(ctx, &var->loc, "Initializers for objects not supported yet.\n");
return;
- } }