fix(gpu): handle integer RT blend disable and target format variants #3340

Open
github-bot wants to merge 1 commit from github-bot/gh-3340 into main AGit
Owner

@⁠legayclightning22 on GitHub · 2026-11-26 19:04 UTC · original
legayclightning22:fix/integer-rt-blend-and-target-variants → main · +459 −40 · 6 files · 1 commits · open

Summary

Handles integer render-target blend disablement and cached target-format pipeline variants (TargetKey, gated by VICTORY_TARGET_VARIANTS=0) across victory-gpu (4eb0d71).

Changes

  • Track bound RTV/DSV formats from set_targets (RtvRecord::format in crates/victory-gpu/src/descriptor.rs and crates/victory-gpu/src/draw.rs) and resolve graphics pipelines via pipeline::host_pipeline_for_targets.
  • Keep integer RT blending disabled on integer RTVs and add TargetKey + cached target-format variant selection (VICTORY_TARGET_VARIANTS=0 gate) in crates/victory-gpu/src/pipeline/make.rs and crates/victory-gpu/src/pipeline/host.rs.
  • Add unit tests covering signed/unsigned integer blend disablement and target-format variant selection.

Verification

  • cargo test -p victory-gpu --lib pipeline
  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings
  • cargo xtask policy
**@⁠legayclightning22** on GitHub · 2026-11-26 19:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/3340) `legayclightning22:fix/integer-rt-blend-and-target-variants` → `main` · +459 −40 · 6 files · 1 commits · open ## Summary Handles integer render-target blend disablement and cached target-format pipeline variants (`TargetKey`, gated by `VICTORY_TARGET_VARIANTS=0`) across `victory-gpu` (`4eb0d71`). ## Changes - Track bound RTV/DSV formats from `set_targets` (`RtvRecord::format` in `crates/victory-gpu/src/descriptor.rs` and `crates/victory-gpu/src/draw.rs`) and resolve graphics pipelines via `pipeline::host_pipeline_for_targets`. - Keep integer RT blending disabled on integer RTVs and add `TargetKey` + cached target-format variant selection (`VICTORY_TARGET_VARIANTS=0` gate) in `crates/victory-gpu/src/pipeline/make.rs` and `crates/victory-gpu/src/pipeline/host.rs`. - Add unit tests covering signed/unsigned integer blend disablement and target-format variant selection. ## Verification - `cargo test -p victory-gpu --lib pipeline` - `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` - `cargo xtask policy` ```[cite: 21]
Disable blending on integer render targets to avoid invalid D3D12 PSO creation. Key graphics pipeline variants by bound RTV/DSV formats when they differ from shader-declared formats, gated by VICTORY_TARGET_VARIANTS=0.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:06:57 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 19:07 UTC · original · reviewed

Tested on RTX 5090 (Windows / D3D12) against origin/main (63bcca4).

All checks pass:

  • cargo test -p victory-gpu --lib pipeline:: -- --test-threads=1: 28 passed, 0 failed.
  • cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 20 passed, 0 failed.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

One scope note before merge: commit 4eb0d71 appears to bundle the changes from both #3337 (bounded single-descriptor tables for root SRVs/UAVs in draw.rs / pipeline/host.rs) and #3339 (CBV caps and typed buffer view validation in descriptor.rs / descriptor/host.rs) alongside the integer RT blend / target format variant work. If this is meant to be reviewed independently, dropping the #3337/#3339 hunks (or noting that it supersedes them) would avoid merge conflicts.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 19:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/3340#pullrequestreview-6079325371) · **reviewed** Tested on RTX 5090 (Windows / D3D12) against `origin/main` (`63bcca4`). All checks pass: - `cargo test -p victory-gpu --lib pipeline:: -- --test-threads=1`: 28 passed, 0 failed. - `cargo test -p victory-gpu --lib draw:: -- --test-threads=1`: 20 passed, 0 failed. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. One scope note before merge: commit `4eb0d71` appears to bundle the changes from both #3337 (bounded single-descriptor tables for root SRVs/UAVs in `draw.rs` / `pipeline/host.rs`) and #3339 (CBV caps and typed buffer view validation in `descriptor.rs` / `descriptor/host.rs`) alongside the integer RT blend / target format variant work. If this is meant to be reviewed independently, dropping the #3337/#3339 hunks (or noting that it supersedes them) would avoid merge conflicts. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
github-bot force-pushed github-bot/gh-3340 from 4eb0d712b7 to 24fd8e83ca 2026-11-26 19:38:42 +00:00 Compare
Author
Owner

