summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-08-09 10:54:41 -0700
committerGitHub <noreply@github.com>2023-08-09 10:54:41 -0700
commit03a5bb4bc0391e2de3c2dfb9ff3213bc0ccd9664 (patch)
tree8bdc7fbf12777c2efe68e677f6802afdb70ba8fc /tests
parentc4615fe0ae7e1849b23e9a96d1453794b0b40e90 (diff)
Various fixes in GLSL emit. (#3074)
* Fix name mangling of modified types. * Add `InterlockedAdd(__ref uint, int)` overload. * Fix. * Fix type error in ImageStore legalization. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs/buffer-swizzle-store.slang16
-rw-r--r--tests/bugs/buffer-swizzle-store.slang.expected.txt2
-rw-r--r--tests/bugs/interlocked-add-uint-int.slang19
3 files changed, 37 insertions, 0 deletions
diff --git a/tests/bugs/buffer-swizzle-store.slang b/tests/bugs/buffer-swizzle-store.slang
new file mode 100644
index 000000000..ca09cded9
--- /dev/null
+++ b/tests/bugs/buffer-swizzle-store.slang
@@ -0,0 +1,16 @@
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type
+
+//TEST_INPUT: RWTexture2D(format=R16G16_FLOAT, size=4, content = one, mipMaps = 1):name g_test
+[format("rg16f")]
+RWTexture2D<float2> g_test;
+
+//TEST_INPUT:ubuffer(data=[0], stride=4):out,name outputBuffer
+RWStructuredBuffer<float> outputBuffer;
+
+[numthreads(1,1,1)]
+void computeMain( uint2 dispatchThreadID : SV_DispatchThreadID )
+{
+ g_test[dispatchThreadID].xy = float2(0.0, 1.0);
+ outputBuffer[dispatchThreadID.x] = g_test[dispatchThreadID].y;
+} \ No newline at end of file
diff --git a/tests/bugs/buffer-swizzle-store.slang.expected.txt b/tests/bugs/buffer-swizzle-store.slang.expected.txt
new file mode 100644
index 000000000..eddb06a2a
--- /dev/null
+++ b/tests/bugs/buffer-swizzle-store.slang.expected.txt
@@ -0,0 +1,2 @@
+type: float
+1.0 \ No newline at end of file
diff --git a/tests/bugs/interlocked-add-uint-int.slang b/tests/bugs/interlocked-add-uint-int.slang
new file mode 100644
index 000000000..10baa7f17
--- /dev/null
+++ b/tests/bugs/interlocked-add-uint-int.slang
@@ -0,0 +1,19 @@
+//TEST:SIMPLE(filecheck=CHECK): -target spirv -profile glsl_450 -stage compute -entry MainCs -line-directive-mode none
+//CHECK: {{.*}} AtomicIAdd
+RWBuffer<uint> g_InterlockTest;
+
+[numthreads(1,1,1)]
+void MainCs( uint2 dispatchThreadID : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID )
+{
+ uint nVertexCount = 41;
+ uint nVertexBufferSize = 40;
+ uint nVertex = 3;
+
+ InterlockedAdd( g_InterlockTest[ 0 ], nVertexCount, nVertex );
+
+ // Did we overflow?
+ if ( nVertex + nVertexCount > nVertexBufferSize )
+ {
+ InterlockedAdd( g_InterlockTest[ 0 ], -int(nVertexCount) );
+ }
+} \ No newline at end of file