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

Open
opened 2026-11-26 04:14:03 +00:00 by github-bot · 2 comments
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 12:25 UTC · original

Summary

Implements ID3D12GraphicsCommandList::ClearState (vtable slot 11, 0x58) in victory-gpu across both older (LIST_FUNCTIONS) and newer (NEWER_LIST_FUNCTIONS) console command-list layouts.

Because external PR creation is currently restricted (collaborators_only), the CI-green branch is ready on my fork for cherry-pick / review:

  • Branch: geiyiliyabumo/VIctory@feat/list-clear-state
  • Commit: geiyiliyabumo/VIctory@d57ea67 (based on main ffe310e)

Changes

  • crates/victory-gpu/src/draw.rs:
    • Added State::clear(&mut self, pipeline: This) resetting guest bindings (pipeline, heaps, graphics, compute, vertex, index, targets, depth, topology) and cached host state (host_pipeline, host_roots, host_heaps, fresh_tables, table_failed) while preserving self.dynamic descriptor slots still referenced by earlier recorded commands in the same list.
    • Added unit test draw::clear_state_tests::clear_resets_bindings_but_retains_dynamic_slots.
  • crates/victory-gpu/src/list.rs:
    • Added clear_state(this: This, pipeline: This) wired at slot 11 (0x58) in METHODS (shared by both LIST_FUNCTIONS and NEWER_LIST_FUNCTIONS).
    • Calls unsafe { host.list.ClearState(None) } (leaving translated host pipeline binding lazy on the next draw/dispatch), resets guest state via state.clear(pipeline), preserves HostList::states resource-state tracking, and records a diagnostics op note when enabled.
    • Added tests list::tests::clear_state_slot_is_stable and list::tests::clear_state_preserves_recorded_gpu_commands (clears pixel 0 red before ClearState, verifies tracked RENDER_TARGET state survives ClearState, clears pixel 1 green after ClearState, submits and verifies [255, 0, 0, 255, 0, 255, 0, 255] readback).

