Zebediah Figura : d3dcompiler: Store the arguments to a hlsl_ir_constructor as a fixed array.

Alexandre Julliard julliard at winehq.org
Fri Aug 9 14:49:32 CDT 2019


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

Author: Zebediah Figura <zfigura at codeweavers.com>
Date:   Fri Aug  9 09:52:45 2019 -0500

d3dcompiler: Store the arguments to a hlsl_ir_constructor as a fixed array.

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 |  3 ++-
 dlls/d3dcompiler_43/hlsl.y                |  8 +++++++-
 dlls/d3dcompiler_43/utils.c               | 10 ++++++----
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h
index e165f21..d6db46b 100644
--- a/dlls/d3dcompiler_43/d3dcompiler_private.h
+++ b/dlls/d3dcompiler_43/d3dcompiler_private.h
@@ -952,7 +952,8 @@ struct hlsl_ir_constant
 struct hlsl_ir_constructor
 {
     struct hlsl_ir_node node;
-    struct list *arguments;
+    struct hlsl_ir_node *args[16];
+    unsigned int args_count;
 };
 
 struct hlsl_scope
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y
index ba0fd5c..0f98190 100644
--- a/dlls/d3dcompiler_43/hlsl.y
+++ b/dlls/d3dcompiler_43/hlsl.y
@@ -2092,6 +2092,7 @@ postfix_expr:             primary_expr
                         | var_modifiers type '(' initializer_expr_list ')'
                             {
                                 struct hlsl_ir_constructor *constructor;
+                                struct hlsl_ir_node *instr;
 
                                 TRACE("%s constructor.\n", debug_hlsl_type($2));
                                 if ($1)
@@ -2120,7 +2121,12 @@ postfix_expr:             primary_expr
                                 constructor->node.type = HLSL_IR_CONSTRUCTOR;
                                 set_location(&constructor->node.loc, &@3);
                                 constructor->node.data_type = $2;
-                                constructor->arguments = $4;
+                                constructor->args_count = 0;
+                                LIST_FOR_EACH_ENTRY(instr, $4, struct hlsl_ir_node, entry)
+                                {
+                                    constructor->args[constructor->args_count++] = instr;
+                                }
+                                d3dcompiler_free($4);
 
                                 $$ = &constructor->node;
                             }
diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c
index a521eb6..742b262 100644
--- a/dlls/d3dcompiler_43/utils.c
+++ b/dlls/d3dcompiler_43/utils.c
@@ -2122,12 +2122,12 @@ static void debug_dump_ir_expr(const struct hlsl_ir_expr *expr)
 
 static void debug_dump_ir_constructor(const struct hlsl_ir_constructor *constructor)
 {
-    struct hlsl_ir_node *arg;
+    unsigned int i;
 
     TRACE("%s (", debug_hlsl_type(constructor->node.data_type));
-    LIST_FOR_EACH_ENTRY(arg, constructor->arguments, struct hlsl_ir_node, entry)
+    for (i = 0; i < constructor->args_count; ++i)
     {
-        debug_dump_instr(arg);
+        debug_dump_instr(constructor->args[i]);
         TRACE(" ");
     }
     TRACE(")");
@@ -2349,7 +2349,9 @@ static void free_ir_swizzle(struct hlsl_ir_swizzle *swizzle)
 
 static void free_ir_constructor(struct hlsl_ir_constructor *constructor)
 {
-    free_instr_list(constructor->arguments);
+    unsigned int i;
+    for (i = 0; i < constructor->args_count; ++i)
+        free_instr(constructor->args[i]);
     d3dcompiler_free(constructor);
 }
 




More information about the wine-cvs mailing list