diff options
| author | Yong He <yonghe@outlook.com> | 2017-10-30 19:31:52 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-10-30 19:31:52 -0400 |
| commit | 832d9c708891b10145c6648d893b04ca4a0b879a (patch) | |
| tree | e1f44fc27bf80d94de5ac0e866c7409b2adcec22 /tests/compute/implicit-this-expr.slang | |
| parent | c24c173101c2c124401af77d8c513a23efac3b7e (diff) | |
| parent | 3ffdf610d05a9318731bd7237da530c3d312a9a9 (diff) | |
Merge pull request #235 from tfoleyNV/explicit-this-expr
Support `this` expressions (explicit and implicit)
Diffstat (limited to 'tests/compute/implicit-this-expr.slang')
| -rw-r--r-- | tests/compute/implicit-this-expr.slang | 34 |
1 files changed, 34 insertions, 0 deletions
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 |
