Skip to content

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

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

lines9686-rgb wants to merge 1 commit into
ProjectLeonida: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 ProjectLeonida#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.

@ethanweave

Copy link
Copy Markdown

Independent Windows check at 2e86358165889160a3f92a6478f5f14689026bb8 on
the RTX 4050 laptop, no game files.

Environment: Windows 11 26300, NVIDIA GeForce RTX 4050 Laptop GPU, NVIDIA
610.47 (32.0.16.1047), Vulkan 1.4.341, subgroup 32..32. The full runtime was
built with the portable clang-cl 23.1.6 / lld / xwin MSVC 14.44 + Windows SDK
10.0.26100 toolchain, CMake 4.5.1 and Ninja 1.13.2.

On main 561b65a8, ctest -R '^d3d12_indirect_rt$' fails with:

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

With this PR applied and d3d12_indirect_rt_test rebuilt, the same targeted
test passes:

1/1 Test #201: d3d12_indirect_rt ................ Passed 0.56 sec

The full unpatched run was 243/245; the other failure was the separate
d3d12_indirect_dispatch_count issue.

AI-assisted (Codex).

@crastinator

Copy link
Copy Markdown
Contributor

Tested 2e863581 merged onto main 8575d36e (clean merge) on AMD + RADV under Wine: pass.

AMD Radeon RX 6700 XT (gfx1031), RADV Mesa 26.3.1, CachyOS, Linux 7.3.5; Windows build cross-compiled with clang-cl 23.1.5 + xwin (SDK 10.0.26100), run under Wine 11.22 (ctest, which starts the tests through wine).

d3d12_indirect_rt
main 8575d36e fail: RayQueryKHR ARRAY expected hit=1 miss=0, got hit=0 miss=0
with this PR pass

So RDNA2 hardware ray queries through RADV hit the same ARRAY_OF_POINTERS problem as the NVIDIA runs, and this fixes it there too.

AI-assisted (Claude Code).

@lisboon

lisboon commented Nov 23, 2026

Copy link
Copy Markdown

Tested 2e8635816 (this change applied onto main 8575d36ed) on an RTX 4060 desktop (Ada), NVIDIA 621.24, Windows 11 26200, VS 2026 MSVC, Vulkan SDK 1.4.363.0, Resizable BAR off (BAR1 256 MiB, upload heaps in system memory): pass.

d3d12_indirect_rt runs result
main 8575d36ed 5 fails 5/5 (invalid copy or resolve; nothing was submitted, RayQueryKHR ARRAY hit=0)
with this PR 3 passes 3/3

Same mechanism here without Resizable BAR: the pointer-list entry was 0xfffffffffe075000, found by buffer_at (room 64) and refused only by the removed check. Forcing upload heaps into VRAM on main also made it pass, so on this machine the wrap comes from where system-memory buffers land relative to the arena. No game files.

AI-assisted (Claude Code).

@illusionart453-max

Copy link
Copy Markdown

Independent Windows/MSVC 19.44, RTX 5060 driver 32.0.16.1088: #6010 diff applied to main 8575d36 audit checkout; a clean-first rebuild of d3d12_indirect_rt_test passes, exit 0. The initial incremental build still reproduced invalid copy / RayQueryKHR ARRAY hit=0, so a clean rebuild was needed for valid evidence here. Baseline before this patch failed at that ARRAY result. Audit tree also includes unrelated #7125/#7357/#7391 and #5792. Validation layer unavailable. Synthetic GPU fixture only, no game files. AI-assisted (Codex).

@corpse240

Copy link
Copy Markdown

Tested 2e8635816 merged onto main 5d74c2723 (clean) on Intel Arc B580 (Battlemage, 0xe20b, Resizable BAR on), Intel Windows driver 101.9150, Vulkan 1.4.359, Windows 11 Pro 26200; RelWithDebInfo, VS 2022 Build Tools, Vulkan SDK 1.4.363.0: pass.

  • main: d3d12_indirect_rt fails: FAIL: RayQueryKHR ARRAY expected hit=1 miss=0, got hit=0 miss=0 (deterministic, also alone).
  • This PR: d3d12_indirect_rt_test exit 0, all four [PASS] lines (ExecuteIndirect; BLAS + TLAS ARRAY and ARRAY_OF_POINTERS + RayQueryKHR hit=1 miss=0; null entry refused; GPU-written pointer list refused), PASS (0 validation errors).

On this card separate allocations land in two VA pools tens of TiB apart (0xffff8004… / 0xffffb804…, see #8776), so the below-the-arena case is exercised on Intel too. #8981 also passes here.

AI-assisted (Claude Code); run on my own machine, no game files involved.

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.