GPU: verify exact dirty-page masks on D3D12 #1681

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

@⁠avt0m4t48 on GitHub · 2026-11-24 20:43 UTC · original
avt0m4t48:tests/dirty-page-gpu-compare → main · +621 −0 · 3 files · 1 commits · open

First verification slice for GPU-SNAPSHOT-COST in #1633. Add an original compute kernel and a source-built D3D12 fixture. The host can use this contract to test a GPU comparison path before changing when production snapshots or copy-back run.

The kernel compares immutable before/after raw buffers over a declared byte range. Each changed 64 KiB title page gets a bounded record with its clipped range, one bit per changed byte, and values for changed DWORDs. Capacity overflow is explicit so a caller can retain the existing comparison as a fallback. The fixture compares the exact GPU output with a bytewise Rust oracle, including poisoned unused output and input changes outside the declared byte range. No title files or dumps are used.

Verification

  • cargo test --locked -p victory-gpu --features diagnostics dirty_pages_test:: -- --nocapture --test-threads=1: all 11 synthetic cases passed on Windows D3D12 WARP. The runner had no compatible physical adapter and explicitly skipped that complementary check.
  • Removing the clipped-range mask caused the WARP test to report output mask byte 0x07 where the isolated change requires 0x02. Windows candidate and negative control
  • Linux DXC/dxv and SPIR-V validation passed. The kernel also matched a CPU oracle on llvmpipe for 35 cases, including 24 seeded random input ranges. A separate comparison passed on llvmpipe using the exact 11 Rust fixture inputs. Vulkan experiment and capture-point notes
  • Windows-target Clippy from Linux with diagnostics and the pure Rust blake3 feature passed with warnings denied. Asset policy passed.

The production snapshot and submission paths are unchanged. The next integration tests need to prove the baseline capture point and preservation of adjacent CPU writes during reconciliation. Adapter timings and title performance remain open.

AI-assisted using Codex.

**@⁠avt0m4t48** on GitHub · 2026-11-24 20:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/1681) `avt0m4t48:tests/dirty-page-gpu-compare` → `main` · +621 −0 · 3 files · 1 commits · open First verification slice for `GPU-SNAPSHOT-COST` in #1633. Add an original compute kernel and a source-built D3D12 fixture. The host can use this contract to test a GPU comparison path before changing when production snapshots or copy-back run. The kernel compares immutable before/after raw buffers over a declared byte range. Each changed 64 KiB title page gets a bounded record with its clipped range, one bit per changed byte, and values for changed DWORDs. Capacity overflow is explicit so a caller can retain the existing comparison as a fallback. The fixture compares the exact GPU output with a bytewise Rust oracle, including poisoned unused output and input changes outside the declared byte range. No title files or dumps are used. ## Verification - `cargo test --locked -p victory-gpu --features diagnostics dirty_pages_test:: -- --nocapture --test-threads=1`: all 11 synthetic cases passed on Windows D3D12 WARP. The runner had no compatible physical adapter and explicitly skipped that complementary check. - Removing the clipped-range mask caused the WARP test to report output mask byte `0x07` where the isolated change requires `0x02`. [Windows candidate and negative control](https://github.com/avt0m4t48/VIctory/actions/runs/45483219345) - Linux DXC/`dxv` and SPIR-V validation passed. The kernel also matched a CPU oracle on llvmpipe for 35 cases, including 24 seeded random input ranges. A separate comparison passed on llvmpipe using the exact 11 Rust fixture inputs. [Vulkan experiment and capture-point notes](https://git.gtahub.st/github/Marvisak--VIctory/issues/1633) - Windows-target Clippy from Linux with diagnostics and the pure Rust `blake3` feature passed with warnings denied. Asset policy passed. The production snapshot and submission paths are unchanged. The next integration tests need to prove the baseline capture point and preservation of adjacent CPU writes during reconciliation. Adapter timings and title performance remain open. AI-assisted using Codex.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:41:24 +00:00
Author
Owner

@⁠aycow on GitHub · 2026-11-24 21:51 UTC · original

@⁠avt0m4t48 The shared CPU reconciliation contract is ready for comparison with 9c447fb. It covers exact bytes including unchanged neighbours, writes after the GPU sample, real aliases, partial mappings, guard transitions, overflow and ordered replay. Fence ownership and repeated recording are complementary integration cases. On the #387 harness, the guarded bulk writer passed all 20 copy-ordering controls per adapter on AMD and WARP with full GPU-based validation. The extra preflight roughly doubled the 131,072-run case, so use it as a correctness control rather than a write backend for each fragment. Would you be interested in sharing the replay inputs and expected bytes while timing your GPU compare and CPU replay separately?

