From 5d34790402530116672014ca5bea3a06d91f20df Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Thu, 12 Jan 2023 17:28:44 -0600 Subject: [PATCH] vkd3d-shader/hlsl: Call copy_propagation_get_value() directly in copy_propagation_transform_object_load(). copy_propagation_compute_replacement() is not doing very much for us, and conceptually is a bit of an odd fit anyway, since it's meant to deal with multi-component types. --- libs/vkd3d-shader/hlsl_codegen.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index fefb8406..710cdc84 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -805,15 +805,20 @@ static bool copy_propagation_transform_load(struct hlsl_ctx *ctx, static bool copy_propagation_transform_object_load(struct hlsl_ctx *ctx, struct hlsl_deref *deref, struct copy_propagation_state *state) { + struct copy_propagation_value *value; struct hlsl_ir_load *load; - struct hlsl_ir_node *instr; - unsigned int swizzle; + unsigned int start, count; - if (!(instr = copy_propagation_compute_replacement(ctx, state, deref, &swizzle))) + if (!hlsl_component_index_range_from_deref(ctx, deref, &start, &count)) return false; + assert(count == 1); + + if (!(value = copy_propagation_get_value(state, deref->var, start))) + return false; + assert(value->component == 0); /* Only HLSL_IR_LOAD can produce an object. */ - load = hlsl_ir_load(instr); + load = hlsl_ir_load(value->node); hlsl_cleanup_deref(deref); hlsl_copy_deref(ctx, deref, &load->src);