GPU: forward pipeline view instancing (subobject 22) to the host #3060

Closed
fuzeofficlal wants to merge 1 commit from upstream-pr/3062 into main
fuzeofficlal commented 2026-11-26 05:52:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T05:52:06Z.


Summary

Forwards D3D12 pipeline stream subobject 22 (D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VIEW_INSTANCING) to host graphics and mesh pipelines instead of silently dropping it.

Details

  • Subobject parsing (crates/victory-gpu/src/pipeline.rs, crates/victory-gpu/src/pipeline/host.rs):
    • Parses stream subobject 22 (D3D12_VIEW_INSTANCING_DESC, 32 bytes: ViewInstanceCount + 4-byte padding + pViewInstanceLocations + Flags, clamped to D3D12_MAX_VIEW_INSTANCE_COUNT = 4 locations) in GraphicsState::read.
    • Records view_instancing in GraphicsState::describe() so host pipeline library cache keys distinguish view-instanced pipelines from plain ones.
  • Host capability query (crates/victory-gpu/src/host.rs):
    • Queries D3D12_FEATURE_D3D12_OPTIONS3::ViewInstancingTier != D3D12_VIEW_INSTANCING_TIER_NOT_SUPPORTED and records DXGI_ADAPTER_FLAG_SOFTWARE at device creation.
  • Host stream PSO creation & WARP isolation (crates/victory-gpu/src/pipeline/host.rs, crates/victory-gpu/src/draw.rs):
    • Generalizes stream_pipeline with an optional trailing subobject so vertex and mesh pipelines can include DEPTH_STENCIL1 (depth bounds), VIEW_INSTANCING, or both.
    • Emits a one-time warning and drops the subobject on hosts that report D3D12_VIEW_INSTANCING_TIER_NOT_SUPPORTED.
    • Strips D3D12_VIEW_INSTANCING_FLAG_ENABLE_VIEW_INSTANCE_MASKING with a one-time warning because D3D12 defaults the view instance mask to 0 (all views disabled) when masking is enabled and SetViewInstanceMask is not yet wired.
    • On software adapters (WARP) with view instancing support, attaches an explicit masked 1-view (0, 0) D3D12_VIEW_INSTANCING_DESC to SM 6.x (PSV0) plain graphics pipelines and pairs graphics pipeline binds with ID3D12GraphicsCommandList1::SetViewInstanceMask (1 for plain, 0xF for view-instanced), working around a WARP (d3d10warp.dll) state leak where a previous multi-view PSO's view-instancing configuration bleeds into subsequent plain PSO draws across command lists (including older WARP builds such as Windows Server 2022 where an unmasked 1-view subobject alone still leaks). Hardware GPUs and legacy SM 5.1 test shaders are untouched.
  • Tests (crates/victory-gpu/src/pipeline/view_instancing_test.rs):
    • Stream parsing + cache key differentiation (view_instancing_changes_the_stream_state).
    • End-to-end title draw readbacks using real SM 6.6 DXIL emitted by victory-shader:
      • Multi-viewport routing, plain-PSO draw after multi-view PSO (regression test for WARP state leak), and ENABLE_VIEW_INSTANCE_MASKING fallback (view_instancing_routes_one_title_draw_to_multiple_viewports).
      • Multi-slice Texture2DArray routing (view_instancing_routes_one_title_draw_to_multiple_array_slices).
      • Combined depth bounds (subobject 14) + view instancing (subobject 22) (view_instancing_combines_with_depth_bounds).

