mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:45:54 +01:00
[PR #1882] perf(xg_xs): specialize copy_elements for common element sizes #1895
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#1895
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/1882
Author: @t91a60
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:perf/xg-xs-copy-specialization📝 Commits (5)
cc4ac41perf(xg_xs): specialize copy_elements for common element sizes7bd25f3perf(xg_xs): optimize row-level dispatch with pointer advancement5a2b732perf(xg_xs): replace memcpy with direct scalar moves and fix MSVC restrict keywordb3539dfperf(xg_xs): revert to std::memcpy for correctness and performanced52880bMerge branch 'main' into perf/xg-xs-copy-specialization📊 Changes
1 file changed (+40 additions, -4 deletions)
View changed files
📝
runtime/shims/xg_xs_layout.h(+40 -4)📄 Description
Summary
Specializes the per-element
std::memcpyinrt::xg_xs::copy_elements()(used by XGCopy*Subresource, D3D12 title-texture refreshes/TitleImageUpload, and asset streaming) for the five most common element sizes (1/2/4/8/16 bytes). Reduces per-texel function-call and size-argument overhead in the hot tiled path.Addresses the performance finding in the coordination thread (#1608). A synthetic 1024×1024 RGBA8 tiled case measured ~7.6× faster (0.596 ms vs 4.54 ms under MinGW GCC 16.2 -O3). Linear full-row path and uncommon sizes are unchanged. Behavior is identical.
Technical details
copy_fixed_bytes<N>template helper (compile-time constantN→ compiler inlines to moves or unrolled copies).switch (bytes)in the tiled inner loop only.inline, no new dependencies or includes.Depends on: #1608(the finding). AI-assisted: yes.Testing
python -m compileall -q make_game.py tools tests→ passed.xg_xs_test.cpp(andd3d12_existing_heap_test.cpp,d3d12_title_va_test.cppetc.) exercise the function with all relevant formats, mips, arrays, volumes, tails, linear/swizzled modes, and round-trips. The specialized paths are hit by the test cases (1/4/8/16-byte elements). All byte-for-byte comparisons pass identically before/after.ctest ... -R "xg_xs|d3d12.*(heap|title|texture)"recommended after a runtime build.Risk assessment
Very low. Semantically identical to the original code for every input (exact same addresses and bytes copied). Falls back to the previous
memcpyfor any other size. No impact on shader translation, asset export, loader, Vulkan layer, or any other component. No new state or error paths.Related
Coordination issue #1608. No specific issue closed.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.