GPU: implement DiscardResource (slot 55) on command lists with region and state checks (fix on a fork) #835

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

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

ID3D12GraphicsCommandList::DiscardResource (vtable slot 55, 0x1b8) currently falls into missing_table on both older and newer command-list layouts.

Tested Fix Ready on Fork

External PR creation is currently restricted (collaborators_only), so the verified patch is ready on my fork (based on main ffe310e):

Changes (crates/victory-gpu/src/list.rs, crates/victory-gpu/src/host.rs):

  • Wires discard_resource at slot 55 (0x1b8) on both LIST_FUNCTIONS and NEWER_LIST_FUNCTIONS, with compile-time Windows ABI size/alignment assertions against D3D12_DISCARD_REGION and RECT.
  • Adds read-only HostList::tracked_texture_state and only forwards DiscardResource when the current list holds the host texture in a discard-legal state (RENDER_TARGET, DEPTH_WRITE, or UNORDERED_ACCESS) matching the texture's resource flags; null/buffer resources, invalid regions, and untracked/incompatible textures are clean no-ops without introducing spurious barriers.
  • Validates DiscardRegion bounds (subresource range with D3D12_FEATURE_FORMAT_INFO plane count, overflow safety, 2D-only and single-mip-extent rules for rects, non-inverted rect geometry).
  • Adds 4 synthetic unit + live D3D12 tests (discard_resource_slot_is_stable, discard_region_validation, discard_requires_matching_state_and_flags, discard_resource_executes_on_guest_queue).

