Skip to content

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

Merged
Androtim merged 1 commit into
Androtim:mainfrom
RUIZ-Enrique-25002136:fix/formats-copy-table-and-core-default-dir
Dec 2, 2026
Merged

Androtim merged 1 commit into
Androtim:mainfrom
RUIZ-Enrique-25002136:fix/formats-copy-table-and-core-default-dir

Conversation

@RUIZ-Enrique-25002136

Copy link
Copy Markdown
Contributor

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

@Androtim

Androtim commented Dec 2, 2026

Copy link
Copy Markdown
Owner

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
Androtim merged commit 1c72a90 into Androtim:main Dec 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(formats,core): Layout::copy_table panics on render_xor & misses 3D depth_pitch overlap check; empty env vars in default_dir

2 participants