mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:00:52 +01:00
[PR #1948] runtime: stop spirv_stores scan at OpFunction and use flat sorted tables #1955
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#1955
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/1948
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:perf/rt-spirv-stores-preamble-flat📝 Commits (1)
039f893runtime: stop spirv_stores scan at OpFunction and use flat sorted tables📊 Changes
2 files changed (+157 additions, -48 deletions)
View changed files
📝
runtime/src/spirv_stores.h(+108 -48)📝
runtime/test/spirv_stores_test.cpp(+49 -0)📄 Description
Item ID:
RT-SPIRV-STORES-PREAMBLE-AND-FLAT-PERF(claimed in #1608 comment #7168043831).Summary
Optimises
leonida::spirv_declares_writable_storage()(runtime/src/spirv_stores.h) by stopping at the SPIR-V preamble boundary (OpFunction) and replacing seven per-call hash containers with compact flat vectors and early exits:OpFunction(opcode 54):OpDecorate,OpMemberDecorate,OpGroupDecorate,OpGroupMemberDecorate), types, and globalOpVariables (UniformConstant,Uniform,StorageBuffer) precede the firstOpFunction. Previously,spirv_declares_writable_storage()walked the entire function body (95–99% of every translated RDNA2 shader) and also collected localFunction-storage variables.count > words.size() - at).OpVariableand exit early before sorting:UniformConstant,Uniform, andStorageBuffervariables, and exits immediately when no storage-image / storage-buffer /BufferBlockcandidate exists (e.g., ordinary sampled-image + UBO shaders).std::unordered_*tables with flat sortedstd::vectors:OpGroupDecorate/OpGroupMemberDecorateonce before checking variables, and checks full[0, total)NonWritablemember coverage in O(1) after binary-searching the deduplicated sorted(struct_id, member)slice ((hi - lo) >= total && lo[total - 1].second == total - 1).runtime/test/spirv_stores_test.cpp:OpFunctionbodies and localFunctionOpVariables (both read-only and writable),UniformBufferBlockviaOpGroupDecorate, and duplicateOpMemberDecorateentries on member 0 not masking a writable member 1.A/B Benchmark (
-O2, 50k-word shaders with 10,000-instruction function bodies, 5,000 iters, 2 runs)main)UniformBlock)falseStorageBuffer, 4NonWritablemembers)falsetrueVerification
clang++ -std=c++20 -O1 -g -fsanitize=address,undefined -Wall -Wextra -Werror:spirv_stores_testPASSclang++ -std=c++20 -O1 -g -fsanitize=thread -Wall -Wextra -Werror:spirv_stores_testPASSclang++ -std=c++20 -O2 -Wall -Wextra -Werror:spirv_stores_test× 3 runs PASScheck_no_game_data.pyPASS,tests/test_text_write_line_endings.pyPASS (3/3)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.