GPU: read D24S8 and D32S8 planes into guest buffers #3022

Open
github-bot wants to merge 2 commits from github-bot/gh-3022 into main AGit
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 03:35 UTC · original
andrewpozdnakov7-jpg:codex2/planar-depth-readback → main · +202 −11 · 2 files · 2 commits · open

Guest CopyTextureRegion discards reads from D24S8 and D32S8. The device already gives the guest distinct footprints for the depth and stencil planes. This change uses the same footprint mapping to copy a whole single-sampled plane at the selected mip and array slice, then transfers its rows to the guest buffer without overwriting padding.

The same synthetic guest test clears mip 1 of array slice 1 in four D24S8/D32S8 typed and typeless guest descriptions. It tracks the native clears in DEPTH_WRITE, checks depth 0.25 and 0.75 plus stencil 0x37 and 0x91, and copies subresources 3 and 7 to separate offsets with 512-byte pitch. Native inbox and Agility WARP report 16 bytes per depth row and 4 bytes per stencil row. The guest test checks both rows of both planes and the entire surrounding sentinel buffer.

Build Guest readback
63bcca4 with the fixture Both plane destinations stay untouched in all four cases
This change All depth and stencil rows match the native reference, including untouched padding

App-local WARP GPU tests: 247 passed, one ignored. The focused test passed with the D3D12 debug flag. Strict GPU Clippy with and without diagnostics and the repository asset policy passed.

#3006 handles single-plane D16/D32. Both PRs replace the old depth guard. A local combination of the original commits passed 247 tests and one ignore, including both readback fixtures. #2509 handles CPU-to-GPU stencil staging. Direct3D 12 CopyTextureRegion · Coordination claim

AI-assisted with Codex. Synthetic textures only.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 03:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/3022) `andrewpozdnakov7-jpg:codex2/planar-depth-readback` → `main` · +202 −11 · 2 files · 2 commits · open Guest `CopyTextureRegion` discards reads from D24S8 and D32S8. The device already gives the guest distinct footprints for the depth and stencil planes. This change uses the same footprint mapping to copy a whole single-sampled plane at the selected mip and array slice, then transfers its rows to the guest buffer without overwriting padding. The same synthetic guest test clears mip 1 of array slice 1 in four D24S8/D32S8 typed and typeless guest descriptions. It tracks the native clears in DEPTH_WRITE, checks depth 0.25 and 0.75 plus stencil 0x37 and 0x91, and copies subresources 3 and 7 to separate offsets with 512-byte pitch. Native inbox and Agility WARP report 16 bytes per depth row and 4 bytes per stencil row. The guest test checks both rows of both planes and the entire surrounding sentinel buffer. | Build | Guest readback | | --- | --- | | `63bcca4` with the fixture | Both plane destinations stay untouched in all four cases | | This change | All depth and stencil rows match the native reference, including untouched padding | App-local WARP GPU tests: 247 passed, one ignored. The focused test passed with the D3D12 debug flag. Strict GPU Clippy with and without diagnostics and the repository asset policy passed. #3006 handles single-plane D16/D32. Both PRs replace the old depth guard. A local combination of the original commits passed 247 tests and one ignore, including both readback fixtures. #2509 handles CPU-to-GPU stencil staging. [Direct3D 12 CopyTextureRegion](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12graphicscommandlist-copytextureregion) · [Coordination claim](https://git.gtahub.st/github/Marvisak--VIctory/issues/1633) AI-assisted with Codex. Synthetic textures only.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:20:21 +00:00
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 03:40 UTC · original

c28e6b6 corrects the test setup. It registers DEPTH_WRITE before the native clears so the list prelude leaves the clears in the right state and the following copy records its transition to COPY_SOURCE. The original fixture did not register the clear. The test now checks distinct left and right depth values as well as distinct stencil values in every row.

With the same corrected fixture, 63bcca4 leaves the guest buffer untouched in all four cases. This revision matches the native values and preserves every padding byte. App-local WARP with the D3D12 debug flag passed 247 tests with one ignored. Both strict GPU Clippy runs and asset policy passed.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 03:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/3022#issuecomment-7181918637) [c28e6b6](https://github.com/Marvisak/VIctory/commit/c28e6b63b09d1ebcf5ca9f42082b463484cce725) corrects the test setup. It registers DEPTH_WRITE before the native clears so the list prelude leaves the clears in the right state and the following copy records its transition to COPY_SOURCE. The original fixture did not register the clear. The test now checks distinct left and right depth values as well as distinct stencil values in every row. With the same corrected fixture, `63bcca4` leaves the guest buffer untouched in all four cases. This revision matches the native values and preserves every padding byte. App-local WARP with the D3D12 debug flag passed 247 tests with one ignored. Both strict GPU Clippy runs and asset policy passed.
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-26 03:58 UTC · original

