yum-mirror/slang

Making it easier to work with shaders

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

James Helferty (NVIDIA)render-test: Change D3D12 default to sm_6_5 (#8320)f02b08490

master
2.1 KiB47 linesraw
1// atomic-float-byte-address-buffer.slang
2
3//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type -shaderobj
4//TEST(compute):COMPARE_COMPUTE_EX:-dx11 -slang -compute -render-features atomic-float -output-using-type -nvapi-slot u0 -shaderobj
5//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -render-features atomic-float -output-using-type -shaderobj
6//TEST(compute):COMPARE_COMPUTE_EX:-d3d12 -compute -render-features atomic-float -output-using-type -compile-arg -O2 -nvapi-slot u0 -shaderobj
7//TEST(compute):COMPARE_COMPUTE_EX:-d3d12 -compute -render-features atomic-float -output-using-type -compile-arg -O2 -nvapi-slot u0 -shaderobj
8//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -output-using-type -shaderobj
9//TEST(compute):COMPARE_COMPUTE_EX:-mtl -compute -output-using-type -shaderobj
10
11// The test doesn't directly use this, but having this defined makes the 0 slot available if NVAPI is going to be used
12// Only strictly necessary on the D3D11/D3D12 paths
13//TEST_INPUT:ubuffer(data=[0 0 0 0 ], stride=4):name=nvapiBuffer
14RWStructuredBuffer<int> nvapiBuffer;
15
16//TEST_INPUT:ubuffer(data=[1.0 2.0 3.0 4.0], stride=4):out,name=outputBuffer
17RWStructuredBuffer<float> outputBuffer;
18
19//TEST_INPUT:ubuffer(data=[1.0 2.0 3.0 4.0]):name=workBuffer
20RWByteAddressBuffer workBuffer;
21
22//TEST_INPUT:ubuffer(data=[0.7 0.5 0.2 0.6], stride=4):name=anotherBuffer
23RWStructuredBuffer<float> anotherBuffer;
24
25[numthreads(16, 1, 1)]
26void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
27{
28    uint tid = dispatchThreadID.x;
29    int idx = int((tid & 3) ^ (tid >> 2)); 
30
31    //const float delta = anotherBuffer[idx & 3];
32    
33    float previousValue = 0;
34    workBuffer.InterlockedAddF32((idx << 2), 1.0f, previousValue);
35    //workBuffer.InterlockedAddF32((idx ^ 2) << 2, 2.0f + delta);
36    
37    // The sum of values in anotherBuffer should also be added
38    //int anotherIdx = tid >> 2;
39    //workBuffer.InterlockedAddF32(anotherIdx << 2, delta);
40    
41    GroupMemoryBarrierWithGroupSync();
42    
43    if (tid < 4)
44    {
45        outputBuffer[tid] = asfloat(workBuffer.Load(int(tid << 2)));
46    }
47}