d3d12/xs: guard 48-bit host-import VAs and sync title-written descriptor heaps (D3D-RTX5070-HOST-HEAP-SYNC) #644

Open
github-bot wants to merge 1 commit from github-bot/gh-644 into main AGit
Owner

@⁠TanmaySatyam on GitHub · 2026-11-24 10:49 UTC · original
TanmaySatyam:feature/rtx5070-fixes → main · +339 −10 · 5 files · 1 commits · open

Claimed in the coordination issue as: D3D-RTX5070-HOST-HEAP-SYNC

AI-assisted.

Summary

  1. 48-bit VA guard for host-imported slot-133 buffers (runtime/shims/d3d12_vulkan_device.cpp)
    • When VK_EXT_external_memory_host places a title-backed host import below heap_base, address - heap_base wraps in 64-bit unsigned arithmetic (bits 48..63 = 0xFFFF), corrupting 48-bit V# buffer descriptors.
    • Detects va >= (1ull << 48) after subtracting heap_base and falls back to the existing in-arena shadow buffer path cleanly.
  2. Custom CPU descriptor heap mirroring & pre-submit synchronization (runtime/shims/d3d12_xs_device.cpp)
    • Backs mapped console-extended descriptor heaps with a real GPU-arena heap, translates and mirrors device descriptor writes (slots 17–24 and Xbox slot 70) back to the title's CPU backing, and diffs/syncs title-written shader-visible descriptors into the GPU arena prior to queue ExecuteCommandLists / ExecuteCommandListsX.

Testing & Verification

  • Hardware / Driver: NVIDIA GeForce RTX 5070 (Driver 591.74, Windows 11, MSVC RelWithDebInfo, main@21625bca8)
  • Passed d3d12_existing_heap, d3d12_descriptor, and d3d12_console_descriptor_heap CTests under LEONIDA_VK_VALIDATION=1 and VK_VALIDATION_VALIDATE_SYNC=1 (3/3 passed, 0 validation errors).
  • Clean-room verified: python -I scripts/check_no_game_data.py runtime/shims/d3d12_vulkan_device.cpp runtime/shims/d3d12_xs_device.cpp exited 0.
**@⁠TanmaySatyam** on GitHub · 2026-11-24 10:49 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/644) `TanmaySatyam:feature/rtx5070-fixes` → `main` · +339 −10 · 5 files · 1 commits · open Claimed in the coordination issue as: D3D-RTX5070-HOST-HEAP-SYNC AI-assisted. ### Summary 1. **48-bit VA guard for host-imported slot-133 buffers (`runtime/shims/d3d12_vulkan_device.cpp`)** - When `VK_EXT_external_memory_host` places a title-backed host import below `heap_base`, `address - heap_base` wraps in 64-bit unsigned arithmetic (`bits 48..63 = 0xFFFF`), corrupting 48-bit V# buffer descriptors. - Detects `va >= (1ull << 48)` after subtracting `heap_base` and falls back to the existing in-arena shadow buffer path cleanly. 2. **Custom CPU descriptor heap mirroring & pre-submit synchronization (`runtime/shims/d3d12_xs_device.cpp`)** - Backs mapped console-extended descriptor heaps with a real GPU-arena heap, translates and mirrors device descriptor writes (slots 17–24 and Xbox slot 70) back to the title's CPU backing, and diffs/syncs title-written shader-visible descriptors into the GPU arena prior to queue `ExecuteCommandLists` / `ExecuteCommandListsX`. ### Testing & Verification - **Hardware / Driver:** NVIDIA GeForce RTX 5070 (Driver 591.74, Windows 11, MSVC RelWithDebInfo, `main@21625bca8`) - Passed `d3d12_existing_heap`, `d3d12_descriptor`, and `d3d12_console_descriptor_heap` CTests under `LEONIDA_VK_VALIDATION=1` and `VK_VALIDATION_VALIDATE_SYNC=1` (3/3 passed, 0 validation errors). - Clean-room verified: `python -I scripts/check_no_game_data.py runtime/shims/d3d12_vulkan_device.cpp runtime/shims/d3d12_xs_device.cpp` exited 0.
Rebased onto upstream main on top of #939 (LEONIDA_DESC_MIRROR) and the below-arena guard:
- d3d12_com.h / d3d12_vulkan_device.cpp: add rt::d3d12::host_import_va_in_vsharp_range() so positive offsets >= 2^48 above heap_base also fall back to the arena shadow while preserving LEONIDA_IMPORT_BELOW_ARENA=1 for below-arena imports; add deterministic 48-bit boundary + BDA arena tests in d3d12_existing_heap_test.cpp.
- d3d12_xs_device.cpp: layer two missing sync paths directly on top of LEONIDA_DESC_MIRROR and local_accessible():
  1) local_sync_source() before CopyDescriptors / CopyDescriptorsSimple so direct CPU writes to custom-backed source heaps reach destinations immediately on the CPU timeline.
  2) Per-slot 64-bit fingerprint sync (local_sync_shader_visible_heaps) before queue ExecuteCommandLists (slots 10/35) for shader-visible custom-backed heaps, picking up pre-filled slots on first submit and title-byte-copied descriptors outside 64-slot root-table binds without copying unchanged slots.
