yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Simon Kallweitupdate slang-rhi (#6587)ae1a5e408

master
885 B24 linesraw
1// atomic-image-access.slang
2//TEST:SIMPLE(filecheck=CHECK): -target spirv -entry computeMain -stage compute -emit-spirv-directly
3
4// The executable test is disabled because it somehow doesn't work. Might be a gfx issue.
5//TEST_DISABLED(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUFFER):-vk -compute -output-using-type
6
7// Test direct SPIR-V emit on image atomics.
8
9//TEST_INPUT:set resultBuffer = out ubuffer(data=[0 0 0 0], stride=4)
10RWStructuredBuffer<uint> resultBuffer;
11
12// TEST_INPUT: set tex = RWTexture2D(format=R32Uint, size=4, content=zero, mipMaps = 1)
13[vk::image_format("r32ui")]
14RWTexture2D<uint> tex;
15
16[numthreads(1,1,1)]
17void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
18{
19    // CHECK: OpImageTexelPointer
20    InterlockedAdd(tex[uint2(0, 0)], 1);
21    uint oldVal;
22    InterlockedAdd(tex[uint2(0, 0)], 1, oldVal);
23    resultBuffer[0] = oldVal;
24}