Mesa (main): nir: Move zero_initialize_shared_memory into common shader_info

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 8 18:11:20 UTC 2021


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

Author: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Date:   Wed May  5 09:34:46 2021 -0700

nir: Move zero_initialize_shared_memory into common shader_info

Move it out the "cs" sub-struct, since the bit will be used for other
shader stages in the future.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Timur Kristóf <timur.kristof at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11225>

---

 src/amd/vulkan/radv_shader.c       | 2 +-
 src/compiler/shader_info.h         | 7 +++++--
 src/compiler/spirv/vtn_variables.c | 2 +-
 src/intel/vulkan/anv_pipeline.c    | 2 +-
 4 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c
index 9c3940e3ffb..6d1cb023cca 100644
--- a/src/amd/vulkan/radv_shader.c
+++ b/src/amd/vulkan/radv_shader.c
@@ -648,7 +648,7 @@ radv_shader_compile_to_nir(struct radv_device *device, struct vk_shader_module *
       }
       NIR_PASS_V(nir, nir_lower_explicit_io, nir_var_mem_shared, nir_address_format_32bit_offset);
 
-      if (nir->info.cs.zero_initialize_shared_memory && nir->info.shared_size > 0) {
+      if (nir->info.zero_initialize_shared_memory && nir->info.shared_size > 0) {
          const unsigned chunk_size = 16; /* max single store size */
          const unsigned shared_size = ALIGN(nir->info.shared_size, chunk_size);
          NIR_PASS_V(nir, nir_zero_initialize_shared_memory, shared_size, chunk_size);
diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h
index b1800226c23..7c18e565433 100644
--- a/src/compiler/shader_info.h
+++ b/src/compiler/shader_info.h
@@ -254,6 +254,11 @@ typedef struct shader_info {
     */
    bool shared_memory_explicit_layout:1;
 
+   /**
+    * Used for VK_KHR_zero_initialize_workgroup_memory.
+    */
+   bool zero_initialize_shared_memory:1;
+
    union {
       struct {
          /* Which inputs are doubles */
@@ -396,8 +401,6 @@ typedef struct shader_info {
           */
          enum gl_derivative_group derivative_group:2;
 
-         bool zero_initialize_shared_memory;
-
          /**
           * pointer size is:
           *   AddressingModelLogical:    0    (default)
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index a93d3d52067..cc49564a20c 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -1960,7 +1960,7 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val,
                      "as initializer, but have %u instead",
                      vtn_id_for_value(b, val),
                      vtn_id_for_value(b, initializer));
-         b->shader->info.cs.zero_initialize_shared_memory = true;
+         b->shader->info.zero_initialize_shared_memory = true;
          break;
 
       case SpvStorageClassUniformConstant:
diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c
index e0c147cf153..3eb75f725e2 100644
--- a/src/intel/vulkan/anv_pipeline.c
+++ b/src/intel/vulkan/anv_pipeline.c
@@ -1808,7 +1808,7 @@ anv_pipeline_compile_cs(struct anv_compute_pipeline *pipeline,
       NIR_PASS_V(stage.nir, nir_lower_explicit_io,
                  nir_var_mem_shared, nir_address_format_32bit_offset);
 
-      if (stage.nir->info.cs.zero_initialize_shared_memory &&
+      if (stage.nir->info.zero_initialize_shared_memory &&
           stage.nir->info.shared_size > 0) {
          /* The effective Shared Local Memory size is at least 1024 bytes and
           * is always rounded to a power of two, so it is OK to align the size



More information about the mesa-commit mailing list