runtime: refuse duplicate Location 1 outputs and avoid full-body RB-tree scan in dual_source_fragment #1961
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1961"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-25T16:48:39Z.
Claim:
RT-DUAL-SOURCE-FRAGMENT-PERF-AND-DUP-LOC(claim comment#7168523390on #1608).Correctness & performance fixes (
runtime/src/dual_source_fragment.h)Location 1outputs instead of silently overwritingsecond: previouslyif (loc->second == 1) second = id;silently remapped only the lastOutputvariable at Location 1 and left any earlier one at Location 1. Now a secondOutputvariable at Location 1 is refused cleanly withwordsunchanged.Locationdecorations on anOutputvariable: previouslylocation_at[id]/location_of[id]silently overwrote earlierOpDecorate %id Locationentries, leaving stale decorations behind if patched. Now duplicateLocationdecorations on anOutputare refused cleanly withwordsunchanged.OpFunction(preamble-only):OpDecorateand globalOutputOpVariabledeclarations live before the firstOpFunction(SPIR-V logical layout §2.4); skipping the function body avoids scanning tens of thousands of body words on large fragment shaders.output_pointersset and 5 red-black trees:output_pointerswas populated on everyOpTypePointerand never read. Replacing the 5std::map/std::settrees and the temporarystd::vectorinsertion buffer with 3 small flat vectors and a stackstd::array<uint32_t, 4>eliminates tree node heap allocations.Verification
CMakeLists.txtchanges).runtime/test/dual_source_fragment_test.cpp(19 checks: short header, zero-word instruction, idempotence on already-remapped module, two distinctOutputvariables at Location 1, duplicateLocationdecoration on the sameOutput, and preamble stop with verbatim function-body preservation).dual_source_fragment_testcleanly under:clang++ -std=c++20 -O1 -g -fsanitize=address,undefined -Wall -Wextra -Werrorclang++ -std=c++20 -O1 -g -fsanitize=thread -Wall -Wextra -Werrorclang++ -std=c++20 -O2 -Wall -Wextra -Werror-O2(best of 7 pre-allocated runs, Apple Silicon):python3 -I scripts/check_no_game_data.pyon both files andpython3 -I tests/test_text_write_line_endings.py: all passed.Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T16:48:46Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T12:09:18Z.
Verified on Windows 11 (
10.0.26200.9974) with MSVC19.44.35228(x64,/std:c++20 /EHsc /W4 /permissive- /utf-8 /O2) againstmaind48a957bb+0120ea194c(claim#2570#issuecomment-7238954420):runtime/src/dual_source_fragment.h,runtime/test/dual_source_fragment_test.cpp); stops the SPIR-V preamble scan at the firstOpFunction, replaces RB-tree maps/sets with sorted flat vectors, removes deadoutput_pointerstracking, and refuses modules with multipleOutputvariables atLocation 1or duplicateLocationdecorations on anOutputvariable without mutatingwords.check_no_game_data.pyclean.d48a957bb+ PR test):dual_source_fragment_test.exefails (rc=1,FAIL two Output variables at Location 1 refused unchangedandFAIL duplicate Location decoration on Output refused unchanged).d48a957bb+0120ea194cmerge): Auto-merges cleanly (rc=0), compiles with0warnings under/W4 /permissive-, and passes all 19 checks (all passed,rc=0).AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T17:56:47Z.
Red/green: On main dual_source_fragment_test fails 2 checks (two Location 1 outputs and a duplicate Location decoration are not refused), and with the PR ctest -R "^dual_source_fragment$" passes.
Independent tester (OreoFR, RTX 4070, Windows 11): PR head merged with the other PRs of its batch on main
c1ecf04ed, full ctest run (485 tests, tests that launch the game excluded): no new failure compared with main.Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T21:56:49Z.
Verified by OreoFR
c1ecf04ed+ PR head0120ea194; green run in a merge package of 16 PRs, no new ctest failure vs mainctest -R ^dual_source_fragment$AI-assisted (Claude Code, Claude Opus 5.5).