Skip to content

GPU: blending off on integer render targets - #2346

Open
Calvix2k wants to merge 1 commit into
Marvisak:mainfrom
Calvix2k:codex/gpu-blend-integer-targets
Open

Calvix2k wants to merge 1 commit into
Marvisak:mainfrom
Calvix2k:codex/gpu-blend-integer-targets

Conversation

@Calvix2k

Copy link
Copy Markdown
Contributor

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 (GPU tests: placed R32_UINT -> R9G9B9E5 view does not share its host texture (Windows 10, RX 7800 XT) #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.

A title may describe blending on a render target whose format holds
integers (this title's slot 2 is R8_UINT). The console's blend hardware
ignores it; D3D12 refuses the whole pipeline instead — CreatePipelineState
fails with E_INVALIDARG, and with the debug layer on:

  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.

so every draw of that pipeline was dropped. `GraphicsState::host_blend()`
clears BlendEnable for exactly those slots before the graphics and mesh
pipelines are made, and `describe()` uses the same state so that a pipeline
library name and the description stored under it agree.

@DenRakEiw DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants