Skip to content

GPU: disable implicit stream depth test without a DSV format - #2952

Open
fuzeofficlal wants to merge 1 commit into
Marvisak:mainfrom
fuzeofficlal:fix/gpu-stream-omitted-depth-default
Open

fuzeofficlal wants to merge 1 commit into
Marvisak:mainfrom
fuzeofficlal:fix/gpu-stream-omitted-depth-default

Conversation

@fuzeofficlal

Copy link
Copy Markdown
Contributor

Summary

When a D3D12_PIPELINE_STATE_STREAM_DESC omits both depth-stencil subobjects (DEPTH_STENCIL kind 11 and DEPTH_STENCIL1 kind 21), D3D12's stream parser defaults DepthEnable to TRUE only when a DSVFormat is present (!= DXGI_FORMAT_UNKNOWN) and to FALSE when DSVFormat == DXGI_FORMAT_UNKNOWN.

Previously GraphicsState::default() left DepthEnable = TRUE unconditionally, so HostPipeline::new emitted an explicit depth-stencil state with DepthEnable = TRUE even for color-only pipeline streams that omitted depth-stencil state and had DXGI_FORMAT_UNKNOWN. On host D3D12 (for example, color-only streams using ForcedSampleCount > 0), CreateGraphicsPipelineState / CreatePipelineState refuses that explicit DepthEnable = TRUE state with E_INVALIDARG (0x80070057), causing draws using the pipeline to be dropped.

Changes

  • Track whether a stream supplied a depth-stencil subobject (kind 11 | 21) in read_stream (crates/victory-gpu/src/pipeline.rs) and call GraphicsState::apply_stream_defaults(has_depth_stencil) once all subobjects are parsed (so subobject order relative to DSVFormat kind 16 does not matter, and both runtime create_stream and offline Prebuild stay identical).
  • In GraphicsState::apply_stream_defaults (crates/victory-gpu/src/pipeline/host.rs), set DepthEnable = FALSE when !has_depth_stencil && self.depth_format == DXGI_FORMAT_UNKNOWN.
  • Add unit tests covering omitted depth-stencil with DXGI_FORMAT_UNKNOWN vs DXGI_FORMAT_D32_FLOAT, explicit kind 11/21 overrides, and live D3D12 host PSO creation for a color-only stream with ForcedSampleCount = 1.

Testing (Windows 11, Rust 1.98.1)

  • cargo test --locked -p victory-gpu --lib -- pipeline:: (RTX 5090, VICTORY_D3D12_DEBUG=1): 26/26 passed
  • cargo test --locked -p victory-gpu --features diagnostics --lib -- pipeline:: (RTX 5090, VICTORY_D3D12_DEBUG=1): 29/29 passed
  • cargo test --locked -p victory-gpu --features diagnostics --lib -- pipeline:: (WARP, VICTORY_D3D12_WARP=1, VICTORY_D3D12_DEBUG=1): 29/29 passed
  • cargo clippy --locked -p victory-gpu --tests -- -D warnings (default and --features diagnostics): 0 warnings
  • cargo xtask policy: 191 files ok

@oni-swr

oni-swr commented Nov 26, 2026

Copy link
Copy Markdown

Independent test report for 2cdb5e396f24b8cdf1baf27b3f24a8b29cfae404, with the exact parent 63bcca43c6a00a758510398fa43096ce7e4f7df0 as the control. Claim: #1633.

Setup: Windows 11 Pro 10.0.26200, Rust 1.98.1. Built with --features diagnostics and VICTORY_D3D12_WARP=1. A probe confirmed that the device the pipelines were made on is Microsoft Basic Render Driver (vendor 0x1414, device 0x8c, DXGI_ADAPTER_FLAG_SOFTWARE, no dedicated memory). Nothing ran on a physical GPU. All inputs were synthetic: FXC-compiled trivial VS/PS and hand-built streams. No game files were used.

PR tests: cargo test -j 4 --locked -p victory-gpu --features diagnostics --lib -- pipeline:: --test-threads=1

  • Head: 30/30 passed. The 3 new tests and my local probe pass.
  • Parent with only the PR's test hunk applied: 28 passed, 2 failed.
    • omitted_stream_depth_defaults_to_dsv_format fails because DepthEnable is true without a DSV format.
    • omitted_stream_depth_builds_forced_sample_count_pipeline fails because WARP refuses the PSO.
    • explicit_stream_depth_overrides_dsv_default passes on both revisions.

