Module: Mesa
Branch: master
Commit: 8b6bfed3d254f2652f7f416384e2f2ffc27dc8ba
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8b6bfed3d254f2652f7f416384e2f2ffc27dc8ba

Author: Pierre-Eric Pelloux-Prayer <[email protected]>
Date:   Fri Jul 12 15:54:17 2019 +0200

tgsi: add ATOMICINC_WRAP/ATOMICDEC_WRAP opcode

Reviewed-by: Marek Olšák <[email protected]>

---

 src/gallium/auxiliary/tgsi/tgsi_info.c           |  3 ++-
 src/gallium/auxiliary/tgsi/tgsi_info_opcodes.h   |  2 ++
 src/gallium/auxiliary/tgsi/tgsi_scan.c           |  2 ++
 src/gallium/docs/source/tgsi.rst                 | 30 ++++++++++++++++++++++++
 src/gallium/include/pipe/p_shader_tokens.h       |  5 +++-
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp       |  2 ++
 src/mesa/state_tracker/st_glsl_to_tgsi_private.h |  2 ++
 7 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.c 
b/src/gallium/auxiliary/tgsi/tgsi_info.c
index 37e16cca428..477876d7e52 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_info.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_info.c
@@ -263,7 +263,8 @@ tgsi_opcode_infer_src_type(enum tgsi_opcode opcode, uint 
src_idx)
       return TGSI_TYPE_UNSIGNED;
 
    if (src_idx == 1 &&
-       opcode >= TGSI_OPCODE_ATOMUADD && opcode <= TGSI_OPCODE_ATOMIMAX)
+       ((opcode >= TGSI_OPCODE_ATOMUADD && opcode <= TGSI_OPCODE_ATOMIMAX) ||
+       opcode == TGSI_OPCODE_ATOMINC_WRAP || opcode == 
TGSI_OPCODE_ATOMDEC_WRAP))
       return TGSI_TYPE_UNSIGNED;
 
    switch (opcode) {
diff --git a/src/gallium/auxiliary/tgsi/tgsi_info_opcodes.h 
b/src/gallium/auxiliary/tgsi/tgsi_info_opcodes.h
index f391b0cea6b..0b9b264bc53 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_info_opcodes.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_info_opcodes.h
@@ -250,3 +250,5 @@ OPCODE(1, 2, COMP, I64MOD)
 OPCODE(1, 2, COMP, U64MOD)
 OPCODE(1, 2, COMP, DDIV)
 OPCODE(1, 3, OTHR, LOD)
+OPCODE(1, 3, OTHR, ATOMINC_WRAP, .is_store = 1)
+OPCODE(1, 3, OTHR, ATOMDEC_WRAP, .is_store = 1)
diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c 
b/src/gallium/auxiliary/tgsi/tgsi_scan.c
index 37a223a0f68..3ed8d1a3ed3 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c
@@ -392,6 +392,8 @@ scan_instruction(struct tgsi_shader_info *info,
    case TGSI_OPCODE_ATOMIMIN:
    case TGSI_OPCODE_ATOMIMAX:
    case TGSI_OPCODE_ATOMFADD:
+   case TGSI_OPCODE_ATOMINC_WRAP:
+   case TGSI_OPCODE_ATOMDEC_WRAP:
       if (tgsi_is_bindless_image_file(fullinst->Src[0].Register.File)) {
          info->uses_bindless_images = true;
 
diff --git a/src/gallium/docs/source/tgsi.rst b/src/gallium/docs/source/tgsi.rst
index 59410cfd663..17ad097e85e 100644
--- a/src/gallium/docs/source/tgsi.rst
+++ b/src/gallium/docs/source/tgsi.rst
@@ -2834,6 +2834,36 @@ These atomic operations may only be used with 32-bit 
integer image formats.
   resource[offset] = (dst_x > src_x ? dst_x : src_x)
 
 
+.. opcode:: ATOMINC_WRAP - Atomic increment + wrap around
+
+  Syntax: ``ATOMINC_WRAP dst, resource, offset, src``
+
+  Example: ``ATOMINC_WRAP TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
+
+  The following operation is performed atomically:
+
+.. math::
+
+  dst_x = resource[offset] + 1
+
+  resource[offset] = dst_x < src_x ? dst_x : 0
+
+
+.. opcode:: ATOMDEC_WRAP - Atomic decrement + wrap around
+
+  Syntax: ``ATOMDEC_WRAP dst, resource, offset, src``
+
+  Example: ``ATOMDEC_WRAP TEMP[0], BUFFER[0], TEMP[1], TEMP[2]``
+
+  The following operation is performed atomically:
+
+.. math::
+
+  dst_x = resource[offset]
+
+  resource[offset] = (dst_x > 0 && dst_x < src_x) ? dst_x - 1 : 0
+
+
 .. _interlaneopcodes:
 
 Inter-lane opcodes
diff --git a/src/gallium/include/pipe/p_shader_tokens.h 
b/src/gallium/include/pipe/p_shader_tokens.h
index 8f290615c3f..e708f68745f 100644
--- a/src/gallium/include/pipe/p_shader_tokens.h
+++ b/src/gallium/include/pipe/p_shader_tokens.h
@@ -612,7 +612,10 @@ enum tgsi_opcode {
 
    TGSI_OPCODE_LOD                = 249,
 
-   TGSI_OPCODE_LAST               = 250,
+   TGSI_OPCODE_ATOMINC_WRAP       = 250,
+   TGSI_OPCODE_ATOMDEC_WRAP       = 251,
+
+   TGSI_OPCODE_LAST               = 252,
 };
 
 
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 3c6e9601655..ad5c2f5e623 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -6241,6 +6241,8 @@ compile_tgsi_instruction(struct st_translate *t,
    case TGSI_OPCODE_ATOMIMAX:
    case TGSI_OPCODE_ATOMFADD:
    case TGSI_OPCODE_IMG2HND:
+   case TGSI_OPCODE_ATOMINC_WRAP:
+   case TGSI_OPCODE_ATOMDEC_WRAP:
       for (i = num_src - 1; i >= 0; i--)
          src[i + 1] = src[i];
       num_src++;
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_private.h 
b/src/mesa/state_tracker/st_glsl_to_tgsi_private.h
index 6b5d8278027..939da3b6ae6 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi_private.h
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_private.h
@@ -182,6 +182,8 @@ is_resource_instruction(unsigned opcode)
    case TGSI_OPCODE_ATOMIMIN:
    case TGSI_OPCODE_ATOMIMAX:
    case TGSI_OPCODE_ATOMFADD:
+   case TGSI_OPCODE_ATOMINC_WRAP:
+   case TGSI_OPCODE_ATOMDEC_WRAP:
    case TGSI_OPCODE_IMG2HND:
       return true;
    default:

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to