Mesa (main): panvk: Handle empty shaders gracefully

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Apr 25 16:49:43 UTC 2022


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

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Sat Apr 23 18:55:00 2022 -0400

panvk: Handle empty shaders gracefully

Fixes dEQP-VK.spirv_assembly.instruction.compute.shader_default_output.int.uninitialized

Signed-off-by: Alyssa Rosenzweig <alyssa at collabora.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16123>

---

 src/panfrost/ci/deqp-panfrost-g52-vk.toml |  1 +
 src/panfrost/vulkan/panvk_vX_pipeline.c   | 15 +++++++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/panfrost/ci/deqp-panfrost-g52-vk.toml b/src/panfrost/ci/deqp-panfrost-g52-vk.toml
index a223c499bc5..77db5a0a985 100644
--- a/src/panfrost/ci/deqp-panfrost-g52-vk.toml
+++ b/src/panfrost/ci/deqp-panfrost-g52-vk.toml
@@ -24,5 +24,6 @@ include = [
     "dEQP-VK.pipeline.input_assembly.*",
     "dEQP-VK.pipeline.sampler.view_type.*.format.r*.address_modes.all_mode_clamp_to_border*",
     "dEQP-VK.spirv_assembly.instruction.compute.opquantize.*",
+    "dEQP-VK.spirv_assembly.instruction.compute.shader_default_output.*",
     "dEQP-VK.ssbo.layout.single_basic_type.*",
 ]
diff --git a/src/panfrost/vulkan/panvk_vX_pipeline.c b/src/panfrost/vulkan/panvk_vX_pipeline.c
index 84860706b2a..8db64430db2 100644
--- a/src/panfrost/vulkan/panvk_vX_pipeline.c
+++ b/src/panfrost/vulkan/panvk_vX_pipeline.c
@@ -162,6 +162,12 @@ static VkResult
 panvk_pipeline_builder_upload_shaders(struct panvk_pipeline_builder *builder,
                                       struct panvk_pipeline *pipeline)
 {
+   /* In some cases, the optimized shader is empty. Don't bother allocating
+    * anything in this case.
+    */
+   if (builder->shader_total_size == 0)
+      return VK_SUCCESS;
+
    struct panfrost_bo *bin_bo =
       panfrost_bo_create(&builder->device->physical_device->pdev,
                          builder->shader_total_size, PAN_BO_EXECUTE,
@@ -335,8 +341,13 @@ panvk_pipeline_builder_init_shaders(struct panvk_pipeline_builder *builder,
       if (i == MESA_SHADER_VERTEX && shader->info.vs.writes_point_size)
          pipeline->ia.writes_point_size = true;
 
-      mali_ptr shader_ptr = pipeline->binary_bo->ptr.gpu +
-                            builder->stages[i].shader_offset;
+      mali_ptr shader_ptr = 0;
+
+      /* Handle empty shaders gracefully */
+      if (util_dynarray_num_elements(&builder->shaders[i]->binary, uint8_t)) {
+         shader_ptr = pipeline->binary_bo->ptr.gpu +
+                      builder->stages[i].shader_offset;
+      }
 
       void *rsd = pipeline->state_bo->ptr.cpu + builder->stages[i].rsd_offset;
       mali_ptr gpu_rsd = pipeline->state_bo->ptr.gpu + builder->stages[i].rsd_offset;



More information about the mesa-commit mailing list