Zebediah Figura : vkd3d-shader: Don't use assignment instructions as sources.

Alexandre Julliard julliard at winehq.org
Mon Mar 15 16:58:42 CDT 2021


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

Author: Zebediah Figura <zfigura at codeweavers.com>
Date:   Tue Mar  9 19:42:46 2021 -0600

vkd3d-shader: Don't use assignment instructions as sources.

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

---

 libs/vkd3d-shader/hlsl.y | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index ce4bd62..a9c9dd0 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -1261,6 +1261,7 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in
 {
     struct hlsl_ir_assignment *assign;
     struct hlsl_type *lhs_type;
+    struct hlsl_ir_expr *copy;
     DWORD writemask = 0;
 
     lhs_type = lhs->data_type;
@@ -1321,7 +1322,7 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in
         lhs = lhs_inner;
     }
 
-    init_node(&assign->node, HLSL_IR_ASSIGNMENT, lhs_type, lhs->loc);
+    init_node(&assign->node, HLSL_IR_ASSIGNMENT, NULL, lhs->loc);
     assign->writemask = writemask;
     assign->lhs.var = hlsl_ir_load(lhs)->src.var;
     hlsl_src_from_node(&assign->lhs.offset, hlsl_ir_load(lhs)->src.offset.node);
@@ -1337,7 +1338,14 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in
     hlsl_src_from_node(&assign->rhs, rhs);
     list_add_tail(instrs, &assign->node.entry);
 
-    return &assign->node;
+    /* 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)))
+        return NULL;
+    list_add_tail(instrs, &copy->node.entry);
+    return &copy->node;
 }
 
 static void struct_var_initializer(struct hlsl_ctx *ctx, struct list *list, struct hlsl_ir_var *var,




More information about the wine-cvs mailing list