Zebediah Figura : vkd3d-shader: Rename hlsl_type_compare() to hlsl_types_are_equal().

Alexandre Julliard julliard at winehq.org
Mon Mar 22 16:48:26 CDT 2021


Module: vkd3d
Branch: master
Commit: 3ac20487f897982e5143dcda30025cda30a422be
URL:    https://source.winehq.org/git/vkd3d.git/?a=commit;h=3ac20487f897982e5143dcda30025cda30a422be

Author: Zebediah Figura <zfigura at codeweavers.com>
Date:   Thu Mar 18 00:22:19 2021 -0500

vkd3d-shader: Rename hlsl_type_compare() to hlsl_types_are_equal().

hlsl_type_compare() implies a stable comparison function, as if to be passed to
qsort().

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 libs/vkd3d-shader/hlsl.c         |  8 ++++----
 libs/vkd3d-shader/hlsl.h         |  2 +-
 libs/vkd3d-shader/hlsl.y         | 14 +++++++-------
 libs/vkd3d-shader/hlsl_codegen.c |  2 +-
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c
index 988f64d..cb13e8f 100644
--- a/libs/vkd3d-shader/hlsl.c
+++ b/libs/vkd3d-shader/hlsl.c
@@ -230,7 +230,7 @@ unsigned int hlsl_type_component_count(struct hlsl_type *type)
     return count;
 }
 
-bool hlsl_type_compare(const struct hlsl_type *t1, const struct hlsl_type *t2)
+bool hlsl_types_are_equal(const struct hlsl_type *t1, const struct hlsl_type *t2)
 {
     if (t1 == t2)
         return true;
@@ -259,7 +259,7 @@ bool hlsl_type_compare(const struct hlsl_type *t1, const struct hlsl_type *t2)
         {
             t1field = LIST_ENTRY(t1cur, struct hlsl_struct_field, entry);
             t2field = LIST_ENTRY(t2cur, struct hlsl_struct_field, entry);
-            if (!hlsl_type_compare(t1field->type, t2field->type))
+            if (!hlsl_types_are_equal(t1field->type, t2field->type))
                 return false;
             if (strcmp(t1field->name, t2field->name))
                 return false;
@@ -271,7 +271,7 @@ bool hlsl_type_compare(const struct hlsl_type *t1, const struct hlsl_type *t2)
     }
     if (t1->type == HLSL_CLASS_ARRAY)
         return t1->e.array.elements_count == t2->e.array.elements_count
-                && hlsl_type_compare(t1->e.array.type, t2->e.array.type);
+                && hlsl_types_are_equal(t1->e.array.type, t2->e.array.type);
 
     return true;
 }
