gpu(pipeline,sampler): deduplicate host root signatures and cache OPTIONS19 #158

Closed
github-bot wants to merge 1 commit from gh-pr/158/head into gh-pr/158/base
Owner

@⁠Androtim on GitHub · 2026-11-29 19:28 UTC · original
Androtim:feat/iter156-gpu-root-signature-cache-options19 → main · +1460 −26 · 4 files · 1 commits · closed without merging

Port 815f58ce to deduplicate host ID3D12RootSignature COM objects / blobs and cache D3D12_FEATURE_DATA_D3D12_OPTIONS19 (AnisoFilterWithPointMipSupported) per ID3D12Device:

Changes

  • crates/victory-gpu/src/sampler.rs (aniso_point_mip): Cache OPTIONS19 query results per ID3D12Device (retaining a COM reference so raw pointers cannot suffer ABA reuse across test/live devices).
  • crates/victory-gpu/src/pipeline/host.rs (root_signature): Deduplicate ID3D12RootSignature COM objects and serialized blobs (Arc<[u8]>) across pipelines keyed on (device_raw, flags, params, static_samplers) (VICTORY_ROOT_CACHE=0 to disable), skipping redundant serialization and CreateRootSignature calls while preserving ID3D12PipelineLibrary names.
  • crates/victory-gpu/src/host.rs (HostList::bind_pipeline): Deduplicate shared root-signature COM retention in HostList::deferred.kept.
  • crates/victory-gpu/src/draw.rs: Track #[cfg(test)] root_binds / host_roots() for root-signature rebind tests.

Verification

  • cargo +1.98.1-x86_64-pc-windows-gnu run --locked -p xtask -- policy
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --locked -- pipeline::host::
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --locked -- sampler::
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --locked -- draw::
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --locked -- host::
  • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --locked --all-targets -- -D warnings (default features and --all-features)
