yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Mukund KeshavaAdd GetDimensions support for CUDA (#6718)549aa897b

master
2.8 KiB86 linesraw
1//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj
2
3// Only testing the dimensions available in CUDA via txq:
4// - txq.width.b32
5// - txq.height.b32
6// - txq.depth.b32
7
8//TEST_INPUT: Texture1D(size=4, content = one):name cudaT1D
9Texture1D<float> cudaT1D;
10//TEST_INPUT: Texture2D(size=8, content = one):name cudaT2D
11Texture2D<float> cudaT2D;
12//TEST_INPUT: Texture3D(size=2, content = one):name cudaT3D
13Texture3D<float> cudaT3D;
14//TEST_INPUT: TextureCube(size=16, content = one):name cudaTCube
15TextureCube<float> cudaTCube;
16//TEST_INPUT: Texture2D(size=4, content = one, arrayLength=3):name cudaT2DArray
17Texture2DArray<float> cudaT2DArray;
18//TEST_INPUT: TextureCube(size=16, content = one, arrayLength=1):name cudaTCubeArray
19TextureCubeArray<float> cudaTCubeArray;
20
21//TEST_INPUT: ubuffer(data=[0 0 0 0 0 0 0], stride=4):out,name cudaOutputBuffer
22RWStructuredBuffer<uint> cudaOutputBuffer;
23
24[numthreads(7, 1, 1)]
25void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
26{
27    int idx = dispatchThreadID.x;
28    
29    uint width = 0;
30    uint height = 0;
31    uint depth = 0;
32    
33    switch (idx)
34    {
35        case 0:
36        {
37            // Test 1D texture width
38            cudaT1D.GetDimensions(width);
39            cudaOutputBuffer[idx] = width;
40            break;
41        }
42        case 1:
43        {
44            // Test 2D texture width and height
45            cudaT2D.GetDimensions(width, height);
46            cudaOutputBuffer[idx] = ((0xff & width) << 8) | (0xff & height);
47            break;
48        }
49        case 2:
50        {
51            // Test 3D texture width, height and depth
52            cudaT3D.GetDimensions(width, height, depth);
53            cudaOutputBuffer[idx] = ((0xff & width) << 16) | ((0xff & height) << 8) | (0xff & depth);
54            break;
55        }
56        case 3:
57        {
58            // Test Cube texture width and height
59            cudaTCube.GetDimensions(width, height);
60            cudaOutputBuffer[idx] = ((0xff & width) << 8) | (0xff & height);
61            break;
62        }
63        case 4:
64        {
65            // Test 2D array texture width and height
66            // Note: We don't test array size since txq.array_size is not implemented
67            cudaT2DArray.GetDimensions(width, height, depth);
68            cudaOutputBuffer[idx] = ((0xff & width) << 8) | (0xff & height);
69            break;
70        }
71        case 5:
72        {
73            // Test Cube array texture width and height
74            // Note: We don't test array size since txq.array_size is not implemented
75            cudaTCubeArray.GetDimensions(width, height, depth);
76            cudaOutputBuffer[idx] = ((0xff & width) << 8) | (0xff & height);
77            break;
78        }
79        case 6:
80        {
81            // Reserved for future use
82            cudaOutputBuffer[idx] = 0;
83            break;
84        }
85    }
86}