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

Closed
opened 2026-11-26 20:18:56 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/710
Author: @aslan2142
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142

Base: main ← Head: gpuav-as-type


📝 Commits (2)

  • 186b20e d3d12: arena AS resources take their address from vkGetAccelerationStructureDeviceAddressKHR
  • 296508e d3d12_indirect_rt: check arena AS addresses, also on a driver whose address is not buffer address + offset

📊 Changes

2 files changed (+112 additions, -2 deletions)

View changed files

📝 runtime/shims/d3d12_vulkan_device.cpp (+22 -2)
📝 runtime/test/d3d12_indirect_rt_test.cpp (+90 -0)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/710 **Author:** [@aslan2142](https://github.com/aslan2142) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `gpuav-as-type` --- ### 📝 Commits (2) - [`186b20e`](https://github.com/ubiquitarianism/leonida/commit/186b20e462c65f2dc61cd9fb8b373efec1aab9b4) d3d12: arena AS resources take their address from vkGetAccelerationStructureDeviceAddressKHR - [`296508e`](https://github.com/ubiquitarianism/leonida/commit/296508e19d65f18209c3cc78d2a6cbcaaf12949a) d3d12_indirect_rt: check arena AS addresses, also on a driver whose address is not buffer address + offset ### 📊 Changes **2 files changed** (+112 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+22 -2) 📝 `runtime/test/d3d12_indirect_rt_test.cpp` (+90 -0) </details> ### 📄 Description 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). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:18:56 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#751
No description provided.