summaryrefslogtreecommitdiffstats
path: root/tests/compute/texture-get-dimensions-cuda.slang
blob: 43d11a6f8cdc89fc1f8897b7b8145019298fba98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj

// Only testing the dimensions available in CUDA via txq:
// - txq.width.b32
// - txq.height.b32
// - txq.depth.b32

//TEST_INPUT: Texture1D(size=4, content = one):name cudaT1D
Texture1D<float> cudaT1D;
//TEST_INPUT: Texture2D(size=8, content = one):name cudaT2D
Texture2D<float> cudaT2D;
//TEST_INPUT: Texture3D(size=2, content = one):name cudaT3D
Texture3D<float> cudaT3D;
//TEST_INPUT: TextureCube(size=16, content = one):name cudaTCube
TextureCube<float> cudaTCube;
//TEST_INPUT: Texture2D(size=4, content = one, arrayLength=3):name cudaT2DArray
Texture2DArray<float> cudaT2DArray;
//TEST_INPUT: TextureCube(size=16, content = one, arrayLength=1):name cudaTCubeArray
TextureCubeArray<float> cudaTCubeArray;

//TEST_INPUT: ubuffer(data=[0 0 0 0 0 0 0], stride=4):out,name cudaOutputBuffer
RWStructuredBuffer<uint> cudaOutputBuffer;

[numthreads(7, 1, 1)]
void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
{
    int idx = dispatchThreadID.x;
    
    uint width = 0;
    uint height = 0;
    uint depth = 0;
    
    switch (idx)
    {
        case 0:
        {
            // Test 1D texture width
            cudaT1D.GetDimensions(width);
            cudaOutputBuffer[idx] = width;
            break;
        }
        case 1:
        {
            // Test 2D texture width and height
            cudaT2D.GetDimensions(width, height);
            cudaOutputBuffer[idx] = ((0xff & width) << 8) | (0xff & height);
            break;
        }
        case 2:
        {
            // Test 3D texture width, height and depth
            cudaT3D.GetDimensions(width, height, depth);
            cudaOutputBuffer[idx] = ((0xff & width) << 16) | ((0xff & height) << 8) | (0xff & depth);
            break;
        }
        case 3:
        {
            // Test Cube texture width and height
            cudaTCube.GetDimensions(width, height);
            cudaOutputBuffer[idx] = ((0xff & width) << 8) | (0xff & height);
            break;
        }
        case 4:
        {
            // Test 2D array texture width and height
            // Note: We don't test array size since txq.array_size is not implemented
            cudaT2DArray.GetDimensions(width, height, depth);
            cudaOutputBuffer[idx] = ((0xff & width) << 8) | (0xff & height);
            break;
        }
        case 5:
        {
            // Test Cube array texture width and height
            // Note: We don't test array size since txq.array_size is not implemented
            cudaTCubeArray.GetDimensions(width, height, depth);
            cudaOutputBuffer[idx] = ((0xff & width) << 8) | (0xff & height);
            break;
        }
        case 6:
        {
            // Reserved for future use
            cudaOutputBuffer[idx] = 0;
            break;
        }
    }
}