GPU: blending off on integer render targets #2346

Closed
github-bot wants to merge 2 commits from gh-pr/2346/head into gh-pr/2346/base
Owner

@⁠Calvix2k on GitHub · 2026-11-25 11:14 UTC · original
Calvix2k:codex/gpu-blend-integer-targets → main · +57 −3 · 1 files · 2 commits · closed without merging

The debug layer names the cause exactly:

D3D12: ID3D12Device::CreateGraphicsPipelineState: The render target format at slot 2 is format (R8_UINT).
This format does not support blending. The Pixel Shader output signature indicates this output could be
written, and the Blend State indicates blending is enabled for this slot.  id=676
victory_gpu::pipeline::host: host mesh pipeline refused error=0x80070057 shaders=[mesh f5e50eb2…, pixel ce3f0432…]

A console title may describe blending on a slot whose format holds integers; the console's blend hardware ignores it, but D3D12 refuses the whole pipeline (E_INVALIDARG), so every draw of that pipeline was dropped — part of the world's mesh objects never ran.

What the fix does

GraphicsState::host_blend() clears BlendEnable for exactly the render targets whose format is an integer one (_UINT/_SINT, DXGI 3..64 — R8_UINT is 30 in DXGI numbering, R16G16_UINT 37), and both pipeline paths — the plain graphics stream and the mesh stream — are built from it. describe() (the pipeline library name and the early-start key) uses the same state, so a library entry's name and the description stored under it still agree.

