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 KiB51 linesraw
1//DISABLE_TEST(compute):COMPARE_COMPUTE:-dx12 -compute -output-using-type -profile cs_6_2 -render-features half -shaderobj
2//TEST(compute):COMPARE_COMPUTE:-vk -compute -output-using-type -profile cs_6_2 -render-features half -shaderobj
3//TEST(compute):COMPARE_COMPUTE:-cuda -compute -output-using-type -render-features half -shaderobj
4
5// Test for doing a calculation using half
6
7//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
8RWStructuredBuffer<float> outputBuffer;
9
10[numthreads(4, 1, 1)]
11void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
12{
13    int tid = dispatchThreadID.x;
14    int x = tid.x;
15    
16    half2 v3 = half2(float(x));
17    
18    half2 v0 = half2(float2(x * 2.0f, x * 0.5f));
19    half3 v1 = half3(half(x * 2.0f), half(x * 0.5f), half(x - 1.0f));
20    half4 v2 = half4(half(x + 1), half(x - 1), half(x + 2) , half(x - 2));
21    
22    v1 += v0.yxy;
23    v1 += v2.wzy;
24    v2 += v0.xyxy;
25    
26    v1 ++;
27    --v2;
28    v3++;
29    
30    // Unary
31    v2 = +v2.yxwz;
32    v2.xyz = -v2.zwx;
33    
34    // Scalar vector 
35    v1 = v1 + v2.x;
36    v2 = v2 * half(2.0f);
37    v0 = half(2.0f) * v0;
38    v2 = v2 / half(2.0f);
39    
40    v0 *= half(2.0f);
41    
42    v0 = v0 + v0 * v0;
43    v1 = v1 + v1 * v1;
44    v2 = v2 + v2 * v2;
45    
46    half o2 = v2.x + v2.y + v2.z + v2.w;
47    half o1 = v1.x + v1.y + v1.z;
48    half o0 = v0.x + v0.y;
49        
50    outputBuffer[tid] = o0 + o1 + o2 + v3.y;
51}