- d3d12_console_descriptor_heap_test.cpp: add unit coverage for pre-filled first-submit sync, post-creation direct writes, and CopyDescriptorsSimple / CopyDescriptors from custom-backed heaps.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:13:36 +00:00
Author
Owner

@⁠sodove on GitHub · 2026-11-24 11:27 UTC · original

Independent Windows review of exact head 23872cc on 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:

  1. Pre-filled custom heap on its first submit. An unchanged valid descriptor already in the CPU range when the heap is created never reaches the real backing on that submit. The nearby slot filled after creation does. register_descriptor_range initializes last_synced from the supplied CPU range without initializing the real backing, so the first diff treats those existing bytes as already copied.
  2. CPU-only custom heap as the source of a descriptor copy. After directly writing valid CBV bytes to CPU storage, neither CopyDescriptorsSimple nor CopyDescriptors copies 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.

**@⁠sodove** on GitHub · 2026-11-24 11:27 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/644#issuecomment-7130114804) Independent Windows review of exact head `23872cc` on 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: 1. **Pre-filled custom heap on its first submit.** An unchanged valid descriptor already in the CPU range when the heap is created never reaches the real backing on that submit. The nearby slot filled after creation does. `register_descriptor_range` initializes `last_synced` from the supplied CPU range without initializing the real backing, so the first diff treats those existing bytes as already copied. 2. **CPU-only custom heap as the source of a descriptor copy.** After directly writing valid CBV bytes to CPU storage, neither `CopyDescriptorsSimple` nor `CopyDescriptors` copies 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](https://learn.microsoft.com/en-us/windows/win32/direct3d12/copying-descriptors). All inputs were synthetic. AI-assisted.
Author
Owner

@⁠lixonik on GitHub · 2026-11-24 11:28 UTC · original · reviewed

One additional coverage gap on 23872cc from code review. The existing-heap fixture leaves VulkanDeviceInfo::buffer_device_address unset. The device only calls create_arena() when that flag is enabled, so this fixture cannot exercise the new condition that requires both an arena address and an imported buffer address.

Could the 48-bit check get a deterministic regression case? The boundary inputs are a buffer address just below the arena, offsets of 0 and 2^48 - 1, and an offset of 2^48. The valid offsets should still be accepted and the out-of-range ones should take the shadow path.

AI-assisted static review. No GPU run for this observation.

**@⁠lixonik** on GitHub · 2026-11-24 11:28 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/644#pullrequestreview-6038391358) · **reviewed** One additional coverage gap on `23872cc` from code review. The [existing-heap fixture](https://github.com/ubiquitarianism/leonida/blob/21625bca8c675c62f9dbffc318ce6a59d57faf31/runtime/test/d3d12_existing_heap_test.cpp#L342-L355) leaves `VulkanDeviceInfo::buffer_device_address` unset. The device only calls `create_arena()` when that flag is enabled, so this fixture cannot exercise the new condition that requires both an arena address and an imported buffer address. Could the 48-bit check get a deterministic regression case? The boundary inputs are a buffer address just below the arena, offsets of 0 and `2^48 - 1`, and an offset of `2^48`. The valid offsets should still be accepted and the out-of-range ones should take the shadow path. AI-assisted static review. No GPU run for this observation.
Author
Owner

