summaryrefslogtreecommitdiffstats
path: root/tests/compute
diff options
context:
space:
mode:
authorkaizhangNV <149626564+kaizhangNV@users.noreply.github.com>2024-12-17 19:06:30 -0600
committerGitHub <noreply@github.com>2024-12-17 17:06:30 -0800
commit6f57e47a9e1675b011f023277b47cfc768d30da8 (patch)
treeed9d531c1e1e4f55650314956c485d5107130a21 /tests/compute
parent49e912a9d0d6ca5f762ec11cd8cb918f182eb76e (diff)
Implement bitcast for 64-bit date type (#5895)
Close #5470 * implement bitcast for 64-bit date type * Move 'ensurePrelude' to base class to remove duplication * Assert on 'double' type for Metal target, as Metal doesn't have 'double' support
Diffstat (limited to 'tests/compute')
-rw-r--r--tests/compute/bitcast-64bit.slang43
-rw-r--r--tests/compute/bitcast-64bit.slang.expected.txt5
2 files changed, 48 insertions, 0 deletions
diff --git a/tests/compute/bitcast-64bit.slang b/tests/compute/bitcast-64bit.slang
new file mode 100644
index 000000000..410fa768a
--- /dev/null
+++ b/tests/compute/bitcast-64bit.slang
@@ -0,0 +1,43 @@
+//TEST(compute):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -emit-spirv-via-glsl -output-using-type
+//TEST(compute):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -d3d12 -profile cs_6_6 -use-dxil -shaderobj -output-using-type
+//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj -output-using-type
+//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj -output-using-type
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name=gOutputBuffer
+RWStructuredBuffer<uint64_t> gOutputBuffer;
+
+int64_t icast(double x)
+{
+ return bit_cast<int64_t>(x);
+}
+
+int64_t icast(uint64_t x)
+{
+ return bit_cast<int64_t>(x);
+}
+
+uint64_t ucast(double x)
+{
+ return bit_cast<uint64_t>(x);
+}
+
+uint64_t ucast(int64_t x)
+{
+ return bit_cast<uint64_t>(x);
+}
+
+[numthreads(1, 1, 1)]
+[shader("compute")]
+void computeMain()
+{
+ double t1 = -1.0;
+ uint64_t t2 = 2;
+ gOutputBuffer[0] = icast(t1); // 0xBFF0000000000000 => 13830554455654793216
+ gOutputBuffer[1] = icast(t2); // 0x0000000000000002 => 2
+
+ double t3 = 3.0;
+ int64_t t4 = -4;
+ gOutputBuffer[2] = ucast(t3); // 0x4008000000000000 => 4613937818241073152
+ gOutputBuffer[3] = ucast(t4); // 0xFFFFFFFFFFFFFFFC => 18446744073709551612
+}
diff --git a/tests/compute/bitcast-64bit.slang.expected.txt b/tests/compute/bitcast-64bit.slang.expected.txt
new file mode 100644
index 000000000..cb9a9f87d
--- /dev/null
+++ b/tests/compute/bitcast-64bit.slang.expected.txt
@@ -0,0 +1,5 @@
+type: uint64_t
+13830554455654793216
+2
+4613937818241073152
+18446744073709551612