From 03a5bb4bc0391e2de3c2dfb9ff3213bc0ccd9664 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 9 Aug 2023 10:54:41 -0700 Subject: 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 --- tests/bugs/buffer-swizzle-store.slang | 16 ++++++++++++++++ tests/bugs/buffer-swizzle-store.slang.expected.txt | 2 ++ tests/bugs/interlocked-add-uint-int.slang | 19 +++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 tests/bugs/buffer-swizzle-store.slang create mode 100644 tests/bugs/buffer-swizzle-store.slang.expected.txt create mode 100644 tests/bugs/interlocked-add-uint-int.slang (limited to 'tests') 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 g_test; + +//TEST_INPUT:ubuffer(data=[0], stride=4):out,name outputBuffer +RWStructuredBuffer 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 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 -- cgit v1.2.3