@⁠lixonik on GitHub · 2026-11-24 12:26 UTC · original · edited 2026-11-24 12:55 UTC

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_test and d3d12_console_descriptor_heap_test both exited 0.

d3d12_existing_heap_test terminated with 0xC0000008 in 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 21625bca is available now. With the same AppContainer setup and packaged synthetic fixtures, both descriptor tests also exit 0 on the base, and d3d12_existing_heap_test terminates with the identical 0xC0000008. All three outcomes match between base and PR in this harness. This comparison does not establish the cause of the existing-heap failure.

**@⁠lixonik** on GitHub · 2026-11-24 12:26 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/644#issuecomment-7131454658) · edited 2026-11-24 12:55 UTC 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_test` and `d3d12_console_descriptor_heap_test` both exited 0. `d3d12_existing_heap_test` terminated with `0xC0000008` in 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 `21625bca` is available now. With the same AppContainer setup and packaged synthetic fixtures, both descriptor tests also exit 0 on the base, and `d3d12_existing_heap_test` terminates with the identical `0xC0000008`. All three outcomes match between base and PR in this harness. This comparison does not establish the cause of the existing-heap failure.
Author
Owner

@⁠Timon360SB on GitHub · 2026-11-24 13:35 UTC · original

Independent regression verification — Turing and Blackwell

Baseline:
21625bca8c

PR head:
23872cc5495d914d044ebc7ad8ef9422b3e5c357

Environment

Configuration RTX 2060 SUPER RTX 5070
Architecture Turing Blackwell
NVIDIA driver 621.14 621.14
Windows 11 build 28000 26200
Vulkan SDK 1.4.363.0 1.4.363.0
MSVC 19.44.35230 19.44.35230
Build RelWithDebInfo RelWithDebInfo
Generator Ninja Multi-Config Ninja Multi-Config

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.

Test 2060S BASE 2060S HEAD 5070 BASE 5070 HEAD
d3d12_existing_heap 3/3 3/3 3/3 3/3
d3d12_descriptor 3/3 3/3 3/3 3/3
d3d12_console_descriptor_heap 3/3 3/3 3/3 3/3

36/36 test executions passed.
No skipped tests or reported Vulkan validation errors.

Additional observations

  • All 8 OpenExistingHeapFromAddress comparison
    cases matched both native hardware D3D12 and WARP.
  • Slot-133 buffer import and ordinary-buffer
    fallback checks passed on both revisions.
  • HEAD logs confirm that descriptor slots
    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.

**@⁠Timon360SB** on GitHub · 2026-11-24 13:35 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/644#issuecomment-7133044992) ## Independent regression verification — Turing and Blackwell Baseline: 21625bca8c675c62f9dbffc318ce6a59d57faf31 PR head: 23872cc5495d914d044ebc7ad8ef9422b3e5c357 ### Environment | Configuration | RTX 2060 SUPER | RTX 5070 | | --- | --- | --- | | Architecture | Turing | Blackwell | | NVIDIA driver | 621.14 | 621.14 | | Windows 11 build | 28000 | 26200 | | Vulkan SDK | 1.4.363.0 | 1.4.363.0 | | MSVC | 19.44.35230 | 19.44.35230 | | Build | RelWithDebInfo | RelWithDebInfo | | Generator | Ninja Multi-Config | Ninja Multi-Config | 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. | Test | 2060S BASE | 2060S HEAD | 5070 BASE | 5070 HEAD | | --- | --- | --- | --- | --- | | d3d12_existing_heap | 3/3 | 3/3 | 3/3 | 3/3 | | d3d12_descriptor | 3/3 | 3/3 | 3/3 | 3/3 | | d3d12_console_descriptor_heap | 3/3 | 3/3 | 3/3 | 3/3 | 36/36 test executions passed. No skipped tests or reported Vulkan validation errors. ### Additional observations - All 8 OpenExistingHeapFromAddress comparison cases matched both native hardware D3D12 and WARP. - Slot-133 buffer import and ordinary-buffer fallback checks passed on both revisions. - HEAD logs confirm that descriptor slots 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.
Author
Owner

