Giovanni Mascellani (@giomasce) commented about libs/vkd3d-shader/hlsl_codegen.c:
for (i = 0; i < type->dimx; ++i)
{
unsigned int s = hlsl_swizzle_from_writemask(1 << i);
if (!(comps[i] = hlsl_new_swizzle(ctx, s, 1, mult, &instr->loc)))
return false;
list_add_before(&instr->entry, &comps[i]->entry);
}
res = comps[0];
for (i = 1; i < type->dimx; ++i)
{
if (!(res = hlsl_new_binary_expr(ctx, HLSL_OP2_ADD, res, comps[i])))
return false;
list_add_before(&instr->entry, &res->entry);
}
I suppose that you're spelling out the dot product so that it works with any numeric type? I'd rather emit an actual DOT here and then implement DOT lowering for integral types: you make the code cleaner and implement another feature for free.
Also, notice that the current code triggers an assertion when indexing `bool4`. I think that's due to the introduction of a `bool` cast once they're assumed to have already been lowered. I guess this pass should happen a bit earlier (though, to be fair, it's always difficult to track the pass dependencies and assumptions).