summaryrefslogtreecommitdiff
path: root/tests/bugs/operator-overload.slang
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-04-26 10:10:17 -0400
committerGitHub <noreply@github.com>2022-04-26 10:10:17 -0400
commit66ad0072821b58318c6dc5d2d64c966e312951dd (patch)
tree1d28f0dcf23ca9ac40f4fdd0b92eb5a55b170df1 /tests/bugs/operator-overload.slang
parentb69b0e43e27ec94c0397774db804b4077b062b21 (diff)
Overloaded name lookup fix (#2199)
* #include an absolute path didn't work - because paths were taken to always be relative. * Fix for overloaded name lookup. * Small improvements.
Diffstat (limited to 'tests/bugs/operator-overload.slang')
-rw-r--r--tests/bugs/operator-overload.slang31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/bugs/operator-overload.slang b/tests/bugs/operator-overload.slang
new file mode 100644
index 000000000..b70b9b987
--- /dev/null
+++ b/tests/bugs/operator-overload.slang
@@ -0,0 +1,31 @@
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
+
+// Tests operator overloading works in user space.
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+struct Vec2d
+{
+ float x, y;
+};
+
+Vec2d operator+(Vec2d a, Vec2d b)
+{
+ return {a.x + b.x, a.y + b.y};
+}
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int index = dispatchThreadID.x;
+
+ Vec2d a = { 1, -index + 3 };
+ Vec2d b = { index - 4, index * index };
+
+ Vec2d c = a + b;
+
+ int r = int(c.x + c.y);
+
+ outputBuffer[dispatchThreadID.x] = int(r);
+} \ No newline at end of file