[PATCH v4 vkd3d 1/5] vkd3d-shader/hlsl: Avoid hard-coding array sizes in hlsl_type_to_string().

Giovanni Mascellani gmascellani at codeweavers.com
Tue Nov 9 10:09:54 CST 2021


Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
--
Might be the third time I sign off on this patch... :-P

On 09/11/21 04:39, Zebediah Figura wrote:
> From: Joshua Ashton <joshua at froggi.es>
> 
> Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
> ---
>   libs/vkd3d-shader/hlsl.c | 18 +++++++++---------
>   1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c
> index c71eac3f1..1eee4278a 100644
> --- a/libs/vkd3d-shader/hlsl.c
> +++ b/libs/vkd3d-shader/hlsl.c
> @@ -854,14 +854,14 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru
>   {
>       struct vkd3d_string_buffer *string;
>   
> -    static const char base_types[HLSL_TYPE_LAST_SCALAR + 1][7] =
> -    {
> -        "float",
> -        "half",
> -        "double",
> -        "int",
> -        "uint",
> -        "bool",
> +    static const char *const base_types[] =
> +    {
> +        [HLSL_TYPE_FLOAT] = "float",
> +        [HLSL_TYPE_HALF] = "half",
> +        [HLSL_TYPE_DOUBLE] = "double",
> +        [HLSL_TYPE_INT] = "int",
> +        [HLSL_TYPE_UINT] = "uint",
> +        [HLSL_TYPE_BOOL] = "bool",
>       };
>   
>       if (!(string = hlsl_get_string_buffer(ctx)))
> @@ -915,7 +915,7 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru
>   
>           case HLSL_CLASS_OBJECT:
>           {
> -            static const char dimensions[5][HLSL_SAMPLER_DIM_MAX + 1] =
> +            static const char *const dimensions[] =
>               {
>                   [HLSL_SAMPLER_DIM_1D] = "1D",
>                   [HLSL_SAMPLER_DIM_2D] = "2D",
> 



More information about the wine-devel mailing list