Skip to content

Share immutable texture address tables - #118

Open
andrewDoing wants to merge 1 commit into
DexNom:mainfrom
andrewDoing:perf/share-texture-patterns
Open

andrewDoing wants to merge 1 commit into
DexNom:mainfrom
andrewDoing:perf/share-texture-patterns

Conversation

@andrewDoing

@andrewDoing andrewDoing commented Nov 26, 2026 •

Copy link
Copy Markdown

Identical texture layouts currently rebuild immutable address tables, and cloning a layout copies the tables again. Lazily share tables by their bounded layout parameters, keeping the Series X and S render-XOR patterns separate.

10,080 layout combinations produced the same tables or invalid result as before. Cross-thread model isolation and all 12 texture tests passed. This branch merges cleanly with #109; the combined implementation matched upstream for 5,010 tile/detile layouts, including pitches and padding.

In synthetic 20,000-layout runs, standard 64 KiB layout construction fell from a 24.728 ms median to 1.498 ms and cloning from 3.249 ms to 0.762 ms. Cached table storage is bounded to 55 slots, at most approximately 44 KiB on Win64. These are CPU-only measurements; no gameplay frame-time claim.

Pinned Rust 1.98.1: both workspace Clippy configurations and asset policy passed; serial workspace tests: 684 passed, 0 failed, 12 ignored with CI's software-adapter setting.

GPT-6.2 Astra implemented and tested the change.

Related work: TG0000's shared swizzle tables independently shares standard swizzle patterns. This implementation was developed independently and also shares the model-specific render-XOR patterns.

@retrope13

Copy link
Copy Markdown

Independent hardware-GPU Windows verification and diff review of #118 (a0cf6e6c) against main (64bd58f5): both Clippy configs, victory-formats (debug + release), and full workspace suite pass with 0 failures (no software-adapter skip).

Tested

  • Hardware / Env: NVIDIA GeForce RTX 4060 Laptop GPU (8 GB, driver 32.0.16.2140), Intel Core i5-14500HX (14C/20T), 24 GB RAM, Windows 11 26H2 (build 26300.9818), pinned rustc 1.98.1 (x86_64-pc-windows-msvc), verified BCPack tables via Initialize-FormatTables.ps1.
  • victory-formats tests:
    • Debug (cargo test --locked -p victory-formats): 27 passed, 0 failed, 4 ignored (7.69 s, including layouts_share_model_specific_render_patterns).
    • Release (cargo test --release --locked -p victory-formats): 27 passed, 0 failed, 4 ignored (0.50 s).
  • Clippy (both CI configs):
    • cargo clippy --workspace --all-targets --locked -- -D warnings: pass (exit 0)
    • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: pass (exit 0)
  • Full workspace suite (real hardware GPU, VICTORY_TESTS_ALLOW_SOFTWARE_SKIP unset):
    • cargo test --workspace --locked --no-fail-fast -- --test-threads=1: 684 passed, 0 failed, 12 ignored.

Diff Review (64bd58f5..a0cf6e6c)

  • Bounds & bijective cache indexing (crates/victory-formats/src/texture.rs:549-569): Verified every index into STANDARD ([OnceLock<Pattern>; 45]) and RENDER ([[OnceLock<Pattern>; 5]; 2]) is strictly in-bounds and collision-free: Layout::new_for_model enforces element_bytes.is_power_of_two() && element_bytes <= 16 (element_log2 ∈ 0..=4), Swizzle::block_log2 only returns {8, 12, 16} for tiled modes ((block_log2 - 8) / 4 ∈ 0..=2), and kind ∈ 0..=2 (standard / display / 3D thick).
  • Model isolation & Layout semantics: Series X and Series S render-XOR patterns occupy distinct RENDER[0] / RENDER[1] slots, Clone now copies &'static Pattern in O(1), and PartialEq/Eq still compare pattern contents identically.

Not Tested

  • Live retail gameplay runs, AMD GPUs, and the 12 #[ignore] tests.

AI disclosure: Antigravity (Gemini 4 Neon, XHigh) ran the checks, reviewed the diff, and drafted this report.

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.

3 participants