GPU: match host graphics pipelines to bound RTV formats #3109

Open
github-bot wants to merge 1 commit from github-bot/gh-3109 into main AGit
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 08:23 UTC · original
fuzeofficlal:fix/gpu-rtv-format-pipeline-variants → main · +952 −34 · 6 files · 1 commits · open

Summary

When a title draws with a graphics pipeline whose declared RTFormats differ from the render target views currently bound via OMSetRenderTargets (for example, R10G10B10A2_UNORM declared in the pipeline stream against a bound R11G11B10_FLOAT or typeless R8G8B8A8_UNORM_SRGB target), D3D12 raises debug-layer error 613 (D3D12_MESSAGE_ID_RENDER_TARGET_FORMAT_MISMATCH_PIPELINE_STATE) and leaves host render-target output conversion mismatched.

This change tracks the host DXGI formats of the bound render targets and lazily builds and caches matching host graphics pipeline variants per title pipeline when any declared non-UNKNOWN target slot differs from the bound format.

Changes

  • crates/victory-gpu/src/draw.rs: track bound host RTV DXGI formats in State::set_targets (from the RTV desc format or resource desc fallback) and resolve graphics/mesh draws through pipeline::host_pipeline_for (and diagnostics through note_drop_for).
  • crates/victory-gpu/src/pipeline/host.rs: add GraphicsState::targets_for (overriding only declared non-UNKNOWN slots that differ from bound non-UNKNOWN formats, returning None when already matching) and GraphicsState::with_targets (cloning input semantic names and re-pointing SemanticName pointers).
  • crates/victory-gpu/src/pipeline/make.rs: add Pending::variant sharing translated shaders, inheriting skipped_shader and host_blend integer-target handling, storing variants in the pipeline library, and keeping draw-time variants out of the early-start list (record_early: false); return Option<Arc<HostPipeline>> from ready.
  • crates/victory-gpu/src/pipeline.rs: add per-Pipeline lazy variant cache (Mutex<Vec<(TargetFormatsKey, Arc<make::Pending>)>>), keeping matching draws on the lock-free base path.
  • crates/victory-gpu/src/pipeline/rtv_format_test.rs & unit tests: end-to-end D3D12 draw + pixel readback + D3D12 debug-layer zero-Error-613 tests covering R10G10B10A2_UNORM -> R11G11B10_FLOAT and multi-RT typeless R8G8B8A8_UNORM_SRGB, plus unit tests for targets_for, with_targets (including integer-target blend disabling), and Pending::variant.

