formats: the full mip chain and the stencil plane, held at their limits #131
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/131"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Zettrox/ztrx. Originally posted by xiaotu030202 on 2026-11-25T13:21:58Z.
Two pairs of values that have to agree, and nothing checked
The chain length against
MAX_MIPSTexture::newcomputes amips = 0description's chain as:and
Layout::newthen requires1..=16. Two separate expressions of the same limit — raiseMAX_EXTENT, or make the chain one longer, and a description that used to lay out becomesInvalidwith nothing pointing at the pair.a_full_mip_chain_fits_the_limit_at_every_extentchecks the extents that decide it:MAX_EXTENT×1MAX_EXTENTMAX_EXTENT×MAX_EXTENTIt also pins the other end: an extent of zero is refused. The
max(1)is for the mip count, not for the size, and it is easy to read the other way — I did, going in, and the test corrected me.The stencil plane's block against the colour format's
Texture::newbuilds the stencilDescaselement_bytes: 1, block: f.block— it keeps the colour format's block:That is right only because no format in
format()is both stencilled and block-compressed. Nothing states it. A BC format gaining a stencil bit would give the stencil plane a 4-texel block and a quarter of the size it needs — silently, since nothing would fail.a_stencil_plane_is_one_byte_and_never_block_compressedscans every numberformat()answers for 0..=200, asserts the two sets do not meet, and then checks a real depth-stencil texture's second plane is one byte with block 1.Both checked by mutation
Verification
Windows 11, Rust 1.98.1 (pinned), MSVC 14.44.35207. No game files, no GPU.
What I found, and did not
No bug. Both pairs currently agree; these tests make them agree on record, so the next change to either side has to notice the other.
The zero-extent case is the one thing I had wrong: I wrote the test expecting
0x0to lay out one mip because of themax(1), and it is refused — the right answer, and now stated.Three PRs in this file now, each reviewable alone:
addressable()answering wrongly for multisampled linear layouts (a real bug)walkstaying inside the buffers it is givenIf that is too many for one file, they can be squashed — but they fail independently, which is why I kept them apart.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.