GPU: fix texture footprint span and committed-range overflow with unit tests #935

Open
opened 2026-11-24 14:20:17 +00:00 by geiyiliyabumo · 2 comments
geiyiliyabumo commented 2026-11-24 14:20:17 +00:00 (Migrated from github.com)
Contributor

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T14:20:17Z.


Summary

Fixes 2 real defects in crates/victory-gpu/src/texture.rs (previously 0 unit tests) and adds 9 deterministic synthetic unit tests.

Because external PR creation is currently restricted (collaborators_only), the CI-green branch is ready on my fork for cherry-pick / review:

  • Branch: geiyiliyabumo/VIctory@test/gpu-texture-audit
  • Commit: geiyiliyabumo/VIctory@1456fe7 (based on main ffe310e)

Changes (crates/victory-gpu/src/texture.rs)

  • Fix 1: Upload staging span now uses the exact D3D12 footprint ending after the last row's data (previously over-reported e.g. 1,536 bytes for a 1,300-byte footprint).
  • Fix 2: Committed-memory range queries now reject overflowing address ranges cleanly instead of panicking on arithmetic overflow.
  • Tests (+9 synthetic): covers footprint bounds, placement/arithmetic bounds, array mip order, 3D depth strides, BC1/BC7 block rows, upload eligibility, and Windows committed memory queries.

Verification (Windows 11 x64 MSVC)

  • rustfmt --edition 2024 --check crates/victory-gpu/src/texture.rs: PASS
  • cargo xtask policy: PASS (154 files ok)
  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings (default + --features diagnostics): PASS (0 warnings)
  • cargo test -p victory-gpu --locked -- texture:: (default + --features diagnostics): 9 passed, 0 failed

AI-assisted; synthetic tests only, no game files.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6583883209 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/935). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-24T14:20:17Z. --- ### Summary Fixes 2 real defects in `crates/victory-gpu/src/texture.rs` (previously 0 unit tests) and adds 9 deterministic synthetic unit tests. Because external PR creation is currently restricted (`collaborators_only`), the CI-green branch is ready on my fork for cherry-pick / review: - **Branch**: `geiyiliyabumo/VIctory@test/gpu-texture-audit` - **Commit**: `geiyiliyabumo/VIctory@1456fe7` (based on `main` `ffe310e`) ### Changes (`crates/victory-gpu/src/texture.rs`) - **Fix 1**: Upload staging span now uses the exact D3D12 footprint ending after the last row's data (previously over-reported e.g. 1,536 bytes for a 1,300-byte footprint). - **Fix 2**: Committed-memory range queries now reject overflowing address ranges cleanly instead of panicking on arithmetic overflow. - **Tests (+9 synthetic)**: covers footprint bounds, placement/arithmetic bounds, array mip order, 3D depth strides, BC1/BC7 block rows, upload eligibility, and Windows committed memory queries. ### Verification (Windows 11 x64 MSVC) - `rustfmt --edition 2024 --check crates/victory-gpu/src/texture.rs`: **PASS** - `cargo xtask policy`: **PASS** (`154 files ok`) - `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings` (default + `--features diagnostics`): **PASS** (0 warnings) - `cargo test -p victory-gpu --locked -- texture::` (default + `--features diagnostics`): **9 passed, 0 failed** *AI-assisted; synthetic tests only, no game files.*
MichaelSmithAI commented 2026-11-24 15:04:06 +00:00 (Migrated from github.com)
Author
Contributor

Imported from Marvisak/VIctory. Originally posted by MichaelSmithAI on 2026-11-24T14:34:26Z.


On 1456fe7, a test-only GPU readback exercised the production texture upload on an RTX 4090 under Wine with vkd3d-proton 3.2. The input was a tiled 5×6 RGBA8 texture with 120 distinct bytes. The staging buffer was 1,300 bytes and the subresource range was 0..1300 (five 256-byte pitches plus the final 20 bytes). After upload, all six rows matched the input byte for byte, including the last row.

All ten texture tests passed with diagnostics enabled (the nine authored tests plus this readback). The GPU case covers a single mip and array slice. Title use and any change in rendered output remain unmeasured.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7134596660 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/935#issuecomment-7134596660). Originally posted by [MichaelSmithAI](https://github.com/MichaelSmithAI) on 2026-11-24T14:34:26Z. --- On `1456fe7`, a test-only GPU readback exercised the production texture upload on an RTX 4090 under Wine with vkd3d-proton 3.2. The input was a tiled 5×6 RGBA8 texture with 120 distinct bytes. The staging buffer was 1,300 bytes and the subresource range was `0..1300` (five 256-byte pitches plus the final 20 bytes). After upload, all six rows matched the input byte for byte, including the last row. All ten texture tests passed with diagnostics enabled (the nine authored tests plus this readback). The GPU case covers a single mip and array slice. Title use and any change in rendered output remain unmeasured.
Marvisak commented 2026-11-25 07:03:24 +00:00 (Migrated from github.com)
Author
Contributor

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


Automated triage for the maintainers.

Both defects look fixed on current main (merge 256d7b9, today). In crates/victory-gpu/src/texture.rs, subresource_len now clamps a subresource's span to total - offset, so a 5x6 RGBA8 upload stays at the 1,300-byte footprint (test subresource_len_stays_inside_staging_total), and committed uses checked_add and returns false on an overflowing range instead of panicking. The extra unit tests on 1456fe7 would still be welcome as a pull request (pull requests are open to everyone now). Proposed for closing as fixed in main: it will be closed in 48 hours unless the reporter replies or a maintainer removes the label.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7155232277 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/935#issuecomment-7155232277). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T06:51:32Z. --- <!-- victory-issue-triage v1 verdict=proposed-close seen=2026-11-24T14:34:26Z at=2026-11-25T06:51:32Z --> Automated triage for the maintainers. Both defects look fixed on current `main` (merge `256d7b9`, today). In `crates/victory-gpu/src/texture.rs`, `subresource_len` now clamps a subresource's span to `total - offset`, so a 5x6 RGBA8 upload stays at the 1,300-byte footprint (test `subresource_len_stays_inside_staging_total`), and `committed` uses `checked_add` and returns `false` on an overflowing range instead of panicking. The extra unit tests on `1456fe7` would still be welcome as a pull request (pull requests are open to everyone now). Proposed for closing as fixed in `main`: it will be closed in 48 hours unless the reporter replies or a maintainer removes the label. --- _Generated by [Claude Code](https://claude.ai/code)_
Sign in to join this conversation.
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#935
No description provided.