aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/AtomicMinMaxS32Storage.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'src/Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/AtomicMinMaxS32Storage.glsl')
-rw-r--r--src/Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/AtomicMinMaxS32Storage.glsl21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/AtomicMinMaxS32Storage.glsl b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/AtomicMinMaxS32Storage.glsl
new file mode 100644
index 00000000..0862a71b
--- /dev/null
+++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/AtomicMinMaxS32Storage.glsl
@@ -0,0 +1,21 @@
+int Helper_AtomicMaxS32(int index, int offset, int value)
+{
+ uint oldValue, newValue;
+ do
+ {
+ oldValue = $STORAGE_MEM$[index].data[offset];
+ newValue = uint(max(int(oldValue), value));
+ } while (atomicCompSwap($STORAGE_MEM$[index].data[offset], oldValue, newValue) != oldValue);
+ return int(oldValue);
+}
+
+int Helper_AtomicMinS32(int index, int offset, int value)
+{
+ uint oldValue, newValue;
+ do
+ {
+ oldValue = $STORAGE_MEM$[index].data[offset];
+ newValue = uint(min(int(oldValue), value));
+ } while (atomicCompSwap($STORAGE_MEM$[index].data[offset], oldValue, newValue) != oldValue);
+ return int(oldValue);
+} \ No newline at end of file