fix(agc): place the HTILE of a mipmapped depth view #26035
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/26035"
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 boykopovar/AnyPS5. Originally posted by birdmarty on 2026-11-23T04:53:44Z.
What
A depth target with mip levels and HTILE threw
HTILE for the depth view mip N of M ... is unsupported:decodeDepthPlaneaccepted mipmapped depth views only without HTILE, because it had no place for each level's HTILE.AMD PAL's gfx10 addrlib (
Gfx10Lib::HwlComputeHtileInfo,src/core/imported/addrlib/src/gfx10/gfx10addrlib.cpp) gives that place for SW_64KB_Z_X: with more than one mip, the levels' HTILE starts with one meta block for the mip tail, when there is one, then the levels outside the tail follow from the smallest to mip 0, each its extent at that level rounded up (GetMipSize,ShiftCeil) and aligned to the meta block, in meta blocks; a slice is the whole chain. The PS5's meta block is 1024x512 pixels and 32 KiB, asHtileMetadataBytesalready assumes.A mipmapped depth view now gets its HTILE address by that rule, and slices step by the whole chain's HTILE. A view of a level in the mip tail stays refused (its depth already is). The code that uses a target's HTILE sizes it from the target's extent (
HtileMetadataBytes(target.extent)), and a view's extent is its level's logical size, rounded down. When the rounded-up size needs more meta blocks than that, as mip 1 of a 2049x1024 surface does (1025x512, two blocks, against 1024x512, one), the view is refused instead of being tracked one meta block short.Changes
core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp:decodeDepthPlaneplaces a mipmapped view's HTILE.core/libs/prx/libSceAgcDriver/tests/Graphics.cpp(agc_driver_graphics): the case that expected the refusal now checks the HTILE address. For a 1024x1024 D16 chain of three levels, mip 1 is at base + 0x8000, mip 0 at base + 0x10000, and slice 1 steps by 0x20000. For a 1536x1536 D32 chain of five levels, as the game below uses, mip 0 is at base + 0x28000 and mip 1 at base + 0x18000. For a 2049x1024 D32 chain of two levels, mip 0 is at base + 0x10000 (after mip 1's two meta blocks), slice 1 steps by 0x40000, and a view of mip 1 is refused. The values were worked out by hand from the rule above. A level in the mip tail still refuses.docs/dev/debt/changes/fix-agc-htile-mipmapped-depth-view.md: a new entry. It also records the refused views whose rounded-up extent needs more HTILE than their own. The offsets are not measured on the console, and the HTILE inside a level is taken to be laid out like a surface of that level's extent (addrlib'sHwlComputeHtileAddrFromCoordreturnsADDR_NOTIMPLEMENTEDfor more than one mip).Tested
Windows 11 Pro (build 26300), Intel Core i9-9900K, AMD Radeon RX 6800 (AMD driver 26.10.1, Windows driver 32.0.21045.16010, Vulkan 1.4.315), MinGW-w64 GCC 15.3.0, Release,
main03a717f38e.Focused set (
agc_driver_graphics,agc_shader_memory,agc_driver_recorder,agc_driver_native_*,agc_driver_depth*,agc_driver_htile*,agc_driver_stencil*,agc_driver_dispatch*,agc_driver_*fill*,agc_driver_layered*,agc_driver_sampled_cache*) withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(1.4.363) andVK_LOADER_DEBUG=layer:main03a717f38ef13719ce15)VUID-linesWithout the fix (
main'sState.cppwith this branch's test),agc_driver_graphicsfails withAGC graphics: HTILE for the depth view mip 1 of 3 at 1024x1024 (DB_Z_INFO 0xa0020181, DB_DEPTH_VIEW 0x04000000) is unsupported. With 153ce1cbbc'sState.cpp, which rounded each level down, it fails withthe HTILE of view mip 0 of a 2049x1024 two-mip D32 chain is not after the two meta blocks of mip 1, whose rounded-up extent is 1025x512.Forza Horizon 5 (PPSA22327 01.685.672), local stack of open PRs:
DB_Z_INFO 0xa0040183), at mip 0.153ce1cbbc, none with it. All five ran past the point where it stopped, to a later, unrelated freeze.f13719ce15changes nothing for this target (every level of 1536x1536 is a whole number of pixels, so rounding up and down agree) and was not run in the game.py -3 tools/check_conventions.py --base origin/mainandpy -3 tools/debt_fold.py --checkpass.py -3 tools/pr_overlap.py --branch fix/agc-htile-mipmapped-depth-view(2,503 open PRs): all 51 mergeable PRs that share files merge cleanly except #21948, which sizes HTILE that is not pipe-aligned (TargetHtileBytes) on the same slice line, and #24083, which names the depth slice pitch in the same mip block; neither places the HTILE of a mip. Whichever merges second keeps both. The 34 PRs that conflict withmainwere searched by hand; #6808 and #7256 touch HTILE elsewhere, and none places mip HTILE.Not tested: the console's HTILE offsets for mip levels (taken from addrlib, not measured), HTILE that is not pipe-aligned with mips, other GPUs, Linux.
Related
Part of the Forza Horizon 5 (PPSA22327) bring-up, #25152. It was found on the stack of open PRs the game needs (#24960, #24994, #25151, #23688, #23545, #21479, #11825, #23778, #21155, #22306, #21199 and #25867–#25874) and stands alone: it applies to
mainby itself and needs none of them to build or pass its tests.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)mainand this change, 0 VUIDs🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T04:56:41Z.
Review: APPROVED
Reviewed — looks good
The reviewed change computes mipmapped HTILE addresses using the described block sizes and slice stride; downstream depth handling accepts these targets, though its per-view metadata sizing warrants follow-up.
What I ran
Reviewed head
153ce1cbbc085168d2604eb056b72f418b56ce4ausing the pinnedrepo_read.pyreader. No tests or builds were run.Results
Findings
Blocking
None.
Non-blocking
core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp:566-567computes the mip’s HTILE address, but the resultingDepthTargetcarries no metadata size. Existing consumers size, inspect, and claim HTILE usingHtileMetadataBytes(target.extent); for a mip target this is only that mip’s extent, while offsets for later mips and slices use the whole chain. Consider carrying the applicable HTILE range size with the target so bookkeeping follows the decoded layout. This was not verified to cause incorrect behavior in a runtime scenario.Not verified
Graphics.cppfile was excluded by the review-folder size rule; its changed lines were read through the reader.State.cppand the new debt note were read. No other changed files were excluded.To get this to a good state
Nothing is required. The metadata-range sizing point above is optional follow-up.
Imported from boykopovar/AnyPS5. Originally posted by mihiii1337 on 2026-11-23T07:07:08Z.
Review: CHANGES_REQUESTED
Reviewed exact head
153ce1cbbc085168d2604eb056b72f418b56ce4a. The new chain layout floors each mip's dimensions before calculating HTILE bytes:That differs from the PAL routine this PR uses as its layout source.
Gfx10Lib::HwlComputeHtileInfocallsGetMipSizefor every non-tail mip, andGetMipSizeusesShiftCeilfor width and height before aligning them to the HTILE meta block (PAL source at pinnedc5e8000, ceil helper).A concrete non-tail case is a 2049×1024 D32 surface with two mip levels. PAL sizes mip 1 as 1025×512, which occupies
0x10000HTILE bytes. This head uses 1024×512 and only0x8000, so it places mip 0 at HTILE base +0x8000instead of +0x10000; the whole-slice stride is0x38000instead of0x40000. The selected mip's downstreamHtileMetadataBytes(target.extent)uses the same logical/floored extent, so memory claims and HTILE read/write ranges can also be one metadata block short.Please derive each HTILE mip allocation and the slice stride with the same ceil-reduced dimensions as PAL, and carry the selected mip's allocation size to consumers (or conservatively keep these odd extents refused until that size is represented). Add a regression around an odd meta-block boundary such as 2049×1024.
I compared the exact changed source with the pinned PAL implementation and reproduced the offsets/slice sizes in CPU arithmetic controls, including even-size controls.
git diff --checkand merge probes were clean; hosted CI is terminal with 7 successes and 7 expected skips, and the published GPU matrices use even extents. I did not run a local project build, CTest, or GPU workload.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by mihiii1337 on 2026-11-23T08:32:25Z.
Review: APPROVED
Re-reviewed fix head
f13719ce157a3ec05bacfb32b69e874cd0985040. This resolves my PALShiftCeil/mip-placement finding.A CPU-only witness using the exact old/new placement loops and
HtileMetadataBytesreproduced the 2049×1024 case: old mip-0 offset/slice stride were0x8000/0x38000; this head produces0x10000/0x40000, matching the pinned PAL calculation. For selected mip 1, floor/ceil metadata requirements are0x8000/0x10000, and this head refuses the inconsistent logical view with the expected diagnostic rather than silently binding too little metadata. Even-dimension controls (2048×1024, 1024² and 1536²) are unchanged.The head's ceil expression also matched PAL
ShiftCeilfor all 262,144 tested one-axis width/mip pairs (widths 1..16384, mips 0..15); mip-tail membership already uses the corresponding ceil layout. Merge preview, diff, conventions and debt-fold are clean.The author reports exact-head AMD results of 151/151 tests on both base and change with 213 validation-layer insertions and 0 VUIDs. I did not run a local GPU or full CTest suite. Hosted intake/portability/report checks are green; the replacement Windows/conventions/labels jobs are queued and remain watched.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T08:37:45Z.
Review: COMMENTED
Reviewed — comments
The HTILE mip placement is supported by focused tests and targeted code inspection, but its layout is inferred from AMD addrlib rather than confirmed on console, so a formal approval is not justified.
What I ran
Reviewed head
f13719ce157a3ec05bacfb32b69e874cd0985040. No commands or tests were run in this review; the description reports author-run tests and console runs, which I did not independently verify.Results
Findings
Blocking
None.
Non-blocking
Not verified
core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp,core/libs/prx/libSceAgcDriver/tests/Graphics.cpparound the changed tests, anddocs/dev/debt/changes/fix-agc-htile-mipmapped-depth-view.md. The fullGraphics.cppwas excluded from the prepared review folder due to size, so only the targeted head range was read. No other changed files were excluded.To get this to a good state
Nothing is required. Optional: confirm the inferred HTILE placement against console behavior.