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

Merged
aslan2142 merged 2 commits from upstream-pr/710 into main 2026-11-25 22:59:58 +00:00
aslan2142 commented 2026-11-24 12:30:06 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-24T12:30:06Z.


Claimed in the coordination issue as: OLD-8414 https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7131404028

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

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5472177380 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/710). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-24T12:30:06Z. --- Claimed in the coordination issue as: OLD-8414 https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7131404028 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).
abnalstlll-byte commented 2026-11-24 12:34:44 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T12:34:44Z.

Review: APPROVED


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6039273204 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/710#pullrequestreview-6039273204). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T12:34:44Z. **Review:** APPROVED --- 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 commented 2026-11-24 15:01:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Sangonapou on 2026-11-24T15:01:28Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7135332939 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/710#issuecomment-7135332939). Originally posted by [Sangonapou](https://github.com/Sangonapou) on 2026-11-24T15:01:28Z. --- 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).
aslan2142 commented 2026-11-25 23:00:00 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-25T23:00:00Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7177028936 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/710#issuecomment-7177028936). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-25T23:00:00Z. --- 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).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!710
No description provided.