Formats: reject overlapping texture depth slices #351
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/351"
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?
Imported from Marvisak/VIctory. Originally posted by pedrofort on 2026-11-24T02:30:45Z.
<head></head>
Problem
Layout::walk()validates row pitch and total buffer size but does not ensure that the depth pitch separates individual slices of a 3D texture.Both
tile()anddetile()can therefore accept overlapping linear depth slices without reporting an error.Fix
Calculate the minimum occupied byte span of a depth slice using checked arithmetic.
Reject insufficient depth pitches when copying multiple slices.
Preserve valid tightly packed and padded layouts.
Preserve the existing overflow checks.
Verification
Apple M5, macOS arm64, Rust 1.98.1, base commit
Test | Before | After -- | -- | -- Overlapping detile slices | FAIL | PASS Overlapping tile slices | FAIL | PASS Exact and padded slice pitches | PASS | PASS Full formats suite | — | 23 passed, 0 failed, 3 ignoredd2a4bae.Tests cover both linear and 4 KiB standard tiled layouts and verify that rejected copies leave destination buffers unchanged.
Clippy: clean.
Asset policy: 151 files OK.
All tests use synthetic data. No game assets were used.
AI-assisted implementation and test preparation (ChatGPT), with results verified locally on Apple Silicon.
Imported from Marvisak/VIctory. Originally posted by CesarLopesO on 2026-11-24T02:48:54Z.
Independent validation — Debian 13 (Trixie)
I tested the current PR head
93a24b7locally on Debian 13.Results
cargo test --locked -p victory-formats --lib texture::tests::depth_pitch_— 3 passed, 0 failed.cargo test --locked -p victory-formats— 23 passed, 0 failed, 3 ignored.cargo clippy --locked -p victory-formats --all-targets -- -D warnings— passed with no warnings.cargo xtask policy— passed (151 files).git diff --check— passed; working tree clean.The focused tests cover overlapping depth pitches in both
tile()anddetile(), plus exact and padded slice pitches. The fullvictory-formatssuite also passes on Linux.I did not run the full workspace test suite as part of this validation.
No game files or game data were used.
Thanks for the fix!
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T10:05:32Z.
Review: APPROVED
Tested
93a24b7on Windows 11, RTX 5070, MSVC: the workspace passes (198 outsidevictory-shader), including the three newdepth_pitch_*tests on both linear andSW_4KB_S.The check is exact. A slice occupies
(height − 1) · row_pitch + width · bytes, so with more than one slice, anydepth_pitchsmaller than that makes consecutive slices overlap. Rejecting it withTooSmallbefore any copy, which the tests show leaves the destination untouched, closes the gap. Single-slice copies (any pitch, including 0) and D3D12-style footprints (pitch = rows · row_pitch) are unaffected.No issues found. Nit: the description is pasted rich HTML. Plain Markdown would read better on GitHub.
AI-assisted (Claude Code).