GPU: no blending on integer render targets #715

Open
github-bot wants to merge 2 commits from github-bot/gh-715 into main AGit
Owner

@⁠KyleS98 on GitHub · 2026-11-25 05:25 UTC · original
KyleS98:fix/integer-target-blend → main · +121 −5 · 1 files · 2 commits · open

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

**@⁠KyleS98** on GitHub · 2026-11-25 05:25 UTC · [original](https://github.com/fxceless/victory-fork/pull/715) `KyleS98:fix/integer-target-blend` → `main` · +121 −5 · 1 files · 2 commits · open 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)
A pipeline whose blend description enables blending on an integer render
target (UINT/SINT) is created as it is today. D3D12 calls that an error
(debug layer message 676: "The render target format at slot 2 is format
(R8_UINT). This format does not support blending", from a G-buffer pass
of Grand Theft Auto VI), and what NVIDIA's driver then writes to that
target is undefined. The console's blender passes integer targets
through.

GraphicsState::host_blend turns blending off for every integer slot,
spreading the first slot's description to all of them first when the
title's description is not independent (D3D12 applies RenderTarget[0]
to every slot then). Float and UNORM targets keep the title's blend.
Both the plain and the stream (mesh, depth bounds) pipelines use it.
VICTORY_FIX_INTBLEND=0 keeps the title's description as it is.

Four unit tests cover shared and independent blend descriptions, a
non-blending integer slot, and float-only targets.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
GraphicsState::describe, part of a pipeline's library name and of its
early-start key, formatted the title's blend description. With integer
slots now made without blending, a pipeline stored by an earlier build
(or with VICTORY_FIX_INTBLEND toggled) kept its name, and the pipeline
library would refuse it at every run (its description no longer
matches) and never store the new one. describe now formats host_blend,
so two descriptions the host turns into the same pipeline share a
name, and different host pipelines never do.

New test: descriptions that differ only in an integer slot's blend
describe the same; a float slot's blend still tells them apart.

Reported by @avt0m4t48 in review.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:49:32 +00:00
Author
Owner

@⁠avt0m4t48 on GitHub · 2026-11-25 05:32 UTC · original

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.

**@⁠avt0m4t48** on GitHub · 2026-11-25 05:32 UTC · [original](https://github.com/fxceless/victory-fork/pull/715#issuecomment-7153869497) 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.
Author
Owner

@⁠KyleS98 on GitHub · 2026-11-25 05:37 UTC · original

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

**@⁠KyleS98** on GitHub · 2026-11-25 05:37 UTC · [original](https://github.com/fxceless/victory-fork/pull/715#issuecomment-7153980916) 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).
Author
Owner

@⁠avt0m4t48 on GitHub · 2026-11-25 05:47 UTC · original

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.

**@⁠avt0m4t48** on GitHub · 2026-11-25 05:47 UTC · [original](https://github.com/fxceless/victory-fork/pull/715#issuecomment-7154137834) 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.
Author
Owner

@⁠KyleS98 on GitHub · 2026-11-25 05:52 UTC · original

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** on GitHub · 2026-11-25 05:52 UTC · [original](https://github.com/fxceless/victory-fork/pull/715#issuecomment-7154213455) 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).
Author
Owner

@⁠KyleS98 on GitHub · 2026-11-25 08:47 UTC · original

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.

**@⁠KyleS98** on GitHub · 2026-11-25 08:47 UTC · [original](https://github.com/fxceless/victory-fork/pull/715#issuecomment-7157482928) 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.
Author
Owner

@⁠xunbreakablex on GitHub · 2026-11-25 15:20 UTC · original

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.

**@⁠xunbreakablex** on GitHub · 2026-11-25 15:20 UTC · [original](https://github.com/fxceless/victory-fork/pull/715#issuecomment-7166678038) 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.
Author
Owner

@⁠KyleS98 on GitHub · 2026-11-26 06:42 UTC · original

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

**@⁠KyleS98** on GitHub · 2026-11-26 06:42 UTC · [original](https://github.com/fxceless/victory-fork/pull/715#issuecomment-7184700936) @⁠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 has changes conflicting with the target branch.
  • crates/victory-gpu/src/pipeline/host.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/715/head:github-bot/gh-715'
git switch 'github-bot/gh-715'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-715'
git switch 'github-bot/gh-715'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-715'
git switch 'github-bot/gh-715'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-715'
git switch 'main'
git merge --squash 'github-bot/gh-715'
git switch 'main'
git merge --ff-only 'github-bot/gh-715'
git switch 'main'
git merge 'github-bot/gh-715'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.