@⁠legayclightning22 on GitHub · 2026-11-26 19:46 UTC · original

Pushed 24fd8e8 trimming out all #3337 and #3339 hunks (descriptor/host.rs reverted to upstream/main; descriptor.rs and draw.rs keep only RtvRecord::format() and target-format variant selection) so this PR stands cleanly on its own. Re-verified pipeline:: tests (28/28 passing), clippy -- -D warnings, and cargo xtask policy.

**@⁠legayclightning22** on GitHub · 2026-11-26 19:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/3340#issuecomment-7201950220) Pushed `24fd8e8` trimming out all `#3337` and `#3339` hunks (`descriptor/host.rs` reverted to `upstream/main`; `descriptor.rs` and `draw.rs` keep only `RtvRecord::format()` and target-format variant selection) so this PR stands cleanly on its own. Re-verified `pipeline::` tests (28/28 passing), `clippy -- -D warnings`, and `cargo xtask policy`.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 19:52 UTC · original

I found a target-variant selection edge case on 24fd8e8. Once the base pipeline finishes with a refusal, ready_for_targets returns before looking at the formats that were actually bound. The regression sets up a completed refusal and requests a different R32_UINT target. On the PR head, the variant cache stays empty.

e17b393 lets a different target key reach the variant builder in that case. The regression checks that the requested key is attempted and cached once. The disabled switch, same-format request, and explicitly skipped shader paths still leave the cache empty.

The 31 pipeline checks passed with VICTORY_TARGET_VARIANTS=1 and again with 0, excluding the depth-bounds draw that timed out on both the untouched PR and the follow-up on this host. Both strict all-target Clippy configurations and the repository policy check passed. The new regression checks CPU selection and caching; hardware creation of the resulting format variant is the next check.

legayclightning22, please consider applying the follow-up and trying the bound-format case on your adapter. If you fold the change into another commit, please preserve its Git author or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 19:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/3340#issuecomment-7202044704) I found a target-variant selection edge case on `24fd8e8`. Once the base pipeline finishes with a refusal, `ready_for_targets` returns before looking at the formats that were actually bound. The regression sets up a completed refusal and requests a different `R32_UINT` target. On the PR head, the variant cache stays empty. [`e17b393`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/e17b3935832741d66e9fd2dbb8f6d476a3fada56) lets a different target key reach the variant builder in that case. The regression checks that the requested key is attempted and cached once. The disabled switch, same-format request, and explicitly skipped shader paths still leave the cache empty. The 31 pipeline checks passed with `VICTORY_TARGET_VARIANTS=1` and again with `0`, excluding the depth-bounds draw that timed out on both the untouched PR and the follow-up on this host. Both strict all-target Clippy configurations and the repository policy check passed. The new regression checks CPU selection and caching; hardware creation of the resulting format variant is the next check. legayclightning22, please consider applying the follow-up and trying the bound-format case on your adapter. If you fold the change into another commit, please preserve its Git author or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 20:07 UTC · original

There is a second format-selection issue on 24fd8e8. For a typed texture with a default view, view_format may return None because the host texture already has the right format. A view descriptor with DXGI_FORMAT_UNKNOWN likewise inherits the resource’s format in D3D12. The original key path reads either case as format 0. My local explicit-UNKNOWN control returned 0 where the typed resource selected RGBA8 (28).

c2cfe74 gets the key from the same RTV/DSV descriptions passed to D3D12, using the host resource format for default or UNKNOWN views. It retains explicitly described formats. The regression, both strict all-target Clippy runs, and the policy check passed. The RTV and DSV rules are the same here.

I also tested both follow-ups together with #2626 in 5581f9f. The recorded RTV and graphics stream keys agree for 86 and 115 with native format support. A test-only CPU capability control made both fall back to RGBA8, and both keys still agreed. The combined pipeline checks passed 31/31 with the separately reproduced depth-bounds timeout excluded. This verifies the chosen formats and keys in the CPU code.

