[PATCH vkd3d v5 2/6] vkd3d-shader/hlsl: Move sampler_dim_count() to hlsl.h.

Giovanni Mascellani gmascellani at codeweavers.com
Fri Jan 28 02:24:54 CST 2022


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

Il 27/01/22 19:31, Francisco Casas ha scritto:
> Signed-off-by: Francisco Casas <fcasas at codeweavers.com>
> ---
>   libs/vkd3d-shader/hlsl.h | 17 +++++++++++++++++
>   libs/vkd3d-shader/hlsl.y | 23 +++--------------------
>   2 files changed, 20 insertions(+), 20 deletions(-)
> 
> diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h
> index 2319895a..3dfeea1d 100644
> --- a/libs/vkd3d-shader/hlsl.h
> +++ b/libs/vkd3d-shader/hlsl.h
> @@ -667,6 +667,23 @@ static inline struct hlsl_type *hlsl_get_numeric_type(const struct hlsl_ctx *ctx
>           return hlsl_get_matrix_type(ctx, base_type, dimx, dimy);
>   }
>   
> +static inline unsigned int hlsl_sampler_dim_count(enum hlsl_sampler_dim dim)
> +{
> +    switch (dim)
> +    {
> +        case HLSL_SAMPLER_DIM_1D:
> +            return 1;
> +        case HLSL_SAMPLER_DIM_2D:
> +            return 2;
> +        case HLSL_SAMPLER_DIM_3D:
> +        case HLSL_SAMPLER_DIM_CUBE:
> +            return 3;
> +        default:
> +            assert(0);
> +            return 0;
> +    }
> +}
> +
>   const char *debug_hlsl_expr_op(enum hlsl_ir_expr_op op);
>   const char *debug_hlsl_type(struct hlsl_ctx *ctx, const struct hlsl_type *type);
>   const char *debug_hlsl_writemask(unsigned int writemask);
> diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
> index 9476765f..18126032 100644
> --- a/libs/vkd3d-shader/hlsl.y
> +++ b/libs/vkd3d-shader/hlsl.y
> @@ -1513,23 +1513,6 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
>       return statements_list;
>   }
>   
> -static unsigned int sampler_dim_count(enum hlsl_sampler_dim dim)
> -{
> -    switch (dim)
> -    {
> -        case HLSL_SAMPLER_DIM_1D:
> -            return 1;
> -        case HLSL_SAMPLER_DIM_2D:
> -            return 2;
> -        case HLSL_SAMPLER_DIM_3D:
> -        case HLSL_SAMPLER_DIM_CUBE:
> -            return 3;
> -        default:
> -            assert(0);
> -            return 0;
> -    }
> -}
> -
>   struct find_function_call_args
>   {
>       const struct parse_initializer *params;
> @@ -1856,7 +1839,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
>   
>       if (!strcmp(name, "Load"))
>       {
> -        const unsigned int sampler_dim = sampler_dim_count(object_type->sampler_dim);
> +        const unsigned int sampler_dim = hlsl_sampler_dim_count(object_type->sampler_dim);
>           struct hlsl_ir_resource_load *load;
>           struct hlsl_ir_node *coords;
>   
> @@ -1882,7 +1865,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
>       }
>       else if (!strcmp(name, "Sample"))
>       {
> -        const unsigned int sampler_dim = sampler_dim_count(object_type->sampler_dim);
> +        const unsigned int sampler_dim = hlsl_sampler_dim_count(object_type->sampler_dim);
>           const struct hlsl_type *sampler_type;
>           struct hlsl_ir_resource_load *load;
>           struct hlsl_ir_node *offset = NULL;
> @@ -1933,7 +1916,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
>       else if (!strcmp(name, "Gather") || !strcmp(name, "GatherRed") || !strcmp(name, "GatherBlue")
>               || !strcmp(name, "GatherGreen") || !strcmp(name, "GatherAlpha"))
>       {
> -        const unsigned int sampler_dim = sampler_dim_count(object_type->sampler_dim);
> +        const unsigned int sampler_dim = hlsl_sampler_dim_count(object_type->sampler_dim);
>           enum hlsl_resource_load_type load_type;
>           const struct hlsl_type *sampler_type;
>           struct hlsl_ir_resource_load *load;



More information about the wine-devel mailing list