GPU: a pipeline that blends an integer target is made instead of refused #2790
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!2790
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2790/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?
@HoLa-Lee on GitHub · 2026-11-25 20:35 UTC · original
HoLa-Lee:gpu/integer-target-blend→main· +199 −3 · 1 files · 1 commits · closed without mergingWhat this is
On the card, one graphics pipeline of the intro is refused and every one of its draws is lost. With the debug layer on (
VICTORY_D3D12_DEBUG=1), the refusal names itself:CreateGraphicsPipelineStateanswersE_INVALIDARG("参数错误"), so the pipeline - a mesh/pixel pair,[mesh f5e50eb2108c425b, pixel ce3f0432a08f1d35]- is refused whole.The state is the console's, where the renderer allows a blend on an integer target. D3D12 does not, and NVIDIA enforces it.
What the change does
GraphicsState::settle_integer_targetsturnsBlendEnableoff for render target slots whose format is an integer one, and only for those. It runs once, after the stream is read and before the state is described - so a pipeline's name in the library still says what is actually made - and before the graphics, mesh or depth-bounds pipeline is built.ONE/ZERO, its usual static state) the picture is the same.Evidence
The refused state, refused then made - on the card. Built through the same code on a tree that has the device tests: the device refuses an
R8_UINTtarget with blending enabled, and makes the same pipeline once that slot's blend is off. This PR carries the half of that which needs no device harness:The state test,
a_blend_on_an_integer_target_is_turned_off_for_that_slot_onlypins the slots: the integer target loses its blend, the two float targets keep theirs, a slot pastNumRenderTargetsis untouched, the factors survive, settling twice changes nothing, and a state the title wrote with the blend already off settles to the same description (so it shares the pipeline name, as it should - the pipelines are identical).On the title, same keys, same 300 s, old binary against new:
blend0(before)blend1(after)host mesh pipeline refusedlinesblending is off for those slots slots=[(2, 62)](62 isR8_UINT)One correction worth stating
The frame line's
dropped … without a host pipelinecounter is not the measure of this fix. Its largest term is dispatches of the ray-tracing structure builder, which are dropped on purpose (VICTORY_BVH_BUILDER=1gates the builder, andpipeline.rsdocuments why: a 32-lane host cannot build them whole, and #2311 measured a card hung in exactly that dispatch): 200 to 1,400 a frame, in both runs. So the counter barely moves; what moves is the refused pipeline, listed above.Checks
cargo test -p victory-gpu --lib --profile diag --features diagnosticsdynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_views- the known#1744view-heap pair on an NVIDIA host (FIND-9: this card caps shader-visible view heaps at 1,000,000 andHEAP_VIEWSis 2^21); they fail without this change toocargo clippy -p victory-gpu --all-features -- -D warningsRTX 4080 SUPER, Rust 1.98.1, Windows 11.
What is not done
Where a blend was not a plain write, this changes what those draws put in that
R8_UINTtarget: it becomes an overwrite. If that turns out to matter, the emulation belongs in the shader (fetch, blend, store) rather than in the state, andsettle_integer_targetsis the place to hang it.One graphics pipeline of the intro is refused on the card, and with the debug layer on the refusal says why: 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. ID3D12Device::CreateGraphicsPipelineState: Pixel Shader output 'SV_Target2' has type that is NOT float, while the corresponding Output Merger RenderTarget slot [2] has blending enabled. and the pipeline - a mesh/pixel pair, `[mesh f5e50eb2108c425b, pixel ce3f0432a08f1d35]` - comes back `E_INVALIDARG` ("参数错误") with every one of its draws lost. The frame line's `dropped` counter is not where that shows: its largest term is dispatches of the ray-tracing structure builder, dropped on purpose (`VICTORY_BVH_BUILDER=1` gates the builder), 200 to 1,400 a frame. The evidence here is the pipeline. The state is the console's, where the renderer allows a blend on an integer target; D3D12 does not. `GraphicsState::settle_integer_targets` turns the blend off for those slots alone, before the state is described (so the library name still says what is made) and before any pipeline is built. Where the title's blend was a write - `ONE`/`ZERO`, its usual static state - the picture is the same; where it was not, the slot is overwritten rather than blended. Only `BlendEnable` changes: the blend factors are left as the title wrote them. `IndependentBlendEnable` decides what "that slot" means. With it off - D3D12's default - `RenderTarget[0]` applies to every bound slot and `RenderTarget[1..]` is never read, so a slot cannot be settled by itself: slot 1 may say it does not blend while slot 0's state blends it. Then slot 0's state is copied to every slot and the slots are made independent, which leaves the float slots blending exactly as the title asked while the integer slot is turned off on its own. When every bound slot is integer, nothing has to become independent: slot 0's blend goes off and the shared state goes with it. Measured on an RTX 4080 SUPER. Three state tests pin the slots: the integer one loses its blend, the float ones keep theirs, a slot past `NumRenderTargets` is untouched, the factors survive, settling twice changes nothing; the shared case takes the slots apart with slot 0's state on each, whichever slot is the integer one; and a state that blends nothing is left exactly as it was. The device agrees: built through the same code where the device tests live, a shared state over an `R8_UINT` slot is refused by the device and made once the slots are apart. A card run with the same keys 300 s either side went from 20 `host mesh pipeline refused` lines to none, gaining one line naming `slots=[(2, 62)]` - format 62 is `R8_UINT`. `cargo test -p victory-gpu --lib --profile diag --features diagnostics`: 198 passed, 2 failed, 1 ignored - the two failures are the known #1744 view-heap pair on an NVIDIA host (FIND-9: this device caps shader-visible view heaps at 1,000,000, `HEAP_VIEWS` is 2^21), and they fail here without this change too. `cargo clippy -p victory-gpu --all-features -- -D warnings` is clean.@kotekompotek on GitHub · 2026-11-25 20:38 UTC · original
+68k across 583 files is a whole-fork diff, not a reviewable change - third of this shape after #2643 and #2758. The integer-blend fix in the title may be real, but nobody can verify what else is in here; please split it into focused PRs.
@fuzeofficlal on GitHub · 2026-11-25 20:46 UTC · original
Reviewed and tested
bb69da3bon Windows 11 (RTX 5090 + WARP). Two blockers before merge:1. Branch hygiene & policy failures
ffe310eb, 583 files changed,+67,983/-1,808), conflicts withmain(13f91ca), bundles build artifacts undertarget-merge/diag/andtools/disasm_rva.py, failscargo xtask policy(548 violations), and failscargo clippy --all-targets -- -D warnings. This needs to be rebased onto13f91caas a clean commit containing only thepipeline/host.rschange and tests.2. D3D12
IndependentBlendEnable == FALSEspec bug insettle_integer_targetsIn D3D12, when
self.blend.IndependentBlendEnableisfalse(the default), the runtime appliesRenderTarget[0]'s blend state to every bound render target0..NumRenderTargetsand ignoresRenderTarget[1..7]:RenderTarget[0].BlendEnable = true, RT2 isR8_UINTwithRenderTarget[2].BlendEnable = false, andIndependentBlendEnable = false,settle_integer_targetsinspectsRenderTarget[2].BlendEnable(false), makes no change, and D3D12 still rejects the PSO because RT0's blend applies to RT2.BlendEnable = true, RT1 is float, andIndependentBlendEnable = false, clearingRenderTarget[0].BlendEnablewithout first settingIndependentBlendEnable = trueand copyingRenderTarget[0]into the other active slots silently disables blending on float RT1 as well.Handling
IndependentBlendEnable == falseby expandingRenderTarget[0]across0..rt_countand settingIndependentBlendEnable = truewhenever any non-zero slot is an integer target (while RT0 blends) or RT0 is integer (while any other slot is float) will cover both MRT cases cleanly.(On
bb69da3b, the two new testsa_blend_on_an_integer_target_is_turned_off_for_that_slot_onlyanda_pipeline_that_blends_an_integer_target_is_refused_until_the_blend_is_offpass on RTX 5090 and WARP.)@fuzeofficlal on GitHub · 2026-11-25 21:31 UTC · original
Re-verified
f00d527fon Windows 11 (RTX 5090 + WARP,--features diagnostics):+107/-3incrates/victory-gpu/src/pipeline/host.rs, cleangit merge-treeagainstorigin/main13f91ca).cargo xtask policy: 184 files ok;cargo clippy(default &--features diagnostics): 0 warnings; RTX 5090pipeline::host::tests3/3 passed; WARP full suite 199/199 passed (1 ignored).However, the
IndependentBlendEnable == FALSEbug from the previous review is still unaddressed insettle_integer_targets:IndependentBlendEnable == false, RT0 is a float target withRenderTarget[0].BlendEnable = true, and RT2 isR8_UINTwithRenderTarget[2].BlendEnable = false, D3D12 appliesRenderTarget[0]to all active slots0..NumRenderTargetsand still rejects the PSO withE_INVALIDARG, whilesettle_integer_targetsseesRenderTarget[2].BlendEnable == falseand returns0without changing anything.IndependentBlendEnable == false, RT0 is an integer target withBlendEnable = true, and RT1 is a float target, clearingRenderTarget[0].BlendEnablewithout settingIndependentBlendEnable = trueand copying the originalRenderTarget[0]to the other active slots also turns off blending on float RT1.Minor nits:
takes_blendingincludesDXGI_FORMAT_R9G9B9E5_SHAREDEXP(which is not an integer format and not a valid RTV format), line 769 removes indentation onmesh_pipeline's doc comment, and the test only exercisesIndependentBlendEnable == trueon CPU without creating a host PSO. (For reference, #2801 handlesIndependentBlendEnable == falseexpansion, reusestwin::integer, preservesGraphicsState::blend/describe(), and tests real PSO creation on D3D12.)0x80070057/ D3D12id=676):BlendOp=MAXenabled onDXGI_FORMAT_R8_UINTRT slot 2 ([mesh f5e50eb2108c425b, pixel ce3f0432a08f1d35]) #2775@HoLa-Lee on GitHub · 2026-11-25 22:24 UTC · original
@fuzeofficlal - you were right about both halves, and it is fixed in
69d483f.settle_integer_targetsnow readsIndependentBlendEnablefirst:RenderTarget[0]applies to every bound slot andRenderTarget[1..]is never read, so a slot cannot be settled by itself. If any bound slot is integer and slot 0 blends, slot 0's state is copied to every slot andIndependentBlendEnableis set - which fixes your two cases at once:R8_UINTslot 2 with its ownBlendEnablefalse now settles (before: returns 0 and the PSO is still refused);On the device, not only in the state. I built your missed disable case through the same code on an RTX 4080 SUPER (a pixel shader writing
SV_Target0float andSV_Target1uint,NumRenderTargets = 2,R8G8B8A8_UNORM+R8_UINT,IndependentBlendEnable = false, slot 0 blending, slot 1 not):E_INVALIDARGsettle_integer_targets()IndependentBlendEnabletrueThat device test lives where the device harness is; this PR's tree has no
dxc/host()test helpers, so the PR carries the three state tests and the device result is above.@kotekompotek - the +68k diff was the branch, not the change. It was cut from a tree that had a fork merge in it.
f00d527and now69d483fare cut from13f91caand touch one file: +199/-3 incrates/victory-gpu/src/pipeline/host.rs.State of the three tests now:
a_blend_on_an_integer_target_is_turned_off_for_that_slot_only(per-slot, independent case),a_shared_blend_state_stops_sharing_so_an_integer_slot_can_be_settled(your four cases: mixed with slot 0 float, mixed with slot 0 integer, all integer, slot 0 quiet), and the device test above.cargo test -p victory-gpu --lib --profile diag --features diagnosticson this tree: 198 passed, 2 failed, 1 ignored - the 2 are the#1744view-heap pair (FIND-9: this card caps shader-visible view heaps at 1,000,000,HEAP_VIEWSis 2^21) and fail without the change too.cargo clippy -p victory-gpu --all-features -- -D warnings: clean.@Marvisak on GitHub · 2026-11-25 23:14 UTC · original
Automated triage for the maintainers.
This PR no longer merges cleanly into current
main(it was cut from13f91ca;mainhas moved since): it conflicts incrates/victory-gpu/src/pipeline/host.rs. Its content will be reviewed once it is rebased. When you rebase, note that #2801 also changes integer render targets' blending in the same area.Generated by Claude Code
@HoLa-Lee on GitHub · 2026-11-25 23:28 UTC · original
The picture with the blend turned off: same screen, same pixels. Measured.
You asked what happens to what those draws put in that
R8_UINTtarget. Two 300 s runs of the intro, same keys, same seed,VICTORY_FAST=1+STAGE_MB=64+GATHER=1,VICTORY_CAPTUREon so every power-of-two frame is written to half-resolution PNG, RTX 4080 SUPER:Frame 2048 is not a visual difference from the change: the two runs are on different screens there - one shows the Korean legal notices page (
법적 공지), the other the English one (LEGAL NOTICES) - so the scripted keys landed one page apart. The captures make that plain. Frame 4096 differs in 228 pixels (0.011%, a few glyph edges).So: on every screen both runs reached together, the frames are pixel-identical. Whatever that slot's blend was contributing, turning it off did not change the picture on the screens we could capture.
What this does and does not say
R8_UINTtarget may be a mask or a coverage buffer that no captured screen reads back. A world frame with something the target feeds would be the stronger test, and that needs getting past the intro, which this machine does not yet do.E_INVALIDARG→Ok), and the two runs' logs go from 20host mesh pipeline refusedlines to none.Reproduce:
cargo test -p victory-gpu --lib --profile diag --features diagnostics pipeline::host::testsand a run withVICTORY_CAPTURE=<folder>; the comparison script is 30 lines of Pillow, and the numbers above are its output.@HoLa-Lee on GitHub · 2026-11-25 23:32 UTC · original
Closing: main now does this itself, in
a7cb47c(GPU: no blending on integer render targets in host pipelines (#1152), Pablo González, 2026-11-25 22:49 UTC).host_blendinpipeline/host.rsturns blending off on integer targets and, "with one description for all targets, each target gets its own copy so the others keep theirs" - the same two halves this PR had: the per-slot disable, and theIndependentBlendEnablehandling @fuzeofficlal asked for in review. There is nothing left here worth merging.What this thread did contribute, for the record:
R8_UINTat slot 2,E_INVALIDARGfromCreateGraphicsPipelineState) and the counts of draws it cost;VICTORY_CAPTUREframe: 12 of 13 pixel-identical, the one that differed was a different screen);IndependentBlendEnable == FALSEcase, whichhost_blendalso has to get right and does (blends(i)reads slot 0 when the slots share, then the shared state is copied out and the integer slots are turned off).The one thing
a7cb47chas no test for ishost_blenditself. That is worth a small PR of its own and I will send it rather than leave the function unguarded: the six cases are pure function in, function out, no GPU needed.@HoLa-Lee on GitHub · 2026-11-25 23:39 UTC · original
One correction to what I wrote above:
a7cb47cdoes ship tests forhost_blend-integer_targets_do_not_blend(bothIndependentBlendEnablevalues, slot 0 and 1 keeping theirs, slot 2 off, the title's factors kept) andblend_states_without_integer_blending_are_kept(no integer target, an integer target that does not blend, integer formats pastNumRenderTargets). So there is nothing for me to add there either; I looked at the merged file after posting. The closing stands for the right reason.Pull request closed