Please consider taking the two follow-ups together. If you fold them into another commit, please preserve the Git author or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 20:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/3340#issuecomment-7202321026) There is a second format-selection issue on `24fd8e8`. For a typed texture with a default view, `view_format` may return `None` because the host texture already has the right format. A view descriptor with `DXGI_FORMAT_UNKNOWN` likewise inherits the resource’s format in D3D12. The original key path reads either case as format 0. My local explicit-UNKNOWN control returned 0 where the typed resource selected RGBA8 (28). [`c2cfe74`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/c2cfe743d405a68be9d3b7c56231a8eeedd84f21) gets the key from the same RTV/DSV descriptions passed to D3D12, using the host resource format for default or UNKNOWN views. It retains explicitly described formats. The regression, both strict all-target Clippy runs, and the policy check passed. The [RTV](https://learn.microsoft.com/en-us/windows/desktop/api/d3d12/ns-d3d12-d3d12_render_target_view_desc) and [DSV](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_depth_stencil_view_desc) rules are the same here. I also tested both follow-ups together with #2626 in [`5581f9f`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/5581f9f9ed80a38b334b624f4ac4e444f30b377f). The recorded RTV and graphics stream keys agree for 86 and 115 with native format support. A test-only CPU capability control made both fall back to RGBA8, and both keys still agreed. The combined pipeline checks passed 31/31 with the separately reproduced depth-bounds timeout excluded. This verifies the chosen formats and keys in the CPU code. Please consider taking the two follow-ups together. If you fold them into another commit, please preserve the Git author or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 20:38 UTC · original · requested changes

Tested locally merged onto origin/main (63bcca43) at PR head 24fd8e83 on Windows 11 x64 (NVIDIA GeForce RTX 5090 + Microsoft WARP, --features diagnostics, VICTORY_D3D12_DEBUG=1).

While pipeline:: (31/31) and draw:: (20/20) unit tests compile and pass, there are four blocking issues reproduced on 24fd8e83:

1. Critical: half-trimmed #3337 leaves a root-signature vs command-list binding mismatch (pipeline/host.rs:306-369, 624-655 vs draw.rs:805-851)

Commit 24fd8e8 reverted #3337's binding changes from draw.rs, but left #3337's root-signature changes in crates/victory-gpu/src/pipeline/host.rs (root_srv_direct, root_view_range, root_view_parameter, and HostPipeline::new lines 624-655). As a result:

  • HostPipeline::new declares every root SRV and root UAV parameter (including VIEW_STRIDES) as D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE by default.
  • draw.rs (L824-L848) still binds them with raw GPU addresses via SetComputeRootShaderResourceView / SetGraphicsRootShaderResourceView / SetComputeRootUnorderedAccessView / SetGraphicsRootUnorderedAccessView.

Reproduced live on both RTX 5090 and WARP with VICTORY_D3D12_DEBUG=1 by building a compute HostPipeline with VIEW_STRIDES in root_srvs and calling State::bind (after materializing the heaps and clearing InfoQueue):

  • On PR #3340 (24fd8e83), both RTX 5090 and WARP immediately fail D3D12 Debug Layer validation with:
    ID3D12CommandList::SetComputeRootShaderResourceView: The currently set root signature declares parameter [0] with type descriptor table, so it is invalid to set a root SRV here.
  • On pristine origin/main (63bcca43), the exact same test produces None (0 D3D12 Debug Layer errors) on both RTX 5090 and WARP.

Please also drop the remaining #3337 hunks from crates/victory-gpu/src/pipeline/host.rs (and their tests root_srvs_and_uavs_are_bounded_one_descriptor_tables, root_srv_direct_opt_out_keeps_raw_addresses, root_srv_direct_only_for_one).

2. RtvRecord::format() returns DXGI_FORMAT_UNKNOWN (0) for typed textures with default or UNKNOWN views (descriptor.rs:363-373)

crate::resource::view_format() returns None whenever the host texture already has the typed format (format == own), and explicit RTV/DSV descriptors with Format == DXGI_FORMAT_UNKNOWN (0) also inherit the resource's format in D3D12.

Reproduced locally with a typed R8G8B8A8_UNORM (28) render target texture:

  • Default RTV (described = 0): record.format() returns DXGI_FORMAT(0) instead of 28.
  • Explicit UNKNOWN RTV (described = 1, desc[0] = 0): record.format() returns DXGI_FORMAT(0) instead of 28.

