Skip to content

BCPack: keep all 32 indices in the first BC7 dictionary entry - #374

Open
davutsimsekk wants to merge 1 commit into
fxceless:mainfrom
davutsimsekk:fix/bcpack-bc7-first-entry
Open

davutsimsekk wants to merge 1 commit into
fxceless:mainfrom
davutsimsekk:fix/bcpack-bc7-first-entry

Conversation

@davutsimsekk

Copy link
Copy Markdown

BCPack's BC7 dictionary stores 255 entries. Entry 0 has its 32 i16 indices immediately after the two bit-width bytes; every later entry repeats the width bytes first. Tables::parse skipped a u16 for every entry, so entry 0 read index 0 as the width field and shifted all its indices by one.

pick can reference dictionary[0] (for example a block whose restored index is 0), so this produced wrong BC7 indices for those blocks.

This keeps the width skip only for entries after the first.

Test

bc7_first_dictionary_entry_keeps_all_32_indices builds the table with entry 0's width bytes and indices 2, 1, and asserts the parsed entry keeps ix[0][0] == 2 and ix[0][1] == 1. On main the first value is 0.

  • cargo test -p victory-formats --lib: 25 passed, 0 failed, 4 ignored
  • cargo clippy -p victory-formats --all-targets --locked -- -D warnings: clean
  • rustfmt --edition 2024 --check crates/victory-formats/src/bcpack.rs: clean
  • No game data or GPU was used.

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.

1 participant