summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2017-11-07 11:57:58 -0800
committerGitHub <noreply@github.com>2017-11-07 11:57:58 -0800
commita54364303241e3cd7c3d075ee1dd4164915d939f (patch)
treeb7560ff41a43cda235ab7db8a19fd2371e3f7ba8
parentccea5702442a7a8303e6735a038be86939c1ce7a (diff)
parentd1b45f3059e100d096327eb178c1bac365e564f1 (diff)
Merge branch 'master' into falcor-integration-work
-rw-r--r--source/slang/emit.cpp17
-rw-r--r--source/slang/lower-to-ir.cpp5
-rw-r--r--tests/compute/select-expr.slang18
-rw-r--r--tests/compute/select-expr.slang.expected.txt4
4 files changed, 39 insertions, 5 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp
index 617e25d71..9fda630bf 100644
--- a/source/slang/emit.cpp
+++ b/source/slang/emit.cpp
@@ -5104,6 +5104,13 @@ emitDeclImpl(decl, nullptr);
}
break;
+ case kIROp_Neg:
+ {
+ emit("-");
+ emitIROperand(ctx, inst->getArg(0));
+ }
+ break;
+
case kIROp_Sample:
emitIROperand(ctx, inst->getArg(0));
emit(".Sample(");
@@ -5226,6 +5233,16 @@ emitDeclImpl(decl, nullptr);
}
break;
+ case kIROp_Select:
+ {
+ emitIROperand(ctx, inst->getArg(0));
+ emit(" ? ");
+ emitIROperand(ctx, inst->getArg(1));
+ emit(" : ");
+ emitIROperand(ctx, inst->getArg(2));
+ }
+ break;
+
default:
emit("/* unhandled */");
break;
diff --git a/source/slang/lower-to-ir.cpp b/source/slang/lower-to-ir.cpp
index 2672c5698..2c64c539b 100644
--- a/source/slang/lower-to-ir.cpp
+++ b/source/slang/lower-to-ir.cpp
@@ -1497,11 +1497,6 @@ struct ExprLoweringVisitorBase : ExprVisitor<Derived, LoweredValInfo>
return emitDeclRef(context, expr->declRef);
}
- LoweredValInfo visitSelectExpr(SelectExpr* /*expr*/)
- {
- SLANG_UNIMPLEMENTED_X("codegen for select expression");
- }
-
LoweredValInfo visitGenericAppExpr(GenericAppExpr* /*expr*/)
{
SLANG_UNIMPLEMENTED_X("generic application expression during code generation");
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