From 83876733d69582eec6bad26af64a651d40fa43aa Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 21 Mar 2023 20:03:12 -0700 Subject: Fix associated type resolution bug. (#2719) * Fix associated type resolution bug. * Fix. * Fix language server hinting messed up by breadcrumb nodes. --------- Co-authored-by: Yong He --- tests/autodiff/diff-assoc-type.slang | 30 +++++++++++++++++++++++ tests/autodiff/diff-assoc-type.slang.expected.txt | 2 ++ 2 files changed, 32 insertions(+) create mode 100644 tests/autodiff/diff-assoc-type.slang create mode 100644 tests/autodiff/diff-assoc-type.slang.expected.txt (limited to 'tests') diff --git a/tests/autodiff/diff-assoc-type.slang b/tests/autodiff/diff-assoc-type.slang new file mode 100644 index 000000000..60a80b32c --- /dev/null +++ b/tests/autodiff/diff-assoc-type.slang @@ -0,0 +1,30 @@ +// Tests automatic synthesis of Differential type and method requirements. + +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type + +//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +struct B : IDifferentiable +{ + float x; +} + +float myFunc(DifferentialPair d) +{ + return d.p.x + d.d.x; +} + +float myFunc2(DifferentialPair.Differential d) +{ + return d.p.x + d.d.x; +} + +[numthreads(1, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + B.Differential bd; + bd.x = 1.0; + outputBuffer[0] = myFunc(diffPair(bd, bd)) + myFunc2(diffPair(bd, bd)); +} diff --git a/tests/autodiff/diff-assoc-type.slang.expected.txt b/tests/autodiff/diff-assoc-type.slang.expected.txt new file mode 100644 index 000000000..bc795a8ba --- /dev/null +++ b/tests/autodiff/diff-assoc-type.slang.expected.txt @@ -0,0 +1,2 @@ +type: float +4.0 -- cgit v1.2.3