Skip to content

Formats: console formats 189/190 have texture layouts; rustdoc builds without warnings - #315

Closed
SkippySteve wants to merge 73 commits into
Marvisak:mainfrom
SkippySteve:SkippySteve/victory-pr-own-next23
Closed

SkippySteve wants to merge 73 commits into
Marvisak:mainfrom
SkippySteve:SkippySteve/victory-pr-own-next23

Conversation

@SkippySteve

@SkippySteve SkippySteve commented Nov 24, 2026 •

Copy link
Copy Markdown

Two small changes to victory-formats' texture.rs, plus one rustdoc line in victory-loader. This PR also includes the rustdoc fix from #272, which it replaces.

Console formats 189 and 190 have texture layouts

victory-gpu's resource::element already sizes two console-only DXGI formats: 189 (R10G10B10_SNORM_A2_UNORM, 4 bytes) and 190 (R4G4_UNORM, 1 byte). victory_formats::texture::format did not list them, so Texture::new returned Error::Invalid for any texture in those formats. As a result:

  • resource::footprint fell back to the packed size estimate instead of the console layout's size and alignment.
  • texture.rs had no layout to detile watched textures with.
  • xg layout queries for those formats failed.

Changes:

  • format(): 189 → 4 bytes, 190 → 1 byte, both single-plane and uncompressed.
  • Its doc now lists the console's own numbers (116/117, 118-120, 189, 190).
  • New test console_formats_have_layouts: pins the element size of each console format, checks that a 256×256 SW_64KB_R_X texture lays out with that size, and checks that 1-bit and video formats still return None.

Not changed: resource::element also sizes 191 as 4 bytes ("24/8 color"). DirectXTex lists 191 as A4B4G4R4_UNORM, which is 2 bytes. I couldn't confirm the console's meaning, so I left 191 out of this table. It may be worth a look in victory-gpu.

rustdoc builds the formats and loader crates without warnings

cargo doc --no-deps gave two warnings on main:

warning: public documentation for `texture` links to private item `MICRO`
  --> crates/victory-formats/src/texture.rs:16:19
warning: `prepare` is both a function and a module
 --> crates/victory-loader/src/lib.rs:7:10
  • texture.rs: MICRO is a private table, so the public module page can't link to it. It is still shown in code font, but without the link.
  • loader lib.rs: step 1 of the overview refers to the function, so the link is now [`prepare()`]. rustdoc now links it to the function instead of having to choose between the function and the prepare module.

Both are comment-only changes.

Testing (Linux)

  • cargo test -p victory-formats: 21 passed, 3 ignored (they need data from outside the repo).
  • cargo clippy -p victory-formats -p victory-loader --all-targets -- -D warnings is clean.
  • RUSTDOCFLAGS="-D warnings" cargo doc --no-deps -p victory-formats -p victory-loader passes.
  • cargo xtask policy passes.
  • cargo fmt --check shows the same diffs as on main and none in the lines this PR changes.

