diff options
| author | Yong He <yonghe@outlook.com> | 2019-01-25 08:08:01 -0800 |
|---|---|---|
| committer | Tim Foley <tfoleyNV@users.noreply.github.com> | 2019-01-25 08:08:01 -0800 |
| commit | 3048d5da46112a2c6c312922ed3f024e14b8a79f (patch) | |
| tree | eb2a47e53036208b02c767f69b1f661270d84ff8 /tests/compute/empty-struct2.slang | |
| parent | 8171a553c2523906240f5653cd1fa5c169dd89b9 (diff) | |
Fixup handling of empty structs in function return types and parameters. (#796)
* Fixup handling of empty structs in function return types and parameters.
* Bug fix in legalizeFunc()
* More comprehensive empty struct test
* Fix `legalizeFieldExtract` for empty struct field.
* Add empty struct handling for construct inst
Diffstat (limited to 'tests/compute/empty-struct2.slang')
| -rw-r--r-- | tests/compute/empty-struct2.slang | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/compute/empty-struct2.slang b/tests/compute/empty-struct2.slang new file mode 100644 index 000000000..17cbb6ab4 --- /dev/null +++ b/tests/compute/empty-struct2.slang @@ -0,0 +1,52 @@ +//TEST(smoke,compute):COMPARE_COMPUTE: +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out +// This is a basic test for Slang compute shader. + +RWStructuredBuffer<uint> outputBuffer; + +interface IInterface +{ + associatedtype T; + T getT(); + [mutating] + void setT(T val); +} +interface IEmptyS +{ + float emptyFunc(); +}; +struct EmptyS : IEmptyS +{ + float emptyFunc() {return 0.0;} +}; + +struct Empty<TT : IEmptyS> : IInterface +{ + typedef TT T; + TT value; + float a; + TT getT() + { + return value; + } + [mutating] + void setT(TT val) + { + value = val; + a = value.emptyFunc(); + } +} + +void test<Obj : IInterface>(Obj obj) +{ + Obj.T v = obj.getT(); + obj.setT(v); +} + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + Empty<EmptyS> obj; + test(obj); + outputBuffer[dispatchThreadID.x] = dispatchThreadID.x; +}
\ No newline at end of file |
