Preserve untouched mips and slices during water texture readback #1152

Open
github-bot wants to merge 5 commits from github-bot/gh-1152 into main AGit
Owner

@⁠BradRoland on GitHub · 2026-11-25 21:46 UTC · original
BradRoland:codex/texture-readback-subresources → main · +51679 −150 · 16 files · 20 commits · open

The water texture readback added in #999 records a writable texture when a draw or dispatch binds it. It previously discarded the UAV description and copied every mip and array slice back into title memory. On a synthetic R32_FLOAT array, this overwrote an untouched slice with a value left on the host by an earlier command list.

This patch records the mip and slices each bound UAV exposes, takes their union per texture within the command list, and copies and tiles those subresources using their original indices. A default view covers mip zero across all slices. Explicit array views support the all-remaining-slices count. A non-array 2D view of an array covers slice zero. The existing allocation snapshot and fence handling are retained.

The WARP regression exercises the draw binding path with real D3D12 clears on a three-mip 2D texture and a four-slice array. It checks updated texels, untouched texels, and padding after binding default and overlapping views. The regression failed on 9c184b3 and passed after the change, including with the debug layer enabled. The graphics crate passed all 202 enabled diagnostics tests (six ignored). An earlier run hit the existing intermittent failure in #1118, which passed on an unchanged rerun.

On the original PR head 643f05a0, an independent Series X replay on an RTX 5070 Ti kept the boat afloat and showed a continuous water surface in the sampled view. The tester reported small dark reflection spots, a dark sun disk, and one unsupported-tiling warning. A matched baseline is pending. Tester’s gameplay report

With VICTORY_TEXTURE_BACK=1, the existing texture readback landed line now reports cumulative bindings, restricted_bindings, copied_subresources, and skipped_subresources. A restricted binding exposes only part of a texture. Repeated bindings count individually. The two subresource counters count each mip and array slice once per texture per command list at the write-back stage. A nonzero skipped_subresources delta shows that narrowing bindings reduced the number of copies in the measured window. The counters exclude stale allocations and tiling failures and share the existing copied reporting cadence.

The counter regression passed on WARP and an RTX 4080 with the D3D12 debug layer enabled. Three synthetic readbacks produced nine valid bindings, eight restricted bindings, fourteen copied subresources, and five skipped subresources. An invalidated fourth readback left every counter unchanged. The final diagnostics run passed 202 tests with six ignored.

