GPU: a pipeline that blends an integer target is made instead of refused #2788
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2790"
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 HoLa-Lee on 2026-11-25T20:35:22Z.
What 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.Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T20:38:55Z.
+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.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T20:46:55Z.
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.)Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T21:31:25Z.
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.)Imported from Marvisak/VIctory. Originally posted by HoLa-Lee on 2026-11-25T22:24:14Z.
@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.Imported from Marvisak/VIctory. Originally posted by AwsAli05 on 2026-11-25T23:06:54Z.
Review: COMMENTED
Current
mainhas the integer-target blend fix from #1152, including preserving the float target's blend state when independent blending has to be enabled. On842b0cbthe merge preview for this branch conflicts inpipeline/host.rs.I compared the format lists. The remaining behavior this branch adds is treating
R9G9B9E5_SHAREDEXPas non-blendable. Can the branch use main's existing helper and isolate that format, with a test for the actual graphics pipeline? The current replacement also omits main'sR32G32B32_UINTandR32G32B32_SINTcases.AI-assisted static review.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T23:14:14Z.
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
Imported from Marvisak/VIctory. Originally posted by HoLa-Lee on 2026-11-25T23:28:26Z.
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.Imported from Marvisak/VIctory. Originally posted by HoLa-Lee on 2026-11-25T23:32:14Z.
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.Imported from Marvisak/VIctory. Originally posted by HoLa-Lee on 2026-11-25T23:39:32Z.
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