From 15f3274ea6150ee1b778b9e891269692496cab19 Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Tue, 26 Jul 2022 12:20:16 +0200 Subject: [PATCH] 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: --- src/freedreno/vulkan/tu_pipeline.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/freedreno/vulkan/tu_pipeline.c b/src/freedreno/vulkan/tu_pipeline.c index e5d15bb8478..d2391d19fef 100644 --- a/src/freedreno/vulkan/tu_pipeline.c +++ b/src/freedreno/vulkan/tu_pipeline.c @@ -150,6 +150,15 @@ tu6_emit_load_state(struct tu_pipeline *pipeline, */ VkShaderStageFlags stages = pipeline->active_stages & binding->shader_stages; 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) {