Vulkan: Correct page-mirror memory placement accounting #3160
Open
github-bot
wants to merge 1 commit from
github-bot/gh-3160 into main
AGit
pull from: github-bot/gh-3160
merge into: github:main
github:main
github:perf/darner-title-priority-ceiling
github:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
github:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
github:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
github:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
github:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
github:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
github:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
github:fix/runtime-test-conservative-fixtures
github:ci/shard-semantic-linux
github:docs/fg-limit-fps-switch
github:fix/runtime-test-fixture-paths
github:fix/runtime-test-fixture-readers
github:fix/read-file-hard-link
github:fix/book-slot-heap-never-read
github:fix/depth-resolve-spv-path
github:fix/indirect-unused-batched
github:gh-pr/3358/base
github:fix/xmem-refusal-diagnostics
github:gh-pr/3357/base
github:ci/shorten-ci-time
github:fix/alias-later-queued-submissions
github:claude/gallant-sagan-aamatr
github:gh-pr/3342/base
github:gh-pr/3341/base
github:d3d12/agility-sdk-621
github:gh-pr/3293/base
github:gh-pr/3319/base
github:gh-pr/3318/base
github:gh-pr/3315/base
github:gh-pr/3313/base
github:gh-pr/3314/base
github:claude/fervent-curie-m19lnr
github:gh-pr/3216/base
github:gh-pr/3272/base
github:gh-pr/3276/base
github:gh-pr/3279/base
github:gh-pr/3257/base
github:gh-pr/3258/base
github:gh-pr/3271/base
github:codex/skip-no-hit-ray-passes
github:gh-pr/3230/base
github:gh-pr/3266/base
github:gh-pr/3247/base
github:gh-pr/3246/base
github:gh-pr/3244/base
github:claude/sharp-sagan-1jqnp3
github:t3/preserve-fsr-sdk-restart-path
github:t3/propagate-host-failure-hresult
github:t3/launcher-custom-parameters
github:t3/series-x-2160-startup
github:codex/d3d12-uncapped-simulation
github:ci/less-to-run
github:perf/native-compute-shader-forms
github:claude/blissful-franklin-ukp7ag
github:codex/full-precompile-default
github:gh-pr/3166/base
github:gh-pr/3148/base
github:gh-pr/3138/base
github:gh-pr/3106/base
github:gh-pr/3057/base
github:gh-pr/2756/base
github:gh-pr/2812/base
github:gh-pr/3032/base
github:gh-pr/2992/base
github:notes/card-time-and-plant-flicker
github:gh-pr/2986/base
github:gh-pr/3000/base
github:gh-pr/2966/base
github:gh-pr/2924/base
github:gh-pr/726/base
github:gh-pr/2761/base
github:gh-pr/2663/base
github:gh-pr/2861/base
github:gh-pr/2862/base
github:gh-pr/2820/base
github:gh-pr/2811/base
github:gh-pr/2803/base
github:rt-call-trace
github:gh-pr/2802/base
github:gh-pr/2766/base
github:perf/ahead-split
github:gh-pr/2589/base
github:gh-pr/2699/base
github:gh-pr/2696/base
github:docs/readme-runtime-proposal
github:gh-pr/1346/base
github:codex/coord-claim-check-20261124-7e48
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
area: ci
.github/ workflows and settings
area: d3d12
The D3D12 runtime in d3d12/ (Rust: leonida.exe and its crates)
area: docs
Documentation
area: launcher
The launcher (launcher/)
area: runtime (legacy)
The earlier Vulkan runtime in runtime/
area: shader translator
The shader translator (leonida-shader, tools/rdna2spirv) and its tests
area: tools
tools/ and scripts/
area: viewer
The map viewer (viewer/)
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs in-game run
Changes the code a frame runs through: needs the 300 s in-game gate (docs/game_gate.md)
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
wontfix
This will not be worked on
No labels
accessibility
area: ci
area: d3d12
area: docs
area: launcher
area: runtime (legacy)
area: shader translator
area: tools
area: viewer
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs in-game run
needs rebase
needs-triage
question
ready-for-agent
submodules
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!3160
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3160"
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?
@BadgersMC on GitHub · 2026-12-02 15:15 UTC · original
BadgersMC:fix/vulkan-mirror-actual-placement-accounting→main· +55 −21 · 3 files · 1 commits · openClaimed in the coordination issue as: RT-VULKAN-MIRROR-ACTUAL-PLACEMENT-ACCOUNTING
What and why
Page-mirror accounting used the preferred placement rather than the allocation's actual memory flags, and counted allocations even when mapping subsequently failed. Record only successfully mapped units, using the selected memory type's DEVICE_LOCAL flag. Preserve memory type selection, allocation/free behavior and synchronization. The placement-transition message now distinguishes actual placement from policy preference. This is a telemetry correctness fix, not a measured RAM/VRAM reduction.
Tested
d3d12_state_map_test.cppdirectly with Vulkan headers; normal and--bounded-index-viewmodes both exited 0. Added committed helper regression tests for actual flags, successful transitions and failed maps. Scratch harness is not committed.git diff --checkandpython -I scripts/check_no_game_data.pyon all three changed paths passed.GPUs tested: RTX 3060 Ti (standalone actual Vulkan allocation/mapping; not production sparse mirror).
AI-assisted: yes ΓÇö GPT-6.2 (implementation and testing), Claude Opus 5.5 (independent read-only review).
Contributor testing requested
If available, please test NVIDIA/AMD with ReBAR on/off, especially constrained VRAM that causes host fallback. Compare mirror unit counts with actual placement transition logs and total allocated mirror units. Include GPU, driver, OS, commit, and sanitized synthetic results only. A compile/CI check of the shim would also help. Do not include game data or raw game-derived logs.
Checklist
mainat preparation (83046a713f).Additional validation (rebased head
16d3fb288)All five CI checks passed after the rebase incorporating #3162. Thank you to @merzleckeier and @fiestorra for the independent Linux and Windows checks.
Standalone synthetic Vulkan allocation probe, Windows / RTX 3060 Ti / NVIDIA 610.88 (raw driver 0x98960000), ReBAR predicate false: one 32 MiB allocation at a time, actual vkAllocateMemory and vkMapMemory, CPU page-stride write/readback. Using the committed memory_type_order and MirrorUnitAccounting helpers, three cases passed: local preference -> type 5 (flags 0x7); deliberately restricted compatible types with local preference -> host type 3 (0x6), which the old preferred-policy counter would misclassify; host preference -> type 4 (0xe). Failed-map behavior was tested synthetically, not by making an invalid Vulkan call.
Limitations: these allocations were tested with ordinary buffers (mask 0x3b), not the production mirror callback or sparse binding. The separately queried synthetic sparse buffer (32 MiB, broad-use flags) reported mask 0x2 and no host-visible coherent compatible type. No game boot, sparse bind, GPU shader execution, or memory reduction claimed. No code change since the rebase.
Remaining requests: explicit full C++ Vulkan runtime/shim build confirmation; a compatible GPU/driver with host-visible coherent sparse buffer types to validate the actual mirror path (please report buffer requirements mask, selected memory flags, successful unit counts, OS/driver, and synthetic test results). Please do not exhaust VRAM or include game data. AMD/NVIDIA with and without ReBAR are useful comparisons. AI-assisted: GPT-6.2.
Independent Windows regression verification (
16d3fb288)@fiestorra confirmed a fresh native MSVC 17.14 Ninja Release build and execution of the state-map test. The committed test passed (exit 0); a deliberate negative control ignoring map results and counting every unit as local failed at the new accounting assertion (exit 1). This verifies regression sensitivity, not a full shim build or a production Vulkan sparse mirror run. Moving to ready for review with those validation requests still open; no merge or measured memory savings claimed. AI-assisted: GPT-6.2.
@BadgersMC on GitHub · 2026-12-02 15:32 UTC · original
CI triage: the Windows check reported 1 failed file out of 660:
tests/test_xcl_compare.py, specificallyOutputEOF.test_live_title_after_eof_returns_hung_check_for_restart. The traceback is a TemporaryDirectory cleanup failure (WinError 32 followed by WinError 5), before the functional assertions, not a Vulkan assertion.Both the test (blob
37667fed) andtools/xcl_compare.py(blob2acec8f4) are byte-identical at base83046a7and headfd9e0c2. The exact base Windows CI passed this file (20 tests). Local Windows Python 3.12.10 A/B: 20/20 passed at both revisions, with five additional targeted repetitions passing on base. This suggests an intermittent Windows cleanup/handle-release issue; the specific handle owner is unconfirmed.No source or test changes were made in response. Could a maintainer rerun the failed Windows job on the same head? Linux and semantic jobs passed. Keeping this PR scoped to mirror accounting.
@merzleckeier on GitHub · 2026-12-02 15:45 UTC · original
Independent CPU-only check of
fd9e0c2againstmain3c106eb2f. The PR merges cleanly. I compiledruntime/test/d3d12_state_map_test.cppwith Clang on Linux and ran normal and--bounded-index-viewmodes on both trees. All four runs exited 0. The PR's new assertions cover actual host placement and failed maps. In the production callback, the actual allocation flags feed the accounting and a failed map still frees the allocation. This check covered the standalone C++ suite and source, with no GPU or full shim build.I confirmed the Windows
WinError 32in the fixture's directory teardown and opened #3162 separately. All 20 XCL comparison tests passed there on Linux and Windows CPython 3.12.10 under Wine. AI-assisted with OpenAI Codex.@fiestorra on GitHub · 2026-12-02 16:18 UTC · original
Built it and ran its test on this machine: the change compiles and
d3d12_state_map_testpasses.Build (the change applied on
main, MSVC,RelWithDebInfo, 4.8 minutes):Test (built from your tree):
What that establishes: the accounting change compiles against the current tree and does not disturb the state-map suite - state map, enhanced barriers, subresource decoding, layout tracking, discard ranges, block formats all ran, and the executable exits 0.
What it does not establish, and I would rather say it than let the green line stand for more:
mainalone (your branch also changes the test), so this is a green, not a red and green;AI-assisted: yes - DeepSeek v4.1 (flash).
Written with an AI assistant.
fd9e0c2205to16d3fb2885@fiestorra on GitHub · 2026-12-02 23:52 UTC · original
VERIFY-3160 — Windows nativo, C++ de verdad: build, ejecución y control
16d3fb288—runtime/src/vulkan_memory.h(+16),runtime/shims/d3d12_vulkan_device.cpp(41),runtime/test/d3d12_state_map_test.cpp(+19)Built and ran it here (fresh
Ninja/Releasebuild in a worktree at the head, MSVC Build Tools 17.14):Negative control: I made
MirrorUnitAccounting::recordignore the map result and count every unit as device-local ((void)map_result; const bool local = true;), rebuilt and re-ran:It bites on the exact line the pull request adds, and that is the point: the accounting must count what the driver actually gave (a local preference may fall back to host memory) and must not report a placement transition on a failed map.
What the change is: the mirror units are counted by actual memory placement, not by the preferred kind, and a failed
vkMapMemoryno longer counts as a transition. Both are "the counter says a mirror and the memory is somewhere else" — which is the bug this replaces.Why this one is worth the build: it is the only C++ change I have verified tonight by running the binary, and
d3d12_state_map_test.exeis host-side, so it needs no Vulkan device to pass — which is why the control works here. On a machine with no GPU driver it would still be meaningful.What I could not test
Written with an AI assistant.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.