@⁠TanmaySatyam on GitHub · 2026-11-24 14:34 UTC · original

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:

  1. Pre-filled custom shader-visible heap on first submit (@⁠sodove #1):

    • 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.
  2. CPU-only custom heap as source of \CopyDescriptors\ / \CopyDescriptorsSimple\ (@⁠sodove #2):
    • Added \sync_title_source_descriptors\ and call it for every source range in \proxy_copy_descriptors\ (slot 23) and \proxy_copy_descriptors_simple\ (slot 24) before forwarding to \self->real->CopyDescriptors*, so direct CPU writes into any mirrored custom heap reach the destination immediately on the CPU timeline.
  3. Deterministic 48-bit V# VA guard & live BDA-arena regression tests (@⁠lixonik):
    • Extracted
      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 \
**@⁠TanmaySatyam** on GitHub · 2026-11-24 14:34 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/644#issuecomment-7134591933) 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: 1. **Pre-filled custom shader-visible heap on first submit (@⁠sodove #1):** - \ 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\. 2. **CPU-only custom heap as source of \CopyDescriptors\ / \CopyDescriptorsSimple\ (@⁠sodove #2):** - Added \sync_title_source_descriptors\ and call it for every source range in \proxy_copy_descriptors\ (slot 23) and \proxy_copy_descriptors_simple\ (slot 24) before forwarding to \self->real->CopyDescriptors*\, so direct CPU writes into any mirrored custom heap reach the destination immediately on the CPU timeline. 3. **Deterministic 48-bit V# VA guard & live BDA-arena regression tests (@⁠lixonik):** - Extracted \ 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 \
Author
Owner

@⁠lixonik on GitHub · 2026-11-24 15:24 UTC · original

Thanks for adding the deterministic boundary cases and the live BDA fixture. One static follow-up on 2c136008: in check_title_placed_with_bda, VirtualFree(pages, ...) runs before the local Ref<ID3D12Resource> buffer destructor 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 lifetime

AI-assisted static follow-up. No GPU run on this head yet.

**@⁠lixonik** on GitHub · 2026-11-24 15:24 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/644#issuecomment-7135986448) Thanks for adding the deterministic boundary cases and the live BDA fixture. One static follow-up on `2c136008`: in `check_title_placed_with_bda`, `VirtualFree(pages, ...)` runs before the local `Ref<ID3D12Resource> buffer` destructor 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](https://github.com/ubiquitarianism/leonida/blob/2c136008f8ccd3ed5a04ef38bd2ba12189673a04/runtime/test/d3d12_existing_heap_test.cpp#L368-L389) · [Vulkan host-pointer lifetime](https://docs.vulkan.org/refpages/latest/refpages/source/VkImportMemoryHostPointerInfoEXT.html) AI-assisted static follow-up. No GPU run on this head yet.
Author
Owner

@⁠TanmaySatyam on GitHub · 2026-11-24 15:31 UTC · original

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.

**@⁠TanmaySatyam** on GitHub · 2026-11-24 15:31 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/644#issuecomment-7136170481) Good catch @⁠lixonik — scoped \Ref<ID3D12Resource> 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.
Author
Owner

@⁠MalexAson on GitHub · 2026-11-24 19:52 UTC · original

Tested c4b11a8c32 applied on main 6293c1c4f, 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_heap as a whole is red on this GPU before and after, for a reason that is already on main.

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 with VK_LOADER_DRIVERS_SELECT):

main 6293c1c4f with this change
d3d12_descriptor pass pass
d3d12_console_descriptor_heap pass pass
d3d12_existing_heap fails fails, the same lines

The new cases in d3d12_existing_heap run here and pass:

vsharp 48-bit range guard: deterministic boundary cases passed
vulkan slot-133 buffer (BDA arena): returned valid GPU VA 0x10000 (arena shadow fallback)

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 below heap_base, the case the guard is for.

What keeps the test red is not from this pull request. In the existing check_title_placed cases (no BDA arena) the import succeeds and the copy out of the buffer is then refused, three times, identically with and without the change:

[rt] d3d12: ExecuteCommandLists failed: unsupported; nothing was submitted
vulkan slot-133 buffer line 219: SUCCEEDED(queue->Signal(fence.p, 1))

That is the finding in #14. 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.

**@⁠MalexAson** on GitHub · 2026-11-24 19:52 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/644#issuecomment-7142718177) Tested c4b11a8c32 applied on `main` 6293c1c4f, 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_heap` as a whole is red on this GPU before and after, for a reason that is already on `main`. `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 with `VK_LOADER_DRIVERS_SELECT`): | | `main` 6293c1c4f | with this change | |---|---|---| | `d3d12_descriptor` | pass | pass | | `d3d12_console_descriptor_heap` | pass | pass | | `d3d12_existing_heap` | fails | fails, the same lines | The new cases in `d3d12_existing_heap` run here and pass: ``` vsharp 48-bit range guard: deterministic boundary cases passed vulkan slot-133 buffer (BDA arena): returned valid GPU VA 0x10000 (arena shadow fallback) ``` 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 below `heap_base`, the case the guard is for. What keeps the test red is not from this pull request. In the existing `check_title_placed` cases (no BDA arena) the import succeeds and the copy out of the buffer is then refused, three times, identically with and without the change: ``` [rt] d3d12: ExecuteCommandLists failed: unsupported; nothing was submitted vulkan slot-133 buffer line 219: SUCCEEDED(queue->Signal(fence.p, 1)) ``` That is the finding in https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14. 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.
Author
Owner

@⁠QemmHD on GitHub · 2026-11-24 21:20 UTC · original

Independent test of head c4b11a8c3 on Windows 11 / RTX 4070 SUPER (NVIDIA 621.24, VS 2022, Ninja, RelWithDebInfo), merged alone onto main 66d4f5aa3:

  • existing_heap, console_descriptor_heap, descriptor, xs_proxy_mock, device_proxy and queue_proxy pass 6/6, both plain and with LEONIDA_VK_VALIDATION=1 (0 VUIDs).
  • The repo-consistency set gives 573 passed / 5 skipped / 0 failed. No game data. It merges cleanly onto current main.

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:

  1. On this NVIDIA card the BDA-arena fixture also hits the new 48-bit guard ("bits 48-63: 65535", arena-shadow fallback), the same thing MalexAson saw on Intel. So on NVIDIA, too, title-placed host imports in BDA mode now take the shadow fallback instead of producing a wrapped V#.
  2. A readable console slot-14 heap no longer takes the console-addressed path. Its GPU start becomes the arena offset instead of the title VA. The CPU start still equals the title address, which is what the retail boot checks.
  3. Every ExecuteCommandLists memcmps each mirrored shader-visible heap, so the per-submit cost grows with heap size. A dirty-range or generation check would keep it flat.
  4. Descriptor mirroring writes into title memory after only a readable_range check. A writable check, or catching the write fault, would be safer.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠QemmHD** on GitHub · 2026-11-24 21:20 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/644#issuecomment-7144790548) Independent test of head `c4b11a8c3` on Windows 11 / RTX 4070 SUPER (NVIDIA 621.24, VS 2022, Ninja, RelWithDebInfo), merged alone onto main 66d4f5aa3: - existing_heap, console_descriptor_heap, descriptor, xs_proxy_mock, device_proxy and queue_proxy pass 6/6, both plain and with `LEONIDA_VK_VALIDATION=1` (0 VUIDs). - The repo-consistency set gives 573 passed / 5 skipped / 0 failed. No game data. It merges cleanly onto current main. 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: 1. On this NVIDIA card the BDA-arena fixture also hits the new 48-bit guard ("bits 48-63: 65535", arena-shadow fallback), the same thing MalexAson saw on Intel. So on NVIDIA, too, title-placed host imports in BDA mode now take the shadow fallback instead of producing a wrapped V#. 2. A readable console slot-14 heap no longer takes the console-addressed path. Its GPU start becomes the arena offset instead of the title VA. The CPU start still equals the title address, which is what the retail boot checks. 3. Every ExecuteCommandLists memcmps each mirrored shader-visible heap, so the per-submit cost grows with heap size. A dirty-range or generation check would keep it flat. 4. Descriptor mirroring writes into title memory after only a `readable_range` check. A writable check, or catching the write fault, would be safer. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠QemmHD on GitHub · 2026-11-25 07:08 UTC · original

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).

