From: Zebediah Figura Subject: [PATCH 2/5] d3dcompiler: Allow hlsl_ir_constant to contain only numeric types. Message-Id: <20200605221933.1861389-2-zfigura@codeweavers.com> Date: Fri, 5 Jun 2020 17:19:30 -0500 In-Reply-To: <20200605221933.1861389-1-zfigura@codeweavers.com> References: <20200605221933.1861389-1-zfigura@codeweavers.com> Signed-off-by: Zebediah Figura --- 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 c9bb6ced6c7..b1719ec44f7 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 8fbb879778d..d5247d69b5c 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -589,7 +589,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; } @@ -1230,15 +1230,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; @@ -2251,7 +2251,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; } @@ -2265,7 +2265,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; } @@ -2279,7 +2279,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 4f156b678f2..45dd52da590 100644 --- a/dlls/d3dcompiler_43/utils.c +++ b/dlls/d3dcompiler_43/utils.c @@ -1835,19 +1835,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)); @@ -2127,24 +2127,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