Zebediah Figura : d3dcompiler: Separate out an hlsl_deref structure and store it in hlsl_ir_assignment directly.

Alexandre Julliard julliard at winehq.org
Thu Mar 12 17:09:07 CDT 2020


Module: wine
Branch: master
Commit: 54387427b0aec5012aa0dae12a7c72f189d3c3a1
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=54387427b0aec5012aa0dae12a7c72f189d3c3a1

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Fri Mar  6 17:17:34 2020 -0600

d3dcompiler: Separate out an hlsl_deref structure and store it in hlsl_ir_assignment directly.

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

---

 dlls/d3dcompiler_43/d3dcompiler_private.h | 25 +++++++++++++++----------
 dlls/d3dcompiler_43/hlsl.y                |  6 +++---
 dlls/d3dcompiler_43/utils.c               | 25 +++++++++++++++----------
 3 files changed, 33 insertions(+), 23 deletions(-)

diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h
index 04878c7046..830434c9ff 100644
--- a/dlls/d3dcompiler_43/d3dcompiler_private.h
+++ b/dlls/d3dcompiler_43/d3dcompiler_private.h
@@ -796,14 +796,6 @@ struct hlsl_ir_loop
     struct list *body;
 };
 
-struct hlsl_ir_assignment
-{
-    struct hlsl_ir_node node;
-    struct hlsl_ir_node *lhs;
-    struct hlsl_ir_node *rhs;
-    unsigned char writemask;
-};
-
 enum hlsl_ir_expr_op {
     HLSL_IR_UNOP_BIT_NOT = 0,
     HLSL_IR_UNOP_LOGIC_NOT,
@@ -907,9 +899,8 @@ enum hlsl_ir_deref_type
     HLSL_IR_DEREF_RECORD,
 };
 
-struct hlsl_ir_deref
+struct hlsl_deref
 {
-    struct hlsl_ir_node node;
     enum hlsl_ir_deref_type type;
     union
     {
@@ -927,6 +918,20 @@ struct hlsl_ir_deref
     } v;
 };
 
+struct hlsl_ir_deref
+{
+    struct hlsl_ir_node node;
+    struct hlsl_deref src;
+};
+
+struct hlsl_ir_assignment
+{
+    struct hlsl_ir_node node;
+    struct hlsl_deref lhs;
+    struct hlsl_ir_node *rhs;
+    unsigned char writemask;
+};
+
 struct hlsl_ir_constant
 {
     struct hlsl_ir_node node;
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y
index 591f755a7b..a24d29e5df 100644
--- a/dlls/d3dcompiler_43/hlsl.y
+++ b/dlls/d3dcompiler_43/hlsl.y
@@ -2123,9 +2123,9 @@ postfix_expr:             primary_expr
                                     free_instr_list($3);
                                     YYABORT;
                                 }
-                                deref->type = HLSL_IR_DEREF_ARRAY;
-                                deref->v.array.array = node_from_list($1);
-                                deref->v.array.index = node_from_list($3);
+                                deref->src.type = HLSL_IR_DEREF_ARRAY;
+                                deref->src.v.array.array = node_from_list($1);
+                                deref->src.v.array.index = node_from_list($3);
 
                                 $$ = append_binop($1, $3, &deref->node);
                             }
diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c
index 9c38800808..29b35c3d7e 100644
--- a/dlls/d3dcompiler_43/utils.c
+++ b/dlls/d3dcompiler_43/utils.c
@@ -1380,8 +1380,8 @@ struct hlsl_ir_deref *new_var_deref(struct hlsl_ir_var *var)
     }
     deref->node.type = HLSL_IR_DEREF;
     deref->node.data_type = var->data_type;
-    deref->type = HLSL_IR_DEREF_VAR;
-    deref->v.var = var;
+    deref->src.type = HLSL_IR_DEREF_VAR;
+    deref->src.v.var = var;
     return deref;
 }
 
@@ -1396,9 +1396,9 @@ struct hlsl_ir_deref *new_record_deref(struct hlsl_ir_node *record, struct hlsl_
     }
     deref->node.type = HLSL_IR_DEREF;
     deref->node.data_type = field->type;
-    deref->type = HLSL_IR_DEREF_RECORD;
-    deref->v.record.record = record;
-    deref->v.record.field = field;
+    deref->src.type = HLSL_IR_DEREF_RECORD;
+    deref->src.v.record.record = record;
+    deref->src.v.record.field = field;
     return deref;
 }
 
@@ -1547,13 +1547,13 @@ struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *lhs, enum parse_assign
 
     rhs = implicit_conversion(rhs, type, &rhs->loc);
 
-    assign->lhs = lhs;
+    assign->lhs = deref_from_node(lhs)->src;
     if (assign_op != ASSIGN_OP_ASSIGN)
     {
         enum hlsl_ir_expr_op op = op_from_assignment(assign_op);
         struct hlsl_ir_node *expr;
 
-        if (deref_from_node(lhs)->type != HLSL_IR_DEREF_VAR)
+        if (assign->lhs.type != HLSL_IR_DEREF_VAR)
         {
             FIXME("LHS expression not supported in compound assignments yet.\n");
             assign->rhs = rhs;
@@ -1567,7 +1567,12 @@ struct hlsl_ir_node *make_assignment(struct hlsl_ir_node *lhs, enum parse_assign
         }
     }
     else
+    {
+        list_remove(&lhs->entry);
+        /* Don't recursively free the deref; we just copied its members. */
+        d3dcompiler_free(lhs);
         assign->rhs = rhs;
+    }
 
     return &assign->node;
 }
@@ -1860,7 +1865,7 @@ static void debug_dump_ir_var(const struct hlsl_ir_var *var)
         wine_dbg_printf(" : %s", debugstr_a(var->semantic));
 }
 
-static void debug_dump_ir_deref(const struct hlsl_ir_deref *deref)
+static void debug_dump_deref(const struct hlsl_deref *deref)
 {
     switch (deref->type)
     {
@@ -2048,7 +2053,7 @@ static const char *debug_writemask(DWORD writemask)
 static void debug_dump_ir_assignment(const struct hlsl_ir_assignment *assign)
 {
     wine_dbg_printf("= (");
-    debug_dump_src(assign->lhs);
+    debug_dump_deref(&assign->lhs);
     if (assign->writemask != BWRITERSP_WRITEMASK_ALL)
         wine_dbg_printf("%s", debug_writemask(assign->writemask));
     wine_dbg_printf(" ");
@@ -2129,7 +2134,7 @@ static void debug_dump_instr(const struct hlsl_ir_node *instr)
             debug_dump_ir_expr(expr_from_node(instr));
             break;
         case HLSL_IR_DEREF:
-            debug_dump_ir_deref(deref_from_node(instr));
+            debug_dump_deref(&deref_from_node(instr)->src);
             break;
         case HLSL_IR_CONSTANT:
             debug_dump_ir_constant(constant_from_node(instr));




More information about the wine-cvs mailing list