fix(libSceAgcDriver): size a PS4 depth target's HTILE in 512x512 blocks #10435
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10435"
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 ntamas94 on 2026-10-24T00:14:10Z.
What
A PS4 depth target's HTILE spans 16 KiB per 512x512 pixel block.
HtileMetadataBytesgave every target the PS5 size, 32 KiB per 1024x512 block. The two agree only when the width is a multiple of 1024. For a 512x512 target the PS5 size is twice the real one.Gang Beasts (CUSA04865, Unity) clears each 512x512 spot-light shadow map by filling 16 KiB of its HTILE with zero, using the compact pattern fill kernel. Measured against 32 KiB:
The shadow casters then drew over the previous frames' depth, and on the elevator stage the shadows of earlier frames stayed on the floor and the back wall. The 4096x4096 directional shadow map (1 MiB fill) and the 2048x1152 camera depth (0x30000-byte fill) were cleared, because both sizes agree for those widths.
While PS4 (GCN) shaders run,
HtileMetadataBytesnow uses the PS4 block, asDecodeStatealready does for the depth extent. The HTILE fill coverage check, the bind-time HTILE read and the HTILE slice step all go through it. PS5 targets are unchanged. The 512x512 block is the macro tile addrlib's CIComputeTileDataWidthAndHeightgives for 32-bit HTILE words, 16384 cache bits and the 8 pipes ofP8_32x32_16x16, the pipe configuration the PS4 tiling code here already assumes. The HTILE debt entry says so.Tested
Windows 11 Pro (10.0.26200), WinLibs GCC, NVIDIA GeForce RTX 2080 (driver 617.14), Release build with
BUILD_TESTING=ON, on this branch (ps4/agc-gcnat26d651d3eplus this commit):agc_driver_graphicsnow checks the PS4 HTILE size for 512x512, 256x256, 2048x1152 and 4096x4096 targets, and that a 16 KiB fill covers a 512x512 PS4 target's HTILE while a shorter one does not. It passes; withDepthSurface.cppreverted to the base it fails (a PS4 HTILE is 16 KiB per 512x512 block).The depth execution tests pass:
depth_bias_per_face,depth_bits_guest_memory,depth_clear_hle,depth_compare_copy,depth_fast_clear,depth_fast_clear_submit,depth_htile_write,depth_plane_buffer_memory,depth_plane_fill,depth_plane_guest_layers,depth_plane_partial_store,depth_plane_sampling,depth_range_remap_draw,depth_storage,depth_storage_dispatch,depth_storage_reuse,depth_surface_from_storage,depth_surface_last_writer,gcn_detile,native_depth_bda_clear,native_multisample_depth,native_depth_retirement,native_depth_clears,native_depth_clear_refusals,pattern_buffer_fill,sample_mask_depth_stencil,stencil_replay,stencil_replay_no_gpl.Gang Beasts, with the equivalent change (the PS4 size chosen per depth target) on my bring-up branch (#7941): on the elevator stage the shadows follow the characters and no longer stay behind. A trace of that stage showed that before the change, the two 512x512 spot shadow maps got no clear in 2.5 s while the 4096x4096 map got one each frame.
tools/check_conventions.py --base refs/pr/9431with this title and description: no findings.Paired validation-layer run of the 30 tests above, on the base (
26d651d3e) and this branch, withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1andVK_LOADER_DEBUG=warn,error,ctest -V, on the NVIDIA GeForce RTX 2080, driver 617.14, Windows 11 (10.0.26200), Vulkan SDK 1.4.363.0. Both logs carry the loader'sadding layers "VK_LAYER_KHRONOS_validation"line and neither reportswas not found but was requested by env var VK_INSTANCE_LAYERS.VUID-ids on the base: 0; on this branch: 0; new on this branch: 0. The base run covered 24 of the 30 tests, including the failingagc_driver_graphics; this branch ran all 30.After merging current
maininto this branch (cedf987d5, to resolve the conflicts it inherited from #9431 inDepthSurface.cppandGuestTextureResource.hpp): the same validation-layer run passes 31 of 31 tests (the 31st,depth_storage_reuse_draw_pipeline, comes frommain),VUID-ids: 0;check_conventions.py --base origin/main: no findings.2026-10-29, head
41c0489401onmain66405c3250after #9431 landed: 40 depth,gcn_detileandpattern_buffer_filltests with the validation layer, three runs on the head and one on the base, 0VUID-ids; details in the review reply.Checklist
main; no other open PR implements the same functions (merged withmain66405c3250after #9431 landed; searched open boykopovar/AnyPS5 PRs for HTILE size,HtileMetadataBytesand PS4 HTILE on 2026-10-24)NotImplemented_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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T22:01:44Z.
Review: CHANGES_REQUESTED
Reviewed exact head
cedf987d5ba4ee2f0c4c0184599ad5b3f8705d1cagainst refreshed upstreammainc8d34aa8f4d8058d57169cc1e423ba6db00faaf0.The PS4 HTILE sizing change is threaded through target layout, fill coverage, bind-time checking, and slice addressing; the body includes useful unit, Vulkan validation-layer, and Gang Beasts evidence. The PR is a five-commit stack including #9431, with merge base
e2b9700a98d377aa32296cd886f16f40c4d4f76a; current main has 20 later commits. A merge-tree preview is clean and current-main conventions/diff-check pass, but the reported 31-test integration run is on the older stack and the hosted product jobs are skipped.Please refresh the #9431 dependency stack and this follow-up onto current main, then rerun the focused PS4 texture/HTILE and depth execution suite with the Vulkan validation layer requested. Preserve the earlier base/change comparison where feasible, and report exact tests and skips on the updated head. This is an integration-verification request for a broad AGC change; I found no specific defect in the patch from the current-head-only inspection.
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-29T03:41:32Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The HTILE sizing change is correct and its test works when applied to current
mainalone. But the PR head conflicts withmainin three files and does not build on Linux, so it can't merge as it stands.What I ran
cedf987d5ba4ee2f0c4c0184599ad5b3f8705d1cmain:b433c40f2f46aa2e59e19806010a839ac8572d64BUILD_TESTING=ON, in a clean worktree.Results
mainGraphics/include/State.hpp,Graphics/src/State.cppandtests/Graphics.cppgit diff --checkcheck_conventions.py --base origin/main(PR head)PipelineJournal.cpp:38and:39static_assertc8b8d24aefalone onmain: 7 focused tests with the validation layermainbaseline: same 7 tests with the validation layerVUID-lines (change /main)was not found but was requested by env var VK_INSTANCE_LAYERSadding layers "VK_LAYER_KHRONOS_validation"agc_driver_graphics4.3 s; the others are under 1.5 sPR head build failure
Focused tests, PR commit on main (validation layer on)
Negative control
On top of the cherry-picked commit I restored only
Graphics/src/DepthSurface.cppfromorigin/mainand kept the new test.agc_driver_graphicsthen fails as it should:Findings
Blocking
Conflicts with
main. A merge intob433c40f2fconflicts inGraphics/include/State.hpp(ShaderStagesfields and theDrawKeyRegisterstable),Graphics/src/State.cpp(decodeDepthPlaneextent and mip checks,DecodeShaderStages) andtests/Graphics.cpp. This confirms the conflict oneandonlydean reported. All three conflicts are in the carried copy of #9431, not in this PR's own commit. #9431 has been updated since (headeefa5084126) and GitHub now reports it as mergeable. Rebasing this PR's one commit onto #9431's current head, or ontomainonce #9431 lands, should resolve them.The PR head does not build on Linux. This reproduces TechLevelZero's report on the head itself, without merging
mainfirst. Thebool legacyVertexthat the carried #9431 commit adds toShaderStages(State.hpp:35) breaks the size asserts in PipelineJournal.cpp:38-39 (116 == 112). #9431's current head has new values for these asserts, so the rebase in finding 1 should fix this as well. I did not check whether that head also serializes the new field in the recipe codec, as TechLevelZero asked; that question belongs on #9431.Non-blocking
HtileMetadataBytes: the fill coverage check, the bind-time read and the slice step. The head has more. One is the multisample HTILE size inGraphics/src/MultisampleTarget.cpp:847; others are the initial-state and HTILE write ranges inDepthSurface.cpp. In PS4 mode all of them now get the PS4 size. That is consistent, because HTILE covers 8x8 pixels regardless of the sample count, but none of the tests covers a multisampled PS4 target. A sentence in the description would help reviewers after the rebase.SetGcnGuestShaders(true)and switches it back after twoRequires (tests/Graphics.cpp:2402-2405). A failingRequireends the test anyway, so this is fine today. A scoped guard would keep later checks inDepthStencilTestsfrom inheriting GCN mode if the test ever stops failing fast.The sizing itself (DepthSurface.cpp:2415-2420) checks out. One 4-byte HTILE word per 8x8 tile gives 64 × 64 words × 4 B = 16 KiB per 512x512 block. The 2048x1152 case rounds to 4 × 3 blocks (0x30000) and 4096x4096 to 8 × 8 blocks (1 MiB). Both match the fill sizes in the description. PS5 targets keep the 1024x512 / 32 KiB path.
Not verified
libSceAgcDriverdoes not compile at that head on Linux, so I ran the PR's commit onmaininstead (see above).To get this to a good state
c8b8d24aefonto #9431's current head (or ontomainafter #9431 merges) so that the conflicts and thePipelineJournal.cppasserts go away.agc_driver_graphicsand the listed depth,gcn_detileandpattern_buffer_filltests on the rebased head, with the validation layer requested. Report the head SHA, the pass/skip counts and theVUID-comparison in the description.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T09:45:32Z.
Review: APPROVED
Re-checked — approved
The refreshed branch removes its duplicate #9431 changes and keeps the PR's HTILE fix isolated to the size helper, the focused assertion, and the debt entry. The current-main merge preview is clean; current
mainf7e84c4cf1609cc10bac95a44cd431805e5ebc8ahas no intervening changes to those touched files since the reported integration base66405c3250.The author reports 40 focused depth, detile, pattern-fill and graphics tests passing on the updated head in two of three runs, with the other run's two native-depth tests timing out under a concurrent 16-job build and then passing three reruns. The validation layer loaded, and all runs reported zero VUIDs. The base comparison passed 40/40; the earlier negative control showed the PS4 HTILE regression on main. The author also reports conventions and
git diff --checkpassing. I did not run a local build or GPU tests.No blocking issue remains. Approval covers exact head
41c0489401b6ed32f01bcfa4d0f9a0e9052e9788.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-29T10:37:36Z.
Review: APPROVED
Re-checked — approved
The branch now carries only this PR's HTILE change, merged with current
main, so the conflicts and the Linux build failure from my last review are gone. The change itself is line-for-line the commit I reviewed before, and it builds and passes the focused tests with the validation layer on.What changed since my last review
main(93667d0313,41c0489401,b5b541e3fb). After #9431 landed,git diff origin/main...b5b541e3fbshows three files, +11/−3:HtileMetadataBytesinDepthSurface.cpp, the PS4 checks intests/Graphics.cppand one sentence in theHtileFillCoversdebt entry. Its+/-lines matchc8b8d24aefexactly. The only change is that it now also adds theRdnaInstructionDecoder.hppinclude next tomain's includes.41c0489401. Since then the head moved tob5b541e3fb, another merge frommain. It changes nothing underGraphics/or the GCN decoder compared with41c0489401.What I ran
b5b541e3fbd8e4fbb675afde4200a97d7bb2fe9dmain:8958e22ad924f64b726c561828093f3a295e27b8BUILD_TESTING=ON, in a clean worktree.Results
main8958e22ad9git diff --checkcheck_conventions.py --base origin/mainlibSceAgcDriver, includingPipelineJournal.cpp, plus 28 test executables)agc_driver_graphics_maps_fallback5.6 smainbaseline: same 41 testsVUID-lines (change /main)was not found but was requested by env var VK_INSTANCE_LAYERSadding layers "VK_LAYER_KHRONOS_validation"The regex selects the author's 40 tests plus
agc_driver_graphics_maps_fallback.native_multisample_depthandnative_depth_clearstook 1.6 s each here. The 30 s timeouts the author saw in their second run did not occur in this run.Merged tree, ctest summary
Previous findings
main: Resolved. The merge into8958e22ad9is clean, and the branch no longer carries a copy of #9431.PipelineJournal.cpp:38-39: Resolved. The merged tree compilesPipelineJournal.cppand links all the test executables with GCC 16. TheShaderStages/Statedefinitions aremain's.DepthSurface.cppandMultisampleTarget.cpp:966. That last call sits behind aZ64KBXtile-mode check, so a GCN target is unlikely to reach it.SetGcnGuestShaderstoggle in the test without a scoped guard (tests/Graphics.cpp:2483-2486): Still open (minor). It is unchanged and fine as long asRequirefails fast.New findings
Blocking
None.
Non-blocking
41c0489401. The head is nowb5b541e3fb. I confirmed that the extra merge changes nothing underGraphics/or the GCN decoder, and the run above covers the current head. Updating the SHA in the description would keep it accurate.Negative control
On the merged tree I restored only
Graphics/src/DepthSurface.cppfromorigin/mainand kept the new test.agc_driver_graphicsthen fails as it should:Not verified
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T10:57:32Z.
Review: APPROVED
Re-reviewed current head
b5b541e3fbd8e4fbb675afde4200a97d7bb2fe9d. Its only new commit merges currentmainbc3e33f4; the PR diff remains the same three-file HTILE sizing fix, focused assertion, and debt entry reviewed at41c04894. The author’s 40-test Vulkan-validation comparison covers the rebased code and reports the layer loaded with zero VUIDs; the two timeouts were rerun successfully and the main baseline comparison passed. I checked the current-main merge preview, rangit diff --checkand current-main conventions successfully. Main sincebc3e33f4has no changes to the three PR paths. I did not run local GPU tests; hosted Windows passes, and product Linux/specialized CI jobs are skipped.