Mesa (master): anv: Fix UBO range detection in anv_nir_compute_push_layout

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Apr 15 22:01:10 UTC 2020


Module: Mesa
Branch: master
Commit: 26a1adce5bd2f0e44900f21e58ea09fea9f6690f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=26a1adce5bd2f0e44900f21e58ea09fea9f6690f

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Fri Apr  3 12:38:32 2020 -0500

anv: Fix UBO range detection in anv_nir_compute_push_layout

This fixes two bugs:  First, if the same block index showed up twice, we
only pick the first one.  Second, we weren't multiplying by 32.  This
didn't show up in tests because RBA testing is garbage.  Found while
looking at shaders from the UE4 Shooter demo.

Fixes: e03f9652 "anv: Bounds-check pushed UBOs when..."
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4578>

---

 src/intel/vulkan/anv_nir_compute_push_layout.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/src/intel/vulkan/anv_nir_compute_push_layout.c b/src/intel/vulkan/anv_nir_compute_push_layout.c
index 3f9572644df..960fb1ca4a3 100644
--- a/src/intel/vulkan/anv_nir_compute_push_layout.c
+++ b/src/intel/vulkan/anv_nir_compute_push_layout.c
@@ -208,8 +208,11 @@ anv_nir_compute_push_layout(const struct anv_physical_device *pdevice,
 
                   int ubo_range_idx = -1;
                   for (unsigned i = 0; i < 4; i++) {
-                     if (prog_data->ubo_ranges[i].length > 0 &&
-                         prog_data->ubo_ranges[i].block == index) {
+                     const struct brw_ubo_range *range =
+                        &prog_data->ubo_ranges[i];
+                     if (range->block == index &&
+                         offset + size > range->start * 32 &&
+                         offset < (range->start + range->length) * 32) {
                         ubo_range_idx = i;
                         break;
                      }
@@ -218,14 +221,6 @@ anv_nir_compute_push_layout(const struct anv_physical_device *pdevice,
                   if (ubo_range_idx < 0)
                      break;
 
-                  const struct brw_ubo_range *range =
-                     &prog_data->ubo_ranges[ubo_range_idx];
-                  const uint32_t range_end =
-                     (range->start + range->length) * 32;
-
-                  if (range_end < offset || offset + size <= range->start)
-                     break;
-
                   b.cursor = nir_after_instr(&intrin->instr);
 
                   assert(push_range_idx_map[ubo_range_idx] >= 0);



More information about the mesa-commit mailing list