Restore the title’s final texture state after water readback #1167

Open
BradRoland wants to merge 2 commits from upstream-pr/1170 into main
BradRoland commented 2026-11-25 22:37:35 +00:00 (Migrated from github.com)

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


The water readback in #999 transitions a texture to COPY_SOURCE when the command list closes. It can leave the texture there even if the title had already transitioned it back to shader-resource or unordered-access use. A later shader can inherit this state when its texture index is computed and the next list does not explicitly name that texture.

This saves the final state recorded by the current list, transitions for the copy if needed, and restores that state immediately afterward. A combined read state that already includes COPY_SOURCE needs no extra barrier. For a texture with no earlier state in the list, the submission prelude still establishes the copy-source state.

On 9c184b3, an 8×8 R32_FLOAT regression landed the expected texel but left the texture at 0x800 instead of the requested shader-resource state 0xc0. The corrected test passes for shader-resource, unordered-access, combined shader-resource/copy-source, and copy-source states. Reproduce with cargo test --locked -p victory-gpu --features diagnostics water_readback_preserves_the_final_texture_state.

A separate D3D12 debug-queue check covered 48 combinations on RTX 4080 and WARP, with water readback on/off and synchronous or deferred submission (relay off or stage 2). All 48 passed after the fix. The graphics suite had 201 passes and six ignored on each of two standalone runs. The sole failure was the existing indirect-budget ordering assertion in #1118. In 12 isolated WARP repetitions per binary, the same assertion failed six times with the original renderer and nine times with this patch. The state and subresource tests also passed together with #1152.

The fixtures use synthetic textures. The later device loss in the mission report still has no established cause. Gameplay report

AI-assisted implementation and testing.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6615182548 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1170). Originally posted by [BradRoland](https://github.com/BradRoland) on 2026-11-25T22:37:35Z. --- The water readback in #999 transitions a texture to `COPY_SOURCE` when the command list closes. It can leave the texture there even if the title had already transitioned it back to shader-resource or unordered-access use. A later shader can inherit this state when its texture index is computed and the next list does not explicitly name that texture. This saves the final state recorded by the current list, transitions for the copy if needed, and restores that state immediately afterward. A combined read state that already includes `COPY_SOURCE` needs no extra barrier. For a texture with no earlier state in the list, the submission prelude still establishes the copy-source state. On `9c184b3`, an 8×8 R32_FLOAT regression landed the expected texel but left the texture at `0x800` instead of the requested shader-resource state `0xc0`. The corrected test passes for shader-resource, unordered-access, combined shader-resource/copy-source, and copy-source states. Reproduce with `cargo test --locked -p victory-gpu --features diagnostics water_readback_preserves_the_final_texture_state`. A separate D3D12 debug-queue check covered 48 combinations on RTX 4080 and WARP, with water readback on/off and synchronous or deferred submission (relay off or stage 2). All 48 passed after the fix. The graphics suite had 201 passes and six ignored on each of two standalone runs. The sole failure was the existing indirect-budget ordering assertion in #1118. In 12 isolated WARP repetitions per binary, the same assertion failed six times with the original renderer and nine times with this patch. The state and subresource tests also passed together with #1152. The fixtures use synthetic textures. The later device loss in the mission report still has no established cause. [Gameplay report](https://github.com/fxceless/victory-fork/pull/999#issuecomment-7169160638) AI-assisted implementation and testing.
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/1170:upstream-pr/1170'
git switch 'upstream-pr/1170'

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/1170'
git switch 'upstream-pr/1170'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1170'
git switch 'upstream-pr/1170'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1170'
git switch 'main'
git merge --squash 'upstream-pr/1170'
git switch 'main'
git merge --ff-only 'upstream-pr/1170'
git switch 'main'
git merge 'upstream-pr/1170'
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!1167
No description provided.