Repository navigation
Formats: console formats 189/190 have texture layouts; rustdoc builds without warnings - #315
SkippySteve wants to merge 73 commits into
Conversation
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.
…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.
…rn Unsupported for addresses
|
Verified Not covered: real console textures in the newly sized XOR/MSAA layouts (no game data here). |
…il planes; unknown ones refuse a texture
d453895 to
4436d7c
Compare
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.
…layouts pack rows and mips
…ytes and fewer blocks are ignored
|
Tested PR #315 at head
Behavior covered: Checks console format texture layouts for formats 189/190 and builds rustdoc for the changed formats and loader crates. |
…over the field and fit
…es, alignment, tail marks)
…cking helpers are pinned
…sions round as addrlib
…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
|
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 ( 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 CI: no check runs on the head commit. Generated by Claude Code |
Two small changes to
victory-formats'texture.rs, plus one rustdoc line invictory-loader. This PR also includes the rustdoc fix from #272, which it replaces.Console formats 189 and 190 have texture layouts
victory-gpu'sresource::elementalready sizes two console-only DXGI formats: 189 (R10G10B10_SNORM_A2_UNORM, 4 bytes) and 190 (R4G4_UNORM, 1 byte).victory_formats::texture::formatdid not list them, soTexture::newreturnedError::Invalidfor any texture in those formats. As a result:resource::footprintfell back to the packed size estimate instead of the console layout's size and alignment.texture.rshad no layout to detile watched textures with.xglayout queries for those formats failed.Changes:
format(): 189 → 4 bytes, 190 → 1 byte, both single-plane and uncompressed.console_formats_have_layouts: pins the element size of each console format, checks that a 256×256SW_64KB_R_Xtexture lays out with that size, and checks that 1-bit and video formats still returnNone.Not changed:
resource::elementalso sizes 191 as 4 bytes ("24/8 color"). DirectXTex lists 191 asA4B4G4R4_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 invictory-gpu.rustdoc builds the formats and loader crates without warnings
cargo doc --no-depsgave two warnings on main:MICROis a private table, so the public module page can't link to it. It is still shown in code font, but without the link.[`prepare()`]. rustdoc now links it to the function instead of having to choose between the function and thepreparemodule.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 warningsis clean.RUSTDOCFLAGS="-D warnings" cargo doc --no-deps -p victory-formats -p victory-loaderpasses.cargo xtask policypasses.cargo fmt --checkshows the same diffs as onmainand none in the lines this PR changes.Also in this PR (folded from #296 and #316)
victory-formatscrate docs anddocs/architecture.mdsay the crate already holds BCPack and XMA2.After the fold,
cargo test -p victory-formatsgives 21 passed and 3 ignored, andRUSTDOCFLAGS="-D warnings" cargo doc --no-deps -p victory-formats -p victory-loaderpasses.Also in this PR: noise tests for textures and XMA
bcpackalready had a seedednoise_never_panicstest.textureandxmahad 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: randomDescs, with each field usually valid and sometimes not, plus edge extents aroundMAX_EXTENT. For each layout it checks thatalignmentis a power of two, that everyoffsetresult plus the element size fits insize, and thatdetile/tilewith random pitches and buffer lengths either succeed or return an error. It also checks that randomTextureDescs produce plane offsets aligned to their plane's alignment and asizethat ends at the last plane. One sample run reached 121 layouts, about 180Okoffsets and about 530Textures.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 everydecode, good or bad, appends exactlyFRAME_SAMPLES × channelssamples. One sample run decoded about 530 frames, about 125 of themOk.Both tests run in about 0.2 s in debug. Neither found a new panic.
After this addition (Linux):
cargo test -p victory-formatsgives 23 passed and 3 ignored.cargo clippy -p victory-formats -p victory-loader --all-targets -- -D warningsis clean,RUSTDOCFLAGS="-D warnings" cargo doc --no-deps -p victory-formats -p victory-loaderpasses, andcargo xtask policypasses.cargo fmt --checkshows no diffs in the new lines; the remaining diffs were already onmain.Also in this PR: BC7 rotation and a BCPack block-stage noise test
The existing
bcpack::tests::noise_never_panicsuses 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.Tables::parseaccepts any BC7 control word. A word for mode 0-3 or 6-7 with rotation bits set gave alpha's precision (0) to red, sobc7_packshifted au16by 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 inbcpack-tables.binis affected, so the shipped tables give the same output as before.decodeis split intolayout(bc), which gives the block size, lane widths and symbols per lane, andunpack, the block stage. The behaviour and error order are unchanged.bcpack::tests::shipped_tables_never_panic: it uses a fixed seed and needs no outside files. It feedsunpackrandom 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 throughdecodewith the shipped tables, and it asserts that both theOkandErrpaths are reached. With the rotation fix reverted it panics (attempt to shift right with overflow). A 20,000-round run with-C overflow-checks=onfound nothing else (about 180kOkand 60kErrcalls).After this addition (Linux):
cargo test -p victory-formatsgives 24 passed and 3 ignored.cargo clippy -p victory-formats -p victory-loader --all-targets -- -D warningsis clean,RUSTDOCFLAGS="-D warnings" cargo doc --no-deps -p victory-formats -p victory-loaderpasses,cargo xtask policypasses, andrustfmt --checkonbcpack.rsis clean.Also in this PR: XMA
decodehung whenbitsran past the dataA longer seeded run outside the repo checked the public APIs: 3M random
TextureDescs withdetile/tileof every plane and mip, 100k BCPack streams, and 200k XMAdecodecalls withbitsup tousize::MAX. Textures and BCPack had no panics or hangs. XMA hung.Decoder::decodeused the caller'sbitsas the frame's end. Reads pastdatareturn zeros. In a stereo tile header of zeros, no channel takes the subframe, so the loop never moves forward, and only reading pastendstops it. A 2-channel decoder givendecode(&[], usize::MAX, ..)(or&[0; 16]with1 << 40bits) looped forever. Mono returned an error. The in-treenoise_never_panicsonly goes 64 bits past the data, so it missed this. Frames fromread_framealways havedata.len() == bits.div_ceil(8)and aren't affected.bits.min(data.len() * 8)(saturating), and the doc comment says so.xma::tests::a_length_past_the_data_ends_at_the_data: mono and stereo, with empty data and with 16 zero bytes, andbitsfar past the end. Each call must returnErrand append exactlyFRAME_SAMPLES × channelssamples. With the cap removed, this test hangs (killed by a 60 s timeout).After this addition (Linux):
cargo test -p victory-formatsgives 25 passed and 3 ignored.cargo clippy -p victory-formats --all-targets -- -D warningsis clean,RUSTDOCFLAGS="-D warnings" cargo doc --no-deps -p victory-formatspasses, andcargo xtask policypasses. A 300k-call rerun of the XMA fuzz with the fix (bitsup tousize::MAX) finished, and every call appended exactly one frame of samples.Also in this PR: BCPack decoding with models at their extremes
Tables::parseaccepts any model frequencies that tile 65536, but every BCPack test decoded with the shipped models (shipped_tables_never_panicreplaces only the ranks, control codes and dictionaries with noise). The new testbcpack::tests::extreme_models_never_panicbuilds 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 bothOkandErroccur. 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-formatsgives 26 passed and 3 ignored.cargo clippy -p victory-formats --all-targets -- -D warningsis clean,RUSTDOCFLAGS="-D warnings" cargo doc --no-deps -p victory-formatspasses,cargo xtask policypasses, andrustfmt --checkonbcpack.rsis clean.Also in this PR:
mips: 0gives the full chainTexture::newwithmips: 0(whatxgandresource::footprintpass 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 testtexture::tests::a_zero_mip_count_is_the_full_chaincovers:MAX_EXTENT) → 15 mips.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-formatsgives 27 passed and 3 ignored.cargo clippy -p victory-formats --all-targets -- -D warningsis clean,RUSTDOCFLAGS="-D warnings" cargo doc --no-deps -p victory-formatspasses,cargo xtask policypasses, andcargo fmt --checkshows no diffs in the new lines.Also in this PR: XMA
Decoderconstruction,resetandflushNew test
xma::tests::reset_flush_and_construction(test-only, hermetic: xorshift noise frames, no files). It checks what theDecoderAPI promises:Decoder::newclamps the channel count: 0 → 1, 6 → 2.u32::MAX.resetafter decoding other frames gives the same output as a new decoder.flushalso resets, so the same decoder can decode the frames again. A secondflushgives only half a frame of silence per channel.cargo test -p victory-formats: 28 passed, 3 ignored.cargo clippy -p victory-formats --all-targets -- -D warningsandcargo xtask policyare clean.cargo fmt --checkshows no diffs in the new lines.Also in this PR: swizzle numbers, and XOR/MSAA layouts
Tests only, in
texture.rs. Nothing tested theError::Unsupportedpath before this.swizzle_numbers_classify: for swizzle numbers 0-63,block_log2isSomeonly for the 16 modes GFX10 has. Any other number givesLayout::new→Invalid. Each tiled mode is exactly one kind (S,D,ZorR),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/_Xmode has the same size, alignment and mips as its non-XOR form. In-rangeoffsetanddetilecalls returnUnsupported, and out-of-range ones still returnInvalid.Z_X/R_Xand 4× MSAA layouts are also not addressable. MSAA layouts with more than one mip, or with 3 or 16 samples, areInvalid.subresource_depthpast the chain is 0.cargo test -p victory-formats: 30 passed, 3 ignored.cargo clippy -p victory-formats --all-targets -- -D warningsandcargo xtask policypass.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, theSmodes and the 64 KiB_Xmodes, and refuses 256 B and plainD. 3DS/Dlayouts 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. 3DZ_X/R_Xare 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, andoffsetat 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 warningsandcargo xtask policypass.cargo fmt --checkshows 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, asdecode'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 warningsandcargo xtask policypass.rustfmt --checkis clean onbcpack.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 and0x7fffare not frames, and 16 is. A frame longer than the buffer, a start past the end and a cut-off header all giveNone.errors_name_the_codec:Error'sDisplayprefixesXMA:.No code changes were needed.
cargo test -p victory-formats: 40 passed, 3 ignored.cargo clippy -p victory-formats --all-targets -- -D warningsandcargo xtask policypass.rustfmt --checkshows 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:Bitsreads MSB first across byte boundaries, sign-extendsn-bit fields from their top bit, reads zeros past the data, and reports an overread only once it has passedend. 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, bothcoef,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:scalestarts at -60, andvec4/vec2count the escape as -1.large_values_take_8_16_24_or_31_bits: the 0, 10, 110 and 111 prefixes offf_wma_get_large_valselect 8, 16, 24 and 31 value bits.log2_samples_and_windows:log2floors and treats 0 as 1.to_i16rounds and saturates, and NaN gives 0. The 128/256/512 sine windows rise strictly and meetw[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 warningsandcargo xtask policypass.rustfmt --checkshows 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:zzmaps 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.interleaveputs its first symbol on the even bits and is one-to-one over all 256 pairs.nibblestakes 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.pickgives zero for 0, a history block for a back reference (a ring ofHISTORY), and the dictionary before the first block.index_sums_and_block_bits:add_indexwraps 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 warningsandcargo xtask policypass.rustfmt --checkshows 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:quadslooks 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).pairswrites 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 type11are errors.010means no transform,001is M/S on every band, and000is followed by one flag per band; bands pastnum_bandskeep 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 warningsandcargo xtask policypass.cargo fmt --checkshows no diffs in the new lines.Also in this PR: XMA tile headers and scale factor bands are pinned
No test called
tile_headerorsubframe_lengthdirectly, and nothing checked the band tablesDecoder::newbuilds. The two new tests use fixed inputs and need no outside files.xma::tests::tile_header_splits_the_frame_into_subframes:subframe_lengthreads0for a whole frame,10for a half and11for 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_lengthmakes the tile test fail.cargo test -p victory-formats: 60 passed, 3 ignored.cargo clippy -p victory-formats --all-targets -- -D warningsandcargo xtask policypass.rustfmt --checkshows 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:0bit. After a1bit 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.scale factor runerror.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 / stepdivision, 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 warningsandcargo xtask policypass.rustfmt --checkshows 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:esc_len-bit run.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.vector coefficientsorrun level coefficientserror.No code changes were needed (one test's indentation was fixed). I checked the test by breaking the code on purpose: dropping the
+ 1from 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 warningsandcargo xtask policypass.rustfmt --checkshows 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 testbcpack::tests::bc7_blocks_follow_the_public_layoutreads 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.ANCHOR2,ANCHOR3A,ANCHOR3Bfor the primary set, pixel 0 for the secondary set), and mode 4 writes its 2-bit set first. The test also checksBC7_INDEXagainst the public index widths.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 warningsandcargo xtask policypass.rustfmt --checkis clean onbcpack.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: