yum-mirror/slang

Making it easier to work with shaders

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

skallweitNVenable more metal tests (#4326)712ce653d

master
993 B44 linesraw
1// static-const-in-interface.slang
2
3//TEST(compute):COMPARE_COMPUTE: -shaderobj
4
5// Test that `static const` variable declarations inside of
6// a `interface` type correctly translate to interface requirements.
7
8interface ITest
9{
10    static const int kUserDefinedValue;
11}
12
13extension int : ITest
14{
15    static const int kUserDefinedValue = 4;
16}
17
18extension int16_t : ITest
19{
20    static const int kUserDefinedValue = 2;
21}
22
23struct GetValue<T : ITest>
24{
25    static const int value = T.kUserDefinedValue;
26}
27
28struct EnsureCompileTimeEval<let u : int>
29{
30    static const int value = u;
31}
32
33//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
34RWStructuredBuffer<int> outputBuffer;
35
36[numthreads(4, 1, 1)]
37void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
38{
39    int tid = dispatchThreadID.x;
40    int inVal = tid;
41    static const int result = EnsureCompileTimeEval<GetValue<int>.value - GetValue<int16_t>.value>.value;
42    int outVal = result;
43    outputBuffer[tid] = outVal;
44}