From 21c663605330d629e9022314a4720b86b017f295 Mon Sep 17 00:00:00 2001 From: kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> Date: Tue, 23 Sep 2025 11:06:44 -0500 Subject: Lookup refactor (#8467) Close #8201. This PR unify the lowering logic for LookupDeclRef of an interface requirement. We will always lower this AST node to a LookupWitness IR. The key of this IR is the special witnessTableType `ThisTypeWitness`, this witness Table is simply a wrapper for an interface type. Our current specialization pass doesn't handle this kind of LookupWitness IR at all, so we will also add the specialization of this_type IR as well. --- ...differential-ptr-pair-with-associate-type.slang | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tests/autodiff/differential-ptr-pair-with-associate-type.slang (limited to 'tests') diff --git a/tests/autodiff/differential-ptr-pair-with-associate-type.slang b/tests/autodiff/differential-ptr-pair-with-associate-type.slang new file mode 100644 index 000000000..870660b84 --- /dev/null +++ b/tests/autodiff/differential-ptr-pair-with-associate-type.slang @@ -0,0 +1,42 @@ +//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-vk -compute -shaderobj -output-using-type +//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-cuda -compute -shaderobj -output-using-type +interface IFoo +{ + associatedtype Parameters : IDifferentiablePtrType; + property DifferentialPtrPair parametersDual { get; } +} + +extension T: IDifferentiablePtrType +{ + typealias Differential = T; +} + +struct Foo : IFoo +{ + typealias Parameters = Array; + property DifferentialPtrPair parametersDual + { + get + { + Parameters primal = {T(1)}; + Parameters diff = {T(2)}; + return DifferentialPtrPair(primal, diff); + } + } +} + +//TEST_INPUT:ubuffer(data=[0 0], stride=4):out,name=output +RWStructuredBuffer output; + +[shader("compute")] +[numthreads(1, 1, 1)] +void computeMain() +{ + Foo foo; + let res = foo.parametersDual; + output[0] = res.p[0]; + output[1] = res.d[0]; + + // CHECK: 1.0 + // CHECK: 2.0 +} -- cgit v1.2.3