@⁠andrewpozdnakov7-jpg The corrected fixture at c28e6b6 passed on my RTX 5080 (621.40) and Windows built-in WARP (10.0.26100.10068), with the D3D12 debug layer enabled. I also compared the guest copies with native CopyTextureRegion readbacks on the same adapter.

Per adapter, across four storage formats RTX 5080 WARP
Depth texels matching native 12,024 / 12,024 12,024 / 12,024
Stencil texels matching native 12,024 / 12,024 12,024 / 12,024
Unexpected changes to guest padding 0 0

Each D24S8 and D32S8 resource (typed and typeless) had two array slices and three mips, sized 131×9, 65×4 and 32×2. Each mip/slice got two distinct native depth and stencil clears. The guest read both planes in reverse subresource order. I checked the native values against those clears, then compared the entire guest buffer, including 512 extra bytes of row pitch, gaps between footprints, and the final row ending exactly at the buffer boundary.

On the direct parent 63bcca4, all 12,024 depth and all 12,024 stencil texels per adapter missed the native reference. As a sensitivity check on the PR, selecting the other valid array slice at the same mip and plane also produced 12,024 mismatches per plane on each adapter.

The optional test-only commit extends your corrected fixture directly on c28e6b6. The filtered test is still depth_and_stencil_planes_reach_the_guest_buffer. Strict GPU Clippy and the asset policy passed. Synthetic textures only. AI-assisted with Codex.

**@⁠steven-seagull27** on GitHub · 2026-11-26 03:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/3022#issuecomment-7182184133) @⁠andrewpozdnakov7-jpg The corrected fixture at `c28e6b6` passed on my RTX 5080 (621.40) and Windows built-in WARP (10.0.26100.10068), with the D3D12 debug layer enabled. I also compared the guest copies with native `CopyTextureRegion` readbacks on the same adapter. | Per adapter, across four storage formats | RTX 5080 | WARP | |---|---:|---:| | Depth texels matching native | 12,024 / 12,024 | 12,024 / 12,024 | | Stencil texels matching native | 12,024 / 12,024 | 12,024 / 12,024 | | Unexpected changes to guest padding | 0 | 0 | Each D24S8 and D32S8 resource (typed and typeless) had two array slices and three mips, sized 131×9, 65×4 and 32×2. Each mip/slice got two distinct native depth and stencil clears. The guest read both planes in reverse subresource order. I checked the native values against those clears, then compared the entire guest buffer, including 512 extra bytes of row pitch, gaps between footprints, and the final row ending exactly at the buffer boundary. On the direct parent `63bcca4`, all 12,024 depth and all 12,024 stencil texels per adapter missed the native reference. As a sensitivity check on the PR, selecting the other valid array slice at the same mip and plane also produced 12,024 mismatches per plane on each adapter. The [optional test-only commit](https://github.com/steven-seagull27/VIctory/commit/ba312640f877b55e1b3295d3f3dea93e408800cf) extends your corrected fixture directly on `c28e6b6`. The filtered test is still `depth_and_stencil_planes_reach_the_guest_buffer`. Strict GPU Clippy and the asset policy passed. Synthetic textures only. AI-assisted with Codex.
Author
Owner

@⁠pickles976 on GitHub · 2026-11-26 03:59 UTC · original

Independent hardware check on exact clean head c28e6b63b09d1ebcf5ca9f42082b463484cce725, RTX 4060 Laptop GPU (8 GiB), 16 GiB RAM, Wine 11.0 / vkd3d-proton 3.2.0 / DXVK 3.1.1, Windows-MSVC victory-gpu test build: resource::tests::depth_and_stencil_planes_reach_the_guest_buffer 1/1 PASS (0.79 s). DXVK logs Found device: NVIDIA GeForce RTX 4060 Laptop GPU; vkd3d creates the hardware D3D12 device and the test runs, rather than the host() == None skip path. Fixture checks the D24S8 and D32S8 typed and typeless cases, both mip-1/slice-1 plane rows, left/right depth/stencil and the 4096-byte destination sentinel including row padding.

