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
1.4 KiB42 linesraw
1//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj
2// No support for int64_t on D3D11 (no sm 6.0)
3//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
4// No support with Dx12 with dxbc. Needs SM6.0 + dxil
5//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -shaderobj
6//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -profile cs_6_0 -dx12 -shaderobj -render-feature hardware-device
7//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -render-feature int64
8//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj
9//TEST(compute, metal):COMPARE_COMPUTE_EX:-slang -compute -mtl
10
11//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
12RWStructuredBuffer<int> outputBuffer;
13
14[numthreads(4, 1, 1)]
15void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
16{
17    int64_t idx = int64_t(dispatchThreadID.x);
18    
19    int64_t ti =0;
20    
21    ti += max(2, idx);
22    ti += min(idx, 1);
23    ti += abs(idx - 2);
24    ti += clamp(idx * 10, 11, 23);
25
26    // Math
27    ti = ti - idx;
28    ti = ti + (ti % (idx + 5));
29    ti = ti + (ti / (idx + 20));
30    
31    // Logical ops
32    ti = ti | idx;
33    ti = ti ^ (idx & (idx + 1));
34    
35    // Shift
36    ti = ti + (idx >> 1);
37    ti = ti + (idx << 2);
38  
39    int64_t v = (ti * 0x400010035435435ll) / 3ll + 7ll - 9ll; 
40    
41    outputBuffer[uint(idx)] = int(v) ^ int(((v >> 32) & 0xffffffff)); 
42}