Otherwise we always output "dcl_temps 1" even when no temp registers were used.
-- v2: vkd3d-shader/tpf: Fix used temp registers accounting for dcl_temps.
From: Nikolay Sivov nsivov@codeweavers.com
Otherwise we always output "dcl_temps 1" even when no temp registers were used. --- libs/vkd3d-shader/hlsl_codegen.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 7d17ca8ce..8e52f2490 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -3206,18 +3206,16 @@ static void compute_liveness(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl
struct register_allocator { - size_t count, capacity; - - /* Highest register index that has been allocated. - * Used to declare sm4 temp count. */ - uint32_t max_reg; - struct allocation { uint32_t reg; unsigned int writemask; unsigned int first_write, last_read; } *allocations; + size_t count, capacity; + + /* Total number of registers allocated so far. Used to declare sm4 temp count. */ + uint32_t reg_count; };
static unsigned int get_available_writemask(const struct register_allocator *allocator, @@ -3260,7 +3258,7 @@ static void record_allocation(struct hlsl_ctx *ctx, struct register_allocator *a allocation->first_write = first_write; allocation->last_read = last_read;
- allocator->max_reg = max(allocator->max_reg, reg_idx); + allocator->reg_count = max(allocator->reg_count, reg_idx + 1); }
/* reg_size is the number of register components to be reserved, while component_count is the number @@ -3691,7 +3689,7 @@ static void allocate_temp_registers(struct hlsl_ctx *ctx, struct hlsl_ir_functio }
allocate_temp_registers_recurse(ctx, &entry_func->body, &allocator); - ctx->temp_count = allocator.max_reg + 1; + ctx->temp_count = allocator.reg_count; vkd3d_free(allocator.allocations); }
On Sat Oct 28 23:48:06 2023 +0000, Zebediah Figura wrote:
Let's rename it to "reg_count" then.
Done.
This merge request was approved by Zebediah Figura.
This merge request was approved by Giovanni Mascellani.