xg_x: calculate HTILE plane for single-mip depth-bind textures and write correct plane usages #119
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
library
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/omonkeyz--xbox-emulator!119
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/119/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?
@adriaespii on GitHub · 2026-11-22 12:40 UTC · original
adriaespii:contrib/xg-x-htile-plane→main· +203 −24 · 3 files · 104 commits · closed without mergingSummary
This PR implements HTILE plane calculation and correct plane usage serialization for depth-bind textures in
xg_x, resolving the depth buffer allocation size mismatch identified indocs/BLOCKERS.md:244.Context & Problem
In
docs/BLOCKERS.md:244:Before this fix:
compute_withomitted the HTILE metadata plane when calculating depth layouts, resulting in depth buffers allocated by games (like Trackmania) falling short of console sizes.write_layout, plane count and usages were hardcoded to video planar layouts (0x14 = 2,0x18 = 5,0x5e0 = 6), whereas console encodes each plane's usage at0x18 + i * PLANE_PITCH(4 for HTILE, 7 for Depth, 8 for Stencil).Key Changes
crates/compat/xg_x/src/layout.rs):pub fn htile_plane(d: &Desc) -> Plane:align(pitch, 128) * align(height, 64) / 16).align(pitch, 512) * align(height, 512) / 16).0x4000blocks, with 2 KiB (0x800) base plane alignment and bpe 0.compute_depthandcompute_depth_msaa:0x140c000(exact console match; previously was0x13ec000).DXGI_FORMAT_D32_FLOAT, fmt 55 /DXGI_FORMAT_D16_UNORM) as 2-plane layouts (HTILE + Depth).write_layout:usage: u32toPlane.0x18 + i * PLANE_PITCH(matching offset0x18for plane 0,0x5e0for plane 1,0xba8for plane 2), correctly setting plane counts at0x14.XGCreateTextureComputerWithPitch(crates/compat/xg_x/src/lib.rs):BIND_DEPTH_STENCIL(flags & 2 != 0) and depth formats throughlayout::compute_depth.crates/compat/xg_x/src/layout_oracle_tests.rs):compute_depth_trackmania_matches_console_exact: verifies exact0x140c000layout, plane offsets, alignments, and serialized buffer layout.compute_depth_array_uses_512_tiling_rule: verifies 512x512 tile HTILE rule on array depth buffers.compute_depth_plain_formats: verifies 2-plane HTILE+Depth layouts for fmt 40 and fmt 55.depth_bind_planar_msaa_planes_match_consoleto compare direct 3-plane layouts against console oracle.Verification
cargo check -p xg_x: Clean compilation (0 errors).cargo test -p xg_x --lib compute_depth: 4/4 passed.cargo test -p xg_x --lib -- --skip oracle --skip console --skip built_dll: 11/11 passed.@omonkeyz on GitHub · 2026-11-22 13:13 UTC · original
Main's history was rewritten, which auto-closed this PR (sorry for the noise). A maintainer is checking this against the xg_x console oracle. No action needed for now. We will apply it with your authorship or comment with the exact change.
Pull request closed