formats(texture): avoid mip layout scratch allocations and reject 1D BC layouts #89

Manually merged
github merged 1 commit from gh-pr/89/head into gh-pr/89/base 2026-12-01 20:08:12 +00:00
Owner

@⁠Androtim on GitHub · 2026-11-29 08:22 UTC · original
Androtim:feat/iter90-formats-mip-alloc-and-1d-bc → main · +144 −4 · 1 files · 1 commits · merged 2026-11-29 09:06 UTC

Summary

Adapted from upstream VIctory-NVIDIA PRs #1259 (0445761) and #1016 (facd4b0) (GPL-3.0), extracted cleanly off origin/main (7fe6886) with zero overlap against open PRs:

  • Remove mip-layout scratch heap allocations (crates/victory-formats/src/texture.rs): Preallocates Vec::with_capacity(d.mips as usize) in Layout::linear and replaces the sizes heap Vec in Layout::tiled with a fixed [0u64; MAX_MIPS as usize] stack array.
  • Reject block-compressed 1D layouts (crates/victory-formats/src/texture.rs): Requires d.block == 1 alongside d.height == 1 when d.dimension == Dimension::Tex1d.
  • Unit tests: Adds 8 unit tests covering linear/tiled mip offsets (MAX_MIPS / MAX_EXTENT) and 1D BC rejection alongside existing uncompressed 1D and 2D/3D BC layouts.

Verification

  • cargo xtask policy: asset policy: 303 files ok
  • cargo test -p victory-formats --lib --locked: 58 passed; 0 failed; 5 ignored (pre-existing benchmarks/external-data tests), including all 8 newly added tests
  • cargo clippy --workspace --all-targets -- -D warnings: 0 warnings
  • cargo clippy --workspace --all-targets --features diagnostics -- -D warnings: 0 warnings
  • Plain --release --locked + objdump -p: standard Windows system DLLs only
