Mesa (main): microsoft/compiler: Fix emit_ubo_var()
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jun 24 18:14:02 UTC 2022
Module: Mesa
Branch: main
Commit: e9c37e5ba8efd4bb791cca87d5d054ff034f183f
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e9c37e5ba8efd4bb791cca87d5d054ff034f183f
Author: Boris Brezillon <boris.brezillon at collabora.com>
Date: Fri Jun 24 02:38:55 2022 -0700
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 <jenatali at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17230>
---
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
More information about the mesa-commit
mailing list