diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2022-04-05 13:32:24 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-05 13:32:24 -0400 |
| commit | 7f36c34daf633dcade3a3bab9cdcf14a34fed3cd (patch) | |
| tree | 2eb61dc9a51da5dc0e997e993d63a1070c064f8f /tests | |
| parent | f58f36eedac6c11e30d60201f43bb4fb1be70bee (diff) | |
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.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/bugs/meta-2.slang (renamed from tests/experiments/generic/meta-2.slang) | 7 | ||||
| -rw-r--r-- | tests/bugs/meta-2.slang.expected.txt | 4 | ||||
| -rw-r--r-- | tests/experiments/generic/generic-func-static-const-var.slang | 24 | ||||
| -rw-r--r-- | tests/experiments/generic/generic-struct-func-static-const-var.slang | 21 |
4 files changed, 50 insertions, 6 deletions
diff --git a/tests/experiments/generic/meta-2.slang b/tests/bugs/meta-2.slang index 98ae09ce5..6dd5541c4 100644 --- a/tests/experiments/generic/meta-2.slang +++ b/tests/bugs/meta-2.slang @@ -1,9 +1,4 @@ -//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj - -/* A test meta programing. - -CRASHES the compiler(!). Stack overrun. - */ +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj //TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer RWStructuredBuffer<int> outputBuffer; diff --git a/tests/bugs/meta-2.slang.expected.txt b/tests/bugs/meta-2.slang.expected.txt new file mode 100644 index 000000000..f7bacac93 --- /dev/null +++ b/tests/bugs/meta-2.slang.expected.txt @@ -0,0 +1,4 @@ +A +A +A +A 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<int> outputBuffer; + +struct GetValue2<let N : int> +{ + 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<int> outputBuffer; + +static int getValue<let N: int>() +{ + 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>(); +} + |
