GPU: implement ID3D12GraphicsCommandList::ClearState (slot 0x58) #1166

Closed
geiyiliyabumo wants to merge 1 commit from upstream-pr/1166 into main
geiyiliyabumo commented 2026-11-24 16:19:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T16:19:02Z.


Summary

Closes #848

Full verification details and change notes are documented in #848 (commit d57ea67, based on main ffe310e).

 crates/victory-gpu/src/draw.rs |  82 +++++++++++++++
 crates/victory-gpu/src/list.rs | 219 ++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 300 insertions(+), 1 deletion(-)

Verification (Windows 11 x64 MSVC)

  • rustfmt --edition 2024 --check on edited files: PASS
  • cargo xtask policy: PASS (zero game files/data)
  • cargo clippy --all-targets --locked -- -D warnings (default + --features diagnostics where applicable): PASS
  • Targeted & crate unit/GPU tests: PASS

AI-assisted; synthetic tests only, no game files.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6586333441 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1166). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-24T16:19:02Z. --- ### Summary Closes #848 Full verification details and change notes are documented in #848 (commit `d57ea67`, based on `main` `ffe310e`). ```text crates/victory-gpu/src/draw.rs | 82 +++++++++++++++ crates/victory-gpu/src/list.rs | 219 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 300 insertions(+), 1 deletion(-) ``` ### Verification (Windows 11 x64 MSVC) - `rustfmt --edition 2024 --check` on edited files: **PASS** - `cargo xtask policy`: **PASS** (zero game files/data) - `cargo clippy --all-targets --locked -- -D warnings` (default + `--features diagnostics` where applicable): **PASS** - Targeted & crate unit/GPU tests: **PASS** *AI-assisted; synthetic tests only, no game files.*
Zipettte commented 2026-11-24 18:06:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T18:00:57Z.


Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at d57ea67: cargo test -p victory-gpu passes, 53 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7140033385 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1166#issuecomment-7140033385). Originally posted by [Zipettte](https://github.com/Zipettte) on 2026-11-24T18:00:57Z. --- Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at d57ea67: `cargo test -p victory-gpu` passes, 53 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
Marvisak commented 2026-11-25 01:08:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:38:19Z.


Automated triage for the maintainers.

