GPU: aliased texture arrays with other mip counts are not copied subresource by subresource #2273

Closed
denkencar-sketch wants to merge 1 commit from upstream-pr/2275 into main
denkencar-sketch commented 2026-11-25 09:29:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by denkencar-sketch on 2026-11-25T09:29:02Z.


Summary

Aliased texture arrays with other mip counts were copied subresource by subresource, but their subresource numbers name different mips and slices, so one slice's mip went into another slice. subresources_correspond now allows the per-subresource copy only when the mip counts match.

Testing

Test array_subresources_correspond_only_with_as_many_mips fails if subresources_correspond always returns true and passes with this change; it covers the helper, not the call site. cargo test --workspace --locked passes apart from the known flakes: modules::dstorage::tests::a_page_list_filled_after_its_request_starts fails now and then on main too, and so does a parallel-run flake in victory-gpu's lib tests (watch:: and descriptor::host:: tests, 2 of 40 runs on pristine main).

Not tried: a run in the game.

AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6601357125 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2275). Originally posted by [denkencar-sketch](https://github.com/denkencar-sketch) on 2026-11-25T09:29:02Z. --- ## Summary Aliased texture arrays with other mip counts were copied subresource by subresource, but their subresource numbers name different mips and slices, so one slice's mip went into another slice. `subresources_correspond` now allows the per-subresource copy only when the mip counts match. ## Testing Test `array_subresources_correspond_only_with_as_many_mips` fails if `subresources_correspond` always returns true and passes with this change; it covers the helper, not the call site. `cargo test --workspace --locked` passes apart from the known flakes: `modules::dstorage::tests::a_page_list_filled_after_its_request_starts` fails now and then on `main` too, and so does a parallel-run flake in `victory-gpu`'s lib tests (`watch::` and `descriptor::host::` tests, 2 of 40 runs on pristine `main`). Not tried: a run in the game. AI-assisted.
catminou4 commented 2026-11-25 10:07:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T09:35:43Z.

Review: COMMENTED


Aliased texture arrays with different mip counts are not copied (subresources_correspond guard). 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. Complements #2274; same alias_copy area.

<!-- greyfinch-sync:Marvisak/VIctory:review:6055075270 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2275#pullrequestreview-6055075270). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T09:35:43Z. **Review:** COMMENTED --- Aliased texture arrays with different mip counts are not copied (subresources_correspond guard). 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. Complements #2274; same alias_copy area.
DenRakEiw commented 2026-11-25 10:07:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T10:04:00Z.

Review: APPROVED


Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:

  • Confirmed resource::alias_source already requires matching dimension and depth_or_array_size, so subresources_correspond accurately guards texture arrays with differing mip counts while allowing single-slice textures and 3D textures to copy their common mip prefix.
  • cargo test -p victory-gpu texture::: 3/3 passed on RTX 5090, 3/3 passed on WARP (including array_subresources_correspond_only_with_as_many_mips).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: 0 warnings.
  • cargo xtask policy: 183 files ok.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6055486340 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2275#pullrequestreview-6055486340). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T10:04:00Z. **Review:** APPROVED --- Verified against `origin/main` (`940d32f`) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP: - Confirmed `resource::alias_source` already requires matching `dimension` and `depth_or_array_size`, so `subresources_correspond` accurately guards texture arrays with differing mip counts while allowing single-slice textures and 3D textures to copy their common mip prefix. - `cargo test -p victory-gpu texture::`: 3/3 passed on RTX 5090, 3/3 passed on WARP (including `array_subresources_correspond_only_with_as_many_mips`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: 0 warnings. - `cargo xtask policy`: 183 files ok. AI-assisted (Gemini 4 Neon).
Dathinel commented 2026-11-25 10:07:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dathinel on 2026-11-25T09:55:37Z.


Tested #2275 (b6a9ebe) together with #2274 (8a88297) on Windows. Both changes share base 940d32f. The two textual conflicts are at helper/test insertion points; keeping both helpers and both tests compiled. The call-site edits combined automatically.

I supplied synthetic RGBA32F and BC7 descriptions to D3D12 GetCopyableFootprints and checked the resulting prefix in both directions:

  • Two slices, two mips each: 24×16 RGBA32F vs 96×64 BC7 retained all four subresources. At 25×16 vs 100×64, the second mip had 192 vs 208 bytes per row. Omitting just the row-size comparison admitted four; including it retained one.
  • At width 24 with two mips vs one, the footprint prefix alone was one. With two slices the mip-count guard rejected the pair; with one slice it retained the common first mip.

All three selected tests passed. This checks the native layout metadata and both selection rules. GPU copy execution and resulting texels were outside this run. AI-assisted, synthetic descriptors only.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7158987737 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2275#issuecomment-7158987737). Originally posted by [Dathinel](https://github.com/Dathinel) on 2026-11-25T09:55:37Z. --- Tested #2275 (b6a9ebe) together with #2274 (8a88297) on Windows. Both changes share base 940d32f. The two textual conflicts are at helper/test insertion points; keeping both helpers and both tests compiled. The call-site edits combined automatically. I supplied synthetic RGBA32F and BC7 descriptions to D3D12 GetCopyableFootprints and checked the resulting prefix in both directions: - Two slices, two mips each: 24×16 RGBA32F vs 96×64 BC7 retained all four subresources. At 25×16 vs 100×64, the second mip had 192 vs 208 bytes per row. Omitting just the row-size comparison admitted four; including it retained one. - At width 24 with two mips vs one, the footprint prefix alone was one. With two slices the mip-count guard rejected the pair; with one slice it retained the common first mip. All three selected tests passed. This checks the native layout metadata and both selection rules. GPU copy execution and resulting texels were outside this run. AI-assisted, synthetic descriptors only.
andrewpozdnakov7-jpg commented 2026-11-25 11:05:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T10:51:54Z.


I added a WARP readback regression on top of your exact head b6a9ebe00182abf29a77aaf8097d4412b4e355c6. Test commit b9020a9.

The source is a two-slice, one-mip R32G32_UINT texture with two synthetic BC1 blocks. The destination is a two-slice, two-mip BC1 texture at the same title address, initialized to blue. The fixture resolves the alias through alias_source, records alias_copy, submits the list and reads the packed destination blocks back.

  • On 940d32f with the same test, array slice 1 overwrites mip 1 of destination slice 0 with the green block 0x07e0.
  • On b6a9ebe, the tested mip retains its original blue block 0x001f. Full forced-WARP GPU library suite gives 148 passed, 2 ignored. GPU Clippy in both feature modes and repository policy passed.

Please preserve the Git author if you cherry-pick this test. If you fold it into another commit, please add:

Co-authored-by: andrewpozdnakov7-jpg [email protected]

AI-assisted. Synthetic tests only.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7160275224 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2275#issuecomment-7160275224). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-25T10:51:54Z. --- I added a WARP readback regression on top of your exact head `b6a9ebe00182abf29a77aaf8097d4412b4e355c6`. [Test commit `b9020a9`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/b9020a9e8b5689d2c28a79cd6d0b4d466e1c045c). The source is a two-slice, one-mip R32G32_UINT texture with two synthetic BC1 blocks. The destination is a two-slice, two-mip BC1 texture at the same title address, initialized to blue. The fixture resolves the alias through `alias_source`, records `alias_copy`, submits the list and reads the packed destination blocks back. - On `940d32f` with the same test, array slice 1 overwrites mip 1 of destination slice 0 with the green block `0x07e0`. - On `b6a9ebe`, the tested mip retains its original blue block `0x001f`. Full forced-WARP GPU library suite gives 148 passed, 2 ignored. GPU Clippy in both feature modes and repository policy passed. Please preserve the Git author if you cherry-pick this test. If you fold it into another commit, please add: Co-authored-by: andrewpozdnakov7-jpg <[email protected]> AI-assisted. Synthetic tests only.
Marvisak commented 2026-11-25 14:07:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T13:32:52Z.


Automated triage for the maintainers.

Merge candidate (worth a look). texture::alias_copy copied aliased textures by subresource index; for arrays whose mip counts differ, index i names a different mip/slice in each (D3D12 numbers subresources mip-major within a slice), and the footprint comparison on main does not always catch that. The new subresources_correspond skips such pairs (with a once! log), which leaves the destination stale instead of writing a slice into another slice's mip; a tester reproduced the wrong copy on main on WARP and its absence with this head. CI check passes and it merges cleanly. Note: #2274 edits the same function and the two conflict textually (a tester merged both by hand); copying the common mips slice by slice could be a later improvement over skipping.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7163935099 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2275#issuecomment-7163935099). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T13:32:52Z. --- <!-- victory-triage v1 head=b6a9ebe00182abf29a77aaf8097d4412b4e355c6 verdict=merge-candidate at=2026-11-25T13:48:00Z --> Automated triage for the maintainers. **Merge candidate (worth a look).** `texture::alias_copy` copied aliased textures by subresource index; for arrays whose mip counts differ, index `i` names a different mip/slice in each (D3D12 numbers subresources mip-major within a slice), and the footprint comparison on `main` does not always catch that. The new `subresources_correspond` skips such pairs (with a `once!` log), which leaves the destination stale instead of writing a slice into another slice's mip; a tester reproduced the wrong copy on `main` on WARP and its absence with this head. CI `check` passes and it merges cleanly. Note: #2274 edits the same function and the two conflict textually (a tester merged both by hand); copying the common mips slice by slice could be a later improvement over skipping. --- _Generated by [Claude Code](https://claude.ai/code)_
upstream-sync closed this pull request 2026-11-25 23:04:09 +00:00
Marvisak commented 2026-11-25 23:05:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:07:47Z.


Automated triage for the maintainers, second look (a review against current main, with builds and tests where they could change the verdict).

Closing because the fix is worse than main where it applies. It returns before copying anything, so subresource 0 and the first slice's common mips, which do correspond, are no longer copied, and host_writes is not called, so the destination falls back to stale title memory. The helper also tests only the source's array size. The problem is real in principle; copying by (mip, slice) for the mips below the smaller count would be the right change.

If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7175972897 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2275#issuecomment-7175972897). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:07:47Z. --- Automated triage for the maintainers, second look (a review against current `main`, with builds and tests where they could change the verdict). Closing because the fix is worse than `main` where it applies. It returns before copying anything, so subresource 0 and the first slice's common mips, which do correspond, are no longer copied, and `host_writes` is not called, so the destination falls back to stale title memory. The helper also tests only the source's array size. The problem is real in principle; copying by (mip, slice) for the mips below the smaller count would be the right change. If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

Pull request closed

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
Marvisak/VIctory!2273
No description provided.