diff options
Diffstat (limited to 'tests/compute')
| -rw-r--r-- | tests/compute/half-calc.slang | 4 | ||||
| -rw-r--r-- | tests/compute/half-calc.slang.expected.txt | 8 | ||||
| -rw-r--r-- | tests/compute/half-structured-buffer.slang | 2 | ||||
| -rw-r--r-- | tests/compute/half-vector-calc.slang | 4 | ||||
| -rw-r--r-- | tests/compute/half-vector-calc.slang.expected.txt | 8 | ||||
| -rw-r--r-- | tests/compute/half-vector-compare.slang | 98 | ||||
| -rw-r--r-- | tests/compute/half-vector-compare.slang.expected.txt | 5 |
7 files changed, 121 insertions, 8 deletions
diff --git a/tests/compute/half-calc.slang b/tests/compute/half-calc.slang index e0dd01315..0f321ef98 100644 --- a/tests/compute/half-calc.slang +++ b/tests/compute/half-calc.slang @@ -29,5 +29,9 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) v += half(1.0f); v += offset; + v++; + --v; + v--; + outputBuffer[tid] = v; }
\ No newline at end of file diff --git a/tests/compute/half-calc.slang.expected.txt b/tests/compute/half-calc.slang.expected.txt index 2915a0dbc..389e44adf 100644 --- a/tests/compute/half-calc.slang.expected.txt +++ b/tests/compute/half-calc.slang.expected.txt @@ -1,4 +1,4 @@ -3F800000 -40800000 -40E00000 -41200000 +0 +40400000 +40C00000 +41100000 diff --git a/tests/compute/half-structured-buffer.slang b/tests/compute/half-structured-buffer.slang index db0837d53..e701bb0fa 100644 --- a/tests/compute/half-structured-buffer.slang +++ b/tests/compute/half-structured-buffer.slang @@ -1,4 +1,6 @@ //TEST(compute):COMPARE_COMPUTE:-vk -compute -profile cs_6_2 -render-features half -shaderobj +//TEST(compute):COMPARE_COMPUTE:-cuda -compute -render-features half -shaderobj + //Disable on Dx12 for now - because writing to structured buffer produces unexpected results //TEST_DISABLED(compute):COMPARE_COMPUTE:-dx12 -compute -use-dxil -profile cs_6_2 -render-features half -shaderobj diff --git a/tests/compute/half-vector-calc.slang b/tests/compute/half-vector-calc.slang index 3ae204796..b145e27ec 100644 --- a/tests/compute/half-vector-calc.slang +++ b/tests/compute/half-vector-calc.slang @@ -23,6 +23,10 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) v1 += v2.wzy; v2 += v0.xyxy; + v1 ++; + --v2; + v3++; + // Unary v2 = +v2.yxwz; v2 = -v2.zwxy; diff --git a/tests/compute/half-vector-calc.slang.expected.txt b/tests/compute/half-vector-calc.slang.expected.txt index 49c339529..2e80e4e2a 100644 --- a/tests/compute/half-vector-calc.slang.expected.txt +++ b/tests/compute/half-vector-calc.slang.expected.txt @@ -1,5 +1,5 @@ type: float -30.000000 -161.500000 -492.000000 -1021.500000 +73.000000 +206.500000 +539.000000 +1070.000000 diff --git a/tests/compute/half-vector-compare.slang b/tests/compute/half-vector-compare.slang new file mode 100644 index 000000000..5f4670456 --- /dev/null +++ b/tests/compute/half-vector-compare.slang @@ -0,0 +1,98 @@ +//DISABLE_TEST(compute):COMPARE_COMPUTE:-dx12 -compute -output-using-type -use-dxil -profile cs_6_2 -render-features half -shaderobj +//TEST(compute):COMPARE_COMPUTE:-vk -compute -output-using-type -profile cs_6_2 -render-features half -shaderobj +//TEST(compute):COMPARE_COMPUTE:-cuda -compute -output-using-type -render-features half -shaderobj + +// Test for doing a calculation using half + +//TEST_INPUT:ubuffer(data=[0.2 10.0 12.0 16.0], stride=4):name=inputBuffer +RWStructuredBuffer<int> inputBuffer; + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer<float> outputBuffer; + +struct Values +{ + __init(int index) + { + m_index = index; + } + + [mutating] half next() + { + float v = inputBuffer[m_index & 3]; + m_index++; + return half(v); + } + + int m_index = 0; +}; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + + Values values = Values(int(tid)); + + int r = 0; + + half s0 = values.next(); + half s1 = values.next(); + + if (s0 < s1) + { + r += 0x1; + } + + half2 h2_0 = half2(values.next(), values.next()); + half2 h2_1 = half2(values.next(), values.next()); + + if (any(h2_0 < h2_1)) + { + r += 0x2; + } + + if (all(h2_0 < h2_1)) + { + r += 0x4; + } + + half3 h3_0 = half3(values.next(), values.next(), values.next()); + half3 h3_1 = half3(values.next(), values.next(), values.next()); + + if (any(h3_0 > h3_1)) + { + r += 0x8; + } + + if (all(h3_0 <= h3_1)) + { + r += 0x10; + } + + half4 h4_0 = half4(values.next(), values.next(), values.next(), values.next()); + half4 h4_1 = half4(values.next(), values.next(), values.next(), values.next()); + + + if (any(h4_0 > h4_1)) + { + r += 0x8; + } + + if (all(h4_0 <= h4_1)) + { + r += 0x10; + } + + if (any(!(h4_0 == h4_1))) + { + r += 0x20; + } + + if (all(h4_0 != h4_1)) + { + r += 0x40; + } + + outputBuffer[tid] = r; +} diff --git a/tests/compute/half-vector-compare.slang.expected.txt b/tests/compute/half-vector-compare.slang.expected.txt new file mode 100644 index 000000000..51c83b301 --- /dev/null +++ b/tests/compute/half-vector-compare.slang.expected.txt @@ -0,0 +1,5 @@ +type: float +32.000000 +32.000000 +32.000000 +32.000000 |
