diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2022-03-24 11:42:56 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-24 11:42:56 -0400 |
| commit | b8617af2888db01f80efba9e0a103e6a61989c9c (patch) | |
| tree | 66830e801ac0dc78180ac8d9cda8af75d59bb557 /tests | |
| parent | e1a331a2e2945f2b90c00d0af4d1ba5f67dbd256 (diff) | |
Fix for default initialization with generic field (#2168)
* #include an absolute path didn't work - because paths were taken to always be relative.
* Fix for = {} initialization with a field that is generic type parameter.
* Handling for if a non type is passed to a generic parameter which requires a type.
* Small comment improvements.
Fix some tab issues.
* This fixes the matrix.slang issue. Move the matrix.slang test into bugs as generic-default-matrix.slang
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/bugs/generic-default-matrix.slang (renamed from tests/experiments/generic/matrix.slang) | 9 | ||||
| -rw-r--r-- | tests/bugs/generic-default-matrix.slang.expected.txt | 4 | ||||
| -rw-r--r-- | tests/bugs/generic-default-value.slang | 23 | ||||
| -rw-r--r-- | tests/bugs/generic-default-value.slang.expected.txt | 4 | ||||
| -rw-r--r-- | tests/diagnostics/generic-invalid-type-specialization.slang | 20 | ||||
| -rw-r--r-- | tests/diagnostics/generic-invalid-type-specialization.slang.expected | 8 |
6 files changed, 61 insertions, 7 deletions
diff --git a/tests/experiments/generic/matrix.slang b/tests/bugs/generic-default-matrix.slang index c55c7be33..47fbe520e 100644 --- a/tests/experiments/generic/matrix.slang +++ b/tests/bugs/generic-default-matrix.slang @@ -1,9 +1,4 @@ -//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj - -/* A test to use generics around resource/built in types. - -CRASHES the compiler. - */ +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj //TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer RWStructuredBuffer<int> outputBuffer; @@ -20,6 +15,6 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) Another<2, 4> a = {}; - outputBuffer[index] = index; + outputBuffer[index] = index + a.values[0].x; } diff --git a/tests/bugs/generic-default-matrix.slang.expected.txt b/tests/bugs/generic-default-matrix.slang.expected.txt new file mode 100644 index 000000000..bc856dafa --- /dev/null +++ b/tests/bugs/generic-default-matrix.slang.expected.txt @@ -0,0 +1,4 @@ +0 +1 +2 +3 diff --git a/tests/bugs/generic-default-value.slang b/tests/bugs/generic-default-value.slang new file mode 100644 index 000000000..b3805e317 --- /dev/null +++ b/tests/bugs/generic-default-value.slang @@ -0,0 +1,23 @@ +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer<int> outputBuffer; + +/* Tests purpose is to confirm that use of `= {}` initialization +works with a generic */ + +struct Check<T> +{ + T v; +}; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int index = dispatchThreadID.x; + + Check<float> v = {}; + + outputBuffer[index] = index + v.v; +} + diff --git a/tests/bugs/generic-default-value.slang.expected.txt b/tests/bugs/generic-default-value.slang.expected.txt new file mode 100644 index 000000000..bc856dafa --- /dev/null +++ b/tests/bugs/generic-default-value.slang.expected.txt @@ -0,0 +1,4 @@ +0 +1 +2 +3 diff --git a/tests/diagnostics/generic-invalid-type-specialization.slang b/tests/diagnostics/generic-invalid-type-specialization.slang new file mode 100644 index 000000000..28d155643 --- /dev/null +++ b/tests/diagnostics/generic-invalid-type-specialization.slang @@ -0,0 +1,20 @@ +//DIAGNOSTIC_TEST:SIMPLE: + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer<int> outputBuffer; + +struct Check<T> +{ + T v; +}; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int index = dispatchThreadID.x; + + // Invalid as should only accept a type + Check<2 + 2> v; + + outputBuffer[index] = index; +} diff --git a/tests/diagnostics/generic-invalid-type-specialization.slang.expected b/tests/diagnostics/generic-invalid-type-specialization.slang.expected new file mode 100644 index 000000000..b3c75c760 --- /dev/null +++ b/tests/diagnostics/generic-invalid-type-specialization.slang.expected @@ -0,0 +1,8 @@ +result code = -1 +standard error = { +tests/diagnostics/generic-invalid-type-specialization.slang(17): error 30060: expected a type, got a 'InfixExpr' + Check<2 + 2> v; + ^ +} +standard output = { +} |
