Replay: sample depth and stencil using their copy layouts #1017

Merged
invismann merged 1 commit from upstream-pr/1017 into main 2026-11-29 08:16:57 +00:00
invismann commented 2026-11-28 11:14:06 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by invismann on 2026-11-28T11:14:06Z.


replay --pixel --depth read texels using the packed depth-stencil texture's format. D3D12 copies depth and stencil as separate planes. On an R32G8X24 texture, calculating the depth offset with the packed eight-byte size sent a probe at X=1076 to the depth at X=2152. That made the trace attribute changes to draws at the wrong pixel.

Use the D3D12 copy footprint of the selected subresource for the copied format, row pitch, and texel offset. The probe now reports the value of the requested texel.

Validation

  • Four pixel replay tests pass. The new layout test queries actual D3D12 footprints and checks the four-byte depth and one-byte stencil offsets.
  • The frame recording and replay integration test passes. A GPU replay of the affected frame also confirmed that the depth trace follows the requested coordinates.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5539535681 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1017). Originally posted by [invismann](https://github.com/invismann) on 2026-11-28T11:14:06Z. --- `replay --pixel --depth` read texels using the packed depth-stencil texture's format. D3D12 copies depth and stencil as separate planes. On an R32G8X24 texture, calculating the depth offset with the packed eight-byte size sent a probe at X=1076 to the depth at X=2152. That made the trace attribute changes to draws at the wrong pixel. Use the D3D12 copy footprint of the selected subresource for the copied format, row pitch, and texel offset. The probe now reports the value of the requested texel. ## Validation - Four pixel replay tests pass. The new layout test queries actual D3D12 footprints and checks the four-byte depth and one-byte stencil offsets. - The frame recording and replay integration test passes. A GPU replay of the affected frame also confirmed that the depth trace follows the requested coordinates.
Dukestar69 commented 2026-11-28 11:46:26 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Dukestar69 on 2026-11-28T11:46:26Z.

Review: APPROVED


Tested locally merged onto main (63b902f).

  • Merge & Policy: Clean merge; cargo xtask policy passed (294 files ok).
  • Tests (RTX 5090): cargo test -p victory-gpu --features diagnostics --lib replay:: passed (25 passed; 0 failed, including the new replay::play::pixel::tests::depth_probe_reads_the_copied_plane_layout test) with 0 compiler warnings.

Clean depth/stencil copy-layout sampling fix in replay pixel probing. LGTM.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:review:6097600650 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1017#pullrequestreview-6097600650). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-28T11:46:26Z. **Review:** APPROVED --- Tested locally merged onto `main` (`63b902f`). - **Merge & Policy**: Clean merge; `cargo xtask policy` passed (`294 files ok`). - **Tests (RTX 5090)**: `cargo test -p victory-gpu --features diagnostics --lib replay::` passed (`25 passed; 0 failed`, including the new `replay::play::pixel::tests::depth_probe_reads_the_copied_plane_layout` test) with 0 compiler warnings. Clean depth/stencil copy-layout sampling fix in replay pixel probing. LGTM. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
upipibi commented 2026-11-28 20:23:56 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by upipibi on 2026-11-28T20:23:56Z.


Tested on Ampere: RTX 3070 (10de:2484), driver 616.56, native Windows 11 Pro 10.0.26100, rustc 1.98.1. Debug test profile, --features diagnostics. The system WARP is the one that ships with Windows.

  • Head 52a4c6f6f, merged onto main 923e38cc8 (--no-ff, clean, merge e840538). The PR's base is 63b902f. crates/victory-gpu/src/replay/play/pixel.rs is the only file that changes (+55/-14). The head was still 52a4c6f6f when I finished.

replay::play::pixel::tests::depth_probe_reads_the_copied_plane_layout

cargo test -p victory-gpu --lib --locked --features diagnostics -- --exact \
  replay::play::pixel::tests::depth_probe_reads_the_copied_plane_layout --nocapture
VICTORY_D3D12_WARP=1 cargo test ...   # same command, WARP
  • Hardware, 3 runs: 1 passed, 0 failed, 0 ignored each (0.21 to 0.24 s).
  • WARP (VICTORY_D3D12_WARP=1), 3 runs: 1 passed, 0 failed, 0 ignored each (0.02 to 0.03 s).
  • The test opens a real device through crate::host::host() and asks it for GetCopyableFootprints. It is compiled only with diagnostics.

Adapters seen

I added a temporary eprintln! to the test. It resolves device.GetAdapterLuid() through EnumAdapterByLuid, prints GetDesc1, and prints the two plane footprints of the test's 2560x1440 R32G8X24_TYPELESS texture. I removed it afterwards. The output was the same in all runs:

run adapter vendor:device flags
default NVIDIA GeForce RTX 3070 10de:2484 0x0
VICTORY_D3D12_WARP=1 Microsoft Basic Render Driver 1414:008c 0x2 (software)

Both adapters returned the same footprints. Plane 0 is format 39 (R32_TYPELESS) at offset 0 with a row pitch of 10240. Plane 1 is format 60 (R8_TYPELESS) at offset 14745600 with a row pitch of 2560. Both are 2560x1440x1. So the 4-byte depth and 1-byte stencil layouts the test expects come from the driver on the 3070 as well as on WARP.

Negative control

The log is in r1017-control.log.

  • A. Code hunks reverted, test kept. git diff --stat 923e38cc8 -- crates/: pixel.rs | 28 + (the test, plus my temporary print). It does not compile: error[E0425]: cannot find function depth_texel_offset in this scope (pixel.rs:847 and :849). The test calls the new helper.
  • B. The 3-line depth_texel_offset helper put back as well, so that it builds. All the Player hunks are still main's (the depth_copies field, the copy into scratch, the retain_mut that sets s.format). git diff --stat: pixel.rs | 29 +. 3 runs on hardware and 3 on WARP: 1 passed, 0 failed, 0 ignored each. The test passes against main's probe code.

The test checks the driver's footprints and the offset arithmetic of the new helper. It does not call the code that reads the probe (Player's copy into scratch and the spots filter), so it would not catch a regression there. For reference, here is main's formula for the description's case, worked out by hand and not measured. Main uses the packed format's 8 bytes, with a pitch of (2560 * 8).next_multiple_of(256) = 20480. The texel (1076, 362) then lands at 362 * 20480 + 1076 * 8 = 7422368. The PR's depth-plane offset is 3711184, which is half of that. That matches the X=1076 -> 2152 shift in the description.

