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 KiB51 linesraw
1// Native half not supported on CPU currently
2//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type -shaderobj
3// Doesn't work on DX11 currently - locks up on binding
4//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -output-using-type -shaderobj
5// Produces a different result on DX12 with DXBC than expected(!). So disabled for now
6//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -output-using-type -shaderobj
7//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile cs_6_0 -output-using-type -shaderobj
8//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type -shaderobj
9//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -output-using-type -shaderobj -render-features half
10
11//TEST_INPUT: RWTexture2D(format=R16Float, size=4, content = one, mipMaps = 1):name rwt2D
12[format("r16f")]
13RWTexture2D<float> rwt2D;
14
15//TEST_INPUT: RWTexture2D(format=RG16Float, size=4, content = one, mipMaps = 1):name rwt2D_2
16[format("rg16f")]
17RWTexture2D<float2> rwt2D_2;
18
19//TEST_INPUT: RWTexture2D(format=RGBA16Float, size=4, content = one, mipMaps = 1):name rwt2D_4
20[format("rgba16f")]
21RWTexture2D<float4> rwt2D_4;
22
23//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
24RWStructuredBuffer<float> outputBuffer;
25
26[numthreads(4, 1, 1)]
27void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
28{
29    int idx = dispatchThreadID.x;
30    
31    float val = 0;
32 
33    // Do a format converting write2!
34    rwt2D[uint2(idx, idx)] = idx - 1;
35    rwt2D_2[uint2(idx, idx)] = float2(idx + idx, idx * idx);
36    rwt2D_4[uint2(idx, idx)] = float4(idx + 97, idx + 8, idx + 16, idx + 24);    
37    
38    // May not be strictly necessary
39    AllMemoryBarrierWithGroupSync();
40    
41    // Do read converting
42    // There is *only* CUDA support for half/float *converting* reads for 1d, 2d, 3d shapes for RWTexture/surface
43    
44    float4 v4 = rwt2D_4[uint2(idx, idx)];
45    float2 v2 = rwt2D_2[uint2(idx, idx)];
46    float v = rwt2D[uint2(idx, idx)];
47    
48    val += v4.x + v2.x + v;
49    
50    outputBuffer[idx] = val;
51}