GPU: no blending on integer render targets #715

Open
KyleS98 wants to merge 2 commits from upstream-pr/715 into main
KyleS98 commented 2026-11-25 05:25:29 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by KyleS98 on 2026-11-25T05:25:29Z.


A pipeline whose blend description enables blending on an integer render target (UINT/SINT) is created as the title describes it. D3D12 treats that as an error, and what the driver writes to the target is undefined. On an RTX 3090 Ti the debug layer (VICTORY_D3D12_DEBUG=1) reports it for a G-buffer pass of the prologue:

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)

The console's blender passes integer targets through, so this PR does the same on the host.

Change

  • GraphicsState::host_blend turns blending (and logic ops) off for every integer render-target slot.
  • When the title's description is not independent, D3D12 applies RenderTarget[0] to every slot. In that case the first slot's description is spread to all slots before the integer ones are switched off, so the other targets keep exactly the blend they had.
  • Float and UNORM targets keep the title's blend unchanged. When no integer slot blends, the description is returned untouched.
  • Used by the plain graphics pipeline, the mesh stream, and the depth-bounds stream.
  • VICTORY_FIX_INTBLEND=0 restores the old behaviour, for comparisons.

Testing

  • 4 new unit tests (pipeline::host::blend_tests): shared and independent descriptions, a non-blending integer slot, and float-only targets. All pass.
  • cargo clippy -p victory-gpu --all-targets adds no new warnings. The existing ones in resource.rs, draw.rs and indirect.rs are unchanged.
  • In-game (RTX 3090 Ti, Series X profile, diag build): the debug-layer message is gone and the prologue renders. I have not isolated a visible difference from this change alone; it was tested together with other changes.

AI-assisted (Claude Code, Claude Opus 5.5). No game data attached.

🤖 Generated with Claude Code

