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

Open
opened 2026-11-26 04:14:27 +00:00 by github-bot · 2 comments
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 14:20 UTC · original

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.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 14:20 UTC · [original](https://github.com/Marvisak/VIctory/issues/935) ### 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.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:14:27 +00:00
Author
Owner

@⁠MichaelSmithAI on GitHub · 2026-11-24 14:34 UTC · original

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.

**@⁠MichaelSmithAI** on GitHub · 2026-11-24 14:34 UTC · [original](https://github.com/Marvisak/VIctory/issues/935#issuecomment-7134596660) 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.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 06:51 UTC · original

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

**@⁠Marvisak** on GitHub · 2026-11-25 06:51 UTC · [original](https://github.com/Marvisak/VIctory/issues/935#issuecomment-7155232277) <!-- 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)_
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory#935
No description provided.