Skip to content

d3d12: an ARRAY_OF_POINTERS entry below the arena is not an overflow (d3d12_indirect_rt on NVIDIA) - #6010

Open
lines9686-rgb wants to merge 1 commit into
ItsNotRexed:mainfrom
lines9686-rgb:fix-khr-pointer-list-wrap
Open

lines9686-rgb wants to merge 1 commit into
ItsNotRexed:mainfrom
lines9686-rgb:fix-khr-pointer-list-wrap

Conversation

@lines9686-rgb

Copy link
Copy Markdown
Contributor

Item: new finding, claimed in #5934 (#5934 (comment)). Depends on: none. Regression from cc4b374 (#4060's merge, "translate ARRAY_OF_POINTERS instances on the KHR path"); @ttd0x reported the failure in #166 and bisected it to that commit.

What fails. d3d12_indirect_rt on main 561b65a8, RTX 3060 Ti (NVIDIA 610.88, Windows 11, Resizable BAR: upload heaps live in VRAM) and RTX 2080 Ti (#166):

[rt] d3d12: ExecuteCommandLists failed: invalid copy or resolve; nothing was submitted
FAIL: RayQueryKHR ARRAY expected hit=1 miss=0, got hit=0 miss=0

It passed on 3faac557, before cc4b374.

Why. stage_khr_instances (runtime/src/vulkan_backend.h) refuses a pointer-list entry when va > UINT64_MAX - vk.heap_base. The list's host read is fine (a debug print gave va=0xfffffffffed40000 status=ok); the refusal is that overflow check. An UPLOAD buffer's VA is its device address minus the heap base (docs/d3d12_vulkan.md, section 3), so a buffer allocated below the arena has a VA that wraps, and heap_base + va is its device address again. Every other VA-to-address conversion is that wrapping sum (addr() in vulkan_replay.h, the XDXR path). The refusal fails the whole ExecuteCommandLists, so the plain ARRAY TLAS in the same list misses too.

Fix. Drop that one condition and say why in a comment. Null entries, entries outside any buffer and entries with less than 64 bytes of room are still refused by the same if.

Tested on the RTX 3060 Ti, MSVC RelWithDebInfo, on main 561b65a8:

No game files. AI-assisted (Claude Code).

🤖 Generated with Claude Code

stage_khr_instances refused a pointer whose VA is above UINT64_MAX - heap_base. An UPLOAD buffer's VA is its
device address minus the heap base, so a buffer allocated below the arena has a VA that wraps, and heap_base + va
is its device address again, as addr() in vulkan_replay.h and the XDXR path compute it. The refusal failed the
whole ExecuteCommandLists ("invalid copy or resolve"), so d3d12_indirect_rt failed on NVIDIA (RTX 3060 Ti, and
RTX 2080 Ti per ItsNotRexed#166) since cc4b374.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@shdann

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 2e86358 on Windows 11 with the NVIDIA GeForce RTX 4090 (driver 32.0.16.2101) and AMD Radeon integrated graphics (driver 32.0.21043.5001). The targeted ray-tracing test passes on each adapter with zero Vulkan validation errors.

I built the PR and its parent 561b65a8 in separate folders with cmake --build <build> --config RelWithDebInfo --target d3d12_indirect_rt_test. I ran RelWithDebInfo/d3d12_indirect_rt_test.exe from each build folder with LEONIDA_VK_VALIDATION=1. I set LEONIDA_VK_DEVICE=4090 or Radeon and disabled the other driver's manifest with VK_LOADER_DRIVERS_DISABLE=*amd* or *nv*, respectively. I checked the printed device name on all four runs.

Both TLAS layouts give hit=1 and miss=0 on both revisions. Both revisions also reject the null entry and the GPU-written placed pointer list before submission. The parent passes here, so these runs do not reproduce the below-arena allocation seen on the RTX 3060 Ti. This check covers the indirect RT target only.

AI-assisted.

@kour0

kour0 commented Nov 23, 2026

Copy link
Copy Markdown

Tested 2e86358 on RTX 4070 Ti SUPER (Ada), NVIDIA 621.01, Windows 11 (build 26300), MSVC RelWithDebInfo: pass.

  • Before the change (on 561b65a83, with a temporary print at the refusal): entry 0 va=0xfffffffffe07d000, room=64, heap_base=0x8e40000, so the only condition that refused it was va > UINT64_MAX - heap_base. Same diagnosis as yours, independently.
  • d3d12_indirect_rt: PASS with and without LEONIDA_VK_VALIDATION=1 (0 validation errors): BLAS + TLAS ARRAY and ARRAY_OF_POINTERS hit=1 miss=0; the null-entry and GPU-written-list cases still refuse before submission.
  • Full ctest: 244/247. The three failures are the same as on main without the change: d3d12_indirect_dispatch_count (d3d12_indirect_dispatch_count_test: its compute fixture reads the root UAV at s4:s5 (D3D-448 layout) #5792), and dxgi_device / dxgi_swapchain, which this remote session without a desktop cannot run.

No game files.

@CharlyRien

Copy link
Copy Markdown

Tested 2e86358 (merged on main 561b65a) on RTX 3090 (NVIDIA 616.56, Windows 11 23H2, Resizable BAR off, so upload heaps are in system memory): pass. AI-assisted.

  • d3d12_indirect_rt_test passes, with and without LEONIDA_VK_VALIDATION=1 (0 validation errors): BLAS + TLAS (ARRAY and ARRAY_OF_POINTERS) + RayQueryKHR (hit=1, miss=0). Both negative controls (null entry refused, GPU-written list unsupported) pass as well. On main 561b65a the same test fails here with the invalid copy or resolve / hit=0 miss=0 output from your description.
  • This covers the non-ReBAR case, which complements your RTX 3060 Ti (ReBAR) result. A correction to my note on D3D-516: Keep committed buffer addresses within the V# range #5052: the failure is not limited to machines without ReBAR, since it also happens on your 3060 Ti with ReBAR. What matters is whether the driver places the upload buffer below the arena, so that the VA wraps.

@Exopus-0x65f7ad0

Copy link
Copy Markdown
Contributor

Tested 2e863581 on RTX 5060 Ti / NVIDIA 621.14, Windows 11 26300, MSVC 14.51, Vulkan SDK 1.4.363.0, built with -DLEONIDA_LLVM_MC: pass.

  • Negative control: on main 561b65a8 on the same machine, d3d12_indirect_rt_test fails with FAIL: RayQueryKHR ARRAY expected hit=1 miss=0, got hit=0 miss=0, after ExecuteCommandLists failed: invalid copy or resolve.
  • This PR: LEONIDA_VK_VALIDATION=1 ctest -R ^d3d12_indirect_rt$ passes 5 of 5. A direct run gives [PASS] BLAS + TLAS (ARRAY and ARRAY_OF_POINTERS) + RayQueryKHR (hit=1, miss=0), both ARRAY_OF_POINTERS refusals PASS, and d3d12_indirect_rt_test: PASS (0 validation errors).

So on a Blackwell card this one fixes the failure @zxcvqwerasdf couldn't reproduce on an RTX 2080 Ti. AI-assisted (Claude Code).

@Jadiac5

Jadiac5 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 2e86358 on Windows 11, AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32029.2010: pass, but the run cannot tell fix from no fix

  • Ran d3d12_indirect_rt_test with LEONIDA_VK_VALIDATION=1 off and on (Vulkan layers 1.4.363): exit 0, 0 validation errors both times.
  • Control: the merge base 561b65a also passes the same test here. The PR describes the failure on NVIDIA with ReBAR, where heap_base + va wraps for a buffer below the arena. Upload heaps are in VRAM here (ReBAR on), and the failure does not show on this GPU, so this run does not exercise the changed condition in stage_khr_instances (runtime/src/vulkan_backend.h).
  • The PR adds no test. A buffer placed below the arena base would be the input that shows the wrap; I did not construct one.
  • Not done: no input that puts a buffer below the arena; only the existing test was run.

AI-assisted (Claude Code).

@devnull34

Copy link
Copy Markdown

Tested 2e863581 (base cc4b3744) on Windows 11 (build 26300), MSVC 19.51, AMD Radeon RX 7900 GRE: pass.

  • ctest --test-dir runtime/build -C RelWithDebInfo -R '^d3d12_indirect_rt$' --output-on-failure: Passed (0.29s).
  • Code review: The removal of the erroneous va > UINT64_MAX - vk.heap_base check is mathematically correct. For upload buffers, the VA is computed as device_address - heap_base, where wrapping around is intentional and expected when the address falls below the arena base. Unsigned 64-bit addition restores the proper device address without false-positive overflow rejection. Clean fix. Approve.

@devnull34 devnull34 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved based on independent verification of commit 2e86358.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants