From ebe8ddefc48478307d5f206cd3e40c41d28a36e3 Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 26 Sep 2023 23:56:06 -0700 Subject: Various SPIRV fixes. (#3231) * Various SPIRV fixes. - Geometry shader support (WIP). - Fix texture get dimension and load. - Fold global GetElement(MakeArray/MakeVector) insts. - Call spvopt to inline all functions. - Translate OpImageSubscript. - Emit struct member names and global variable names. - Fix lowering of OpBitNot -> OpNot, instead of OpBitReverse. * Fix test. * Fix geometry shader. * Fix geometry shader emit. * Add atomic Image access test. * Fix tests. * don't fail if spirv-opt fails. * Update comments. * Fix test. * Cleanups. * indentation --------- Co-authored-by: Yong He Co-authored-by: Ellie Hermaszewska --- tests/spirv/atomic-image-access.slang | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/spirv/atomic-image-access.slang (limited to 'tests/spirv/atomic-image-access.slang') diff --git a/tests/spirv/atomic-image-access.slang b/tests/spirv/atomic-image-access.slang new file mode 100644 index 000000000..1fc7cd28f --- /dev/null +++ b/tests/spirv/atomic-image-access.slang @@ -0,0 +1,24 @@ +// atomic-image-access.slang +//TEST:SIMPLE(filecheck=CHECK): -target spirv -entry computeMain -stage compute -emit-spirv-directly + +// The executable test is disabled because it somehow doesn't work. Might be a gfx issue. +//TEST_DISABLED(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUFFER):-vk -compute -output-using-type + +// Test direct SPIR-V emit on image atomics. + +//TEST_INPUT:set resultBuffer = out ubuffer(data=[0 0 0 0], stride=4) +RWStructuredBuffer resultBuffer; + +// TEST_INPUT: set tex = RWTexture2D(format=R32_UINT, size=4, content=zero, mipMaps = 1) +[vk::image_format("r32ui")] +RWTexture2D tex; + +[numthreads(1,1,1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + // CHECK: OpImageTexelPointer + InterlockedAdd(tex[uint2(0, 0)], 1); + uint oldVal; + InterlockedAdd(tex[uint2(0, 0)], 1, oldVal); + resultBuffer[0] = oldVal; +} -- cgit v1.2.3