GPU: aliased textures copy only the subresources that have the same bytes per row #2272

Open
denkencar-sketch wants to merge 1 commit from upstream-pr/2274 into main
denkencar-sketch commented 2026-11-25 09:28:59 +00:00 (Migrated from github.com)

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


Summary

Aliased textures were copied subresource by subresource when mips had the same footprint and rows but another row width, through a buffer sized for only one of them. common_subresources now keeps only the subresources with the same bytes per row.

Testing

Test aliased_subresources_need_the_same_bytes_per_row fails without the sa == sb row-pitch check and passes with this change; it covers the helper, not the alias_copy 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:6601356209 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2274). Originally posted by [denkencar-sketch](https://github.com/denkencar-sketch) on 2026-11-25T09:28:59Z. --- ## Summary Aliased textures were copied subresource by subresource when mips had the same footprint and rows but another row width, through a buffer sized for only one of them. `common_subresources` now keeps only the subresources with the same bytes per row. ## Testing Test `aliased_subresources_need_the_same_bytes_per_row` fails without the `sa == sb` row-pitch check and passes with this change; it covers the helper, not the `alias_copy` 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:18 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Aliased textures copy only the subresources that have the same footprint (common_subresources prefix match). 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. Cluster with #2275 (both touch alias_copy in texture.rs).

<!-- greyfinch-sync:Marvisak/VIctory:review:6055075042 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2274#pullrequestreview-6055075042). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T09:35:42Z. **Review:** COMMENTED --- Aliased textures copy only the subresources that have the same footprint (common_subresources prefix match). 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. Cluster with #2275 (both touch alias_copy in texture.rs).
DenRakEiw commented 2026-11-25 10:07:18 +00:00 (Migrated from github.com)

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

Review: APPROVED


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

  • Capturing pRowSizeInBytes from GetCopyableFootprints and checking sa[i] == sb[i] in common_subresources cleanly prevents copying aliased subresources whose row pitch matches but whose per-row byte count differs.
  • cargo test -p victory-gpu texture::: 3/3 passed on RTX 5090, 3/3 passed on WARP (including aliased_subresources_need_the_same_bytes_per_row).
  • 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:6055486768 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2274#pullrequestreview-6055486768). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T10:04:01Z. **Review:** APPROVED --- Verified against `origin/main` (`940d32f`) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP: - Capturing `pRowSizeInBytes` from `GetCopyableFootprints` and checking `sa[i] == sb[i]` in `common_subresources` cleanly prevents copying aliased subresources whose row pitch matches but whose per-row byte count differs. - `cargo test -p victory-gpu texture::`: 3/3 passed on RTX 5090, 3/3 passed on WARP (including `aliased_subresources_need_the_same_bytes_per_row`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: 0 warnings. - `cargo xtask policy`: 183 files ok. AI-assisted (Gemini 4 Neon).
Marvisak commented 2026-11-25 14:07:23 +00:00 (Migrated from github.com)

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


Automated triage for the maintainers.

Worth a look: texture.rs alias_copy copies subresources in order while their offsets, row pitch, row count and depth match. It does not compare the row size in bytes, so a pair such as a 25x16 RGBA32 texture and a 100x64 BC7 texture (mip 1: 192 against 208 bytes a row) was copied out of a buffer sized from texture A's footprints with texture B's, reading past its end. The PR also takes GetCopyableFootprints' row sizes and stops at the first subresource where they differ (common_subresources); its unit test numbers check out. CI passes. It touches the same lines as #1888 (a larger rework of the same function, which does not add this check), so whichever lands second needs a rebase.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7163913787 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2274#issuecomment-7163913787). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T13:32:01Z. --- <!-- victory-triage v1 head=8a88297df004c98794ccfc548774af8a3b4761f4 verdict=merge-candidate at=2026-11-25T13:33:20Z --> Automated triage for the maintainers. Worth a look: `texture.rs` `alias_copy` copies subresources in order while their offsets, row pitch, row count and depth match. It does not compare the row size in bytes, so a pair such as a 25x16 RGBA32 texture and a 100x64 BC7 texture (mip 1: 192 against 208 bytes a row) was copied out of a buffer sized from texture A's footprints with texture B's, reading past its end. The PR also takes `GetCopyableFootprints`' row sizes and stops at the first subresource where they differ (`common_subresources`); its unit test numbers check out. CI passes. It touches the same lines as #1888 (a larger rework of the same function, which does not add this check), so whichever lands second needs a rebase. --- _Generated by [Claude Code](https://claude.ai/code)_
fuzeofficlal commented 2026-11-26 01:04:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T00:50:46Z.


Code review and RTX 5090 + WARP verification at head 8a88297df004 merged cleanly onto main (63bcca43c6a0):

  • Code review (crates/victory-gpu/src/texture.rs:249-326):
    • common_subresources adds pRowSizeInBytes (sa[i] == sb[i]) alongside Offset, RowPitch, row count (ra[i] == rb[i]), and Depth from GetCopyableFootprints.
    • Fixes aliased BC/uncompressed pairs (such as 100x64 BC7 vs 25x16 RGBA32) where mip 0 matches but mip 1 shares RowPitch = 256 / rows = 8 / Offset = 8192 while differing in actual row byte width (208 B vs 192 B), ensuring the total-byte staging buffer allocated from fa strictly covers fb[0..n]. Stopping at the first mismatched subresource via take_while is conservative on multi-slice arrays but safe.
  • Verified (Windows 11, NVIDIA RTX 5090 + WARP, VICTORY_D3D12_DEBUG=1, Rust 1.98.1):
    • cargo xtask policy: 191 files ok; cargo clippy -p victory-gpu --all-targets -- -D warnings (default + --features diagnostics): 0 warnings
    • texture:: resource::tests: 21/21 passed on both RTX 5090 and WARP (--features diagnostics).

LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7179171187 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2274#issuecomment-7179171187). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T00:50:46Z. --- Code review and RTX 5090 + WARP verification at head `8a88297df004` merged cleanly onto `main` (`63bcca43c6a0`): - **Code review (`crates/victory-gpu/src/texture.rs:249-326`)**: - `common_subresources` adds `pRowSizeInBytes` (`sa[i] == sb[i]`) alongside `Offset`, `RowPitch`, row count (`ra[i] == rb[i]`), and `Depth` from `GetCopyableFootprints`. - Fixes aliased BC/uncompressed pairs (such as `100x64` BC7 vs `25x16` RGBA32) where mip 0 matches but mip 1 shares `RowPitch = 256` / `rows = 8` / `Offset = 8192` while differing in actual row byte width (`208` B vs `192` B), ensuring the `total`-byte staging buffer allocated from `fa` strictly covers `fb[0..n]`. Stopping at the first mismatched subresource via `take_while` is conservative on multi-slice arrays but safe. - **Verified (Windows 11, NVIDIA RTX 5090 + WARP, `VICTORY_D3D12_DEBUG=1`, Rust 1.98.1)**: - `cargo xtask policy`: `191 files ok`; `cargo clippy -p victory-gpu --all-targets -- -D warnings` (default + `--features diagnostics`): 0 warnings - `texture:: resource::tests`: **21/21 passed** on both RTX 5090 and WARP (`--features diagnostics`). LGTM.
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/2274:upstream-pr/2274'
git switch 'upstream-pr/2274'

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