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

Closed
wbkepler wants to merge 2 commits from upstream-pr/702 into main
wbkepler commented 2026-11-24 07:06:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by wbkepler on 2026-11-24T07:06:33Z.


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)
<!-- greyfinch-sync:Marvisak/VIctory:issue:6576547103 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/702). Originally posted by [wbkepler](https://github.com/wbkepler) on 2026-11-24T07:06:33Z. --- ## 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)
LAKSHYA-cmd-tech commented 2026-11-24 08:02:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by LAKSHYA-cmd-tech on 2026-11-24T07:10:35Z.

Review: APPROVED


Tested on Windows 11 MSVC (rustc 1.98.1):

  • cargo test -p victory-gpu --lib raytracing: 3 passed, 0 failed (live DXR 1.1 OPTIONS5 query, BLAS prebuild info sizing, and BLAS/TLAS build/copy pass cleanly)
  • cargo test -p victory-gpu: 46 passed, 0 failed, 1 ignored
  • cargo xtask policy: 152 files ok

All safety comments present on new unsafe blocks, clean tier query fallback when raytracing is unsupported, and correct descriptor translation for raytracing acceleration structures.

<!-- greyfinch-sync:Marvisak/VIctory:review:6035077969 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/702#pullrequestreview-6035077969). Originally posted by [LAKSHYA-cmd-tech](https://github.com/LAKSHYA-cmd-tech) on 2026-11-24T07:10:35Z. **Review:** APPROVED --- Tested on Windows 11 MSVC (rustc 1.98.1): - cargo test -p victory-gpu --lib raytracing: 3 passed, 0 failed (live DXR 1.1 OPTIONS5 query, BLAS prebuild info sizing, and BLAS/TLAS build/copy pass cleanly) - cargo test -p victory-gpu: 46 passed, 0 failed, 1 ignored - cargo xtask policy: 152 files ok All safety comments present on new unsafe blocks, clean tier query fallback when raytracing is unsupported, and correct descriptor translation for raytracing acceleration structures.
Altorru commented 2026-11-24 11:04:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Altorru on 2026-11-24T10:17:07Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7128568169 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/702#issuecomment-7128568169). Originally posted by [Altorru](https://github.com/Altorru) on 2026-11-24T10:17:07Z. --- 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.
konradbeck commented 2026-11-24 14:05:01 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by konradbeck on 2026-11-24T14:03:55Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7133781772 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/702#issuecomment-7133781772). Originally posted by [konradbeck](https://github.com/konradbeck) on 2026-11-24T14:03:55Z. --- 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.
upstream-sync closed this pull request 2026-11-25 01:04:51 +00:00
Marvisak commented 2026-11-25 01:07:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:27:45Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148534289 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/702#issuecomment-7148534289). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:27:45Z. --- 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

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
Marvisak/VIctory!702
No description provided.