summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/constants/static-const-in-interface.slang
blob: 48737564f674b384328484c0b9184a0be533d73f (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
// static-const-in-interface.slang

//TEST(compute):COMPARE_COMPUTE: -shaderobj

// Test that `static const` variable declarations inside of
// a `interface` type correctly translate to interface requirements.

interface ITest
{
    static const int kUserDefinedValue;
}

extension int : ITest
{
    static const int kUserDefinedValue = 4;
}

extension int16_t : ITest
{
    static const int kUserDefinedValue = 2;
}

struct GetValue<T : ITest>
{
    static const int value = T.kUserDefinedValue;
}

struct EnsureCompileTimeEval<let u : int>
{
    static const int value = u;
}

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

[numthreads(4, 1, 1)]
void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
{
    int tid = dispatchThreadID.x;
    int inVal = tid;
    static const int result = EnsureCompileTimeEval<GetValue<int>.value - GetValue<int16_t>.value>.value;
    int outVal = result;
    outputBuffer[tid] = outVal;
}