summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs/gh-487.slang30
-rw-r--r--tests/bugs/gh-487.slang.expected.txt4
2 files changed, 34 insertions, 0 deletions
diff --git a/tests/bugs/gh-487.slang b/tests/bugs/gh-487.slang
new file mode 100644
index 000000000..ee01ee9b1
--- /dev/null
+++ b/tests/bugs/gh-487.slang
@@ -0,0 +1,30 @@
+// gh-487.slang
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute
+
+// This test is to confirm that we can apply builtin functions taht expect
+// a floating-point argument to an integer, with the compiler filling
+// in the implicit conversion. This is made tricky by the fact
+// that a builtin line `sqrt` is actually a constrained generic,
+// `sqrt<T:BuiltinFloatingPointType>` so that inference currently
+// fails to deduce `T=float` when presented with an `int` argument.
+
+int test(int val)
+{
+ int squared = val * val;
+ float result = sqrt(squared);
+ return int(result);
+}
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out
+RWStructuredBuffer<int> gBuffer;
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ uint tid = dispatchThreadID.x;
+
+ int inVal = tid;
+ int outVal = test(inVal);
+
+ gBuffer[tid] = outVal;
+} \ No newline at end of file
diff --git a/tests/bugs/gh-487.slang.expected.txt b/tests/bugs/gh-487.slang.expected.txt
new file mode 100644
index 000000000..bc856dafa
--- /dev/null
+++ b/tests/bugs/gh-487.slang.expected.txt
@@ -0,0 +1,4 @@
+0
+1
+2
+3