GPU: implement ClearState on command lists #2984

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

@⁠fuzeofficlal on GitHub · 2026-11-26 02:12 UTC · original
fuzeofficlal:fix/gpu-list-clear-state → main · +290 −8 · 2 files · 1 commits · open

Problem

ID3D12GraphicsCommandList::ClearState (slot 11 / 0x58) was missing from METHODS in crates/victory-gpu/src/list.rs and fell through to the generic unimplemented stub. Because ClearState returns void, calling ClearState(pso_b) silently left State.pipeline pointing to the previous pipeline along with stale root arguments, descriptor heaps, render/depth targets, vertex/index views, topology, depth bounds, and Fixed replay state, and never cleared the host command list.

Fix

  • Register clear_state at slot 11 (0x58) in METHODS (preserving the same slot in both LIST_FUNCTIONS and NEWER_LIST_FUNCTIONS).
  • On open DIRECT and COMPUTE lists, call host.list.ClearState(None), clear all guest and cached host bindings plus Fixed replay state via State::clear_state(pipeline) while preserving resources needed by previously recorded commands (dynamic, fresh_tables, root_slots, root_run, memory, deferred uploads/copies), and record pipeline::bound(pipeline).
  • Track explicit guest closed state on List (distinct from internal segment cuts at waits) so ClearState on a closed list is safely ignored.