AI-assisted using Codex.

**@⁠aycow** on GitHub · 2026-11-24 21:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/1681#issuecomment-7145472593) @⁠avt0m4t48 The [shared CPU reconciliation contract](https://github.com/aycow/VIctory/blob/e4e015ff08589b19762fdabe55148793a30df9b1/docs/copyback-protection.md) is ready for comparison with 9c447fb. It covers exact bytes including unchanged neighbours, writes after the GPU sample, real aliases, partial mappings, guard transitions, overflow and ordered replay. Fence ownership and repeated recording are complementary integration cases. On the #387 harness, the guarded bulk writer passed all 20 copy-ordering controls per adapter on AMD and WARP with full GPU-based validation. The extra preflight roughly doubled the 131,072-run case, so use it as a correctness control rather than a write backend for each fragment. Would you be interested in sharing the replay inputs and expected bytes while timing your GPU compare and CPU replay separately? AI-assisted using Codex.
Author
Owner

@⁠DeerSilver on GitHub · 2026-11-24 23:06 UTC · original

Setup: one laptop with an NVIDIA GeForce RTX 5060 Laptop GPU (Blackwell, 10de:2d59, driver 621.24) and an Intel UHD Graphics (Raptor Lake Xe-LP, 8086:a788, driver 32.0.101.7088), Windows 11 26300, Rust 1.98.1. The PR was merged onto main 70564ae.

  • cargo test --workspace --all-features --locked --no-fail-fast -- --test-threads=1 with the D3D12 debug layer on (VICTORY_D3D12_DEBUG=1, and a local, uncommitted change that also turns the debug layer on in victory-shader's test Host): 477 passed, 5 failed, 7 ignored. The 5 failures are the ones main 70564ae has by itself on NVIDIA (the view-heap cap and the structured-view stride, already reported in #1744); this PR adds none.
  • cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --all-features: clean
  • hardware_dirty_pages ran on the RTX (D3D12 dirty-page adapter (hardware): NVIDIA GeForce RTX 5060 Laptop GPU (0x10de:0x2d59, flags 0x0)) and warp_dirty_pages on WARP (Microsoft Basic Render Driver (0x1414:0x008c, flags 0x2)); both pass every case.

The debug layer gives 22 more lines than main, all of one warning:

D3D12 WARNING: ID3D12Device::CreateCommittedResource: Ignoring InitialState D3D12_RESOURCE_STATE_COPY_DEST. Buffers are effectively created in state D3D12_RESOURCE_STATE_COMMON. [ STATE_CREATION WARNING: CREATERESOURCE_STATE_IGNORED]

It comes from the buffers the new test creates with D3D12_RESOURCE_STATE_COPY_DEST. It's harmless; creating them in D3D12_RESOURCE_STATE_COMMON would silence it.

No game data used. AI-assisted (Claude Code).

**@⁠DeerSilver** on GitHub · 2026-11-24 23:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/1681#issuecomment-7147022782) **Setup:** one laptop with an NVIDIA GeForce RTX 5060 Laptop GPU (Blackwell, `10de:2d59`, driver 621.24) and an Intel UHD Graphics (Raptor Lake Xe-LP, `8086:a788`, driver 32.0.101.7088), Windows 11 26300, Rust 1.98.1. The PR was merged onto `main` `70564ae`. - `cargo test --workspace --all-features --locked --no-fail-fast -- --test-threads=1` with the D3D12 debug layer on (`VICTORY_D3D12_DEBUG=1`, and a local, uncommitted change that also turns the debug layer on in victory-shader's test `Host`): 477 passed, 5 failed, 7 ignored. The 5 failures are the ones `main` `70564ae` has by itself on NVIDIA (the view-heap cap and the structured-view stride, already reported in #1744); this PR adds none. - `cargo clippy --workspace --all-targets --locked -- -D warnings`, with and without `--all-features`: clean - `hardware_dirty_pages` ran on the RTX (`D3D12 dirty-page adapter (hardware): NVIDIA GeForce RTX 5060 Laptop GPU (0x10de:0x2d59, flags 0x0)`) and `warp_dirty_pages` on WARP (`Microsoft Basic Render Driver (0x1414:0x008c, flags 0x2)`); both pass every case. The debug layer gives 22 more lines than `main`, all of one warning: ``` D3D12 WARNING: ID3D12Device::CreateCommittedResource: Ignoring InitialState D3D12_RESOURCE_STATE_COPY_DEST. Buffers are effectively created in state D3D12_RESOURCE_STATE_COMMON. [ STATE_CREATION WARNING: CREATERESOURCE_STATE_IGNORED] ``` It comes from the buffers the new test creates with `D3D12_RESOURCE_STATE_COPY_DEST`. It's harmless; creating them in `D3D12_RESOURCE_STATE_COMMON` would silence it. No game data used. AI-assisted (Claude Code).
Author
Owner

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

Automated triage for the maintainers.

Needs work. This adds a dirty-page compare kernel (crates/victory-gpu/src/dirty_pages.hlsl) and a WARP/hardware test that checks it against a bytewise Rust oracle (dirty_pages_test.rs). The kernel and test read correctly, but nothing in shadow.rs or the copy-back path uses the kernel ("production snapshot and submission paths are unchanged"), so main would carry an unused shader whose only caller is its own test. Please send it together with its first use in shadow.rs (writing / copy_back), or stack that PR on this one, so the kernel arrives with a user and a measurement. Minor: a tester's debug-layer run reports CREATERESOURCE_STATE_IGNORED for the buffers created in COPY_DEST; creating them in COMMON silences it. CI: no check runs on this head.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 03:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/1681#issuecomment-7152022900) <!-- victory-triage v1 head=9c447fbdd049e215d72c091a2e78f6b7d77b69e6 verdict=needs-work at=2026-11-25T03:36:20Z --> Automated triage for the maintainers. **Needs work.** This adds a dirty-page compare kernel (`crates/victory-gpu/src/dirty_pages.hlsl`) and a WARP/hardware test that checks it against a bytewise Rust oracle (`dirty_pages_test.rs`). The kernel and test read correctly, but nothing in `shadow.rs` or the copy-back path uses the kernel ("production snapshot and submission paths are unchanged"), so `main` would carry an unused shader whose only caller is its own test. Please send it together with its first use in `shadow.rs` (`writing` / `copy_back`), or stack that PR on this one, so the kernel arrives with a user and a measurement. Minor: a tester's debug-layer run reports `CREATERESOURCE_STATE_IGNORED` for the buffers created in `COPY_DEST`; creating them in `COMMON` silences it. CI: no check runs on this head. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠MrEjecutor on GitHub · 2026-11-25 20:38 UTC · original

A physical-adapter data point for this, since the description says the runner had none: on an RTX 5060 Ti 16 GB (Blackwell, driver 621.24, Windows 11 26200), 9c447fb merged cleanly onto current main (13f91ca, plus a few open NVIDIA PRs and #2705), and cargo test --locked -p victory-gpu --lib -- dirty_pages_test --test-threads=1 --nocapture passes both hardware_dirty_pages and warp_dirty_pages, with no "SKIP ... no compatible physical adapter" line, so the hardware case ran on the card.

If it helps the next slice: in a world run of that stack the CPU side this would replace costs about 39 ms and ~300 MB of snapshots a frame here ("snapshots ... MB in ... ms" on the copystat line), and with #2705's card copies on, the declared writes the comparison would read already live in video memory.

Not tested: rustc 1.98.1 (stable 1.100 here); the diagnostics feature; anything beyond the two tests.

AI use: Claude Code (Claude Opus 5.5) ran and wrote this; checked by mrejecutor.

**@⁠MrEjecutor** on GitHub · 2026-11-25 20:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/1681#issuecomment-7173966985) A physical-adapter data point for this, since the description says the runner had none: on an RTX 5060 Ti 16 GB (Blackwell, driver 621.24, Windows 11 26200), `9c447fb` merged cleanly onto current `main` (`13f91ca`, plus a few open NVIDIA PRs and #2705), and `cargo test --locked -p victory-gpu --lib -- dirty_pages_test --test-threads=1 --nocapture` passes both `hardware_dirty_pages` and `warp_dirty_pages`, with no "SKIP ... no compatible physical adapter" line, so the hardware case ran on the card. If it helps the next slice: in a world run of that stack the CPU side this would replace costs about 39 ms and ~300 MB of snapshots a frame here ("snapshots ... MB in ... ms" on the copystat line), and with #2705's card copies on, the declared writes the comparison would read already live in video memory. Not tested: rustc 1.98.1 (stable 1.100 here); the diagnostics feature; anything beyond the two tests. AI use: Claude Code (Claude Opus 5.5) ran and wrote this; checked by mrejecutor.
Author
Owner

@⁠pokces on GitHub · 2026-11-26 07:02 UTC · original · edited 2026-11-26 07:07 UTC

On a physical RX 9070 XT (1002:7550, Windows 11 build 26300, driver 32.0.32029.2010), the unmodified 9c447fb passed all 11 oracle cases on both the card and WARP. I also measured the cost of discovering the readback size, following the RTX 3080 comparison above. Opt-in test and benchmark source

Each input was 32 MiB in a DEFAULT heap (512 pages). One seeded byte changed per selected page. The same DIRECT queue ran both the existing kernel and the full-buffer control. The table gives the range of two run medians, seven samples per run after one warm-up, with method order rotated.

Dirty pages Pre-sized result Compare + pre-sized readback, GPU ms Full 32 MiB readback, GPU ms
5/512 0.35 MiB 0.257 0.562–0.572
256/512 18.01 MiB 0.545–0.561 0.570–0.579
384/512 27.01 MiB 0.733–0.736 0.572–0.580
448/512 31.51 MiB 0.824–0.862 0.577–0.587
512/512 36.01 MiB 0.910–0.927 0.570–0.571

When the CPU needs the count first, the harness reads the 16-byte GPU header, waits, and submits the payload copy. With 5 dirty pages the two GPU intervals summed to 0.253–0.254 ms, but the helper took 1.856–1.936 ms wall-clock, compared with 1.605–1.656 ms for a full readback. With 512 dirty pages the header selected the full-buffer fallback. Capacity was 512 throughout. The pre-sized column assumes the size is known before submission.

Wall time includes list/allocator and fence creation, CPU waits, and timestamp resolution/mapping in the debug Rust test harness. Input and output initialization, baseline capture, and CPU reconciliation are outside the measurements. Hardware timestamps exclude the CPU wait between submissions. Desktop capture remained active. This suggests testing whether the count read can overlap other work at the proposed production capture point.

To reproduce, check out the linked commit, then run:

$env:VICTORY_DIRTY_PAGE_BENCH = '1'
cargo test --locked -p victory-gpu --features diagnostics --lib dirty_pages_test::hardware_dirty_pages -- --nocapture --test-threads=1

The added benchmark harness and this report were generated by GPT 6.2 Astra. The dirty-page kernel under test is from the original PR; the timings were measured on the RX 9070 XT.

**@⁠pokces** on GitHub · 2026-11-26 07:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/1681#issuecomment-7185037133) · edited 2026-11-26 07:07 UTC On a physical **RX 9070 XT** (`1002:7550`, Windows 11 build 26300, driver 32.0.32029.2010), the unmodified `9c447fb` passed all 11 oracle cases on both the card and WARP. I also measured the cost of discovering the readback size, following the RTX 3080 comparison above. [Opt-in test and benchmark source](https://github.com/pokces/VIctory-Backup/commit/dd72ea8e806160ff377d412eb2a9fe573dc7e22d) Each input was 32 MiB in a DEFAULT heap (512 pages). One seeded byte changed per selected page. The same DIRECT queue ran both the existing kernel and the full-buffer control. The table gives the range of two run medians, seven samples per run after one warm-up, with method order rotated. | Dirty pages | Pre-sized result | Compare + pre-sized readback, GPU ms | Full 32 MiB readback, GPU ms | |---:|---:|---:|---:| | 5/512 | 0.35 MiB | 0.257 | 0.562–0.572 | | 256/512 | 18.01 MiB | 0.545–0.561 | 0.570–0.579 | | 384/512 | 27.01 MiB | 0.733–0.736 | 0.572–0.580 | | 448/512 | 31.51 MiB | 0.824–0.862 | 0.577–0.587 | | 512/512 | 36.01 MiB | 0.910–0.927 | 0.570–0.571 | **When the CPU needs the count first**, the harness reads the 16-byte GPU header, waits, and submits the payload copy. With 5 dirty pages the two GPU intervals summed to **0.253–0.254 ms**, but the helper took **1.856–1.936 ms wall-clock**, compared with **1.605–1.656 ms** for a full readback. With 512 dirty pages the header selected the full-buffer fallback. Capacity was 512 throughout. The pre-sized column assumes the size is known before submission. Wall time includes list/allocator and fence creation, CPU waits, and timestamp resolution/mapping in the debug Rust test harness. Input and output initialization, baseline capture, and CPU reconciliation are outside the measurements. Hardware timestamps exclude the CPU wait between submissions. Desktop capture remained active. This suggests testing whether the count read can overlap other work at the proposed production capture point. To reproduce, check out the linked commit, then run: ```powershell $env:VICTORY_DIRTY_PAGE_BENCH = '1' cargo test --locked -p victory-gpu --features diagnostics --lib dirty_pages_test::hardware_dirty_pages -- --nocapture --test-threads=1 ``` --- The added benchmark harness and this report were generated by GPT 6.2 Astra. The dirty-page kernel under test is from the original PR; the timings were measured on the RX 9070 XT.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/1681/head:github-bot/gh-1681'
git switch 'github-bot/gh-1681'

Merge

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