Skip to content

OLD-8414: restore old upstream PR 8414 - d3d12: arena AS resources take their address from vkGetAccelerationStructureDeviceAddressKHR - #710

Merged
aslan2142 merged 2 commits into
ProjectLeonida:mainfrom
aslan2142:gpuav-as-type
Nov 25, 2026
Merged

aslan2142 merged 2 commits into
ProjectLeonida:mainfrom
aslan2142:gpuav-as-type

Conversation

@aslan2142

Copy link
Copy Markdown
Collaborator

Claimed in the coordination issue as: OLD-8414 #14 (comment)

Restoration of my original pull request, old upstream PR 8414 in ItsNotRexed/Leonida, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Ported onto main at 21625bc. The runtime change applies unchanged. In d3d12_indirect_rt_test.cpp, main's CLONE/COMPACT tests stay as they are, and the new checks go right after the TLAS lookups, where they were in the original.

What and why

  • The problem: a default-heap acceleration-structure resource in the GPU address arena returns buffer address + offset as its GPU VA without asking the driver.
  • What Vulkan requires: an instance must name its BLAS by a value from vkGetAccelerationStructureDeviceAddressKHR (VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-12281). For a GENERIC structure the spec only promises consistent offsets between the structures of one buffer, not that the address equals the buffer address.
  • The fix: the arena path now queries that address, as the committed-resource path already does. If a driver returns a different address, the resource uses the driver's address and keeps the arena address registered too. Release unregisters both, through the existing buffer_va_ path.
  • What GPU-assisted validation reported: it only knows addresses it has seen that call return. So it reported every arena BLAS as "an invalid acceleration structure reference" and replaced the instance's BLAS with its dummy one.
    • With the fix, three of its four reports turn into the known layer limit: a GENERIC structure built as bottom level is "not a bottom level acceleration structure", which the spec allows.
    • The fourth report, on the ARRAY_OF_POINTERS instance, was already there in the original PR's run.
  • The new test checks in d3d12_indirect_rt:
    • The BLAS and both TLAS resources have the driver's address as their GPU VA.
    • On a second device whose get_instance_proc returns a vkGetAccelerationStructureDeviceAddressKHR that adds 256 MiB to the real address (no runtime change), an AS resource's GPU VA is the driver's address, and the arena address still names the structure.
    • Releasing that resource forgets both addresses.
    • No builds run on that second device.

Tested

On Linux, d3d12_indirect_rt_test was cross-built with clang for the mingw target and run under Wine 11.22 (staging) on Mesa 26.3.1 RADV. CI's MSVC build was not run locally. Each GPU ran three builds: main, main with only the new test, and this branch. Every run used the host Khronos validation layer.

Run main main + test only this branch
Integrated GPU, validation PASS, 7 checks, 0 errors FAIL: shifted AS GPU VA PASS, 9 checks, 0 errors
Integrated GPU, LEONIDA_UPLOAD_SYSMEM=1 PASS, 7 checks - PASS, 9 checks
RX 7900 XTX, validation PASS, 7 checks, 0 errors FAIL: shifted AS GPU VA PASS, 9 checks, 0 errors
RX 7900 XTX, LEONIDA_UPLOAD_SYSMEM=1 PASS, 7 checks - PASS, 9 checks

With GPU-AV (VK_KHRONOS_VALIDATION_GPUAV_ENABLE=1), both GPUs give the same result as each other and as the original PR:

  • On main: 4 "invalid acceleration structure reference" reports.
  • On this branch: 3 "not a bottom level" reports for GENERIC structures, plus 1 invalid reference on the ARRAY_OF_POINTERS instance.
  • On both: the RayQueryKHR ARRAY check misses, because the layer still replaces the instance's BLAS with its dummy one.

Both changed files pass git diff --check and python -I scripts/check_no_game_data.py.

GPUs tested: AMD Radeon RX 7900 XTX (RDNA3) and the integrated AMD Radeon Graphics of a Ryzen 9 7950X3D (RDNA2, gfx1036), both on Mesa 26.3.1 RADV, Arch Linux, through Wine 11.22

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

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

aslan2142 and others added 2 commits November 24, 2026 07:25
…ructureDeviceAddressKHR

A default-heap acceleration-structure resource in the GPU address arena handed out buffer address + offset as its
GPU VA without asking the driver. An instance must name its BLAS by a value obtained from
vkGetAccelerationStructureDeviceAddressKHR (VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-12281), and for a GENERIC
structure the spec only promises consistent offsets between structures of one buffer, not equality with the buffer
address. Query it as the committed path does; if a driver ever returns a different address, use the driver's and
keep the arena address registered too.

GPU-assisted validation only knows addresses it has seen that call return, so it reported every arena BLAS as "an
invalid acceleration structure reference" and rewrote the instance to its dummy BLAS (the ray-query miss marso006
saw). It now reports the remaining layer limitation instead: a GENERIC structure built as bottom level is "not a
bottom level acceleration structure", which the spec allows.

Restored from old upstream PR 8414, which was closed unmerged when the original repository went private.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ddress is not buffer address + offset

Every AS resource's GPU VA must be the driver's vkGetAccelerationStructureDeviceAddressKHR value for the structure
behind it; the test checks that for the BLAS and both TLAS resources.

Envyre's review of old upstream PR 8414: the branch that takes the driver's address when it differs only ran on such
a driver. The test creates a second device whose get_instance_proc hands out a
vkGetAccelerationStructureDeviceAddressKHR that answers the real address plus 256 MiB (the device's existing
function-lookup hook, no change to the runtime), creates one AS resource on it and checks that its GPU VA is the
driver's address, that the arena address still names the structure, and that releasing the resource forgets both.
No builds run on that device.

The checks sit right after the TLAS lookups, before the CLONE/COMPACT section main has added since.

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

@abnalstlll-byte abnalstlll-byte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed and verified OLD-8414 restoration. Querying \�kGetAccelerationStructureDeviceAddressKHR\ for arena-backed acceleration structure resources satisfies VUID \VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-12281\ while maintaining registration across driver-shifted addresses and raw arena offsets. CTest additions in \d3d12_indirect_rt_test.cpp\ confirm GPU VA lookup, driver address alignment, and dual-address teardown. Approved.

@Sangonapou

Copy link
Copy Markdown
Contributor

Tested 296508e on NVIDIA GeForce RTX 3080 Ti Laptop (Ampere), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Pro (build 26300), native Windows: pass

Built with scripts\build_runtime.ps1 (MSVC 19.51, VS Build Tools 2026, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0). No game files.

ctest -R ^d3d12_indirect_rt$ -V: passed, PASS (0 validation errors), including [PASS] AS resource GPU VAs are the driver's acceleration structure addresses and [PASS] a driver address other than buffer address + offset is the GPU VA; both freed; the runtime logs GENERIC acceleration structure address is not its buffer address + offset; arena offset in KiB: 64 for the shifted device. Same result as I got on this card for the old upstream PR 8414 at b9e05449, where I also checked that the shifted device is what tells the two versions apart on NVIDIA (the real driver's address equals buffer address + offset here).

@aslan2142

Copy link
Copy Markdown
Collaborator Author

Merged: arena AS resources in the d3d12 layer take their address from vkGetAccelerationStructureDeviceAddressKHR.

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

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.

3 participants