summaryrefslogtreecommitdiff
path: root/tests/language-feature/system-value-extraction.slang
blob: 12ca07a966530c83cb502ec37ef70c25e50d83aa (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
//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -dx11 -compute
//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -dx12 -compute
//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -cpu -compute
//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -cuda -compute
//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -wgsl -compute
//DISABLE_TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -mtl -compute
//TEST(compute,vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -vk -compute

// Slang allows the type of system value semantics to differ from their
// "canonical" type - e.g. `uint8_t tid : SV_DispatchThreadID` is technically
// valid and refers to the first element in the underlying uint3 vector.

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

[numthreads(2, 4, 1)]
void computeMain(
    uint ind : SV_GroupIndex,
    vector<uint, 2> tid: SV_DispatchThreadID,
    int localTid : SV_GroupThreadID
){
    // CHECK: 0
    // CHECK-NEXT: 5
    // CHECK-NEXT: 8
    // CHECK-NEXT: D
    // CHECK-NEXT: 10
    // CHECK-NEXT: 15
    // CHECK-NEXT: 18
    // CHECK-NEXT: 1D
    outputBuffer[ind] = 4 * (tid.x + 2 * tid.y) + localTid;
}