Verification

  • cargo test -p victory-gpu --locked pipeline:: on NVIDIA GeForce RTX 5090 (27/27 passed, VICTORY_D3D12_DEBUG=1).
  • cargo test -p victory-gpu --locked --features diagnostics pipeline:: on Microsoft Basic Render Driver / WARP (VICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1, 30/30 passed).
  • cargo clippy -p victory-gpu --locked --all-targets -- -D warnings (default and --features diagnostics) — clean.
  • cargo test -p xtask --locked policy::tests::repository_passes_policy — passed.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6620473285 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3062). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T05:52:06Z. --- ### Summary Forwards D3D12 pipeline stream subobject `22` (`D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VIEW_INSTANCING`) to host graphics and mesh pipelines instead of silently dropping it. ### Details - **Subobject parsing (`crates/victory-gpu/src/pipeline.rs`, `crates/victory-gpu/src/pipeline/host.rs`)**: - Parses stream subobject `22` (`D3D12_VIEW_INSTANCING_DESC`, 32 bytes: `ViewInstanceCount` + 4-byte padding + `pViewInstanceLocations` + `Flags`, clamped to `D3D12_MAX_VIEW_INSTANCE_COUNT = 4` locations) in `GraphicsState::read`. - Records `view_instancing` in `GraphicsState::describe()` so host pipeline library cache keys distinguish view-instanced pipelines from plain ones. - **Host capability query (`crates/victory-gpu/src/host.rs`)**: - Queries `D3D12_FEATURE_D3D12_OPTIONS3::ViewInstancingTier != D3D12_VIEW_INSTANCING_TIER_NOT_SUPPORTED` and records `DXGI_ADAPTER_FLAG_SOFTWARE` at device creation. - **Host stream PSO creation & WARP isolation (`crates/victory-gpu/src/pipeline/host.rs`, `crates/victory-gpu/src/draw.rs`)**: - Generalizes `stream_pipeline` with an optional trailing subobject so vertex and mesh pipelines can include `DEPTH_STENCIL1` (depth bounds), `VIEW_INSTANCING`, or both. - Emits a one-time warning and drops the subobject on hosts that report `D3D12_VIEW_INSTANCING_TIER_NOT_SUPPORTED`. - Strips `D3D12_VIEW_INSTANCING_FLAG_ENABLE_VIEW_INSTANCE_MASKING` with a one-time warning because D3D12 defaults the view instance mask to `0` (all views disabled) when masking is enabled and `SetViewInstanceMask` is not yet wired. - On software adapters (WARP) with view instancing support, attaches an explicit masked 1-view `(0, 0)` `D3D12_VIEW_INSTANCING_DESC` to SM 6.x (`PSV0`) plain graphics pipelines and pairs graphics pipeline binds with `ID3D12GraphicsCommandList1::SetViewInstanceMask` (`1` for plain, `0xF` for view-instanced), working around a WARP (`d3d10warp.dll`) state leak where a previous multi-view PSO's view-instancing configuration bleeds into subsequent plain PSO draws across command lists (including older WARP builds such as Windows Server 2022 where an unmasked 1-view subobject alone still leaks). Hardware GPUs and legacy SM 5.1 test shaders are untouched. - **Tests (`crates/victory-gpu/src/pipeline/view_instancing_test.rs`)**: - Stream parsing + cache key differentiation (`view_instancing_changes_the_stream_state`). - End-to-end title draw readbacks using real SM 6.6 DXIL emitted by `victory-shader`: - Multi-viewport routing, plain-PSO draw after multi-view PSO (regression test for WARP state leak), and `ENABLE_VIEW_INSTANCE_MASKING` fallback (`view_instancing_routes_one_title_draw_to_multiple_viewports`). - Multi-slice `Texture2DArray` routing (`view_instancing_routes_one_title_draw_to_multiple_array_slices`). - Combined depth bounds (`subobject 14`) + view instancing (`subobject 22`) (`view_instancing_combines_with_depth_bounds`). ### Verification - `cargo test -p victory-gpu --locked pipeline::` on NVIDIA GeForce RTX 5090 (27/27 passed, `VICTORY_D3D12_DEBUG=1`). - `cargo test -p victory-gpu --locked --features diagnostics pipeline::` on Microsoft Basic Render Driver / WARP (`VICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1`, 30/30 passed). - `cargo clippy -p victory-gpu --locked --all-targets -- -D warnings` (default and `--features diagnostics`) — clean. - `cargo test -p xtask --locked policy::tests::repository_passes_policy` — passed.
upstream-sync closed this pull request 2026-11-26 07:01:32 +00:00
kotekompotek commented 2026-11-26 07:01:32 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T06:06:12Z.

Review: APPROVED


Verified: the console subobject-22 read uses the PC layout like depth_stencil1; locations are copied into owned storage (the title pointer would dangle), count/null/D3D12_MAX_VIEW_INSTANCE_COUNT validated, and ENABLE_VIEW_INSTANCE_MASKING is stripped — right, since the default mask is 0 and would discard every draw until SetViewInstanceMask is wired. The stream dispatch covers all four combinations with V=() adding zero bytes. The WARP reset is the clever-but-correct part: WARP latches instancing across PSO switches, so a cached anonymous 1-view (0,0) PSO bound before any non-instanced graphics pipeline returns it to view 0; bind_pipeline is correctly inside take_rebind and leaves compute binds alone. The test asserts key changes per locations/flags and count==0 restore.

<!-- greyfinch-sync:Marvisak/VIctory:review:6069286020 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3062#pullrequestreview-6069286020). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-26T06:06:12Z. **Review:** APPROVED --- Verified: the console subobject-22 read uses the PC layout like depth_stencil1; locations are copied into owned storage (the title pointer would dangle), count/null/D3D12_MAX_VIEW_INSTANCE_COUNT validated, and ENABLE_VIEW_INSTANCE_MASKING is stripped — right, since the default mask is 0 and would discard every draw until SetViewInstanceMask is wired. The stream dispatch covers all four combinations with V=() adding zero bytes. The WARP reset is the clever-but-correct part: WARP latches instancing across PSO switches, so a cached anonymous 1-view (0,0) PSO bound before any non-instanced graphics pipeline returns it to view 0; bind_pipeline is correctly inside take_rebind and leaves compute binds alone. The test asserts key changes per locations/flags and count==0 restore.
Marvisak commented 2026-11-26 07:01:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T06:17:18Z.


