From ba6f55ed9481960b4f6c7f0a6b8f1cf7d450c752 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 24 Aug 2022 12:05:19 -0700 Subject: Allow `static const` interface requirements. (#2378) --- .../constants/static-const-in-interface.slang | 44 ++++++++++++++++++++++ .../static-const-in-interface.slang.expected.txt | 4 ++ 2 files changed, 48 insertions(+) create mode 100644 tests/language-feature/constants/static-const-in-interface.slang create mode 100644 tests/language-feature/constants/static-const-in-interface.slang.expected.txt (limited to 'tests') diff --git a/tests/language-feature/constants/static-const-in-interface.slang b/tests/language-feature/constants/static-const-in-interface.slang new file mode 100644 index 000000000..48737564f --- /dev/null +++ b/tests/language-feature/constants/static-const-in-interface.slang @@ -0,0 +1,44 @@ +// static-const-in-interface.slang + +//TEST(compute):COMPARE_COMPUTE: -shaderobj + +// Test that `static const` variable declarations inside of +// a `interface` type correctly translate to interface requirements. + +interface ITest +{ + static const int kUserDefinedValue; +} + +extension int : ITest +{ + static const int kUserDefinedValue = 4; +} + +extension int16_t : ITest +{ + static const int kUserDefinedValue = 2; +} + +struct GetValue +{ + static const int value = T.kUserDefinedValue; +} + +struct EnsureCompileTimeEval +{ + static const int value = u; +} + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(int3 dispatchThreadID : SV_DispatchThreadID) +{ + int tid = dispatchThreadID.x; + int inVal = tid; + static const int result = EnsureCompileTimeEval.value - GetValue.value>.value; + int outVal = result; + outputBuffer[tid] = outVal; +} diff --git a/tests/language-feature/constants/static-const-in-interface.slang.expected.txt b/tests/language-feature/constants/static-const-in-interface.slang.expected.txt new file mode 100644 index 000000000..487b11653 --- /dev/null +++ b/tests/language-feature/constants/static-const-in-interface.slang.expected.txt @@ -0,0 +1,4 @@ +2 +2 +2 +2 -- cgit v1.2.3