GPU: blending off on integer render targets #2344

Closed
Calvix2k wants to merge 2 commits from upstream-pr/2346 into main
Calvix2k commented 2026-11-25 11:14:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T11:14:26Z.


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.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6603216610 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2346). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-25T11:14:26Z. --- 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.
DenRakEiw commented 2026-11-25 12:03:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T11:25:20Z.

Review: APPROVED


Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:

  • Clearing blend enable only on integer render targets cleanly prevents D3D12 PSO validation rejection while leaving float/normalized targets untouched.
  • cargo test -p victory-gpu pipeline::host::tests: 3/3 passed on RTX 5090, 3/3 passed on WARP (including blending_is_cleared_only_on_integer_targets).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: 0 warnings.
  • cargo xtask policy: 183 files ok.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6056746537 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2346#pullrequestreview-6056746537). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T11:25:20Z. **Review:** APPROVED --- Verified against `origin/main` (`940d32f`) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP: - Clearing blend enable only on integer render targets cleanly prevents D3D12 PSO validation rejection while leaving float/normalized targets untouched. - `cargo test -p victory-gpu pipeline::host::tests`: 3/3 passed on RTX 5090, 3/3 passed on WARP (including `blending_is_cleared_only_on_integer_targets`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: 0 warnings. - `cargo xtask policy`: 183 files ok. AI-assisted (Gemini 4 Neon).
DrDarkDK commented 2026-11-25 12:03:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-25T11:37:17Z.

Review: CHANGES_REQUESTED


I reproduced a remaining PSO rejection at 7a338ce on native Windows with an RTX 4070 Ti (621.01) and WARP.

The synthetic pixel shader writes to R8G8B8A8_UNORM at slot 0 and R8_UINT at slot 1. With blending enabled in slot 0 and IndependentBlendEnable = FALSE, host_blend() clears slot 1’s BlendEnable, but CreateGraphicsPipelineState still returns E_INVALIDARG on both adapters. The debug layer identifies blending on slot 1’s R8_UINT target.

Setting IndependentBlendEnable = TRUE with the same per-target entries lets the PSO create on both adapters. Could host_blend() expand slot 0’s shared state into the active slots before clearing blending on integer targets, so the normalized target keeps blending?

Synthetic PSO creation only. No game data used.

AI-assisted with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:review:6056898292 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2346#pullrequestreview-6056898292). Originally posted by [DrDarkDK](https://github.com/DrDarkDK) on 2026-11-25T11:37:17Z. **Review:** CHANGES_REQUESTED --- I reproduced a remaining PSO rejection at `7a338ce` on native Windows with an RTX 4070 Ti (621.01) and WARP. The synthetic pixel shader writes to `R8G8B8A8_UNORM` at slot 0 and `R8_UINT` at slot 1. With blending enabled in slot 0 and `IndependentBlendEnable = FALSE`, `host_blend()` clears slot 1’s `BlendEnable`, but `CreateGraphicsPipelineState` still returns `E_INVALIDARG` on both adapters. The debug layer identifies blending on slot 1’s `R8_UINT` target. Setting `IndependentBlendEnable = TRUE` with the same per-target entries lets the PSO create on both adapters. Could `host_blend()` expand slot 0’s shared state into the active slots before clearing blending on integer targets, so the normalized target keeps blending? Synthetic PSO creation only. No game data used. *AI-assisted with Codex.*
catminou4 commented 2026-11-25 12:03:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T11:52:01Z.

Review: COMMENTED


Blending cleared on integer render targets (D3D12 refuses E_INVALIDARG pipelines otherwise). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Includes the UINT/SINT format table; matches D3D12 rules.

<!-- greyfinch-sync:Marvisak/VIctory:review:6057090214 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2346#pullrequestreview-6057090214). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T11:52:01Z. **Review:** COMMENTED --- Blending cleared on integer render targets (D3D12 refuses E_INVALIDARG pipelines otherwise). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Includes the UINT/SINT format table; matches D3D12 rules.
Calvix2k commented 2026-11-25 12:03:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T11:36:54Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7161275204 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2346#issuecomment-7161275204). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-25T11:36:54Z. --- 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.
Mbappinho commented 2026-11-25 14:07:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Mbappinho on 2026-11-25T13:13:22Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7163464562 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2346#issuecomment-7163464562). Originally posted by [Mbappinho](https://github.com/Mbappinho) on 2026-11-25T13:13:22Z. --- 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.
upipibi commented 2026-11-25 14:07:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-25T13:22:43Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7163689315 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2346#issuecomment-7163689315). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-25T13:22:43Z. --- 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.
Calvix2k commented 2026-11-25 14:07:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T14:03:41Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7164696736 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2346#issuecomment-7164696736). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-25T14:03:41Z. --- 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.
upstream-sync closed this pull request 2026-11-25 15:03:06 +00:00
ThatZaliaSGuy commented 2026-11-25 15:04:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ThatZaliaSGuy on 2026-11-25T14:19:10Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7165093050 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2346#issuecomment-7165093050). Originally posted by [ThatZaliaSGuy](https://github.com/ThatZaliaSGuy) on 2026-11-25T14:19:10Z. --- 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.
Calvix2k commented 2026-11-25 15:04:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T14:35:52Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7165522470 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2346#issuecomment-7165522470). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-25T14:35:52Z. --- 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

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