From 1c1f1094a5a1a748eebc5fcb456ff8404981a00e Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Wed, 21 Jun 2023 12:00:39 -0500 Subject: [PATCH] vkd3d-shader/hlsl: Handle reserved vars specially in get_allocated_object(). --- libs/vkd3d-shader/hlsl_codegen.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 96b4cb66..36b66982 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -3626,11 +3626,23 @@ static const struct hlsl_ir_var *get_allocated_object(struct hlsl_ctx *ctx, enum LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, const struct hlsl_ir_var, extern_entry) { - if (!var->regs[regset].allocated) + if (var->reg_reservation.reg_type == get_regset_name(regset) + && var->data_type->reg_size[regset]) + { + /* Vars with a reservation prevent non-reserved vars from being + * bound there even if the reserved vars aren't used. */ + start = var->reg_reservation.reg_index; + count = var->data_type->reg_size[regset]; + } + else if (var->regs[regset].allocated) + { + start = var->regs[regset].id; + count = var->regs[regset].bind_count; + } + else + { continue; - - start = var->regs[regset].id; - count = var->regs[regset].bind_count; + } if (start <= index && index < start + count) return var;