<!-- greyfinch-sync:fxceless/victory-fork:issue:6597849640 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/715). Originally posted by [KyleS98](https://github.com/KyleS98) on 2026-11-25T05:25:29Z. --- A pipeline whose blend description enables blending on an integer render target (UINT/SINT) is created as the title describes it. D3D12 treats that as an error, and what the driver writes to the target is undefined. On an RTX 3090 Ti the debug layer (`VICTORY_D3D12_DEBUG=1`) reports it for a G-buffer pass of the prologue: > `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) The console's blender passes integer targets through, so this PR does the same on the host. ### Change - `GraphicsState::host_blend` turns blending (and logic ops) off for every integer render-target slot. - When the title's description is not independent, D3D12 applies `RenderTarget[0]` to every slot. In that case the first slot's description is spread to all slots before the integer ones are switched off, so the other targets keep exactly the blend they had. - Float and UNORM targets keep the title's blend unchanged. When no integer slot blends, the description is returned untouched. - Used by the plain graphics pipeline, the mesh stream, and the depth-bounds stream. - `VICTORY_FIX_INTBLEND=0` restores the old behaviour, for comparisons. ### Testing - 4 new unit tests (`pipeline::host::blend_tests`): shared and independent descriptions, a non-blending integer slot, and float-only targets. All pass. - `cargo clippy -p victory-gpu --all-targets` adds no new warnings. The existing ones in `resource.rs`, `draw.rs` and `indirect.rs` are unchanged. - In-game (RTX 3090 Ti, Series X profile, diag build): the debug-layer message is gone and the prologue renders. I have not isolated a visible difference from this change alone; it was tested together with other changes. AI-assisted (Claude Code, Claude Opus 5.5). No game data attached. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
avt0m4t48 commented 2026-11-25 06:06:38 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by avt0m4t48 on 2026-11-25T05:32:11Z.


I independently checked the integer-target blend change at c2eb4c4c0a3a5724ae9edd5cde0ded7d13de7f76 against its parent and the listed base 310c6eb6c16822ab95076aad61fce19bba86bb98.

  • A standalone CPU fixture used the PR's host_blend body and the Windows bindings' descriptor fields and format constants. It varied 21 signed and unsigned integer formats across all eight slots with shared and independent blending. Base kept blending enabled in all 336 affected cases. The PR passed all 336, clearing the integer slot's blend flag and preserving the other active slots' effective blend factors, operations, and write masks.
  • Six unchanged-descriptor controls passed at both revisions, covering float and normalized targets, an inactive integer slot, an integer slot with blending already disabled, a shared logic-only descriptor, and zero active slots. Both opt-out controls returned the original descriptor with VICTORY_FIX_INTBLEND=0.
  • The plain graphics descriptor, its depth-bounds stream, and both mesh stream branches get the normalized blend state. cargo check --locked --offline -p victory-gpu --tests --features diagnostics,blake3/pure --target x86_64-pc-windows-msvc passed at both revisions. WARP, physical GPU execution, and game data were outside these checks.

One cache interaction showed up in source review. The pipeline name still hashes the raw blend description, so an affected descriptor can use the same library name before and after normalization, including across the opt-out toggle. If a previous run successfully stored that name with different blend state, D3D12's descriptor matching and no-overwrite rule suggest a persistent miss and recreate for the affected entry. That is a source-level finding. I did not measure it with a Windows pipeline library.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7153869497 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/715#issuecomment-7153869497). Originally posted by [avt0m4t48](https://github.com/avt0m4t48) on 2026-11-25T05:32:11Z. --- I independently checked the integer-target blend change at `c2eb4c4c0a3a5724ae9edd5cde0ded7d13de7f76` against its parent and the listed base `310c6eb6c16822ab95076aad61fce19bba86bb98`. - A standalone CPU fixture used the PR's `host_blend` body and the Windows bindings' descriptor fields and format constants. It varied 21 signed and unsigned integer formats across all eight slots with shared and independent blending. Base kept blending enabled in all 336 affected cases. The PR passed all 336, clearing the integer slot's blend flag and preserving the other active slots' effective blend factors, operations, and write masks. - Six unchanged-descriptor controls passed at both revisions, covering float and normalized targets, an inactive integer slot, an integer slot with blending already disabled, a shared logic-only descriptor, and zero active slots. Both opt-out controls returned the original descriptor with `VICTORY_FIX_INTBLEND=0`. - The plain graphics descriptor, its depth-bounds stream, and both mesh stream branches get the normalized blend state. `cargo check --locked --offline -p victory-gpu --tests --features diagnostics,blake3/pure --target x86_64-pc-windows-msvc` passed at both revisions. WARP, physical GPU execution, and game data were outside these checks. One cache interaction showed up in source review. The [pipeline name still hashes the raw blend description](https://github.com/fxceless/victory-fork/blob/c2eb4c4c0a3a5724ae9edd5cde0ded7d13de7f76/crates/victory-gpu/src/pipeline/host.rs#L620), so an affected descriptor can use the same library name before and after normalization, including across the opt-out toggle. If a previous run successfully stored that name with different blend state, D3D12's [descriptor matching](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12pipelinelibrary-loadgraphicspipeline) and [no-overwrite rule](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12pipelinelibrary-storepipeline) suggest a persistent miss and recreate for the affected entry. That is a source-level finding. I did not measure it with a Windows pipeline library.
KyleS98 commented 2026-11-25 06:06:39 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by KyleS98 on 2026-11-25T05:37:59Z.


Thanks @avt0m4t48, that's right: the library name was still built from the title's blend description. Fixed in 9478005 ("GPU: name pipelines by the host blend description").

  • GraphicsState::describe, which feeds both the library name and the early-start key, now formats host_blend() instead of the raw blend.
  • Two title descriptions that the host turns into the same pipeline now share a name. Different host pipelines (a float slot's blend differs, or the VICTORY_FIX_INTBLEND toggle changes the result) get different names, so a stored entry can't be matched against a mismatched description.
  • New unit test the_name_follows_the_host_blend covers both directions. The 5 blend tests pass.

As in your note, I haven't measured the library behaviour on Windows. Entries stored under the old names simply stop being looked up.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:fxceless/victory-fork:comment:7153980916 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/715#issuecomment-7153980916). Originally posted by [KyleS98](https://github.com/KyleS98) on 2026-11-25T05:37:59Z. --- Thanks @avt0m4t48, that's right: the library name was still built from the title's blend description. Fixed in 9478005 ("GPU: name pipelines by the host blend description"). - `GraphicsState::describe`, which feeds both the library name and the early-start key, now formats `host_blend()` instead of the raw `blend`. - Two title descriptions that the host turns into the same pipeline now share a name. Different host pipelines (a float slot's blend differs, or the `VICTORY_FIX_INTBLEND` toggle changes the result) get different names, so a stored entry can't be matched against a mismatched description. - New unit test `the_name_follows_the_host_blend` covers both directions. The 5 blend tests pass. As in your note, I haven't measured the library behaviour on Windows. Entries stored under the old names simply stop being looked up. AI-assisted (Claude Code, Claude Opus 5.5).
avt0m4t48 commented 2026-11-25 06:06:39 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by avt0m4t48 on 2026-11-25T05:47:14Z.


I rechecked the pipeline-name follow-up at 9478005c00a8598daccf254441107788dc17e624 against the previous head, c2eb4c4c0a3a5724ae9edd5cde0ded7d13de7f76.

  • A CPU fixture ran the production blend, state description, and library-name functions over 336 synthetic descriptors (21 integer formats × 8 slots × shared or independent blend). The earlier head reused every affected key with VICTORY_FIX_INTBLEND on and off. The new head separates all 336 pairs in both the graphics and mesh library names. The early-start hash, computed from the same state text and fixed synthetic shader IDs, showed the same result.
  • Affected descriptors shared keys with explicitly equivalent host descriptors. Changing a float slot's blend changed every affected key. The opt-out keys and the four float-only or inactive-slot controls kept their previous keys.
  • All five blend tests passed in the standalone CPU fixture. The untouched PR head passed cargo check --locked --offline -p victory-gpu --tests --features diagnostics,blake3/pure --target x86_64-pc-windows-msvc with the existing depth_written warning. Live D3D12 pipeline-library load/store and GPU execution remain unverified.

AI-assisted using Codex.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7154137834 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/715#issuecomment-7154137834). Originally posted by [avt0m4t48](https://github.com/avt0m4t48) on 2026-11-25T05:47:14Z. --- I rechecked the pipeline-name follow-up at `9478005c00a8598daccf254441107788dc17e624` against the previous head, `c2eb4c4c0a3a5724ae9edd5cde0ded7d13de7f76`. - A CPU fixture ran the production blend, state description, and library-name functions over 336 synthetic descriptors (21 integer formats × 8 slots × shared or independent blend). The earlier head reused every affected key with `VICTORY_FIX_INTBLEND` on and off. The new head separates all 336 pairs in both the graphics and mesh library names. The early-start hash, computed from the same state text and fixed synthetic shader IDs, showed the same result. - Affected descriptors shared keys with explicitly equivalent host descriptors. Changing a float slot's blend changed every affected key. The opt-out keys and the four float-only or inactive-slot controls kept their previous keys. - All five blend tests passed in the standalone CPU fixture. The untouched PR head passed `cargo check --locked --offline -p victory-gpu --tests --features diagnostics,blake3/pure --target x86_64-pc-windows-msvc` with the existing `depth_written` warning. Live D3D12 pipeline-library load/store and GPU execution remain unverified. AI-assisted using Codex.
KyleS98 commented 2026-11-25 06:06:40 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by KyleS98 on 2026-11-25T05:52:00Z.


Thanks for the re-check @avt0m4t48. Good to have the 336 pairs separated in both the graphics and mesh library names, and the early-start key too.

For the part that's still unverified (live pipeline-library store/load and GPU execution), I'll run the prologue on an RTX 3090 Ti with VICTORY_D3D12_DEBUG=1 and a warm library. I'll post whether message 676 still appears, and whether the affected pipelines load from the library on the second run instead of being made again ("the library did not load it").

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:fxceless/victory-fork:comment:7154213455 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/715#issuecomment-7154213455). Originally posted by [KyleS98](https://github.com/KyleS98) on 2026-11-25T05:52:00Z. --- Thanks for the re-check @avt0m4t48. Good to have the 336 pairs separated in both the graphics and mesh library names, and the early-start key too. For the part that's still unverified (live pipeline-library store/load and GPU execution), I'll run the prologue on an RTX 3090 Ti with `VICTORY_D3D12_DEBUG=1` and a warm library. I'll post whether message 676 still appears, and whether the affected pipelines load from the library on the second run instead of being made again ("the library did not load it"). AI-assisted (Claude Code, Claude Opus 5.5).
KyleS98 commented 2026-11-25 09:08:50 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by KyleS98 on 2026-11-25T08:47:53Z.


Note: I reworded this branch's commit messages (metadata line only, no code change), so the hashes changed: c2eb4c4 is now e386512 and 9478005 is now 1bc4884. The diff against 310c6eb is the same as before.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7157482928 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/715#issuecomment-7157482928). Originally posted by [KyleS98](https://github.com/KyleS98) on 2026-11-25T08:47:53Z. --- Note: I reworded this branch's commit messages (metadata line only, no code change), so the hashes changed: `c2eb4c4` is now `e386512` and `9478005` is now `1bc4884`. The diff against `310c6eb` is the same as before.
xunbreakablex commented 2026-11-25 16:12:51 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by xunbreakablex on 2026-11-25T15:20:04Z.


Data point from an NVIDIA card (AI-assisted, Claude; run on my machine): RTX 4070 (undervolted, 100 W limit), Ryzen 5 5600 at 3.95 GHz (6 cores), Windows 11, driver 621.01, Series X profile.

I ported only the integer-render-target blend part of this PR onto a253706 by hand (pipeline/host.rs, +122/-5, with your tests; not pushed) and ran it once into the world (480 s).

  • Before, on every run of that tree: host mesh pipeline refused (0x80070057) shaders=[mesh f5e50eb2108c425b, pixel ce3f0432a08f1d35], first bound between world +76 and +218 frames, about one dropped draw per frame.
  • With the change: no refusal in the log, and host pipeline shaders=[mesh f5e50eb2…, pixel ce3f0432…] is created and bound. Translation cache stayed warm (the change is host-side), no device loss.
  • Frame time: one run, inside the run-to-run spread, so no claim either way; I did not see a visual difference by eye in the cell scene, but did not look for the specific wall it draws.

So on a 32-lane NVIDIA card the refused pair is exactly this case and the fix makes it build.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7166678038 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/715#issuecomment-7166678038). Originally posted by [xunbreakablex](https://github.com/xunbreakablex) on 2026-11-25T15:20:04Z. --- Data point from an NVIDIA card (AI-assisted, Claude; run on my machine): RTX 4070 (undervolted, 100 W limit), Ryzen 5 5600 at 3.95 GHz (6 cores), Windows 11, driver 621.01, Series X profile. I ported only the integer-render-target blend part of this PR onto `a253706` by hand (pipeline/host.rs, +122/-5, with your tests; not pushed) and ran it once into the world (480 s). - Before, on every run of that tree: `host mesh pipeline refused (0x80070057) shaders=[mesh f5e50eb2108c425b, pixel ce3f0432a08f1d35]`, first bound between world +76 and +218 frames, about one dropped draw per frame. - With the change: no refusal in the log, and `host pipeline shaders=[mesh f5e50eb2…, pixel ce3f0432…]` is created and bound. Translation cache stayed warm (the change is host-side), no device loss. - Frame time: one run, inside the run-to-run spread, so no claim either way; I did not see a visual difference by eye in the cell scene, but did not look for the specific wall it draws. So on a 32-lane NVIDIA card the refused pair is exactly this case and the fix makes it build.
KyleS98 commented 2026-11-26 07:03:54 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by KyleS98 on 2026-11-26T06:42:26Z.


@xunbreakablex thanks, that is a useful confirmation: the same kind of refusal (mesh f5e50eb2108c425b, pixel ce3f0432a08f1d35) on a second 32-lane card, and the pipeline builds once blending is left off for the integer target, with no device loss. Agreed that one run says nothing about frame time; what it buys is one fewer dropped draw a frame on your card.

AI-assisted (Claude Code, Claude Fable 5.2).

<!-- greyfinch-sync:fxceless/victory-fork:comment:7184700936 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/715#issuecomment-7184700936). Originally posted by [KyleS98](https://github.com/KyleS98) on 2026-11-26T06:42:26Z. --- @xunbreakablex thanks, that is a useful confirmation: the same kind of refusal (`mesh f5e50eb2108c425b`, `pixel ce3f0432a08f1d35`) on a second 32-lane card, and the pipeline builds once blending is left off for the integer target, with no device loss. Agreed that one run says nothing about frame time; what it buys is one fewer dropped draw a frame on your card. AI-assisted (Claude Code, Claude Fable 5.2).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/715:upstream-pr/715'
git switch 'upstream-pr/715'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/715'
git switch 'upstream-pr/715'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/715'
git switch 'upstream-pr/715'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/715'
git switch 'main'
git merge --squash 'upstream-pr/715'
git switch 'main'
git merge --ff-only 'upstream-pr/715'
git switch 'main'
git merge 'upstream-pr/715'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
fxceless/victory-fork!715
No description provided.