@@ -473,7 +473,7 @@ struct hlsl_ir_node *hlsl_new_binary_expr(enum hlsl_ir_expr_op op, struct hlsl_i
 {
     struct hlsl_ir_expr *expr;
 
-    assert(hlsl_type_compare(arg1->data_type, arg2->data_type));
+    assert(hlsl_types_are_equal(arg1->data_type, arg2->data_type));
 
     if (!(expr = vkd3d_calloc(1, sizeof(*expr))))
         return NULL;
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h
index 92ac527..c15a8d9 100644
--- a/libs/vkd3d-shader/hlsl.h
+++ b/libs/vkd3d-shader/hlsl.h
@@ -563,10 +563,10 @@ bool hlsl_scope_add_type(struct hlsl_scope *scope, struct hlsl_type *type) DECLS
 
 struct hlsl_type *hlsl_type_clone(struct hlsl_ctx *ctx, struct hlsl_type *old,
         unsigned int default_majority) DECLSPEC_HIDDEN;
-bool hlsl_type_compare(const struct hlsl_type *t1, const struct hlsl_type *t2) DECLSPEC_HIDDEN;
 unsigned int hlsl_type_component_count(struct hlsl_type *type) DECLSPEC_HIDDEN;
 bool hlsl_type_is_row_major(const struct hlsl_type *type) DECLSPEC_HIDDEN;
 bool hlsl_type_is_void(const struct hlsl_type *type) DECLSPEC_HIDDEN;
+bool hlsl_types_are_equal(const struct hlsl_type *t1, const struct hlsl_type *t2) DECLSPEC_HIDDEN;
 
 int hlsl_lexer_compile(struct hlsl_ctx *ctx, const struct vkd3d_shader_code *hlsl) DECLSPEC_HIDDEN;
 
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index 4769475..af6c397 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -169,7 +169,7 @@ static bool compatible_data_types(struct hlsl_type *t1, struct hlsl_type *t2)
 
     if (t1->type == HLSL_CLASS_ARRAY)
     {
-        if (hlsl_type_compare(t1->e.array.type, t2))
+        if (hlsl_types_are_equal(t1->e.array.type, t2))
             /* e.g. float4[3] to float4 is allowed */
             return true;
 
@@ -226,7 +226,7 @@ static bool implicit_compatible_data_types(struct hlsl_type *t1, struct hlsl_typ
             || (t1->type <= HLSL_CLASS_LAST_NUMERIC && t2->type == HLSL_CLASS_ARRAY))
     {
         /* e.g. float4[3] to float4 is allowed */
-        if (t1->type == HLSL_CLASS_ARRAY && hlsl_type_compare(t1->e.array.type, t2))
+        if (t1->type == HLSL_CLASS_ARRAY && hlsl_types_are_equal(t1->e.array.type, t2))
             return true;
         if (hlsl_type_component_count(t1) == hlsl_type_component_count(t2))
             return true;
@@ -254,7 +254,7 @@ static bool implicit_compatible_data_types(struct hlsl_type *t1, struct hlsl_typ
     }
 
     if (t1->type == HLSL_CLASS_STRUCT && t2->type == HLSL_CLASS_STRUCT)
-        return hlsl_type_compare(t1, t2);
+        return hlsl_types_are_equal(t1, t2);
 
     return false;
 }
@@ -265,7 +265,7 @@ static struct hlsl_ir_node *add_implicit_conversion(struct hlsl_ctx *ctx, struct
     struct hlsl_type *src_type = node->data_type;
     struct hlsl_ir_expr *cast;
 
-    if (hlsl_type_compare(src_type, dst_type))
+    if (hlsl_types_are_equal(src_type, dst_type))
         return node;
 
     if (!implicit_compatible_data_types(src_type, dst_type))
@@ -1046,7 +1046,7 @@ static struct hlsl_type *expr_common_type(struct hlsl_ctx *ctx, struct hlsl_type
         return NULL;
     }
 
-    if (hlsl_type_compare(t1, t2))
+    if (hlsl_types_are_equal(t1, t2))
         return t1;
 
     if (!expr_compatible_data_types(t1, t2))
@@ -1158,7 +1158,7 @@ static struct hlsl_ir_expr *add_expr(struct hlsl_ctx *ctx, struct list *instrs,
 
         if (!operands[i])
             break;
-        if (hlsl_type_compare(operands[i]->data_type, type))
+        if (hlsl_types_are_equal(operands[i]->data_type, type))
             continue;
         if (operands[i]->data_type->dimx * operands[i]->data_type->dimy != 1
                 && operands[i]->data_type->dimx * operands[i]->data_type->dimy != type->dimx * type->dimy)
@@ -1799,7 +1799,7 @@ hlsl_prog:
                     hlsl_note(ctx, decl->loc, VKD3D_SHADER_LOG_ERROR, "\"%s\" was previously defined here.", $2.name);
                     YYABORT;
                 }
-                else if (!hlsl_type_compare(decl->return_type, $2.decl->return_type))
+                else if (!hlsl_types_are_equal(decl->return_type, $2.decl->return_type))
                 {
                     hlsl_error(ctx, $2.decl->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
                             "Function \"%s\" was already declared with a different return type.", $2.name);
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c
index 283a67e..5b68a46 100644
--- a/libs/vkd3d-shader/hlsl_codegen.c
+++ b/libs/vkd3d-shader/hlsl_codegen.c
@@ -73,7 +73,7 @@ static bool fold_redundant_casts(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst
         if (expr->op != HLSL_IR_UNOP_CAST)
             return false;
 
-        if (hlsl_type_compare(src_type, dst_type)
+        if (hlsl_types_are_equal(src_type, dst_type)
                 || (src_type->base_type == dst_type->base_type && is_vec1(src_type) && is_vec1(dst_type)))
         {
             replace_node(&expr->node, expr->operands[0].node);




More information about the wine-cvs mailing list