Commit 5900f001 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

d3dcompiler: Create assignment instructions more directly in struct_var_initializer().

In particular so that we can remove the need for creating a load instruction, which besides being unnecessary was also never added to any instruction lists. Signed-off-by: 's avatarZebediah Figura <zfigura@codeweavers.com> Signed-off-by: 's avatarMatteo Bruni <mbruni@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 7fc0b9a6
......@@ -549,22 +549,30 @@ static struct hlsl_ir_var *new_synthetic_var(const char *name, struct hlsl_type
return var;
}
static struct hlsl_ir_assignment *make_simple_assignment(struct hlsl_ir_var *lhs, struct hlsl_ir_node *rhs)
static struct hlsl_ir_assignment *new_assignment(struct hlsl_ir_var *var, struct hlsl_ir_node *offset,
struct hlsl_ir_node *rhs, unsigned int writemask, struct source_location loc)
{
struct hlsl_ir_assignment *assign;
if (!writemask && type_is_single_reg(rhs->data_type))
writemask = (1 << rhs->data_type->dimx) - 1;
if (!(assign = d3dcompiler_alloc(sizeof(*assign))))
return NULL;
init_node(&assign->node, HLSL_IR_ASSIGNMENT, rhs->data_type, rhs->loc);
assign->lhs.var = lhs;
init_node(&assign->node, HLSL_IR_ASSIGNMENT, NULL, loc);
assign->lhs.var = var;
assign->lhs.offset = offset;
assign->rhs = rhs;
if (type_is_single_reg(lhs->data_type))
assign->writemask = (1 << lhs->data_type->dimx) - 1;
assign->writemask = writemask;
return assign;
}
static struct hlsl_ir_assignment *make_simple_assignment(struct hlsl_ir_var *lhs, struct hlsl_ir_node *rhs)
{
return new_assignment(lhs, NULL, rhs, 0, rhs->loc);
}
static struct hlsl_ir_constant *new_uint_constant(unsigned int n, const struct source_location loc)
{
struct hlsl_ir_constant *c;
......@@ -693,8 +701,6 @@ static void struct_var_initializer(struct list *list, struct hlsl_ir_var *var,
{
struct hlsl_type *type = var->data_type;
struct hlsl_struct_field *field;
struct hlsl_ir_node *assignment;
struct hlsl_ir_load *load;
unsigned int i = 0;
if (initializer_size(initializer) != components_count_type(type))
......@@ -710,22 +716,21 @@ static void struct_var_initializer(struct list *list, struct hlsl_ir_var *var,
LIST_FOR_EACH_ENTRY(field, type->e.elements, struct hlsl_struct_field, entry)
{
struct hlsl_ir_node *node = initializer->args[i];
struct hlsl_ir_assignment *assign;
struct hlsl_ir_constant *c;
if (i++ >= initializer->args_count)
{
d3dcompiler_free(initializer->args);
return;
}
break;
if (components_count_type(field->type) == components_count_type(node->data_type))
{
if (!(load = new_record_load(&new_var_load(var, var->loc)->node, field, node->loc)))
{
ERR("Out of memory.\n");
if (!(c = new_uint_constant(field->reg_offset * 4, node->loc)))
break;
}
list_add_tail(list, &load->node.entry);
assignment = make_assignment(&load->node, ASSIGN_OP_ASSIGN, node);
list_add_tail(list, &assignment->entry);
list_add_tail(list, &c->node.entry);
if (!(assign = new_assignment(var, &c->node, node, 0, node->loc)))
break;
list_add_tail(list, &assign->node.entry);
}
else
FIXME("Initializing with \"mismatched\" fields is not supported yet.\n");
......
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