blob: 87d8e3be84c5282842ff2aed5651e9803f25c17c (
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
|
// static-const-in-generic-interface.slang
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -shaderobj
// Test that `static const` variable declarations inside of
// a generic `interface` type correctly translate to interface requirements.
interface ITest<T:__BuiltinIntegerType>
{
static const T kUserDefinedValue;
}
struct Impl : ITest<int>
{
static const int kUserDefinedValue = 4;
}
struct EnsureCompileTimeEval<T : __BuiltinIntegerType>
{
static T getValue<U : ITest<T>>() { return U.kUserDefinedValue; }
}
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<int> outputBuffer;
[numthreads(1, 1, 1)]
void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
{
static const int result = EnsureCompileTimeEval<int>.getValue<Impl>();
int outVal = result;
// CHECK: 4
outputBuffer[0] = outVal;
}
|