**@⁠BradRoland** on GitHub · 2026-11-25 21:46 UTC · [original](https://github.com/fxceless/victory-fork/pull/1152) `BradRoland:codex/texture-readback-subresources` → `main` · +51679 −150 · 16 files · 20 commits · open The water texture readback added in #999 records a writable texture when a draw or dispatch binds it. It previously discarded the UAV description and copied every mip and array slice back into title memory. On a synthetic R32_FLOAT array, this overwrote an untouched slice with a value left on the host by an earlier command list. This patch records the mip and slices each bound UAV exposes, takes their union per texture within the command list, and copies and tiles those subresources using their original indices. A default view covers mip zero across all slices. Explicit array views support the all-remaining-slices count. A non-array 2D view of an array covers slice zero. The existing allocation snapshot and fence handling are retained. The WARP regression exercises the draw binding path with real D3D12 clears on a three-mip 2D texture and a four-slice array. It checks updated texels, untouched texels, and padding after binding default and overlapping views. The regression failed on `9c184b3` and passed after the change, including with the debug layer enabled. The graphics crate passed all 202 enabled diagnostics tests (six ignored). An earlier run hit the existing intermittent failure in #1118, which passed on an unchanged rerun. On the original PR head `643f05a0`, an independent Series X replay on an RTX 5070 Ti kept the boat afloat and showed a continuous water surface in the sampled view. The tester reported small dark reflection spots, a dark sun disk, and one unsupported-tiling warning. A matched baseline is pending. [Tester’s gameplay report](https://git.gtahub.st/github/fxceless--victory-fork/pulls/1152) With `VICTORY_TEXTURE_BACK=1`, the existing `texture readback landed` line now reports cumulative `bindings`, `restricted_bindings`, `copied_subresources`, and `skipped_subresources`. A restricted binding exposes only part of a texture. Repeated bindings count individually. The two subresource counters count each mip and array slice once per texture per command list at the write-back stage. A nonzero `skipped_subresources` delta shows that narrowing bindings reduced the number of copies in the measured window. The counters exclude stale allocations and tiling failures and share the existing `copied` reporting cadence. The counter regression passed on WARP and an RTX 4080 with the D3D12 debug layer enabled. Three synthetic readbacks produced nine valid bindings, eight restricted bindings, fourteen copied subresources, and five skipped subresources. An invalidated fourth readback left every counter unchanged. The final diagnostics run passed 202 tests with six ignored.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:58:30 +00:00
Author
Owner

@⁠SkillIssueXO on GitHub · 2026-11-25 22:08 UTC · original

Independent Series X replay on an RTX 5070 Ti. I tested 643f05a0 on 9c184b35 with local keyboard/mouse and fullscreen changes, the README run 253 settings, and VICTORY_TEXTURE_BACK=1. The focused WARP regression passed here.

The boat stayed afloat in the chase, with a continuous water surface in the sampled view. I saw small dark reflection spots and the dark sun disk. The run logged over 39,000 landed texture readbacks and one unsupported-tiling warning.

One 30-second chase window had 253 consecutive logged present intervals, averaging 8.45 FPS at 125.0 ms median and 233.4 ms p95. A matched baseline and counts of restricted UAV bindings are still pending, so these timings describe this run.

AI-assisted testing. Source identifiers and aggregate measurements only.

**@⁠SkillIssueXO** on GitHub · 2026-11-25 22:08 UTC · [original](https://github.com/fxceless/victory-fork/pull/1152#issuecomment-7175998092) Independent Series X replay on an RTX 5070 Ti. I tested `643f05a0` on `9c184b35` with local keyboard/mouse and fullscreen changes, the README run 253 settings, and `VICTORY_TEXTURE_BACK=1`. The focused WARP regression passed here. The boat stayed afloat in the chase, with a continuous water surface in the sampled view. I saw small dark reflection spots and the dark sun disk. The run logged over 39,000 landed texture readbacks and one unsupported-tiling warning. One 30-second chase window had 253 consecutive logged present intervals, averaging 8.45 FPS at 125.0 ms median and 233.4 ms p95. A matched baseline and counts of restricted UAV bindings are still pending, so these timings describe this run. AI-assisted testing. Source identifiers and aggregate measurements only.
Author
Owner

@⁠BradRoland on GitHub · 2026-11-25 22:31 UTC · original

Thanks for running the boat chase on the 5070 Ti. I added the missing binding counts in 78d66d4. For a matched chase interval, the difference between two texture readback landed lines gives the counts for that window. restricted_bindings counts each valid view that covers part of its texture. skipped_subresources counts the mip/slice copies avoided after combining overlapping views. A run can have restricted bindings and still copy every subresource. The new fields use the existing VICTORY_TEXTURE_BACK=1 setting.

I verified those distinctions with synthetic textures on WARP and an RTX 4080. The 8.45 FPS figure remains the single-run measurement from your report.

**@⁠BradRoland** on GitHub · 2026-11-25 22:31 UTC · [original](https://github.com/fxceless/victory-fork/pull/1152#issuecomment-7176473092) Thanks for running the boat chase on the 5070 Ti. I added the missing binding counts in `78d66d4`. For a matched chase interval, the difference between two `texture readback landed` lines gives the counts for that window. `restricted_bindings` counts each valid view that covers part of its texture. `skipped_subresources` counts the mip/slice copies avoided after combining overlapping views. A run can have restricted bindings and still copy every subresource. The new fields use the existing `VICTORY_TEXTURE_BACK=1` setting. I verified those distinctions with synthetic textures on WARP and an RTX 4080. The 8.45 FPS figure remains the single-run measurement from your report.
Author
Owner

@⁠BradRoland on GitHub · 2026-11-25 23:36 UTC · original · edited 2026-11-25 23:42 UTC

Run 280 logged Unsupported while tiling a texture at mip 0, slice 0. In the layout walker that result means the layout can be sized but has no address equation for placing its texels back in title memory. The old path discovered this after transitioning the texture, recording a GPU copy and reading it back. The log did not identify which layout triggered it. Run 280 warning

I added 5757e1a to this PR. At list close the renderer now checks the layout before the state transition or readback allocation. The first occurrence logs the title format, dimensions, swizzle and selected subresource. Supported layouts keep the existing copy path.

I reproduced the unnecessary work on WARP with a synthetic 8×8 R32_FLOAT XOR layout. Before the change one readback was queued and the texture ended in COPY_SOURCE. With the change, two successive lists each queued zero readbacks, left the texture in UAV state and preserved the original title-memory bytes. Exactly one warning identified format 41 and swizzle 21. The mip, slice and remap controls still passed. The game log does not establish that its texture had this particular swizzle or how often it was encountered. Patch and regression

I also ran the same regression through the D3D12 hardware path. DXGI identified the device for the test as NVIDIA GeForce RTX 4080. The mip, array, remap and unsupported-layout assertions all passed on that device.

**@⁠BradRoland** on GitHub · 2026-11-25 23:36 UTC · [original](https://github.com/fxceless/victory-fork/pull/1152#issuecomment-7177791009) · edited 2026-11-25 23:42 UTC Run 280 logged `Unsupported` while tiling a texture at mip 0, slice 0. In the layout walker that result means the layout can be sized but has no address equation for placing its texels back in title memory. The old path discovered this after transitioning the texture, recording a GPU copy and reading it back. The log did not identify which layout triggered it. [Run 280 warning](https://github.com/fxceless/victory-fork/blob/32b31f7/diagnostics/timing-run-295s-2026-11-25.txt#L21613) I added `5757e1a` to this PR. At list close the renderer now checks the layout before the state transition or readback allocation. The first occurrence logs the title format, dimensions, swizzle and selected subresource. Supported layouts keep the existing copy path. I reproduced the unnecessary work on WARP with a synthetic 8×8 `R32_FLOAT` XOR layout. Before the change one readback was queued and the texture ended in `COPY_SOURCE`. With the change, two successive lists each queued zero readbacks, left the texture in UAV state and preserved the original title-memory bytes. Exactly one warning identified format 41 and swizzle 21. The mip, slice and remap controls still passed. The game log does not establish that its texture had this particular swizzle or how often it was encountered. [Patch and regression](https://git.gtahub.st/github/fxceless--victory-fork/pulls/1152/commits/5757e1a2f13d18a21dd4250defa58b70e22ba3fa) I also ran the same regression through the D3D12 hardware path. DXGI identified the device for the test as NVIDIA GeForce RTX 4080. The mip, array, remap and unsupported-layout assertions all passed on that device.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/descriptor/host.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1152/head:github-bot/gh-1152'
git switch 'github-bot/gh-1152'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1152'
git switch 'github-bot/gh-1152'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1152'
git switch 'github-bot/gh-1152'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1152'
git switch 'main'
git merge --squash 'github-bot/gh-1152'
git switch 'main'
git merge --ff-only 'github-bot/gh-1152'
git switch 'main'
git merge 'github-bot/gh-1152'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.