mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:30:53 +01:00
[PR #1961] runtime: refuse duplicate Location 1 outputs and avoid full-body RB-tree scan in dual_source_fragment #1967
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1967
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1961
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/rt-dual-source-fragment-perf-and-dup-loc📝 Commits (1)
0120ea1runtime: refuse duplicate Location 1 outputs and speed up dual_source_fragment preamble scan📊 Changes
2 files changed (+106 additions, -28 deletions)
View changed files
📝
runtime/src/dual_source_fragment.h(+57 -28)📝
runtime/test/dual_source_fragment_test.cpp(+49 -0)📄 Description
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.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.