GPU diagnostics: count clean buffer refreshes once per command list #2669

Closed
github-bot wants to merge 1 commit from github-bot/gh-2669 into main AGit
Owner

@⁠SinisterRob on GitHub · 2026-11-25 17:47 UTC · original
gpu/gre-refresh-readback → main · +29 −16 · 2 files · 1 commits · closed without merging

On main, the diagnostics frame summary prints skipped refresh requests and their byte count, but both counters stay at zero even when the tracked buffer is clean. This makes it hard to tell how much work the existing clean-buffer check avoids.

Count the clean subset of explicit buffer refresh requests and accumulate all four request totals once per command list. Heap and page-table scans keep their own dirty-bit filters. Copies that pass those filters go straight into the batch. The reported skipped bytes measure the requested range, and the log format stays the same.

GPU verification. Tested with a local synthetic harness on an RX 7900 GRE, RADV, Wine 11.22 and vkd3d-proton, using the Windows GNU LLVM target and the optimized diagnostics profile. A closed command list refreshes one tracked 64 KiB buffer and copies its first word to a separate GPU buffer for CPU readback. Resubmitting unchanged, writing a new word, then resubmitting unchanged again yields:

Submission GPU readback Explicit requests Skipped requests Skipped bytes
Initial write 11 1 0 0
Unchanged 11 1 1 65,536
CPU writes again 29 1 0 0
Unchanged 29 1 1 65,536

The same check fails on 13f91ca at the first unchanged submission: readback is correct, both skip counters are zero. The existing batch refresh test also passes.

Diagnostics overhead. In a separate stress case, one closed list issues 8,192 distinct four-byte refresh requests into one clean buffer plus a GPU copy whose result is checked after each submission. Four runs per build, in counterbalanced order, each with 10 warmups and 60 timed submissions. Per-run median wall time in microseconds:

Base Patched
1264, 1285, 1314, 1256 1208, 1211, 1178, 1186

Game frame time is unmeasured. Synthetic inputs only. AI-assisted.

**@⁠SinisterRob** on GitHub · 2026-11-25 17:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/2669) `gpu/gre-refresh-readback` → `main` · +29 −16 · 2 files · 1 commits · closed without merging On main, the diagnostics frame summary prints skipped refresh requests and their byte count, but both counters stay at zero even when the tracked buffer is clean. This makes it hard to tell how much work the existing clean-buffer check avoids. Count the clean subset of explicit buffer refresh requests and accumulate all four request totals once per command list. Heap and page-table scans keep their own dirty-bit filters. Copies that pass those filters go straight into the batch. The reported skipped bytes measure the requested range, and the log format stays the same. **GPU verification.** Tested with a local synthetic harness on an RX 7900 GRE, RADV, Wine 11.22 and vkd3d-proton, using the Windows GNU LLVM target and the optimized diagnostics profile. A closed command list refreshes one tracked 64 KiB buffer and copies its first word to a separate GPU buffer for CPU readback. Resubmitting unchanged, writing a new word, then resubmitting unchanged again yields: | Submission | GPU readback | Explicit requests | Skipped requests | Skipped bytes | |---|---:|---:|---:|---:| | Initial write | 11 | 1 | 0 | 0 | | Unchanged | 11 | 1 | 1 | 65,536 | | CPU writes again | 29 | 1 | 0 | 0 | | Unchanged | 29 | 1 | 1 | 65,536 | The same check fails on `13f91ca` at the first unchanged submission: readback is correct, both skip counters are zero. The existing batch refresh test also passes. **Diagnostics overhead.** In a separate stress case, one closed list issues 8,192 distinct four-byte refresh requests into one clean buffer plus a GPU copy whose result is checked after each submission. Four runs per build, in counterbalanced order, each with 10 warmups and 60 timed submissions. Per-run median wall time in microseconds: | Base | Patched | |---|---| | 1264, 1285, 1314, 1256 | 1208, 1211, 1178, 1186 | Game frame time is unmeasured. Synthetic inputs only. AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:11:38 +00:00
github-bot closed this pull request 2026-11-26 06:30:50 +00:00
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 17:55 UTC · original

Reviewed: counting clean-vs-dirty refreshes and routing only dirty ones to add_dirty makes the stats mean 'work done' — and skipping clean adds also avoids pointless batch growth. Diagnostics-only paths. CI green.