Verification (Windows 11 x64 MSVC, AMD Radeon RX 9060 XT RDNA4 + WARP)

  • cargo xtask policy: PASS (154 files ok)
  • cargo clippy --workspace --all-targets --locked -- -D warnings (default + --features diagnostics): PASS (0 warnings)
  • cargo test -p victory-gpu --locked -- clear_state: 3/3 PASS (live RX 9060 XT GPU readback)
  • VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --locked -- clear_state: 3/3 PASS
  • cargo test --workspace --locked: PASS (all workspace crates green)

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

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 12:25 UTC · [original](https://github.com/Marvisak/VIctory/issues/848) ### Summary Implements `ID3D12GraphicsCommandList::ClearState` (vtable slot `11`, `0x58`) in `victory-gpu` across both older (`LIST_FUNCTIONS`) and newer (`NEWER_LIST_FUNCTIONS`) console command-list layouts. Because external PR creation is currently restricted (`collaborators_only`), the CI-green branch is ready on my fork for cherry-pick / review: - **Branch**: `geiyiliyabumo/VIctory@feat/list-clear-state` - **Commit**: `geiyiliyabumo/VIctory@d57ea67` (based on `main` `ffe310e`) ### Changes - `crates/victory-gpu/src/draw.rs`: - Added `State::clear(&mut self, pipeline: This)` resetting guest bindings (`pipeline`, `heaps`, `graphics`, `compute`, `vertex`, `index`, `targets`, `depth`, `topology`) and cached host state (`host_pipeline`, `host_roots`, `host_heaps`, `fresh_tables`, `table_failed`) while preserving `self.dynamic` descriptor slots still referenced by earlier recorded commands in the same list. - Added unit test `draw::clear_state_tests::clear_resets_bindings_but_retains_dynamic_slots`. - `crates/victory-gpu/src/list.rs`: - Added `clear_state(this: This, pipeline: This)` wired at slot `11` (`0x58`) in `METHODS` (shared by both `LIST_FUNCTIONS` and `NEWER_LIST_FUNCTIONS`). - Calls `unsafe { host.list.ClearState(None) }` (leaving translated host pipeline binding lazy on the next draw/dispatch), resets guest state via `state.clear(pipeline)`, preserves `HostList::states` resource-state tracking, and records a `diagnostics` op note when enabled. - Added tests `list::tests::clear_state_slot_is_stable` and `list::tests::clear_state_preserves_recorded_gpu_commands` (clears pixel 0 red before `ClearState`, verifies tracked `RENDER_TARGET` state survives `ClearState`, clears pixel 1 green after `ClearState`, submits and verifies `[255, 0, 0, 255, 0, 255, 0, 255]` readback). ### Verification (Windows 11 x64 MSVC, AMD Radeon RX 9060 XT RDNA4 + WARP) - `cargo xtask policy`: **PASS** (`154 files ok`) - `cargo clippy --workspace --all-targets --locked -- -D warnings` (default + `--features diagnostics`): **PASS** (0 warnings) - `cargo test -p victory-gpu --locked -- clear_state`: **3/3 PASS** (live RX 9060 XT GPU readback) - `VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --locked -- clear_state`: **3/3 PASS** - `cargo test --workspace --locked`: **PASS** (all workspace crates green) *AI-assisted; synthetic tests only, no game files.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:14:03 +00:00
Author
Owner

@⁠MichaelSmithAI on GitHub · 2026-11-24 12:55 UTC · original

Melissa checked ClearState together with #158, which adds a dynamic depth range to the list. The two patches apply cleanly, but the saved range survives ClearState and the next bind replays it. With depth cleared to 0.5, a draw after ClearState still failed the old bounds and left 0.5 in the pixel. A draw after Reset wrote the expected 0.25.

The follow-up saves the list's dynamic descriptor allocations, calls the existing guest-state reset helper to clear bindings and saved depth bounds, then restores ownership of the allocations. Earlier recorded commands can still use those slots. On RTX 4090 under Wine/vkd3d-proton 3.2, the draw after ClearState then wrote 0.25. The vertex and mesh readbacks covered fresh, excluded, included, cleared, and reset states. All three original ClearState controls passed, including the two recorded clears.

This is a synthetic result on the combined branches. On #848 alone, the saved-depth-bounds field does not exist. The helper change and readback are available in the integration commit.

**@⁠MichaelSmithAI** on GitHub · 2026-11-24 12:55 UTC · [original](https://github.com/Marvisak/VIctory/issues/848#issuecomment-7132101488) Melissa checked ClearState together with #158, which adds a dynamic depth range to the list. The two patches apply cleanly, but the saved range survives ClearState and the next bind replays it. With depth cleared to 0.5, a draw after ClearState still failed the old bounds and left 0.5 in the pixel. A draw after Reset wrote the expected 0.25. The follow-up saves the list's dynamic descriptor allocations, calls the existing guest-state reset helper to clear bindings and saved depth bounds, then restores ownership of the allocations. Earlier recorded commands can still use those slots. On RTX 4090 under Wine/vkd3d-proton 3.2, the draw after ClearState then wrote 0.25. The vertex and mesh readbacks covered fresh, excluded, included, cleared, and reset states. All three original ClearState controls passed, including the two recorded clears. This is a synthetic result on the combined branches. On #848 alone, the saved-depth-bounds field does not exist. The helper change and readback are available in the [integration commit](https://github.com/MichaelSmithAI/VIctory/commit/5beacc44d558f58b58cfca08e18409303354cb91).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 03:55 UTC · original

Automated triage for the maintainers.

Confirmed missing on main: slot 11 (0x58, ClearState) is not in the METHODS table in crates/victory-gpu/src/list.rs, so it falls into the missing table on both list layouts. This change is now open as PR #1166 (same author), so review continues there.

The comment above notes that the dynamic depth range from #158 would survive ClearState if both landed. Please raise that on #1166 so whichever lands second resets it.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 03:55 UTC · [original](https://github.com/Marvisak/VIctory/issues/848#issuecomment-7152367248) <!-- victory-issue-triage v1 verdict=tracked seen=2026-11-24T12:55:21Z at=2026-11-25T03:55:32Z --> Automated triage for the maintainers. Confirmed missing on `main`: slot 11 (`0x58`, ClearState) is not in the `METHODS` table in `crates/victory-gpu/src/list.rs`, so it falls into the missing table on both list layouts. This change is now open as PR #1166 (same author), so review continues there. The comment above notes that the dynamic depth range from #158 would survive ClearState if both landed. Please raise that on #1166 so whichever lands second resets it. --- _Generated by [Claude Code](https://claude.ai/code)_
This discussion has been locked. Commenting is limited to contributors.
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#848
No description provided.