fix(formats,core): harden Layout::copy_table and ignore empty env vars in default_dir (#320) #334

Manually merged
github merged 1 commit from github-bot/gh-334 into gh-pr/334/base 2026-12-02 12:52:35 +00:00 AGit
Owner

@⁠RUIZ-Enrique-25002136 on GitHub · 2026-12-02 12:40 UTC · original
RUIZ-Enrique-25002136:fix/formats-copy-table-and-core-default-dir → main · +105 −11 · 2 files · 1 commits · merged 2026-12-02 12:48 UTC

Summary

Fixes all three platform-independent bugs tracked in #320 across crates/victory-formats/src/texture.rs and crates/victory-core/src/config.rs.

Fixes #320

AI-Ready Context & Change Map

For downstream coding/review agents, here is the exact scope, behavioral invariants, and test coverage of this PR:

  1. crates/victory-formats/src/texture.rs — Layout::copy_table (texture.rs:958-976)

    • Reject render_xor layouts (texture.rs:958-960):
      • configure_render_xor makes Layout::addressable() return true for SW_64KB_R_X while self.pattern remains &EMPTY_PATTERN ([Vec::new(); 3]).
      • Added || self.render_xor.is_some() to the initial guard so copy_table returns Err(Error::Unsupported) instead of panicking with out-of-bounds index 0 inside Layout::column(m, 0) (texture.rs:657). This restores clean fallback to Why::NoTable / CPU detiling in crates/victory-gpu/src/detile.rs:758.
    • Enforce 3D overlapping depth-slice validation (texture.rs:961-976):
      • Computes slice_bytes = (m.height - 1) * row_pitch + bytes (checked), rejects row_pitch < bytes with Err(Error::TooSmall), and rejects depth > 1 && depth_pitch < slice_bytes with Err(Error::TooSmall) before computing need, matching Layout::walk (texture.rs:751-764).
    • Unit tests (texture.rs:2231-2274):
      • copy_table_rejects_render_xor_layout: verifies SW_64KB_R_X + configure_render_xor reports addressable() == true and returns Err(Error::Unsupported) from copy_table.
      • copy_table_rejects_overlapping_depth_slices: verifies Tex3d (depth = 4) returns Err(Error::TooSmall) for depth_pitch = 0 and slice_bytes - 1, and Ok(_) for depth_pitch = slice_bytes.
  2. crates/victory-core/src/config.rs — default_dir / default_dir_from (config.rs:146-163)

    • Extracted default_dir_from(name, env) called by default_dir(name) so directory resolution can be unit-tested deterministically without mutating process environment variables.
    • Filtered empty values (filter(|v| !v.is_empty())) across VICTORY_HOME, LOCALAPPDATA, XDG_CACHE_HOME, and HOME, matching env_path, explicit_config_path, and home_override. Prevents empty env vars (e.g. XDG_CACHE_HOME="") from producing relative paths (victory/<name> / .cache/victory/<name>) in CWD.
    • Unit test (config.rs:249-280): default_dir_ignores_empty_env_vars covers empty VICTORY_HOME/LOCALAPPDATA/XDG_CACHE_HOME falling back to HOME/.cache, fallback to XDG_CACHE_HOME, and error when all four are empty.

Rig Specs Tested On

  • CPU: Linux workstation (x86_64)
  • GPU & VRAM: N/A (platform-independent victory-formats and victory-core fixes)
  • System RAM: N/A
  • OS & GPU Driver: Linux (x86_64) — Windows x86_64-pc-windows-msvc full workspace clippy and tests verified by GitHub Actions (windows-latest)

Run Settings & Profile

  • Build & Commit SHA: fixes rebased on origin/main (3230974)
  • Console Profile & Internal Resolution / Scale: N/A (unit tests)
  • Ray Tracing: N/A
  • Upscaling: N/A
  • Frame Generation: N/A
  • Launcher Command / Preset & Extra VICTORY_* Overrides: N/A
  • Scene / Area & Session Length: N/A

Measurements & Verification

  • Base FPS (without Frame Gen): N/A
  • Frame-Gen FPS (if enabled): N/A
  • VRAM / RAM Usage: N/A
  • Crashes / DRED Resets: N/A
  • Automated Checks:
    • cargo clippy --workspace --all-targets --locked -- -D warnings (requires x86_64-pc-windows-msvc; verified on GitHub Actions windows-latest CI)
    • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings (requires x86_64-pc-windows-msvc; verified on GitHub Actions windows-latest CI)
    • cargo test --locked -p victory-core -> 15 passed, 0 failed
    • cargo test --locked -p victory-formats -> 69 passed, 0 failed, 7 ignored
    • cargo clippy --locked -p victory-formats -p victory-core --all-targets -- -D warnings -> 0 warnings, exit 0
    • cargo test --locked -p xtask -> 8 passed, 0 failed
    • cargo xtask policy -> asset policy: 324 files ok
**@⁠RUIZ-Enrique-25002136** on GitHub · 2026-12-02 12:40 UTC · [original](https://github.com/Androtim/MiniVI/pull/334) `RUIZ-Enrique-25002136:fix/formats-copy-table-and-core-default-dir` → `main` · +105 −11 · 2 files · 1 commits · merged 2026-12-02 12:48 UTC ## Summary Fixes all three platform-independent bugs tracked in #320 across `crates/victory-formats/src/texture.rs` and `crates/victory-core/src/config.rs`. Fixes #320 ### AI-Ready Context & Change Map For downstream coding/review agents, here is the exact scope, behavioral invariants, and test coverage of this PR: 1. **`crates/victory-formats/src/texture.rs` — `Layout::copy_table` (`texture.rs:958-976`)** - **Reject `render_xor` layouts (`texture.rs:958-960`):** - `configure_render_xor` makes `Layout::addressable()` return `true` for `SW_64KB_R_X` while `self.pattern` remains `&EMPTY_PATTERN` (`[Vec::new(); 3]`). - Added `|| self.render_xor.is_some()` to the initial guard so `copy_table` returns `Err(Error::Unsupported)` instead of panicking with out-of-bounds index `0` inside `Layout::column(m, 0)` (`texture.rs:657`). This restores clean fallback to `Why::NoTable` / CPU detiling in `crates/victory-gpu/src/detile.rs:758`. - **Enforce 3D overlapping depth-slice validation (`texture.rs:961-976`):** - Computes `slice_bytes = (m.height - 1) * row_pitch + bytes` (checked), rejects `row_pitch < bytes` with `Err(Error::TooSmall)`, and rejects `depth > 1 && depth_pitch < slice_bytes` with `Err(Error::TooSmall)` before computing `need`, matching `Layout::walk` (`texture.rs:751-764`). - **Unit tests (`texture.rs:2231-2274`):** - `copy_table_rejects_render_xor_layout`: verifies `SW_64KB_R_X` + `configure_render_xor` reports `addressable() == true` and returns `Err(Error::Unsupported)` from `copy_table`. - `copy_table_rejects_overlapping_depth_slices`: verifies `Tex3d` (`depth = 4`) returns `Err(Error::TooSmall)` for `depth_pitch = 0` and `slice_bytes - 1`, and `Ok(_)` for `depth_pitch = slice_bytes`. 2. **`crates/victory-core/src/config.rs` — `default_dir` / `default_dir_from` (`config.rs:146-163`)** - Extracted `default_dir_from(name, env)` called by `default_dir(name)` so directory resolution can be unit-tested deterministically without mutating process environment variables. - Filtered empty values (`filter(|v| !v.is_empty())`) across `VICTORY_HOME`, `LOCALAPPDATA`, `XDG_CACHE_HOME`, and `HOME`, matching `env_path`, `explicit_config_path`, and `home_override`. Prevents empty env vars (e.g. `XDG_CACHE_HOME=""`) from producing relative paths (`victory/<name>` / `.cache/victory/<name>`) in CWD. - **Unit test (`config.rs:249-280`):** `default_dir_ignores_empty_env_vars` covers empty `VICTORY_HOME`/`LOCALAPPDATA`/`XDG_CACHE_HOME` falling back to `HOME/.cache`, fallback to `XDG_CACHE_HOME`, and error when all four are empty. ## Rig Specs Tested On - **CPU:** Linux workstation (`x86_64`) - **GPU & VRAM:** N/A (platform-independent `victory-formats` and `victory-core` fixes) - **System RAM:** N/A - **OS & GPU Driver:** Linux (`x86_64`) — Windows `x86_64-pc-windows-msvc` full workspace clippy and tests verified by GitHub Actions (`windows-latest`) ## Run Settings & Profile - **Build & Commit SHA:** fixes rebased on `origin/main` (`3230974`) - **Console Profile & Internal Resolution / Scale:** N/A (unit tests) - **Ray Tracing:** N/A - **Upscaling:** N/A - **Frame Generation:** N/A - **Launcher Command / Preset & Extra `VICTORY_*` Overrides:** N/A - **Scene / Area & Session Length:** N/A ## Measurements & Verification - **Base FPS (without Frame Gen):** N/A - **Frame-Gen FPS (if enabled):** N/A - **VRAM / RAM Usage:** N/A - **Crashes / DRED Resets:** N/A - **Automated Checks:** - [ ] `cargo clippy --workspace --all-targets --locked -- -D warnings` (requires `x86_64-pc-windows-msvc`; verified on GitHub Actions `windows-latest` CI) - [ ] `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` (requires `x86_64-pc-windows-msvc`; verified on GitHub Actions `windows-latest` CI) - [x] `cargo test --locked -p victory-core` -> 15 passed, 0 failed - [x] `cargo test --locked -p victory-formats` -> 69 passed, 0 failed, 7 ignored - [x] `cargo clippy --locked -p victory-formats -p victory-core --all-targets -- -D warnings` -> 0 warnings, exit 0 - [x] `cargo test --locked -p xtask` -> 8 passed, 0 failed - [x] `cargo xtask policy` -> `asset policy: 324 files ok`
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 12:42:01 +00:00
github-bot changed target branch from main to gh-pr/334/base 2026-12-02 12:52:33 +00:00
github manually merged commit 7b26216aaf into gh-pr/334/base 2026-12-02 12:52:35 +00:00
Author
Owner

@⁠Androtim on GitHub · 2026-12-02 12:48 UTC · original

Autonomous architectural audit PASSED on 7b26216a (CI GREEN, allowlisted author RUIZ-Enrique-25002136): clean platform-independent safety/correctness fixes for #320 (Layout::copy_table render_xor guard + 3D depth_pitch overlap validation matching Layout::walk, and empty env-var filtering in default_dir_from with deterministic unit tests). Squash-merging into main.

**@⁠Androtim** on GitHub · 2026-12-02 12:48 UTC · [original](https://github.com/Androtim/MiniVI/pull/334#issuecomment-7345920949) Autonomous architectural audit **PASSED** on `7b26216a` (CI GREEN, allowlisted author `RUIZ-Enrique-25002136`): clean platform-independent safety/correctness fixes for `#320` (`Layout::copy_table` `render_xor` guard + 3D `depth_pitch` overlap validation matching `Layout::walk`, and empty env-var filtering in `default_dir_from` with deterministic unit tests). Squash-merging into `main`.
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!334
No description provided.