vulkan: the predicate reducer and the present composer pick memory through memory_type_order (RT-PREDICATE-COMPOSE-MEMORY-TYPES) #2548
Closed
github-bot
wants to merge 1 commit from
github-bot/gh-2548 into main
AGit
pull from: github-bot/gh-2548
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!2548
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2548"
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?
@Tyrannys on GitHub · 2026-11-28 01:46 UTC · original
Tyrannys:rt-predicate-compose-memory-types→main· +204 −19 · 5 files · 1 commits · closed without mergingClaimed in the coordination issue as: RT-PREDICATE-COMPOSE-MEMORY-TYPES (#1608)
What and why
Item 4 of @kevincommits' Finding 19 in #1608 (#1608). Thanks for the report.
PredicateReducer::batch(runtime/src/vulkan_predicate.h) andPresentComposer::ensure_target(runtime/src/vulkan_present_compose.h) each chose memory with a loop of their own. The loop took the firstDEVICE_LOCALtype the resource accepts and calledvkAllocateMemoryonce:VUID-vkAllocateMemory-pAllocateInfo-01713). On a GPU without Resizable BAR, a smallDEVICE_LOCAL | HOST_VISIBLEheap (256 MiB) often comes before the VRAM heap.memoryTypeCount, so a count aboveVK_MAX_MEMORY_TYPESmeant1u << ipast 31 and reads past the array.DEVICE_LOCALtype.Change. Both now take
memory_type_order(vulkan_memory.h), asvulkan_indirect_dispatch_count.halready does:DEVICE_LOCALtypes first, then any type the resource takes;VK_MAX_MEMORY_TYPES.A new
allocate_first_fittingthere tries them in turn. The composer also refuses a zero extent beforevkCreateImage(VUID-VkImageCreateInfo-extent-00944/00945), keeping its current target.Overlap: no open PR touches
vulkan_predicate.horvulkan_present_compose.h.Tested
Windows 11, MSVC (VS 18), RelWithDebInfo, on
main431ceba4f.predicate_memory_type, withPredicateReduceron fake device calls and a memory layout without Resizable BAR (a small BAR heap, VRAM, system memory):DEVICE_LOCALtype is followed by the next, and system memory is the last resort;memoryTypeBitstypes are asked;memoryTypeCountof 40 is read up to 32;allocate_first_fitting, including refusals.main'svulkan_predicate.h, 3 checks fail (the BAR type is asked first, and no type after a refused one); all pass with the change.vk_predicate_capture,vk_predicated_copyandvk_present_dump(3 cases, which present through the composer) pass.gta6rt_d3d12_combuilds.scripts/check_no_game_data.py: clean.Not tested: a real GPU without Resizable BAR, and a game boot.
GPUs tested: profile M: NVIDIA GeForce RTX 4070 SUPER, 12 GB, desktop, driver 621.01, Windows 11
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: no translator change)🤖 Generated with Claude Code
@zmasi on GitHub · 2026-11-28 03:18 UTC · original
#2548 | head
61822f7c5e(merged cleanly with main02f71ccfe7) |ctest --test-dir runtime/build -C RelWithDebInfo -R "^(predicate_memory_type|d3d12_predicated_copy)$" --output-on-failure(LEONIDA_VK_VALIDATION=1) | red on main:predicate_memory_type_test.cppfails to compile (C2039: missingleonida::allocate_first_fitting), and running thePredicateReducer::batch()assertions alone againstmainfails3/6checks (picks the undersized BAR heap, stops on a refusedDEVICE_LOCALtype, and never falls back to host memory) | green on PR+main:2/2CTests pass (predicate_memory_type10/10checks,d3d12_predicated_copyon RTX 3090 with0Khronos validation errors);test_ci_registration.py18/18OK,check_no_game_data.py0violations | Windows 11, RTX 3090 (610.88), Vulkan SDK 1.4.363.1 | AI-assisted: yesAlso verified the zero-extent
PresentComposer::ensure_targetguard (VUID-VkImageCreateInfo-extent-00944/00945) and allPresentComposercompose:paths on RTX 3090 underVK_LAYER_KHRONOS_validation.@lixonik on GitHub · 2026-11-28 08:51 UTC · original · approved these changes
Reviewed the diff and tested merged onto
main(493867366) with Ninja Release (MSVC).Extracting
allocate_first_fittingintovulkan_memory.hand routing bothvulkan_predicate.handvulkan_present_compose.hthrough it cleanly handles memory-type fallback without duplicating allocation loops, and the new unit test thoroughly exercises fallback selection and failure paths.Tests run
ctest --output-on-failure -R "^predicate_memory_type$": 1/1 passed (predicate_memory_type0.03 s).python -m unittest tests/test_ctest_registration.py -v: 7/7 passed (1.12 s).AI-assisted (Antigravity, Gemini).
@Maticcm on GitHub · 2026-11-28 21:35 UTC · original
Independent Windows Radeon integrated Vulkan result for exact head
61822f7c5e5e836623e63317d6cdcf758836ce3cversus parent431ceba4f4a55c69c26fcf0e36fd83e86e1b9a32. Windows 11, AMD Radeon(TM) Graphics selected explicitly, MSVC RelWithDebInfo, Khronos Vulkan validation enabled.d3d12_predicated_copyon the physical Radeon passed on both revisions. Each reported 180 exact predicated-buffer cases against Vulkan, WARP and literal-byte oracles, plus 16 query-to-copy cases and four recapture controls. Neither log reported a validation error or VUID.predicate_memory_typetest passed all 10 mock checks, including the type-count limit and the composer's allocation helper. The stock Radeon test covers predicated copies. The heap-boundary and composer results come from synthetic mocks.Focused CTest totals were parent 1/1 and head 2/2. Synthetic inputs only. AI-assisted with OpenAI Codex.
@timbot103 on GitHub · 2026-11-29 01:06 UTC · original · reviewed
Static audit of
61822f7c5against48bae6cad.runtime/src/vulkan_memory.h:68— After ordinary VRAM allocations fail, the retry can try an AMD device-coherent type that is present in the resource mask but forbidden on the logical device (VUID 02790). Filter those types unless the feature is enabled and cover that ordering in the mock.runtime/test/predicate_memory_type_test.cpp:86— The generic create and no-op stubs are called through incompatible PFN types. Please use signature-matched stubs.runtime/src/vulkan_present_compose.h:137andruntime/src/vulkan_predicate.h:68: commit output handles only on successful creation. Atruntime/src/vulkan_present.h:1180, require a successful idle wait before replacing the target.The supplied GPU results cover the normal paths. Forced allocation refusal is covered by mocks.
AI-assisted.
@lixonik on GitHub · 2026-11-29 02:50 UTC · original
I confirmed the device-coherent fallback with a signature-matched allocator mock on head
61822f7c5e5e836623e63317d6cdcf758836ce3cmerged intomainc8bf0e7b65(Windows 10, MSVC 19.29, no GPU needed).The resource mask allowed ordinary VRAM (type 0), AMD device-coherent VRAM (type 1), and host memory (type 2). After type 0 returned
VK_ERROR_OUT_OF_DEVICE_MEMORY, the PR attempted 0, 1, 2. With the unavailable coherent type filtered out, it attempted 0, 2 and still succeeded. The final successful allocation can therefore hide the invalid intermediate call in this case. The Vulkan requirement is VUID 02790.AI-assisted. Codex (GPT-6).
@KelboLive on GitHub · 2026-11-30 17:01 UTC · original
Independent check on Windows (not the author), at
61822f7c5.predicate_memory_type_testand ran it: 0 failures — 4 KiB image prefers VRAM then system memory (not the BAR),allocate_first_fittingmoves to system memory when VRAM is refused, returns none when every type is refused, and none withoutvkAllocateMemory.Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711, Vulkan SDK 1.4.363.0.
AI-assisted: yes (opencode).
@aslan2142 on GitHub · 2026-12-01 16:46 UTC · original
Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (
d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools,d3d12/, or general docs), please feel free to reopen it.Pull request closed