formats: test what every DXGI number stores #123
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/123"
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:08:41Z.
What
formatdecides, and why it was worth a testFor every texture,
formatpicks how many bytes an element is, how many texels a block side holds, and whether there is a stencil plane. 93 of the 121 numbers the Windows SDK defines are grouped by size in onematch:There was no test for any of it. One bound moved by one —
19..=22narrowed to19..=21— changes which formats are given a stencil plane, and a depth format read as having no stencil is a texture allocated half the size it needs. Nothing would have noticed.Three tests, named against the SDK
The format names come from
dxgiformat.h(Windows SDK 10.0.22621.0), so a wrong row is wrong about a number Microsoft names.every_format_group_stores_what_the_sdk_says_it_does— 33 rows covering every group's bounds:R32G32B32A32_SINTR32G32_SINTD32_FLOAT_S8X24_UINTR8G8B8A8_UNORMR24G8_TYPELESSR8G8_TYPELESSR8_TYPELESSR9G9B9E5_SHAREDEXPBC1_UNORM_SRGBBC7_UNORM_SRGBB5G6R5_UNORMB8G8R8A8_UNORMBC6H_TYPELESSthe_formats_it_declines_are_the_ones_it_names— the numbers refused on purpose, so a change that starts answering one has to say why: 96-bit (5..=8, which the comment already excluded),FORCE_UINT(0),R1and the two 4:2:2 YUV formats (66, 68, 69), the 15 video formats (100..=114), the SDK's newer video and sampler-feedback numbers (130..=132, 189..=190), and anything undefined.the_console_only_numbers_are_the_sizes_this_code_assumes— 116..=120, which the Windows SDK does not name at all. They are answered here, so they are console numbers the GDK adds; the test records the sizes this code was written against rather than asserting them against a name, so whoever finds the real ones can correct the row.Checked by mutation, not just by passing
A test that passes on the code as written proves little, so I moved the code under it and re-ran:
Both caught, with the row named in the message. Then restored.
Verification
Windows 11, Rust 1.98.1 (pinned), MSVC 14.44.35207. No game files, no GPU — this crate is pure byte arithmetic.
The 4 ignored need reference data outside the repository (BCPack tables and chunks, XMA streams, a reference decoder). Nothing here changes them.
What this does not say
I did not find a wrong row. I went looking: 5..=8 looked like an oversight until
dxgiformat.hshowed they are the 96-bit formats the comment already excludes; 19..=22 looked shifted until the header showed the four depth-with-stencil numbers really are 19..=22. The mapping is right — it was just unheld.I also looked at the two neighbouring
shortcut:notes in this file (XOR tile modes_X/_Tand MSAA addressing; render-target metadata planes) and left both alone: they say "add them when a title copies into or out of one", and there is no evidence one has, so a patch there would be speculation.victory-formatshas almost no contributions in flight — two of 34 open PRs touch it and both are elsewhere — which is why the unheld table seemed worth picking up.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.