Module: Mesa
Branch: main
Commit: 7adb40cfaa87c9c8c3c969c8edf415dcbc694fdc
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7adb40cfaa87c9c8c3c969c8edf415dcbc694fdc

Author: M Henning <[email protected]>
Date:   Thu Nov 23 15:47:44 2023 -0500

nvk: Fix descriptor alignment offset

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26347>

---

 src/nouveau/vulkan/nvk_nir_lower_descriptors.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/nouveau/vulkan/nvk_nir_lower_descriptors.c 
b/src/nouveau/vulkan/nvk_nir_lower_descriptors.c
index e2a29f77e0b..2fb268e21c7 100644
--- a/src/nouveau/vulkan/nvk_nir_lower_descriptors.c
+++ b/src/nouveau/vulkan/nvk_nir_lower_descriptors.c
@@ -105,15 +105,17 @@ load_descriptor(nir_builder *b, unsigned num_components, 
unsigned bit_size,
          nir_iadd_imm(b, nir_imul_imm(b, index, binding_layout->stride),
                          binding_layout->offset + offset_B);
 
-      unsigned desc_align = (1 << (ffs(binding_layout->stride) - 1));
-      desc_align = MIN2(desc_align, 16);
+      unsigned desc_align_mul = (1 << (ffs(binding_layout->stride) - 1));
+      desc_align_mul = MIN2(desc_align_mul, 16);
+      unsigned desc_align_offset = binding_layout->offset + offset_B;
+      desc_align_offset %= desc_align_mul;
 
       nir_def *set_addr = load_descriptor_set_addr(b, set, ctx);
       nir_def *desc =
          nir_load_global_constant_offset(b, num_components, bit_size,
                                          set_addr, desc_ubo_offset,
-                                         .align_mul = desc_align,
-                                         .align_offset = 0);
+                                         .align_mul = desc_align_mul,
+                                         .align_offset = desc_align_offset);
       if (binding_layout->type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER ||
           binding_layout->type == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) {
          /* We know a priori that the the .w compnent (offset) is zero */

Reply via email to