From 54d9b345bff4b01949e875366cb1e7cf1c021c61 Mon Sep 17 00:00:00 2001 From: "James Helferty (NVIDIA)" Date: Wed, 8 Oct 2025 19:11:10 -0400 Subject: parser: Avoid dropping modifiers when splitting list (#8546) Fix for a linked list usage bug; avoids dropping any modifiers when moving type modifiers from a linked list of modifiers into their own linked list. Since this change results in no_diff modifiers to traditional functions ending up on the return type instead of the function (due to the order they're parsed in), we duplicate the no_diff modifier onto the function declaration after the fact. Includes a test for the original issue. The no_diff redistribution case is covered by a slangpy device test case. Fixes #8332 --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --- tests/autodiff/no-diff-static.slang | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/autodiff/no-diff-static.slang (limited to 'tests') diff --git a/tests/autodiff/no-diff-static.slang b/tests/autodiff/no-diff-static.slang new file mode 100644 index 000000000..15d316a90 --- /dev/null +++ b/tests/autodiff/no-diff-static.slang @@ -0,0 +1,31 @@ +//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-slang -compute -output-using-type + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; +// BUF: 1.000000 +// BUF: 1.000000 + +struct TestStruct : IDifferentiable +{ + static const no_diff float foo = 1.0f; + + int x; + + void assignOut() + { + outputBuffer[0] = foo; + } +} +no_diff static const float foo = 1.0f; + +[shader("compute")] +[numthreads(1, 1, 1)] +void computeMain(uint thread_idx: SV_DispatchThreadID) +{ + if (thread_idx == 0) { + TestStruct t; + t.x = 10; + t.assignOut(); + } + outputBuffer[1] = foo; +} -- cgit v1.2.3