GPU: deduplicate host ID3D12RootSignatures and cache OPTIONS19 #891

Closed
github-bot wants to merge 0 commits from github-bot/gh-891 into main AGit
Owner

@⁠Starchaser1024 on GitHub · 2026-11-28 08:38 UTC · original
Starchaser1024:perf/deduplicate-root-signatures → main · +1463 −26 · 4 files · 1 commits · closed without merging

Summary

Deduplicates ID3D12RootSignature COM objects and serialized root-signature blobs across HostPipelines, caches D3D12_FEATURE_D3D12_OPTIONS19 (AnisoFilterWithPointMipSupported) per device, and deduplicates shared root-signature retention in HostList::bind_pipeline.

Cause

  1. HostPipeline::new (crates/victory-gpu/src/pipeline/host.rs) queried CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS19), called D3D12SerializeVersionedRootSignature, and called device.CreateRootSignature unconditionally for every graphics, mesh, and compute PSO (~2,700–88,600 PSOs sharing a small set of unique root layouts).
  2. In victory warm (known::make), where each HostPipeline is dropped immediately after compilation, D3D12Core.dll cannot reuse live ID3D12RootSignature handles across PSOs, destroying and recreating driver root signatures on every PSO.
  3. During recording, distinct ID3D12RootSignature pointers defeated State::host_roots (draw.rs:1932-1943) on PSO switches and pushed duplicate ID3D12RootSignature COM clones into HostList::deferred.kept (HostList::bind_pipeline).

Changes

  • pipeline::samplers::aniso_point_mip (crates/victory-gpu/src/pipeline/samplers.rs): expose a device-safe OPTIONS19 cache (OnceLock fast path for the primary Host device + RwLock<Vec<...>> fallback retaining a ID3D12Device COM reference so raw device pointers cannot suffer ABA reuse across standalone/WARP test devices) and reuse it in HostPipeline::new.
  • pipeline::host::root_signature (crates/victory-gpu/src/pipeline/host.rs): cache (ID3D12RootSignature, Arc<[u8]>) in ROOT_SIGNATURES (VICTORY_ROOT_CACHE, default 1, =0 bypasses) using a stack-inline RootSigKeyBuf ([u32; 256] inline + spill) encoding (device_raw, flags, params, static_samplers) losslessly (bit-exact f32::to_bits on LOD fields), skipping both D3D12SerializeVersionedRootSignature and CreateRootSignature on hits while preserving byte-identical ID3D12PipelineLibrary names.
  • HostList::bind_pipeline (crates/victory-gpu/src/host.rs): deduplicate root.as_raw() as usize in deferred.bound before cloning into deferred.kept.

Benchmark & Verification (RTX 5060 Ti 16 GB, Windows 11, --release)

pipeline::host::tests::benchmark_500_host_pipeline_root_signatures (500 PSOs across 25 realistic root layouts, 9 rounds):

Mode Median (500 PSOs) Speedup
VICTORY_ROOT_CACHE=0 (victory warm drop-each mode) 2.200 ms baseline
VICTORY_ROOT_CACHE=0 (live keep-alive mode) 0.927 ms 2.37x
VICTORY_ROOT_CACHE=1 (cold batch: 25 misses + 475 hits) 0.171 ms 12.8x vs victory warm (5.41x vs keep-alive)
VICTORY_ROOT_CACHE=1 (warm batch: 500 hits) 0.066 ms 33.6x vs victory warm (14.2x vs keep-alive)
  • pipeline::host::tests::shared_root_signatures_load_from_library_and_execute_across_pso_switches: verified under VICTORY_D3D12_DEBUG=1 (0 ID3D12InfoQueue messages, ID3D12PipelineLibrary store + reload, SetComputeRootSignature and SetGraphicsRootSignature called 1 time instead of 3 across pso1 -> pso2 -> pso1, exact GPU UAV and RTV readback).
  • cargo test -p victory-gpu --locked: 457 passed, 0 failed.
  • cargo clippy --workspace --all-targets --all-features --locked: 0 warnings in changed files.
  • cargo xtask policy: 294 files ok.
