runtime: preserve in-flight GPU label targets when expanding a non-heap region (RT-GPU-LABEL-MEMORY-EXPAND) #1788
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1788"
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?
Imported from ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-25T12:11:27Z.
Summary
Fixes
leonida::label::Memory::track()inruntime/src/gpu_label_memory.hso growing a tracked non-heap region at the samebaseandallocation_baseupdatesRegion::endin place instead of overwritingregions_[base]and dropping in-flight GPU completion value writes.RT-GPU-LABEL-MEMORY-EXPANDRoot cause
In
Memory::track(base, bytes, allocation_base, heap):basewith the sameallocation_basealready existed and a newtrack()call covered a larger range (end > r.end), the early-return checkend <= r.endfailed and line 41 executedregions_[base] = std::make_shared<Region>(...).regions_[base]destroyed the previousRegionshared_ptr(and causedit->second != regioninpublish()), silently dropping any in-flightlabel::TargetGPU completion writes captured from[base, old_end)before the expansion.Changes
runtime/src/gpu_label_memory.h:!heapand an existing non-heap region at the samebaseandallocation_baseis expanded (base == r.begin && end > r.end), updater.end = endin place undermutex_.Regionidentity andgeneration(so stale pre-decommit targets remain rejected, live post-decommit targets survive further expansion, adjacent pages stay isolated from each other's partial decommits, and heap regions or distinctallocation_basereservations still allocate a freshRegion).runtime/test/gpu_label_memory_test.cpp&runtime/CMakeLists.txt:gpu_label_memoryCTest covering in-place expansion, post-partial-release generation retention, subrange and adjacent-page isolation, heap and new-reservation invalidation, base-0 GPU arena tracking, alignment/overflow bounds, and concurrent expand/capture/publish under TSan.Verification
gpu_label_store/xbox_gpu_labeltests rely on Windows CI).clang++ -std=c++20 -Wall -Wextra -Werror -fsanitize=address,undefined -O1 runtime/test/gpu_label_memory_test.cpp— passclang++ -std=c++20 -Wall -Wextra -Werror -fsanitize=thread -O1 runtime/test/gpu_label_memory_test.cpp— pass (zero data races)clang++ -std=c++20 -Wall -Wextra -Werror -O2 runtime/test/gpu_label_memory_test.cpp— passgpu_label_memory_test.cppagainst unpatchedmain:runtime/src/gpu_label_memory.h— fails ontest_expand_preserves_inflight_targets, confirming regression coveragepython3 -I scripts/check_no_game_data.py runtime/src/gpu_label_memory.h runtime/test/gpu_label_memory_test.cpp runtime/CMakeLists.txt— passpython3 -I tests/test_text_write_line_endings.py— 3/3 passImported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T12:11:39Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-25T16:18:37Z.
Independent verification of head
0267290f9c7ec35bece4e0b81a132f7d8310e4e6, merged onto currentmain(b0f3d3998) without conflicts.Windows 11 Pro, RTX 4070 SUPER (NVIDIA 621.01), MSVC 19.52.37029, RelWithDebInfo.
gpu_label_memory(new), plus neighboursgpu_label_storeandxbox_gpu_label_completion: 3/3 pass.main'sgpu_label_memory.h: fails atline 56: publish_ok(mem, t4, kBase + 0x10, 4, kAlloc)(the region is replaced on growth, so the in-flight target is dropped), which is the bug the PR fixes.Diff read:
Region::endis changed under the samemutex_thatcapture/publishtake, and only for the same base and allocation base, so targets keep their owner. No problem found.No game files used. AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T23:06:39Z.
Native Windows 11 + MSVC
19.44+ RTX 3090 Khronos Validation Verification (0267290f9c+origin/mainadfb3821a2)Verdict: PASS (0 blockers, 0
/W4warnings,0Vulkan validation errors on RTX 3090)Environment & Merge Check
10.0.26200), MSVC19.44.35228(x64,/W4 /permissive- /utf-8 /O2 /EHsc), NVIDIA GeForce RTX 3090, KhronosVK_LAYER_KHRONOS_validation1.4.363.1(LEONIDA_VK_VALIDATION=1,VK_VALIDATE_SYNC=1)origin/main(adfb3821a2,git merge-tree --write-treerc=0).Red -> Green & RTX 3090 GPU Results
origin/mainruntime/src/gpu_label_memory.h+ PR#1788runtime/test/gpu_label_memory_test.cpp):1atline 56: publish_ok(mem, t4, kBase + 0x10, 4, kAlloc)because replacingregions_[base]dropped in-flight targets captured prior to non-heap region growth.PR #1788 + origin/main):gpu_label_memory_test.exe: PASS (gpu_label_memory_test: ok,0.13 s,0/W4warnings).gpu_label_store_test.exe: PASS (gpu_label_store_test: ok (24 checks, 0 failures),0.41 s).xbox_gpu_label_test.exe(xbox_gpu_label_completionon NVIDIA GeForce RTX 3090 withLEONIDA_VK_VALIDATION=1+VK_VALIDATE_SYNC=1): PASS (rc=0,0VUID-errors —GPU completion values, two real timestamp samples, resubmission and stale allocation guard passed).Diff Audit Notes
r.end = endin place undermutex_only when!heap && !r.heap && r.allocation_base == allocation_base && base == r.begin && end > r.endpreserves existingshared_ptr<Region>ownership andgenerationcounters while leaving heap allocations, new reservations, and adjacent pages isolated.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T01:17:56Z.
Verified by OreoFR
48bae6cad+ PR head0267290f9(tested as a merge)ctest -R ^gpu_label_memory$(red keeps the PR's CMake registration of the new test)gpu_label_memoryfails (publish_ok(mem, t4, kBase + 0x10, 4, kAlloc), line 56)gpu_label_memorypassesgta6rt.exebuilds and links;dumpbin /dependentsshows the same DLLs as main, no network DLL)5825b02ff)AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-29T03:35:12Z.
Merging, thank you @IlyassRS3! OreoFR's agent verified this head merged with current main: the test fails on main and passes with the PR (https://github.com/ProjectLeonida/mandy/pull/1788#issuecomment-7248691304), and it still merges cleanly.
AI-assisted (Claude Code, Claude Opus 5.5), on behalf of DadaCap.