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
3.9 KiB102 linesraw
1//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type -shaderobj
2// Doesn't work on DX11 currently - locks up on binding
3//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -output-using-type -shaderobj
4// Produces a different result on DX12 with DXBC than expected(!). So disabled for now
5//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -output-using-type -shaderobj
6//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile cs_6_0 -output-using-type -shaderobj
7//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type -shaderobj
8
9//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -output-using-type -shaderobj
10
11//TEST_INPUT: RWTexture1D(format=R32Float, size=4, content = one, mipMaps = 1):name rwt1D
12RWTexture1D<float> rwt1D;
13//TEST_INPUT: RWTexture2D(format=R32Float, size=4, content = one, mipMaps = 1):name rwt2D
14RWTexture2D<float> rwt2D;
15//TEST_INPUT: RWTexture3D(format=R32Float, size=4, content = one, mipMaps = 1):name rwt3D
16RWTexture3D<float> rwt3D;
17//TEST_INPUT: RWTexture1D(format=RG32Float, size=4, content = one, mipMaps = 1):name rwt1D_float2
18RWTexture1D<float2> rwt1D_float2;
19//TEST_INPUT: RWTexture1D(format=RGBA32Float, size=4, content = one, mipMaps = 1):name rwt1D_float4
20RWTexture1D<float4> rwt1D_float4;
21//TEST_INPUT: RWTexture2D(format=RG32Float, size=4, content = one, mipMaps = 1):name rwt2D_float2
22RWTexture2D<float2> rwt2D_float2;
23//TEST_INPUT: RWTexture2D(format=RGBA32Float, size=4, content = one, mipMaps = 1):name rwt2D_float4
24RWTexture2D<float4> rwt2D_float4;
25//TEST_INPUT: RWTexture3D(format=RG32Float, size=4, content = one, mipMaps = 1):name rwt3D_float2
26RWTexture3D<float2> rwt3D_float2;
27//TEST_INPUT: RWTexture3D(format=RGBA32Float, size=4, content = one, mipMaps = 1):name rwt3D_float4
28RWTexture3D<float4> rwt3D_float4;
29
30//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
31RWStructuredBuffer<float> outputBuffer;
32
33[numthreads(4, 1, 1)]
34void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
35{
36    int idx = dispatchThreadID.x;
37    
38    float val = 0.0f;
39 
40    // float texture operations
41    val += rwt1D[idx];
42    val += rwt2D[uint2(idx, idx)];
43    val += rwt3D[uint3(idx, idx, idx)];
44    
45    rwt1D[idx] = idx;
46    rwt2D[uint2(idx, idx)] = idx;    
47    rwt3D[uint3(idx, idx, idx)] = idx;    
48            
49    val += rwt1D[idx];
50    val += rwt2D[uint2(idx, idx)];
51    val += rwt3D[uint3(idx, idx, idx)];
52    
53    // float2 texture operations for 1D
54    float2 val2_1d = rwt1D_float2[idx];
55    rwt1D_float2[idx] = float2(idx, idx);
56    val2_1d = rwt1D_float2[idx];
57    val += val2_1d.x;
58    val += val2_1d.y;
59    
60    // float2 texture operations for 2D
61    float2 val2 = rwt2D_float2[uint2(idx, idx)];
62    rwt2D_float2[uint2(idx, idx)] = float2(idx, idx);
63    val2 = rwt2D_float2[uint2(idx, idx)];
64    val += val2.x;
65    val += val2.y;
66    
67    // float2 texture operations for 3D
68    float2 val2_3d = rwt3D_float2[uint3(idx, idx, idx)];
69    rwt3D_float2[uint3(idx, idx, idx)] = float2(idx, idx);
70    val2_3d = rwt3D_float2[uint3(idx, idx, idx)];
71    val += val2_3d.x;
72    val += val2_3d.y;
73    
74    // float4 texture operations for 1D
75    float4 val4_1d = rwt1D_float4[idx];
76    rwt1D_float4[idx] = float4(idx, idx, idx, idx);
77    val4_1d = rwt1D_float4[idx];
78    val += val4_1d.x;
79    val += val4_1d.y;
80    val += val4_1d.z;
81    val += val4_1d.w;
82    
83    // float4 texture operations for 2D
84    float4 val4 = rwt2D_float4[uint2(idx, idx)];
85    rwt2D_float4[uint2(idx, idx)] = float4(idx, idx, idx, idx);
86    val4 = rwt2D_float4[uint2(idx, idx)];
87    val += val4.x;
88    val += val4.y;
89    val += val4.z;
90    val += val4.w;
91    
92    // float4 texture operations for 3D
93    float4 val4_3d = rwt3D_float4[uint3(idx, idx, idx)];
94    rwt3D_float4[uint3(idx, idx, idx)] = float4(idx, idx, idx, idx);
95    val4_3d = rwt3D_float4[uint3(idx, idx, idx)];
96    val += val4_3d.x;
97    val += val4_3d.y;
98    val += val4_3d.z;
99    val += val4_3d.w;
100    
101    outputBuffer[idx] = val;
102}