mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:15:51 +01:00
[PR #1880] xg_xs copy_elements: dispatch fixed element widths 1/2/4/8/16 to a compile-time-sized copy loop (RT-TEXEL-COPY-FIXEDWIDTH) #1893
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#1893
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/1880
Author: @thiefyzheng
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/texel-copy-fixedwidth📝 Commits (1)
7f9e656copy_elements: dispatch fixed element widths 1/2/4/8/16 to a compile-time-sized memcpy loop📊 Changes
3 files changed (+190 additions, -4 deletions)
View changed files
📝
runtime/CMakeLists.txt(+7 -0)📝
runtime/shims/xg_xs_layout.h(+26 -4)➕
runtime/test/texel_copy_test.cpp(+157 -0)📄 Description
RT-TEXEL-COPY-FIXEDWIDTH
Claimed on #1608 (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7164508666); implements the first of @cheltyi's two findings (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7164354183):
runtime/shims/xg_xs_layout.h'scopy_elementsissued a runtime-sizedmemcpyper texel/block — the pathTitleImageUpload::writeuses during runtime texture refresh. The finder's prototype (876 comparisons, ASan/UBSan clean, 4.54→0.596 ms on a synthetic 1024x1024 RGBA8 tiled texture under MinGW GCC 16.2 -O3) is the origin of this change; those numbers are the finder's, not re-measured here.What
copy_tiled_row<Into, Width>;copy_elementsdoes ONEswitch (bytes)per row: widths 1/2/4/8/16 get a compile-timeWidth, everything else takesWidth = 0— a verbatim copy of the old runtime-size loop. Address math untouched; linear textures still copy whole rows and never reach the element loop.Verification
runtime/test/texel_copy_test.cpp(ctesttexel_copy, no GPU): runscopy_elementsagainst a verbatim copy of the old loop, comparing the WHOLE destination buffer (bytes the copy must not touch are checked too). Corpus: 17 textures — R8, R16, RGBA8, RGBA16F, RGBA32F, BC1, BC3, BC5 (all five specialized widths) — tiled 4kb/64kb, linear, full mip chains with tails, arrays, 1D linear, 3D volumes; every case at 3 pointer misalignments × 3 pitch paddings; BOTH directions; and every case re-run with the width forced to 3/6/12 to prove the fallback path is unchanged./W4 /permissive-(VS 2022, winvm):texel_copy_testbuilt;ctest -R texel_copyPassed (4.57 s).xg_xs_testandd3d12_existing_heap_testwere not run (no device on this host).Attribution
AI-assisted (Claude Sonnet 5.5 worker implementation, contributor verification incl. the winvm MSVC build, orchestration).
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.