On 6/8/20 9:06 AM, Matteo Bruni wrote:
On Sat, Jun 6, 2020 at 12:20 AM Zebediah Figura z.figura12@gmail.com wrote:
@@ -2415,41 +2414,60 @@ postfix_expr: primary_expr } $$ = append_binop($1, $3, &load->node); }
/* "var_modifiers" doesn't make sense in this case, but it's needed
in the grammar to avoid shift/reduce conflicts. */
BTW there are 3 of those comments in hlsl.y, all different from each other... Good job me.
if ($2->type == HLSL_CLASS_MATRIX)
FIXME("Matrix constructors are not supported yet.\n");
sprintf(name, "<constructor-%x>", counter++);
if (!(var = new_synthetic_var(name, $2, get_location(&@2))))
YYABORT;
for (i = 0; i < $4.args_count; ++i)
{
const struct hlsl_type *arg_type = $4.args[i]->data_type;
unsigned int component_count = arg_type->dimx * arg_type->dimy;
if (!(assignment = new_assignment(var, NULL, $4.args[i],
((1 << component_count) - 1) << writemask_offset, $4.args[i]->loc)))
YYABORT;
writemask_offset += component_count;
Isn't this wrong for structs or arrays?
Ech, you're right; that should use components_count_type() instead.
FWIW it seems it would be more easily extensible to matrix and other types if you generate a "full" assignment with a swizzle on the lhs and then delegate fixing it up to make_assignment() rather than directly computing the writemask here.
It doesn't particularly feel like less work, when all we're missing here is implicit_conversion(), but we'd have to generate a load and swizzle instruction.