Formats: test texture layouts against addrlib's own sizes and addresses #1549
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1549
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1549/head"
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?
@venglov on GitHub · 2026-11-24 19:03 UTC · original
venglov:formats/addrlib-reference-layouts→main· +122 −0 · 1 files · 1 commits · merged 2026-11-25 00:18 UTCWhat
victory-formats::texturefollows AMD's addrlib, but its tests only check the layouts against themselves (each element at its own address, copies that round-trip) and a few offsets worked out by hand. This adds two tests that pin the layouts to addrlib's own output (Mesasrc/amd/addrlibated09d38, Navi 21 settings):layouts_match_addrlib: 21 descriptions covering every modeLayout::offsetaddresses (linear, 256 B, 4 KiB and 64 KiBS/D; 1–16-byte elements, BC, arrays, mip tails, 1D/2D/3D). Each has addrlib'ssurfSize, its first tail mip and an FNV-1a hash of the address of every element of every mip and slice.deep_volumes_keep_their_chain_in_each_slabs_tail: 16x16x64, 4 mips, 4-byte elements,SW_64KB_S, with explicit addresses. addrlib puts the whole chain in the tail (mipChainInTail). Each 16-slice slab has its own 64 KiB tail block holding that slab's slices of every mip (mip 0 at +32 KiB, mip 1 at +16 KiB, mip 2 at +4 KiB, mip 3 at +2.5 KiB), and mip 1's 32 slices span two slabs. Size: 4 x 64 KiB.Tests only; no code changes.
mainpasses both.Why now: two open PRs would break 3D layouts
#1450 and #1494 (and #1499, since closed as their duplicate) implement
VIC-BT-014from #1242 ("Thick 3D mip-tail predicate omitsmip_depth(i) <= fixed[2]"). They add a depth check to the tail-entry condition. addrlib has no such check, andmainalready matches it:SW_4KB_S/SW_64KB_S, 1–16 B, every mip count, depth up to 256) that differ from addrlibmain(ffe310e)main+ #1450main+ #1494main+ #1499 (closed)With either of them, 5,087 of those layouts grow, by up to 5x (the audit's own 16x16x64/4-mip example goes from 256 KiB to 768 KiB). The other 369 keep their size but their addresses move, and about 30 M of the 93 M compared addresses move in all. Both new tests fail with that change.
This matters beyond detiling.
resource.rsnotes that the title keeps these sizes in its texture tables, and that its streaming asserts when they disagree with the streamed layout.The audit's falsification claim, that
maingives overlapping offsets for 16x16x64/4 mips, does not hold either. With #1450's extra case added toaddresses_are_a_bijection_and_copies_round_tripandmain's layout code, that test passes. Only the tests asserting the new tail position fail.How the reference values were made
addrlib builds standalone with clang (it's MIT-licensed, the same code
texture.rscites). A small driver callsAddr2ComputeSurfaceInfoandAddr2ComputeSurfaceAddrFromCoordfor each description. The same pinned values come out with four differentGB_ADDR_CONFIGvalues (0x444,0x0,0x342,0x4c4), so they don't depend on the console's pipe configuration (no XOR modes are pinned).Driver source and build (no game data involved)
(
-DHAVE_TSERVERonly skips an Apple-only header include.)Wider sweep (not committed)
Besides the pinned cases I compared
Layoutwith addrlib on about 20,000 random and exhaustive descriptions: sizes, alignment, block dimensions, first tail mip, and the addresses of sampled elements (every element along a side of 40 or fewer; edges, powers of two and spread points past that). Every 2D and 3D description in the non-XOR modes matches exactly. (Linear has no mip tail in addrlib, so there only size, alignment and addresses are compared.) The only difference I found: on GFX10, addrlib refuses tiled 1D textures (ADDR_INVALIDPARAMS; 1D must be linear), whileLayout::newaccepts them.texture_layoutonly gives 1D textures a tiled mode when the title asks for one explicitly, so I've left that alone.Verification
cargo test -p victory-formats: 25 passed, 0 failed (4 ignored, as before)cargo clippy -p victory-formats --all-targets --locked -- -D warnings: cleancargo xtask policy: 154 files okcargo fmt --checkalready reports older lines in this file onmain; I didn't touch them.)AI-assisted (Claude Code): the addrlib harness, the sweeps and this write-up. The numbers come from running both implementations.
🤖 Generated with Claude Code
@ArnabSaga on GitHub · 2026-11-24 19:11 UTC · original
Thanks for the comprehensive reference-based verification.
I independently investigated VIC-BT-014 using addrlib v10.9 and reached the same conclusion. My verification covered 33 descriptors, 140 mip metadata rows, and 18,720 exact element-address comparisons.
I've documented the results on #1450 and prepared a reproducible verification package.
Your broader differential testing provides valuable independent corroboration. I support preserving the existing mip-tail predicate and adding reference-compatible regression coverage.
@tdogghockey on GitHub · 2026-11-24 19:23 UTC · original
I independently verified this test-only PR at head
f078008on aarch64 Linux.cargo test --offline -p victory-formats --locked texture::tests::layouts_match_addrlib— 1 passedcargo test --offline -p victory-formats --locked deep_volumes_keep_their_chain_in_each_slabs_tail— 1 passedcargo test --offline -p victory-formats --locked— 25 passed, 0 failed, 4 ignoredcargo clippy --offline -p victory-formats --all-targets --locked -- -D warnings— cleanrustfmt --edition 2024 --check crates/victory-formats/src/texture.rsreports the same 10 pre-existing diff hunks as baseffe310e; none is in the added test region.Coordination note: one case pins
16x16x64,SW_64KB_S, 4 byte elements tofirst_tail_mip = 0andsize = 262144. PR #1450 states that addrlib-derived fix makes the same case enter the tail at mip 2. I could not run addrlib here, so I am not asserting which expectation is correct. If both PRs land, their expectations for this case look incompatible and should be reconciled.Scope note: host-independent tests only; no Windows/GPU/CI verification. No approval implied.
@catminou4 on GitHub · 2026-11-24 19:25 UTC · original
Correction to my earlier review: re-ran
cargo test -p victory-formats --lockedon the PR head merged into main — 25 passed, 0 failed (+2 tests,deep_volumes_keep_their_chain_in_each_slabs_tailandlayouts_match_addrlibboth run and pass). The "23 passed" figure I quoted was from a batch run that raced with another cargo process on the same checkout; the verdict is unchanged.@fiestorra on GitHub · 2026-11-24 21:06 UTC · original
Your prediction was right, and here is the measure of it
You wrote: "Why now: two open PRs would break 3D layouts — #1450 and #1494". On a tree with both your pull request and #1450 (
forge/main: #1450 isc3b045f, this one is78bcd64),layouts_match_addrlibanddeep_volumes_keep_their_chain_in_each_slabs_tailboth fail. Reverting #1450's merge makes them pass, so the two tests are doing their job.I printed every description that disagrees rather than stopping at the first; four of your 21 do, all
Tex3d:Tex3d 4x4x16, 5 mips, 4 B,SW_4KB_STex3d 1x1x17, 2 mips, 1 B,SW_4KB_STex3d 16x16x64, 4 mips, 4 B,SW_64KB_STex3d 8x8x128, 4 mips, 1 B,SW_64KB_SThe other 17 (1D, 2D, and the wide 3D cases) still match, so #1450 only moves the deep narrow volumes — which is what it says it does. The 16x16x64 row is the case it was written for, and addrlib's answer is the structure your other test spells out element by element (whole chain in the tail at mip 0, one 64 KiB tail block per 16-slice slab, mip 1 spanning two slabs).
I have put the four cases and that reading on #1450, since they are the regression set that decides it. What this pull request does not do — fairly, because you said "tests only; no code changes" — is say which of the two structures is authoritative for the runtime; if addrlib is, as
texture.rsalready follows it, the overlap fix in #1450 needs to be expressed inside the slab layout rather than by moving the tail threshold.One thing that would make this kind of clash cheap to catch for everyone: the integration train runs
cargo check, notcargo test, so two pull requests that contradict each other both land in it silently. Your tests are the reason this one did not stay silent past the merge.No game data is involved: sizes and offsets only.
Written with an AI assistant.