Verification

  • Added draw::tests::clear_state_switches_compute_pipeline_without_losing_recorded_work (executes two Wave32 compute pipelines across ClearState(b) in a single list and reads back both title buffers), draw::tests::clear_state_clears_graphics_bindings_before_a_segment_cut (verifies all bindings and Fixed state clear before a wait64 segment cut while retaining recorded dynamic/memory/deferred work), and list::tests::clear_state_has_the_same_slot_in_both_layouts.
  • cargo test --locked -p victory-gpu --lib -- list:: draw:: --test-threads=1 (VICTORY_D3D12_DEBUG=1): 27/27 passed on both hardware D3D12 (RTX 5090) and WARP.
  • cargo clippy --locked -p victory-gpu --tests -- -D warnings (default & --features diagnostics): 0 warnings.
  • cargo xtask policy: 191 files ok.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 02:12 UTC · [original](https://github.com/Marvisak/VIctory/pull/2984) `fuzeofficlal:fix/gpu-list-clear-state` → `main` · +290 −8 · 2 files · 1 commits · open ## Problem `ID3D12GraphicsCommandList::ClearState` (slot 11 / `0x58`) was missing from `METHODS` in `crates/victory-gpu/src/list.rs` and fell through to the generic unimplemented stub. Because `ClearState` returns `void`, calling `ClearState(pso_b)` silently left `State.pipeline` pointing to the previous pipeline along with stale root arguments, descriptor heaps, render/depth targets, vertex/index views, topology, depth bounds, and `Fixed` replay state, and never cleared the host command list. ## Fix - Register `clear_state` at slot 11 (`0x58`) in `METHODS` (preserving the same slot in both `LIST_FUNCTIONS` and `NEWER_LIST_FUNCTIONS`). - On open `DIRECT` and `COMPUTE` lists, call `host.list.ClearState(None)`, clear all guest and cached host bindings plus `Fixed` replay state via `State::clear_state(pipeline)` while preserving resources needed by previously recorded commands (`dynamic`, `fresh_tables`, `root_slots`, `root_run`, `memory`, deferred uploads/copies), and record `pipeline::bound(pipeline)`. - Track explicit guest `closed` state on `List` (distinct from internal segment cuts at waits) so `ClearState` on a closed list is safely ignored. ## Verification - Added `draw::tests::clear_state_switches_compute_pipeline_without_losing_recorded_work` (executes two Wave32 compute pipelines across `ClearState(b)` in a single list and reads back both title buffers), `draw::tests::clear_state_clears_graphics_bindings_before_a_segment_cut` (verifies all bindings and `Fixed` state clear before a `wait64` segment cut while retaining recorded `dynamic`/`memory`/deferred work), and `list::tests::clear_state_has_the_same_slot_in_both_layouts`. - `cargo test --locked -p victory-gpu --lib -- list:: draw:: --test-threads=1` (`VICTORY_D3D12_DEBUG=1`): **27/27 passed** on both hardware D3D12 (RTX 5090) and WARP. - `cargo clippy --locked -p victory-gpu --tests -- -D warnings` (default & `--features diagnostics`): 0 warnings. - `cargo xtask policy`: 191 files ok.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:19:19 +00:00
Author
Owner

@⁠oni-swr on GitHub · 2026-11-26 03:02 UTC · original

Independent Windows WARP test run of 3cdfd5f875c44e2249fa46abee76ff57ab5d9187, compared with its exact parent 63bcca43c6a00a758510398fa43096ce7e4f7df0. This reports test results only, not a review verdict.

Setup. Software only. VICTORY_D3D12_WARP=1 and VICTORY_WARP=1, built with --features diagnostics. VICTORY_DXIL pointed at the Windows SDK 10.0.26100.0 x64 dxil.dll, but the victory-gpu lib tests never loaded it: a probe found no dxil.dll module in the process after creating the translated pipelines. Before any dispatch, each probe checked that the host device's adapter LUID matches EnumWarpAdapter: Microsoft Basic Render Driver, vendor 0x1414, device 0x8c, software flag set. No hardware GPU was used. No game files, dumps or shader data, only synthetic state and programs.

Command. cargo test --locked -j 4 -p victory-gpu --features diagnostics --lib -- --test-threads=1, plus filtered runs (probe_attest, probe_, list::).

Local probes (not pushed). Each one calls vtable slot 0x58 on a title list:

Probe Parent 63bcca4 Head 3cdfd5f8
Open direct list with pipeline, heaps, graphics and compute roots, vertex/index views, targets, depth, depth bounds, topology, host cache, table_failed and fixed topology/stencil set. After ClearState(null) all 16 are cleared, and fresh_tables, root_slots and root_run are kept fails: none cleared (the slot goes to the E_NOTIMPL stub) passes
ClearState after Close leaves state untouched. After Reset it clears again. On a bundle it leaves state untouched fails at the reopened case (no clear) passes
One compute list (type 2) created with A: dispatch A, ClearState(B), dispatch, ClearState(A), dispatch, each into its own page. Expected [A,B,A] fails: [A,A,A] passes: [0x0badc0de, 0x5eed1234, 0x0badc0de], one segment
The same on a direct list (type 0) fails: [A,A,A] passes

The synthetic Wave32 store program in the GPU probes uses the packet layout from this PR's test, with different values. The sequence checked is independent of the PR's tests.

Counts.

  • list:: on the head: 5 passed (including clear_state_has_the_same_slot_in_both_layouts).
  • Full victory-gpu lib suite on the head: 249 of the tree's 250 tests passed, 1 ignored (benchmark_private_data_release), including draw::tests::clear_state_switches_compute_pipeline_without_losing_recorded_work and draw::tests::clear_state_clears_graphics_bindings_before_a_segment_cut. The suite total also included the WARP attestation probe and 4 unrelated local mesh-clamp probes for #2996; 3 of those fail here as they do on the parent.
  • Parent: 246 passed, 1 ignored. All 4 ClearState probes failed as shown above.

AI-assisted: Claude Code (Claude Opus 5.5), coordinated by Codex (gpt-6.2-sol).

**@⁠oni-swr** on GitHub · 2026-11-26 03:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/2984#issuecomment-7181342190) Independent Windows WARP test run of `3cdfd5f875c44e2249fa46abee76ff57ab5d9187`, compared with its exact parent `63bcca43c6a00a758510398fa43096ce7e4f7df0`. This reports test results only, not a review verdict. **Setup.** Software only. `VICTORY_D3D12_WARP=1` and `VICTORY_WARP=1`, built with `--features diagnostics`. `VICTORY_DXIL` pointed at the Windows SDK 10.0.26100.0 x64 `dxil.dll`, but the victory-gpu lib tests never loaded it: a probe found no `dxil.dll` module in the process after creating the translated pipelines. Before any dispatch, each probe checked that the host device's adapter LUID matches `EnumWarpAdapter`: `Microsoft Basic Render Driver`, vendor `0x1414`, device `0x8c`, software flag set. No hardware GPU was used. No game files, dumps or shader data, only synthetic state and programs. **Command.** `cargo test --locked -j 4 -p victory-gpu --features diagnostics --lib -- --test-threads=1`, plus filtered runs (`probe_attest`, `probe_`, `list::`). **Local probes (not pushed).** Each one calls vtable slot `0x58` on a title list: | Probe | Parent `63bcca4` | Head `3cdfd5f8` | |---|---|---| | Open direct list with pipeline, heaps, graphics and compute roots, vertex/index views, targets, depth, depth bounds, topology, host cache, `table_failed` and fixed topology/stencil set. After `ClearState(null)` all 16 are cleared, and `fresh_tables`, `root_slots` and `root_run` are kept | fails: none cleared (the slot goes to the E_NOTIMPL stub) | passes | | `ClearState` after `Close` leaves state untouched. After `Reset` it clears again. On a bundle it leaves state untouched | fails at the reopened case (no clear) | passes | | One compute list (type 2) created with A: dispatch A, `ClearState(B)`, dispatch, `ClearState(A)`, dispatch, each into its own page. Expected `[A,B,A]` | fails: `[A,A,A]` | passes: `[0x0badc0de, 0x5eed1234, 0x0badc0de]`, one segment | | The same on a direct list (type 0) | fails: `[A,A,A]` | passes | The synthetic Wave32 store program in the GPU probes uses the packet layout from this PR's test, with different values. The sequence checked is independent of the PR's tests. **Counts.** - `list::` on the head: 5 passed (including `clear_state_has_the_same_slot_in_both_layouts`). - Full victory-gpu lib suite on the head: 249 of the tree's 250 tests passed, 1 ignored (`benchmark_private_data_release`), including `draw::tests::clear_state_switches_compute_pipeline_without_losing_recorded_work` and `draw::tests::clear_state_clears_graphics_bindings_before_a_segment_cut`. The suite total also included the WARP attestation probe and 4 unrelated local mesh-clamp probes for #2996; 3 of those fail here as they do on the parent. - Parent: 246 passed, 1 ignored. All 4 ClearState probes failed as shown above. AI-assisted: Claude Code (Claude Opus 5.5), coordinated by Codex (gpt-6.2-sol).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 05:26 UTC · original

Automated triage for the maintainers.

Merge candidate (recommending a look, not approving). On main, slot 11 (0x58) of the list vtable in crates/victory-gpu/src/list.rs falls to the unimplemented stub. This PR adds clear_state, which follows the public D3D12 ClearState contract: it acts only on open direct and compute lists, sets the given pipeline, clears the host list, and resets the title-side bindings through the new State::clear_state in draw.rs. It keeps what already-recorded work still needs (dynamic slots, fresh tables, root views, the memory map). The new closed flag is set by close and cleared by reset, so segment cuts at waits do not count as closed. The compute test runs two pipelines across a ClearState in one list and reads back both results, and the graphics test checks each field. A separate WARP run posted here shows the probes fail on main and pass on this head. CI check passes.

One thing worth confirming: whether the title calls ClearState at all. That would decide how much this matters, not whether it is correct.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 05:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/2984#issuecomment-7183486318) <!-- victory-triage v1 head=3cdfd5f875c44e2249fa46abee76ff57ab5d9187 verdict=merge-candidate at=2026-11-26T05:28:00Z --> Automated triage for the maintainers. **Merge candidate** (recommending a look, not approving). On `main`, slot 11 (`0x58`) of the list vtable in `crates/victory-gpu/src/list.rs` falls to the unimplemented stub. This PR adds `clear_state`, which follows the public D3D12 `ClearState` contract: it acts only on open direct and compute lists, sets the given pipeline, clears the host list, and resets the title-side bindings through the new `State::clear_state` in `draw.rs`. It keeps what already-recorded work still needs (dynamic slots, fresh tables, root views, the memory map). The new `closed` flag is set by `close` and cleared by `reset`, so segment cuts at waits do not count as closed. The compute test runs two pipelines across a `ClearState` in one list and reads back both results, and the graphics test checks each field. A separate WARP run posted here shows the probes fail on `main` and pass on this head. CI `check` passes. One thing worth confirming: whether the title calls `ClearState` at all. That would decide how much this matters, not whether it is correct. --- _Generated by [Claude Code](https://claude.ai/code)_
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/2984/head:github-bot/gh-2984'
git switch 'github-bot/gh-2984'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2984'
git switch 'github-bot/gh-2984'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2984'
git switch 'github-bot/gh-2984'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2984'
git switch 'main'
git merge --squash 'github-bot/gh-2984'
git switch 'main'
git merge --ff-only 'github-bot/gh-2984'
git switch 'main'
git merge 'github-bot/gh-2984'
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!2984
No description provided.