formats: a multisampled linear layout said it was addressable #125
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/125"
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:13:10Z.
The bug
Layout::newdecides whether to build a tile pattern with one test:addressable(), the method callers ask instead, tested something else:For a linear layout with more than one sample those disagree.
Layout::newclears the pattern (samples != 1), but the method's first clause is true forLINEARalone, so it answers yes — andoffsetthen takes its linear branch:There is no sample dimension anywhere in that expression. A multisampled texture asked for an address got a wrong one instead of the
Unsupportedtheshortcut:note right above promises ("no addressing for the XOR modes and MSAA"). A copy built on that address reads the wrong bytes — silently.The fix
One line, so the method uses the test
Layout::newuses:The tests, and how they were checked
only_the_modes_without_pipe_xor_are_addressable— all 15 swizzle modes GFX10 has, at one sample: the 7 without pipe XOR addressable, the 8_T/_Xones not.Swizzle::xorisself.0 >= 16and every constant at or above 16 is named_Tor_X, so this pins both the predicate and the naming against each other.multisampling_is_unaddressable_even_without_pipe_xor— the case that found the bug:LINEARandSW_64KB_Sat 4 samples, both of which used to answer yes.a_swizzle_gfx10_does_not_have_is_refused— the other end: numbersblock_log2does not know (3, 4, 7, 8, 11, 16, 20, 28, 100) have no layout at all, soaddressableis never reached with an accidentally empty pattern.Checked by reverting the fix:
Before this PR,
addressable()had one assertion in the whole crate — inside an unrelated depth-stencil test, onSW_64KB_Z_X.Verification
Windows 11, Rust 1.98.1 (pinned), MSVC 14.44.35207. No game files, no GPU — this crate is byte arithmetic.
Two things I looked at and left alone
The 4 ignored tests. I checked whether any could be made self-contained.
matches_a_reference_decodercompares SNR against a real decoder's PCM output — no synthetic stream substitutes for that.walks_saved_streamsandreference_chunksneed real captures and reference chunks. They stay ignored.The neighbouring
shortcut:notes — XOR tile modes (_X,_T) and render-target metadata planes — both still say "add them when a title copies into or out of one", and there is no evidence one has. A patch there would be speculation.Does this change behaviour for the title?
Only where it was already wrong: a multisampled linear layout, asked for an address, now returns
Unsupportedinstead of a wrong offset. Multisampled textures are render targets the host draws, and the note in the code says titles do not copy into or out of them — which is exactly why this went unnoticed, and also why the fix is safe.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.