Testing

  • cargo test -p victory-gpu --locked pipeline:: (RTX 5090 hardware & VICTORY_D3D12_WARP=1): 48 passed, 0 failed.
  • VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --locked --features diagnostics pipeline:: (RTX 5090 hardware & WARP): 51 passed, 0 failed, zero D3D12 error 613.
  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings and --features diagnostics: 0 warnings.
  • cargo test -p xtask --locked policy::tests::repository_passes_policy: passed.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 08:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/3109) `fuzeofficlal:fix/gpu-rtv-format-pipeline-variants` → `main` · +952 −34 · 6 files · 1 commits · open ## Summary When a title draws with a graphics pipeline whose declared `RTFormats` differ from the render target views currently bound via `OMSetRenderTargets` (for example, `R10G10B10A2_UNORM` declared in the pipeline stream against a bound `R11G11B10_FLOAT` or typeless `R8G8B8A8_UNORM_SRGB` target), D3D12 raises debug-layer error 613 (`D3D12_MESSAGE_ID_RENDER_TARGET_FORMAT_MISMATCH_PIPELINE_STATE`) and leaves host render-target output conversion mismatched. This change tracks the host DXGI formats of the bound render targets and lazily builds and caches matching host graphics pipeline variants per title pipeline when any declared non-`UNKNOWN` target slot differs from the bound format. ## Changes - `crates/victory-gpu/src/draw.rs`: track bound host RTV DXGI formats in `State::set_targets` (from the RTV desc format or resource desc fallback) and resolve graphics/mesh draws through `pipeline::host_pipeline_for` (and diagnostics through `note_drop_for`). - `crates/victory-gpu/src/pipeline/host.rs`: add `GraphicsState::targets_for` (overriding only declared non-`UNKNOWN` slots that differ from bound non-`UNKNOWN` formats, returning `None` when already matching) and `GraphicsState::with_targets` (cloning input semantic names and re-pointing `SemanticName` pointers). - `crates/victory-gpu/src/pipeline/make.rs`: add `Pending::variant` sharing translated shaders, inheriting `skipped_shader` and `host_blend` integer-target handling, storing variants in the pipeline library, and keeping draw-time variants out of the early-start list (`record_early: false`); return `Option<Arc<HostPipeline>>` from `ready`. - `crates/victory-gpu/src/pipeline.rs`: add per-`Pipeline` lazy variant cache (`Mutex<Vec<(TargetFormatsKey, Arc<make::Pending>)>>`), keeping matching draws on the lock-free base path. - `crates/victory-gpu/src/pipeline/rtv_format_test.rs` & unit tests: end-to-end D3D12 draw + pixel readback + D3D12 debug-layer zero-Error-613 tests covering `R10G10B10A2_UNORM -> R11G11B10_FLOAT` and multi-RT typeless `R8G8B8A8_UNORM_SRGB`, plus unit tests for `targets_for`, `with_targets` (including integer-target blend disabling), and `Pending::variant`. ## Testing - `cargo test -p victory-gpu --locked pipeline::` (RTX 5090 hardware & `VICTORY_D3D12_WARP=1`): 48 passed, 0 failed. - `VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --locked --features diagnostics pipeline::` (RTX 5090 hardware & WARP): 51 passed, 0 failed, zero D3D12 error 613. - `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings` and `--features diagnostics`: 0 warnings. - `cargo test -p xtask --locked policy::tests::repository_passes_policy`: passed.
A console title may draw with a graphics pipeline whose declared RTFormats differ from the render target views bound via OMSetRenderTargets (for example, R10G10B10A2_UNORM in the pipeline stream against a bound R11G11B10_FLOAT or R8G8B8A8_UNORM_SRGB target). On D3D12 this triggers debug layer error 613 (D3D12_MESSAGE_ID_RENDER_TARGET_FORMAT_MISMATCH_PIPELINE_STATE) and leaves output conversion mismatched on the host.

Track the bound host RTV DXGI formats in draw::State::set_targets and lazily build and cache matching host graphics pipeline variants per title pipeline when any declared non-UNKNOWN target slot differs from the bound format. Matching draws stay on the lock-free base path; variants share the translated shaders, inherit host_blend integer-target handling, store in the pipeline library, and stay out of the early-start list.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:25:04 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 08:27 UTC · original · approved these changes

Verified on RTX 5090 & WARP against origin/main (63bcca4):

  • cargo test -p victory-gpu --lib pipeline:: -- --test-threads=1: 28/28 passed on RTX 5090 and WARP (including mismatched_rtv_format_builds_variant_and_draws_cleanly, multi_rt_and_srgb_mismatch_draws_both_targets_cleanly, targets_for_overrides_only_mismatched_declared_slots, with_targets_repoints_input_names_and_updates_description, and format_variant_does_not_record_early_and_inherits_skip).
  • cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 20/20 passed on RTX 5090.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 192 files ok.

Cleanly builds and caches RTV-format PSO variants on demand when bound RTV formats differ from the declared graphics pipeline formats.

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

