console_heap_gpu: fix erase_overlapping overflow and keep newer slot flags on rollback (CONSOLE-HEAP-GPU-OVERFLOW-AND-ROLLBACK) #2454
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!2454
Loading…
Reference in a new issue
No description provided.
Delete branch "console-heap-gpu-overflow-and-rollback"
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 successfully merged and closed
Claimed in the coordination issue as: CONSOLE-HEAP-GPU-OVERFLOW-AND-ROLLBACK (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7216316918)
What and why
The fix is @KushGene's (commit 694ba09ff, unchanged, with them as its author). @enlight3d carried it after GitHub would not let KushGene's account open the pull request, and tested it on an RTX 3090. I'm opening it, with
upstream/mainmerged in (no conflicts).It fixes two bugs in
runtime/src/console_heap_gpu.h, which runs only withLEONIDA_CONSOLE_HEAP_GPU=1:ConsoleHeapKeys::erase_overlappingoverflow.e.to + spanwrapped pastUINT64_MAX, so an entry at the top of the address space never counted as overlapping. The check is nowe.to >= start || span > start - e.to, which cannot wrap.ConsoleHeapGpu::commit(false, 0)rollback.kZeroFirst). It now re-queues only slots that are not already queued.std::stable_sort, so the newer data is written last.runtime/test/vk_console_heap_gpu_test.cppcovers both bugs.Tested
enlight3d, on
main2859d0c9b (RTX 3090, NVIDIA 621.40, Windows 11, MSVC RelWithDebInfo):ctest -R "^(vk_console_heap_gpu|vk_command_replay|vk_predicated_copy|vk_predicate_capture|vk_queue)$"passed 5/5. The new test fails withmain's header at line 63 and passes with the fix.Here, on the merge with
main63185f4a3 (RTX 4070 SUPER, NVIDIA 621.01, Windows 11, MSVC RelWithDebInfo, Ninja):ctest -Rpasses 5/5.main'sconsole_heap_gpu.h,vk_console_heap_gpufails atline 63: keys.erase_overlapping(UINT64_MAX - 8, UINT64_MAX) == 1.main's header plus only theerase_overlappingfix, it fails atline 560: !std::memcmp(out + 8 * kSlotKeep, keep_words.data(), 32). So the rollback checks catch the second bug too.GPUs tested: NVIDIA GeForce RTX 3090, driver 621.40, Windows 11 (enlight3d); NVIDIA GeForce RTX 4070 SUPER 12 GB desktop, driver 621.01, Windows 11, profile M (ours)
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a)🤖 Generated with Claude Code
Independently checked head
c741bd6daon Windows 11 Pro 26200, MSVC 2022 (19.44.35230.0, RelWithDebInfo, Ninja), Vulkan SDK1.4.363.0, no game files.Local build & dual-GPU verification:
vk_console_heap_gpu_test(zero warnings in PR files).vk_console_heap_gpu_testwithLEONIDA_VK_VALIDATION=1:616.64): PASS (8 passes, 54004 slots, 6000 updates, 95537 misses, 1 overflows, 2 failed, 0 validation errors).25.10.30.02): PASS (8 passes, 54004 slots, 6000 updates, 95537 misses, 1 overflows, 2 failed, 0 validation errors).Static code review notes on
c741bd6da:erase_overlapping(runtime/src/console_heap_gpu.h:171-181) is sound for representable half-open queries (empty queries erase nothing, adjacent endpoints do not intersect; note callers constructings + bytesatd3d12_vulkan_device.cpp:6212-6217can still wrap before calling the helper). Slot flags are properly serialized under the shared mutex for a live heap, and the test exercises both directions ofkZeroFirst.runtime/src/console_heap_gpu.h:559-581, 748-749;vk_console_heap_gpu_test.cpp:536-564):vkCmdCopyBuffercall, which violatesVUID-vkCmdCopyBuffer-pRegions-12482(overlapping destination regions within one copy command).console_heap_gpu.h:390-415, 722-747), so a recreate reusing that index between record and rollback could enqueue old flags onto a fresh slot.AI-assisted.
#2454 | head c741bd6dab24d54e8c462554fce493a328dfce09 (merged cleanly with main adfb3821a23612263c1c5b195453ed01c4c114db — no conflicts on current
main) |ctest --test-dir runtime/build -C RelWithDebInfo -R "^(vk_console_heap_gpu|vk_command_replay|vk_predicated_copy|vk_predicate_capture|vk_queue)$" --output-on-failure(LEONIDA_VK_VALIDATION=1) | red on main: buildingvk_console_heap_gpu_testagainstmain'sruntime/src/console_heap_gpu.hfailsvk_console_heap_gpuatline 63: keys.erase_overlapping(UINT64_MAX - 8, UINT64_MAX) == 1; applying only theerase_overlappingoverflow fix onmainthen fails atline 560: !std::memcmp(out + 8 * kSlotKeep, keep_words.data(), 32)when rollback clobbers newer flags and queued copies | green on PR+main:5/5CTests (vk_console_heap_gpu—8 passes, 54004 slots, 6000 updates, 95537 misses, 1 overflows, 2 failed,vk_command_replay,vk_predicated_copy,vk_predicate_capture,vk_queue) pass in3.42 son RTX 3090 with0Khronos validation errors;check_no_game_data.py0violations | Windows 11, MSVC 19.44, RTX 3090, Vulkan SDK 1.4.363.1 | AI-assisted: yesRun of #2454 (ctest, red/green), by enlight3d. Nothing pushed.
Heads: PR
c741bd6da(merge of main 63185f4a3 into the branch), main1bc055e6c.git merge-tree --write-tree main <PR head>is clean (no conflicts).The PR changes
runtime/src/console_heap_gpu.hand adds checks toruntime/test/vk_console_heap_gpu_test.cpp. The header on main is the same as the PR's base, so the test is new and the code is changed.Machine: NVIDIA GeForce RTX 3090 24 GB, driver 621.40, Windows 11 Pro (build 10.0.26300), MSVC 19.44 (VS 2022 Build Tools), CMake + Ninja, RelWithDebInfo,
-DLEONIDA_REQUIRE_VULKAN=ON.Commands (in the vcvars64 environment, only this target built):
vk_console_heap_gpuPassed (1/1, 0.30 s).console_heap_gpu.htaken from main, test kept): Failed atline 63: keys.erase_overlapping(UINT64_MAX - 8, UINT64_MAX) == 1. This is a behavioural red: the test builds against main's header, it fails because of the overflow.erase_overlappingfix): Failed atline 560: !std::memcmp(out + 8 * kSlotKeep, keep_words.data(), 32), so the rollback checks catch the second bug too.I did not run the other four tests the PR description lists (vk_command_replay, vk_predicated_copy, vk_predicate_capture, vk_queue).
Link check: merged into main 1bc055e6c, gta6rt.exe builds and links (RelWithDebInfo, MSVC 19.44); no new imports vs main.
Merged after enlight3d (Thib)'s red/green run (RUN, RTX 3090, driver 621.40, Windows 11: green with this PR, red without it, and
gta6rt.exestill links) and a re-check here: no conflict withmain21f5baff1, same head as run,no-game-datagreen, and the only ctest failures in the Windows/macOS CI jobs are tests this diff does not touch (known onmainor Vulkan: vk_xdxr_postbuild_readback vk_bindless_dimensions d3d12_compile_pool xbox_present ).AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.