[PATCH vkd3d 06/17] vkd3d-shader/hlsl: Lower scalar-to-vector casts to swizzles.

Giovanni Mascellani gmascellani at codeweavers.com
Thu Dec 2 09:26:02 CST 2021


Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
---
Though with a few comments...

On 01/12/21 17:14, Matteo Bruni wrote:
> +    if (instr->type != HLSL_IR_EXPR)
> +        return false;
> +    cast = hlsl_ir_expr(instr);
> +    src_type = cast->operands[0].node->data_type;
> +    dst_type = cast->node.data_type;

Here operands[0].node is assumed to be valid before we know the 
operation is checked to be OP1_CAST. I know that we don't have nullary 
operators and I can't see why we might eventually have one, but I still 
don't like the idea.

> +    if (cast->op == HLSL_OP1_CAST
> +            && src_type->type <= HLSL_CLASS_VECTOR && dst_type->type <= HLSL_CLASS_VECTOR
> +            && src_type->dimx == 1)

I don't like how this is formatted. I would either put each conjoint on 
a dedicated line, or put two in one line and two in another. This 1-2-1 
structure makes it more difficult to parse to the eye, at least to my eye.

Thanks, Giovanni.



More information about the wine-devel mailing list