Run was in a 9 GiB cgroup scope, 512 MiB swap cap, global available-RAM floor 2 GiB, GPU-used ceiling 6 GiB, disk floor 10 GiB; no safety stop. Local log: .compat-runtime/logs/verify-pr3022-wine-rtx4060-planar-depth.log.

This is a synthetic GPU copy-readback result on the NVIDIA Wine path, not a GTA title load or 30 FPS gameplay result; title loading still reaches the system-RAM safety floor. No objections from this focused hardware fixture.

**@⁠pickles976** on GitHub · 2026-11-26 03:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/3022#issuecomment-7182193059) Independent hardware check on exact clean head `c28e6b63b09d1ebcf5ca9f42082b463484cce725`, **RTX 4060 Laptop GPU (8 GiB), 16 GiB RAM**, Wine 11.0 / vkd3d-proton 3.2.0 / DXVK 3.1.1, Windows-MSVC `victory-gpu` test build: `resource::tests::depth_and_stencil_planes_reach_the_guest_buffer` **1/1 PASS** (0.79 s). DXVK logs `Found device: NVIDIA GeForce RTX 4060 Laptop GPU`; vkd3d creates the hardware D3D12 device and the test runs, rather than the `host() == None` skip path. Fixture checks the D24S8 and D32S8 typed and typeless cases, both mip-1/slice-1 plane rows, left/right depth/stencil and the 4096-byte destination sentinel including row padding. Run was in a 9 GiB cgroup scope, 512 MiB swap cap, global available-RAM floor 2 GiB, GPU-used ceiling 6 GiB, disk floor 10 GiB; no safety stop. Local log: `.compat-runtime/logs/verify-pr3022-wine-rtx4060-planar-depth.log`. This is a synthetic GPU copy-readback result on the NVIDIA Wine path, **not** a GTA title load or 30 FPS gameplay result; title loading still reaches the system-RAM safety floor. No objections from this focused hardware fixture.
Author
Owner

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

Automated triage for the maintainers.

read_back in crates/victory-gpu/src/list.rs used to refuse every depth-stencil source. It now copies D24S8/D32S8 (typed and typeless) planes when the copy is one whole single-sampled subresource (no box, destination at the origin) and the guest's footprint format matches that plane. The plane is taken from the subresource index as index / (mips * slices), the D3D12 planar layout. planar_depth_copy_format in resource.rs keeps the R32_TYPELESS / R8_TYPELESS mapping that subresource already used, so guest footprints do not change. These limits match D3D12's own CopyTextureRegion rules for depth-stencil copies. The Windows test reads both planes of mip 1, slice 1 and checks every byte of the target buffer, padding included. Contributors report it passing on WARP and NVIDIA with the debug layer. CI check: passing.

For the maintainer: the comment this replaces said depth readback stays refused "until a title is seen reading one back", and the PR names no title that does. It also overlaps #3006 (single-plane D16/D32), which replaces the same guard, so whichever merges second will need a small rebase.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 06:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/3022#issuecomment-7184297940) <!-- victory-triage v1 head=c28e6b63b09d1ebcf5ca9f42082b463484cce725 verdict=merge-candidate at=2026-11-26T06:18:12Z --> Automated triage for the maintainers. `read_back` in `crates/victory-gpu/src/list.rs` used to refuse every depth-stencil source. It now copies D24S8/D32S8 (typed and typeless) planes when the copy is one whole single-sampled subresource (no box, destination at the origin) and the guest's footprint format matches that plane. The plane is taken from the subresource index as `index / (mips * slices)`, the D3D12 planar layout. `planar_depth_copy_format` in `resource.rs` keeps the R32_TYPELESS / R8_TYPELESS mapping that `subresource` already used, so guest footprints do not change. These limits match D3D12's own `CopyTextureRegion` rules for depth-stencil copies. The Windows test reads both planes of mip 1, slice 1 and checks every byte of the target buffer, padding included. Contributors report it passing on WARP and NVIDIA with the debug layer. CI `check`: passing. For the maintainer: the comment this replaces said depth readback stays refused "until a title is seen reading one back", and the PR names no title that does. It also overlaps #3006 (single-plane D16/D32), which replaces the same guard, so whichever merges second will need a small rebase. --- _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/3022/head:github-bot/gh-3022'
git switch 'github-bot/gh-3022'

Merge

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