diff options
| author | Yong He <yonghe@outlook.com> | 2024-02-20 21:35:03 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-20 21:35:03 -0800 |
| commit | 2ee05c1257c916e5c804a6b565a2a6aa362050e0 (patch) | |
| tree | eab2a825afa5b8b48f62b5e6fd513f16a9e754e7 /tools | |
| parent | a62be597990966b9516995650baf750ee6a0146b (diff) | |
Add wrapper type syntax for link time specialization. (#3606)
* Add wrapper type syntax for link time specialization.
* Cleanup.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/gfx-unit-test/link-time-type.cpp | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/tools/gfx-unit-test/link-time-type.cpp b/tools/gfx-unit-test/link-time-type.cpp index 0eda4487e..7f470c619 100644 --- a/tools/gfx-unit-test/link-time-type.cpp +++ b/tools/gfx-unit-test/link-time-type.cpp @@ -16,7 +16,24 @@ namespace gfx_test slang::ProgramLayout*& slangReflection) { const char* moduleInterfaceSrc = R"( - interface IFoo { [mutating] void setValue(float v); float getValue(); } + interface IFoo + { + static const int offset; + [mutating] void setValue(float v); + float getValue(); + property float val2{get;set;} + } + struct FooImpl : IFoo + { + float val; + static const int offset = -1; + [mutating] void setValue(float v) { val = v; } + float getValue() { return val + 1.0; } + property float val2 { + get { return val + 2.0; } + set { val = newValue; } + } + }; )"; const char* module0Src = R"( import ifoo; @@ -27,17 +44,12 @@ namespace gfx_test { Foo foo; foo.setValue(3.0); - buffer[0] = foo.getValue(); + buffer[0] = foo.getValue() + foo.val2 + Foo.offset; } )"; const char* module1Src = R"( import ifoo; - export struct Foo : IFoo - { - float val; - [mutating] void setValue(float v) { val = v; } - float getValue() { return val + 1.0; } - }; + export struct Foo : IFoo = FooImpl; )"; Slang::ComPtr<slang::ISession> slangSession; SLANG_RETURN_ON_FAIL(device->getSlangSession(slangSession.writeRef())); @@ -158,7 +170,7 @@ namespace gfx_test compareComputeResult( device, numbersBuffer, - Slang::makeArray<float>(4.0)); + Slang::makeArray<float>(8.0)); } SLANG_UNIT_TEST(linkTimeTypeD3D12) |
