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

Author: Roland Scheidegger <[email protected]>
Date:   Thu Feb 23 23:08:10 2023 +0100

lavapipe, nir: Fix wrong array index scaling in nir_collect_src_uniforms

The scaling needs to be ubo * MAX_INLINABLE_UNIFORMS, not
ubo * PIPE_MAX_CONSTANT_BUFFERS, otherwise accesses beyond buffer size
will result for ubo >= 4 (and we'd also access the wrong values later
for other non-zero ubo indices).

Fixes: a7696a4d98bc ("lavapipe: Fix bad array index scale factor in 
lvp_inline_uniforms pass")
Reviewed-by: Ian Romanick <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21506>

---

 src/compiler/nir/nir_inline_uniforms.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/compiler/nir/nir_inline_uniforms.c 
b/src/compiler/nir/nir_inline_uniforms.c
index 9194c200486..10dcc231638 100644
--- a/src/compiler/nir/nir_inline_uniforms.c
+++ b/src/compiler/nir/nir_inline_uniforms.c
@@ -148,7 +148,7 @@ nir_collect_src_uniforms(const nir_src *src, int component,
 
          /* Already recorded by other one */
          for (int i = 0; i < num_offsets[ubo]; i++) {
-            if (uni_offsets[ubo * MAX_NUM_BO + i] == offset)
+            if (uni_offsets[ubo * MAX_INLINABLE_UNIFORMS + i] == offset)
                return true;
          }
 
@@ -157,7 +157,7 @@ nir_collect_src_uniforms(const nir_src *src, int component,
             return false;
 
          /* Record the uniform offset. */
-         uni_offsets[ubo * MAX_NUM_BO + num_offsets[ubo]++] = offset;
+         uni_offsets[ubo * MAX_INLINABLE_UNIFORMS + num_offsets[ubo]++] = 
offset;
          return true;
       }
       return false;

Reply via email to