GPU: blending off on integer render targets #2346
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2346
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2346/head"
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?
@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 mergingThe 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.@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:
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.@Mbappinho on GitHub · 2026-11-25 13:13 UTC · original
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.
@upipibi on GitHub · 2026-11-25 13:22 UTC · original
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.
@Calvix2k on GitHub · 2026-11-25 14:03 UTC · original
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.
@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 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.@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/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