Verification (Windows 11 Pro 26100, AMD Radeon RX 9060 XT driver 32.0.32029.2010, Rust 1.98.1):

  • cargo xtask policy: PASS (154 files ok)
  • cargo clippy --workspace --all-targets --locked -- -D warnings: PASS
  • cargo clippy --workspace --all-targets --features diagnostics --locked -- -D warnings: PASS
  • cargo test -p victory-gpu --locked -- discard --nocapture: 4/4 PASS (live discard adapter: AMD Radeon RX 9060 XT)
  • VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --locked -- discard --nocapture: 4/4 PASS (live discard adapter: Microsoft Basic Render Driver)
  • cargo test --workspace --locked: PASS (0 failed)

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

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 11:53 UTC · [original](https://github.com/Marvisak/VIctory/issues/835) `ID3D12GraphicsCommandList::DiscardResource` (vtable slot `55`, `0x1b8`) currently falls into `missing_table` on both older and newer command-list layouts. ### Tested Fix Ready on Fork External PR creation is currently restricted (`collaborators_only`), so the verified patch is ready on my fork (based on `main` `ffe310e`): - Branch: https://github.com/geiyiliyabumo/VIctory/tree/feat/list-discard-resource - Commit: https://github.com/geiyiliyabumo/VIctory/commit/735f3af **Changes (`crates/victory-gpu/src/list.rs`, `crates/victory-gpu/src/host.rs`):** - Wires `discard_resource` at slot `55` (`0x1b8`) on both `LIST_FUNCTIONS` and `NEWER_LIST_FUNCTIONS`, with compile-time Windows ABI size/alignment assertions against `D3D12_DISCARD_REGION` and `RECT`. - Adds read-only `HostList::tracked_texture_state` and only forwards `DiscardResource` when the current list holds the host texture in a discard-legal state (`RENDER_TARGET`, `DEPTH_WRITE`, or `UNORDERED_ACCESS`) matching the texture's resource flags; null/buffer resources, invalid regions, and untracked/incompatible textures are clean no-ops without introducing spurious barriers. - Validates `DiscardRegion` bounds (subresource range with `D3D12_FEATURE_FORMAT_INFO` plane count, overflow safety, 2D-only and single-mip-extent rules for rects, non-inverted rect geometry). - Adds 4 synthetic unit + live D3D12 tests (`discard_resource_slot_is_stable`, `discard_region_validation`, `discard_requires_matching_state_and_flags`, `discard_resource_executes_on_guest_queue`). **Verification (Windows 11 Pro 26100, AMD Radeon RX 9060 XT driver `32.0.32029.2010`, Rust `1.98.1`):** - `cargo xtask policy`: PASS (`154 files ok`) - `cargo clippy --workspace --all-targets --locked -- -D warnings`: PASS - `cargo clippy --workspace --all-targets --features diagnostics --locked -- -D warnings`: PASS - `cargo test -p victory-gpu --locked -- discard --nocapture`: **4/4 PASS** (`live discard adapter: AMD Radeon RX 9060 XT`) - `VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --features diagnostics --locked -- discard --nocapture`: **4/4 PASS** (`live discard adapter: Microsoft Basic Render Driver`) - `cargo test --workspace --locked`: PASS (0 failed) *AI-assisted; synthetic tests only, no game files.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:14:02 +00:00
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-24 12:10 UTC · original

I tested a valid first-use case on 735f3af. One DIRECT list cleared an 8×8 RGBA8 render target and submitted. A fresh DIRECT list then called the guest discard slot before its first clear. On both RTX 5090 and WARP, that discard reached the native call zero times. The same-list control after a clear reached it once.

Follow-up 17cd278 uses the existing submission prelude for the first RT or depth use, after region validation. The same probe then observed one native call for each RTV case on both adapters and read back the expected post-clear color. A D32 texture created in DEPTH_WRITE also forwarded its first-use discard and completed a depth clear on both adapters.

The three existing slot, region and state tests passed, along with diagnostics Clippy and the asset check. The follow-up applies directly on top of your branch.

**@⁠fuzeofficlal** on GitHub · 2026-11-24 12:10 UTC · [original](https://github.com/Marvisak/VIctory/issues/835#issuecomment-7131062294) I tested a valid first-use case on `735f3af`. One DIRECT list cleared an 8×8 RGBA8 render target and submitted. A fresh DIRECT list then called the guest discard slot before its first clear. On both RTX 5090 and WARP, that discard reached the native call zero times. The same-list control after a clear reached it once. [Follow-up `17cd278`](https://github.com/fuzeofficlal/VIctory/commit/17cd278321852d098e298fa8d5afdde2e9576a0e) uses the existing submission prelude for the first RT or depth use, after region validation. The same probe then observed one native call for each RTV case on both adapters and read back the expected post-clear color. A D32 texture created in `DEPTH_WRITE` also forwarded its first-use discard and completed a depth clear on both adapters. The three existing slot, region and state tests passed, along with diagnostics Clippy and the asset check. The follow-up applies directly on top of your branch.
Author
Owner

@⁠nopsled0x on GitHub · 2026-11-24 12:43 UTC · original

I checked feat/list-discard-resource (735f3af, on top of ffe310e) on Windows 10, debug build:

  • cargo test -p victory-gpu --locked -- discard: 4/4 pass on a real adapter (NVIDIA GeForce RTX 5060 Ti) and 4/4 on WARP (VICTORY_D3D12_WARP=1 with --features diagnostics). discard_resource_executes_on_guest_queue ran (was not skipped) in both runs, on the RTX 5060 Ti and on WARP.
  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings: clean.
  • From reading the diff: the slot 55 wiring, the region validation and the state/flag gating look consistent, and I found no path that panics inside the extern "system" function.
  • The follow-up 17cd278 (from the comment above) also passes the same 4 tests. None of the 4 tests exercises the first-use-on-a-fresh-list case it describes, so I could not confirm that claim by test. From reading the code (not tested), without this follow-up the first use on a fresh list does not reach the native call.

Not verified: cargo test --workspace, xtask policy, workspace-wide clippy, clippy on 17cd278, or in-game behavior.

AI-assisted verification (Claude); tests were run locally by me.

**@⁠nopsled0x** on GitHub · 2026-11-24 12:43 UTC · [original](https://github.com/Marvisak/VIctory/issues/835#issuecomment-7131825330) I checked `feat/list-discard-resource` (735f3af, on top of ffe310e) on Windows 10, debug build: - `cargo test -p victory-gpu --locked -- discard`: 4/4 pass on a real adapter (NVIDIA GeForce RTX 5060 Ti) and 4/4 on WARP (`VICTORY_D3D12_WARP=1` with `--features diagnostics`). `discard_resource_executes_on_guest_queue` ran (was not skipped) in both runs, on the RTX 5060 Ti and on WARP. - `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings`: clean. - From reading the diff: the slot 55 wiring, the region validation and the state/flag gating look consistent, and I found no path that panics inside the `extern "system"` function. - The follow-up `17cd278` (from the comment above) also passes the same 4 tests. None of the 4 tests exercises the first-use-on-a-fresh-list case it describes, so I could not confirm that claim by test. From reading the code (not tested), without this follow-up the first use on a fresh list does not reach the native call. Not verified: `cargo test --workspace`, `xtask policy`, workspace-wide clippy, clippy on `17cd278`, or in-game behavior. _AI-assisted verification (Claude); tests were run locally by me._
Author
Owner

@⁠wanchudao on GitHub · 2026-11-24 15:46 UTC · original

Tested geiyiliyabumo/VIctory's feat/list-discard-resource branch at 735f3af on
Windows 11 Pro build 26300 with an RTX 3070 Ti (driver 610.88), rustc 1.98.1,
MSVC 14.44.35207, and Windows SDK 10.0.26100.0.

cargo test -p victory-gpu --lib discard -- --nocapture

The four existing discard tests passed, with 0 failures, 0 ignored, and 51 filtered
out. The live guest-queue test printed live discard adapter: NVIDIA GeForce RTX 3070 Ti.

This adds an RTX 3070 Ti result for the existing tests. The run did not cover the
first-use discard case on a fresh command list discussed in this thread.

AI use — DeepSeek Harness (DeepSeek V4.1 Flash) ran the tests and drafted this report.
OpenAI Codex (GPT-6.2 Sol) checked the archived results and revised it.

**@⁠wanchudao** on GitHub · 2026-11-24 15:46 UTC · [original](https://github.com/Marvisak/VIctory/issues/835#issuecomment-7136592026) Tested geiyiliyabumo/VIctory's feat/list-discard-resource branch at 735f3af on Windows 11 Pro build 26300 with an RTX 3070 Ti (driver 610.88), rustc 1.98.1, MSVC 14.44.35207, and Windows SDK 10.0.26100.0. `cargo test -p victory-gpu --lib discard -- --nocapture` The four existing discard tests passed, with 0 failures, 0 ignored, and 51 filtered out. The live guest-queue test printed `live discard adapter: NVIDIA GeForce RTX 3070 Ti`. This adds an RTX 3070 Ti result for the existing tests. The run did not cover the first-use discard case on a fresh command list discussed in this thread. AI use — DeepSeek Harness (DeepSeek V4.1 Flash) ran the tests and drafted this report. OpenAI Codex (GPT-6.2 Sol) checked the archived results and revised it.
Author
Owner

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

Automated triage for the maintainers.

The reported gap is fixed in main: slot 55 (0x1b8, DiscardResource) is no longer missing. Since commit 0b35b7f both method tables in crates/victory-gpu/src/list.rs map it to ignored_state (a no-op, which is valid because a discard only says the contents may be undefined), and the test unordered_access_clears_have_the_same_slots_in_both_layouts pins that slot in both layouts.

Forwarding the discard to the host list is a possible optimization on top of that, not a correctness fix. Pull requests are open to everyone again (see #717), so if you want it considered, please open a PR against current main that includes the first-use follow-up from the comments (17cd278), with a measurement showing it helps. Proposed for closing as fixed in main; this will be closed in 48 hours unless the reporter replies or a maintainer removes the label.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 03:54 UTC · [original](https://github.com/Marvisak/VIctory/issues/835#issuecomment-7152353795) <!-- victory-issue-triage v1 verdict=proposed-close seen=2026-11-24T15:46:35Z at=2026-11-25T03:54:40Z --> Automated triage for the maintainers. The reported gap is fixed in `main`: slot 55 (`0x1b8`, DiscardResource) is no longer missing. Since commit `0b35b7f` both method tables in `crates/victory-gpu/src/list.rs` map it to `ignored_state` (a no-op, which is valid because a discard only says the contents may be undefined), and the test `unordered_access_clears_have_the_same_slots_in_both_layouts` pins that slot in both layouts. Forwarding the discard to the host list is a possible optimization on top of that, not a correctness fix. Pull requests are open to everyone again (see #717), so if you want it considered, please open a PR against current `main` that includes the first-use follow-up from the comments (`17cd278`), with a measurement showing it helps. Proposed for closing as fixed in `main`; this will be closed in 48 hours unless the reporter replies or a maintainer removes the label. --- _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#835
No description provided.