Recommended for a maintainer's look. This fills slot 0x58 (ClearState) in crates/victory-gpu/src/list.rs, which main leaves to the E_NOTIMPL stub. It calls the host's ClearState(None) and resets the list's cached State (State::clear in draw.rs), so the pipeline, root signatures and heaps are bound again before the next draw. The dynamic descriptor slots and the root-view run are kept until reset, because earlier commands may still read them. These semantics match the public D3D12 ClearState documentation. The GPU test reads back a clear recorded before ClearState and another recorded after it, confirming that both run. CI is passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148721344 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1166#issuecomment-7148721344). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:38:19Z. --- <!-- victory-triage v1 head=2d779bf53dcbc5aae9297c0c3ae5717c619d32ec verdict=merge-candidate at=2026-11-25T02:20:29Z --> Automated triage for the maintainers. Recommended for a maintainer's look. This fills slot 0x58 (`ClearState`) in `crates/victory-gpu/src/list.rs`, which main leaves to the `E_NOTIMPL` stub. It calls the host's `ClearState(None)` and resets the list's cached `State` (`State::clear` in `draw.rs`), so the pipeline, root signatures and heaps are bound again before the next draw. The dynamic descriptor slots and the root-view run are kept until reset, because earlier commands may still read them. These semantics match the public D3D12 `ClearState` documentation. The GPU test reads back a clear recorded before `ClearState` and another recorded after it, confirming that both run. CI is passing. --- _Generated by [Claude Code](https://claude.ai/code)_
geiyiliyabumo commented 2026-11-25 02:06:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-25T01:51:49Z.


Rebased cleanly onto \main\ (\ccfb029). \cargo test -p victory-gpu --locked\ (144 passed, 0 failed), \cargo clippy -p victory-gpu --all-targets --locked -- -D warnings, and \cargo xtask policy\ all pass.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7150045633 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1166#issuecomment-7150045633). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-25T01:51:49Z. --- Rebased cleanly onto \main\ (\ccfb029\). \cargo test -p victory-gpu --locked\ (144 passed, 0 failed), \cargo clippy -p victory-gpu --all-targets --locked -- -D warnings\, and \cargo xtask policy\ all pass.
andrewpozdnakov7-jpg commented 2026-11-25 21:03:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T20:40:22Z.


I tested this PR at 2d779bf merged with current main 13f91ca. The textual merge is clean, but the resulting test build hits E0063 at the State initializer because main added the saved fixed-function state, and E0308 where the existing readback test passes an owned texture to transition.

After adapting only those test call sites, the expanded binding test finds that ClearState leaves the saved topology, viewport, scissor, blend factor, stencil reference and targets available for replay by State::cut. The fix resets that saved state while retaining the descriptor slots and root views used by earlier commands. D3D12 ClearState

Commit bfd5ce0 sits on the merge of your exact HEAD and main, keeping your commits and authorship. With the same tests, the old composition fails the stale-state assertion and the updated composition passes all three ClearState tests. The submitted clear regression still reads red and green from its two texels. Six paired runs reproduced the results. The full serial GPU suite on WARP passed 201 tests with one ignored under each debug setting. Strict Clippy in both configurations and asset policy passed.

Please retain the Git author on cherry-pick or rebase. If you fold the fix or test into another commit, please add the following trailer.

Co-authored-by: andrewpozdnakov7-jpg [email protected]

AI-assisted with Codex. Synthetic tests on WARP.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7174017642 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1166#issuecomment-7174017642). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-25T20:40:22Z. --- I tested this PR at 2d779bf merged with current main 13f91ca. The textual merge is clean, but the resulting test build hits E0063 at the State initializer because main added the saved fixed-function state, and E0308 where the existing readback test passes an owned texture to transition. After adapting only those test call sites, the expanded binding test finds that ClearState leaves the saved topology, viewport, scissor, blend factor, stencil reference and targets available for replay by State::cut. The fix resets that saved state while retaining the descriptor slots and root views used by earlier commands. [D3D12 ClearState](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12graphicscommandlist-clearstate) [Commit bfd5ce0](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/bfd5ce04f25c336e7c04e2a64779c63ffe3a7656) sits on the merge of your exact HEAD and main, keeping your commits and authorship. With the same tests, the old composition fails the stale-state assertion and the updated composition passes all three ClearState tests. The submitted clear regression still reads red and green from its two texels. Six paired runs reproduced the results. The full serial GPU suite on WARP passed 201 tests with one ignored under each debug setting. Strict Clippy in both configurations and asset policy passed. Please retain the Git author on cherry-pick or rebase. If you fold the fix or test into another commit, please add the following trailer. Co-authored-by: andrewpozdnakov7-jpg <[email protected]> AI-assisted with Codex. Synthetic tests on WARP.
upstream-sync closed this pull request 2026-11-25 22:02:49 +00:00
Marvisak commented 2026-11-25 22:04:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T21:59:33Z.


Automated triage for the maintainers, second look (a review against current main, with builds and tests where they could change the verdict).

Closing because the title never calls this slot (an unimplemented list slot logs its first call, and no title run has logged 0x58), and the change is incomplete against current main. State gained a fixed field that State::clear does not reset, so a list cut at a wait after ClearState would set the old viewports, scissors, blend factor, stencil reference, topology and targets again; host_heaps is set to [0; 2] where main uses usize::MAX; and the tests no longer compile on main.

If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7175798687 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1166#issuecomment-7175798687). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T21:59:33Z. --- Automated triage for the maintainers, second look (a review against current `main`, with builds and tests where they could change the verdict). Closing because the title never calls this slot (an unimplemented list slot logs its first call, and no title run has logged 0x58), and the change is incomplete against current `main`. `State` gained a `fixed` field that `State::clear` does not reset, so a list cut at a wait after `ClearState` would set the old viewports, scissors, blend factor, stencil reference, topology and targets again; `host_heaps` is set to `[0; 2]` where `main` uses `usize::MAX`; and the tests no longer compile on `main`. If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

Pull request closed

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
Marvisak/VIctory!1166
No description provided.