Zebediah Figura : vkd3d-shader: Factor out hlsl_new_copy().

Alexandre Julliard julliard at winehq.org
Wed Mar 17 16:19:09 CDT 2021


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

Author: Zebediah Figura <zfigura at codeweavers.com>
Date:   Tue Mar 16 16:31:52 2021 -0500

vkd3d-shader: Factor out hlsl_new_copy().

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 | 6 ++++++
 libs/vkd3d-shader/hlsl.h | 1 +
 libs/vkd3d-shader/hlsl.y | 8 +++-----
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c
index 19c0e2e..988f64d 100644
--- a/libs/vkd3d-shader/hlsl.c
+++ b/libs/vkd3d-shader/hlsl.c
@@ -382,6 +382,12 @@ struct hlsl_ir_expr *hlsl_new_cast(struct hlsl_ir_node *node, struct hlsl_type *
     return hlsl_ir_expr(cast);
 }
 
+struct hlsl_ir_expr *hlsl_new_copy(struct hlsl_ir_node *node)
+{
+    /* Use a cast to the same type as a makeshift identity expression. */
+    return hlsl_new_cast(node, node->data_type, &node->loc);
+}
+
 struct hlsl_ir_var *hlsl_new_var(const char *name, struct hlsl_type *type, const struct vkd3d_shader_location loc,
         const char *semantic, unsigned int modifiers, const struct hlsl_reg_reservation *reg_reservation)
 {
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h
index 5a2f6af..92ac527 100644
--- a/libs/vkd3d-shader/hlsl.h
+++ b/libs/vkd3d-shader/hlsl.h
@@ -525,6 +525,7 @@ struct hlsl_ir_node *hlsl_new_binary_expr(enum hlsl_ir_expr_op op, struct hlsl_i
         struct hlsl_ir_node *arg2) DECLSPEC_HIDDEN;
 struct hlsl_ir_expr *hlsl_new_cast(struct hlsl_ir_node *node, struct hlsl_type *type,
         struct vkd3d_shader_location *loc) DECLSPEC_HIDDEN;
+struct hlsl_ir_expr *hlsl_new_copy(struct hlsl_ir_node *node) DECLSPEC_HIDDEN;
 struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx, struct hlsl_type *return_type,
         struct list *parameters, const char *semantic, struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
 struct hlsl_ir_if *hlsl_new_if(struct hlsl_ir_node *condition, struct vkd3d_shader_location loc) DECLSPEC_HIDDEN;
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index 6fceafb..afac0ab 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -1336,9 +1336,8 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in
 
     /* Don't use the instruction itself as a source, as this makes structure
      * splitting easier. Instead copy it here. Since we retrieve sources from
-     * the last instruction in the list, we do need to copy. Use a cast
-     * instruction to the same type as a makeshift identity expression. */
-    if (!(copy = hlsl_new_cast(rhs, rhs->data_type, &lhs->loc)))
+     * the last instruction in the list, we do need to copy. */
+    if (!(copy = hlsl_new_copy(rhs)))
         return NULL;
     list_add_tail(instrs, &copy->node.entry);
     return &copy->node;
@@ -1365,8 +1364,7 @@ static bool add_increment(struct hlsl_ctx *ctx, struct list *instrs, bool decrem
     {
         struct hlsl_ir_expr *copy;
 
-        /* Use a cast to the same type as a makeshift identity expression. */
-        if (!(copy = hlsl_new_cast(lhs, lhs->data_type, &lhs->loc)))
+        if (!(copy = hlsl_new_copy(lhs)))
             return false;
         list_add_tail(instrs, &copy->node.entry);
 




More information about the wine-cvs mailing list