diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/bugs/op-assignment-unify-mat.slang | 47 | ||||
| -rw-r--r-- | tests/bugs/op-assignment-unify-mat.slang.expected.txt | 4 | ||||
| -rw-r--r-- | tests/bugs/op-assignment-unify-vec.slang | 47 | ||||
| -rw-r--r-- | tests/bugs/op-assignment-unify-vec.slang.expected.txt | 6 | ||||
| -rw-r--r-- | tests/bugs/op-assignment-unify.slang | 44 | ||||
| -rw-r--r-- | tests/bugs/op-assignment-unify.slang.expected.txt | 6 | ||||
| -rw-r--r-- | tests/diagnostics/implicit-cast-lvalue.slang | 9 | ||||
| -rw-r--r-- | tests/diagnostics/implicit-cast-lvalue.slang.expected | 7 |
8 files changed, 166 insertions, 4 deletions
diff --git a/tests/bugs/op-assignment-unify-mat.slang b/tests/bugs/op-assignment-unify-mat.slang new file mode 100644 index 000000000..13b6ecf48 --- /dev/null +++ b/tests/bugs/op-assignment-unify-mat.slang @@ -0,0 +1,47 @@ +// We can't test on VK, as currently we don't support integer matrix types +//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -vk +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -cpu + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer<uint> outputBuffer; + +void silly<T : __BuiltinIntegerType, let ROWS : int, let COLS : int>(matrix<T, ROWS, COLS> a, inout matrix<T, ROWS, COLS> b) +{ + b *= a; +} + +void silly2<T : __BuiltinIntegerType, let ROWS : int, let COLS : int>(matrix<T, ROWS, COLS> a, out matrix<T, ROWS, COLS> b) +{ + b = a; +} + + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + matrix<int, 2, 2> v = { 1, 2, 3, 4}; + matrix<uint, 2, 2> u = { 5, 6, 7, 8}; + + int idx = int(dispatchThreadID.x); + + matrix<uint, 2, 2> uidx = { idx, idx * idx, idx + idx, idx + 2 }; + + v += uidx; + u += idx; + + silly(u, v); + silly(v, u); + + // Check that detects issues with undefined variables. + + matrix<int, 2, 2> undef1, undef2; // undefined + // Downstream compilers detect this + //silly(u, undef1); + silly2(u, undef2); + + matrix<uint, 2, 2> added = (u + v + undef2); + uint2 added2 = added[0] + added[1]; + + outputBuffer[idx] = added2.x + added2.y; +} diff --git a/tests/bugs/op-assignment-unify-mat.slang.expected.txt b/tests/bugs/op-assignment-unify-mat.slang.expected.txt new file mode 100644 index 000000000..f5973ac46 --- /dev/null +++ b/tests/bugs/op-assignment-unify-mat.slang.expected.txt @@ -0,0 +1,4 @@ +53E +92C +FA8 +19C0 diff --git a/tests/bugs/op-assignment-unify-vec.slang b/tests/bugs/op-assignment-unify-vec.slang new file mode 100644 index 000000000..4cc3154a0 --- /dev/null +++ b/tests/bugs/op-assignment-unify-vec.slang @@ -0,0 +1,47 @@ +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -vk +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -cpu + + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer<uint> outputBuffer; + + +void silly<T : __BuiltinIntegerType, let N : int>(vector<T, N> a, inout vector<T, N> b) +{ + b *= a; +} + +void silly2<T : __BuiltinIntegerType, let N : int>(vector<T, N> a, out vector<T, N> b) +{ + b = a; +} + + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int2 v = int2(0, 0); + uint2 u = uint2(0, 0); + + int idx = int(dispatchThreadID.x); + + uint2 uidx = uint2(idx, idx * idx); + + v += uidx; + u += idx; + + silly(u, v); + silly(v, u); + + // Check that detects issues with undefined variables. + + int2 undef1, undef2; // undefined + // Downstream compilers detect this + //silly(u, undef1); + silly2(u, undef2); + + uint2 added = (u + v + undef2); + + outputBuffer[idx] = added.x + added.y; +} diff --git a/tests/bugs/op-assignment-unify-vec.slang.expected.txt b/tests/bugs/op-assignment-unify-vec.slang.expected.txt new file mode 100644 index 000000000..d92319a24 --- /dev/null +++ b/tests/bugs/op-assignment-unify-vec.slang.expected.txt @@ -0,0 +1,6 @@ +0 +6 +3C +FC +0 +0 diff --git a/tests/bugs/op-assignment-unify.slang b/tests/bugs/op-assignment-unify.slang new file mode 100644 index 000000000..738b49677 --- /dev/null +++ b/tests/bugs/op-assignment-unify.slang @@ -0,0 +1,44 @@ +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -vk +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -cpu + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer<uint> outputBuffer; + + +void silly<T : __BuiltinIntegerType>(T a, inout T b) +{ + b *= a; +} + +void silly2<T : __BuiltinIntegerType>(T a, out T b) +{ + b = a; +} + + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int v = 0; + uint u = 0; + + int idx = int(dispatchThreadID.x); + uint uidx = uint(idx); + + v += uidx; + u += idx; + + silly(u, v); + silly(v, u); + + // Check that detects issues with undefined variables. + + int undef1, undef2; // undefined + + // Downstream compilers detect this... + //silly(u, undef1); + silly2(u, undef2); + + outputBuffer[idx] = u + v + undef2; +} diff --git a/tests/bugs/op-assignment-unify.slang.expected.txt b/tests/bugs/op-assignment-unify.slang.expected.txt new file mode 100644 index 000000000..539ab696c --- /dev/null +++ b/tests/bugs/op-assignment-unify.slang.expected.txt @@ -0,0 +1,6 @@ +0 +3 +14 +3F +0 +0 diff --git a/tests/diagnostics/implicit-cast-lvalue.slang b/tests/diagnostics/implicit-cast-lvalue.slang index 79b619443..daf196378 100644 --- a/tests/diagnostics/implicit-cast-lvalue.slang +++ b/tests/diagnostics/implicit-cast-lvalue.slang @@ -1,15 +1,20 @@ //DIAGNOSTIC_TEST:SIMPLE: + +// Generally speaking: // Passing an argument for an `out` parameter such // that implicit conversion would be required in // both directions. +// +// But we do have special case code to handle uint/int of the same type and scalar/vector/matrix forms. +// So for this to fail we need to use floats or something else -void a(out uint x) +void a(out float x) { x = 0; } -void b(int y) +void b(double y) { a(y); } diff --git a/tests/diagnostics/implicit-cast-lvalue.slang.expected b/tests/diagnostics/implicit-cast-lvalue.slang.expected index 3fdd846a5..920ad17c2 100644 --- a/tests/diagnostics/implicit-cast-lvalue.slang.expected +++ b/tests/diagnostics/implicit-cast-lvalue.slang.expected @@ -1,9 +1,12 @@ result code = -1 standard error = { -tests/diagnostics/implicit-cast-lvalue.slang(14): error 30047: argument passed to parameter '0' must be l-value. +tests/diagnostics/implicit-cast-lvalue.slang(19): warning 30081: implicit conversion from 'double' to 'float' is not recommended a(y); ^ -tests/diagnostics/implicit-cast-lvalue.slang(14): note 30048: argument was implicitly cast from 'int' to 'uint', and Slang does not support using an implicit cast as an l-value +tests/diagnostics/implicit-cast-lvalue.slang(19): error 30047: argument passed to parameter '0' must be l-value. + a(y); + ^ +tests/diagnostics/implicit-cast-lvalue.slang(19): note 30048: argument was implicitly cast from 'double' to 'float', and Slang does not support using an implicit cast as an l-value } standard output = { } |
