From 2ee05c1257c916e5c804a6b565a2a6aa362050e0 Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 20 Feb 2024 21:35:03 -0800 Subject: Add wrapper type syntax for link time specialization. (#3606) * Add wrapper type syntax for link time specialization. * Cleanup. --- tools/gfx-unit-test/link-time-type.cpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'tools/gfx-unit-test/link-time-type.cpp') 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 slangSession; SLANG_RETURN_ON_FAIL(device->getSlangSession(slangSession.writeRef())); @@ -158,7 +170,7 @@ namespace gfx_test compareComputeResult( device, numbersBuffer, - Slang::makeArray(4.0)); + Slang::makeArray(8.0)); } SLANG_UNIT_TEST(linkTimeTypeD3D12) -- cgit v1.2.3