Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/d3dcompiler_private.h | 2 +- dlls/d3dcompiler_43/hlsl.y | 25 ++++++++++++++++++++--- dlls/d3dcompiler_43/utils.c | 6 +++++- 3 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h index d221d1056fa..f4f68b9e4cf 100644 --- a/dlls/d3dcompiler_43/d3dcompiler_private.h +++ b/dlls/d3dcompiler_43/d3dcompiler_private.h @@ -907,7 +907,7 @@ struct hlsl_deref struct hlsl_ir_var *var; struct { - struct hlsl_ir_node *array; + struct hlsl_deref *array; struct hlsl_ir_node *index; } array; struct diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index 40159c60dcc..11dd8026c16 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -2114,8 +2114,17 @@ postfix_expr: primary_expr /* This may be an array dereference or a vector/matrix * subcomponent access. * We store it as an array dereference in any case. */ - struct hlsl_ir_deref *deref = d3dcompiler_alloc(sizeof(*deref)); - struct hlsl_type *expr_type = node_from_list($1)->data_type; + struct hlsl_ir_deref *deref = d3dcompiler_alloc(sizeof(*deref)), *src; + struct hlsl_ir_node *node = node_from_list($1); + struct hlsl_type *expr_type = node->data_type; + + if (node->type != HLSL_IR_DEREF) + { + FIXME("Unimplemented index of node type %s.\n", + debug_node_type(node->type)); + YYABORT; + } + src = deref_from_node(node);
TRACE("Array dereference from type %s\n", debug_hlsl_type(expr_type)); if (!deref) @@ -2157,7 +2166,17 @@ postfix_expr: primary_expr YYABORT; } deref->src.type = HLSL_IR_DEREF_ARRAY; - deref->src.v.array.array = node_from_list($1); + if (!(deref->src.v.array.array = d3dcompiler_alloc(sizeof(*deref->src.v.array.array)))) + { + ERR("Out of memory.\n"); + d3dcompiler_free(deref); + free_instr_list($1); + free_instr_list($3); + YYABORT; + } + *deref->src.v.array.array = src->src; + list_remove(&src->node.entry); + d3dcompiler_free(src); 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 ded8d3d77e3..9ee392967ce 100644 --- a/dlls/d3dcompiler_43/utils.c +++ b/dlls/d3dcompiler_43/utils.c @@ -1858,7 +1858,7 @@ static void debug_dump_deref(const struct hlsl_deref *deref) wine_dbg_printf(")"); break; case HLSL_IR_DEREF_ARRAY: - debug_dump_src(deref->v.array.array); + debug_dump_deref(deref->v.array.array); wine_dbg_printf("["); debug_dump_src(deref->v.array.index); wine_dbg_printf("]"); @@ -2223,6 +2223,10 @@ static void free_deref(struct hlsl_deref *deref) free_deref(deref->v.record.record); d3dcompiler_free(deref); break; + case HLSL_IR_DEREF_ARRAY: + free_deref(deref->v.array.array); + d3dcompiler_free(deref); + break; default: break; }