GPU: integer render targets write unblended on the host (#2775) #2801

Open
github-bot wants to merge 3 commits from github-bot/gh-2801 into main AGit
Owner

@⁠miatson on GitHub · 2026-11-25 20:56 UTC · original
miatson:gpu-integer-target-blend → main · +114 −0 · 1 files · 3 commits · open

Fixes #2775.

Problem

The console blends (MIN/MAX) into integer render targets; desktop D3D12 refuses a
pipeline that enables blending on a _UINT/_SINT target. The title's blend state was
passed to the host unchanged, so pipelines like the mesh pipeline in #2775 (blending on
slot 2, R8_UINT) were refused with E_INVALIDARG and all their draws were dropped.

Change

GraphicsState::host_blend (in pipeline/host.rs) is now the blend state both host paths use
(the graphics description and the mesh pipeline stream):

  • Targets with an integer format get BlendEnable = FALSE; the others keep the title's blending.
  • If IndependentBlendEnable was off, target 0's description is first copied to every
    target and independent blending turned on, so only the integer target changes.
  • States with no blended integer target are passed on unchanged.

It reuses twin::integer (now pub(crate)) for the format check.

Trade-off

The integer target now overwrites instead of MIN/MAX-blending, as the issue suggests.
That can differ from the console's output for that target, but the pass is drawn instead
of dropped.

Tests

  • integer_targets_write_unblended: the blend state for both the independent and the
    shared description cases, and the unchanged case.
  • the_host_takes_a_pipeline_blending_into_an_integer_target: creates the pipeline on the
    host device (skipped without one). Before the change it failed locally with
    HRESULT(0x80070057), the error in the issue; it now passes.

cargo clippy --workspace --all-targets [--all-features] --locked -- -D warnings is clean, and
cargo test --workspace --locked passes (782 passed, 0 failed) on Windows 11.

Not tested in game: I have no game data. The mesh path uses the same host_blend but
only the graphics path is covered by the device test.

Written with the help of Claude Code.

**@⁠miatson** on GitHub · 2026-11-25 20:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/2801) `miatson:gpu-integer-target-blend` → `main` · +114 −0 · 1 files · 3 commits · open Fixes #2775. ## Problem The console blends (MIN/MAX) into integer render targets; desktop D3D12 refuses a pipeline that enables blending on a `_UINT`/`_SINT` target. The title's blend state was passed to the host unchanged, so pipelines like the mesh pipeline in #2775 (blending on slot 2, `R8_UINT`) were refused with `E_INVALIDARG` and all their draws were dropped. ## Change `GraphicsState::host_blend` (in `pipeline/host.rs`) is now the blend state both host paths use (the graphics description and the mesh pipeline stream): - Targets with an integer format get `BlendEnable = FALSE`; the others keep the title's blending. - If `IndependentBlendEnable` was off, target 0's description is first copied to every target and independent blending turned on, so only the integer target changes. - States with no blended integer target are passed on unchanged. It reuses `twin::integer` (now `pub(crate)`) for the format check. ## Trade-off The integer target now overwrites instead of MIN/MAX-blending, as the issue suggests. That can differ from the console's output for that target, but the pass is drawn instead of dropped. ## Tests - `integer_targets_write_unblended`: the blend state for both the independent and the shared description cases, and the unchanged case. - `the_host_takes_a_pipeline_blending_into_an_integer_target`: creates the pipeline on the host device (skipped without one). Before the change it failed locally with `HRESULT(0x80070057)`, the error in the issue; it now passes. `cargo clippy --workspace --all-targets [--all-features] --locked -- -D warnings` is clean, and `cargo test --workspace --locked` passes (782 passed, 0 failed) on Windows 11. Not tested in game: I have no game data. The mesh path uses the same `host_blend` but only the graphics path is covered by the device test. Written with the help of Claude Code.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:14:34 +00:00
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 21:20 UTC · original

Reviewed and verified 28b7278f on Windows 11 (RTX 5090 + WARP) against main (13f91ca).

