GPU: read single-plane depth textures into guest buffers #3006

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

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 03:15 UTC · original
andrewpozdnakov7-jpg:codex2/depth-copy-readback → main · +122 −3 · 2 files · 2 commits · open

The guest CopyTextureRegion readback path discards copies from any depth resource. Allow whole, single-sampled D16 and D32 subresources with a compatible single-plane footprint. The depth case checks the source subresource, the destination origin and the whole-subresource rule before recording the copy. It uses the existing pitched row transfer into the guest buffer. CopyTextureRegion requirements

Verification

  • Native inbox and Agility WARP both read the cleared 0.25 and 0.75 depths from D32_FLOAT, R32_TYPELESS, D16_UNORM and R16_TYPELESS, using the corresponding DSV and GetCopyableFootprints.
  • The same guest list test on main leaves all four depth buffers entirely at the sentinel value. The patch returns both exact rows for all four formats and preserves the buffer padding. The original RGBA8 clipped-region control also passes.
  • Focused default and Agility WARP tests passed, including the diagnostics run with VICTORY_D3D12_DEBUG=1. Full GPU diagnostics passed (246 tests, one ignored), with both strict Clippy builds and asset policy.

AI-assisted with Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 03:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/3006) `andrewpozdnakov7-jpg:codex2/depth-copy-readback` → `main` · +122 −3 · 2 files · 2 commits · open The guest CopyTextureRegion readback path discards copies from any depth resource. Allow whole, single-sampled D16 and D32 subresources with a compatible single-plane footprint. The depth case checks the source subresource, the destination origin and the whole-subresource rule before recording the copy. It uses the existing pitched row transfer into the guest buffer. [CopyTextureRegion requirements](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12graphicscommandlist-copytextureregion) ## Verification - Native inbox and Agility WARP both read the cleared 0.25 and 0.75 depths from D32_FLOAT, R32_TYPELESS, D16_UNORM and R16_TYPELESS, using the corresponding DSV and GetCopyableFootprints. - The same guest list test on main leaves all four depth buffers entirely at the sentinel value. The patch returns both exact rows for all four formats and preserves the buffer padding. The original RGBA8 clipped-region control also passes. - Focused default and Agility WARP tests passed, including the diagnostics run with VICTORY_D3D12_DEBUG=1. Full GPU diagnostics passed (246 tests, one ignored), with both strict Clippy builds and asset policy. AI-assisted with Codex.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:19:56 +00:00
Author
Owner

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

Independent RTX 5080 and Windows built-in WARP readback on 7a11b21: 12,024/12,024 depth texels matched on each adapter, alongside the original clipped RGBA8 and depth cases. The new fixture uses D32_FLOAT, R32_TYPELESS, D16_UNORM and R16_TYPELESS. Each resource has two array slices and three mips (131×9, 65×4, 32×2).

I filled each mip/slice with two distinct native DSV clears, then read all six through the guest command list in reverse order. Destination footprints begin at separate aligned offsets, have 256 extra bytes of row pitch, and end exactly after the final row's payload. All pitch and alignment padding retained its sentinel. On parent 63bcca4, all four depth formats failed the new check on both adapters. As a sensitivity check, deliberately taking each mip from the first array slice failed at subresource 3 (slice 1, mip 0) in all four formats on both adapters.

The test-only commit 18fce85 applies on your PR. Run cargo test --locked -p victory-gpu --features diagnostics --lib depth_mips_and_array_slices -- --nocapture, and repeat with VICTORY_D3D12_WARP=1 for the software pass. Both adapters ran with VICTORY_D3D12_DEBUG=1.

