From e9c37e5ba8efd4bb791cca87d5d054ff034f183f Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Fri, 24 Jun 2022 02:38:55 -0700 Subject: [PATCH] microsoft/compiler: Fix emit_ubo_var() get_dword_size() is misleading, its name implies it's returning a size in dwords, but it's actually returning a size in bytes. This led to a wrong size passed to emit_cbv(). Instead of fixing get_dword_size(), let's inline the code in emit_ubo_var(). Reviewed-by: Jesse Natalie Part-of: --- src/microsoft/compiler/nir_to_dxil.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/microsoft/compiler/nir_to_dxil.c b/src/microsoft/compiler/nir_to_dxil.c index ea47c45a53a..578103d3888 100644 --- a/src/microsoft/compiler/nir_to_dxil.c +++ b/src/microsoft/compiler/nir_to_dxil.c @@ -1054,15 +1054,6 @@ emit_uav_var(struct ntd_context *ctx, nir_variable *var, unsigned count) return emit_uav(ctx, binding, space, count, comp_type, res_kind, name); } -static unsigned get_dword_size(const struct glsl_type *type) -{ - if (glsl_type_is_array(type)) { - type = glsl_without_array(type); - } - assert(glsl_type_is_struct(type) || glsl_type_is_interface(type)); - return glsl_get_explicit_size(type, false); -} - static void var_fill_const_array_with_vector_or_scalar(struct ntd_context *ctx, const struct nir_constant *c, @@ -1218,8 +1209,12 @@ emit_ubo_var(struct ntd_context *ctx, nir_variable *var) name = temp_name; } + const struct glsl_type *type = glsl_without_array(var->type); + assert(glsl_type_is_struct(type) || glsl_type_is_interface(type)); + unsigned dwords = ALIGN_POT(glsl_get_explicit_size(type, false), 16) / 4; + return emit_cbv(ctx, var->data.binding, var->data.descriptor_set, - get_dword_size(var->type), count, name); + dwords, count, name); } static bool