**@⁠Starchaser1024** on GitHub · 2026-11-28 08:38 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/891) `Starchaser1024:perf/deduplicate-root-signatures` → `main` · +1463 −26 · 4 files · 1 commits · closed without merging ## Summary Deduplicates `ID3D12RootSignature` COM objects and serialized root-signature blobs across `HostPipeline`s, caches `D3D12_FEATURE_D3D12_OPTIONS19` (`AnisoFilterWithPointMipSupported`) per device, and deduplicates shared root-signature retention in `HostList::bind_pipeline`. ### Cause 1. `HostPipeline::new` (`crates/victory-gpu/src/pipeline/host.rs`) queried `CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS19)`, called `D3D12SerializeVersionedRootSignature`, and called `device.CreateRootSignature` unconditionally for every graphics, mesh, and compute PSO (~2,700–88,600 PSOs sharing a small set of unique root layouts). 2. In `victory warm` (`known::make`), where each `HostPipeline` is dropped immediately after compilation, `D3D12Core.dll` cannot reuse live `ID3D12RootSignature` handles across PSOs, destroying and recreating driver root signatures on every PSO. 3. During recording, distinct `ID3D12RootSignature` pointers defeated `State::host_roots` (`draw.rs:1932-1943`) on PSO switches and pushed duplicate `ID3D12RootSignature` COM clones into `HostList::deferred.kept` (`HostList::bind_pipeline`). ### Changes - **`pipeline::samplers::aniso_point_mip` (`crates/victory-gpu/src/pipeline/samplers.rs`)**: expose a device-safe `OPTIONS19` cache (`OnceLock` fast path for the primary `Host` device + `RwLock<Vec<...>>` fallback retaining a `ID3D12Device` COM reference so raw device pointers cannot suffer ABA reuse across standalone/WARP test devices) and reuse it in `HostPipeline::new`. - **`pipeline::host::root_signature` (`crates/victory-gpu/src/pipeline/host.rs`)**: cache `(ID3D12RootSignature, Arc<[u8]>)` in `ROOT_SIGNATURES` (`VICTORY_ROOT_CACHE`, default `1`, `=0` bypasses) using a stack-inline `RootSigKeyBuf` (`[u32; 256]` inline + spill) encoding `(device_raw, flags, params, static_samplers)` losslessly (bit-exact `f32::to_bits` on LOD fields), skipping both `D3D12SerializeVersionedRootSignature` and `CreateRootSignature` on hits while preserving byte-identical `ID3D12PipelineLibrary` names. - **`HostList::bind_pipeline` (`crates/victory-gpu/src/host.rs`)**: deduplicate `root.as_raw() as usize` in `deferred.bound` before cloning into `deferred.kept`. ## Benchmark & Verification (RTX 5060 Ti 16 GB, Windows 11, `--release`) `pipeline::host::tests::benchmark_500_host_pipeline_root_signatures` (500 PSOs across 25 realistic root layouts, 9 rounds): | Mode | Median (500 PSOs) | Speedup | | :--- | ---: | ---: | | `VICTORY_ROOT_CACHE=0` (`victory warm` drop-each mode) | **2.200 ms** | baseline | | `VICTORY_ROOT_CACHE=0` (live keep-alive mode) | **0.927 ms** | `2.37x` | | `VICTORY_ROOT_CACHE=1` (cold batch: 25 misses + 475 hits) | **0.171 ms** | **12.8x** vs `victory warm` (`5.41x` vs keep-alive) | | `VICTORY_ROOT_CACHE=1` (warm batch: 500 hits) | **0.066 ms** | **33.6x** vs `victory warm` (`14.2x` vs keep-alive) | - `pipeline::host::tests::shared_root_signatures_load_from_library_and_execute_across_pso_switches`: verified under `VICTORY_D3D12_DEBUG=1` (`0` `ID3D12InfoQueue` messages, `ID3D12PipelineLibrary` store + reload, `SetComputeRootSignature` and `SetGraphicsRootSignature` called **1 time** instead of 3 across `pso1 -> pso2 -> pso1`, exact GPU UAV and RTV readback). - `cargo test -p victory-gpu --locked`: 457 passed, 0 failed. - `cargo clippy --workspace --all-targets --all-features --locked`: 0 warnings in changed files. - `cargo xtask policy`: 294 files ok.
- Cache `D3D12_FEATURE_D3D12_OPTIONS19` (`AnisoFilterWithPointMipSupported`) per `ID3D12Device` in `pipeline::samplers::aniso_point_mip` (retaining a COM reference per cached device so raw pointers cannot suffer ABA reuse across standalone/WARP test devices) and reuse it in `HostPipeline::new`.
- Deduplicate `ID3D12RootSignature` COM objects and serialized blobs (`Arc<[u8]>`) across `HostPipeline`s in `pipeline::host::root_signature` (`VICTORY_ROOT_CACHE=0` to disable), using a stack-inline, lossless `(device_raw, flags, params, static_samplers)` key to skip both `D3D12SerializeVersionedRootSignature` and `CreateRootSignature` on cache hits while preserving byte-identical `ID3D12PipelineLibrary` names.
- Deduplicate shared `ID3D12RootSignature` retention in `HostList::bind_pipeline` so binding multiple PSOs that share a root signature does not push duplicate COM references into `HostList::deferred.kept`.
- Add unit and RTX 5060 Ti hardware tests verifying layout/device key exactness, `ID3D12PipelineLibrary` store + reload, consecutive `pso1 -> pso2 -> pso1` compute dispatches and graphics draws with `Set*RootSignature` skipped, D3D12 InfoQueue cleanliness, and a 500-PSO A/B benchmark.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 14:29:41 +00:00
github-bot changed title from GPU: deduplicate host ID3D12RootSignatures and cache OPTIONS19 to [pr-performance][rendering][NVIDIA] GPU: deduplicate host ID3D12RootSignatures and cache OPTIONS19 2026-11-29 01:55:16 +00:00
github-bot force-pushed github-bot/gh-891 from a641a14d95 to 815f58ced5 2026-11-29 02:17:31 +00:00 Compare
github-bot changed title from [pr-performance][rendering][NVIDIA] GPU: deduplicate host ID3D12RootSignatures and cache OPTIONS19 to GPU: deduplicate host ID3D12RootSignatures and cache OPTIONS19 2026-11-29 02:28:37 +00:00
github-bot closed this pull request 2026-11-29 07:48:22 +00:00

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/trustno1-coder--VIctory-NVIDIA!891
No description provided.