[PATCH v2 4/6] d3dcompiler: Allow hlsl_ir_constant to contain only numeric types.

Zebediah Figura z.figura12 at gmail.com
Mon Jun 8 16:49:37 CDT 2020


Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 dlls/d3dcompiler_43/d3dcompiler_private.h | 17 +++++---------
 dlls/d3dcompiler_43/hlsl.y                | 18 +++++++--------
 dlls/d3dcompiler_43/utils.c               | 28 ++++-------------------
 3 files changed, 20 insertions(+), 43 deletions(-)

diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h
index 0002a070cca..9ac2f14041a 100644
--- a/dlls/d3dcompiler_43/d3dcompiler_private.h
+++ b/dlls/d3dcompiler_43/d3dcompiler_private.h
@@ -866,17 +866,12 @@ struct hlsl_ir_constant
     struct hlsl_ir_node node;
     union
     {
-        union
-        {
-            unsigned u[16];
-            int i[16];
-            float f[16];
-            double d[16];
-            BOOL b[16];
-        } value;
-        struct hlsl_ir_constant *array_elements;
-        struct list *struct_elements;
-    } v;
+        unsigned u[16];
+        int i[16];
+        float f[16];
+        double d[16];
+        BOOL b[16];
+    } value;
 };
 
 struct hlsl_scope
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y
index d8e711795eb..79becca2578 100644
--- a/dlls/d3dcompiler_43/hlsl.y
+++ b/dlls/d3dcompiler_43/hlsl.y
@@ -590,7 +590,7 @@ static struct hlsl_ir_constant *new_uint_constant(unsigned int n, const struct s
     if (!(c = d3dcompiler_alloc(sizeof(*c))))
         return NULL;
     init_node(&c->node, HLSL_IR_CONSTANT, hlsl_ctx.builtin_types.scalar[HLSL_TYPE_UINT], loc);
-    c->v.value.u[0] = n;
+    c->value.u[0] = n;
     return c;
 }
 
@@ -1231,15 +1231,15 @@ static unsigned int evaluate_array_dimension(struct hlsl_ir_node *node)
         switch (constant->node.data_type->base_type)
         {
         case HLSL_TYPE_UINT:
-            return constant->v.value.u[0];
+            return constant->value.u[0];
         case HLSL_TYPE_INT:
-            return constant->v.value.i[0];
+            return constant->value.i[0];
         case HLSL_TYPE_FLOAT:
-            return constant->v.value.f[0];
+            return constant->value.f[0];
         case HLSL_TYPE_DOUBLE:
-            return constant->v.value.d[0];
+            return constant->value.d[0];
         case HLSL_TYPE_BOOL:
-            return constant->v.value.b[0];
+            return constant->value.b[0];
         default:
             WARN("Invalid type %s.\n", debug_base_type(constant->node.data_type));
             return 0;
@@ -2252,7 +2252,7 @@ primary_expr:             C_FLOAT
                                 }
                                 init_node(&c->node, HLSL_IR_CONSTANT,
                                         hlsl_ctx.builtin_types.scalar[HLSL_TYPE_FLOAT], get_location(&@1));
-                                c->v.value.f[0] = $1;
+                                c->value.f[0] = $1;
                                 if (!($$ = make_list(&c->node)))
                                     YYABORT;
                             }
@@ -2266,7 +2266,7 @@ primary_expr:             C_FLOAT
                                 }
                                 init_node(&c->node, HLSL_IR_CONSTANT,
                                         hlsl_ctx.builtin_types.scalar[HLSL_TYPE_INT], get_location(&@1));
-                                c->v.value.i[0] = $1;
+                                c->value.i[0] = $1;
                                 if (!($$ = make_list(&c->node)))
                                     YYABORT;
                             }
@@ -2280,7 +2280,7 @@ primary_expr:             C_FLOAT
                                 }
                                 init_node(&c->node, HLSL_IR_CONSTANT,
                                         hlsl_ctx.builtin_types.scalar[HLSL_TYPE_BOOL], get_location(&@1));
-                                c->v.value.b[0] = $1;
+                                c->value.b[0] = $1;
                                 if (!($$ = make_list(&c->node)))
                                     YYABORT;
                             }
diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c
index 63b1bccbd83..9abdabbf2bc 100644
--- a/dlls/d3dcompiler_43/utils.c
+++ b/dlls/d3dcompiler_43/utils.c
@@ -1831,19 +1831,19 @@ static void debug_dump_ir_constant(const struct hlsl_ir_constant *constant)
             switch (type->base_type)
             {
                 case HLSL_TYPE_FLOAT:
-                    wine_dbg_printf("%g ", (double)constant->v.value.f[y * type->dimx + x]);
+                    wine_dbg_printf("%g ", (double)constant->value.f[y * type->dimx + x]);
                     break;
                 case HLSL_TYPE_DOUBLE:
-                    wine_dbg_printf("%g ", constant->v.value.d[y * type->dimx + x]);
+                    wine_dbg_printf("%g ", constant->value.d[y * type->dimx + x]);
                     break;
                 case HLSL_TYPE_INT:
-                    wine_dbg_printf("%d ", constant->v.value.i[y * type->dimx + x]);
+                    wine_dbg_printf("%d ", constant->value.i[y * type->dimx + x]);
                     break;
                 case HLSL_TYPE_UINT:
-                    wine_dbg_printf("%u ", constant->v.value.u[y * type->dimx + x]);
+                    wine_dbg_printf("%u ", constant->value.u[y * type->dimx + x]);
                     break;
                 case HLSL_TYPE_BOOL:
-                    wine_dbg_printf("%s ", constant->v.value.b[y * type->dimx + x] == FALSE ? "false" : "true");
+                    wine_dbg_printf("%s ", constant->value.b[y * type->dimx + x] == FALSE ? "false" : "true");
                     break;
                 default:
                     wine_dbg_printf("Constants of type %s not supported\n", debug_base_type(type));
@@ -2123,24 +2123,6 @@ void free_instr_list(struct list *list)
 
 static void free_ir_constant(struct hlsl_ir_constant *constant)
 {
-    struct hlsl_type *type = constant->node.data_type;
-    unsigned int i;
-    struct hlsl_ir_constant *field, *next_field;
-
-    switch (type->type)
-    {
-        case HLSL_CLASS_ARRAY:
-            for (i = 0; i < type->e.array.elements_count; ++i)
-                free_ir_constant(&constant->v.array_elements[i]);
-            d3dcompiler_free(constant->v.array_elements);
-            break;
-        case HLSL_CLASS_STRUCT:
-            LIST_FOR_EACH_ENTRY_SAFE(field, next_field, constant->v.struct_elements, struct hlsl_ir_constant, node.entry)
-                free_ir_constant(field);
-            break;
-        default:
-            break;
-    }
     d3dcompiler_free(constant);
 }
 
-- 
2.26.2




More information about the wine-devel mailing list