From 797fadefb7e41972324dc76c7576f0eae5f54c82 Mon Sep 17 00:00:00 2001 From: Anders Leino Date: Wed, 15 Jan 2025 14:28:18 +0200 Subject: [PATCH] Add tests for GLSL atomics destination validation Attempting to use the GLSL atomic functions on destinations that are neither groupshared nor from a device buffer should fail with the following error: error 41403: cannot perform atomic operation because destination is neither groupshared nor from a device buffer. --- tests/glsl-intrinsic/atomic/invalidDestAdd.slang | 13 +++++++++++++ tests/glsl-intrinsic/atomic/invalidDestAnd.slang | 13 +++++++++++++ .../glsl-intrinsic/atomic/invalidDestCompSwap.slang | 13 +++++++++++++ .../glsl-intrinsic/atomic/invalidDestExchange.slang | 13 +++++++++++++ tests/glsl-intrinsic/atomic/invalidDestMax.slang | 13 +++++++++++++ tests/glsl-intrinsic/atomic/invalidDestMin.slang | 13 +++++++++++++ tests/glsl-intrinsic/atomic/invalidDestOr.slang | 13 +++++++++++++ tests/glsl-intrinsic/atomic/invalidDestXor.slang | 13 +++++++++++++ 8 files changed, 104 insertions(+) create mode 100644 tests/glsl-intrinsic/atomic/invalidDestAdd.slang create mode 100644 tests/glsl-intrinsic/atomic/invalidDestAnd.slang create mode 100644 tests/glsl-intrinsic/atomic/invalidDestCompSwap.slang create mode 100644 tests/glsl-intrinsic/atomic/invalidDestExchange.slang create mode 100644 tests/glsl-intrinsic/atomic/invalidDestMax.slang create mode 100644 tests/glsl-intrinsic/atomic/invalidDestMin.slang create mode 100644 tests/glsl-intrinsic/atomic/invalidDestOr.slang create mode 100644 tests/glsl-intrinsic/atomic/invalidDestXor.slang diff --git a/tests/glsl-intrinsic/atomic/invalidDestAdd.slang b/tests/glsl-intrinsic/atomic/invalidDestAdd.slang new file mode 100644 index 0000000000..47e1015d88 --- /dev/null +++ b/tests/glsl-intrinsic/atomic/invalidDestAdd.slang @@ -0,0 +1,13 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target glsl -DTARGET_GLSL +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target spirv -emit-spirv-directly -DTARGET_SPIRV +#version 430 + +// CHECK: error 41403 + +uint notShared; + +void computeMain() +{ + // error 41403: cannot perform atomic operation because destination is neither groupshared nor from a device buffer. + atomicAdd(notShared, 1u); +} diff --git a/tests/glsl-intrinsic/atomic/invalidDestAnd.slang b/tests/glsl-intrinsic/atomic/invalidDestAnd.slang new file mode 100644 index 0000000000..c71a8ba425 --- /dev/null +++ b/tests/glsl-intrinsic/atomic/invalidDestAnd.slang @@ -0,0 +1,13 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target glsl -DTARGET_GLSL +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target spirv -emit-spirv-directly -DTARGET_SPIRV +#version 430 + +// CHECK: error 41403 + +uint notShared; + +void computeMain() +{ + // error 41403: cannot perform atomic operation because destination is neither groupshared nor from a device buffer. + atomicAnd(notShared, 1u); +} diff --git a/tests/glsl-intrinsic/atomic/invalidDestCompSwap.slang b/tests/glsl-intrinsic/atomic/invalidDestCompSwap.slang new file mode 100644 index 0000000000..e5be47617b --- /dev/null +++ b/tests/glsl-intrinsic/atomic/invalidDestCompSwap.slang @@ -0,0 +1,13 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target glsl -DTARGET_GLSL +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target spirv -emit-spirv-directly -DTARGET_SPIRV +#version 430 + +// CHECK: error 41403 + +uint notShared; + +void computeMain() +{ + // error 41403: cannot perform atomic operation because destination is neither groupshared nor from a device buffer. + atomicCompSwap(notShared, 1u, 2u); +} diff --git a/tests/glsl-intrinsic/atomic/invalidDestExchange.slang b/tests/glsl-intrinsic/atomic/invalidDestExchange.slang new file mode 100644 index 0000000000..e2d8b9cb50 --- /dev/null +++ b/tests/glsl-intrinsic/atomic/invalidDestExchange.slang @@ -0,0 +1,13 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target glsl -DTARGET_GLSL +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target spirv -emit-spirv-directly -DTARGET_SPIRV +#version 430 + +// CHECK: error 41403 + +uint notShared; + +void computeMain() +{ + // error 41403: cannot perform atomic operation because destination is neither groupshared nor from a device buffer. + atomicExchange(notShared, 1u); +} diff --git a/tests/glsl-intrinsic/atomic/invalidDestMax.slang b/tests/glsl-intrinsic/atomic/invalidDestMax.slang new file mode 100644 index 0000000000..d6d79bd077 --- /dev/null +++ b/tests/glsl-intrinsic/atomic/invalidDestMax.slang @@ -0,0 +1,13 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target glsl -DTARGET_GLSL +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target spirv -emit-spirv-directly -DTARGET_SPIRV +#version 430 + +// CHECK: error 41403 + +uint notShared; + +void computeMain() +{ + // error 41403: cannot perform atomic operation because destination is neither groupshared nor from a device buffer. + atomicMax(notShared, 1u); +} diff --git a/tests/glsl-intrinsic/atomic/invalidDestMin.slang b/tests/glsl-intrinsic/atomic/invalidDestMin.slang new file mode 100644 index 0000000000..2ffdf133a1 --- /dev/null +++ b/tests/glsl-intrinsic/atomic/invalidDestMin.slang @@ -0,0 +1,13 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target glsl -DTARGET_GLSL +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target spirv -emit-spirv-directly -DTARGET_SPIRV +#version 430 + +// CHECK: error 41403 + +uint notShared; + +void computeMain() +{ + // error 41403: cannot perform atomic operation because destination is neither groupshared nor from a device buffer. + atomicMin(notShared, 1u); +} diff --git a/tests/glsl-intrinsic/atomic/invalidDestOr.slang b/tests/glsl-intrinsic/atomic/invalidDestOr.slang new file mode 100644 index 0000000000..e936adbecb --- /dev/null +++ b/tests/glsl-intrinsic/atomic/invalidDestOr.slang @@ -0,0 +1,13 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target glsl -DTARGET_GLSL +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target spirv -emit-spirv-directly -DTARGET_SPIRV +#version 430 + +// CHECK: error 41403 + +uint notShared; + +void computeMain() +{ + // error 41403: cannot perform atomic operation because destination is neither groupshared nor from a device buffer. + atomicOr(notShared, 1u); +} diff --git a/tests/glsl-intrinsic/atomic/invalidDestXor.slang b/tests/glsl-intrinsic/atomic/invalidDestXor.slang new file mode 100644 index 0000000000..327f935625 --- /dev/null +++ b/tests/glsl-intrinsic/atomic/invalidDestXor.slang @@ -0,0 +1,13 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target glsl -DTARGET_GLSL +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target spirv -emit-spirv-directly -DTARGET_SPIRV +#version 430 + +// CHECK: error 41403 + +uint notShared; + +void computeMain() +{ + // error 41403: cannot perform atomic operation because destination is neither groupshared nor from a device buffer. + atomicXor(notShared, 1u); +}