**@⁠kotekompotek** on GitHub · 2026-11-25 17:55 UTC · [original](https://github.com/Marvisak/VIctory/pull/2669#issuecomment-7170201832) Reviewed: counting clean-vs-dirty refreshes and routing only dirty ones to `add_dirty` makes the stats mean 'work done' — and skipping clean adds also avoids pointless batch growth. Diagnostics-only paths. CI green.
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 18:13 UTC · original

Independent verification of head 1b240444de62b5b133cae208eb92598f3c0ac1a9 on origin/main 13f91caee25f2fdf2c062be5f7a27f058e51cbca (merges cleanly, fast-forward).

Environment: Windows 11 Pro 10.0.26100, WARP (d3d10warp 10.0.26100.9818) only, rustc/cargo 1.98.1 (per rust-toolchain.toml), DXC 1.8.2502.11 / dxil.dll 1.8.2502.11 (Windows SDK 10.0.26100.0 x64). VICTORY_WARP=1 and VICTORY_D3D12_WARP=1 set for every run; victory-gpu tests were only run with --features diagnostics (without it the crate opens the default adapter). Limits: no physical GPU, no game files, no title-driven runs; this says nothing about behaviour on real hardware.

  • Focused: ... -p victory-gpu --features diagnostics host::batch -> host::batch::a_copy_is_refreshed_once_per_submission_by_the_pages_written 1 passed (updated to add_dirty).
  • Full crate: 198 passed, 0 failed, 1 ignored. origin/main baseline (cargo test -j 4 --locked -p victory-gpu --features diagnostics): 197 passed, 1 failed (memory::tests::a_submission_that_missed_leaves_the_copies_at_once, memory.rs:886), 1 ignored. That test passed in all four PR runs, so it looks flaky; I did not investigate it, and none of these PRs touch memory.rs.
  • clippy (same four invocations): clean.
  • Negative control: not possible. The PR adds no test, and nothing asserts the Refreshes/Skipped counters, which only exist under diagnostics and are only printed in the stats line. The existing batch test passes before and after, so it covers the unchanged flush behaviour, not this change.
  • Code read: Batch::add's shadow.clean() check moved to the Step::Refresh caller, and Heap/Memory callers already filter on watch::clean_bit (bindless.rs:319, memory.rs:428), so no unfiltered path reaches add_dirty. One small difference: those two paths no longer double-check shadow.clean(), so a shadow whose cached bit is stale-dirty gets a (harmless) no-op update instead of being skipped. No bugs found.
  • Suggestion, non-blocking: a small diagnostics test that runs a deferred list with one clean and one dirty refresh and checks the counter deltas would pin the new once-per-list accounting.

AI disclosure: independent verification by Claude Code / Claude Sonnet 5.5, run for a user; no game files, dumps or hashes involved.

**@⁠oni-swr** on GitHub · 2026-11-25 18:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/2669#issuecomment-7170613729) **Independent verification of head `1b240444de62b5b133cae208eb92598f3c0ac1a9`** on `origin/main` `13f91caee25f2fdf2c062be5f7a27f058e51cbca` (merges cleanly, fast-forward). **Environment:** Windows 11 Pro 10.0.26100, WARP (d3d10warp 10.0.26100.9818) only, rustc/cargo 1.98.1 (per rust-toolchain.toml), DXC 1.8.2502.11 / dxil.dll 1.8.2502.11 (Windows SDK 10.0.26100.0 x64). `VICTORY_WARP=1` and `VICTORY_D3D12_WARP=1` set for every run; `victory-gpu` tests were only run with `--features diagnostics` (without it the crate opens the default adapter). **Limits:** no physical GPU, no game files, no title-driven runs; this says nothing about behaviour on real hardware. - Focused: `... -p victory-gpu --features diagnostics host::batch` -> `host::batch::a_copy_is_refreshed_once_per_submission_by_the_pages_written` 1 passed (updated to `add_dirty`). - Full crate: 198 passed, 0 failed, 1 ignored. `origin/main` baseline (`cargo test -j 4 --locked -p victory-gpu --features diagnostics`): 197 passed, 1 failed (`memory::tests::a_submission_that_missed_leaves_the_copies_at_once`, `memory.rs:886`), 1 ignored. That test passed in all four PR runs, so it looks flaky; I did not investigate it, and none of these PRs touch `memory.rs`. - clippy (same four invocations): clean. - **Negative control: not possible.** The PR adds no test, and nothing asserts the `Refreshes`/`Skipped` counters, which only exist under `diagnostics` and are only printed in the stats line. The existing batch test passes before and after, so it covers the unchanged flush behaviour, not this change. - Code read: `Batch::add`'s `shadow.clean()` check moved to the `Step::Refresh` caller, and `Heap`/`Memory` callers already filter on `watch::clean_bit` (`bindless.rs:319`, `memory.rs:428`), so no unfiltered path reaches `add_dirty`. One small difference: those two paths no longer double-check `shadow.clean()`, so a shadow whose cached bit is stale-dirty gets a (harmless) no-op `update` instead of being skipped. No bugs found. - Suggestion, non-blocking: a small diagnostics test that runs a deferred list with one clean and one dirty refresh and checks the counter deltas would pin the new once-per-list accounting. AI disclosure: independent verification by Claude Code / Claude Sonnet 5.5, run for a user; no game files, dumps or hashes involved.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 19:03 UTC · original

Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP verification and review of 1b240444 (on 13f91ca):

Verification (rustc 1.98.1 MSVC)

  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings and --features diagnostics: 0 warnings.
  • RTX 5090: cargo test --locked -p victory-gpu --features diagnostics --lib host::batch: 1 passed, 0 failed.
  • WARP (VICTORY_D3D12_WARP=1): cargo test --locked -p victory-gpu --features diagnostics --lib -- --test-threads=1: 198 passed, 0 failed, 1 ignored.

Review Notes

  • Stack-local counters in HostList::run_deferred add zero locks, zero heap allocations, and zero cross-reset state; under non-diagnostics builds all counting compiles away completely and lifting shadow.clean() ahead of batch.add_dirty avoids an extra check on already-filtered Step::Heap/Step::Memory calls. Clean and ready to merge.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 19:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/2669#issuecomment-7171752103) Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP verification and review of `1b240444` (on `13f91ca`): ### Verification (`rustc 1.98.1` MSVC) - `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` and `--features diagnostics`: **0 warnings**. - **RTX 5090:** `cargo test --locked -p victory-gpu --features diagnostics --lib host::batch`: **1 passed, 0 failed**. - **WARP (`VICTORY_D3D12_WARP=1`):** `cargo test --locked -p victory-gpu --features diagnostics --lib -- --test-threads=1`: **198 passed, 0 failed, 1 ignored**. ### Review Notes - Stack-local counters in `HostList::run_deferred` add zero locks, zero heap allocations, and zero cross-reset state; under non-`diagnostics` builds all counting compiles away completely and lifting `shadow.clean()` ahead of `batch.add_dirty` avoids an extra check on already-filtered `Step::Heap`/`Step::Memory` calls. Clean and ready to merge.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:24 UTC · original

Automated triage for the maintainers.

Merge candidate (small; diagnostics counters). On main nothing ever adds to C::Skipped/C::SkippedBytes (crates/victory-gpu/src/copystat.rs only prints them), so the frame summary always shows zero skipped refreshes. HostList::run_deferred (crates/victory-gpu/src/host.rs) now checks shadow.clean() at the Step::Refresh caller, counts requests and skips locally, and adds them once per list. Batch::add becomes add_dirty without its own clean check. The Heap and Memory paths already filter on watch::clean_bit (bindless::refresh, memory::prepare), so nothing that was copied before is skipped now; at worst a hull with a stale dirty bit gets a no-op update. It merges cleanly; CI check: passing.

Non-blocking: a small diagnostics test that checks the counter deltas would pin the new accounting.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 22:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/2669#issuecomment-7176315793) <!-- victory-triage v1 head=1b240444de62b5b133cae208eb92598f3c0ac1a9 verdict=merge-candidate at=2026-11-25T22:30:30Z --> Automated triage for the maintainers. **Merge candidate** (small; diagnostics counters). On `main` nothing ever adds to `C::Skipped`/`C::SkippedBytes` (`crates/victory-gpu/src/copystat.rs` only prints them), so the frame summary always shows zero skipped refreshes. `HostList::run_deferred` (`crates/victory-gpu/src/host.rs`) now checks `shadow.clean()` at the `Step::Refresh` caller, counts requests and skips locally, and adds them once per list. `Batch::add` becomes `add_dirty` without its own clean check. The `Heap` and `Memory` paths already filter on `watch::clean_bit` (`bindless::refresh`, `memory::prepare`), so nothing that was copied before is skipped now; at worst a hull with a stale dirty bit gets a no-op update. It merges cleanly; CI `check`: passing. Non-blocking: a small diagnostics test that checks the counter deltas would pin the new accounting. --- _Generated by [Claude Code](https://claude.ai/code)_

Pull request closed

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!2669
No description provided.