[PATCH vkd3d v2 2/6] vkd3d-shader/hlsl: Move type_is_single_reg() to hlsl.h and rename it to hlsl_type_uses_writemask().

Francisco Casas fcasas at codeweavers.com
Tue Feb 22 16:13:38 CST 2022


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

---
v2:
- Changed the name to hlsl_type_uses_writemask().

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 a9a42770..2a9298c8 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_uses_writemask(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 be515e32..30bb5b0e 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_uses_writemask(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 17a7649f..c325ab00 100644
--- a/libs/vkd3d-shader/hlsl_codegen.c
+++ b/libs/vkd3d-shader/hlsl_codegen.c
@@ -1541,11 +1541,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;
@@ -1589,14 +1584,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_uses_writemask(var->data_type))
     {
         assert(!offset);
         ret.writemask = var->reg.writemask;
     }
     else
     {
-        assert(type_is_single_reg(type));
+        assert(hlsl_type_uses_writemask(type));
         ret.writemask = ((1 << type->dimx) - 1) << (offset % 4);
     }
     return ret;
-- 
2.25.1




More information about the wine-devel mailing list