radv: use scoped barriers
authorRhys Perry <pendingchaos02@gmail.com>
Fri, 17 Jul 2020 18:17:10 +0000 (19:17 +0100)
committerMarge Bot <eric+marge@anholt.net>
Wed, 29 Jul 2020 17:57:13 +0000 (17:57 +0000)
fossil-db (LLVM, Navi):
Totals from 843 (0.62% of 135820) affected shaders:
SGPRs: 40456 -> 40480 (+0.06%); split: -0.10%, +0.16%
VGPRs: 39648 -> 39688 (+0.10%); split: -0.01%, +0.11%
CodeSize: 2936164 -> 2932508 (-0.12%); split: -0.21%, +0.09%
MaxWaves: 10828 -> 10827 (-0.01%)

fossil-db changes seem to be due to SPIR-V -> NIR emitting a workgroup
scope shared memory barrier instead of a group_memory_barrier.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5980>

src/amd/vulkan/radv_meta_fast_clear.c
src/amd/vulkan/radv_shader.c

index 45d15fd9e2bf9f8ee53c8add06df69f5d8f7ab74..bf9ed047c35623d236020c214d702220e7b88356 100644 (file)
@@ -83,11 +83,8 @@ build_dcc_decompress_compute_shader(struct radv_device *dev)
        nir_ssa_dest_init(&tex->instr, &tex->dest, 4, 32, "tex");
        nir_builder_instr_insert(&b, &tex->instr);
 
        nir_ssa_dest_init(&tex->instr, &tex->dest, 4, 32, "tex");
        nir_builder_instr_insert(&b, &tex->instr);
 
-       nir_intrinsic_instr *membar = nir_intrinsic_instr_create(b.shader, nir_intrinsic_memory_barrier);
-       nir_builder_instr_insert(&b, &membar->instr);
-
-       nir_intrinsic_instr *bar = nir_intrinsic_instr_create(b.shader, nir_intrinsic_control_barrier);
-       nir_builder_instr_insert(&b, &bar->instr);
+       nir_scoped_barrier(&b, NIR_SCOPE_WORKGROUP, NIR_SCOPE_WORKGROUP,
+                          NIR_MEMORY_ACQ_REL, nir_var_mem_ssbo);
 
        nir_ssa_def *outval = &tex->dest.ssa;
        nir_intrinsic_instr *store = nir_intrinsic_instr_create(b.shader, nir_intrinsic_image_deref_store);
 
        nir_ssa_def *outval = &tex->dest.ssa;
        nir_intrinsic_instr *store = nir_intrinsic_instr_create(b.shader, nir_intrinsic_image_deref_store);
index 810d4055186e2979dd2360ac010b1ca1780d7a21..e499e6ea2343079c6d3f6b0011e8470c89217019 100644 (file)
@@ -76,6 +76,7 @@ static const struct nir_shader_compiler_options nir_options_llvm = {
        .lower_fpow = true,
        .lower_mul_2x32_64 = true,
        .lower_rotate = true,
        .lower_fpow = true,
        .lower_mul_2x32_64 = true,
        .lower_rotate = true,
+       .use_scoped_barrier = true,
        .max_unroll_iterations = 32,
        .use_interpolated_input_intrinsics = true,
        /* nir_lower_int64() isn't actually called for the LLVM backend, but
        .max_unroll_iterations = 32,
        .use_interpolated_input_intrinsics = true,
        /* nir_lower_int64() isn't actually called for the LLVM backend, but
@@ -118,6 +119,7 @@ static const struct nir_shader_compiler_options nir_options_aco = {
        .lower_fpow = true,
        .lower_mul_2x32_64 = true,
        .lower_rotate = true,
        .lower_fpow = true,
        .lower_mul_2x32_64 = true,
        .lower_rotate = true,
+       .use_scoped_barrier = true,
        .max_unroll_iterations = 32,
        .use_interpolated_input_intrinsics = true,
        .lower_int64_options = nir_lower_imul64 |
        .max_unroll_iterations = 32,
        .use_interpolated_input_intrinsics = true,
        .lower_int64_options = nir_lower_imul64 |
@@ -130,7 +132,6 @@ static const struct nir_shader_compiler_options nir_options_aco = {
                                 nir_lower_dsqrt |
                                 nir_lower_drsq |
                                 nir_lower_ddiv,
                                 nir_lower_dsqrt |
                                 nir_lower_drsq |
                                 nir_lower_ddiv,
-       .use_scoped_barrier = true,
 };
 
 bool
 };
 
 bool