Skip to content

Commit

Permalink
Add tests for GLSL atomics destination validation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aleino-nv committed Jan 16, 2025
1 parent 68af9b0 commit 797fade
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/glsl-intrinsic/atomic/invalidDestAdd.slang
Original file line number Diff line number Diff line change
@@ -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);
}
13 changes: 13 additions & 0 deletions tests/glsl-intrinsic/atomic/invalidDestAnd.slang
Original file line number Diff line number Diff line change
@@ -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);
}
13 changes: 13 additions & 0 deletions tests/glsl-intrinsic/atomic/invalidDestCompSwap.slang
Original file line number Diff line number Diff line change
@@ -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);
}
13 changes: 13 additions & 0 deletions tests/glsl-intrinsic/atomic/invalidDestExchange.slang
Original file line number Diff line number Diff line change
@@ -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);
}
13 changes: 13 additions & 0 deletions tests/glsl-intrinsic/atomic/invalidDestMax.slang
Original file line number Diff line number Diff line change
@@ -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);
}
13 changes: 13 additions & 0 deletions tests/glsl-intrinsic/atomic/invalidDestMin.slang
Original file line number Diff line number Diff line change
@@ -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);
}
13 changes: 13 additions & 0 deletions tests/glsl-intrinsic/atomic/invalidDestOr.slang
Original file line number Diff line number Diff line change
@@ -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);
}
13 changes: 13 additions & 0 deletions tests/glsl-intrinsic/atomic/invalidDestXor.slang
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 797fade

Please sign in to comment.