summaryrefslogtreecommitdiffstats
path: root/tests/compute
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2017-11-07 11:57:48 -0800
committerGitHub <noreply@github.com>2017-11-07 11:57:48 -0800
commitd1b45f3059e100d096327eb178c1bac365e564f1 (patch)
tree161fd25105ed7e924f1ad5b53517c55f101ddd5a /tests/compute
parent9919c823938ae929b16efac9d507f6d5eb122bf4 (diff)
IR: support for select and negate (#257)
- During IR emit, treat a "select" expression (`?:` operator) like any other `InvokeExpr`, since it will have an `__intrinsic_op` modifier attached to turn it into a `select` instruction. - During HLSL/GLSL emit from IR, turn a `select` instruction into a `?:` expression - Also add support for the `neg` instruction during HLSL/GLSL emit Note that right now we are assuming HLSL semantics for `?:` where it does not short-circuit. Correctly handling the GLSL case would require going back to special-case codegen for `SelectExpr`, but we can cross that bridge when we come to it.
Diffstat (limited to 'tests/compute')
-rw-r--r--tests/compute/select-expr.slang18
-rw-r--r--tests/compute/select-expr.slang.expected.txt4
2 files changed, 22 insertions, 0 deletions
diff --git a/tests/compute/select-expr.slang b/tests/compute/select-expr.slang
new file mode 100644
index 000000000..d90708ab9
--- /dev/null
+++ b/tests/compute/select-expr.slang
@@ -0,0 +1,18 @@
+//TEST(smoke,compute):COMPARE_COMPUTE:
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out
+
+
+// Test IR code generation for the `?:` "select" operator
+
+int test(int input)
+{
+ return input > 1 ? -input : input;
+}
+
+RWStructuredBuffer<int> outputBuffer;
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ outputBuffer[dispatchThreadID.x] = test((int) dispatchThreadID.x);
+} \ No newline at end of file
diff --git a/tests/compute/select-expr.slang.expected.txt b/tests/compute/select-expr.slang.expected.txt
new file mode 100644
index 000000000..384f9a732
--- /dev/null
+++ b/tests/compute/select-expr.slang.expected.txt
@@ -0,0 +1,4 @@
+0
+1
+FFFFFFFE
+FFFFFFFD