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

Author: Alyssa Rosenzweig <[email protected]>
Date:   Sat Apr 23 19:04:43 2022 -0400

panvk: Lower shared memory

Copy the code. Fixes workgroup tests, now compute kernels should work properly
on Bifrost.

Signed-off-by: Alyssa Rosenzweig <[email protected]>
Reviewed-by: Jason Ekstrand <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16123>

---

 src/panfrost/ci/deqp-panfrost-g52-vk.toml |  1 +
 src/panfrost/ci/panfrost-g52-skips.txt    |  5 +++++
 src/panfrost/vulkan/panvk_vX_shader.c     | 28 ++++++++++++++++++++++++++++
 3 files changed, 34 insertions(+)

diff --git a/src/panfrost/ci/deqp-panfrost-g52-vk.toml 
b/src/panfrost/ci/deqp-panfrost-g52-vk.toml
index 77db5a0a985..9e2aa791a87 100644
--- a/src/panfrost/ci/deqp-panfrost-g52-vk.toml
+++ b/src/panfrost/ci/deqp-panfrost-g52-vk.toml
@@ -25,5 +25,6 @@ include = [
     
"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.spirv_assembly.instruction.compute.workgroup_memory.*",
     "dEQP-VK.ssbo.layout.single_basic_type.*",
 ]
diff --git a/src/panfrost/ci/panfrost-g52-skips.txt 
b/src/panfrost/ci/panfrost-g52-skips.txt
index 2ec440005b7..f3c7ea846d9 100644
--- a/src/panfrost/ci/panfrost-g52-skips.txt
+++ b/src/panfrost/ci/panfrost-g52-skips.txt
@@ -17,3 +17,8 @@ 
KHR-GLES31.core.draw_indirect.advanced-twoPass-transformFeedback-elements
 # fail seen here and in others
 # https://gitlab.freedesktop.org/mesa/mesa/-/jobs/19776551
 dEQP-GLES31.functional.ssbo.layout.random.all_shared_buffer.36
+
+# InternalError (Variable pointers requested but feature not returned at
+# vktAmberTestCase.cpp:364)
+dEQP-VK.spirv_assembly.instruction.compute.vector_shuffle.vector_shuffle
+
diff --git a/src/panfrost/vulkan/panvk_vX_shader.c 
b/src/panfrost/vulkan/panvk_vX_shader.c
index 7830b6fd4c9..6170ae3d3fd 100644
--- a/src/panfrost/vulkan/panvk_vX_shader.c
+++ b/src/panfrost/vulkan/panvk_vX_shader.c
@@ -4,6 +4,9 @@
  * Derived from tu_shader.c which is:
  * Copyright © 2019 Google LLC
  *
+ * Also derived from anv_pipeline.c which is
+ * Copyright © 2015 Intel Corporation
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
  * to deal in the Software without restriction, including without limitation
@@ -493,6 +496,18 @@ panvk_lower_load_push_constant(nir_builder *b, nir_instr 
*instr, void *data)
    return true;
 }
 
+static void
+shared_type_info(const struct glsl_type *type, unsigned *size, unsigned *align)
+{
+   assert(glsl_type_is_vector_or_scalar(type));
+
+   uint32_t comp_size = glsl_type_is_boolean(type)
+      ? 4 : glsl_get_bit_size(type) / 8;
+   unsigned length = glsl_get_vector_elements(type);
+   *size = comp_size * length,
+   *align = comp_size * (length == 3 ? 4 : length);
+}
+
 struct panvk_shader *
 panvk_per_arch(shader_create)(struct panvk_device *dev,
                               gl_shader_stage stage,
@@ -567,6 +582,19 @@ panvk_per_arch(shader_create)(struct panvk_device *dev,
    NIR_PASS_V(nir, nir_lower_explicit_io,
               nir_var_mem_push_const,
               nir_address_format_32bit_offset);
+
+   if (gl_shader_stage_uses_workgroup(stage)) {
+      if (!nir->info.shared_memory_explicit_layout) {
+         NIR_PASS_V(nir, nir_lower_vars_to_explicit_types,
+                    nir_var_mem_shared,
+                    shared_type_info);
+      }
+
+      NIR_PASS_V(nir, nir_lower_explicit_io,
+                 nir_var_mem_shared,
+                 nir_address_format_32bit_offset);
+   }
+
    NIR_PASS_V(nir, nir_shader_instructions_pass,
               panvk_lower_load_push_constant,
               nir_metadata_block_index |

Reply via email to