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

Giovanni Mascellani gmascellani at codeweavers.com
Wed Feb 16 02:49:48 CST 2022


Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
---
Though I think that just getting rid of that helper would make the code 
more readable. Besides, I find the name "is single register" slightly 
wrong: a matrix 1x1 takes a single register too.

Il 15/02/22 21:17, Francisco Casas ha scritto:
> Signed-off-by: Francisco Casas <fcasas at codeweavers.com>
> ---
>   libs/vkd3d-shader/hlsl.c         | 7 +------
>   libs/vkd3d-shader/hlsl.h         | 5 +++++
>   libs/vkd3d-shader/hlsl_codegen.c | 9 ++-------
>   3 files changed, 8 insertions(+), 13 deletions(-)
> 
> diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c
> index 8a0f4b01..8c56761d 100644
> --- a/libs/vkd3d-shader/hlsl.c
> +++ b/libs/vkd3d-shader/hlsl.c
> @@ -527,17 +527,12 @@ struct hlsl_ir_var *hlsl_new_synthetic_var(struct hlsl_ctx *ctx, const char *nam
>       return var;
>   }
>   
> -static bool type_is_single_reg(const struct hlsl_type *type)
> -{
> -    return type->type == HLSL_CLASS_SCALAR || type->type == HLSL_CLASS_VECTOR;
> -}
> -
>   struct hlsl_ir_store *hlsl_new_store(struct hlsl_ctx *ctx, struct hlsl_ir_var *var, struct hlsl_ir_node *offset,
>           struct hlsl_ir_node *rhs, unsigned int writemask, struct vkd3d_shader_location loc)
>   {
>       struct hlsl_ir_store *store;
>   
> -    if (!writemask && type_is_single_reg(rhs->data_type))
> +    if (!writemask && hlsl_type_is_single_reg(rhs->data_type))
>           writemask = (1 << rhs->data_type->dimx) - 1;
>   
>       if (!(store = hlsl_alloc(ctx, sizeof(*store))))
> diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h
> index 3a69165e..1f3ca4a2 100644
> --- a/libs/vkd3d-shader/hlsl.h
> +++ b/libs/vkd3d-shader/hlsl.h
> @@ -697,6 +697,11 @@ static inline unsigned int hlsl_sampler_dim_count(enum hlsl_sampler_dim dim)
>       }
>   }
>   
> +static inline bool hlsl_type_is_single_reg(const struct hlsl_type *type)
> +{
> +    return type->type == HLSL_CLASS_SCALAR || type->type == HLSL_CLASS_VECTOR;
> +}
> +
>   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_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c
> index eac3513c..c502773d 100644
> --- a/libs/vkd3d-shader/hlsl_codegen.c
> +++ b/libs/vkd3d-shader/hlsl_codegen.c
> @@ -1685,11 +1685,6 @@ static void allocate_objects(struct hlsl_ctx *ctx, enum hlsl_base_type type)
>       }
>   }
>   
> -static bool type_is_single_reg(const struct hlsl_type *type)
> -{
> -    return type->type == HLSL_CLASS_SCALAR || type->type == HLSL_CLASS_VECTOR;
> -}
> -
>   bool hlsl_offset_from_deref(const struct hlsl_deref *deref, unsigned int *offset)
>   {
>       struct hlsl_ir_node *offset_node = deref->offset.node;
> @@ -1733,14 +1728,14 @@ struct hlsl_reg hlsl_reg_from_deref(struct hlsl_ctx *ctx, const struct hlsl_dere
>   
>       ret.id += offset / 4;
>   
> -    if (type_is_single_reg(var->data_type))
> +    if (hlsl_type_is_single_reg(var->data_type))
>       {
>           assert(!offset);
>           ret.writemask = var->reg.writemask;
>       }
>       else
>       {
> -        assert(type_is_single_reg(type));
> +        assert(hlsl_type_is_single_reg(type));
>           ret.writemask = ((1 << type->dimx) - 1) << (offset % 4);
>       }
>       return ret;



More information about the wine-devel mailing list