[PATCH vkd3d 05/12] vkd3d-shader/hlsl: Support vector indexing.

Zebediah Figura zfigura at codeweavers.com
Wed Apr 20 12:57:24 CDT 2022


On 4/18/22 01:34, Giovanni Mascellani wrote:
> Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
> ---
>   libs/vkd3d-shader/hlsl.y               | 14 ++++++++++----
>   tests/hlsl-vector-indexing.shader_test |  4 ++--
>   2 files changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
> index fd808648..291f8392 100644
> --- a/libs/vkd3d-shader/hlsl.y
> +++ b/libs/vkd3d-shader/hlsl.y
> @@ -592,13 +592,21 @@ static bool add_array_load(struct hlsl_ctx *ctx, struct list *instrs, struct hls
>       if (expr_type->type == HLSL_CLASS_ARRAY)
>       {
>           data_type = expr_type->e.array.type;
> +        if (!(c = hlsl_new_uint_constant(ctx, hlsl_type_get_array_element_reg_size(data_type), &loc)))
> +            return false;
>       }
> -    else if (expr_type->type == HLSL_CLASS_MATRIX || expr_type->type == HLSL_CLASS_VECTOR)
> +    else if (expr_type->type == HLSL_CLASS_MATRIX)
>       {
>           /* This needs to be lowered now, while we still have type information. */
> -        FIXME("Index of matrix or vector type.\n");
> +        FIXME("Index of matrix type.\n");
>           return false;
>       }
> +    else if (expr_type->type == HLSL_CLASS_VECTOR)
> +    {
> +        data_type = hlsl_get_scalar_type(ctx, expr_type->base_type);
> +        if (!(c = hlsl_new_uint_constant(ctx, 1, &loc)))
> +            return false;

Why not just bring the constant + mul into the ARRAY path?

> +    }
>       else
>       {
>           if (expr_type->type == HLSL_CLASS_SCALAR)



More information about the wine-devel mailing list