Support MSAA tiled texture placement and layout calculations #42
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from ivall/xcl. Originally posted by Lum7nt on 2026-11-22T19:59:20Z.
Summary
precise, and thes_round_modeNOOPs are not free #72Imported from ivall/xcl. Originally posted by ivall on 2026-11-22T20:27:13Z.
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.)Imported from ivall/xcl. Originally posted by Foniass on 2026-11-22T22:47:09Z.
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.Imported from ivall/xcl. Originally posted by Lum7nt on 2026-11-23T03:35:42Z.
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.Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T10:14:18Z.
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).Imported from ivall/xcl. Originally posted by Lum7nt on 2026-11-23T13:22:05Z.
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.
mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #172mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #172d32s8_targets_take_their_own_size_of_video_memoryon adapters with under 8 GB of dedicated video memory. Fixes #42. #1080Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T15:22:22Z.
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.Imported from ivall/xcl. Originally posted by gut0to on 2026-11-26T16:46:34Z.
Code review location:
crates/xcl/tests/xg_oracle.rs; line 623AI-assisted review (OpenAI GPT-6); I inspected the test paths; I did not run tests or the game.
This oracle test creates a 4x MSAA texture and reads its resource layout, but it only prints the returned values and never queries GetTexelOffset. The new pattern test checks that each block is a permutation, which would still pass if sample indices were mapped to the wrong locations. Could this oracle assert a few (x, y, sample) offsets and the relevant plane size against the console XG result so the sample ordering has a stable regression check?
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-12-01T02:35:25Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T02:59:34Z.
Triage (#1607) – head
7f727f1No open or merged PR makes the same MSAA tiling change.
Problems in the diff:
gpu/texture.rs: placementsetssurface.last_level = 0for MSAA and then callstiling::image_chain(&surface, …), which takes the sample count fromt.last_level(1 << last_level). Every MSAA texture is therefore laid out and sized as 1 sample: an explicit "not yet (MSAA)" error becomes an allocation that is too small by the sample count. Nothing testsplacementwith an MSAA T#.hle/xgameruntime/mod.rschangesfetch_updatetotry_updateinXUserCloseHandle, which has nothing to do with MSAA.verify_console_msaa_offsetsonly prints the console layout and asserts nothing about it, so the XG MSAA sizes and the new FMASK plane are not checked against the console.Recommendation: close (bad: MSAA placement always uses 1 sample).
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.