Automated triage for the maintainers.

Needs work. The plumbing is careful: the subobject is parsed in GraphicsState::read, kept out of the pipeline key when inactive, and the masking flag is cleared because no SetViewInstanceMask slot exists yet. But this changes GPU state handling without evidence for the two things it depends on:

  1. That the title uses subobject 22, and its console layout. GraphicsState::read (crates/victory-gpu/src/pipeline/host.rs, arm 22) reads it with the PC D3D12_VIEW_INSTANCING_DESC layout, and the description says the console layout "still needs title-side verification". Please add evidence: the title's own pipeline streams, or a trace showing a non-zero ViewInstanceCount. Without it, this adds unused code paths, and the title's location pointer is dereferenced on a layout nobody has checked.
  2. The WARP workaround in the production bind path. bind_pipeline (draw.rs) binds an extra WARP_VIEW_RESET PSO before every plain graphics pipeline on software adapters. That PSO is built once from the first view-instancing pipeline's root signature and shaders, and is then set on lists using unrelated root signatures. It works around a WARP behaviour, not anything the title does. It would fit better in the tests, or behind a specific, documented WARP bug, than in draw.rs.

Also: the new view_instancing_test.rs is 910 lines for a feature the title has not been shown to use. A smaller test of stream parsing and keys would do until (1) is settled.

CI: check was still running when this was written.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7184280473 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3062#issuecomment-7184280473). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T06:17:18Z. --- <!-- victory-triage v1 head=491683abcca34dacc49c2631eb2586af781a10fa verdict=needs-work at=2026-11-26T06:18:50Z --> Automated triage for the maintainers. **Needs work.** The plumbing is careful: the subobject is parsed in `GraphicsState::read`, kept out of the pipeline key when inactive, and the masking flag is cleared because no `SetViewInstanceMask` slot exists yet. But this changes GPU state handling without evidence for the two things it depends on: 1. **That the title uses subobject 22, and its console layout.** `GraphicsState::read` (`crates/victory-gpu/src/pipeline/host.rs`, arm `22`) reads it with the PC `D3D12_VIEW_INSTANCING_DESC` layout, and the description says the console layout "still needs title-side verification". Please add evidence: the title's own pipeline streams, or a trace showing a non-zero `ViewInstanceCount`. Without it, this adds unused code paths, and the title's location pointer is dereferenced on a layout nobody has checked. 2. **The WARP workaround in the production bind path.** `bind_pipeline` (`draw.rs`) binds an extra `WARP_VIEW_RESET` PSO before every plain graphics pipeline on software adapters. That PSO is built once from the first view-instancing pipeline's root signature and shaders, and is then set on lists using unrelated root signatures. It works around a WARP behaviour, not anything the title does. It would fit better in the tests, or behind a specific, documented WARP bug, than in `draw.rs`. Also: the new `view_instancing_test.rs` is 910 lines for a feature the title has not been shown to use. A smaller test of stream parsing and keys would do until (1) is settled. CI: `check` was still running when this was written. --- _Generated by [Claude Code](https://claude.ai/code)_
fuzeofficlal commented 2026-11-26 07:01:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T06:28:41Z.


Agreed with the triage review — closing this for now:

  1. We do not yet have a title pipeline-stream trace confirming that subobject 22 is emitted with non-zero ViewInstanceCount or confirming its exact console struct layout before dereferencing pViewInstanceLocations.
  2. Supporting it on CI (windows-latest / Server 2022 d3d10warp.dll) also exposed a WARP driver state-leak quirk across plain PSOs that should not push workarounds into the production bind path.

Happy to revisit with a smaller, verified patch if a title trace later confirms subobject 22 usage and layout.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7184467498 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3062#issuecomment-7184467498). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T06:28:41Z. --- Agreed with the triage review — closing this for now: 1. We do not yet have a title pipeline-stream trace confirming that subobject `22` is emitted with non-zero `ViewInstanceCount` or confirming its exact console struct layout before dereferencing `pViewInstanceLocations`. 2. Supporting it on CI (`windows-latest` / Server 2022 `d3d10warp.dll`) also exposed a WARP driver state-leak quirk across plain PSOs that should not push workarounds into the production bind path. Happy to revisit with a smaller, verified patch if a title trace later confirms subobject `22` usage and layout.

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!3060
No description provided.