**@⁠steven-seagull27** on GitHub · 2026-11-26 03:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/3006#issuecomment-7181751654) Independent RTX 5080 and Windows built-in WARP readback on `7a11b21`: **12,024/12,024 depth texels matched on each adapter**, alongside the original clipped RGBA8 and depth cases. The new fixture uses D32_FLOAT, R32_TYPELESS, D16_UNORM and R16_TYPELESS. Each resource has two array slices and three mips (131×9, 65×4, 32×2). I filled each mip/slice with two distinct native DSV clears, then read all six through the guest command list in reverse order. Destination footprints begin at separate aligned offsets, have 256 extra bytes of row pitch, and end exactly after the final row's payload. All pitch and alignment padding retained its sentinel. On parent `63bcca4`, all four depth formats failed the new check on both adapters. As a sensitivity check, deliberately taking each mip from the first array slice failed at subresource 3 (slice 1, mip 0) in all four formats on both adapters. The [test-only commit `18fce85`](https://github.com/steven-seagull27/VIctory/commit/18fce85f46fb000ac35367b60c35a824c37ea067) applies on your PR. Run `cargo test --locked -p victory-gpu --features diagnostics --lib depth_mips_and_array_slices -- --nocapture`, and repeat with `VICTORY_D3D12_WARP=1` for the software pass. Both adapters ran with `VICTORY_D3D12_DEBUG=1`.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 06:16 UTC · original · edited 2026-11-26 07:19 UTC

Automated triage for the maintainers.

Thanks, the test is now tidy. In crates/victory-gpu/src/resource.rs the branch diff only adds a separate depth test, and the RGBA8 test is untouched. The list.rs::read_back checks are unchanged and still look consistent with the D3D12 copy rules.

As you say, the main point is still open. In main, refusing to read back a depth texture is a deliberate shortcut until a title is seen doing it. Lifting it needs evidence that GTA VI reads a depth texture back into a buffer, for example the "texture to buffer copy refused: a depth or stencil texture" warning firing in a diagnostics run. It also needs confirmation that the console's layout for these formats matches the host's single-plane rows on this path. With that, this would be a good candidate.

CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 06:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/3006#issuecomment-7184263376) · edited 2026-11-26 07:19 UTC <!-- victory-triage v1 head=34c28df456662659ced476726f9630052883b2c7 verdict=needs-work at=2026-11-26T07:19:53Z --> Automated triage for the maintainers. Thanks, the test is now tidy. In `crates/victory-gpu/src/resource.rs` the branch diff only adds a separate depth test, and the RGBA8 test is untouched. The `list.rs::read_back` checks are unchanged and still look consistent with the D3D12 copy rules. As you say, the main point is still open. In `main`, refusing to read back a depth texture is a deliberate shortcut until a title is seen doing it. Lifting it needs evidence that GTA VI reads a depth texture back into a buffer, for example the "texture to buffer copy refused: a depth or stencil texture" warning firing in a diagnostics run. It also needs confirmation that the console's layout for these formats matches the host's single-plane rows on this path. With that, this would be a good candidate. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 06:41 UTC · original

Commit 34c28df restores the existing RGBA8 test verbatim and adds a separate synthetic test for D16 and D32, including their typeless counterparts. In the full branch diff, resource.rs now only adds the depth test.

With that fixture on 63bcca43, all four destination buffers stay untouched. The same fixture with the fix returns the exact depth texels and preserves every padding byte. The original RGBA8 test passes. App-local WARP GPU suite 247 passed and 1 ignored. Strict GPU Clippy passed in both modes, and asset policy passed.

The evidence here is for the synthetic guest copy and the host D3D12 layout. The requested title usage and console layout confirmation are still open.

Please retain the Git author when moving the test. If it is folded into another commit, please add Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 06:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/3006#issuecomment-7184675736) [Commit 34c28df](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/34c28df456662659ced476726f9630052883b2c7) restores the existing RGBA8 test verbatim and adds a separate synthetic test for D16 and D32, including their typeless counterparts. In the full branch diff, `resource.rs` now only adds the depth test. With that fixture on `63bcca43`, all four destination buffers stay untouched. The same fixture with the fix returns the exact depth texels and preserves every padding byte. The original RGBA8 test passes. App-local WARP GPU suite 247 passed and 1 ignored. Strict GPU Clippy passed in both modes, and asset policy passed. The evidence here is for the synthetic guest copy and the host D3D12 layout. The requested title usage and console layout confirmation are still open. Please retain the Git author when moving the test. If it is folded into another commit, please add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`.
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/3006/head:github-bot/gh-3006'
git switch 'github-bot/gh-3006'

Merge

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