d3d12_vulkan: without Resizable BAR, textures and staging buffers leave the BAR window to the arena; tile heaps prefer VRAM (RT-ALLOC-NO-REBAR-RETRIES) #1681
Open
github-bot
wants to merge 4 commits from
github-bot/gh-1681 into main
AGit
pull from: github-bot/gh-1681
merge into: github:main
github:main
github:docs/animation-merge-remnants
github:docs/story-dedup-and-cli
github:docs/restofworld-merge-remnants
github:docs/gamedata-dedup-tables
github:docs/textures-bcpack-tables-and-cli
github:docs/exe-fail-fast-shims-sync
github:fix/address-guard-wraparound-parity
github:fix/cvt-f16-denorm-and-clamp
github:docs/pso-cache-scope-note
github:docs/viewer-readme
github:docs/textures-arrays-dds-preview
github:docs/conformance-readme-status
github:fix/docs-validators-fences-urls
github:claude/loop-total
github:claude/pops-collision-seed
github:claude/dstorage-hold-page-reads
github:claude/host-image-copy-switch
github:feat/gdk-lifecycle-window-hook
github:claude/d16s8-uav-nvidia-fallback
github:feat/mfplat-offline-shim
github:claude/gameinput-slow-reader
github:fix/rt-null-barrier-clear
github:claude/depth-resolve-sample-positions
github:integration/palmetto-parity
github:claude/valu-literal-sext
github:claude/slot74-pool-handle
github:claude/rgb9e5-uint-alias-view
github:claude/fssm-root-layout-tables
github:feat/gdk-speech-display-lifecycle
github:asset-audio-skip-current
github:qemmhd/old-9940-rectangle-quad-lists
github:feat/ws2-offline-shim
github:qemmhd/rt-d16-unorm-uav
github:feat/xs-device-stops-7-9
github:qemmhd/rt-depth-same-base-shapes
github:qemmhd/rt-lazy-attachment-variant
github:feat/acphal-xma2-decoder
github:asset-audio-skip
github:codex/coord-claim-check-20261124-7e48
github:feat/xs-frame-pacing-presentx
github:feat/xs-device-vm-options
github:old-pr/9844
github:old-pr/9978
github:old-pr/9815
github:old-pr/10057
github:old-pr/9874
github:old-pr/9965
github:old-pr/9863
github:old-pr/10068
github:old-pr/10066
github:old-pr/10067
github:old-pr/10007
github:old-pr/10061
github:old-pr/10065
github:old-pr/10059
github:old-pr/10063
github:old-pr/10055
github:old-pr/10062
github:old-pr/10042
github:old-pr/10041
github:old-pr/10049
github:old-pr/10047
github:old-pr/10046
github:old-pr/10045
github:old-pr/10056
github:old-pr/10043
github:old-pr/10036
github:old-pr/10034
github:old-pr/9984
github:old-pr/10052
github:old-pr/10038
github:old-pr/10033
github:old-pr/10028
github:old-pr/10050
github:old-pr/9891
github:old-pr/9889
github:old-pr/10051
github:old-pr/10019
github:old-pr/10027
github:old-pr/10029
github:old-pr/10031
github:old-pr/10026
github:old-pr/9941
github:old-pr/10030
github:old-pr/10040
github:old-pr/9990
github:old-pr/10021
github:old-pr/9962
github:old-pr/10022
github:old-pr/10020
github:old-pr/10015
github:old-pr/10025
github:old-pr/9886
github:old-pr/10048
github:old-pr/10014
github:old-pr/10011
github:old-pr/9861
github:old-pr/10010
github:old-pr/10008
github:old-pr/9860
github:old-pr/10006
github:old-pr/9920
github:old-pr/9995
github:old-pr/10000
github:old-pr/10016
github:old-pr/10004
github:old-pr/10023
github:old-pr/9982
github:old-pr/9981
github:old-pr/9983
github:old-pr/9970
github:old-pr/9969
github:old-pr/9968
github:old-pr/9971
github:old-pr/9972
github:old-pr/9942
github:old-pr/9963
github:old-pr/9960
github:old-pr/9964
github:old-pr/9985
github:old-pr/9973
github:old-pr/9862
github:old-pr/9953
github:old-pr/10017
github:old-pr/9952
github:old-pr/9955
github:old-pr/9946
github:old-pr/9954
github:old-pr/9938
github:old-pr/9956
github:old-pr/9856
github:old-pr/9947
github:old-pr/9924
github:old-pr/9961
github:old-pr/9927
github:old-pr/9979
github:old-pr/10032
github:old-pr/9926
github:old-pr/5237
github:old-pr/9951
github:old-pr/9931
github:old-pr/9902
github:old-pr/9921
github:old-pr/9994
github:old-pr/9775
github:old-pr/9768
github:old-pr/9905
github:old-pr/9936
github:old-pr/9901
github:old-pr/9904
github:old-pr/9906
github:old-pr/9988
github:old-pr/9908
github:old-pr/9909
github:old-pr/9911
github:old-pr/9912
github:old-pr/9913
github:old-pr/9887
github:old-pr/9916
github:old-pr/9919
github:old-pr/9925
github:old-pr/9933
github:old-pr/9935
github:old-pr/9918
github:old-pr/9879
github:old-pr/9880
github:old-pr/9881
github:old-pr/9996
github:old-pr/9876
github:old-pr/9892
github:old-pr/9899
github:old-pr/9915
github:old-pr/9914
github:old-pr/9872
github:old-pr/9869
github:old-pr/9866
github:old-pr/9819
github:old-pr/10012
github:old-pr/9857
github:old-pr/9893
github:old-pr/9897
github:old-pr/9928
github:old-pr/9868
github:old-pr/9917
github:old-pr/9940
github:old-pr/9873
github:old-pr/9816
github:old-pr/10009
github:old-pr/9900
github:old-pr/9966
github:old-pr/9859
github:old-pr/9843
github:old-pr/9991
github:old-pr/10058
github:old-pr/9883
github:old-pr/9838
github:old-pr/9835
github:old-pr/9959
github:old-pr/9895
github:old-pr/9837
github:old-pr/9858
github:old-pr/9865
github:old-pr/9864
github:old-pr/9840
github:old-pr/9820
github:old-pr/4669
github:old-pr/9848
github:old-pr/9850
github:old-pr/9810
github:old-pr/9799
github:old-pr/9853
github:old-pr/9875
github:old-pr/9831
github:old-pr/9796
github:old-pr/9801
github:old-pr/9813
github:old-pr/9794
github:old-pr/7417
github:old-pr/9781
github:old-pr/9806
github:old-pr/9958
github:old-pr/9809
github:old-pr/9791
github:old-pr/9792
github:old-pr/10053
github:old-pr/9784
github:old-pr/9789
github:old-pr/9849
github:old-pr/9846
github:old-pr/9773
github:old-pr/9785
github:old-pr/9803
github:old-pr/9826
github:old-pr/9839
github:old-pr/9922
github:old-pr/9948
github:old-pr/7189
github:old-pr/9957
github:old-pr/9823
github:old-pr/9807
github:old-pr/9851
github:old-pr/9774
github:old-pr/9830
github:old-pr/9836
github:old-pr/9822
github:old-pr/9783
github:old-pr/9833
github:old-pr/9890
github:old-pr/9770
github:old-pr/9769
github:old-pr/9772
github:old-pr/9787
github:old-pr/9852
github:old-pr/9834
github:old-pr/9845
github:old-pr/9871
github:old-pr/9771
github:old-pr/9776
github:old-pr/10005
github:old-pr/9949
github:old-pr/9923
github:old-pr/9805
github:old-pr/9829
github:old-pr/9790
github:old-pr/9827
github:old-pr/9929
github:old-pr/9855
github:old-pr/9934
github:old-pr/9907
github:old-pr/9910
github:old-pr/9779
github:old-pr/9780
github:old-pr/9885
github:old-pr/9882
github:old-pr/9877
github:old-pr/9998
github:old-pr/4251
github:old-pr/9987
github:old-pr/9989
github:old-pr/9950
github:old-pr/9777
github:old-pr/10044
github:old-pr/9884
github:old-pr/2906
github:old-pr/5076
github:old-pr/9937
github:old-pr/9986
github:old-pr/3014
github:old-pr/9943
github:old-pr/9939
github:old-pr/4682
github:old-pr/4765
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
bug
Something isn't working
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 rebase
Conflicts with the base branch: rebase it on main
question
Further information is requested
wontfix
This will not be worked on
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
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!1681
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1681"
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?
@ImLele69 on GitHub · 2026-11-25 07:59 UTC · original
ImLele69:rt-alloc-no-rebar→main· +42 −6 · 3 files · 4 commits · openClaimed in the coordination issue as: RT-ALLOC-NO-REBAR-RETRIES — #1608
What and why
On a card without Resizable BAR the DEVICE_LOCAL | HOST_VISIBLE memory type sits in a heap of about 256 MiB. Two things went wrong once that window or VRAM filled up during the story load (RTX 2070 SUPER 8 GB, NVIDIA 620.70.06, Wine 11.21):
memory_type_orderput the window type second for every texture and default-heap buffer that prefers VRAM, and in index order for staging buffers. Textures used it up (nvidia-smiBAR1 at 246 of 256 MiB), and from 18,585 registered images on, every such allocation failed there before reaching system memory.Heap::tiles) required DEVICE_LOCAL, so with VRAM full the 8 MiB heaps failed for every type andtiles()returned nothing.Changes:
memory_type_order: only an allocation that asks for both DEVICE_LOCAL and HOST_VISIBLE (the arena, upload buffers with Resizable BAR) tries a BAR-window type (bar_window_type, new) in its place; the others try it last. Nothing changes with Resizable BAR, where that type is not a window.Heap::tiles: DEVICE_LOCAL preferred instead of required. The types are the sparse resource's ownmemoryTypeBits, so a system-memory type there is valid.The first version also changed
allocate's retries ofVK_ERROR_OUT_OF_HOST_MEMORY.mainhas since made those retries adaptive (they stop while they don't recover), which covers the same case without the regression kawaii-shakal pointed out for the arena, so that part and its failure counter are gone after the merge withmain0d80bc5df.Tested
d3d12_state_map_test(Linux, clang 20): new cases forbar_window_typeand the order of textures, staging buffers and the arena on the RTX 3090 layout already in the test, with and without Resizable BAR. Passes after the merge.VK_ERROR_OUT_OF_DEVICE_MEMORY, so only changes 1 and 2 above can apply there, once VRAM is full.AI-assisted: yes (Claude Code).
@whoalin1 on GitHub · 2026-11-25 08:52 UTC · original
Independent verification (native Windows; RTX 4070 SUPER + AMD Radeon gfx1036 iGPU,
LEONIDA_VK_VALIDATION=1): full RelWithDebInfo build 572/572 OK; CPU memory-path tests pass incl. newbar_window_type/ordering cases. GPU ctest memory subset: NVIDIA 15/15 PASS; AMD 11 pass + 4 fail (d3d12_title_va,d3d12_geometry_views,d3d12_title_index_window,d3d12_title_vertex_window) — identical failures reproduced on an origin/main baseline build (iGPUmaxPushConstantsSize=128 < 144, UBO fallback not built — documented pre-existing limit), not a regression. Code review clean: attempts=1 for BAR-window/2s-exhausted types, retry success never poisons a type, othermemory_type_ordercallers unaffected. Retail/Wine no-ReBAR claims unverifiable without game files; mechanism matches. AI-assisted verification.@kawaii-shakal on GitHub · 2026-11-25 09:45 UTC · original · reviewed
Review (read-only, not run). Moving the BAR-window type to the end for allocations that don't ask for host access, and the tile heaps' "prefer, don't require", both look right, and the order tests are clear. One possible regression:
The arena gets one try in the BAR window instead of six.
attemptsis 1 for anybar_window_typetype, including for an allocation that wants bothDEVICE_LOCALandHOST_VISIBLE, the arena among them. The six retries existed because the NVIDIA driver also returns a spuriousVK_ERROR_OUT_OF_HOST_MEMORYthat succeeds on retry (your description keeps retries for that case elsewhere). On a no-ReBAR card the arena is the one allocation that should land in the window. A single spurious answer would now send it to system memory for the whole run, silently, apart from the placement log. Suggest keeping the retries whenwants_window, or for the first allocation in that type, and limiting the single try to allocations that only reached the window as a fallback.Minor: the
failurescounter's first message prints at 32 (failed > 16and a power of two). If 16 was meant, use>=.AI-assisted review (Claude Code, Claude Opus 5.5).
@adrianmjim on GitHub · 2026-11-25 11:24 UTC · original
Tested
1940c2ac4applied ontomain42537e7b6on a discrete AMD GPU without Resizable BAR: Radeon RX 7900 XT (20 GB), AMD driver 32.0.32029.2010 (26.11.2), Windows 11 build 26300, VS 2022 RelWithDebInfo. The memory layout is heap 0 VRAM, heap 1 system memory, and heap 2 a 256 MiBDEVICE_LOCAL | HOST_VISIBLEwindow. No game files.This PR alone: no behaviour change on this card, and no regression.
d3d12_state_map,indirect_dispatch_count_alloc,image_memory,arena_size,d3d12_vulkan_device,d3d12_texture_memory,d3d12_buffer_tiles,d3d12_texture_tiles,d3d12_sparse_queue_family*,d3d12_placed_heap_lifetime,d3d12_heap_properties,d3d12_existing_heap,d3d12_title_va,d3d12_geometry_views,d3d12_title_*_window,xbox_geometry_upload_batch,d3d12_indirect_rt_upload_sysmem) give the same results asmain. 17 pass, andd3d12_texture_tiles(#964) andd3d12_geometry_viewsfail on both.ctest -j 6: 3 failures out of 402 (13 skipped for missing data or features), the same three asmain:d3d12_texture_tiles,d3d12_clearandd3d12_geometry_views.LEONIDA_GEOMETRY_MB=16,d3d12_title_va_testlogs exactly the same allocation failures asmain: threevkAllocateMemory failed (-2) ... memory type 2 (flags 0x7, heap 2 of 256 MiB)lines, and nosucceeded on retry.That fits the code:
VK_ERROR_OUT_OF_DEVICE_MEMORY(-2) when the window is full, so the retry and "exhausted" logic, which acts on -1, never runs here.HOST_VISIBLEand prefersDEVICE_LOCAL, so it still takes the BAR type first. At 256 MiB it fills this 256 MiB window exactly.So the retry part of change 2 looks NVIDIA-specific (its failure counter does count AMD's -2 answers, see below), and changes 1 and 3 only matter once VRAM is full.
With #1678 on top (geometry views fall back to system memory when the window is full):
d3d12_geometry_viewspasses, with 64/64 for the table V#, the CBV and the root view. There are no validation messages underLEONIDA_VK_VALIDATION=1, and the fallback is logged once. The wholectestgives 400 of 402, with onlyd3d12_texture_tilesandd3d12_clearleft. The two changes compose without conflicts.One thing to watch once both are in: each new geometry-view block first tries the full window once (-2) and then goes to system memory. That is 1 to 4
vkAllocateMemory failedlines in this test. Your new "has failed N times" line counts every failedvkAllocateMemoryinallocateand first prints at the 32nd failure (then 64, 128, ...). With #1678 each view block adds one failure that is recovered at once. So a run with 32 or more view blocks, or fewer blocks plus other failures, will print it even though every allocation ended up succeeding.@ImLele69 on GitHub · 2026-11-25 11:59 UTC · original
Thanks @kawaii-shakal, @adrianmjim and @whoalin1. Merged
main0d80bc5df(the branch was conflicting).mainnow makes theOUT_OF_HOST_MEMORYretries adaptive, which covers what my retry change was for, and keeps the arena's retries at boot, so I dropped that change and the failure counter instead of patching them: the arena regression and the counter's 16/32 and "recovered failures" points no longer apply. What's left is the window ordering and the tile heaps' "prefer, don't require". Description updated;d3d12_state_map_testpasses and the runtime cross-builds after the merge.@Timon360SB on GitHub · 2026-11-25 14:30 UTC · original
Independent verification — Turing and Blackwell
0d80bc5df7c873f40965f34f185cb9691378676586eb22f7e84ed057adb9dc259c53394f05f2c706Environment
NVIDIA 621.14, Vulkan SDK 1.4.363.0, MSVC 19.44, Ninja RelWithDebInfo.
Three initial repetitions per configuration, followed by two additional sets of validated runs. Duplicate checkpoint results were excluded.
Results
d3d12_state_mapd3d12_texture_tilesd3d12_existing_heapd3d12_geometry_viewsd3d12_title_vad3d12_indirect_rt_upload_sysmemd3d12_buffer_tilesd3d12_texture_memoryd3d12_heap_properties432 unique test executions: 396 passed, 36 failed, 0 skipped.
Findings
vkAllocateMemory failedmessages in the captured logs.The only failing test is
d3d12_indirect_rt_upload_sysmemunder validation, reproduced on both revisions and GPUs:VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-12281FAIL: RayQueryKHR ARRAY expected hit=1 miss=0, got hit=0 miss=0Conclusion
No regressions observed in the nine selected CTest scenarios, including the no-ReBAR Turing configuration.
BAR-window exhaustion and VRAM-pressure fallback were not explicitly forced, so these results establish regression coverage rather than direct verification of allocation behavior under memory exhaustion.
Synthetic tests only. No game files used.
AI-assisted: yes.
@qhukz13 on GitHub · 2026-11-25 22:25 UTC · original
A Pascal data point, since the reports above are Turing, Blackwell and RDNA3. GeForce GTX 1050 Ti 4 GB without Resizable BAR, NVIDIA 582.66, Windows 10 Pro 19045, MSVC RelWithDebInfo, base
0d80bc5dfvs head86eb22f7e.Memory layout (vulkaninfo): heap 0 VRAM 3.91 GiB, heap 1 system memory 15.96 GiB, heap 2
DEVICE_LOCAL214 MiB. Types: 0-6 heap 1 with no flags, 7 heap 0DEVICE_LOCAL, 8 heap 1HOST_VISIBLE|HOST_COHERENT, 9 the same plusHOST_CACHED, 10 heap 2DEVICE_LOCAL|HOST_VISIBLE|HOST_COHERENT. Sobar_window_typetakes type 10 (214 MiB <=kBarWindowBytes), and the PR changes the order here as intended:DEVICE_LOCAL)HOST_VISIBLE+DEVICE_LOCAL)HOST_VISIBLEonly)Staging buffers do not change on this card because the window type already has the highest index; the texture order is where the window was being used up.
Tests, 21 memory tests (
d3d12_state_map,indirect_dispatch_count_alloc,image_memory,arena_size,d3d12_vulkan_device,d3d12_texture_memory,d3d12_buffer_tiles,d3d12_texture_tiles,d3d12_sparse_queue_family*,d3d12_placed_heap_lifetime,d3d12_heap_properties,d3d12_existing_heap*,d3d12_title_va,d3d12_geometry_views,d3d12_title_index_window,d3d12_title_vertex_window,xbox_geometry_upload_batch,d3d12_indirect_rt_upload_sysmem), 3 runs plain and 1 withLEONIDA_VK_VALIDATION=1on each side: identical on base and head, 15 pass and the same 6 fail, no validation messages. The 6 have known causes on this host unrelated to this PR:d3d12_existing_heap*(3, title images whose HOST_TRANSFER image gets no memory type, #1894),d3d12_heap_propertiesandd3d12_vulkan_device(resource heap tier 1 comparisons, #1389),d3d12_geometry_views(Windows 10 root signature serialization, #2059). So no regression here; the window filling up during a story load is not something these tests reach.If useful, this layout could go into
d3d12_state_map_testnext to the RTX 3090 one; it is the case where staging and textures differ.AI-assisted (Claude Code).
@GrahamboJangles on GitHub · 2026-11-26 08:19 UTC · original
Read-through review — head
86eb22f7e(merged withmain0d80bc5df)Read-through on this CPU-only host (no cmake/clang-cl here — not built; the runtime side is backed by whoalin1's 572/572 native build and the adrianmjim, Timon360SB and qhukz13 hardware reports at this head).
Coordination: claimed on #1608 (
RT-ALLOC-NO-REBAR-RETRIES), rosterdone: ... -> #1681; no open PR definesmemory_type_order/bar_window_type(runtime/src/vulkan_memory.h) is touched elsewhere, and no open PR touches thetiles()allocate site — #1678 and #443 change other paths.Rebase clean:
0d80bc5df..main(a73a57e13) is a zero-byte diff forruntime/src/vulkan_memory.handruntime/test/d3d12_state_map_test.cpp, andmainhas not touched thetiles()allocation ind3d12_vulkan_device.cpp(still the old require-DEVICE_LOCAL form). Merges without conflicts.Order logic (static check, sound):
bar_window_typeandresizable_barare exact complements atkBarWindowBytes(device-local heap ≤ 256 MiB vs >): no gap, no overlap, so with Resizable BAR every call is byte-identical tomain.wants_windowis constant per call, so a type cannot land in bothorderandwindow; per-list dedupe is therefore consistent, andwindowtypes are appended after both passes — last, after system memory, as the comment claims.window.required=0, preferred=DEVICE_LOCAL) matches the window type in the first (required | preferred) pass — the type has DEVICE_LOCAL — and is diverted towindow, so it stays a fallback, just last, after system memory.order{1,2,3}), and the 24 GiB heap case with!bar_window_typeand the pre-change order restored.allocate(requirements, 0, DEVICE_LOCAL, ...)cannot yield an invalid type —requirements.memoryTypeBitsis the sparse resource's own bits. The recordedmemory_typeflows intoTileHeapAllocation; nothing in the diff or at the call sites assumes the tile backing is DEVICE_LOCAL (the arena's ownmemory_typeattiles_share_arenais a separate allocation).required=HOST_VISIBLE|HOST_COHERENT, preferred=DEVICE_LOCAL, sowants_windowis true and it retries per main's adaptive rule, as before. kawaii-shakal's pre-merge arena-retry concern no longer applies at this head, as the author's 11:59Z reply says.Verdict: no blocking issues — the merged version is strictly narrower than the pre-merge one (retry/counter part dropped, covered by main's adaptive retries). Nothing to request; the four independent hardware reports (Turing, Blackwell, RDNA3, Pascal, no- and with-ReBAR) all land on this head with no regression.
Reviewed by Hermes Agent (read-through, not run).
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.