Verification

  • blending_is_cleared_only_on_integer_targets: UNORM, FLOAT and R10G10B10A2_UNORM keep blending; R8_UINT, R16G16_UINT and R16G16_SINT lose it; a slot past NumRenderTargets is left as the title had it; describe() starts with the blend state the pipeline is made from.
  • cargo test -p victory-gpu --features diagnostics --lib: 145 passed, 2 ignored, plus the known placed-view failure on a runtime without ID3D12Device10 (#1999). clippy -D warnings clean.
  • On the title: Windows 10 / RX 7800 XT, Series X console, debug layer on. Before: host mesh pipeline refused … [mesh f5e50eb2108c425b, pixel ce3f0432a08f1d35] once per run, and the debug layer's "does not support blending" message. After the change, same build otherwise: host mesh pipeline shaders=[mesh f5e50eb2108c425b, pixel ce3f0432a08f1d35], zero refusals, and no blend message.
**@⁠Calvix2k** on GitHub · 2026-11-25 11:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/2346) `Calvix2k:codex/gpu-blend-integer-targets` → `main` · +57 −3 · 1 files · 2 commits · closed without merging The debug layer names the cause exactly: ``` D3D12: ID3D12Device::CreateGraphicsPipelineState: The render target format at slot 2 is format (R8_UINT). This format does not support blending. The Pixel Shader output signature indicates this output could be written, and the Blend State indicates blending is enabled for this slot. id=676 victory_gpu::pipeline::host: host mesh pipeline refused error=0x80070057 shaders=[mesh f5e50eb2…, pixel ce3f0432…] ``` A console title may describe blending on a slot whose format holds integers; the console's blend hardware ignores it, but D3D12 refuses the whole pipeline (`E_INVALIDARG`), so every draw of that pipeline was dropped — part of the world's mesh objects never ran. ### What the fix does `GraphicsState::host_blend()` clears `BlendEnable` for exactly the render targets whose format is an integer one (`_UINT`/`_SINT`, DXGI 3..64 — `R8_UINT` is 30 in DXGI numbering, `R16G16_UINT` 37), and both pipeline paths — the plain graphics stream and the mesh stream — are built from it. `describe()` (the pipeline library name and the early-start key) uses the same state, so a library entry's name and the description stored under it still agree. ### Verification - `blending_is_cleared_only_on_integer_targets`: UNORM, FLOAT and R10G10B10A2_UNORM keep blending; `R8_UINT`, `R16G16_UINT` and `R16G16_SINT` lose it; a slot past `NumRenderTargets` is left as the title had it; `describe()` starts with the blend state the pipeline is made from. - `cargo test -p victory-gpu --features diagnostics --lib`: 145 passed, 2 ignored, plus the known placed-view failure on a runtime without `ID3D12Device10` (#1999). clippy `-D warnings` clean. - **On the title**: Windows 10 / RX 7800 XT, Series X console, debug layer on. Before: `host mesh pipeline refused … [mesh f5e50eb2108c425b, pixel ce3f0432a08f1d35]` once per run, and the debug layer's "does not support blending" message. After the change, same build otherwise: `host mesh pipeline shaders=[mesh f5e50eb2108c425b, pixel ce3f0432a08f1d35]`, zero refusals, and no blend message.
A title may describe blending on a render target whose format holds
integers (this title's slot 2 is R8_UINT). The console's blend hardware
ignores it; D3D12 refuses the whole pipeline instead — CreatePipelineState
fails with E_INVALIDARG, and with the debug layer on:

  The render target format at slot 2 is format (R8_UINT). This format does
  not support blending. The Pixel Shader output signature indicates this
  output could be written, and the Blend State indicates blending is
  enabled for this slot.

so every draw of that pipeline was dropped. `GraphicsState::host_blend()`
clears BlendEnable for exactly those slots before the graphics and mesh
pipelines are made, and `describe()` uses the same state so that a pipeline
library name and the description stored under it agree.
Checked against dxgiformat.h (Windows SDK 10.0.26100.0): 33 TYPELESS, 34
FLOAT, 35 UNORM, 36 UINT, 37 SNORM, 38 SINT, and 39 is R32_TYPELESS. The
table had the pair one off, so an R16G16_UINT target kept blending on (the
refusal this change exists to avoid) and an R16G16_SNORM one lost it.
Reported by upipibi (and Mbappinho) on the PR.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:02:57 +00:00
github-bot closed this pull request 2026-11-26 05:02:57 +00:00
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-25 11:36 UTC · original

An in-game note for the visual effect, since it is larger than "one pipeline came back".

A/B on the title, same save, same cutscene, Windows 10 / RX 7800 XT, Series X:

  • before (a build from earlier today, no blend change): the whole scene is a white haze — the character reads as a ghost, one frame is pure white.
  • after (this change): the same scene is an interior at night — face lit by a lamp, window with a silhouette outside, posters on the wall, the trim on the shirt orange.

The R8_UINT slot was a mask the title writes every frame; its pipeline was refused, so the mask was never written and the frame came out over-bright. So this is not a micro-optimisation: restoring that pipeline changes the image from "unreadable white" to "looks like the game".

That is also the answer to a question the PR invites — whether clearing BlendEnable is right at all. The console hardware cannot blend an integer format either, so a direct write is the faithful emulation; what looked better before was the mask missing entirely.

**@⁠Calvix2k** on GitHub · 2026-11-25 11:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/2346#issuecomment-7161275204) An in-game note for the visual effect, since it is larger than "one pipeline came back". A/B on the title, same save, same cutscene, Windows 10 / RX 7800 XT, Series X: - **before** (a build from earlier today, no blend change): the whole scene is a white haze — the character reads as a ghost, one frame is pure white. - **after** (this change): the same scene is an interior at night — face lit by a lamp, window with a silhouette outside, posters on the wall, the trim on the shirt orange. The `R8_UINT` slot was a mask the title writes every frame; its pipeline was refused, so the mask was never written and the frame came out over-bright. So this is not a micro-optimisation: restoring that pipeline changes the image from "unreadable white" to "looks like the game". That is also the answer to a question the PR invites — whether clearing `BlendEnable` is right at all. The console hardware cannot blend an integer format either, so a direct write is the faithful emulation; what looked better before was the mask missing entirely.
Author
Owner

@⁠Mbappinho on GitHub · 2026-11-25 13:13 UTC · original

The integer format table in integer_target (at 7a338ce) is off by one for the R16G16 pair:

3 | 4 | 7 | 8 | 12 | 14 | 17 | 18 | 25 | 30 | 32 | 37 | 39 | 42 | ...

In DXGI, R16G16_UINT is 36 and R16G16_SINT is 38. 37 is R16G16_SNORM and 39 is R32_TYPELESS. So with this table:

  • a pipeline blending into an R16G16_UINT or R16G16_SINT target is still refused (E_INVALIDARG);
  • blending is wrongly turned off on R16G16_SNORM targets.

The test does not catch it because it uses the same numbers ([29u32, 10, 62, 37, 39, 24], commented as R16G16_UINT, R16G16_SINT). Matching on the named constants (DXGI_FORMAT_R16G16_UINT, ...) instead of numbers avoids this; a test that walks every _UINT/_SINT constant would have failed on 36.

This is on top of @⁠DrDarkDK's point about a shared blend description: the same fix with both changes is in Belobug/VIctory-Belobug-AMD#45 (named formats, slot 0 spread over the targets first), confirmed in game on an RX 9070 XT.

Found by a unit test while porting this PR; no game data involved in this check.

AI use: Hermes (Claude) found this while writing tests; reviewed by me.

**@⁠Mbappinho** on GitHub · 2026-11-25 13:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/2346#issuecomment-7163464562) The integer format table in `integer_target` (at `7a338ce`) is off by one for the `R16G16` pair: ```rust 3 | 4 | 7 | 8 | 12 | 14 | 17 | 18 | 25 | 30 | 32 | 37 | 39 | 42 | ... ``` In DXGI, `R16G16_UINT` is **36** and `R16G16_SINT` is **38**. 37 is `R16G16_SNORM` and 39 is `R32_TYPELESS`. So with this table: - a pipeline blending into an `R16G16_UINT` or `R16G16_SINT` target is still refused (`E_INVALIDARG`); - blending is wrongly turned off on `R16G16_SNORM` targets. The test does not catch it because it uses the same numbers (`[29u32, 10, 62, 37, 39, 24]`, commented as `R16G16_UINT, R16G16_SINT`). Matching on the named constants (`DXGI_FORMAT_R16G16_UINT`, ...) instead of numbers avoids this; a test that walks every `_UINT`/`_SINT` constant would have failed on 36. This is on top of @⁠DrDarkDK's point about a shared blend description: the same fix with both changes is in Belobug/VIctory-Belobug-AMD#45 (named formats, slot 0 spread over the targets first), confirmed in game on an RX 9070 XT. Found by a unit test while porting this PR; no game data involved in this check. AI use: Hermes (Claude) found this while writing tests; reviewed by me.
Author
Owner

@⁠upipibi on GitHub · 2026-11-25 13:22 UTC · original

Second check of integer_target (victory-gpu/src/pipeline/host.rs:99 at 7a338ce) against the DXGI_FORMAT enum. Mbappinho's finding holds, and the rest of the table is right:

  • Correct (UINT / SINT): 3, 4 (R32G32B32A32), 7, 8 (R32G32B32), 12, 14 (R16G16B16A16), 17, 18 (R32G32), 25 (R10G10B10A2_UINT), 30, 32 (R8G8B8A8), 42, 43 (R32), 50, 52 (R8G8), 57, 59 (R16), 62, 64 (R8).
  • Wrong: 37 is R16G16_SNORM and 39 is R32_TYPELESS. The pair should be 36 (R16G16_UINT) and 38 (R16G16_SINT).

As it stands, an R16G16_UINT/SINT target keeps blending on, and an R16G16_SNORM target loses it.

AI-assisted (Claude Code). Checked against the enum only; nothing run.

**@⁠upipibi** on GitHub · 2026-11-25 13:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/2346#issuecomment-7163689315) Second check of `integer_target` (`victory-gpu/src/pipeline/host.rs:99` at `7a338ce`) against the `DXGI_FORMAT` enum. Mbappinho's finding holds, and the rest of the table is right: - Correct (UINT / SINT): 3, 4 (R32G32B32A32), 7, 8 (R32G32B32), 12, 14 (R16G16B16A16), 17, 18 (R32G32), 25 (R10G10B10A2_UINT), 30, 32 (R8G8B8A8), 42, 43 (R32), 50, 52 (R8G8), 57, 59 (R16), 62, 64 (R8). - Wrong: 37 is `R16G16_SNORM` and 39 is `R32_TYPELESS`. The pair should be **36** (`R16G16_UINT`) and **38** (`R16G16_SINT`). As it stands, an R16G16_UINT/SINT target keeps blending on, and an R16G16_SNORM target loses it. AI-assisted (Claude Code). Checked against the enum only; nothing run.
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-25 14:03 UTC · original

You are right, and the SDK header settles it: dxgiformat.h in 10.0.26100.0 has 33 TYPELESS, 34 FLOAT, 35 UNORM, 36 UINT, 37 SNORM, 38 SINT, and 39 is R32_TYPELESS — I had the pair one off, so an R16G16_UINT target kept blending on (the very refusal this change exists to prevent) and an R16G16_SNORM one lost it. Fixed in de4f637: the table now carries 36 and 38, the test's two cases follow, and the comment says which formats they are.

That also makes the earlier form of this table in victory-gpu/src/twin.rs (fn integer, which I did not touch) worth a look: it lists 36 and 38 — right for R16G16 — but the call site there only ever passes single-channel R16/R32/R8 views, so it is not affected either way.

Thanks for checking it against the enum rather than against my comment; the whole point of the table is that a wrong entry is invisible until a title uses that format.

**@⁠Calvix2k** on GitHub · 2026-11-25 14:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/2346#issuecomment-7164696736) You are right, and the SDK header settles it: `dxgiformat.h` in 10.0.26100.0 has **33 TYPELESS, 34 FLOAT, 35 UNORM, 36 UINT, 37 SNORM, 38 SINT**, and 39 is `R32_TYPELESS` — I had the pair one off, so an `R16G16_UINT` target kept blending on (the very refusal this change exists to prevent) and an `R16G16_SNORM` one lost it. Fixed in `de4f637`: the table now carries 36 and 38, the test's two cases follow, and the comment says which formats they are. That also makes the earlier form of this table in `victory-gpu/src/twin.rs` (`fn integer`, which I did not touch) worth a look: it lists 36 and 38 — right for R16G16 — but the call site there only ever passes single-channel R16/R32/R8 views, so it is not affected either way. Thanks for checking it against the enum rather than against my comment; the whole point of the table is that a wrong entry is invisible until a title uses that format.
Author
Owner

@⁠ThatZaliaSGuy on GitHub · 2026-11-25 14:19 UTC · original

Reviewed next to #1152 and #2042, which change the same code. One case this version misses: when the blend state has IndependentBlendEnable = FALSE, D3D12 applies RenderTarget[0] to every target. Clearing BlendEnable on an integer slot's own entry then has no effect (slot ≥ 1: the pipeline is still refused), or turns blending off for every target (slot 0). #1152 and #2042 spread target 0's state to each slot and set IndependentBlendEnable first. #1152 is the oldest, has tests and is confirmed on two AMD cards, so consolidating there may be simplest.

**@⁠ThatZaliaSGuy** on GitHub · 2026-11-25 14:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/2346#issuecomment-7165093050) Reviewed next to #1152 and #2042, which change the same code. One case this version misses: when the blend state has `IndependentBlendEnable = FALSE`, D3D12 applies `RenderTarget[0]` to every target. Clearing `BlendEnable` on an integer slot's own entry then has no effect (slot ≥ 1: the pipeline is still refused), or turns blending off for every target (slot 0). #1152 and #2042 spread target 0's state to each slot and set `IndependentBlendEnable` first. #1152 is the oldest, has tests and is confirmed on two AMD cards, so consolidating there may be simplest.
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-25 14:35 UTC · original

Closing as the duplicate of #1152 (pablogonz12), which is the better of the three implementations: it names the DXGI formats instead of numbering them (the trap that had R16G16_UINT/SINT one off in my first revision) and it handles IndependentBlendEnable = FALSE, where D3D12 applies target 0 to every slot — my version cleared the integer slot's own entry, which either does nothing (slot ≥ 1) or turns blending off for every target (slot 0).

The parts worth carrying into #1152 are in my comment there: describe() has to see the blend state the pipeline is made from (the library name is made from that text, and LoadPipeline compares descriptions — the #1683 failure), plus the in-game A/B (white haze to a lit interior) as evidence for what the change does on the title.

One correction to my own work is worth recording here too: the format table I shipped in de4f637 is right (36/38) but was wrong for one revision — checked against dxgiformat.h now, and it is the reason #1152's enum names are the only way to be sure.

**@⁠Calvix2k** on GitHub · 2026-11-25 14:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/2346#issuecomment-7165522470) Closing as the duplicate of #1152 (pablogonz12), which is the better of the three implementations: it names the DXGI formats instead of numbering them (the trap that had `R16G16_UINT`/`SINT` one off in my first revision) and it handles `IndependentBlendEnable = FALSE`, where D3D12 applies target 0 to every slot — my version cleared the integer slot's own entry, which either does nothing (slot ≥ 1) or turns blending off for every target (slot 0). The parts worth carrying into #1152 are in my comment there: `describe()` has to see the blend state the pipeline is made from (the library name is made from that text, and `LoadPipeline` compares descriptions — the #1683 failure), plus the in-game A/B (white haze to a lit interior) as evidence for what the change does on the title. One correction to my own work is worth recording here too: the format table I shipped in `de4f637` is right (36/38) but was wrong for one revision — checked against `dxgiformat.h` now, and it is the reason #1152's enum names are the only way to be sure.

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/Marvisak--VIctory!2346
No description provided.