summaryrefslogtreecommitdiffstats
path: root/tests/bugs
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2023-07-05 14:24:05 -0400
committerGitHub <noreply@github.com>2023-07-05 14:24:05 -0400
commit93948b564d04eda555bf96025e89853be86cff8a (patch)
tree835cc1379c49113fba40bd864174ca418c56298d /tests/bugs
parent69450a2be7575aa4f984b9ae2824da0e5634c9f0 (diff)
Disable l-value coercion for ref types (#2960)
* Make lvalue coercion not work for ref, to stop problem with atomics (for GLSL output). * Improve some comments.
Diffstat (limited to 'tests/bugs')
-rw-r--r--tests/bugs/atomic-coerce.slang27
-rw-r--r--tests/bugs/atomic-coerce.slang.expected.txt4
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/bugs/atomic-coerce.slang b/tests/bugs/atomic-coerce.slang
new file mode 100644
index 000000000..1e56a8d25
--- /dev/null
+++ b/tests/bugs/atomic-coerce.slang
@@ -0,0 +1,27 @@
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
+//TEST(compute,vulkan):COMPARE_COMPUTE_EX:-vk -slang -compute -shaderobj
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0 ], stride=4):out,name outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+groupshared uint gs_values[2];
+
+[shader("compute")]
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int index = (int)dispatchThreadID.x;
+
+ // Initialize first
+ if (index < 2)
+ {
+ gs_values[index] = 2;
+ }
+
+ GroupMemoryBarrierWithGroupSync();
+
+ // NOTE! We have to cast to uint, to make atomic work
+ InterlockedAdd(gs_values[index & 1], uint(index * index));
+
+ outputBuffer[index] = gs_values[index & 1];
+}
diff --git a/tests/bugs/atomic-coerce.slang.expected.txt b/tests/bugs/atomic-coerce.slang.expected.txt
new file mode 100644
index 000000000..9f774a3a1
--- /dev/null
+++ b/tests/bugs/atomic-coerce.slang.expected.txt
@@ -0,0 +1,4 @@
+6
+C
+6
+C