yum-mirror/slang

Making it easier to work with shaders

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

venkataram-nvFix atomics error diagnostics (#8117)b7df3c7aa

master
1.1 KiB31 linesraw
1// gather-texture2darray.slang
2
3//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -compute -shaderobj -output-using-type -emit-spirv-directly -render-feature hardware-device
4//TEST(compute):SIMPLE(filecheck=HLSL):-target hlsl -profile cs_6_6 -entry computeMain
5//TEST(compute):SIMPLE(filecheck=MTL):-target metal -entry computeMain -stage compute
6
7// Test atomics on a RWTexture2D<float>.
8
9//TEST_INPUT: set t = RWTexture2D(format=R32Float, size=4, content = zero, mipMaps = 1)
10[format("r32f")]
11globallycoherent RWTexture2D<float> t;
12
13//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
14RWStructuredBuffer<float> outputBuffer;
15
16[shader("compute")]
17[numthreads(4, 1, 1)]
18void computeMain(uint3 tid : SV_DispatchThreadID)
19{
20    float originalValue;
21    
22    // HLSL: {{.*}}originalValue{{.*}} = NvInterlockedAddFp32({{.*}}t{{.*}}, {{.*}}, {{.*}}1.0{{.*}});
23    // MTL: atomic_fetch_add
24    t.InterlockedAddF32(uint2(1, 0), 1.0, originalValue);
25    
26    AllMemoryBarrier();
27
28    // CHECK: 4.0
29    outputBuffer[0] = t[uint2(1, 0)] + originalValue;
30
31}