GPU: blending off on integer render targets #2344
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2346"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T11:14:26Z.
The debug layer names the cause exactly:
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()clearsBlendEnablefor exactly the render targets whose format is an integer one (_UINT/_SINT, DXGI 3..64 —R8_UINTis 30 in DXGI numbering,R16G16_UINT37), 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_UINTandR16G16_SINTlose it; a slot pastNumRenderTargetsis 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 withoutID3D12Device10(#1999). clippy-D warningsclean.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.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:cargo test -p victory-gpu pipeline::host::tests: 3/3 passed on RTX 5090, 3/3 passed on WARP (includingblending_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).
Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-25T11:37:17Z.
Review: CHANGES_REQUESTED
I reproduced a remaining PSO rejection at
7a338ceon native Windows with an RTX 4070 Ti (621.01) and WARP.The synthetic pixel shader writes to
R8G8B8A8_UNORMat slot 0 andR8_UINTat slot 1. With blending enabled in slot 0 andIndependentBlendEnable = FALSE,host_blend()clears slot 1’sBlendEnable, butCreateGraphicsPipelineStatestill returnsE_INVALIDARGon both adapters. The debug layer identifies blending on slot 1’sR8_UINTtarget.Setting
IndependentBlendEnable = TRUEwith the same per-target entries lets the PSO create on both adapters. Couldhost_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.
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.
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:
The
R8_UINTslot 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
BlendEnableis 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.Imported from Marvisak/VIctory. Originally posted by Mbappinho on 2026-11-25T13:13:22Z.
The integer format table in
integer_target(at7a338ce) is off by one for theR16G16pair:In DXGI,
R16G16_UINTis 36 andR16G16_SINTis 38. 37 isR16G16_SNORMand 39 isR32_TYPELESS. So with this table:R16G16_UINTorR16G16_SINTtarget is still refused (E_INVALIDARG);R16G16_SNORMtargets.The test does not catch it because it uses the same numbers (
[29u32, 10, 62, 37, 39, 24], commented asR16G16_UINT, R16G16_SINT). Matching on the named constants (DXGI_FORMAT_R16G16_UINT, ...) instead of numbers avoids this; a test that walks every_UINT/_SINTconstant 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.
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:99at7a338ce) against theDXGI_FORMATenum. Mbappinho's finding holds, and the rest of the table is right:R16G16_SNORMand 39 isR32_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.
Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T14:03:41Z.
You are right, and the SDK header settles it:
dxgiformat.hin 10.0.26100.0 has 33 TYPELESS, 34 FLOAT, 35 UNORM, 36 UINT, 37 SNORM, 38 SINT, and 39 isR32_TYPELESS— I had the pair one off, so anR16G16_UINTtarget kept blending on (the very refusal this change exists to prevent) and anR16G16_SNORMone lost it. Fixed inde4f637: 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.
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 appliesRenderTarget[0]to every target. ClearingBlendEnableon 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 setIndependentBlendEnablefirst. #1152 is the oldest, has tests and is confirmed on two AMD cards, so consolidating there may be simplest.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/SINTone off in my first revision) and it handlesIndependentBlendEnable = 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, andLoadPipelinecompares 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
de4f637is right (36/38) but was wrong for one revision — checked againstdxgiformat.hnow, and it is the reason #1152's enum names are the only way to be sure.Pull request closed