Mesa (main): freedreno/ir3: Enable load/store vectorization for SSBO access, too.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jun 1 23:05:10 UTC 2022


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

Author: Emma Anholt <emma at anholt.net>
Date:   Thu May 19 12:40:18 2022 -0700

freedreno/ir3: Enable load/store vectorization for SSBO access, too.

Saves a few ldib/stib instructions in gfxbench vk-5-normal compute shaders
by grouping vec4 accesses together.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16616>

---

 src/freedreno/ir3/ir3_compiler.c   | 2 +-
 src/freedreno/ir3/ir3_compiler.h   | 6 +++---
 src/freedreno/ir3/ir3_disk_cache.c | 2 +-
 src/freedreno/ir3/ir3_nir.c        | 4 ++--
 src/freedreno/vulkan/tu_device.c   | 2 +-
 src/freedreno/vulkan/tu_pipeline.c | 4 ++--
 6 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/freedreno/ir3/ir3_compiler.c b/src/freedreno/ir3/ir3_compiler.c
index 07b16044f2d..508be6ebd13 100644
--- a/src/freedreno/ir3/ir3_compiler.c
+++ b/src/freedreno/ir3/ir3_compiler.c
@@ -206,7 +206,7 @@ ir3_compiler_create(struct fd_device *dev, const struct fd_dev_id *dev_id,
    compiler->dev = dev;
    compiler->dev_id = dev_id;
    compiler->gen = fd_dev_gen(dev_id);
-   compiler->robust_ubo_access = options->robust_ubo_access;
+   compiler->robust_buffer_access2 = options->robust_buffer_access2;
 
    /* All known GPU's have 32k local memory (aka shared) */
    compiler->local_mem_size = 32 * 1024;
diff --git a/src/freedreno/ir3/ir3_compiler.h b/src/freedreno/ir3/ir3_compiler.h
index cebd3e45a50..cac4e6d0ec7 100644
--- a/src/freedreno/ir3/ir3_compiler.h
+++ b/src/freedreno/ir3/ir3_compiler.h
@@ -48,7 +48,7 @@ struct ir3_compiler {
 
    struct nir_shader_compiler_options nir_options;
 
-   bool robust_ubo_access;
+   bool robust_buffer_access2;
 
    /*
     * Configuration options for things that are handled differently on
@@ -187,10 +187,10 @@ struct ir3_compiler {
 };
 
 struct ir3_compiler_options {
-   /* If true, UBO accesses are assumed to be bounds-checked as defined by
+   /* If true, UBO/SSBO accesses are assumed to be bounds-checked as defined by
     * VK_EXT_robustness2 and optimizations may have to be more conservative.
     */
-   bool robust_ubo_access;
+   bool robust_buffer_access2;
 
    /* If true, promote UBOs (except for constant data) to constants using ldc.k
     * in the preamble. The driver should ignore everything in ubo_state except
diff --git a/src/freedreno/ir3/ir3_disk_cache.c b/src/freedreno/ir3/ir3_disk_cache.c
index 9dd6fbc6987..32accbcf422 100644
--- a/src/freedreno/ir3/ir3_disk_cache.c
+++ b/src/freedreno/ir3/ir3_disk_cache.c
@@ -63,7 +63,7 @@ ir3_disk_cache_init(struct ir3_compiler *compiler)
    _mesa_sha1_format(timestamp, id_sha1);
 
    uint64_t driver_flags = ir3_shader_debug;
-   if (compiler->robust_ubo_access)
+   if (compiler->robust_buffer_access2)
       driver_flags |= IR3_DBG_ROBUST_UBO_ACCESS;
    compiler->disk_cache = disk_cache_create(renderer, timestamp, driver_flags);
 }
diff --git a/src/freedreno/ir3/ir3_nir.c b/src/freedreno/ir3/ir3_nir.c
index 1c570a3d4f0..5bc960dc16b 100644
--- a/src/freedreno/ir3/ir3_nir.c
+++ b/src/freedreno/ir3/ir3_nir.c
@@ -134,9 +134,9 @@ ir3_optimize_loop(struct ir3_compiler *compiler, nir_shader *s)
       progress |= OPT(s, nir_opt_offsets, &offset_options);
 
       nir_load_store_vectorize_options vectorize_opts = {
-         .modes = nir_var_mem_ubo,
+         .modes = nir_var_mem_ubo | nir_var_mem_ssbo,
          .callback = ir3_nir_should_vectorize_mem,
-         .robust_modes = compiler->robust_ubo_access ? nir_var_mem_ubo : 0,
+         .robust_modes = compiler->robust_buffer_access2 ? nir_var_mem_ubo | nir_var_mem_ssbo: 0,
       };
       progress |= OPT(s, nir_opt_load_store_vectorize, &vectorize_opts);
 
diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c
index 803b66f999d..6388a25f448 100644
--- a/src/freedreno/vulkan/tu_device.c
+++ b/src/freedreno/vulkan/tu_device.c
@@ -1803,7 +1803,7 @@ tu_CreateDevice(VkPhysicalDevice physicalDevice,
    device->compiler =
       ir3_compiler_create(NULL, &physical_device->dev_id,
                           &(struct ir3_compiler_options) {
-                              .robust_ubo_access = robust_buffer_access2,
+                              .robust_buffer_access2 = robust_buffer_access2,
                               .push_ubo_with_preamble = true,
                               .disable_cache = true,
                            });
diff --git a/src/freedreno/vulkan/tu_pipeline.c b/src/freedreno/vulkan/tu_pipeline.c
index 4470a81b273..0a55e2c13ee 100644
--- a/src/freedreno/vulkan/tu_pipeline.c
+++ b/src/freedreno/vulkan/tu_pipeline.c
@@ -2512,8 +2512,8 @@ tu_hash_stage(struct mesa_sha1 *ctx,
 static void
 tu_hash_compiler(struct mesa_sha1 *ctx, const struct ir3_compiler *compiler)
 {
-   _mesa_sha1_update(ctx, &compiler->robust_ubo_access,
-                     sizeof(compiler->robust_ubo_access));
+   _mesa_sha1_update(ctx, &compiler->robust_buffer_access2,
+                     sizeof(compiler->robust_buffer_access2));
    _mesa_sha1_update(ctx, &ir3_shader_debug, sizeof(ir3_shader_debug));
 }
 



More information about the mesa-commit mailing list