nir/opt_uniform_atomics: optimize image atomics
authorRhys Perry <pendingchaos02@gmail.com>
Tue, 1 Sep 2020 16:40:32 +0000 (17:40 +0100)
committerMarge Bot <eric+marge@anholt.net>
Tue, 13 Oct 2020 12:47:21 +0000 (12:47 +0000)
fossil-db (Navi):
Totals from 65 (0.05% of 135946) affected shaders:
SGPRs: 3792 -> 3784 (-0.21%)
VGPRs: 2784 -> 2716 (-2.44%)
CodeSize: 707492 -> 713080 (+0.79%)
MaxWaves: 873 -> 887 (+1.60%)
Instrs: 133376 -> 134524 (+0.86%)
Cycles: 3004772 -> 3011440 (+0.22%)

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

src/compiler/nir/nir_opt_uniform_atomics.c

index cb21ff9..91abf67 100644 (file)
@@ -43,7 +43,7 @@ static nir_op
 parse_atomic_op(nir_intrinsic_op op, unsigned *offset_src, unsigned *data_src)
 {
    switch (op) {
-   #define OP(intrin, alu) \
+   #define OP_NOIMG(intrin, alu) \
    case nir_intrinsic_ssbo_atomic_##intrin: \
       *offset_src = 1; \
       *data_src = 2; \
@@ -56,6 +56,14 @@ parse_atomic_op(nir_intrinsic_op op, unsigned *offset_src, unsigned *data_src)
       return nir_op_##alu; \
       return nir_op_##alu; \
       return nir_op_##alu;
+   #define OP(intrin, alu) \
+   OP_NOIMG(intrin, alu) \
+   case nir_intrinsic_image_deref_atomic_##intrin: \
+   case nir_intrinsic_image_atomic_##intrin: \
+   case nir_intrinsic_bindless_image_atomic_##intrin: \
+      *offset_src = 1; \
+      *data_src = 3; \
+      return nir_op_##alu;
    OP(add, iadd)
    OP(imin, imin)
    OP(umin, umin)
@@ -65,8 +73,9 @@ parse_atomic_op(nir_intrinsic_op op, unsigned *offset_src, unsigned *data_src)
    OP(or, ior)
    OP(xor, ixor)
    OP(fadd, fadd)
-   OP(fmin, fmin)
-   OP(fmax, fmax)
+   OP_NOIMG(fmin, fmin)
+   OP_NOIMG(fmax, fmax)
+   #undef OP_NOIMG
    #undef OP
    default:
       return nir_num_opcodes;