gpu: add native DXR 1.1 acceleration structure backend and OPTIONS5 query #702

Closed
github-bot wants to merge 2 commits from gh-pr/702/head into gh-pr/702/base
Owner

@⁠wbkepler on GitHub · 2026-11-24 07:06 UTC · original
wbkepler:gpu/dxr-bvh-builder → main · +1088 −10 · 6 files · 2 commits · closed without merging

Summary

Adds native DXR 1.1 acceleration structure support in victory-gpu:

  • host.rs & device.rs:
    • Exposes Host::options5(), Host::raytracing_tier(), Host::device5() (gated on RaytracingTier >= TIER_1_0 for clean WARP/non-RT fallback), and Host::default_uav_buffer().
    • Exposes D3D12_FEATURE_D3D12_OPTIONS5 (feature 27) in device::check_feature_support.
  • raytracing.rs & descriptor/host.rs:
    • Implements GetRaytracingAccelerationStructurePrebuildInfo, BuildRaytracingAccelerationStructure (single and batched, BLAS triangle/AABB Shadow translation + TLAS submission-time instance VA rewriting + postbuild info copy-back + UAV barriers), CopyRaytracingAccelerationStructure, and title-VA-to-host-AS tracking evicted on watch::title_memory_remapped.
    • Translates D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE SRVs in descriptor/host.rs.

Verification

  • cargo clippy --workspace --all-targets — passed (zero new warnings)
  • cargo clippy -p victory --features diagnostics --all-targets — passed
  • cargo test --workspace — passed (live DXR 1.1 BLAS/postbuild/CLONE/TLAS/eviction tests pass on hardware GPU)
  • VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --lib raytracing — passed (3/3, clean fallback)
  • VICTORY_D3D12_DEBUG=1 clean on both hardware GPU and WARP
  • cargo xtask policy — passed (152 files ok)
**@⁠wbkepler** on GitHub · 2026-11-24 07:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/702) `wbkepler:gpu/dxr-bvh-builder` → `main` · +1088 −10 · 6 files · 2 commits · closed without merging ## Summary Adds native DXR 1.1 acceleration structure support in `victory-gpu`: - **`host.rs` & `device.rs`**: - Exposes `Host::options5()`, `Host::raytracing_tier()`, `Host::device5()` (gated on `RaytracingTier >= TIER_1_0` for clean WARP/non-RT fallback), and `Host::default_uav_buffer()`. - Exposes `D3D12_FEATURE_D3D12_OPTIONS5` (feature 27) in `device::check_feature_support`. - **`raytracing.rs` & `descriptor/host.rs`**: - Implements `GetRaytracingAccelerationStructurePrebuildInfo`, `BuildRaytracingAccelerationStructure` (single and batched, BLAS triangle/AABB `Shadow` translation + TLAS submission-time instance VA rewriting + postbuild info copy-back + UAV barriers), `CopyRaytracingAccelerationStructure`, and title-VA-to-host-AS tracking evicted on `watch::title_memory_remapped`. - Translates `D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE` SRVs in `descriptor/host.rs`. ## Verification - `cargo clippy --workspace --all-targets` — passed (zero new warnings) - `cargo clippy -p victory --features diagnostics --all-targets` — passed - `cargo test --workspace` — passed (live DXR 1.1 BLAS/postbuild/`CLONE`/TLAS/eviction tests pass on hardware GPU) - `VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --lib raytracing` — passed (3/3, clean fallback) - `VICTORY_D3D12_DEBUG=1` clean on both hardware GPU and WARP - `cargo xtask policy` — passed (152 files ok)
- Add Host::options5, Host::raytracing_tier, Host::device5, and Host::default_uav_buffer in host.rs, and expose D3D12_FEATURE_D3D12_OPTIONS5 (feature 27) in device::check_feature_support.

- Add victory_gpu::raytracing implementing native DXR 1.1 GetRaytracingAccelerationStructurePrebuildInfo, BuildRaytracingAccelerationStructure (single and batched, BLAS triangles/AABBs + TLAS instance VA rewriting + postbuild info copy-back + UAV barriers), CopyRaytracingAccelerationStructure, and title-VA-to-host-AS tracking with title_memory_remapped eviction.

- Translate D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE descriptors in descriptor::host::make to host TLAS GPU virtual addresses.

- Add unit and live DXR 1.1 tests (OPTIONS5 query, BLAS/TLAS prebuild info, live BLAS build + CURRENT_SIZE postbuild readback + CLONE + TLAS build + remap eviction) skipping cleanly on non-DXR/WARP hosts.
Address Altorru's robustness review on PR #702 by bounding and
kernel-validating caller-supplied BLAS geometry arrays in
raytracing::read_geometries before allocating or reading them:

- Cap NumDescs at MAX_GEOMETRY_DESCS (1 << 20) and use checked byte-size
  and address-overflow arithmetic so corrupt counts cannot reserve
  multi-GiB buffers or wrap pointers.
- Verify committed backing memory via texture::committed before
  allocating and read both contiguous arrays and pointer arrays (plus
  each target D3D12_RAYTRACING_GEOMETRY_DESC) through host::read_into
  (ReadProcessMemory) instead of raw from_raw_parts/ptr::read.
