yum-mirror/slang

Making it easier to work with shaders

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

Anders LeinoWGSL: Fix issue where global calls are generated (#5768)9c82ed369

master
880 B33 linesraw
1// static-const-in-generic-interface.slang
2
3//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -shaderobj
4
5// Test that `static const` variable declarations inside of
6// a generic `interface` type correctly translate to interface requirements.
7
8interface ITest<T:__BuiltinIntegerType>
9{
10    static const T kUserDefinedValue;
11}
12
13struct Impl : ITest<int>
14{
15    static const int kUserDefinedValue = 4;
16}
17
18struct EnsureCompileTimeEval<T : __BuiltinIntegerType>
19{
20    static T getValue<U : ITest<T>>() { return U.kUserDefinedValue; }
21}
22
23//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
24RWStructuredBuffer<int> outputBuffer;
25
26[numthreads(1, 1, 1)]
27void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
28{
29    static const int result = EnsureCompileTimeEval<int>.getValue<Impl>();
30    int outVal = result;
31    // CHECK: 4
32    outputBuffer[0] = outVal;
33}