mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:20:53 +01:00
[PR #2052] runtime: reuse thread-local scratch and harden port-model copy validation in xg_xs #2056
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#2056
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/2052
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:rt/xg-xs-copy-scratch-and-port-validation📝 Commits (1)
d16029druntime: reuse thread-local scratch and harden port-model copy validation in xg_xs📊 Changes
2 files changed (+59 additions, -8 deletions)
View changed files
📝
runtime/shims/xg_xs.cpp(+28 -8)📝
runtime/test/xg_xs_test.cpp(+31 -0)📄 Description
Claim ID:
RT-XG-XS-COPY-SCRATCH-AND-PORT-VALIDATIONSummary
Eliminates per-copy heap allocation on the primary
xg_xs.dllcopy path and brings the second (port) layout model's copy and offset validation into parity with the primary model (runtime/shims/xg_xs.cpp):copy_subresource:copy_elementsalready resizes and overwrites the caller-suppliedstd::vector<uint64_t>& columns, butcopy_subresourcepreviously allocated and freed a fresh vector on everyXGCopyIntoSubresource/XGCopyFromSubresourcecall. Reusingstatic thread_local std::vector<uint64_t> columnsavoids per-call heap churn (and catchesstd::bad_alloc->E_OUTOFMEMORYinstead of unwinding across__stdcall).depth_pitchand overflow inport::copy_args: Rejectrow < bytes, zero height/depth,depths > 1 && depth < one_slice(previously allowed undersized 3D depth pitch to silently read/overwrite slice 0), andp.offset + l.sizeuint64 wraparound.sampleinport::copy_into/port::copy_from/port::element_offset: Checkleonida::gfx10::tiling_detail::overlapbefore callingtile()/detile()(preventingstd::memcpyoverlap UB, matching primarycopy_subresource), and rejectsample != 0inport::copy_from(E_INVALIDARG) andport::element_offset(0).runtime/test/xg_xs_test.cppcovering round-trip copy, undersized 3D depth pitch, nonzero sample, buffer overlap, andelement_offsetsample rejection.Verification
runtime/shims/xg_xs.cpp+xg_xs_layout.h+console_texture_layout.h+gfx10_tiling.hwith minimal Win32/shim stubs; Windows MSVC CI run ofxg_xspending)clang++ -std=c++20 -O1 -g -fsanitize=address,undefined -Wall -Wextra -Werror: PASS (failures=0)clang++ -std=c++20 -O1 -g -fsanitize=thread -Wall -Wextra -Werror(4 threads x 25 alternating128x64 RGBA8/16x16 R8copy_into/copy_fromround-trips + all second-model validation checks): PASS (failures=0)-O2A/B check (200,00064x4 RGBA8 SW_4KB_Scopy_intocalls): warm105.655 ms -> 101.226 ms(cold130.911 ms -> 123.630 ms), zero per-call heap allocations, bit-exactchecksum=130620.main: failed all 5 newportvalidation assertions (main_exit=1).python3 -I scripts/check_no_game_data.pyclean;python3 -I tests/test_text_write_line_endings.py(3/3 OK).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.