Code review (and comparison with #2790)

  • Clean, minimal diff on current main (13f91ca), keeping g.blend / g.describe() untouched via GraphicsState::host_blend() for both graphics (host.rs:647) and mesh (host.rs:752) PSO creation.
  • Correctly handles IndependentBlendEnable == FALSE (unlike #2790): inspects blend.RenderTarget[if independent { i } else { 0 }].BlendEnable across 0..count, expands [blend.RenderTarget[0]; 8] and sets IndependentBlendEnable = true when any integer target is blended, and clears BlendEnable only on the integer slots—so both (RT0 float blended, RT2 integer) and (RT0 integer blended, RT1 float) MRT combinations work without rejecting the PSO or disabling blending on float targets.
  • Reuses twin::integer covering all 21 DXGI _UINT/_SINT RTV formats. (Minor edge note: if a title ever set both BlendEnable = TRUE and LogicOpEnable = TRUE simultaneously with IndependentBlendEnable = FALSE, expanding to IndependentBlendEnable = TRUE would also need LogicOpEnable = FALSE, though that combination is already invalid in D3D12.)

Verification (Windows 11, RTX 5090 + WARP)

  • RTX 5090 (--features diagnostics --test-threads=1, pipeline::): 18/18 passed (including integer_targets_write_unblended and the_host_takes_a_pipeline_blending_into_an_integer_target for both independent = true and false).
  • WARP & RTX 5090 full victory-gpu --features diagnostics --lib -- --test-threads=1: 198 passed, 2 failed, 1 ignored (all pipeline::* pass; only the 2 pre-existing 13f91ca view-heap cap baselines fail).
  • cargo clippy --locked -p victory-gpu --features diagnostics --all-targets -- -D warnings: 0 warnings; cargo xtask policy: 184 files ok; clean git merge-tree vs 13f91ca and #2803.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 21:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2801#issuecomment-7174944759) Reviewed and verified `28b7278f` on Windows 11 (RTX 5090 + WARP) against `main` (`13f91ca`). ### Code review (and comparison with `#2790`) - Clean, minimal diff on current `main` (`13f91ca`), keeping `g.blend` / `g.describe()` untouched via `GraphicsState::host_blend()` for both graphics (`host.rs:647`) and mesh (`host.rs:752`) PSO creation. - **Correctly handles `IndependentBlendEnable == FALSE`** (unlike `#2790`): inspects `blend.RenderTarget[if independent { i } else { 0 }].BlendEnable` across `0..count`, expands `[blend.RenderTarget[0]; 8]` and sets `IndependentBlendEnable = true` when any integer target is blended, and clears `BlendEnable` only on the integer slots—so both `(RT0 float blended, RT2 integer)` and `(RT0 integer blended, RT1 float)` MRT combinations work without rejecting the PSO or disabling blending on float targets. - Reuses `twin::integer` covering all 21 DXGI `_UINT`/`_SINT` RTV formats. *(Minor edge note: if a title ever set both `BlendEnable = TRUE` and `LogicOpEnable = TRUE` simultaneously with `IndependentBlendEnable = FALSE`, expanding to `IndependentBlendEnable = TRUE` would also need `LogicOpEnable = FALSE`, though that combination is already invalid in D3D12.)* ### Verification (Windows 11, RTX 5090 + WARP) - **RTX 5090 (`--features diagnostics --test-threads=1`, `pipeline::`)**: **18/18 passed** (including `integer_targets_write_unblended` and `the_host_takes_a_pipeline_blending_into_an_integer_target` for both `independent = true` and `false`). - **WARP & RTX 5090 full `victory-gpu --features diagnostics --lib -- --test-threads=1`**: **198 passed, 2 failed, 1 ignored** (all `pipeline::*` pass; only the 2 pre-existing `13f91ca` view-heap cap baselines fail). - `cargo clippy --locked -p victory-gpu --features diagnostics --all-targets -- -D warnings`: **0 warnings**; `cargo xtask policy`: **184 files ok**; clean `git merge-tree` vs `13f91ca` and `#2803`.
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 21:25 UTC · original

Independent WARP/CPU verification of head 28b7278f6ddcce2bd9b7a01f6e989c2adc86534b, merged onto origin/main 13f91caee25f2fdf2c062be5f7a27f058e51cbca (clean merge).

Environment: Windows 11 Pro 26200, WARP only (VICTORY_D3D12_WARP=1 with --features diagnostics, so host() is WARP, plus VICTORY_WARP=1), Windows SDK 10.0.26100.0 x64 dxil.dll 1.8.2502.11.

  • cargo test -j 4 -p victory-gpu --features diagnostics:
    • The first run gave 199 passed, 1 failed, 1 ignored. The failure was memory::tests::a_submission_that_missed_leaves_the_copies_at_once ("the written page counts as changed at once"), which is the known race on main that #2805 removes, unrelated to this change.
    • Five reruns each gave 200 passed, 0 failed, 1 ignored. The baseline was 198/0/1, so there are 2 new passing tests.
  • the_host_takes_a_pipeline_blending_into_an_integer_target ran on the WARP host device.
  • Negative controls:
    • When host_blend returns the title's self.blend unchanged, both new tests fail. The device test fails with HRESULT(0x80070057) for independent: true, the error in #2775.
    • When target 0 is not copied to every target in the non-independent case, both tests still pass. The fixture gives all 8 RenderTarget entries the same blend, so the copy isn't exercised. In a translated state with IndependentBlendEnable off, entries 1..7 need not match entry 0 (they could be default zeros). Without the copy, the float target 1 would silently lose its blending. Leaving RenderTarget[1..] at their defaults in the independent == false fixture would pin it down.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings was clean, with and without --all-features.
  • cargo fmt --all --check: 897 hunks against 891 on the baseline. The 6 new hunks are all in pipeline/host.rs: the blended closure in host_blend, two assert!s in integer_targets_write_unblended, and the D3DCompile, D3D12_SHADER_BYTECODE and CreateRootSignature lines in the device test.

Diff review:

  • The logic looks right. The early return only applies when a blended target is an integer one, both the graphics and the mesh-stream paths use host_blend, min(8) bounds the format index, and twin::integer's list matches the DXGI _UINT/_SINT formats.
  • The only requests are the test gap and the rustfmt hunks above.
  • The mesh path isn't exercised by a test, as the description says.

Not tested: physical GPU, mesh pipeline path on a device, retail title.

AI use: Claude Code (Claude Opus 5.5)

**@⁠oni-swr** on GitHub · 2026-11-25 21:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/2801#issuecomment-7175065196) Independent WARP/CPU verification of head `28b7278f6ddcce2bd9b7a01f6e989c2adc86534b`, merged onto `origin/main` `13f91caee25f2fdf2c062be5f7a27f058e51cbca` (clean merge). Environment: Windows 11 Pro 26200, WARP only (`VICTORY_D3D12_WARP=1` with `--features diagnostics`, so `host()` is WARP, plus `VICTORY_WARP=1`), Windows SDK 10.0.26100.0 x64 `dxil.dll` 1.8.2502.11. - `cargo test -j 4 -p victory-gpu --features diagnostics`: - The first run gave 199 passed, 1 failed, 1 ignored. The failure was `memory::tests::a_submission_that_missed_leaves_the_copies_at_once` ("the written page counts as changed at once"), which is the known race on `main` that #2805 removes, unrelated to this change. - Five reruns each gave 200 passed, 0 failed, 1 ignored. The baseline was 198/0/1, so there are 2 new passing tests. - `the_host_takes_a_pipeline_blending_into_an_integer_target` ran on the WARP host device. - Negative controls: - When `host_blend` returns the title's `self.blend` unchanged, both new tests fail. The device test fails with `HRESULT(0x80070057)` for `independent: true`, the error in #2775. - When target 0 is **not** copied to every target in the non-independent case, **both tests still pass**. The fixture gives all 8 `RenderTarget` entries the same blend, so the copy isn't exercised. In a translated state with `IndependentBlendEnable` off, entries 1..7 need not match entry 0 (they could be default zeros). Without the copy, the float target 1 would silently lose its blending. Leaving `RenderTarget[1..]` at their defaults in the `independent == false` fixture would pin it down. - `cargo clippy -p victory-gpu --all-targets -- -D warnings` was clean, with and without `--all-features`. - `cargo fmt --all --check`: 897 hunks against 891 on the baseline. The 6 new hunks are all in `pipeline/host.rs`: the `blended` closure in `host_blend`, two `assert!`s in `integer_targets_write_unblended`, and the `D3DCompile`, `D3D12_SHADER_BYTECODE` and `CreateRootSignature` lines in the device test. Diff review: - The logic looks right. The early return only applies when a blended target is an integer one, both the graphics and the mesh-stream paths use `host_blend`, `min(8)` bounds the format index, and `twin::integer`'s list matches the DXGI `_UINT`/`_SINT` formats. - The only requests are the test gap and the rustfmt hunks above. - The mesh path isn't exercised by a test, as the description says. Not tested: physical GPU, mesh pipeline path on a device, retail title. AI use: Claude Code (Claude Opus 5.5)
Author
Owner

@⁠miatson on GitHub · 2026-11-25 21:53 UTC · original

  • The logic looks right. The early return only applies when a blended target is an integer one, both the graphics and the mesh-stream paths use host_blend, min(8) bounds the format index, and twin::integer's list matches the DXGI _UINT/_SINT formats.
  • The only requests are the test gap and the rustfmt hunks above.
  • The mesh path isn't exercised by a test, as the description says.

Not tested: physical GPU, mesh pipeline path on a device, retail title.

Both points are addressed in 100605f:

  • Test gap: with independent == false the fixture now describes only RenderTarget[0] and leaves RenderTarget[1..] at their defaults (unblended). With the [blend.RenderTarget[0]; 8] copy removed, integer_targets_write_unblended now fails at RenderTarget[1].BlendEnable; with it, both tests pass. (The device test still passes without the copy, as expected: the pipeline is valid, target 1 just loses its blending.)
  • rustfmt: the new code is formatted; pipeline/host.rs is back to main's 12 cargo fmt --check hunks, none in this change.

Re-checked on Windows 11 / RX 7900 XT: Clippy clean with and without --all-features, cargo test --workspace --locked 781 passed, 0 failed.

**@⁠miatson** on GitHub · 2026-11-25 21:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/2801#issuecomment-7175666713) > * The logic looks right. The early return only applies when a blended target is an integer one, both the graphics and the mesh-stream paths use `host_blend`, `min(8)` bounds the format index, and `twin::integer`'s list matches the DXGI `_UINT`/`_SINT` formats. > * The only requests are the test gap and the rustfmt hunks above. > * The mesh path isn't exercised by a test, as the description says. > > Not tested: physical GPU, mesh pipeline path on a device, retail title. Both points are addressed in 100605f: - **Test gap:** with `independent == false` the fixture now describes only `RenderTarget[0]` and leaves `RenderTarget[1..]` at their defaults (unblended). With the `[blend.RenderTarget[0]; 8]` copy removed, `integer_targets_write_unblended` now fails at `RenderTarget[1].BlendEnable`; with it, both tests pass. (The device test still passes without the copy, as expected: the pipeline is valid, target 1 just loses its blending.) - **rustfmt:** the new code is formatted; `pipeline/host.rs` is back to main's 12 `cargo fmt --check` hunks, none in this change. Re-checked on Windows 11 / RX 7900 XT: Clippy clean with and without `--all-features`, `cargo test --workspace --locked` 781 passed, 0 failed.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 23:24 UTC · original

Automated triage for the maintainers.

The fix this PR first carried is now in main (host_blend in crates/victory-gpu/src/pipeline/host.rs, from #1152), and after merging main the diff only adds two tests: a_shared_blend_description_is_copied_to_every_target, which leaves RenderTarget[1..] at their defaults so it fails if the copy of target 0 is removed (the existing integer_targets_do_not_blend gives every entry the same blend and does not catch that), and the_host_takes_a_pipeline_blending_into_an_integer_target, which creates such a pipeline on the host device for both IndependentBlendEnable values. I checked both against main's host_blend and the default blend state; they are meaningful tests. No CI run is reported for the current head, and the title and description still describe the fix, so they would be best updated to say this is now tests only.

This is a recommendation for a maintainer to look, not an approval.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 23:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/2801#issuecomment-7177509452) <!-- victory-triage v1 head=36cfa0029b8ac038304a926dda8a294e22260eae verdict=merge-candidate at=2026-11-25T23:23:59Z --> Automated triage for the maintainers. The fix this PR first carried is now in `main` (`host_blend` in `crates/victory-gpu/src/pipeline/host.rs`, from #1152), and after merging `main` the diff only adds two tests: `a_shared_blend_description_is_copied_to_every_target`, which leaves `RenderTarget[1..]` at their defaults so it fails if the copy of target 0 is removed (the existing `integer_targets_do_not_blend` gives every entry the same blend and does not catch that), and `the_host_takes_a_pipeline_blending_into_an_integer_target`, which creates such a pipeline on the host device for both `IndependentBlendEnable` values. I checked both against `main`'s `host_blend` and the default blend state; they are meaningful tests. No CI run is reported for the current head, and the title and description still describe the fix, so they would be best updated to say this is now tests only. This is a recommendation for a maintainer to look, not an approval. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-26 02:08 UTC · original

I checked the mesh dispatch from #2775 on head 36cfa002. The current head carries regression tests, and the production blend fix is already on main. With the D3D12 debug layer enabled, I dispatched a full-screen triangle through VIctory's mesh_pipeline and copied all three render targets back. This exercised the mixed formats together, with MAX blending requested by the guest.

Adapter Shared blend state Independent blend state
RTX 5080, driver 621.40 0 / 1,536 target pixels wrong 0 / 1,536 wrong
Windows WARP, 10.0.26100.10068 0 / 1,536 wrong 0 / 1,536 wrong

Counts are per run. All three repetitions on each adapter agreed. Each column includes a 16×16 full draw and a scissored draw covering 72 pixels, with the other 184 retaining their clear values. The drawn RGBA8 target read [191,192,128,255], the RGBA16F neighbor read [0.75,0.75,0.5,1], and the R8_UINT target in slot 2 changed from 201 to the shader's 17.

For a sensitivity check I locally removed just the shared-state copy for the RGBA16F neighbor. The mesh PSO still created and dispatched on both adapters. All 256 drawn pixels on that neighbor then differed in the full draw and exactly 72 differed in the scissored draw. The other targets and the independent-state cases stayed correct. That gives the shared-state regression test a concrete rendering consequence. These are synthetic mesh draws. I did not run the title.

**@⁠steven-seagull27** on GitHub · 2026-11-26 02:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/2801#issuecomment-7180495942) I checked the mesh dispatch from #2775 on head `36cfa002`. The current head carries regression tests, and the production blend fix is already on main. With the D3D12 debug layer enabled, I dispatched a full-screen triangle through VIctory's `mesh_pipeline` and copied all three render targets back. This exercised the mixed formats together, with MAX blending requested by the guest. | Adapter | Shared blend state | Independent blend state | | --- | --- | --- | | RTX 5080, driver 621.40 | 0 / 1,536 target pixels wrong | 0 / 1,536 wrong | | Windows WARP, 10.0.26100.10068 | 0 / 1,536 wrong | 0 / 1,536 wrong | Counts are per run. All three repetitions on each adapter agreed. Each column includes a 16×16 full draw and a scissored draw covering 72 pixels, with the other 184 retaining their clear values. The drawn RGBA8 target read `[191,192,128,255]`, the RGBA16F neighbor read `[0.75,0.75,0.5,1]`, and the R8_UINT target in slot 2 changed from 201 to the shader's 17. For a sensitivity check I locally removed just the shared-state copy for the RGBA16F neighbor. The mesh PSO still created and dispatched on both adapters. All 256 drawn pixels on that neighbor then differed in the full draw and exactly 72 differed in the scissored draw. The other targets and the independent-state cases stayed correct. That gives the shared-state regression test a concrete rendering consequence. These are synthetic mesh draws. I did not run the title.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/2801/head:github-bot/gh-2801'
git switch 'github-bot/gh-2801'

Merge

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