summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/hlsl-intrinsic/asfloat16.slang25
-rw-r--r--tests/hlsl-intrinsic/asfloat16.slang.expected.txt9
2 files changed, 34 insertions, 0 deletions
diff --git a/tests/hlsl-intrinsic/asfloat16.slang b/tests/hlsl-intrinsic/asfloat16.slang
new file mode 100644
index 000000000..1c1e8a085
--- /dev/null
+++ b/tests/hlsl-intrinsic/asfloat16.slang
@@ -0,0 +1,25 @@
+// Float16 not supported on CPU currently
+//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type
+// Doesn't work on FXC
+//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -output-using-type
+
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -use-dxil -profile sm_6_2 -render-feature half -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -render-feature int16,half -output-using-type
+//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -render-features half -output-using-type
+
+//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);
+
+ // 1
+ float16_t m = asfloat16(uint16_t(0x3c00));
+
+ float16_t v = asfloat16(uint16_t(0x3c00 + (idx << 8))) + m;
+ float f = v;
+
+ outputBuffer[idx] = f;
+} \ No newline at end of file
diff --git a/tests/hlsl-intrinsic/asfloat16.slang.expected.txt b/tests/hlsl-intrinsic/asfloat16.slang.expected.txt
new file mode 100644
index 000000000..a63c5c85a
--- /dev/null
+++ b/tests/hlsl-intrinsic/asfloat16.slang.expected.txt
@@ -0,0 +1,9 @@
+type: float
+2.000000
+2.250000
+2.500000
+2.750000
+3.000000
+3.500000
+4.000000
+4.500000