summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/hlsl-intrinsic/f16tof32.slang18
-rw-r--r--tests/hlsl-intrinsic/f16tof32.slang.expected.txt8
-rw-r--r--tests/hlsl-intrinsic/f32tof16.slang37
-rw-r--r--tests/hlsl-intrinsic/f32tof16.slang.expected.txt8
4 files changed, 71 insertions, 0 deletions
diff --git a/tests/hlsl-intrinsic/f16tof32.slang b/tests/hlsl-intrinsic/f16tof32.slang
new file mode 100644
index 000000000..b73ade4cf
--- /dev/null
+++ b/tests/hlsl-intrinsic/f16tof32.slang
@@ -0,0 +1,18 @@
+//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute
+//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer
+RWStructuredBuffer<float> outputBuffer;
+
+[numthreads(8, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int idx = int(dispatchThreadID.x);
+
+ uint values[] = { 0, 0xC600, 0x4A00, 0xCE00, 0x2555, 0xA155, 0x1D55, 0x9955 };
+
+ outputBuffer[idx] = f16tof32(values[idx]);
+} \ No newline at end of file
diff --git a/tests/hlsl-intrinsic/f16tof32.slang.expected.txt b/tests/hlsl-intrinsic/f16tof32.slang.expected.txt
new file mode 100644
index 000000000..833998d8e
--- /dev/null
+++ b/tests/hlsl-intrinsic/f16tof32.slang.expected.txt
@@ -0,0 +1,8 @@
+0
+C0C00000
+41400000
+C1C00000
+3CAAA000
+BC2AA000
+3BAAA000
+BB2AA000
diff --git a/tests/hlsl-intrinsic/f32tof16.slang b/tests/hlsl-intrinsic/f32tof16.slang
new file mode 100644
index 000000000..465b2840a
--- /dev/null
+++ b/tests/hlsl-intrinsic/f32tof16.slang
@@ -0,0 +1,37 @@
+//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute
+//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer
+RWStructuredBuffer<uint> outputBuffer;
+
+[numthreads(8, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int idx = int(dispatchThreadID.x);
+
+ // We want to test 0
+ float value = 0.0f;
+ // Produces some somewhat interesting numbers
+ if (idx != 0)
+ {
+ value = (3 << idx);
+
+ if ((idx & 1) != 0)
+ {
+ value = -value;
+ }
+
+ // Do the recip
+ if ((idx & 4) != 0)
+ {
+ value = 1.0f / value;
+ }
+ }
+
+ uint r = f32tof16(value);
+
+ outputBuffer[idx] = r;
+} \ No newline at end of file
diff --git a/tests/hlsl-intrinsic/f32tof16.slang.expected.txt b/tests/hlsl-intrinsic/f32tof16.slang.expected.txt
new file mode 100644
index 000000000..2a2175a43
--- /dev/null
+++ b/tests/hlsl-intrinsic/f32tof16.slang.expected.txt
@@ -0,0 +1,8 @@
+0
+C600
+4A00
+CE00
+2555
+A155
+1D55
+9955