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.0 KiB52 linesraw
1// No atomic support on CPU
2//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj
3// No support for int64_t on DX11
4//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
5// No support for int64_t on fxc - we need SM6.0 and dxil
6// https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/hlsl-shader-model-6-0-features-for-direct3d-12
7//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -nvapi-slot u0 -shaderobj
8//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile cs_6_0 -render-features atomic-int64 -compile-arg -O2 -shaderobj
9//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -render-features atomic-int64 -shaderobj
10// For some reason this doesn't work correctly on CUDA? That it behaves as if always does Min. Min and Max do appropriate 
11// things tho, because if I force the condition I do get the right answer
12//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj
13
14// The test doesn't directly use this, but having this defined makes the 0 slot available if NVAPI is going to be used
15// Only strictly necessary on the D3D12 path
16//TEST_INPUT:ubuffer(data=[0 0 0 0 ], stride=4):name=nvapiBuffer
17RWStructuredBuffer<int> nvapiBuffer;
18
19//TEST_INPUT:ubuffer(data=[2 2 2 2 2 2 2 2], stride=4):out,name=outputBuffer
20RWByteAddressBuffer outputBuffer;
21
22//TEST_INPUT:ubuffer(data=[0 1 2 3 4 5 6 7], stride=4):name=inputBuffer
23RWStructuredBuffer<uint> inputBuffer;
24
25[numthreads(16, 1, 1)]
26void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
27{    
28    int tid = dispatchThreadID.x;
29
30    // Produces a different result on CUDA?
31   
32    uint64_t value;
33    {
34        int idx = tid & 3;
35        // Do 64 bit load that works on CUDA
36        value = (uint64_t(inputBuffer[idx * 2 + 1]) << 32) | inputBuffer[idx * 2];
37    }
38
39    {
40        int idx = (tid & 3) ^ (tid >> 2);
41        if (bool(idx & 1))
42        {
43            outputBuffer.InterlockedMaxU64((idx << 3), value);
44        }
45        else
46        {
47            outputBuffer.InterlockedMinU64((idx << 3), value);
48        }
49    }
50}
51
52