[PATCH vkd3d v5 6/8] vkd3d-shader/hlsl: Don't check exact number of components for braceless initialization of numeric types.

Giovanni Mascellani gmascellani at codeweavers.com
Mon Mar 14 08:13:28 CDT 2022


Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>

Il 10/03/22 16:14, Francisco Casas ha scritto:
> The implicit conversion in add_assignment() takes responsability now.
> 
> Signed-off-by: Francisco Casas <fcasas at codeweavers.com>
> 
> ---
> v5:
>   - No changes from v4.
> 
> Signed-off-by: Francisco Casas <fcasas at codeweavers.com>
> ---
>   libs/vkd3d-shader/hlsl.y | 20 +++++++++-----------
>   1 file changed, 9 insertions(+), 11 deletions(-)
> 
> diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
> index bbdc1493..0b6093ba 100644
> --- a/libs/vkd3d-shader/hlsl.y
> +++ b/libs/vkd3d-shader/hlsl.y
> @@ -1602,19 +1602,17 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
>               unsigned int size = initializer_size(&v->initializer);
>               struct hlsl_ir_load *load;
>   
> -            if (type->type <= HLSL_CLASS_LAST_NUMERIC
> -                    && type->dimx * type->dimy != size && size != 1)
> +            if (type->type <= HLSL_CLASS_LAST_NUMERIC && v->initializer.braces
> +                    && type->dimx * type->dimy != size)
>               {
> -                if (size < type->dimx * type->dimy)
> -                {
> -                    hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
> -                            "Expected %u components in numeric initializer, but got %u.",
> -                            type->dimx * type->dimy, size);
> -                    free_parse_initializer(&v->initializer);
> -                    vkd3d_free(v);
> -                    continue;
> -                }
> +                hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
> +                        "Expected %u components in numeric initializer, but got %u.",
> +                        type->dimx * type->dimy, v->initializer.args_count);
> +                free_parse_initializer(&v->initializer);
> +                vkd3d_free(v);
> +                continue;
>               }
> +
>               if ((type->type == HLSL_CLASS_STRUCT || type->type == HLSL_CLASS_ARRAY)
>                       && hlsl_type_component_count(type) != size)
>               {



More information about the wine-devel mailing list