cargo test -p victory-gpu --lib --locked --features diagnostics (hardware, once each)

  • PR merged onto 923e38cc8: 605 passed, 0 failed, 43 ignored.
  • Plain main 923e38cc8: 604 passed, 0 failed, 43 ignored.
  • The one extra pass is the new test. There were no failures. All 4 replay::play::pixel tests passed on the merge.

I also ran cargo test -p victory-gpu --test replay --locked --features diagnostics on the merge: 1 passed, 0 failed, 0 ignored (a_frame_is_recorded_and_replayed). That test does not use the pixel probe, so it does not run the changed path either.

CI

gh pr checks reports no checks on the PR's branch.

Not tested

  • replay --pixel --depth on a real capture, the path this PR changes. No test runs it, and I had no capture to use. Only the author's GPU replay of the affected frame covers it.
  • Depth formats other than R32G8X24_TYPELESS (for example D24S8's R24G8), mips above 0, and arrays.
  • Clippy, the release build, and the rest of the workspace.
  • The game.

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7245257263 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1017#issuecomment-7245257263). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-28T20:23:56Z. --- Tested on Ampere: RTX 3070 (`10de:2484`), driver 616.56, native Windows 11 Pro 10.0.26100, rustc 1.98.1. Debug test profile, `--features diagnostics`. The system WARP is the one that ships with Windows. - Head `52a4c6f6f`, merged onto main `923e38cc8` (`--no-ff`, clean, merge `e840538`). The PR's base is `63b902f`. `crates/victory-gpu/src/replay/play/pixel.rs` is the only file that changes (+55/-14). The head was still `52a4c6f6f` when I finished. **`replay::play::pixel::tests::depth_probe_reads_the_copied_plane_layout`** ``` cargo test -p victory-gpu --lib --locked --features diagnostics -- --exact \ replay::play::pixel::tests::depth_probe_reads_the_copied_plane_layout --nocapture VICTORY_D3D12_WARP=1 cargo test ... # same command, WARP ``` - Hardware, 3 runs: 1 passed, 0 failed, 0 ignored each (0.21 to 0.24 s). - WARP (`VICTORY_D3D12_WARP=1`), 3 runs: 1 passed, 0 failed, 0 ignored each (0.02 to 0.03 s). - The test opens a real device through `crate::host::host()` and asks it for `GetCopyableFootprints`. It is compiled only with `diagnostics`. **Adapters seen** I added a temporary `eprintln!` to the test. It resolves `device.GetAdapterLuid()` through `EnumAdapterByLuid`, prints `GetDesc1`, and prints the two plane footprints of the test's 2560x1440 `R32G8X24_TYPELESS` texture. I removed it afterwards. The output was the same in all runs: | run | adapter | vendor:device | flags | |---|---|---|---| | default | NVIDIA GeForce RTX 3070 | `10de:2484` | `0x0` | | `VICTORY_D3D12_WARP=1` | Microsoft Basic Render Driver | `1414:008c` | `0x2` (software) | Both adapters returned the same footprints. Plane 0 is format 39 (`R32_TYPELESS`) at offset 0 with a row pitch of 10240. Plane 1 is format 60 (`R8_TYPELESS`) at offset 14745600 with a row pitch of 2560. Both are 2560x1440x1. So the 4-byte depth and 1-byte stencil layouts the test expects come from the driver on the 3070 as well as on WARP. **Negative control** The log is in `r1017-control.log`. - **A. Code hunks reverted, test kept.** `git diff --stat 923e38cc8 -- crates/`: `pixel.rs | 28 +` (the test, plus my temporary print). It does not compile: `error[E0425]: cannot find function depth_texel_offset in this scope` (pixel.rs:847 and :849). The test calls the new helper. - **B. The 3-line `depth_texel_offset` helper put back as well**, so that it builds. All the `Player` hunks are still main's (the `depth_copies` field, the copy into scratch, the `retain_mut` that sets `s.format`). `git diff --stat`: `pixel.rs | 29 +`. 3 runs on hardware and 3 on WARP: **1 passed, 0 failed, 0 ignored each. The test passes against main's probe code.** The test checks the driver's footprints and the offset arithmetic of the new helper. It does not call the code that reads the probe (`Player`'s copy into scratch and the `spots` filter), so it would not catch a regression there. For reference, here is main's formula for the description's case, worked out by hand and not measured. Main uses the packed format's 8 bytes, with a pitch of `(2560 * 8).next_multiple_of(256) = 20480`. The texel (1076, 362) then lands at `362 * 20480 + 1076 * 8 = 7422368`. The PR's depth-plane offset is `3711184`, which is half of that. That matches the X=1076 -> 2152 shift in the description. **`cargo test -p victory-gpu --lib --locked --features diagnostics`** (hardware, once each) - PR merged onto `923e38cc8`: 605 passed, 0 failed, 43 ignored. - Plain main `923e38cc8`: 604 passed, 0 failed, 43 ignored. - The one extra pass is the new test. There were no failures. All 4 `replay::play::pixel` tests passed on the merge. I also ran `cargo test -p victory-gpu --test replay --locked --features diagnostics` on the merge: 1 passed, 0 failed, 0 ignored (`a_frame_is_recorded_and_replayed`). That test does not use the pixel probe, so it does not run the changed path either. **CI** `gh pr checks` reports no checks on the PR's branch. **Not tested** - `replay --pixel --depth` on a real capture, the path this PR changes. No test runs it, and I had no capture to use. Only the author's GPU replay of the affected frame covers it. - Depth formats other than `R32G8X24_TYPELESS` (for example `D24S8`'s `R24G8`), mips above 0, and arrays. - Clippy, the release build, and the rest of the workspace. - The game. AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
trustno1-coder/VIctory-NVIDIA!1017
No description provided.