From 7f36c34daf633dcade3a3bab9cdcf14a34fed3cd Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 5 Apr 2022 13:32:24 -0400 Subject: Handling static const variables in generics (#2171) * #include an absolute path didn't work - because paths were taken to always be relative. * Meta-2 test works. * Add new generic test for static const variable in a function in a generic. * Generic function with static const variable doesn't work. --- .../generic/generic-func-static-const-var.slang | 24 ++++++++++++++++++++++ .../generic-struct-func-static-const-var.slang | 21 +++++++++++++++++++ tests/experiments/generic/meta-2.slang | 23 --------------------- 3 files changed, 45 insertions(+), 23 deletions(-) create mode 100644 tests/experiments/generic/generic-func-static-const-var.slang create mode 100644 tests/experiments/generic/generic-struct-func-static-const-var.slang delete mode 100644 tests/experiments/generic/meta-2.slang (limited to 'tests/experiments') diff --git a/tests/experiments/generic/generic-func-static-const-var.slang b/tests/experiments/generic/generic-func-static-const-var.slang new file mode 100644 index 000000000..2c8ea0398 --- /dev/null +++ b/tests/experiments/generic/generic-func-static-const-var.slang @@ -0,0 +1,24 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -Xslang -dump-ir + +/* Doesn't work correctly failing in emit with a 'generic' instruction that is not expected. */ + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer outputBuffer; + +struct GetValue2 +{ + static int getValue() + { + static const int v = N; + return v; + } +}; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int index = dispatchThreadID.x; + + outputBuffer[index] = GetValue2<20>::getValue(); +} + diff --git a/tests/experiments/generic/generic-struct-func-static-const-var.slang b/tests/experiments/generic/generic-struct-func-static-const-var.slang new file mode 100644 index 000000000..db6fc6225 --- /dev/null +++ b/tests/experiments/generic/generic-struct-func-static-const-var.slang @@ -0,0 +1,21 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -Xslang -dump-ir + +/* Doesn't work correctly failing in emit with a 'generic' instruction that is not expected. */ + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer outputBuffer; + +static int getValue() +{ + static const int v = N; + return v; +} + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int index = dispatchThreadID.x; + + outputBuffer[index] = getValue<10>(); +} + diff --git a/tests/experiments/generic/meta-2.slang b/tests/experiments/generic/meta-2.slang deleted file mode 100644 index 98ae09ce5..000000000 --- a/tests/experiments/generic/meta-2.slang +++ /dev/null @@ -1,23 +0,0 @@ -//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj - -/* A test meta programing. - -CRASHES the compiler(!). Stack overrun. - */ - -//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer -RWStructuredBuffer outputBuffer; - -struct GetValue -{ - static const int Value = N; -}; - -[numthreads(4, 1, 1)] -void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) -{ - int index = dispatchThreadID.x; - - outputBuffer[index] = GetValue<10>::Value; -} - -- cgit v1.2.3