When bound in draw.rs::set_targets, this records RTFormats[0] = DXGI_FORMAT_UNKNOWN, causing ready_for_targets to build broken target variants. Resolve the effective format from the view desc when non-zero, falling back to the host resource's actual GetDesc().Format (or view_format().unwrap_or(host_format)).

3. ready_for_targets returns None before trying variants when the base PSO was refused (pipeline/make.rs:772)

let base = p.made.get()?.as_ref()?; exits early when p.made completed with None (e.g. a base PSO created with incompatible/unknown target formats), so make_variant(want) is never reached for compatible bound RTV/DSV formats.

4. UTF-8 mojibake corruption in comments

crates/victory-gpu/src/descriptor/host.rs:688 (× -> ×) and crates/victory-gpu/src/draw.rs:76, 88, 1012, 3518 (→ -> →, — -> —) introduce corrupted UTF-8 characters in untouched comments; please restore clean UTF-8.

(Note: host_blend on main already preserves float RT blending while disabling integer RT blending in MRT configurations; integer_blend_disable_covers_signed_and_unsigned_formats passes cleanly.) Synthetic tests only.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 20:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/3340#pullrequestreview-6080266105) · **requested changes** Tested locally merged onto `origin/main` (`63bcca43`) at PR head `24fd8e83` on Windows 11 x64 (NVIDIA GeForce RTX 5090 + Microsoft WARP, `--features diagnostics`, `VICTORY_D3D12_DEBUG=1`). While `pipeline::` (31/31) and `draw::` (20/20) unit tests compile and pass, there are **four blocking issues reproduced on `24fd8e83`**: ### 1. Critical: half-trimmed `#3337` leaves a root-signature vs command-list binding mismatch (`pipeline/host.rs:306-369, 624-655` vs `draw.rs:805-851`) Commit `24fd8e8` reverted `#3337`'s binding changes from `draw.rs`, but left `#3337`'s root-signature changes in `crates/victory-gpu/src/pipeline/host.rs` (`root_srv_direct`, `root_view_range`, `root_view_parameter`, and `HostPipeline::new` lines `624-655`). As a result: - `HostPipeline::new` declares every root SRV and root UAV parameter (including `VIEW_STRIDES`) as `D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE` by default. - `draw.rs` (`L824-L848`) still binds them with raw GPU addresses via `SetComputeRootShaderResourceView` / `SetGraphicsRootShaderResourceView` / `SetComputeRootUnorderedAccessView` / `SetGraphicsRootUnorderedAccessView`. **Reproduced live on both RTX 5090 and WARP with `VICTORY_D3D12_DEBUG=1`** by building a compute `HostPipeline` with `VIEW_STRIDES` in `root_srvs` and calling `State::bind` (after materializing the heaps and clearing `InfoQueue`): - On PR `#3340` (`24fd8e83`), **both RTX 5090 and WARP** immediately fail D3D12 Debug Layer validation with: `ID3D12CommandList::SetComputeRootShaderResourceView: The currently set root signature declares parameter [0] with type descriptor table, so it is invalid to set a root SRV here.` - On pristine `origin/main` (`63bcca43`), the exact same test produces `None` (0 D3D12 Debug Layer errors) on both RTX 5090 and WARP. Please also drop the remaining `#3337` hunks from `crates/victory-gpu/src/pipeline/host.rs` (and their tests `root_srvs_and_uavs_are_bounded_one_descriptor_tables`, `root_srv_direct_opt_out_keeps_raw_addresses`, `root_srv_direct_only_for_one`). ### 2. `RtvRecord::format()` returns `DXGI_FORMAT_UNKNOWN (0)` for typed textures with default or `UNKNOWN` views (`descriptor.rs:363-373`) `crate::resource::view_format()` returns `None` whenever the host texture already has the typed format (`format == own`), and explicit RTV/DSV descriptors with `Format == DXGI_FORMAT_UNKNOWN (0)` also inherit the resource's format in D3D12. Reproduced locally with a typed `R8G8B8A8_UNORM` (`28`) render target texture: - Default RTV (`described = 0`): `record.format()` returns `DXGI_FORMAT(0)` instead of `28`. - Explicit `UNKNOWN` RTV (`described = 1, desc[0] = 0`): `record.format()` returns `DXGI_FORMAT(0)` instead of `28`. When bound in `draw.rs::set_targets`, this records `RTFormats[0] = DXGI_FORMAT_UNKNOWN`, causing `ready_for_targets` to build broken target variants. Resolve the effective format from the view desc when non-zero, falling back to the host resource's actual `GetDesc().Format` (or `view_format().unwrap_or(host_format)`). ### 3. `ready_for_targets` returns `None` before trying variants when the base PSO was refused (`pipeline/make.rs:772`) `let base = p.made.get()?.as_ref()?;` exits early when `p.made` completed with `None` (e.g. a base PSO created with incompatible/unknown target formats), so `make_variant(want)` is never reached for compatible bound RTV/DSV formats. ### 4. UTF-8 mojibake corruption in comments `crates/victory-gpu/src/descriptor/host.rs:688` (`×` -> `×`) and `crates/victory-gpu/src/draw.rs:76, 88, 1012, 3518` (`→` -> `→`, `—` -> `—`) introduce corrupted UTF-8 characters in untouched comments; please restore clean UTF-8. (Note: `host_blend` on `main` already preserves float RT blending while disabling integer RT blending in MRT configurations; `integer_blend_disable_covers_signed_and_unsigned_formats` passes cleanly.) Synthetic tests only.
Author
Owner