**@⁠Androtim** on GitHub · 2026-11-29 08:22 UTC · [original](https://github.com/Androtim/MiniVI/pull/89) `Androtim:feat/iter90-formats-mip-alloc-and-1d-bc` → `main` · +144 −4 · 1 files · 1 commits · merged 2026-11-29 09:06 UTC ## Summary Adapted from upstream `VIctory-NVIDIA` PRs #1259 (`0445761`) and #1016 (`facd4b0`) (GPL-3.0), extracted cleanly off `origin/main` (`7fe6886`) with zero overlap against open PRs: - **Remove mip-layout scratch heap allocations (`crates/victory-formats/src/texture.rs`):** Preallocates `Vec::with_capacity(d.mips as usize)` in `Layout::linear` and replaces the `sizes` heap `Vec` in `Layout::tiled` with a fixed `[0u64; MAX_MIPS as usize]` stack array. - **Reject block-compressed 1D layouts (`crates/victory-formats/src/texture.rs`):** Requires `d.block == 1` alongside `d.height == 1` when `d.dimension == Dimension::Tex1d`. - **Unit tests:** Adds 8 unit tests covering linear/tiled mip offsets (`MAX_MIPS` / `MAX_EXTENT`) and 1D BC rejection alongside existing uncompressed 1D and 2D/3D BC layouts. ## Verification - `cargo xtask policy`: `asset policy: 303 files ok` - `cargo test -p victory-formats --lib --locked`: **58 passed; 0 failed; 5 ignored** (pre-existing benchmarks/external-data tests), including all 8 newly added tests - `cargo clippy --workspace --all-targets -- -D warnings`: **0 warnings** - `cargo clippy --workspace --all-targets --features diagnostics -- -D warnings`: **0 warnings** - Plain `--release --locked` + `objdump -p`: standard Windows system DLLs only
Adapt VIctory-NVIDIA #1259 (0445761) and #1016 (facd4b0) (GPL-3.0):
- Preallocate linear mip vector to d.mips and replace tiled layout's heap
  scratch Vec with a fixed [u64; MAX_MIPS] stack array.
- Reject block-compressed 1D texture layouts (block != 1 for Dimension::Tex1d)
  and add unit tests covering linear/tiled mip layouts and 1D BC validation.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 20:08:10 +00:00
github manually merged commit a6b80479b4 into gh-pr/89/base 2026-12-01 20:08:12 +00:00
Author
Owner

@⁠Androtim on GitHub · 2026-11-29 09:02 UTC · original

Automated triage for the maintainers (not an approval).

Verdict: merge-candidate · CI (check): passing

Triage Review

Clean, focused change in crates/victory-formats/src/texture.rs with CI passing and no overlap with other open PRs.

Verified Changes

  • Reject 1D block-compressed layouts (Layout::new, L299): Tightens the Dimension::Tex1d check to d.height == 1 && d.block == 1, rejecting 4×4 BC formats on 1D textures consistently with the existing multisample d.block == 1 guard (L295).
  • Avoid mip-layout scratch allocations (Layout::linear L318, Layout::tiled L426/L439):
    • Preallocates mips with Vec::with_capacity(d.mips as usize) in Layout::linear (matching Layout::tiled at L377).
    • Replaces the temporary sizes Vec in Layout::tiled with [0u64; MAX_MIPS as usize]. Because Layout::new enforces (1..=MAX_MIPS).contains(&d.mips) (L288), i as usize in 0..d.mips is strictly in-bounds and every slot read in 0..first_tail_mip as usize (L457-L460) is populated beforehand.
  • Unit tests: Adds 8 targeted tests covering linear/tiled mip offset ordering (including MAX_MIPS / MAX_EXTENT bounds and tail-only layouts) and 1D BC rejection without regressing uncompressed 1D or 2D/3D BC layouts.

Verdict

merge-candidate — pure CPU layout calculation/validation in victory-formats with passing CI and good test coverage; no local GPU smoke test needed. (Triage assessment only, not formal maintainer approval.)


Generated with Antigravity CLI (agy).

**@⁠Androtim** on GitHub · 2026-11-29 09:02 UTC · [original](https://github.com/Androtim/MiniVI/pull/89#issuecomment-7253498261) <!-- minivi-triage v1 head=a6b80479b4cdfa523a576edc0d35dd5936897b29 verdict=merge-candidate ci=passing at=2026-11-29T09:03:15Z --> Automated triage for the maintainers (not an approval). **Verdict:** `merge-candidate` · **CI (`check`):** `passing` ### Triage Review Clean, focused change in `crates/victory-formats/src/texture.rs` with CI passing and no overlap with other open PRs. #### Verified Changes - **Reject 1D block-compressed layouts (`Layout::new`, L299):** Tightens the `Dimension::Tex1d` check to `d.height == 1 && d.block == 1`, rejecting 4×4 BC formats on 1D textures consistently with the existing multisample `d.block == 1` guard (L295). - **Avoid mip-layout scratch allocations (`Layout::linear` L318, `Layout::tiled` L426/L439):** - Preallocates `mips` with `Vec::with_capacity(d.mips as usize)` in `Layout::linear` (matching `Layout::tiled` at L377). - Replaces the temporary `sizes` `Vec` in `Layout::tiled` with `[0u64; MAX_MIPS as usize]`. Because `Layout::new` enforces `(1..=MAX_MIPS).contains(&d.mips)` (L288), `i as usize` in `0..d.mips` is strictly in-bounds and every slot read in `0..first_tail_mip as usize` (L457-L460) is populated beforehand. - **Unit tests:** Adds 8 targeted tests covering linear/tiled mip offset ordering (including `MAX_MIPS` / `MAX_EXTENT` bounds and tail-only layouts) and 1D BC rejection without regressing uncompressed 1D or 2D/3D BC layouts. #### Verdict `merge-candidate` — pure CPU layout calculation/validation in `victory-formats` with passing CI and good test coverage; no local GPU smoke test needed. (Triage assessment only, not formal maintainer approval.) --- _Generated with Antigravity CLI (`agy`)._
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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/Androtim--MiniVI!89
No description provided.