aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/AtomicMinMaxS32Shared.glsl
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2021-01-26 03:38:33 -0300
committerGitHub <noreply@github.com>2021-01-26 17:38:33 +1100
commite453ba69f42057d36559b2c84b6ad9f01eaf4c86 (patch)
treec7c62a2f40a2197bc9e1a41ab1e45a1a5c93a382 /Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/AtomicMinMaxS32Shared.glsl
parentc19cfca183cbbae8091688a292242032c3f337cb (diff)
Add support for shader atomic min/max (S32) (#1948)
Diffstat (limited to 'Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/AtomicMinMaxS32Shared.glsl')
-rw-r--r--Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/AtomicMinMaxS32Shared.glsl21
1 files changed, 21 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/AtomicMinMaxS32Shared.glsl b/Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/AtomicMinMaxS32Shared.glsl
new file mode 100644
index 00000000..9f8c641d
--- /dev/null
+++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/AtomicMinMaxS32Shared.glsl
@@ -0,0 +1,21 @@
+int Helper_AtomicMaxS32(int offset, int value)
+{
+ uint oldValue, newValue;
+ do
+ {
+ oldValue = $SHARED_MEM$[offset];
+ newValue = uint(max(int(oldValue), value));
+ } while (atomicCompSwap($SHARED_MEM$[offset], newValue, oldValue) != oldValue);
+ return int(oldValue);
+}
+
+int Helper_AtomicMinS32(int offset, int value)
+{
+ uint oldValue, newValue;
+ do
+ {
+ oldValue = $SHARED_MEM$[offset];
+ newValue = uint(min(int(oldValue), value));
+ } while (atomicCompSwap($SHARED_MEM$[offset], newValue, oldValue) != oldValue);
+ return int(oldValue);
+} \ No newline at end of file