**@⁠QemmHD** on GitHub · 2026-11-25 07:08 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/644#issuecomment-7155527425) 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).
Author
Owner

@⁠QemmHD on GitHub · 2026-11-25 07:52 UTC · original

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.cpp and 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).

**@⁠QemmHD** on GitHub · 2026-11-25 07:52 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/644#issuecomment-7156345443) 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.cpp` and 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).
Author
Owner

@⁠TanmaySatyam on GitHub · 2026-11-25 09:07 UTC · original

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:

  1. Upper 48-bit V# overflow guard + unit tests (d3d12_com.h, d3d12_vulkan_device.cpp, d3d12_existing_heap_test.cpp): Main now catches buffer_va < arena.address (unless LEONIDA_IMPORT_BELOW_ARENA=1), but not positive offsets >= 2^48 above heap_base. rt::d3d12::host_import_va_in_vsharp_range() guards both bounds while preserving LEONIDA_IMPORT_BELOW_ARENA=1 for below-arena imports, with deterministic boundary and BDA-arena tests.
  2. CopyDescriptors / CopyDescriptorsSimple source sync (d3d12_xs_device.cpp local_sync_source): Main's LEONIDA_DESC_MIRROR mirrors 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 before CopyDescriptors* reads the real heap (addressing @⁠sodove's finding #2).
  3. Per-slot 64-bit fingerprint sync before ExecuteCommandLists (local_sync_shader_visible_heaps): Layered directly onto DescriptorRange, local_desc_mirror() (LEONIDA_DESC_MIRROR=0 disables it too), and local_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.py on all 5 changed files -> exit 0.

