From f5486442227c9e2d6ec45fcfd515660f56a1b720 Mon Sep 17 00:00:00 2001 From: Francisco Casas Date: Fri, 3 May 2024 02:06:37 -0400 Subject: [PATCH] vkd3d-shader/hlsl: Only allocate numeric bind count for SM1 numeric uniforms. Unless they have register reservations, in which case the whole variable is still reserved. --- libs/vkd3d-shader/hlsl_codegen.c | 7 +++---- tests/hlsl/sm1-const-allocation.shader_test | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 25bd5d9c..de778000 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -4593,15 +4593,14 @@ static void allocate_const_registers(struct hlsl_ctx *ctx, struct hlsl_ir_functi LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, struct hlsl_ir_var, extern_entry) { - unsigned int reg_size = var->data_type->reg_size[HLSL_REGSET_NUMERIC]; + unsigned int alloc_size = 4 * var->bind_count[HLSL_REGSET_NUMERIC]; - if (!var->is_uniform || !var->last_read || reg_size == 0) + if (!var->is_uniform || alloc_size == 0) continue; if (!var->regs[HLSL_REGSET_NUMERIC].allocated) { - var->regs[HLSL_REGSET_NUMERIC] = allocate_numeric_registers_for_type(ctx, &allocator, - 1, UINT_MAX, var->data_type); + var->regs[HLSL_REGSET_NUMERIC] = allocate_range(ctx, &allocator, 1, UINT_MAX, alloc_size); TRACE("Allocated %s to %s.\n", var->name, debug_register('c', var->regs[HLSL_REGSET_NUMERIC], var->data_type)); } diff --git a/tests/hlsl/sm1-const-allocation.shader_test b/tests/hlsl/sm1-const-allocation.shader_test index 0a4340ea..e8a60255 100644 --- a/tests/hlsl/sm1-const-allocation.shader_test +++ b/tests/hlsl/sm1-const-allocation.shader_test @@ -26,7 +26,7 @@ float4 main() : sv_target uniform 0 float4 1 2 3 4 uniform 4 float4 100 200 300 400 draw quad -todo probe all rgba (101, 202, 303, 404) +probe all rgba (101, 202, 303, 404) [pixel shader] @@ -188,7 +188,7 @@ uniform 16 float4 41 42 43 44 uniform 20 float4 51 52 53 54 uniform 24 float4 61 62 63 64 draw quad -todo probe all rgba (31, 52, 61, 62) +probe all rgba (31, 52, 61, 62) [pixel shader]