diff options
Diffstat (limited to 'tests/language-feature/constants')
| -rw-r--r-- | tests/language-feature/constants/static-const-in-generic-interface.slang | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/language-feature/constants/static-const-in-generic-interface.slang b/tests/language-feature/constants/static-const-in-generic-interface.slang new file mode 100644 index 000000000..87d8e3be8 --- /dev/null +++ b/tests/language-feature/constants/static-const-in-generic-interface.slang @@ -0,0 +1,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; +} |