Live WARP matrix (local, uncommitted probe): RTV R8G8B8A8, HostPipeline::new. Each cell is DepthEnable / PSO built.

Stream Parent Head
no DSS, no DSV subobject, ForcedSampleCount=1 true / no false / yes
no DSS, DSV=UNKNOWN, FSC=1 true / no false / yes
no DSS, no DSV subobject, FSC=0 (plain color-only) true / yes false / yes
no DSS, DSV=UNKNOWN, FSC=0 true / yes false / yes
no DSS, DSV=D32_FLOAT, FSC=0 true / yes true / yes
no DSS, DSV=D24S8, FSC=0 true / yes true / yes
DSS (11) off, DSV=UNKNOWN, FSC=1 false / yes false / yes
DSS1 (21) off, DSV=UNKNOWN, FSC=1 false / yes false / yes
DSS (11) on, DSV=UNKNOWN, FSC=1 true / no true / no
DSS (11) on, DSV=D32, FSC=0 true / yes true / yes
DSV=D32 before DSS1 (21) off false / yes false / yes
DSV=UNKNOWN before DSS1 (21) on true / yes true / yes

The change only affects streams with no depth-stencil subobject and no DSV format. A depth-stencil subobject is still honored when explicitly present, in either order relative to the DSV format. That includes an explicit DepthEnable=TRUE with FSC=1, which WARP refuses on both revisions. A DSV format with no depth-stencil subobject still enables depth. The plain color-only pipeline builds on both revisions.

Broader checks at head:

  • cargo test -j 4 --locked -p victory-gpu --features diagnostics --lib: 249 passed, 0 failed, 1 ignored.
  • cargo clippy -j 4 --locked -p victory-gpu --features diagnostics --tests -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Limits:

This is an independent test only, not a review. Prepared with Claude Code (Claude Opus 5.5).

@Dukestar69 Dukestar69 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP):

  • cargo test -p victory-gpu --lib pipeline::: 26 passed, 0 failed (RTX 5090 hardware, including all 3 new tests: omitted_stream_depth_defaults_to_dsv_format, explicit_stream_depth_overrides_dsv_default, and omitted_stream_depth_builds_forced_sample_count_pipeline).
  • VICTORY_WARP=1 cargo test -p victory-gpu --lib pipeline::host::tests: 7 passed, 0 failed.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Defaulting DepthEnable to false when a pipeline stream omits both a depth-stencil subobject (11 | 21) and a DSV format (DXGI_FORMAT_UNKNOWN) matches D3D12 stream defaults and unblocks ForcedSampleCount > 0 pipelines cleanly.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

alesanfe added a commit to alesanfe/VIctory that referenced this pull request Nov 26, 2026
… UAV writeback

- Marvisak#2952: a stream with neither a depth-stencil subobject nor a depth
  format defaults to disabled depth testing (apply_stream_defaults)
- Marvisak#2931: feature-level query rejects count == 0 and writes 0 on UNSUPPORTED
- Marvisak#2961: reject shader-visible RTV and DSV heap creation
- Marvisak#2865: guard placed heaps against null and layouts against empty planes
- Marvisak#2954: lower v_bfe_u32/v_bfe_i32 to one Ubfe/Ibfe
- Marvisak#2948: a root UAV a shader only reads is not written back
  (written_root_uavs through Shader/Lowered/HostShader + cache VSH2)

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

@kotekompotek kotekompotek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified: a pipeline-state stream without a DEPTH_STENCIL subobject left DepthEnable at the default true, which fails CreateGraphicsPipelineState when no DSV format is present — the ForcedSampleCount test hits exactly that. The fix preserves D3D12 stream semantics: explicit depth subobject still wins (kind 11/21 for DESC/DESC1), a DSV format alone keeps DepthEnable=true.

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Merge candidate. read_stream in victory-gpu/src/pipeline.rs now records whether a stream has a depth-stencil subobject (kind 11 or 21, the only two GraphicsState::read handles). After parsing, GraphicsState::apply_stream_defaults in pipeline/host.rs turns depth testing off when a stream has neither that subobject nor a DSV format. As far as I know, this is also how the public d3dx12 stream parse helper (DirectX-Headers) sets up a stream's default depth-stencil state. It runs after parsing, so subobject order does not matter, and the runtime and prebuild paths share it. The tests cover both defaults, an explicit 11/21 overriding them in either order, and a live PSO build with ForcedSampleCount = 1 (the case the host refused before). An independent WARP run in the comments shows the same before/after matrix.

CI: passing. Recommending a look, not approving.


Generated by Claude Code

github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants