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

Manually merged
github merged 2 commits from gh-pr/710/head into gh-pr/710/base 2026-11-26 09:17:26 +00:00
Owner

@⁠aslan2142 on GitHub · 2026-11-24 12:30 UTC · original
aslan2142:gpuav-as-type → main · +112 −2 · 2 files · 2 commits · merged 2026-11-25 22:59 UTC

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

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 21625bca8c. 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** on GitHub · 2026-11-24 12:30 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/710) `aslan2142:gpuav-as-type` → `main` · +112 −2 · 2 files · 2 commits · merged 2026-11-25 22:59 UTC Claimed in the coordination issue as: OLD-8414 https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14 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 21625bca8c67. 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 - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] 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).
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 <[email protected]>
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 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:17:24 +00:00
github manually merged commit 296508e19d into gh-pr/710/base 2026-11-26 09:17:26 +00:00
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 12:34 UTC · original · approved these changes

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.

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 12:34 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/710#pullrequestreview-6039273204) · **approved these changes** 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.
Author
Owner

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

Tested 296508e1 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).

**@⁠Sangonapou** on GitHub · 2026-11-24 15:01 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/710#issuecomment-7135332939) Tested 296508e1 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).
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 23:00 UTC · original

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

  • Changed since review: nothing. It merges cleanly with main, and no review point is open. A native Windows run on an RTX 3080 Ti passed d3d12_indirect_rt.
  • Tested: the full Windows suite under Wine on main 5fab93967 with all nine of these runtime PRs merged together (#634, #643, #684, #657, #677, #638, #710, #688, #671), on llvmpipe and the gfx1036 iGPU (RADV): no test went from pass to fail.
  • Checked on main 340e8a415 + 296508e19: it merges cleanly; the semantic suite passes (493 files, 6,318 tests, 0 files failed); the 15 docs and writer tests pass; check_no_game_data.py is clean on the 2 changed files.

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

**@⁠aslan2142** on GitHub · 2026-11-25 23:00 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/710#issuecomment-7177028936) Merged: arena AS resources in the d3d12 layer take their address from `vkGetAccelerationStructureDeviceAddressKHR`. - **Changed since review:** nothing. It merges cleanly with `main`, and no review point is open. A native Windows run on an RTX 3080 Ti passed `d3d12_indirect_rt`. - **Tested:** the full Windows suite under Wine on `main` `5fab93967` with all nine of these runtime PRs merged together (#634, #643, #684, #657, #677, #638, #710, #688, #671), on llvmpipe and the gfx1036 iGPU (RADV): no test went from pass to fail. - **Checked on `main` `340e8a415` + `296508e19`:** it merges cleanly; the semantic suite passes (493 files, 6,318 tests, 0 files failed); the 15 docs and writer tests pass; `check_no_game_data.py` is clean on the 2 changed files. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.