Preserve untouched mips and slices during water texture readback #1149

Open
BradRoland wants to merge 5 commits from upstream-pr/1152 into main
BradRoland commented 2026-11-25 21:46:48 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by BradRoland on 2026-11-25T21:46:48Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:issue:5499722227 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1152). Originally posted by [BradRoland](https://github.com/BradRoland) on 2026-11-25T21:46:48Z. --- 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://github.com/fxceless/victory-fork/pull/1152#issuecomment-7175998092) 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.
SkillIssueXO commented 2026-11-25 23:09:53 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by SkillIssueXO on 2026-11-25T22:08:59Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7175998092 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1152#issuecomment-7175998092). Originally posted by [SkillIssueXO](https://github.com/SkillIssueXO) on 2026-11-25T22:08:59Z. --- 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.
BradRoland commented 2026-11-25 23:09:56 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by BradRoland on 2026-11-25T22:31:42Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7176473092 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1152#issuecomment-7176473092). Originally posted by [BradRoland](https://github.com/BradRoland) on 2026-11-25T22:31:42Z. --- 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 commented 2026-11-26 00:06:09 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by BradRoland on 2026-11-25T23:36:08Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7177791009 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1152#issuecomment-7177791009). Originally posted by [BradRoland](https://github.com/BradRoland) on 2026-11-25T23:36:08Z. --- 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://github.com/fxceless/victory-fork/pull/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.
Filip722 commented 2026-11-27 17:09:08 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Filip722 on 2026-11-27T17:09:08Z.


Checked the readback-only changes from 5eb6a8a and 643f05a on the NVIDIA-based renderer from 52dfd12, keeping the current tiling and allocation invalidation code. On Bazzite with GE-Proton11-14, vkd3d-proton 3.2.0, driver 615.78.08, and an RTX 5060 Laptop, the unmodified renderer overwrote byte 1536 of the synthetic four-slice texture with 0 instead of preserving 0x4a. The forward port passed the same 2D and array checks on the physical RTX and passed the separate allocation invalidation test. The effect on the mission is still unverified.

Assisted by Codex (GPT-6.2-Sol High).

<!-- greyfinch-sync:fxceless/victory-fork:comment:7224085029 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1152#issuecomment-7224085029). Originally posted by [Filip722](https://github.com/Filip722) on 2026-11-27T17:09:08Z. --- Checked the readback-only changes from `5eb6a8a` and `643f05a` on the NVIDIA-based renderer from `52dfd12`, keeping the current tiling and allocation invalidation code. On Bazzite with GE-Proton11-14, vkd3d-proton 3.2.0, driver 615.78.08, and an RTX 5060 Laptop, the unmodified renderer overwrote byte 1536 of the synthetic four-slice texture with 0 instead of preserving 0x4a. The forward port passed the same 2D and array checks on the physical RTX and passed the separate allocation invalidation test. The effect on the mission is still unverified. Assisted by Codex (GPT-6.2-Sol High).
akimfomin commented 2026-11-28 01:30:27 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by akimfomin on 2026-11-28T01:30:27Z.


A pinned merge check of 43cadb44 and #1472 (2fe51723) conflicts in texback.rs. A portable combined test can use #1472's rejected short depth pitch alongside this PR's existing narrow view of a padded array. Reject the first before making a readback; preserve sentinel bytes in an unbound slice of the second. This checks the combined path without repeating any chase or GPU throughput test.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7231713528 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1152#issuecomment-7231713528). Originally posted by [akimfomin](https://github.com/akimfomin) on 2026-11-28T01:30:27Z. --- A pinned merge check of `43cadb44` and [#1472](https://github.com/fxceless/victory-fork/pull/1472) (`2fe51723`) conflicts in `texback.rs`. A portable combined test can use #1472's rejected short depth pitch alongside this PR's existing narrow view of a padded array. Reject the first before making a readback; preserve sentinel bytes in an unbound slice of the second. This checks the combined path without repeating any chase or GPU throughput test.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1152:upstream-pr/1152'
git switch 'upstream-pr/1152'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1152'
git switch 'upstream-pr/1152'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1152'
git switch 'upstream-pr/1152'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1152'
git switch 'main'
git merge --squash 'upstream-pr/1152'
git switch 'main'
git merge --ff-only 'upstream-pr/1152'
git switch 'main'
git merge 'upstream-pr/1152'
git push origin 'main'
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
fxceless/victory-fork!1149
No description provided.