GPU: ignore depth-stencil clears whose host flags mask to zero #2395

Manually merged
github merged 1 commit from github-bot/gh-2395 into main 2026-11-30 14:16:51 +00:00 AGit
Owner

@⁠fuzeofficlal on GitHub · 2026-11-29 12:40 UTC · original
fuzeofficlal:fix/gpu-clear-dsv-empty-flags → main · +192 −4 · 2 files · 1 commits · merged 2026-11-30 14:12 UTC

Summary

Ported from Marvisak/VIctory#3150 (9b3d0f4363), also covering list::thin::clear_dsv (VICTORY_THIN=1).

list::clear_dsv masks incoming ClearDepthStencilView flags with & 3 to strip console-only bits above D3D12_CLEAR_FLAG_DEPTH | D3D12_CLEAR_FLAG_STENCIL, but still marked the list as writing, transitioned the depth target, allocated a host DSV, and recorded ClearDepthStencilView(..., D3D12_CLEAR_FLAGS(0), ...) when the masked value was 0 (e.g. flags == 0 or console-only flags like 0x4). D3D12 rejects ClearFlags == 0 (Invalid ClearFlags value (0x0)).

Changes

  • Mask flags with & 3 at the top of list::clear_dsv and return early when 0, before state.wrote(), state transitions, or recording the clear.
  • Return early on flags & 3 == 0 in list::thin::clear_dsv as well so VICTORY_THIN=1 does not serialize no-op clears.
  • Add list::tests::clear_dsv_skips_empty_masked_flags verifying that flags == 0 and 0x4 emit no clear, transition, or D3D12 debug layer error, while 1 | 0x4 clears a D32_FLOAT target to 0.25 (verified via GPU readback).

Verification

  • cargo test --locked -p victory-gpu --lib list::tests::clear_dsv_skips_empty_masked_flags on RTX 5090 (VICTORY_ADAPTER=NVIDIA, VICTORY_D3D12_DEBUG=1) and WARP (VICTORY_D3D12_WARP=1, VICTORY_D3D12_DEBUG=1): passed.
  • cargo test --locked -p victory-gpu --lib list::tests: all passing.
  • cargo clippy --locked -p victory-gpu --all-targets: 0 new warnings.
  • cargo xtask policy --staged: passed.
**@⁠fuzeofficlal** on GitHub · 2026-11-29 12:40 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2395) `fuzeofficlal:fix/gpu-clear-dsv-empty-flags` → `main` · +192 −4 · 2 files · 1 commits · merged 2026-11-30 14:12 UTC ## Summary Ported from `Marvisak/VIctory#3150` (`9b3d0f4363`), also covering `list::thin::clear_dsv` (`VICTORY_THIN=1`). `list::clear_dsv` masks incoming `ClearDepthStencilView` flags with `& 3` to strip console-only bits above `D3D12_CLEAR_FLAG_DEPTH | D3D12_CLEAR_FLAG_STENCIL`, but still marked the list as writing, transitioned the depth target, allocated a host DSV, and recorded `ClearDepthStencilView(..., D3D12_CLEAR_FLAGS(0), ...)` when the masked value was `0` (e.g. `flags == 0` or console-only flags like `0x4`). D3D12 rejects `ClearFlags == 0` (`Invalid ClearFlags value (0x0)`). ## Changes - Mask `flags` with `& 3` at the top of `list::clear_dsv` and return early when `0`, before `state.wrote()`, state transitions, or recording the clear. - Return early on `flags & 3 == 0` in `list::thin::clear_dsv` as well so `VICTORY_THIN=1` does not serialize no-op clears. - Add `list::tests::clear_dsv_skips_empty_masked_flags` verifying that `flags == 0` and `0x4` emit no clear, transition, or D3D12 debug layer error, while `1 | 0x4` clears a `D32_FLOAT` target to `0.25` (verified via GPU readback). ## Verification - `cargo test --locked -p victory-gpu --lib list::tests::clear_dsv_skips_empty_masked_flags` on RTX 5090 (`VICTORY_ADAPTER=NVIDIA`, `VICTORY_D3D12_DEBUG=1`) and WARP (`VICTORY_D3D12_WARP=1`, `VICTORY_D3D12_DEBUG=1`): **passed**. - `cargo test --locked -p victory-gpu --lib list::tests`: all passing. - `cargo clippy --locked -p victory-gpu --all-targets`: 0 new warnings. - `cargo xtask policy --staged`: passed.
Ported from Marvisak/VIctory#3150 (9b3d0f4363ec06917a7b10938a0248d0ba4f6423),
also covering list::thin::clear_dsv (VICTORY_THIN=1).

ClearDepthStencilView strips console-only clear bits above bits 0..1 via
flags & 3, which yields ClearFlags = 0 when a call passes 0 or only
console-specific bits. D3D12 rejects ClearFlags == 0. Return early before
marking the list as writing, transitioning the depth target, or recording
the clear when flags & 3 == 0.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 12:43:49 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-29 12:47 UTC · original · approved these changes

Tested locally merged onto main (829188e9).

  • Merge: Clean merge in crates/victory-gpu/src/list.rs and list/thin.rs.
  • Tests (RTX 5090): cargo test -p victory-gpu --lib list:: passed (21 passed; 0 failed, including the new list::tests::clear_dsv_skips_empty_masked_flags test) with 0 new warnings.

Clean guard avoiding invalid zero-flag ClearDepthStencilView calls on host D3D12. LGTM.

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

**@⁠Dukestar69** on GitHub · 2026-11-29 12:47 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2395#pullrequestreview-6102937001) · **approved these changes** Tested locally merged onto `main` (`829188e9`). - **Merge**: Clean merge in `crates/victory-gpu/src/list.rs` and `list/thin.rs`. - **Tests (RTX 5090)**: `cargo test -p victory-gpu --lib list::` passed (`21 passed; 0 failed`, including the new `list::tests::clear_dsv_skips_empty_masked_flags` test) with 0 new warnings. Clean guard avoiding invalid zero-flag `ClearDepthStencilView` calls on host D3D12. LGTM. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
github manually merged commit 18d13a1ea8 into main 2026-11-30 14:16:51 +00:00
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/trustno1-coder--VIctory-NVIDIA!2395
No description provided.