Repository navigation
perf(rgba4_fragment): flat preamble/body scan eliminating per-instruction vectors & 7 RB-trees, plus CPU unit test - #1976
Open
IlyassRS3 wants to merge 1 commit into
Conversation
…s, and portable CPU test
Contributor
|
Verified on Windows 11 (
AI-assisted. |
Contributor
|
Verified by OreoFR
Note: shares AI-assisted (Claude Code, Claude Opus 5.5). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.