Also in this PR (folded from #296 and #316)

After the fold, cargo test -p victory-formats gives 21 passed and 3 ignored, and RUSTDOCFLAGS="-D warnings" cargo doc --no-deps -p victory-formats -p victory-loader passes.

Also in this PR: noise tests for textures and XMA

bcpack already had a seeded noise_never_panics test. texture and xma had only fixes found by earlier random-input runs (extents_past_the_hardware_limit_are_invalid, a_zero_length_frame_before_the_start_ends_the_search) and no committed random test that would catch the next such bug. This PR adds one to each module. Both use a fixed seed and need no outside files:

  • texture::tests::noise_never_panics: random Descs, with each field usually valid and sometimes not, plus edge extents around MAX_EXTENT. For each layout it checks that alignment is a power of two, that every offset result plus the element size fits in size, and that detile/tile with random pitches and buffer lengths either succeed or return an error. It also checks that random TextureDescs produce plane offsets aligned to their plane's alignment and a size that ends at the last plane. One sample run reached 121 layouts, about 180 Ok offsets and about 530 Textures.
  • xma::tests::noise_never_panics: random multi-packet buffers, with plausible headers in half of the rounds, are walked frame by frame and decoded in mono and stereo at each sample-rate bucket. Random bits are also decoded directly, including bit counts past the end of the data. The test checks that walks end and that every decode, good or bad, appends exactly FRAME_SAMPLES × channels samples. One sample run decoded about 530 frames, about 125 of them Ok.

Both tests run in about 0.2 s in debug. Neither found a new panic.

After this addition (Linux): cargo test -p victory-formats gives 23 passed and 3 ignored. cargo clippy -p victory-formats -p victory-loader --all-targets -- -D warnings is clean, RUSTDOCFLAGS="-D warnings" cargo doc --no-deps -p victory-formats -p victory-loader passes, and cargo xtask policy passes. cargo fmt --check shows no diffs in the new lines; the remaining diffs were already on main.

Also in this PR: BC7 rotation and a BCPack block-stage noise test

The existing bcpack::tests::noise_never_panics uses the tests' own uniform tables, and random bytes rarely get past the lanes. So the block stage had not been tested with the shipped dictionaries and BC7 control codes, or with a table file that parses but holds bad data.

  • Fix: Tables::parse accepts any BC7 control word. A word for mode 0-3 or 6-7 with rotation bits set gave alpha's precision (0) to red, so bc7_pack shifted a u16 by 16. That panics in debug builds and writes garbage in release builds. Rotation now applies only in modes 4 and 5, as in BC7 itself. None of the 285 control words in bcpack-tables.bin is affected, so the shipped tables give the same output as before.
  • Refactor: decode is split into layout(bc), which gives the block size, lane widths and symbols per lane, and unpack, the block stage. The behaviour and error order are unchanged.
  • Test bcpack::tests::shipped_tables_never_panic: it uses a fixed seed and needs no outside files. It feeds unpack random records that the lanes could produce (each lane's symbols are below 2^(width+1)), with up to 300 blocks so references reach past the 256-block history. It does this for BC1/3/4/5/6/7 with the shipped tables, then with those tables after their ranks, control codes and dictionaries are replaced by noise. It also runs noise streams through decode with the shipped tables, and it asserts that both the Ok and Err paths are reached. With the rotation fix reverted it panics (attempt to shift right with overflow). A 20,000-round run with -C overflow-checks=on found nothing else (about 180k Ok and 60k Err calls).

After this addition (Linux): cargo test -p victory-formats gives 24 passed and 3 ignored. cargo clippy -p victory-formats -p victory-loader --all-targets -- -D warnings is clean, RUSTDOCFLAGS="-D warnings" cargo doc --no-deps -p victory-formats -p victory-loader passes, cargo xtask policy passes, and rustfmt --check on bcpack.rs is clean.

Also in this PR: XMA decode hung when bits ran past the data

A longer seeded run outside the repo checked the public APIs: 3M random TextureDescs with detile/tile of every plane and mip, 100k BCPack streams, and 200k XMA decode calls with bits up to usize::MAX. Textures and BCPack had no panics or hangs. XMA hung.

  • Cause: Decoder::decode used the caller's bits as the frame's end. Reads past data return zeros. In a stereo tile header of zeros, no channel takes the subframe, so the loop never moves forward, and only reading past end stops it. A 2-channel decoder given decode(&[], usize::MAX, ..) (or &[0; 16] with 1 << 40 bits) looped forever. Mono returned an error. The in-tree noise_never_panics only goes 64 bits past the data, so it missed this. Frames from read_frame always have data.len() == bits.div_ceil(8) and aren't affected.
  • Fix: the end is now bits.min(data.len() * 8) (saturating), and the doc comment says so.
  • Test xma::tests::a_length_past_the_data_ends_at_the_data: mono and stereo, with empty data and with 16 zero bytes, and bits far past the end. Each call must return Err and append exactly FRAME_SAMPLES × channels samples. With the cap removed, this test hangs (killed by a 60 s timeout).

After this addition (Linux): cargo test -p victory-formats gives 25 passed and 3 ignored. cargo clippy -p victory-formats --all-targets -- -D warnings is clean, RUSTDOCFLAGS="-D warnings" cargo doc --no-deps -p victory-formats passes, and cargo xtask policy passes. A 300k-call rerun of the XMA fuzz with the fix (bits up to usize::MAX) finished, and every call appended exactly one frame of samples.

Also in this PR: BCPack decoding with models at their extremes

Tables::parse accepts any model frequencies that tile 65536, but every BCPack test decoded with the shipped models (shipped_tables_never_panic replaces only the ranks, control codes and dictionaries with noise). The new test bcpack::tests::extreme_models_never_panic builds tables with a fixed seed and no outside files. In each one, every model either puts nearly all of the range in one bucket (the others get frequency 1), fills buckets greedily from the widest, or splits the range at random. Half the rounds also replace the ranks and dictionaries with noise. It then decodes noise streams with every BC format and asserts that both Ok and Err occur. No code changes were needed. A 400-round version of the same check found nothing with -C overflow-checks=on.

After this addition (Linux): cargo test -p victory-formats gives 26 passed and 3 ignored. cargo clippy -p victory-formats --all-targets -- -D warnings is clean, RUSTDOCFLAGS="-D warnings" cargo doc --no-deps -p victory-formats passes, cargo xtask policy passes, and rustfmt --check on bcpack.rs is clean.

Also in this PR: mips: 0 gives the full chain

Texture::new with mips: 0 (what xg and resource::footprint pass on when a title asks for the full chain) counts mips down to one texel on the largest side. Nothing checked the result. The new test texture::tests::a_zero_mip_count_is_the_full_chain covers:

  • 2D, 1D and linear textures, including non-power-of-two sizes (257×3 → 9 mips, 3×1000 → 10).
  • The array size does not count (4×4 with 1024 slices → 3 mips), but a 3D texture's depth does (64×64×128 → 8).
  • BC1 counts texels, not 4×4 blocks (16×16 → 5 mips, with a last mip of one block).
  • A 16384-wide texture (MAX_EXTENT) → 15 mips.
  • A depth format with stencil (D32_FLOAT_S8X24_UINT) gives both planes the same chain.

Each case also checks that the last mip is one element on every side. No code changes were needed. The test needs no outside files.

After this addition (Linux): cargo test -p victory-formats gives 27 passed and 3 ignored. cargo clippy -p victory-formats --all-targets -- -D warnings is clean, RUSTDOCFLAGS="-D warnings" cargo doc --no-deps -p victory-formats passes, cargo xtask policy passes, and cargo fmt --check shows no diffs in the new lines.

Also in this PR: XMA Decoder construction, reset and flush

New test xma::tests::reset_flush_and_construction (test-only, hermetic: xorshift noise frames, no files). It checks what the Decoder API promises:

  • Decoder::new clamps the channel count: 0 → 1, 6 → 2.
  • Sample rates in the same band decode the same frames identically (≤24000, ≤32000, ≤44100, above). The bands include edge values such as 24001, 44101 and u32::MAX.
  • reset after decoding other frames gives the same output as a new decoder.
  • flush also resets, so the same decoder can decode the frames again. A second flush gives only half a frame of silence per channel.
  • The test asserts that some noise frames decode to non-zero samples, so the comparisons are not comparing silence.

cargo test -p victory-formats: 28 passed, 3 ignored. cargo clippy -p victory-formats --all-targets -- -D warnings and cargo xtask policy are clean. cargo fmt --check shows no diffs in the new lines.

Also in this PR: swizzle numbers, and XOR/MSAA layouts

Tests only, in texture.rs. Nothing tested the Error::Unsupported path before this.

  • swizzle_numbers_classify: for swizzle numbers 0-63, block_log2 is Some only for the 16 modes GFX10 has. Any other number gives Layout::new → Invalid. Each tiled mode is exactly one kind (S, D, Z or R), xor() is true exactly for 16 and up, and a 1×1 texture takes one whole block.
  • xor_and_msaa_layouts_size_but_do_not_address: each _T/_X mode has the same size, alignment and mips as its non-XOR form. In-range offset and detile calls return Unsupported, and out-of-range ones still return Invalid. Z_X/R_X and 4× MSAA layouts are also not addressable. MSAA layouts with more than one mip, or with 3 or 16 samples, are Invalid. subresource_depth past the chain is 0.

cargo test -p victory-formats: 30 passed, 3 ignored. cargo clippy -p victory-formats --all-targets -- -D warnings and cargo xtask policy pass.

Also in this PR: which modes each dimension takes, and linear layouts

Tests only, in texture.rs. They need no outside files.

  • dimensions_take_only_their_modes: for every GFX10 swizzle number, a 1D texture needs a height of 1, and only 2D can be multisampled. 3D accepts only linear, the S modes and the 64 KiB _X modes, and refuses 256 B and plain D. 3D S/D layouts are thick: one block spans several depth slices, the block holds exactly its size in bytes, and a depth of 9 rounds up to whole blocks. 3D Z_X/R_X are thin, with one slice per block. Linear 3D keeps one chain per depth slice.
  • linear_layouts_pack_rows_and_mips: hand-checked pitches, rows, mip offsets and slice sizes for an array, odd extents (placement rounds up, data rounds down), 4×4 BC blocks and a 3D texture. Every row pads to 256 bytes, mips pack smallest first with no gaps and no tail, and offset at each mip's corners in every slice equals slice + mip offset + row × pitch + column.

No code changes were needed. cargo test -p victory-formats: 34 passed, 3 ignored. cargo clippy -p victory-formats --all-targets -- -D warnings and cargo xtask policy pass. cargo fmt --check shows no diffs in the new lines.

Also in this PR: BCPack table checks and stream length

Tests only, in bcpack.rs. They need no outside files.

  • tables_parse_checks_size_and_every_model: a table file one byte short, one byte long or empty is refused as the wrong size. The test covers the first, a middle and the last model of each of the 8 width groups. In each, zeroing any used bucket is an empty-bucket error, and bucket 0 off by one breaks the 65536 tiling. Moving weight from the widest used bucket to bucket 0 still tiles, and buckets past the used ones are never read.
  • trailing_bytes_and_fewer_blocks_are_ignored: the stream has no length field, as decode's doc says. Appending 1, 3 or 1000 bytes doesn't change the output, and asking for 1, 2, 17 or 47 of 48 coded blocks returns the first ones unchanged.

No code changes were needed. cargo test -p victory-formats: 36 passed, 3 ignored. cargo clippy -p victory-formats --all-targets -- -D warnings and cargo xtask policy pass. rustfmt --check is clean on bcpack.rs.

Also in this PR: XMA frame walking across interleaved streams

Tests only, in xma.rs. They need no outside files.

  • frames_skip_other_streams_packets: a five-packet buffer where packets 1 and 3 belong to another stream (skip = 1). A frame that runs off packet 0 continues after packet 2's header, bit for bit, with nothing from packet 1. The frame after packet 2's last frame is found at packet 4's first frame, and the last frame of the last packet has no next frame.
  • a_frame_ending_at_the_packet_end_continues_in_the_next_packet: a frame that fills its packet exactly is followed by the stream's next packet's first frame, even when the header counts more frames. With no next packet there is no next frame.
  • frame_lengths_must_cover_the_field_and_fit: lengths 0 to 15 and 0x7fff are not frames, and 16 is. A frame longer than the buffer, a start past the end and a cut-off header all give None.
  • errors_name_the_codec: Error's Display prefixes XMA: .

No code changes were needed. cargo test -p victory-formats: 40 passed, 3 ignored. cargo clippy -p victory-formats --all-targets -- -D warnings and cargo xtask policy pass. rustfmt --check shows no diffs in the new lines.

Also in this PR: XMA bit reader, Huffman tables and helpers

Tests only, in xma.rs. They need no outside files.

  • bits_read_msb_first_and_zero_past_the_data: Bits reads MSB first across byte boundaries, sign-extends n-bit fields from their top bit, reads zeros past the data, and reports an overread only once it has passed end. Every width from 1 to 32 at every bit offset reads back what was written.
  • huffman_tables_are_complete_prefix_codes: each of the 7 tables (scale, scale_rl, both coef, vec4, vec2, vec1) has one code per entry, left-aligned and in order, and the codes fill the code space exactly, so any 32 bits decode. Each code decodes to its own symbol and uses exactly its length, whatever follows. The symbol offsets are pinned: scale starts at -60, and vec4/vec2 count the escape as -1.
  • large_values_take_8_16_24_or_31_bits: the 0, 10, 110 and 111 prefixes of ff_wma_get_large_val select 8, 16, 24 and 31 value bits.
  • log2_samples_and_windows: log2 floors and treats 0 as 1. to_i16 rounds and saturates, and NaN gives 0. The 128/256/512 sine windows rise strictly and meet w[i]² + w[n-1-i]² = 1.

No code changes were needed. cargo test -p victory-formats: 45 passed, 3 ignored. cargo clippy -p victory-formats --all-targets -- -D warnings and cargo xtask policy pass. rustfmt --check shows no diffs in the new lines.

Also in this PR: BCPack bit helpers and block packing

Tests only, in bcpack.rs. They need no outside files.

  • zigzag_and_interleave_helpers: zz maps 0, 1, 2, 3, 4 to 0, -1, 1, -2, 2 modulo 2^bits and is one-to-one at 5, 6 and 8 bits. interleave puts its first symbol on the even bits and is one-to-one over all 256 pairs. nibbles takes both halves back out, zigzag-decoded, in either order.
  • references_and_picks: the endpoint reference is the index reference plus a zigzag delta, wrapping in a byte, for plain and paired records. pick gives zero for 0, a history block for a back reference (a ring of HISTORY), and the dictionary before the first block.
  • index_sums_and_block_bits: add_index wraps at the residual's width and reads back signed. It scales a reference of another width to that width, and adds nothing for a reference of 0 or more than 16 bits. The 128-bit writer masks each value to its width and drops bits past 128.
  • bc7_and_bc6_mode_details: the p-bit modes are 0, 1, 3, 6 and 7. Only modes 4 and 5 rotate. Channel precisions, with and without rotation, and BC6H index widths for modes 0 to 16 are pinned.
  • bc1_and_bc4_halves_pack_their_codes: line-order indices become BC1 codes 0, 2, 3, 1 and BC4 codes 0, 2..7, 1, at each pixel's bit position. BC4 endpoints are stored 128 above.

No code changes were needed. cargo test -p victory-formats: 50 passed, 3 ignored. cargo clippy -p victory-formats --all-targets -- -D warnings and cargo xtask policy pass. rustfmt --check shows no diffs in the new lines.

Also in this PR: BCPack residual placement and the XMA stereo transform are pinned

Before this, none of these four private helpers was called directly by a test. The new tests are in the existing test modules, use fixed inputs and need no outside files.

  • bcpack::tests::quads_and_pairs_place_index_residuals: quads looks each symbol up in the rank table and writes its four 2-bit values to one 2×2 quad (top-left, top-right, bottom-left, bottom-right, low bits first). pairs writes bits 0-2 and 4-6 of the ranked value to two raster neighbours and ignores the symbol's top two bits. With fewer symbols, both leave the rest of the block alone.
  • xma::tests::channel_transform_reads_the_stereo_group: the bit layout for one stereo group. A leading 1 and type 11 are errors. 010 means no transform, 001 is M/S on every band, and 000 is followed by one flag per band; bands past num_bands keep their old flags. A one-channel subframe reads one bit, and mono reads nothing.
  • xma::tests::inverse_channel_transform_undoes_mid_side: M/S bands become (l - r, l + r), the other bands are scaled by 181/128, and nothing changes past the subframe length, without a transform, or with one channel.

No code changes were needed. I checked the tests by breaking the code on purpose: swapping the M/S output or reading pairs' second value from bit 3 makes them fail. cargo test -p victory-formats: 58 passed, 3 ignored. cargo clippy -p victory-formats --all-targets -- -D warnings and cargo xtask policy pass. cargo fmt --check shows no diffs in the new lines.

Also in this PR: XMA tile headers and scale factor bands are pinned

No test called tile_header or subframe_length directly, and nothing checked the band tables Decoder::new builds. The two new tests use fixed inputs and need no outside files.

  • xma::tests::tile_header_splits_the_frame_into_subframes: subframe_length reads 0 for a whole frame, 10 for a half and 11 for a quarter. It reads nothing for the last quarter. For mono, the test pins the split into quarter/half/quarter and quarter/quarter/half, the "channel longer than a frame" error, and the error for a header that is cut off. For stereo it pins a frame with no fixed bit (one "contains" bit per channel), a fixed frame (no "contains" bits), and an uneven split. In the uneven split, channel 1 takes the whole frame without a "contains" bit because it is the only channel left at offset 0.
  • xma::tests::scale_factor_bands_cover_each_block: for each rate bucket and each of the three block sizes, the bands start at 0, increase in multiples of 4 and end at the block length. Each band maps to itself at its own block size. At the other sizes it maps to the band that holds its midpoint. Lower rates never have fewer bands.

No code changes were needed. I checked the tests by breaking the code on purpose: swapping the half and quarter shift in subframe_length makes the tile test fail. cargo test -p victory-formats: 60 passed, 3 ignored. cargo clippy -p victory-formats --all-targets -- -D warnings and cargo xtask policy pass. rustfmt --check shows no diffs in the new lines.

Also in this PR: XMA scale factors are pinned

No test called scale_factors, which reads each channel's scale factors for a subframe. The new test builds its input from the crate's own Huffman tables and needs no outside files.

  • xma::tests::scale_factors_read_deltas_then_run_level_changes:
    • The first subframe reads a 2-bit step and one delta per band, starting from 45 / step.
    • A later subframe keeps the last set after a 0 bit. After a 1 bit it reads run-level changes: a symbol that skips a band and lowers the next one, the 14-bit escape (level, skip, sign), and a list that ends at the last band without the end symbol.
    • A run past the last band returns the scale factor run error.
    • At a half-length block, each kept band takes the value of the full-frame band that covers its middle (sf_offsets).

No code changes were needed. I checked the test by breaking the code on purpose: flipping the escape's sign bit, dropping the 45 / step division, or always reading band 0 when carrying a set makes it fail. cargo test -p victory-formats: 61 passed, 3 ignored. cargo clippy -p victory-formats --all-targets -- -D warnings and cargo xtask policy pass. rustfmt --check shows no diffs in the new lines.

Also in this PR: XMA coefficients are pinned

No test called coefficients, which reads one channel's spectral coefficients for a subframe. The new test builds its input from the crate's own Huffman tables and needs no outside files.

  • xma::tests::coefficients_read_vectors_then_run_levels:
    • Vector groups of four: a vec4 code, the vec4 escape to two vec2 pairs, the vec2 escape to vec1 values, and vec1's large-value escape (100 + 5). Each nonzero value is followed by a sign bit, where 0 means negative.
    • Without a sent vector count, two zeros in a row at 256 samples switch to run-level coding after that group. With fewer than four vector coefficients, no group is read.
    • Run-level codes from table 0 and table 1 (each with its own runs and levels), the end code, and escapes with no run, a 2-bit run and an esc_len-bit run.
    • A run past the subframe wraps the write (offset & mask, as in FFmpeg) and ends without the end code. A broken escape (three 1 bits) ends the channel's coefficients. Coefficients past the subframe are left alone.
    • Reading past the end returns the vector coefficients or run level coefficients error.

No code changes were needed (one test's indentation was fixed). I checked the test by breaking the code on purpose: dropping the + 1 from the 2-bit run, changing the run-level switch threshold, replacing instead of adding vec1's large value, or clamping instead of wrapping the escape's offset makes it fail. cargo test -p victory-formats: 62 passed, 3 ignored. cargo clippy -p victory-formats --all-targets -- -D warnings and cargo xtask policy pass. rustfmt --check shows no diffs in the new lines.

Also in this PR: BC7 blocks follow the public layout

No test called bc7_pack, which writes each decoded BC7 block. The new test bcpack::tests::bc7_blocks_follow_the_public_layout reads its output back with a small BC7 reader written from the public mode table (subsets, partition, rotation and index-selection bits, colour and alpha widths, endpoint and shared p-bits, index widths). It uses a fixed seed and needs no outside files.

  • It covers all 8 modes, every partition (16 for mode 0, 64 for modes 1-3 and 7), each rotation of modes 4 and 5, and both index selections of mode 4.
  • The reader checks the mode prefix and header fields, then every endpoint in the final channel order: red's low bit is the p-bit, mode 1 shares one p-bit per subset (taken from the subset's first endpoint), and rotation swaps alpha back.
  • Indices read back with one bit fewer at each anchor (ANCHOR2, ANCHOR3A, ANCHOR3B for the primary set, pixel 0 for the secondary set), and mode 4 writes its 2-bit set first. The test also checks BC7_INDEX against the public index widths.
  • Every block uses exactly 128 bits.

No code changes were needed. I checked the test by breaking the code on purpose: taking mode 1's shared p-bit from the second endpoint, writing mode 4's index sets in the other order, dropping mode 5's rotation bits, or not dropping red's p-bit from the endpoint field makes it fail. cargo test -p victory-formats: 67 passed, 3 ignored. cargo clippy -p victory-formats --all-targets -- -D warnings and cargo xtask policy pass. rustfmt --check is clean on bcpack.rs.

Layout edge cases (tests/texture_layout_edges.rs)

These tests use only the public API, and every offset in them was worked out by hand:

  • Linear rows are padded to 256 bytes, and tiling never writes into that padding.
  • A linear volume follows the caller's row and depth pitch, leaves the gaps between them unwritten, and needs exactly the bytes up to the end of its last row.
  • A 5×3 texture in a 4 KiB standard block writes only its own 60 bytes. Its micro-tile x and y bits are pinned.
  • A BC1 5×5 linear chain rounds texels up to whole blocks and places its mips smallest first.
  • For linear, 256B S and 64KB D layouts, copies accept buffers of exactly the right size. They refuse a row pitch, linear buffer or texture buffer that is one byte too small.

SkippySteve added 4 commits November 23, 2026 21:08
The crate's rustdoc listed BCPack and XMA2 as planned and the architecture
table still had BCPack under "planned", though both modules are in the
crate. List the three modules with links, and say where Opus and zlib are
decoded instead (victory-hle, with opus-pure and miniz_oxide).
victory-gpu's element table already sizes the console's
R10G10B10_SNORM_A2_UNORM (189, 4 bytes) and R4G4_UNORM (190, 1 byte),
but texture::format did not know them, so Texture::new refused any
texture in those formats. The GPU then fell back to a packed size
estimate instead of the console layout and had no layout to detile
with, and XG layout queries for them failed.

Add both to the table, list the console numbers in its doc, and pin
every console format's element size and layout in a test.
The format's tables now ship in-tree (Tables::builtin), but the ignored
reference_chunks test still panicked unless VICTORY_BCPACK_TABLES named a
table file. It now uses the built-in tables by default; the variable stays
as an override for comparing another table file. Only VICTORY_BCPACK_CASES
is required.
cargo doc --no-deps warns twice on main for crates that document on any
host:

    warning: public documentation for `texture` links to private item `MICRO`
      --> crates/victory-formats/src/texture.rs:16:19
    warning: `prepare` is both a function and a module
     --> crates/victory-loader/src/lib.rs:7:10

MICRO is a private table, so the public page cannot link to it; it stays
named in code font. In the loader's overview, step 1 means the function,
so the link says prepare() and rustdoc resolves it there instead of
guessing between it and the module.

With both, RUSTDOCFLAGS="-D warnings" cargo doc --no-deps passes for
victory-core, -pe, -loader, -formats, -pipeline, -game and -shader.
Comments only; no code changes.
@SkippySteve SkippySteve changed the title Formats: console formats 189 and 190 have texture layouts Formats: console formats 189/190 have texture layouts; rustdoc builds without warnings Nov 24, 2026
SkippySteve added 7 commits November 23, 2026 21:42
…k/decoder

Seeded, hermetic random-input tests: texture layouts, offsets and
tile/detile copies stay inside their buffers and never panic; XMA packet
walks end and every decode (good or bad frame) appends a whole frame.
…for the block stage

Tables::parse accepts any BC7 control word. A word for modes 0-3 or 6-7
with rotation bits set swapped red's precision with an absent alpha, so
bc7_pack shifted a u16 by 16 (a panic in debug builds, garbage in release).
Rotation now applies only to modes 4 and 5, as in BC7 itself; the shipped
table has no such words, so its output is unchanged.

The block stage is split out of decode (layout + unpack) so a seeded test
can feed it records the lanes can produce, against the shipped tables and
against those tables with ranks, control codes and dictionaries replaced by
noise. The test fails without the rotation fix.
Decoder::decode took the caller's bit count as the frame's end. Reads past
the data give zeros, and a stereo tile header of zeros in which no channel
takes the subframe never advances, so only passing the end stopped it: with
bits past the data (e.g. usize::MAX) decode looped forever. The end is now
capped at the data's length; new test a_length_past_the_data_ends_at_the_data.
…anicking

Tables::parse accepts any model frequencies that tile 65536, but the
tests only decoded with the shipped models. The new seeded test builds
tables whose models put nearly all of the range in one bucket, or split
it at random, and decodes noise streams with them.
…resh decoder's output

A hermetic test on xorshift noise frames: channel counts 0/6 clamp to 1/2,
sample rates within one of the four bands decode identically, reset after
other frames matches a new decoder, flush resets too, and a second flush
gives only silence.
@DaviTostes

Copy link
Copy Markdown

Verified 29e00d3 on Arch Linux x86_64 (rustc 1.98.1, cargo test -p victory-formats): 30 passed, 0 failed, 3 ignored.

Not covered: real console textures in the newly sized XOR/MSAA layouts (no game data here).

@SkippySteve
SkippySteve force-pushed the SkippySteve/victory-pr-own-next23 branch from d453895 to 4436d7c Compare November 24, 2026 03:56
SkippySteve added 3 commits November 23, 2026 23:02
A seeded property test over random addressable layouts (linear and the
non-XOR S/D modes; 1D, 2D arrays and thin/thick 3D; every element size;
BC blocks; up to nine mips): tiling one subresource writes exactly its
elements at Layout::offset and no other byte, detiling reads them back
and leaves the linear padding untouched, and mips outside the tail are
padded, block aligned, disjoint and inside their slice.
@jeremygold02

Copy link
Copy Markdown
Contributor

Tested PR #315 at head 6a15c05c1c8d96f83115c0e8b8cdf4a37f447391 (state at test time: OPEN). Pre-comment refresh: state OPEN, head unchanged at 6a15c05c1c8d96f83115c0e8b8cdf4a37f447391.

  • cargo test --locked -p victory-formats console_formats_have_layouts — passed (ok. 1 passed; 0 failed; 0 ignored; 0 measured; 38 filtered out; finished in 0.00s ); cases: texture::tests::console_formats_have_layouts.
  • cargo doc --locked --no-deps -p victory-formats -p victory-loader — completed successfully.

Behavior covered: Checks console format texture layouts for formats 189/190 and builds rustdoc for the changed formats and loader crates.
Code: crates/victory-formats/src/texture.rs, crates/victory-formats/src/bcpack.rs, crates/victory-loader/src/lib.rs

SkippySteve added 22 commits November 24, 2026 03:46
…ips every subresource in each addressable mode
# Conflicts:
#	crates/victory-formats/src/bcpack.rs
…state on any input

Hermetic tests on synthetic noise frames: every decode appends one frame
of samples, clones and resets match a fresh decoder, bit counts past the
data equal the data's end, sample rates within a bucket and channel
counts above two decode alike, and errors display with the codec name.
…chain; copies check the index first and never write past the texture

Also takes clippy's as_chunks suggestion in one BCPack test, which the
pull-request clippy job from main flags.
…hout touching dst; noise decodes deterministically and ignores trailing bytes
…re the mode; overflowing pitches are too small
… fields and other streams; next stays inside the buffer
…ns follow the largest side; copies check the index before the buffer
…ets and BC6H endpoint modes change nothing; only model frequencies are validated
… sit smallest first after the tail block; the tail holds exactly the mips from first_tail_mip on
…ng samples; gathered frames zero-pad their last byte and keep their length field
…any order or thread and detile in parallel; XMA decoders keep their overlap across threads
…t off; an undecodable frame drops the overlap it inherited
…very addressable mode; slices and thick slabs step by whole slices; whole blocks repeat one pattern that fills each slot once
…ze never shrinks it; array slices and longer chains keep the sizes they share; doubled sides shift the chain by one mip
…back unchanged; 2-byte standard and display textures are byte-identical
…their extra bytes; one subresource writes exactly its footprint inside its plane; the size check covers the whole texture
… or block call for; typed and typeless family members share it; unnamed numbers have no layout
… across interleaved streams decode like the frames themselves, from the start or any seek

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs work: please split. The title describes two small changes, but the PR is now 73 commits and about 10,700 added lines across 36 files. It contains three real fixes that are not in main and look right: the XMA hang (Decoder::decode in xma.rs caps end at data.len() * 8; #183 makes the same change), the BC7 rotation panic (rotation() in bcpack.rs, so only modes 4 and 5 rotate), and layouts for console formats 189 and 190 in texture.rs format(). They are buried under ~30 new integration-test files that pin private helpers to their current output, new public API with no caller (Texture::subresource, footprint, detile, tile, Layout::footprint, Footprint), and an extra allocation per call in bcpack::decode.

At this size it can't really be reviewed. Please split into small PRs: (1) BC7 rotation fix with its regression test, (2) formats 189/190 with console_formats_have_layouts, (3) the XMA cap if #183 does not land. Extra tests and new API can come back separately, each with a stated use.

CI: no check runs on the head commit.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants