d3d12/xs: guard 48-bit host-import VAs and sync title-written descriptor heaps (D3D-RTX5070-HOST-HEAP-SYNC) #644
Closed
leonida/mandy
TanmaySatyam wants to merge 0 commits from
feature/rtx5070-fixes into main
pull from: feature/rtx5070-fixes
merge into: leonida:main
leonida:main
leonida:github-pr/3295
leonida:beta
leonida:docs/changelog-3483-3500
leonida:github-pr/3294
leonida:github-pr/2975
leonida:github-pr/2815
leonida:feat/gate-driver-start
leonida:feat/skip-pipelines-release
leonida:perf/lazy-compare
leonida:perf/mwaitx-wait
leonida:test/prio-ceiling-main
leonida:fix/ab-cpu-stdout
leonida:fix/gate-old-crashes
leonida:diag/ab-cpu
leonida:test/main-0312
leonida:github-pr/3291
leonida:diag/indirect-clamp-census
leonida:feat/barrier-enhanced
leonida:perf/texture-frame-ceiling
leonida:perf/dstorage-threads
leonida:fix/console-queue-dma-tables
leonida:fix/port-descriptors-record-parts
leonida:fix/frame-waits-fence
leonida:fix/console-sampler-words
leonida:fix/graphics-userdata-spill
leonida:fix/xg-reserved-layout-rotation
leonida:fix/barrier-console-flags
leonida:fix/switches-wait-test-child
leonida:test/list-value-waits
leonida:test/lot-gxdk-0412
leonida:fix/bvh-compacted-size
leonida:docs/i18n-quickstarts
leonida:feat/native-pipeline-slots
leonida:fix/clippy-leonida-gpu
leonida:fix/list-value-producers
leonida:fix/descriptor-page-straddle
leonida:fix/xmem-low-window
leonida:fix/ffx-jitter-never-zero
leonida:fix/run-stdout-closed
leonida:github-pr/2892
leonida:github-pr/2896
leonida:feat/warm-save-every
leonida:github-pr/2980
leonida:github-pr/2994
leonida:github-pr/3005
leonida:github-pr/3010
leonida:github-pr/3136
leonida:github-pr/3303
leonida:github-pr/3220
leonida:github-pr/3143
leonida:github-pr/3330
leonida:github-pr/3226
leonida:github-pr/3187
leonida:carry/3395
leonida:github-pr/2946
leonida:github-pr/2947
leonida:github-pr/2945
leonida:github-pr/2983
leonida:github-pr/3001
leonida:github-pr/3372
leonida:github-pr/3128
leonida:github-pr/3296
leonida:github-pr/2588
leonida:github-pr/3119
leonida:github-pr/3378
leonida:fix/crash-diagnostics
leonida:feat/dlss-mip-bias
leonida:fix/retired-out-of-order
leonida:fix/dxr-postbuild-barrier
leonida:fix/amd-relay-default
leonida:fix/removed-report-wait
leonida:feat/heap-twin
leonida:feat/vram-margin
leonida:github-pr/2472
leonida:github-pr/3123
leonida:github-pr/3088
leonida:assets/annonce-v1
leonida:github-pr/2794
leonida:github-pr/3300
leonida:github-pr/3304
leonida:github-pr/3308
leonida:github-pr/3367
leonida:github-pr/3369
leonida:fix/launcher-dlss-diagnostics
leonida:github-pr/3269
leonida:github-pr/2957
leonida:github-pr/3205
leonida:fix/crash-zero-guard
leonida:github-pr/3185
leonida:github-pr/3099
leonida:github-pr/3104
leonida:github-pr/3348
leonida:github-pr/3379
leonida:github-pr/3377
leonida:perf/darner-title-priority-ceiling
leonida:github-pr/3376
leonida:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
leonida:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
leonida:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
leonida:github-pr/3373
leonida:github-pr/3368
leonida:github-pr/3198
leonida:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
leonida:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
leonida:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
leonida:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
leonida:github-pr/3346
leonida:github-pr/3375
leonida:github-pr/2958
leonida:github-pr/3151
leonida:github-pr/3307
leonida:github-pr/3278
leonida:github-pr/3374
leonida:fix/runtime-test-conservative-fixtures
leonida:github-pr/3366
leonida:ci/shard-semantic-linux
leonida:github-pr/3354
leonida:docs/fg-limit-fps-switch
leonida:github-pr/3365
leonida:fix/read-file-hard-link
leonida:github-pr/3364
leonida:fix/book-slot-heap-never-read
leonida:github-pr/3361
leonida:github-pr/3263
leonida:github-pr/3360
leonida:github-pr/3353
leonida:github-pr/3331
leonida:fix/alias-later-queued-submissions
leonida:github-pr/3352
leonida:github-pr/3228
leonida:github-pr/3349
leonida:claude/gallant-sagan-aamatr
leonida:github-pr/3200
leonida:github-pr/3132
leonida:github-pr/3323
leonida:github-pr/3332
leonida:github-pr/3340
leonida:github-pr/3311
leonida:github-pr/3334
leonida:github-pr/3297
leonida:github-pr/3256
leonida:github-pr/2567
leonida:github-pr/2851
leonida:d3d12/agility-sdk-621
leonida:github-pr/3164
leonida:github-pr/3114
leonida:github-pr/3050
leonida:github-pr/3113
leonida:github-pr/3326
leonida:github-pr/3144
leonida:github-pr/2642
leonida:github-pr/3072
leonida:github-pr/2789
leonida:github-pr/2643
leonida:github-pr/3009
leonida:github-pr/3035
leonida:github-pr/3031
leonida:github-pr/2686
leonida:github-pr/2834
leonida:github-pr/3321
leonida:github-pr/3325
leonida:github-pr/3290
leonida:github-pr/3324
leonida:github-pr/3130
leonida:claude/fervent-curie-m19lnr
leonida:github-pr/3309
leonida:github-pr/3305
leonida:github-pr/3306
leonida:github-pr/3302
leonida:github-pr/3301
leonida:github-pr/3345
leonida:github-pr/3211
leonida:github-pr/3027
leonida:github-pr/3286
leonida:github-pr/3235
leonida:github-pr/3265
leonida:github-pr/3275
leonida:codex/skip-no-hit-ray-passes
leonida:github-pr/2823
leonida:github-pr/2911
leonida:github-pr/3262
leonida:github-pr/3125
leonida:github-pr/3206
leonida:github-pr/3250
leonida:github-pr/3238
leonida:github-pr/3188
leonida:github-pr/2952
leonida:github-pr/3217
leonida:github-pr/3168
leonida:t3/preserve-fsr-sdk-restart-path
leonida:t3/propagate-host-failure-hresult
leonida:github-pr/3209
leonida:t3/launcher-custom-parameters
leonida:github-pr/3207
leonida:github-pr/3183
leonida:github-pr/3160
leonida:github-pr/3201
leonida:ci/less-to-run
leonida:github-pr/2930
leonida:github-pr/2797
leonida:github-pr/2999
leonida:perf/native-compute-shader-forms
leonida:github-pr/3191
leonida:github-pr/3011
leonida:github-pr/3019
leonida:github-pr/2996
leonida:gh-readonly-queue/main/pr-2789-45dc41f95c1cd0dcc29c2c50582e0e9af8a77259
leonida:claude/blissful-franklin-ukp7ag
leonida:github-pr/3141
leonida:github-pr/3156
leonida:github-pr/3150
leonida:github-pr/3153
leonida:github-pr/3163
leonida:github-pr/3142
leonida:github-pr/3139
leonida:github-pr/2841
leonida:github-pr/3069
leonida:github-pr/3098
leonida:github-pr/3107
leonida:github-pr/3071
leonida:github-pr/2774
leonida:github-pr/2889
leonida:github-pr/3075
leonida:github-pr/2661
leonida:github-pr/3064
leonida:github-pr/3054
leonida:github-pr/3049
leonida:github-pr/2855
leonida:github-pr/2943
leonida:github-pr/3016
leonida:github-pr/2887
leonida:github-pr/3006
leonida:github-pr/3003
leonida:github-pr/2993
leonida:notes/card-time-and-plant-flicker
leonida:github-pr/2989
leonida:feat/vulkan-rs
leonida:github-pr/2985
leonida:github-pr/2951
leonida:github-pr/2982
leonida:github-pr/752
leonida:github-pr/792
leonida:github-pr/2877
leonida:github-pr/2654
leonida:github-pr/2893
leonida:github-pr/2948
leonida:github-pr/2944
leonida:github-pr/2919
leonida:github-pr/2915
leonida:archive/ci/less-to-run/20261202T1121Z
leonida:github-pr/2800
leonida:github-pr/2822
leonida:github-pr/2833
leonida:github-pr/2840
leonida:github-pr/2831
leonida:github-pr/2832
leonida:github-pr/2801
leonida:github-pr/2890
leonida:github-pr/2891
leonida:github-pr/2664
leonida:github-pr/2807
leonida:rt-call-trace
leonida:github-pr/2755
leonida:perf/ahead-split
leonida:github-pr/2587
leonida:github-pr/2698
leonida:github-pr/2609
leonida:github-pr/3219
leonida:docs/readme-runtime-proposal
leonida:github-pr/2017
leonida:github-pr/1741
leonida:github-pr/1667
leonida:codex/coord-claim-check-20261124-7e48
No reviewers
Assignees
Clear assignees
No assignees
Labels
Clear labels
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
enhancement
New feature or request
missing claim
Needs a claim in #14
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
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
Projects
Clear projects
No items
No project
Milestone
Clear milestone
No items
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
leonida/mandy!644
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/rtx5070-fixes"
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 closed
This pull request cannot be reopened because the branch was deleted.
Claimed in the coordination issue as: D3D-RTX5070-HOST-HEAP-SYNC
AI-assisted.
Summary
runtime/shims/d3d12_vulkan_device.cpp)VK_EXT_external_memory_hostplaces a title-backed host import belowheap_base,address - heap_basewraps in 64-bit unsigned arithmetic (bits 48..63 = 0xFFFF), corrupting 48-bit V# buffer descriptors.va >= (1ull << 48)after subtractingheap_baseand falls back to the existing in-arena shadow buffer path cleanly.runtime/shims/d3d12_xs_device.cpp)ExecuteCommandLists/ExecuteCommandListsX.Testing & Verification
main@21625bca8)d3d12_existing_heap,d3d12_descriptor, andd3d12_console_descriptor_heapCTests underLEONIDA_VK_VALIDATION=1andVK_VALIDATION_VALIDATE_SYNC=1(3/3 passed, 0 validation errors).python -I scripts/check_no_game_data.py runtime/shims/d3d12_vulkan_device.cpp runtime/shims/d3d12_xs_device.cppexited 0.Independent Windows review of exact head
23872ccon RTX 5070 Ti (610.74), MSVC 19.44 Release, and Khronos Vulkan validation 1.4.369. The stock existing-heap, descriptor, console-heap, xmem-placement and compute tests pass (5/5), with zero validation errors.A test-only extension uses real, writable CPU storage behind the console heap descriptor and obtains two distinct, valid CBVs from the layer. The ordinary heap copy control passes. The device-write mirror and a direct CPU write made after creation both reach the new shader-visible backing at submission. Two other paths differ, in three runs with validation active and zero validation errors:
register_descriptor_rangeinitializeslast_syncedfrom the supplied CPU range without initializing the real backing, so the first diff treats those existing bytes as already copied.CopyDescriptorsSimplenorCopyDescriptorscopies the new descriptor to an ordinary destination. Recreating those same source CBVs via the proxy API makes both copies pass. The proxy translates the source handle to the real backing, which has not received the CPU-side write. These copy calls run immediately on the CPU timeline, as documented in Copying Descriptors.All inputs were synthetic. AI-assisted.
Follow-up hardware Vulkan smoke test on Windows using the CI runtime artifact for this PR at
23872cc. I ran the test executables in an AppContainer without network capabilities. With the packaged synthetic shader fixtures in place,d3d12_descriptor_testandd3d12_console_descriptor_heap_testboth exited 0.d3d12_existing_heap_testterminated with0xC0000008in that restricted environment. I do not have a matching main artifact to compare, so that outcome is inconclusive. The console-heap smoke test exercises the fixed-address fixture and does not verify the new mapped-heap branch. The 48-bit guard observation in the earlier review still needs a focused case.AI-assisted. Synthetic inputs only. Vulkan validation layers were not enabled.
Update: the matching base artifact at
21625bcais available now. With the same AppContainer setup and packaged synthetic fixtures, both descriptor tests also exit 0 on the base, andd3d12_existing_heap_testterminates with the identical0xC0000008. All three outcomes match between base and PR in this harness. This comparison does not establish the cause of the existing-heap failure.Independent regression verification — Turing and Blackwell
Baseline:
21625bca8c675c62f9dbffc318ce6a59d57faf31
PR head:
23872cc5495d914d044ebc7ad8ef9422b3e5c357
Environment
LEONIDA_VK_VALIDATION=1 and
VK_VALIDATION_VALIDATE_SYNC=1 were set.
GPU-assisted validation was also enabled.
Results
Three repetitions per revision on each GPU.
36/36 test executions passed.
No skipped tests or reported Vulkan validation errors.
Additional observations
cases matched both native hardware D3D12 and WARP.
fallback checks passed on both revisions.
18, 19, 21, 22, 23 and 24 now execute
the CPU-handle translation handlers.
Scope and limitations
No regressions were observed in the selected tests.
BASE already passes all selected cases, so these
results do not independently reproduce or prove
the fix for the original 48-bit VA underflow.
The console heap test logs indicate a heap not
backed by title memory. Full title-written
descriptor synchronization is therefore not
established by these results.
Synchronization validation was requested, but
the dedicated positive-control test was not run.
Synthetic fixtures only. No game files used.
AI-assisted test automation and result analysis.
Thanks @sodove, @lixonik, and @Timon360SB for the thorough reviews and hardware checks! Rebased onto \main\ (\d0da7dade) and pushed a follow-up commit addressing every review finding:
egister_descriptor_range\ now seeds \last_synced\ from
eal_start\ instead of \custom_start, so valid descriptors already sitting in title memory before \CreateDescriptorHeap\ are detected as dirty and synced on the very first \ExecuteCommandLists.
t::d3d12::host_import_va_in_vsharp_range(arena_address, buffer_va)\ in
untime/shims/d3d12_com.h\ and added deterministic boundary checks in \d3d12_existing_heap_test\ (zero guards, \rena - 1, low VA \
Thanks for adding the deterministic boundary cases and the live BDA fixture. One static follow-up on
2c136008: incheck_title_placed_with_bda,VirtualFree(pages, ...)runs before the localRef<ID3D12Resource> bufferdestructor releases the resource. On a successful direct import, the Vulkan memory object can still refer to those pages. The spec requires the host range to remain valid for the lifetime of the imported memory object.Could the buffer be scoped so it is destroyed before
VirtualFree, as in the existing placed-buffer checks? Fixture · Vulkan host-pointer lifetimeAI-assisted static follow-up. No GPU run on this head yet.
Good catch @lixonik — scoped \Ref buffer\ inside a block before \VirtualFree(pages, 0, MEM_RELEASE)\ in \check_title_placed_with_bda\ so any imported host-memory object is always released before the host pages are freed. Re-verified \d3d12_existing_heap_test\ on RTX 5070 (Driver 591.74, Windows 11, \LEONIDA_VK_VALIDATION=1, \VK_VALIDATION_VALIDATE_SYNC=1): PASS with 0 validation errors.
Tested c4b11a8c32 applied on
main6293c1c4f, on Intel Iris Xe (Raptor Lake-P, 8086:a7a0), Intel 32.0.101.7092, Windows 11 24H2 (26100.6584): this pull request's own cases pass;d3d12_existing_heapas a whole is red on this GPU before and after, for a reason that is already onmain.ctest -R "^(d3d12_existing_heap|d3d12_descriptor|d3d12_console_descriptor_heap)$", layer on the Iris Xe (the NVIDIA driver was kept out of the process withVK_LOADER_DRIVERS_SELECT):main6293c1c4fd3d12_descriptord3d12_console_descriptor_heapd3d12_existing_heapThe new cases in
d3d12_existing_heaprun here and pass:The guard is what answers in the BDA fixture on this driver: the layer logs
title-placed host import lies outside V# 48-bit range above heap_base; using arena shadow instead; bits 48-63: 65535. So on this Intel driver a host import does land belowheap_base, the case the guard is for.What keeps the test red is not from this pull request. In the existing
check_title_placedcases (no BDA arena) the import succeeds and the copy out of the buffer is then refused, three times, identically with and without the change:That is the finding in https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7142086637. It passed on the RTX 4060 Laptop GPU of the same machine earlier today on
main.Not run: the layer on the NVIDIA GPU (its driver was being updated during this run). Built with MSVC 19.50 + Ninja, RelWithDebInfo; the change applies cleanly on current
main.AI-assisted: this run was made with a coding agent.
Independent test of head
c4b11a8c3on Windows 11 / RTX 4070 SUPER (NVIDIA 621.24, VS 2022, Ninja, RelWithDebInfo), merged alone onto main 66d4f5aa3:LEONIDA_VK_VALIDATION=1(0 VUIDs).I'm leaving the merge decision to the owner rather than merging it myself, because it changes runtime behaviour beyond a fix. Some notes for whoever decides:
readable_rangecheck. A writable check, or catching the write fault, would be safer.AI-assisted (Claude Code, Claude Opus 5.5).
A data point from another project for whoever decides on this. fxceless/victory-fork (a VIctory fork that renders gameplay on an RTX 4070) just landed the same idea in its commit a26859f, "The first room renders right": descriptor records the title copies into its heap as bytes are mirrored before each submission, with a per-slot fingerprint so only changed records are copied. They count about 40,000 records a frame in the first gameplay room, and that change is what made the room render correctly there. That supports #644's direction (title-written descriptors synced per ExecuteCommandLists). It also suggests the per-submit cost note from my earlier test can be addressed with a per-slot fingerprint or dirty tracking rather than a full memcmp.
AI-assisted (Claude Code, Claude Opus 5.5).
Update for when you rebase: this head (c4b11a8c3, based on d0da7dade) no longer merges onto current main. A test merge onto c7e82e26e conflicts in
d3d12_vulkan_device.cpp,d3d12_xs_device.cppand both test files. Also, main now has an overlapping mechanism from #939:LEONIDA_DESC_MIRROR(on by default) stores descriptor writes to a title-backed heap at the title's address as well, and list slots 35/36 pull the title's descriptors into the bound table. It would help reviewers if the rebased PR says what it adds on top of that, e.g. picking up records the title byte-copies itself, which is the case the VIctory fork commit I mentioned covers.AI-assisted (Claude Code, Claude Opus 5.5).
Rebased cleanly onto
main(3f81d46ac) on top of #939 (LEONIDA_DESC_MIRROR) and the below-arena host-import guard, addressing @sodove's findings and @QemmHD's review notes:What this adds on top of current
main:d3d12_com.h,d3d12_vulkan_device.cpp,d3d12_existing_heap_test.cpp): Main now catchesbuffer_va < arena.address(unlessLEONIDA_IMPORT_BELOW_ARENA=1), but not positive offsets>= 2^48aboveheap_base.rt::d3d12::host_import_va_in_vsharp_range()guards both bounds while preservingLEONIDA_IMPORT_BELOW_ARENA=1for below-arena imports, with deterministic boundary and BDA-arena tests.CopyDescriptors/CopyDescriptorsSimplesource sync (d3d12_xs_device.cpplocal_sync_source): Main'sLEONIDA_DESC_MIRRORmirrors writes out to the title's backing (local_write_through) and pulls 64-slot tables on list slots 35/36, but does not pull direct CPU writes from a custom-backed source heap beforeCopyDescriptors*reads the real heap (addressing @sodove's finding #2).ExecuteCommandLists(local_sync_shader_visible_heaps): Layered directly ontoDescriptorRange,local_desc_mirror()(LEONIDA_DESC_MIRROR=0disables it too), andlocal_accessible()(writable/readable checks, addressing @QemmHD's note #4). Uses 8-byte per-slot fingerprints (4x smaller than a full 32-byte shadow copy, skipping unchanged/empty slots on submit, addressing @QemmHD's note #3), initialized to 0 so pre-filled slots sync on the first submit (@sodove's finding #1), and picks up title-byte-copied descriptors across the whole shader-visible custom heap rather than only 64-slot root-table binds.Verified locally (Windows 11, NVIDIA GeForce RTX 5070, MSVC RelWithDebInfo,
LEONIDA_VK_VALIDATION=1, 0 VUIDs):ctest -R "^(d3d12_existing_heap|d3d12_console_descriptor_heap|d3d12_descriptor|xs_proxy_mock|device_proxy|queue_proxy)$"-> 6/6 passed.python -I scripts/check_no_game_data.pyon all 5 changed files -> exit 0.AI-assisted.
Retested exact head
2ec2ca450on native Windows 11 build 26100, RTX 5070 Ti (610.74), MSVC 19.44 RelWithDebInfo. All six requested CTest cases passed, with zero VUIDs and Khronos validation 1.4.369 active on the GPU tests.The two cases from my earlier review are now covered by the stock console descriptor heap test and passed here. A valid descriptor placed in slot 0 before heap creation reached the real backing on the first submit. Both
CopyDescriptorsSimpleandCopyDescriptorsobserved a direct CPU write to a custom-backed source heap. The existing-heap test also passed its deterministic 48-bit boundary cases.Synthetic inputs only. This verifies those regressions on Blackwell. AI-assisted: yes (OpenAI Codex).
Hi @TanmaySatyam, thanks for this pull request. It currently conflicts with
main(conflicting file(s):runtime/shims/d3d12_vulkan_device.cpp,runtime/shims/d3d12_xs_device.cpp), so it carries theneeds rebaselabel. CONTRIBUTING.md asks authors to rebase their branch onmain; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.AI-assisted (Claude Code, Claude Opus 5.5).
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.