From 73c8529e6e7deb86b35da17e1b9d527f24690b9d Mon Sep 17 00:00:00 2001 From: Elizabeth Figura Date: Fri, 21 Nov 2025 16:53:14 -0600 Subject: [PATCH] vkd3d-shader/hlsl: Calculate the bind count from the vector width. Scalars have a reg_size of 4 on sm1. In the case of a deref of a vector or matrix resulting in a scalar, however, this yields a required_bind_count that is one higher than it should be. reg_size is the wrong thing to be using here, since it describes the size of a type in isolation, but this is conceptually an embedded type that doesn't include any padding. Since we're only dealing with scalars and vectors here, just use their width. --- libs/vkd3d-shader/hlsl_codegen.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 345f5fa73..30ce7cec3 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -6439,8 +6439,9 @@ static void register_deref_usage(struct hlsl_ctx *ctx, const struct hlsl_deref * else if (regset == HLSL_REGSET_NUMERIC) { type = hlsl_deref_get_type(ctx, deref); + VKD3D_ASSERT(type->class <= HLSL_CLASS_VECTOR); - required_bind_count = align(index + type->reg_size[regset], 4) / 4; + required_bind_count = align(index + type->e.numeric.dimx, 4) / 4; var->bind_count[regset] = max(var->bind_count[regset], required_bind_count); } else