From 0f2578d7b3e75c0e5ef724ffe610d004fb116a03 Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 7 Nov 2023 19:03:52 -0800 Subject: Add `IRThisTypeWitness` to stand in for witness lookups inside an interface definition. (#3316) Co-authored-by: Yong He --- tests/autodiff/differentiable-constructor.slang | 38 +++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/autodiff/differentiable-constructor.slang (limited to 'tests/autodiff') diff --git a/tests/autodiff/differentiable-constructor.slang b/tests/autodiff/differentiable-constructor.slang new file mode 100644 index 000000000..8528f3792 --- /dev/null +++ b/tests/autodiff/differentiable-constructor.slang @@ -0,0 +1,38 @@ +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -shaderobj -output-using-type +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -vk -shaderobj -output-using-type + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +interface IFoo : IDifferentiable +{ + [Differentiable] + __init(); + + float compute(float y); +} + +struct Impl : IFoo +{ + float x; + [Differentiable] + __init() + { + x = 4.0; + } + + float compute(int id) { return outputBuffer[id] = detach(x);} +} + +float test(int id) +{ + T t; + return t.compute(id); +} + +[numthreads(1, 1, 1)] +void computeMain(uint id : SV_DispatchThreadID) +{ + // CHECK: 4.0 + test(id); +} -- cgit v1.2.3