summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/compute/half-calc.slang32
-rw-r--r--tests/compute/half-calc.slang.expected.txt4
-rw-r--r--tests/compute/half-structured-buffer.slang30
-rw-r--r--tests/compute/half-structured-buffer.slang.expected.txt16
4 files changed, 82 insertions, 0 deletions
diff --git a/tests/compute/half-calc.slang b/tests/compute/half-calc.slang
new file mode 100644
index 000000000..b47678dae
--- /dev/null
+++ b/tests/compute/half-calc.slang
@@ -0,0 +1,32 @@
+//TEST(compute):COMPARE_COMPUTE:-dx12 -compute -use-dxil -profile cs_6_2 -render-features half
+//TEST(compute):COMPARE_COMPUTE:-vk -compute -use-dxil -profile cs_6_2 -render-features half
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out
+
+// Test for doing a calculation using half
+
+RWStructuredBuffer<float> outputBuffer;
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ uint tid = dispatchThreadID.x;
+
+ //half2 v0 = { 1, -2 };
+ //half2 v1 = { -2, 4 };
+
+ //half2 v2 = (v0 * 2.0f + v1);
+
+ // This should work (it compiles on dxc, but slang doesn't seem to have overloads yet)
+ //half offset = length(v2);
+
+ //half offset = v2.x + v2.y;
+
+ half offset = 0.0f;
+
+ half v = tid;
+ v *= half(3.0f);
+ v += half(1.0f);
+ v += offset;
+
+ 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
new file mode 100644
index 000000000..2915a0dbc
--- /dev/null
+++ b/tests/compute/half-calc.slang.expected.txt
@@ -0,0 +1,4 @@
+3F800000
+40800000
+40E00000
+41200000
diff --git a/tests/compute/half-structured-buffer.slang b/tests/compute/half-structured-buffer.slang
new file mode 100644
index 000000000..e67aba55e
--- /dev/null
+++ b/tests/compute/half-structured-buffer.slang
@@ -0,0 +1,30 @@
+//TEST(compute):COMPARE_COMPUTE:-vk -compute -profile cs_6_2 -render-features half
+//Disable on Dx12 for now - because writing to structured buffer produces unexpected results
+//DISABLE_TEST(compute):COMPARE_COMPUTE:-dx12 -compute -use-dxil -profile cs_6_2 -render-features half
+//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0], stride=16):dxbinding(0),glbinding(0),out
+
+struct Thing
+{
+ uint pos;
+ float radius;
+ half4 color;
+};
+
+RWStructuredBuffer<Thing> outputBuffer;
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ uint tid = dispatchThreadID.x;
+
+ float v = float(tid);
+
+ float base = v* 4.0f;
+
+ Thing thing;
+ thing.pos = tid;
+ thing.color = half4(base, base + 1.0f, base + 2.0f, base + 3.0f);
+ thing.radius = v;
+
+ outputBuffer[tid] = thing;
+} \ No newline at end of file
diff --git a/tests/compute/half-structured-buffer.slang.expected.txt b/tests/compute/half-structured-buffer.slang.expected.txt
new file mode 100644
index 000000000..9170926f3
--- /dev/null
+++ b/tests/compute/half-structured-buffer.slang.expected.txt
@@ -0,0 +1,16 @@
+0
+0
+3C000000
+42004000
+1
+3F800000
+45004400
+47004600
+2
+40000000
+48804800
+49804900
+3
+40400000
+4A804A00
+4B804B00