- Add raytracing::tests::read_geometries_rejects_null_oversized_and_uncommitted_inputs
  covering oversized counts, null pointers, uncommitted/straddling
  ranges, bad pointer-array elements, and valid ARRAY/ARRAY_OF_POINTERS
  decoding.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:13:32 +00:00
github-bot closed this pull request 2026-11-26 04:13:32 +00:00
Author
Owner

@⁠Altorru on GitHub · 2026-11-24 10:17 UTC · original

Security/robustness note before build_on_list is wired to the title API: read_geometries trusts inputs.NumDescs and the pGeometryDescs / ppGeometryDescs pointer. NumDescs is a u32 from the caller, and std::slice::from_raw_parts(ptr, count) / Vec::with_capacity(count) run before any host D3D12 validation. A corrupt count can read far outside the allocation and, for ARRAY_OF_POINTERS, reserve hundreds of GiB; a bad pointer is UB/crash. translate_tlas_instances already uses checked multiplication and copy_mapped, so the BLAS geometry path is the odd one out.

Please bound count against the committed/mapped title range (or copy through copy_mapped into a checked buffer), reject null/uncommitted pointers, and add a negative case for an oversized or uncommitted geometry array. The synthetic DXR tests only exercise valid inputs; this is not a failure of the current tests.

**@⁠Altorru** on GitHub · 2026-11-24 10:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/702#issuecomment-7128568169) Security/robustness note before `build_on_list` is wired to the title API: `read_geometries` trusts `inputs.NumDescs` and the `pGeometryDescs` / `ppGeometryDescs` pointer. `NumDescs` is a `u32` from the caller, and `std::slice::from_raw_parts(ptr, count)` / `Vec::with_capacity(count)` run before any host D3D12 validation. A corrupt count can read far outside the allocation and, for `ARRAY_OF_POINTERS`, reserve hundreds of GiB; a bad pointer is UB/crash. `translate_tlas_instances` already uses checked multiplication and `copy_mapped`, so the BLAS geometry path is the odd one out. Please bound `count` against the committed/mapped title range (or copy through `copy_mapped` into a checked buffer), reject null/uncommitted pointers, and add a negative case for an oversized or uncommitted geometry array. The synthetic DXR tests only exercise valid inputs; this is not a failure of the current tests.
Author
Owner

@⁠konradbeck on GitHub · 2026-11-24 14:03 UTC · original

Independent inline ray-query readback on an NVIDIA RTX A4500 (driver 32.0.16.2124, Windows 11 build 26300.9974).

  • main at ffe310eb2098e52169f4c44db5ffdabf43a72622
  • PR head at 0237ecadb7791eb62a061206f54fb02143578f6b

I built a synthetic triangle BLAS and a TLAS with two translated, differently masked instances. A compute shader used TraceRayInline through the VIctory-created SRV and copied eight ray results back to the CPU.

Instance layout Ray readback
Contiguous instance records (ARRAY) 8/8 exact
Pointer array to scattered records (ARRAY_OF_POINTERS) 8/8 exact

Both layouts matched the native Direct3D control exactly. The four hits matched instance IDs, indices, and distances. The four expected misses covered mask rejection, a spatial miss, and a distance cutoff. The native control also passed 8/8 on main, where the VIctory OPTIONS5 query returned E_NOTIMPL and the guest path did not create a TLAS view.

The D3D12 debug layer was unavailable. I tested the two revisions separately because the local merge reported a conflict in watch.rs.

AI-assisted test fixture and write-up.

**@⁠konradbeck** on GitHub · 2026-11-24 14:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/702#issuecomment-7133781772) Independent inline ray-query readback on an **NVIDIA RTX A4500** (driver `32.0.16.2124`, Windows 11 build `26300.9974`). - `main` at `ffe310eb2098e52169f4c44db5ffdabf43a72622` - PR head at `0237ecadb7791eb62a061206f54fb02143578f6b` I built a synthetic triangle BLAS and a TLAS with two translated, differently masked instances. A compute shader used `TraceRayInline` through the VIctory-created SRV and copied eight ray results back to the CPU. | Instance layout | Ray readback | | --- | --- | | Contiguous instance records (`ARRAY`) | **8/8** exact | | Pointer array to scattered records (`ARRAY_OF_POINTERS`) | **8/8** exact | Both layouts matched the native Direct3D control exactly. The four hits matched instance IDs, indices, and distances. The four expected misses covered mask rejection, a spatial miss, and a distance cutoff. The native control also passed 8/8 on `main`, where the VIctory `OPTIONS5` query returned `E_NOTIMPL` and the guest path did not create a TLAS view. **The D3D12 debug layer was unavailable.** I tested the two revisions separately because the local merge reported a conflict in `watch.rs`. AI-assisted test fixture and write-up.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:27 UTC · original

Automated triage for the maintainers. Closing because it breaks a repository rule (see docs/asset-policy.md and the project rules): nothing taken from the console SDK or the game, no weakening of the asset policy, and the title stays offline.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

**@⁠Marvisak** on GitHub · 2026-11-25 00:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/702#issuecomment-7148534289) Automated triage for the maintainers. Closing because it breaks a repository rule (see `docs/asset-policy.md` and the project rules): nothing taken from the console SDK or the game, no weakening of the asset policy, and the title stays offline. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!702
No description provided.