@⁠evan-kolberg on GitHub · 2026-11-26 20:50 UTC · original

On an M4 Pro with CrossOver 26.3 and D3DMetal 4.0 beta 3, the generated offscreen draw selected and reused a native pipeline for the new integer target format. legayclightning22’s exact head 24fd8e83

  • With VICTORY_TARGET_VARIANTS=1, a working R32_UINT pipeline returned a distinct host PSO when asked for R16_UINT. A second request reused the single cached variant. Each format read back 0x6a5b at all 64 pixels.
  • With variants disabled, selection retained the base PSO and the variant cache stayed empty. An independently built R16_UINT pipeline matched all 64 pixels as the adapter control.

The fixture used explicit format keys, a resource-free pixel shader, and r4tedx’s fullscreen vertex shader. This adds hardware coverage for the working-base case. Refused-base recovery and format inference remain open. r4tedx’s fixture · andrewpozdnakov7-jpg’s recovery test · Format-inference follow-up

Prepared and tested with Codex.

**@⁠evan-kolberg** on GitHub · 2026-11-26 20:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/3340#issuecomment-7203127123) On an M4 Pro with CrossOver 26.3 and D3DMetal 4.0 beta 3, the generated offscreen draw selected and reused a native pipeline for the new integer target format. [legayclightning22’s exact head `24fd8e83`](https://github.com/legayclightning22/VIctory/commit/24fd8e83ca2c278fff704b43ad144c7d653f5800) - With `VICTORY_TARGET_VARIANTS=1`, a working `R32_UINT` pipeline returned a distinct host PSO when asked for `R16_UINT`. A second request reused the single cached variant. Each format read back `0x6a5b` at all 64 pixels. - With variants disabled, selection retained the base PSO and the variant cache stayed empty. An independently built `R16_UINT` pipeline matched all 64 pixels as the adapter control. The fixture used explicit format keys, a resource-free pixel shader, and r4tedx’s fullscreen vertex shader. This adds hardware coverage for the working-base case. Refused-base recovery and format inference remain open. [r4tedx’s fixture](https://github.com/Marvisak/VIctory/commit/842b0cb76f8f5fa9289bd779783c51ec24d75302) · [andrewpozdnakov7-jpg’s recovery test](https://git.gtahub.st/github/Marvisak--VIctory/pulls/3340) · [Format-inference follow-up](https://git.gtahub.st/github/Marvisak--VIctory/pulls/3340) Prepared and tested with Codex.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3340'
git switch 'github-bot/gh-3340'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3340'
git switch 'github-bot/gh-3340'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3340'
git switch 'main'
git merge --squash 'github-bot/gh-3340'
git switch 'main'
git merge --ff-only 'github-bot/gh-3340'
git switch 'main'
git merge 'github-bot/gh-3340'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3340
No description provided.