blob: 730c4c2dc22fe623b2ae3dfec177d14d95e30867 (
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
|
// static-const-in-generic-interface.slang
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -shaderobj
//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-wgpu
// 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;
}
|