mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:10:52 +01:00
[PR #1976] perf(rgba4_fragment): flat preamble/body scan eliminating per-instruction vectors & 7 RB-trees, plus CPU unit test #1983
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#1983
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/1976
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:perf/rt-rgba4-fragment-flat-scan-and-tests📝 Commits (1)
68903a6perf(rgba4_fragment): flat preamble/body scan, shared scalar constants, and portable CPU test📊 Changes
3 files changed (+450 additions, -65 deletions)
View changed files
📝
runtime/CMakeLists.txt(+3 -0)📝
runtime/src/rgba4_fragment.h(+219 -65)➕
runtime/test/rgba4_fragment_test.cpp(+228 -0)📄 Description
Claim:
RT-RGBA4-FRAGMENT-FLAT-SCAN-AND-TESTS(claim comment#7169189780on #1608).Optimizations & Fixes (
runtime/src/rgba4_fragment.h)std::vector<uint32_t>allocations and 7std::mapRB-trees:quantize()allocated a separatestd::vector<uint32_t>for every instruction in the entire fragment shader (even when no masked output existed or no store matched) and populated 7std::maptrees.OpFunctionusing compact sorted vectors, returningtruein O(preamble) with zero body scan when no masked color output exists.OpAccessChain/OpInBoundsAccessChain/OpPtrAccessChainoutput aliases, and recordsOpStorepatch offsets without copying or mutatingwordsunless at least one store is rewritten.OpStorememory operands.OpConstants across scalar and vector output types:components()emitted a fresh set of 4 scalarOpConstants (0.f, 1.f, 15.f, 1/15.f) for every distinct output type (e.g. both scalarfloatvia access chain andvec4). Now emits the 4 scalar constants once and reuses them in allOpConstantCompositedeclarations.OpMemoryModelwhenGLSL.std.450must be injected: prevents emitting a danglingimport_idif a malformed module lacksOpMemoryModel.rgba4_fragment(runtime/test/rgba4_fragment_test.cpp): previously no standalone CPU unit test coveredrgba4_fragment.h.Verification
runtime/test/rgba4_fragment_test.cppcovering zero mask, unused-location fast path,GLSL.std.450injection beforeOpMemoryModel, extraOpStoreoperand preservation, existing import reuse + shared scalar constants across scalar access-chain andvec4stores, and refusal cases (OpCopyMemory, non-float output, no matching store, bad magic, short header, truncated preamble/body, zero-word instruction, missingOpMemoryModel).rgba4_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-O2vsmain(best of 5 pre-allocated batches, Apple Silicon):python3 -I scripts/check_no_game_data.pyon all 3 changed 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.