**@⁠Androtim** on GitHub · 2026-11-29 19:28 UTC · [original](https://github.com/Androtim/MiniVI/pull/158) `Androtim:feat/iter156-gpu-root-signature-cache-options19` → `main` · +1460 −26 · 4 files · 1 commits · closed without merging Port `815f58ce` to deduplicate host `ID3D12RootSignature` COM objects / blobs and cache `D3D12_FEATURE_DATA_D3D12_OPTIONS19` (`AnisoFilterWithPointMipSupported`) per `ID3D12Device`: ### Changes - **`crates/victory-gpu/src/sampler.rs` (`aniso_point_mip`):** Cache `OPTIONS19` query results per `ID3D12Device` (retaining a COM reference so raw pointers cannot suffer ABA reuse across test/live devices). - **`crates/victory-gpu/src/pipeline/host.rs` (`root_signature`):** Deduplicate `ID3D12RootSignature` COM objects and serialized blobs (`Arc<[u8]>`) across pipelines keyed on `(device_raw, flags, params, static_samplers)` (`VICTORY_ROOT_CACHE=0` to disable), skipping redundant serialization and `CreateRootSignature` calls while preserving `ID3D12PipelineLibrary` names. - **`crates/victory-gpu/src/host.rs` (`HostList::bind_pipeline`):** Deduplicate shared root-signature COM retention in `HostList::deferred.kept`. - **`crates/victory-gpu/src/draw.rs`:** Track `#[cfg(test)] root_binds` / `host_roots()` for root-signature rebind tests. ### Verification - `cargo +1.98.1-x86_64-pc-windows-gnu run --locked -p xtask -- policy` - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --locked -- pipeline::host::` - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --locked -- sampler::` - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --locked -- draw::` - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --locked -- host::` - `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --locked --all-targets -- -D warnings` (default features and `--all-features`)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 20:14:08 +00:00
github-bot closed this pull request 2026-12-01 20:14:08 +00:00
Author
Owner

@⁠Androtim on GitHub · 2026-11-29 20:05 UTC · original · edited 2026-11-30 02:04 UTC

Automated triage for the maintainers (not an approval).

Verdict: needs-gpu-test · CI (check): passing

Summary

Solid, well-tested implementation that deduplicates host ID3D12RootSignature COM objects and serialized blobs across pipelines with identical layouts, avoids redundant root-signature retention in HostList::deferred.kept, and fixes aniso_point_mip to cache D3D12_OPTIONS19 per ID3D12Device.

Code Review

  • crates/victory-gpu/src/pipeline/host.rs (root_sig_key, RootSigKeyBuf, root_signature_in):
    • root_sig_key builds a self-delimiting, bit-exact key over (device_raw, flags, params, static_samplers), using .to_bits() for float sampler fields (MipLODBias, MinLOD, MaxLOD), validating non-null pDescriptorRanges when NumDescriptorRanges > 0, and guarding D3D12_STATIC_SAMPLER_DESC size with a compile-time assert!.
    • RootSigKeyBuf avoids heap allocation on cache hits via a 256-u32 inline buffer and HashMap<Box<[u32]>, CachedRootSig>::get(key.as_slice()).
    • CachedRootSig retains _device: ID3D12Device to prevent raw-pointer ABA reuse across devices, and entry(...).or_insert_with(...) ensures concurrent cold misses converge on a single canonical ID3D12RootSignature and Arc<[u8]> blob while preserving super::library::name keys.
    • VICTORY_ROOT_CACHE=0 cleanly bypasses the cache.
    • Note: The static flag on std::process::Command::new(dxc) is in #[cfg(test)] fn compile_named, matching the existing #[cfg(test)] fn compile helper on main.
  • crates/victory-gpu/src/sampler.rs (aniso_point_mip):
    • Replaces the single-device OnceLock<bool> with a lock-free FIRST fast path plus an OTHERS RwLock<Vec<...>> fallback, retaining HeldDevice(ID3D12Device) per entry to prevent ABA pointer reuse.
  • crates/victory-gpu/src/host.rs (HostList::bind_pipeline):
    • Reuses Deferred::bound to deduplicate shared ID3D12RootSignature pushes into deferred.kept. Because both pso and root remain live in deferred.kept until reset, their COM pointers cannot alias or be reused mid-recording.
  • crates/victory-gpu/src/draw.rs (State):
    • Test-only instrumentation (root_binds, host_roots()) with zero non-test runtime impact.

Verdict

Logic, thread safety, and CI look good. Because this changes D3D12 host root-signature sharing, ID3D12PipelineLibrary reload inputs, and Set*RootSignature elision across PSO switches, a local real-GPU smoke test is recommended before merging.


Generated with Antigravity CLI (agy).

**@⁠Androtim** on GitHub · 2026-11-29 20:05 UTC · [original](https://github.com/Androtim/MiniVI/pull/158#issuecomment-7261792812) · edited 2026-11-30 02:04 UTC <!-- minivi-triage v1 head=1165f34abea1e897ce093d6f657501333f25aca7 verdict=needs-gpu-test ci=passing at=2026-11-30T02:05:27Z --> Automated triage for the maintainers (not an approval). **Verdict:** `needs-gpu-test` · **CI (`check`):** `passing` ### Summary Solid, well-tested implementation that deduplicates host `ID3D12RootSignature` COM objects and serialized blobs across pipelines with identical layouts, avoids redundant root-signature retention in `HostList::deferred.kept`, and fixes `aniso_point_mip` to cache `D3D12_OPTIONS19` per `ID3D12Device`. ### Code Review - **`crates/victory-gpu/src/pipeline/host.rs` (`root_sig_key`, `RootSigKeyBuf`, `root_signature_in`)**: - `root_sig_key` builds a self-delimiting, bit-exact key over `(device_raw, flags, params, static_samplers)`, using `.to_bits()` for float sampler fields (`MipLODBias`, `MinLOD`, `MaxLOD`), validating non-null `pDescriptorRanges` when `NumDescriptorRanges > 0`, and guarding `D3D12_STATIC_SAMPLER_DESC` size with a compile-time `assert!`. - `RootSigKeyBuf` avoids heap allocation on cache hits via a 256-`u32` inline buffer and `HashMap<Box<[u32]>, CachedRootSig>::get(key.as_slice())`. - `CachedRootSig` retains `_device: ID3D12Device` to prevent raw-pointer ABA reuse across devices, and `entry(...).or_insert_with(...)` ensures concurrent cold misses converge on a single canonical `ID3D12RootSignature` and `Arc<[u8]>` blob while preserving `super::library::name` keys. - `VICTORY_ROOT_CACHE=0` cleanly bypasses the cache. - Note: The static flag on `std::process::Command::new(dxc)` is in `#[cfg(test)] fn compile_named`, matching the existing `#[cfg(test)] fn compile` helper on `main`. - **`crates/victory-gpu/src/sampler.rs` (`aniso_point_mip`)**: - Replaces the single-device `OnceLock<bool>` with a lock-free `FIRST` fast path plus an `OTHERS` `RwLock<Vec<...>>` fallback, retaining `HeldDevice(ID3D12Device)` per entry to prevent ABA pointer reuse. - **`crates/victory-gpu/src/host.rs` (`HostList::bind_pipeline`)**: - Reuses `Deferred::bound` to deduplicate shared `ID3D12RootSignature` pushes into `deferred.kept`. Because both `pso` and `root` remain live in `deferred.kept` until reset, their COM pointers cannot alias or be reused mid-recording. - **`crates/victory-gpu/src/draw.rs` (`State`)**: - Test-only instrumentation (`root_binds`, `host_roots()`) with zero non-test runtime impact. ### Verdict Logic, thread safety, and CI look good. Because this changes D3D12 host root-signature sharing, `ID3D12PipelineLibrary` reload inputs, and `Set*RootSignature` elision across PSO switches, a local real-GPU smoke test is recommended before merging. --- _Generated with Antigravity CLI (`agy`)._
Author
Owner

@⁠Androtim on GitHub · 2026-11-29 21:28 UTC · original

Now conflicts with updated main after the Wave 5 GPU merges. Please rebase onto latest main.

**@⁠Androtim** on GitHub · 2026-11-29 21:28 UTC · [original](https://github.com/Androtim/MiniVI/pull/158#issuecomment-7262899103) Now conflicts with updated `main` after the Wave 5 GPU merges. Please rebase onto latest `main`.
Author
Owner

@⁠Androtim on GitHub · 2026-11-30 09:17 UTC · original

Now that #173 merged onto main, crates/victory-gpu/src/pipeline/host.rs:1813 needs code_table initialized on HostShader. Please rebase onto latest main.

**@⁠Androtim** on GitHub · 2026-11-30 09:17 UTC · [original](https://github.com/Androtim/MiniVI/pull/158#issuecomment-7273991335) Now that `#173` merged onto `main`, `crates/victory-gpu/src/pipeline/host.rs:1813` needs `code_table` initialized on `HostShader`. Please rebase onto latest `main`.
Author
Owner

@⁠Androtim on GitHub · 2026-12-01 01:38 UTC · original

Closing stale/conflicted backlog PR per #276. Superseded by the active root-architecture replacement pillars with isolated plain --release A/B verification.

**@⁠Androtim** on GitHub · 2026-12-01 01:38 UTC · [original](https://github.com/Androtim/MiniVI/pull/158#issuecomment-7297730415) Closing stale/conflicted backlog PR per #276. Superseded by the active root-architecture replacement pillars with isolated plain --release A/B verification.

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/Androtim--MiniVI!158
No description provided.