**@⁠Dukestar69** on GitHub · 2026-11-26 08:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/3109#pullrequestreview-6070681898) · **approved these changes** Verified on RTX 5090 & WARP against `origin/main` (`63bcca4`): - `cargo test -p victory-gpu --lib pipeline:: -- --test-threads=1`: 28/28 passed on RTX 5090 and WARP (including `mismatched_rtv_format_builds_variant_and_draws_cleanly`, `multi_rt_and_srgb_mismatch_draws_both_targets_cleanly`, `targets_for_overrides_only_mismatched_declared_slots`, `with_targets_repoints_input_names_and_updates_description`, and `format_variant_does_not_record_early_and_inherits_skip`). - `cargo test -p victory-gpu --lib draw:: -- --test-threads=1`: 20/20 passed on RTX 5090. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 192 files ok. Cleanly builds and caches RTV-format PSO variants on demand when bound RTV formats differ from the declared graphics pipeline formats. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 08:32 UTC · original

Automated triage for the maintainers.

Verdict: needs work. CI check passes.

This PR records the bound RTV formats in draw::State::set_targets. When a declared RTFormats slot differs from the bound format, it builds and caches a host pipeline variant at draw time (Pipeline::variant_for, GraphicsState::targets_for / with_targets, make::Pending::variant). Every graphics lookup moves to host_pipeline_for.

This changes GPU state handling, and the PR gives no evidence from the title:

  • Does the title do this? Please show a run log where the title itself raises debug-layer error 613, with the pipeline and both format sets. The tests use made-up format pairs.
  • Is the mismatch ours? Both sides go through resource::pc_format: the pipeline in GraphicsState (pipeline/host.rs), and the RTV in RtvRecord::host_desc. If the mismatch comes from VIctory mapping the two differently, the fix belongs in that mapping, not in per-draw variants.
  • Is the substitution right? On the console, a pipeline/target format mismatch has defined export conversion. Replacing the pipeline's format with the target's is an assumption. Please cite a public hardware reference for what the console does.
  • Variants built at draw time are not ready on first use, so those draws are dropped until the variant is made. Please note this, or measure it.

The PR also edits set_targets, as #3107 does. With title evidence, and a check that the mismatch is not in our own format mapping, this would be reviewed again.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 08:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/3109#issuecomment-7186716161) <!-- victory-triage v1 head=5c6dd93e5a82d84d1f7f0936bd331f2589bc9993 verdict=needs-work at=2026-11-26T08:31:06Z --> Automated triage for the maintainers. **Verdict: needs work.** CI `check` passes. This PR records the bound RTV formats in `draw::State::set_targets`. When a declared `RTFormats` slot differs from the bound format, it builds and caches a host pipeline variant at draw time (`Pipeline::variant_for`, `GraphicsState::targets_for` / `with_targets`, `make::Pending::variant`). Every graphics lookup moves to `host_pipeline_for`. This changes GPU state handling, and the PR gives no evidence from the title: - **Does the title do this?** Please show a run log where the title itself raises debug-layer error 613, with the pipeline and both format sets. The tests use made-up format pairs. - **Is the mismatch ours?** Both sides go through `resource::pc_format`: the pipeline in `GraphicsState` (`pipeline/host.rs`), and the RTV in `RtvRecord::host_desc`. If the mismatch comes from VIctory mapping the two differently, the fix belongs in that mapping, not in per-draw variants. - **Is the substitution right?** On the console, a pipeline/target format mismatch has defined export conversion. Replacing the pipeline's format with the target's is an assumption. Please cite a public hardware reference for what the console does. - Variants built at draw time are not ready on first use, so those draws are dropped until the variant is made. Please note this, or measure it. The PR also edits `set_targets`, as #3107 does. With title evidence, and a check that the mismatch is not in our own format mapping, this would be reviewed again. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3109/head:github-bot/gh-3109'
git switch 'github-bot/gh-3109'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3109'
git switch 'github-bot/gh-3109'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3109'
git switch 'github-bot/gh-3109'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3109'
git switch 'main'
git merge --squash 'github-bot/gh-3109'
git switch 'main'
git merge --ff-only 'github-bot/gh-3109'
git switch 'main'
git merge 'github-bot/gh-3109'
git push origin 'main'
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/Marvisak--VIctory!3109
No description provided.