summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/compute/generics-constrained.slang4
-rw-r--r--tests/compute/generics-constrained.slang.expected.txt6
-rw-r--r--tests/compute/implicit-this-expr.slang34
-rw-r--r--tests/compute/implicit-this-expr.slang.expected.txt4
4 files changed, 42 insertions, 6 deletions
diff --git a/tests/compute/generics-constrained.slang b/tests/compute/generics-constrained.slang
index 669674376..c8ab71bfa 100644
--- a/tests/compute/generics-constrained.slang
+++ b/tests/compute/generics-constrained.slang
@@ -17,9 +17,7 @@ struct A : Helper
// TODO: we should be able to reference a member variable here,
// but the front-end isn't handling references through `this`
// properly yet.
-// return a;
-
- return 1.0f;
+ return a;
}
};
diff --git a/tests/compute/generics-constrained.slang.expected.txt b/tests/compute/generics-constrained.slang.expected.txt
index cc5e55ab6..ae6b9920b 100644
--- a/tests/compute/generics-constrained.slang.expected.txt
+++ b/tests/compute/generics-constrained.slang.expected.txt
@@ -1,4 +1,4 @@
+0
3F800000
-3F800000
-3F800000
-3F800000
+40000000
+40400000
diff --git a/tests/compute/implicit-this-expr.slang b/tests/compute/implicit-this-expr.slang
new file mode 100644
index 000000000..339c5fb6a
--- /dev/null
+++ b/tests/compute/implicit-this-expr.slang
@@ -0,0 +1,34 @@
+//TEST(smoke,compute):COMPARE_COMPUTE:-xslang -use-ir
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out
+
+// Access fields of a `struct` type from within a "method" by
+// using an implicit `this` expression.
+
+struct A
+{
+ float x;
+
+ float addWith(float y)
+ {
+ return x + y;
+ }
+};
+
+RWStructuredBuffer<float> outputBuffer : register(u0);
+
+
+float test(float inVal)
+{
+ A a;
+ a.x = inVal;
+ return a.addWith(inVal*inVal);
+}
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ uint tid = dispatchThreadID.x;
+ float inVal = float(tid);
+ float outVal = test(inVal);
+ outputBuffer[tid] = outVal;
+} \ No newline at end of file
diff --git a/tests/compute/implicit-this-expr.slang.expected.txt b/tests/compute/implicit-this-expr.slang.expected.txt
new file mode 100644
index 000000000..f73cfe6c3
--- /dev/null
+++ b/tests/compute/implicit-this-expr.slang.expected.txt
@@ -0,0 +1,4 @@
+0
+40000000
+40C00000
+41400000