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]