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.5 KiB108 linesraw
1//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj
2//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
3//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12  -shaderobj
4//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile cs_6_0 -shaderobj
5// TODO(JS): Doesn't work on vk currently
6//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj
7// TODO(JS): Doesn't work on CUDA as there aren't any CUDA functions to get dimensions.
8//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute  -shaderobj
9// Not supported in WGSL: 1D array texture not supported in WGSL
10//DISABLE_TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -wgpu
11
12//TEST_INPUT: Texture1D(size=4, content = one):name t1D
13Texture1D<float> t1D;
14//TEST_INPUT: Texture2D(size=8, content = one):name t2D
15Texture2D<float> t2D;
16//TEST_INPUT: Texture3D(size=2, content = one):name t3D
17Texture3D<float> t3D;
18//TEST_INPUT: TextureCube(size=16, content = one):name tCube
19TextureCube<float> tCube;
20
21//TEST_INPUT: Texture1D(size=2, content = one, arrayLength=2):name t1DArray
22Texture1DArray<float> t1DArray;
23//TEST_INPUT: Texture2D(size=4, content = one, arrayLength=3):name t2DArray
24Texture2DArray<float> t2DArray;
25//TEST_INPUT: TextureCube(size=16, content = one, arrayLength=1):name tCubeArray
26TextureCubeArray<float> tCubeArray;
27
28//TEST_INPUT: Sampler:name samplerState
29SamplerState samplerState;
30
31//TEST_INPUT: ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer
32RWStructuredBuffer<float> outputBuffer;
33
34[numthreads(8, 1, 1)]
35void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
36{
37    int idx = dispatchThreadID.x;
38    
39    uint mipWidth = 0;
40    uint mipHeight = 0;
41    uint mipDepth = 0;
42    uint mipCount = 1;
43    uint elementCount = 0;
44    
45    uint width = 0;
46    uint height = 0;
47    uint depth = 0;
48    
49    switch (idx)
50    {
51        case 0:
52        {
53            t1D.GetDimensions(width);
54            t1D.GetDimensions(0, mipWidth, mipCount);
55            break;
56        }
57        case 1:
58        {
59            t2D.GetDimensions(width, height);
60            t2D.GetDimensions(0, mipWidth, mipHeight, mipCount);
61            break;
62        }
63        case 2:
64        {
65            t3D.GetDimensions(width, height, depth);
66            t3D.GetDimensions(0, mipWidth, mipHeight, mipDepth, mipCount);
67            break;
68        }
69        case 3:
70        {
71            tCube.GetDimensions(width, height);
72            tCube.GetDimensions(0, mipWidth, mipHeight, mipCount);
73            break;
74        }
75        case 4:
76        {
77           t1DArray.GetDimensions(width, elementCount);
78           t1DArray.GetDimensions(0, mipWidth, elementCount, mipCount);
79           break;
80        }
81        case 5:
82        {
83           t2DArray.GetDimensions(width, height, elementCount);
84           t2DArray.GetDimensions(0, mipWidth, mipHeight, elementCount, mipCount);
85           break;
86        }
87        case 6:
88        {
89           tCubeArray.GetDimensions(width, height, elementCount);
90           tCubeArray.GetDimensions(0, mipWidth, mipHeight, elementCount, mipCount);
91           break;
92        }
93    }
94   
95    width = (mipWidth != width) ? ~0 : width;
96    height = (mipHeight != height) ? ~0 : height;
97    depth = (mipDepth != depth) ? ~0 : depth;
98   
99    // Only depth or element count can be set
100    if (depth == 0 && elementCount > 0)
101    {
102        depth = elementCount;
103    }
104   
105    uint val = ((0xff & width) << 24) | ((0xff & height) << 16) | ((0xff & depth) << 8) | (mipCount);
106   
107    outputBuffer[idx] = val;
108}