Module: Mesa
Branch: staging/22.2
Commit: 5b6aa0c7ee1912c81043cef41df0116b871906dc
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5b6aa0c7ee1912c81043cef41df0116b871906dc

Author: Connor Abbott <[email protected]>
Date:   Tue Jul 26 12:20:16 2022 +0200

tu: Don't preload variable-count descriptors

We don't know how many descriptors will actually be valid, which could
lead to preloading descriptors out-of-bounds of the descriptor size.
This was leading to GPU hangs on some tests once we enabled inline
uniforms.

Fixes: d9fcf5de55a ("turnip: Enable nonuniform descriptor indexing")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17960>
(cherry picked from commit 15f3274ea6150ee1b778b9e891269692496cab19)

---

 .pick_status.json                  | 2 +-
 src/freedreno/vulkan/tu_pipeline.c | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/.pick_status.json b/.pick_status.json
index 53d4ea70ad0..2cbd12eefb4 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -166,7 +166,7 @@
         "description": "tu: Don't preload variable-count descriptors",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "d9fcf5de55a7104037823e62284ace8a206c8898"
     },
diff --git a/src/freedreno/vulkan/tu_pipeline.c 
b/src/freedreno/vulkan/tu_pipeline.c
index 73d90cebc12..8d406e0f23e 100644
--- a/src/freedreno/vulkan/tu_pipeline.c
+++ b/src/freedreno/vulkan/tu_pipeline.c
@@ -157,6 +157,15 @@ tu6_emit_load_state(struct tu_pipeline *pipeline,
             binding->shader_stages & VK_SHADER_STAGE_COMPUTE_BIT :
             binding->shader_stages & VK_SHADER_STAGE_ALL_GRAPHICS;
          unsigned count = binding->array_size;
+
+         /* If this is a variable-count descriptor, then the array_size is an
+          * upper bound on the size, but we don't know how many descriptors
+          * will actually be used. Therefore we can't pre-load them here.
+          */
+         if (j == set_layout->binding_count - 1 &&
+             set_layout->has_variable_descriptors)
+            continue;
+
          if (count == 0 || stages == 0)
             continue;
          switch (binding->type) {

Reply via email to