AI-assisted.

**@⁠TanmaySatyam** on GitHub · 2026-11-25 09:07 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/644#issuecomment-7157902082) 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`:** 1. **Upper 48-bit V# overflow guard + unit tests (`d3d12_com.h`, `d3d12_vulkan_device.cpp`, `d3d12_existing_heap_test.cpp`):** Main now catches `buffer_va < arena.address` (unless `LEONIDA_IMPORT_BELOW_ARENA=1`), but not positive offsets `>= 2^48` above `heap_base`. `rt::d3d12::host_import_va_in_vsharp_range()` guards both bounds while preserving `LEONIDA_IMPORT_BELOW_ARENA=1` for below-arena imports, with deterministic boundary and BDA-arena tests. 2. **`CopyDescriptors` / `CopyDescriptorsSimple` source sync (`d3d12_xs_device.cpp` `local_sync_source`):** Main's `LEONIDA_DESC_MIRROR` mirrors 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 before `CopyDescriptors*` reads the real heap (addressing @⁠sodove's finding #2). 3. **Per-slot 64-bit fingerprint sync before `ExecuteCommandLists` (`local_sync_shader_visible_heaps`):** Layered directly onto `DescriptorRange`, `local_desc_mirror()` (`LEONIDA_DESC_MIRROR=0` disables it too), and `local_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.py` on all 5 changed files -> exit 0. AI-assisted.
Author
Owner

@⁠sodove on GitHub · 2026-11-25 10:54 UTC · original

Retested exact head 2ec2ca450 on 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 CopyDescriptorsSimple and CopyDescriptors observed 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).

**@⁠sodove** on GitHub · 2026-11-25 10:54 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/644#issuecomment-7160322909) Retested exact head `2ec2ca450` on 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 `CopyDescriptorsSimple` and `CopyDescriptors` observed 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).
This pull request has changes conflicting with the target branch.
  • runtime/shims/d3d12_vulkan_device.cpp
  • runtime/shims/d3d12_xs_device.cpp
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/644/head:github-bot/gh-644'
git switch 'github-bot/gh-644'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-644'
git switch 'github-bot/gh-644'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-644'
git switch 'github-bot/gh-644'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-644'
git switch 'main'
git merge --squash 'github-bot/gh-644'
git switch 'main'
git merge --ff-only 'github-bot/gh-644'
git switch 'main'
git merge 'github-bot/gh-644'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.