From 11f44241ffef478560eaba79af330c16f0bc8d69 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Mon, 30 Oct 2017 10:03:52 -0700 Subject: Allow for implicit `this` expressions. - When peforming ordinary lookup, if the container declaration for a scope is an aggregate type or `extension` decl, then use a "breadcrumb" to make sure that we use a `this` expression as the base of any resulting declaration reference - Add a test case for implicit `this` usage - Update constrained generic test case to use implicit `this` for member reference, as was originally intended --- tests/compute/implicit-this-expr.slang | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/compute/implicit-this-expr.slang (limited to 'tests/compute/implicit-this-expr.slang') 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 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 -- cgit v1.2.3