Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/xcl/src/hle/bcpack/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,7 @@ pub static BC6: [(Bc6Ep, Bc6Ix); DICTIONARY] = [
(Bc6Ep { e: [[45056, 40960, 38400], [0, 38912, 45056], [29696, 37888, 36864], [12288, 26624, 45056]] }, Bc6Ix { mode: 8, ix: [-4, 3, -2, -3, -2, 0, -3, -3, 1, -2, -4, -3, 2, -3, -3, -3] }),
];
pub static BC7: [(Bc7Ep, Bc7Ix); DICTIONARY] = [
(Bc7Ep { ctrl: 0, rows: [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]] }, Bc7Ix { bits: [4, 0], ix: [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] }),
(Bc7Ep { ctrl: 0, rows: [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]] }, Bc7Ix { bits: [4, 0], ix: [[2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] }),
(Bc7Ep { ctrl: 1, rows: [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]] }, Bc7Ix { bits: [3, 0], ix: [[1, 0, 0, 0, 0, 0, -1, -1, 0, -1, 0, 0, 0, -1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] }),
(Bc7Ep { ctrl: 4, rows: [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]] }, Bc7Ix { bits: [4, 0], ix: [[4, 5, 3, 4, 4, 4, 4, 3, 4, 4, 5, 4, 5, 4, 4, 4], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] }),
(Bc7Ep { ctrl: 5, rows: [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]] }, Bc7Ix { bits: [4, 0], ix: [[2, -2, -4, -2, 3, -2, -4, -2, -2, 1, -4, -3, -2, -1, -4, -3], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] }),
Expand Down
8 changes: 7 additions & 1 deletion crates/xcl/src/hle/bcpack/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,15 @@ fn junk_streams_do_not_panic() {
}

/// The BC7 dictionary indices follow VIctory PR #658: a set with 0 bits holds no
/// indices, and pixel 0 is the anchor (top bit clear).
/// indices, and pixel 0 is the anchor (top bit clear). Entry 0 stores all 32 indices
/// directly without the repeated width word, keeping its leading `[2, 1, 0, ...]` values.
#[test]
fn bc7_dictionary_indices_line_up() {
let (ep0, ix0) = super::tables::BC7[0];
assert_eq!(ep0.ctrl, 0);
assert_eq!(ix0.bits, [4, 0]);
assert_eq!(ix0.ix[0], [2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
assert_eq!(ix0.ix[1], [0; 16]);
for (k, (_, ix)) in super::tables::BC7.iter().enumerate() {
assert!(ix.bits[0] > 0, "entry {k}: the first index set has no bits");
let hi = 1i16 << (ix.bits[0] - 1);
Expand Down
13 changes: 8 additions & 5 deletions scripts/gen_bcpack_victory_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

Layout is that of the format's constant tables: 128 x 9 u16 model frequencies, the
rank tables, 512 u16 BC7 control words, then 255 dictionary entries per format.
BC7 entries follow VIctory PR #658: after the two index widths, two bytes repeat
them and there are 16 + 15 signed indices, not 32.
BC7 entry 0 stores all 32 signed indices directly after its two index widths; entries
1..254 repeat the two width bytes first and store 16 + 15 signed indices (VIctory PR #658).

python -I scripts/gen_bcpack_victory_tables.py <bcpack-tables.bin> <out.rs>
"""
Expand Down Expand Up @@ -74,12 +74,15 @@ def plain(ep, ix):
ix = [r.i16() for _ in range(16)]
bc6.append((e, mode, ix))
bc7 = []
for _ in range(DICTIONARY):
for entry in range(DICTIONARY):
ctrl = r.u16()
ep = [r.u16() for _ in range(24)]
bits = [r.u8(), r.u8()]
r.u16() # the widths again; not indices
ix = [r.i16() for _ in range(31)] + [0] # set 1 has 15 slots, unused
if entry == 0:
ix = [r.i16() for _ in range(32)]
else:
r.u16() # the widths again; not indices
ix = [r.i16() for _ in range(31)] + [0] # set 1 has 15 slots, unused
bc7.append((ctrl, ep, bits, ix))
assert r.i == len(r.b), (r.i, len(r.b))

Expand Down
Loading