Support MSAA tiled texture placement and layout calculations #43
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!43
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-43"
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?
@Lum7nt on GitHub · 2026-11-22 19:59 UTC · original
Lum7nt:gpu-msaa-tiling→main· +585 −41 · 7 files · 2 commits · openSummary
@ivall on GitHub · 2026-11-22 20:27 UTC · original
Thanks for picking up MSAA! I ran it against the console's own layout library before merging.
tests/xg_oracle.rsloads the console'sxg_xs.dll(XCL_SAMPLE_XG, e.g. from a title'sEmbeddedXvd\Windows\System32) and asks it the same questions ashle/xg.rs. The console lays MSAA out quite differently, so I can't merge this as it is.1.
cargo testdoesn't build.Texture::element_offsetgot a fifth argument, but the four calls intests/xg_oracle.rsstill pass four.2. The console only accepts MSAA for render targets / depth. I compared 768 descs: formats 28 / 10 / 2 / 61; sizes 256², 1920×1080, 100×60 and 640×360; 2x / 4x / 8x; arrays of 1 and 6; the library's own mode and six explicit ones; with and without the RT flag. None came out identical. In 672 of them only XCL accepted the desc: the console returns
E_INVALIDARGfor MSAA withoutALLOW_RENDER_TARGET/ALLOW_DEPTH_STENCIL, and for explicit modes.3. Where both accept (render targets), the layout differs. For 256×256 RGBA8 4x, the console gives 3 planes and 0x112000 bytes in total:
This PR gives one plane of a different size (2x: 0x82000 vs the console's 0x92000).
4. Samples are interleaved inside the tile, not stored as one slice each. Texel offsets of the color plane:
The sample index is part of the swizzle equation; addrlib's GFX10 tables have separate
..._Xpatterns per sample count (1xaa / 2xaa / 4xaa / 8xaa). The block's x/y footprint shrinks with the sample count, so "slice × samples" gets neither the offsets nor the padding right.5. In
gpu::texture::placement, an MSAA T#'slast_levelis log2 of the sample count, not a mip count.surfacestill goes intotiling::image_chainwith it, so the chain gets mip levels the image doesn't have.What it would take:
gpu::tiling;XG_RESOURCE_LAYOUT;xg_oracle(an MSAA version oflayouts_match_the_console_libraryand of the texel offset test).Until then,
E_NOTIMPLkeeps XCL on the PC's own allocation info, which is safe. A smaller layout from XCL would make placed resources overlap in thevramarenas.(The
fetch_update→try_updatechange compiles here on 1.96 but isn't needed:mainbuilds without warnings.)@Foniass on GitHub · 2026-11-22 22:47 UTC · original
Tested on RTX 5070 Ti (driver 32.0.16.2114) at
7f727f1, merged ontomain521ec08(clean merge), withcargo test --workspace --release --no-fail-fast -- --test-threads=4and noXCL_SAMPLE_*set. Hardware details are in #42.tests/xg_oracle.rs. Result: 369 passed, 0 failed, 34 ignored (main: 367 / 0 / 34), with no regressions.tiling::tests::every_msaa_pattern_is_a_permutation_of_its_blockruns and passes.verify_console_msaa_offsetsneedsXCL_SAMPLE_XGand returns without running here, so this run doesn't cover the console-layout comparison.fetch_update→try_update: rustc 1.100 does warn onmain(fetch_updateis deprecated,hle/xgameruntime/mod.rs:538), and with this PR the build has no warnings.@Lum7nt on GitHub · 2026-11-23 03:35 UTC · original
Thanks for the thorough review and testing! Commit
7f727f1addresses all points raised:element_offsetcall sites and signatures in tests.ALLOW_RENDER_TARGETorALLOW_DEPTH_STENCIL, or with explicit modes, matching console library behavior.PATTERNS_MSAA), accounting for reduced thin block dimensions and sample bits in the swizzle equation. Verified withevery_msaa_pattern_is_a_permutation_of_its_blockthat all sample layouts form 1-to-1 permutations of the 64KB block.gpu::texture::placement, treated MSAA T#s as single-level (mip 0 only) so the mip chain does not fabricate extra levels fromlast_level(which stores sample count log2).verify_console_msaa_offsetsintests/xg_oracle.rsagainstxg_xs.dll— verified matching plane counts, sizes, alignments, and texel/sample offsets.@ivall on GitHub · 2026-11-23 10:14 UTC · original
Thanks for the second round. I checked
7f727f1against the console's own library again, on Windows with an RX 9070 andXCL_SAMPLE_XG= a retail title'sxg_xs.dll.Good: it builds, and nothing regresses –
layouts_match_the_console_library(29 700 descs: 21 060 identical, 8 640 refused by both),render_target_and_depth_layouts_match(1 872 / 1 872),texel_offsets_…andsubresource_copies_…are as onmain.But
verify_console_msaa_offsetsonly prints the console's layout – it never compares XCL's. A comparison likerender_target_and_depth_layouts_match, with samples set (8 formats: 28 10 2 61 71 40 20 44; 256², 1920×1080, 100×60, 640×360; 2x / 4x / 8x; arrays 1 / 6; layout/flags(0,1) (0,2) (0,0) (0,4) (0x11B,1) (0x118,2) (2,1) (0,3)), 1 536 descs:Texel / sample offsets of plane 0 (
GetTexelElementOffsetBytes, 32 random (x, y, slice, sample) per desc, cases where both accept and the console gives an offset):So colour render targets are close (5 of 6 offsets right, the plane sizes match for the RT cases), but depth MSAA, MSAA UAVs and the metadata plane fields are not there yet. Until they are, XCL's
E_NOTIMPLfor MSAA (the PC's own allocation info) is the safer answer – a wrong size or offset would make placed resources overlap in thevramarenas.What would make it mergeable: the comparison above as a test in
xg_oracle.rs(I can push mine to your branch if you like) passing, i.e. the console's accept / refuse decisions for MSAA UAVs and RT+DS, the depth layouts, and plane 1's fields. Note: the result depends on the library version – one title'sxg_xs.dll(a newer game OS) already differs from XCL in 184 non-MSAA render-target cases (plane 1 +0x10), so please say which one you test against.Also,
fetch_update→try_update: not needed onmainany more (it builds without that warning here).@Lum7nt on GitHub · 2026-11-23 13:22 UTC · original
Yes please, that would be very helpful! Please go ahead and push your comparison test to the branch. Once that's in, we can use it to dial in the MSAA UAV and RT+DS validation rules, depth tiling modes, and plane 1 metadata fields directly against the oracle until the test suite passes cleanly.
@DavidM1911 on GitHub · 2026-11-25 15:22 UTC · original
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.