GPU: refresh a texture alias after its source is written again #2341
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2341
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2341"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 11:07 UTC · original
andrewpozdnakov7-jpg:fix/refresh-gpu-alias-after-source-write→main· +183 −22 · 3 files · 2 commits · openA placed texture alias was copied once per command list. A later GPU write to its source could leave the next alias read on older contents. Recopying after a write to the alias itself can also overwrite that newer destination data.
Keep the source host texture and its write version from the last alias copy. A write to the destination keeps that record. A new source version makes another copy necessary.
The synthetic WARP test records a red write to the R32G32_UINT source, a blue write to the BC1 alias destination, then a green write to the source. It reads the alias after each write and directly verifies the final source block.
67e8ae1401df112248aed36d0024483181b718b7075b2ac4d1c15d4902bfe231346585998ffdb2e3Full GPU suite on WARP had 199 passes and 1 ignored under both D3D12 debug flag settings. Strict GPU Clippy passed with default and all features, and the asset policy passed. AI-assisted. Test data is synthetic.
Please preserve the Git author if you cherry-pick the change. If you fold the code or regression into another commit, please include the trailer below.
Co-authored-by: andrewpozdnakov7-jpg [email protected]
Coordination claim
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 11:28 UTC · original
I tested this change together with #2314 at
1735610. Git combines both branches cleanly. The direct multisampled path also needs to record the completed alias copy so another read can reuse it until the next write.Combined branch and test
76381a5preserves both PR heads. The WARP fixture records two depth clears. It checks that the second write invalidates the original copy, its resolve reads 0.625, and each completed copy satisfies a subsequent read. The reuse assertion failed in the plain merge and passed with the added recording call. Both alias tests passed together. The full GPU suite gave 148 passed, 2 ignored. Strict GPU Clippy in both modes and repository policy passed.If the code or tests are folded into another commit, please add:
Co-authored-by: andrewpozdnakov7-jpg [email protected]
AI-assisted. Synthetic tests only.
@Machad3x on GitHub · 2026-11-25 13:00 UTC · original · edited 2026-11-25 13:16 UTC
Correction: please disregard this as evidence against this PR.
Later runs of stacks without this PR showed an equally dark picture, so the single pair of runs I compared does not attribute it to this PR. I have no result for or against this change.
AI-assisted (Claude Code).
@Marvisak on GitHub · 2026-11-25 15:27 UTC · original · edited 2026-11-25 18:44 UTC
Automated triage for the maintainers.
Merge candidate.
HostListincrates/victory-gpu/src/host.rsnow keeps aTextureStateper texture, with awrite_versionthattrackraises on each move into a write state (render target, UAV, depth write, copy or resolve destination) and that a twin route also raises. Each alias destination storesalias_source, the source and its version at the last copy.texture::alias_copycopies again only when the source has a newer version (alias_copy_is_current), where before it copied once per list (first_use(to | 1)). So a second GPU write to the source reaches the alias, and a write to the alias itself survives until the source changes. Both textures are tracked beforerecord_alias_copyruns. The copy moves the source to copy-source, so its next write is a new transition and raises the version. The WARP test inresource.rscovers the source, alias, source write sequence and reads the final source directly.On your reply: the #2314 integration (the direct multisampled path also calling
record_alias_copy) belongs to whichever of the two PRs lands second. It does not block this one.CI:
checkpassing.Generated by Claude Code
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 16:15 UTC · original
Updated the branch to main
67e8ae1401df112248aed36d0024483181b718b7and kept the original HEAD in its history. The new fixture writes to the alias destination between two source writes. The main baseline reads red/blue/blue. Applying the previous destination-invalidation rule to the same test reads red/red/green. The updated code reads red/blue/green, and the direct final source read is green. Updated commitThe source's version now controls whether to recopy. The destination's own write leaves that record in place. Full GPU suite on WARP passed with 199 passed and 1 ignored in both D3D12 debug flag settings. Strict GPU Clippy and the asset policy passed.
Please preserve our Git author if taking the change or test into another branch. If folding them into another commit, please include this trailer.
Co-authored-by: andrewpozdnakov7-jpg [email protected]
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 17:54 UTC · original
I checked the direct MSAA path on a composition of main
13f91caee2, #2314 at8c8cfb4f85and #2341 at075b2ac4d1. The combined path needs both the updated CopyResource arguments and the alias version record used by the footprint path.With the argument adjustment alone, the same WARP test resolves 0.375, then overwrites a destination-only clear of 0.625 with 0.375. With the version record, all 16 texels resolve to 0.375, then 0.625, then 0.875 after a new source write. Six paired runs across both debug settings reproduced the difference. The serial GPU suite passed 200 tests with one ignored in each setting, and strict GPU Clippy and asset policy passed.
Integration commit aea413d contains the small adaptation and extended readback test above the two exact PR heads. If you fold the adaptation or test into another commit, please keep the Git attribution with:
Co-authored-by: andrewpozdnakov7-jpg [email protected]
@DenRakEiw on GitHub · 2026-11-25 11:26 UTC · original · approved these changes
Verified against
origin/main(940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:cargo test -p victory-gpu resource::tests: 11/11 passed on RTX 5090, 11/11 passed on WARP (including live GPU testa_second_gpu_write_reaches_the_placed_alias_in_the_same_list).cargo test -p victory-gpu texture::tests: 2/2 passed.cargo clippy -p victory-gpu --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 183 files ok.AI-assisted (Gemini 4 Neon).
@catminou4 on GitHub · 2026-11-25 11:51 UTC · original · reviewed
Texture alias refreshed after its source is written — TextureState tracks write_version and alias_source. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Aliasing coherence fix; ties to #2226/#2276 cluster.
@fuzeofficlal on GitHub · 2026-11-26 18:18 UTC · original · approved these changes
Looks good. Verified merged onto
main(63bcca43) on an RTX 5090 and Microsoft WARP under the D3D12 Debug Layer (VICTORY_D3D12_DEBUG=1):write_version(bumped onWRITE_STATEStransitions inHostList::trackand on UAV twin routes wheretwin::routereturnstrue) andalias_sourceinTextureState(crates/victory-gpu/src/host.rs) ensurestexture::alias_copyrefreshes an alias whenever its source is written again in the same command list while preserving writes made directly to the alias destination.cargo xtask policy(191 files ok),cargo clippy --locked -p victory-gpu --all-targets -- -D warnings(default and--all-features), and all 21resource::tests::(19, includinga_second_gpu_write_reaches_the_placed_alias_in_the_same_list) +texture::tests::(2) tests pass on both RTX 5090 and WARP underVICTORY_D3D12_DEBUG=1with zero Debug Layer messages.VICTORY_D3D12_DEBUG=1thatALIAS_COPIESstays at+1across repeatedalias_copycalls and after a destination write (preserving0x3333_4444), and thatHostList::reset()clearsalias_sourceso a reused list copies the source again cleanly (0x1111_2222).#2509onmain.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.