Skip to content

fix(agc): preserve fresh HTILE depth and stencil clears - #6438

Merged
adriadam10 merged 4 commits into
boykopovar:mainfrom
JJenkx:fix/initial-htile-depth-clear
Oct 19, 2026
Merged

adriadam10 merged 4 commits into
boykopovar:mainfrom
JJenkx:fix/initial-htile-depth-clear

Conversation

@JJenkx

@JJenkx JJenkx commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

What

A fresh depth/stencil attachment receives DB_DEPTH_CLEAR and DB_STENCIL_CLEAR in its constructor. Repeating a partial HTILE clear on its first bind loses the initialized stencil value in the tested RADV sequence; DOOM + DOOM II shows duplicated/outlined collection text.

Use the constructor's clear for the cleared planes of a new attachment, inherit only the other planes, and retain the pending-clear path for reused attachments. HTILE decoding, expanded metadata write-back, caching, pipelined draws and native-owner guards remain in place. No general Vulkan-driver defect or speedup is claimed.

Review follow-up

The reported unoptimized fixture failure was real. Its small depth/stencil arrays held only logical pixel data, but DepthSliceBytes tracks a 64 KiB tiled footprint for each plane. The declaration-order layout put subsequently written HTILE bytes inside those undersized ranges. Changing only test translation-unit ordering reproduced the distinction: -O0 -ftoplevel-reorder passed, while -O3 -fno-toplevel-reorder failed at the inherited-stencil assertion, with the runtime libraries unchanged in Release mode.

Allocate the complete plane footprints and check their sizes before drawing. This keeps all inherited-plane assertions and makes the -O0 fixture pass on both drivers. The corrected fixture still distinguishes the production fix on RADV; lavapipe passing with and without the production fix was already the expected driver-specific result.

Dextroid17 independently retested corrected head 8d44a5e6c on lavapipe Mesa 26.2.4 / LLVM 23.1.1 with GCC 16.2.1: the three depth checks pass in three runs of both a full unoptimized build and Release, with or without the production change. This confirms the fixture repair on that driver; their setup has no RADV and does not test the RADV negative control. Independent result.

Tested

Latest refresh: four linear topic commits on main 55f82fee838c9895dd19ae8a997cbc935ef566e1, head 6326d05f02868252bf64cc3e1699bb60e84fdf9f. Resolves the shared DepthFastClearHarness.hpp conflict after #7044 merged, preserving both configurable target dimensions and main’s configurable viewport depth range. The other three topic commits are unchanged by range-diff. Release driver and seven focused test executables build; 7/7 checks pass on RADV and 7/7 on lavapipe, zero skips and zero core-validation errors/VUIDs. Conventions and whitespace pass. No fresh title run, full suite, Windows run or performance claim; prior negative controls remain historical. Pinned refresh report.

Earlier refresh: four linear commits on main c0a7468f6f666a46b1c3e2fb14bb651fed05afc5, head cb113f2a645973a1bb2e5834ca5377c7d1148dc4. Main's newer plane-fill handling is retained. Fresh attachments inherit an explicit pending depth/stencil plane fill while constructor-initialized HTILE clears still avoid a redundant partial clear. New assertions cover both pending-fill aliases. The unadapted rebase fails the new stencil assertion on RADV. With unchanged main's DepthSurface.cpp, the existing HTILE regression fails and the new plane-fill assertions pass; restoring the fix passes both.

Release driver and seven focused executables build. The six earlier focused checks plus agc_driver_depth_plane_fill pass 7/7 on RADV and 7/7 on lavapipe, zero skips, zero core-validation errors/VUIDs (0.81 s / 1.09 s). Conventions and whitespace pass. No fresh title run, full suite, Windows run or performance claim in this refresh. Pinned report, RADV checks, lavapipe checks, main control.

Earlier validation head 14f92f555ead00380215da5bd9da193feabb25d4 rebases the same three topic commits onto main 66e290f1c04a6aa08271f106d0dc83ba06561bfc. Full Release libs and the six focused executables build with the published, clean SPIRV-Tools revision 7f2d9ee926f98fc77a3ed1e1e0f113b8c9c49458, without a private dependency change. The six checks listed below pass 6/6 on RADV and 6/6 on lavapipe, zero skips (0.45 s / 0.56 s); conventions and whitespace pass.

A separate isolated Override 2 PPSA01907 v01.007.000 startup run reaches the menu and closes normally with exit 0 after 93.41 s, restoring temporary settings. Its 80 s screenshot still has very dark 3D output; this topic does not resolve that observation. No new Override compatibility or FPS gain is claimed. Current validation and diagnostic screenshot: htile-main66-validation-public.json, htile-main66-override2-menu.png, and the two htile-main66-*-tests.log files.

Earlier public head 8d44a5e6cd06da28a47b13fd3afcb479ae0f6298: three linear commits on main 5d9dcc42d. Linux 7.2.9-arch1-1, GCC 16.2.1, Ryzen 9 7950X, RX 6650 XT / RADV Mesa 26.2.4-arch1.1; lavapipe Mesa 26.2.4 / LLVM 23.1.1.

  • Earlier full Release libs and six focused test executables build. agc_driver_depth_htile_write, agc_driver_depth_fast_clear, agc_driver_depth_fast_clear_submit, agc_driver_native_multisample_depth, agc_driver_depth_storage and agc_driver_depth_surface_last_writer: 6/6 pass on RADV and 6/6 on lavapipe, zero skips. Tests require Vulkan and select each driver explicitly.
  • Independently compile the corrected fixture at -O0, leaving runtime libraries in Release: both drivers pass. Restore main's DepthSurface.cpp without rebuilding that executable: RADV fails a depth-only HTILE clear discarded the initial stencil clear; lavapipe passes. Restore the fix: both pass. Fixture SHA-256 remains 335a11180bf09d9651e41e67b6bd7622279dea644f7974c0e7e07bba287a51fb throughout. This isolates the fixture failure and checks the production regression; it is not a full unoptimized-runtime build.
  • Earlier native DOOM + DOOM II PPSA21444 v03.000.000 comparison on main ff23657f3 plus shared boot prerequisites: control 53f2e521ce260772f8fc47f8b1043e36e704cec9 has corrupted collection-description text at 30 s; adding this production fix in 4cb5da916d5706ca1e37ed6456546bfd32e52c36 gives readable text at the matching capture and reaches E1M1: Hangar by 170 s. Both end at the scheduled watchdog (124); host configuration is restored. No fresh DOOM run on the new base, sustained gameplay, audible-audio result or FPS gain is claimed.

Earlier validation validation/htile-review-5d, head 0a1fd1b43, adds only the common #6476 source-level validator repair to this PR on main 5d9dcc42d. The three changed source/test files are byte-identical to this public branch. It uses the published third-party revision, not the earlier private submodule repair; #6476 is excluded from this PR. Earlier native integrations also share #5916 and #6348 to pass audio initialization. I have not run a full unoptimized runtime, fresh Windows build, complete CTest suite, or fresh DOOM comparison; the independent lavapipe result is credited above. No game assets, raw title logs or binaries are attached.

Merge ordering: #6423 first. It changes the same creation/clear block; rebase retaining its Refuse diagnostic after it merges. #6300's native-MSAA handling and the manually reviewed stale overlaps #1395, #1368, #5499 and #6292 do not implement this fresh single-sample plane correction.

Neithennn independently reports a full build on Windows 11 Pro 26200, NVIDIA GeForce RTX 4080 driver 617.42, Ryzen 7 5800X, WinLibs GCC 15.2.0 r7 / Ninja / Release, bundled dependencies, BUILD_TESTING=ON, ANYPS5_NO_SHADER_CACHE=1. This exact PR head 14f92f555 was merged onto main f51724078: 8/8 focused depth tests pass with ANYPS5_REQUIRE_VULKAN=1. Full CTest is 1397/1398: guest_memory exits 0xc0000409 once, then passes 5/5 serial repeats; unchanged main passes 1398/1398. This remains an unexplained intermittent full-suite failure, not an all-green result. No title run. Contributor-reported Windows/NVIDIA validation; not independently reproduced locally.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: fix(agc): keep the first native multisample depth sampling refusal #6423 (merge ordering for the shared clear block)
  • Fixes: none
  • Unblocks: PPSA21444 DOOM + DOOM II (PPSA21444) #5921 (earlier readable collection-menu text; declared boot prerequisites remain)
  • GPUs tested: Arch Linux x86-64, Ryzen 9 7950X, RX 6650 XT RADV Mesa 26.2.4-arch1.1; lavapipe Mesa 26.2.4 LLVM 23.1.1; independent earlier Windows/NVIDIA coverage above
  • AI-assisted: yes

@Dextroid17

Copy link
Copy Markdown
Contributor

I ran this PR's depth tests on Linux with lavapipe (Mesa 26.2.4, LLVM 23.1.1), GCC 16.2.1. The checks this PR adds to agc_driver_depth_htile_write give a different result depending on the build type, and in neither build do they tell the fix apart from main's code.

Setup: head 9870b37 merged into main at 92e5041 (no conflicts; the PR is based on that main), clean environment (env -i with only HOME, PATH and VK_ICD_FILENAMES set). ctest -R '^agc_driver_depth_(htile_write|fast_clear|fast_clear_submit)$', 3 runs each. "Fix reverted" means core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp put back to main's version, with the PR's test changes kept.

Default build (CMAKE_BUILD_TYPE empty, BUILD_TESTING=ON):

  • with this PR: 3 of 3 runs fail. agc_driver_depth_htile_write stops at "a fresh depth-only HTILE clear lost its initial depth or inherited stencil data"; agc_driver_depth_fast_clear and agc_driver_depth_fast_clear_submit pass.
  • with the fix reverted: the same result, the same failure at the same message.

Release build (-DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON, the build type and BUILD_TESTING setting build.yml uses):

  • with this PR: 3 of 3 runs pass (3 tests).
  • with the fix reverted: 3 of 3 runs also pass.

So in this setup, the check at that message fails in the unoptimized build whether or not the fix is there, and the whole test passes in Release whether or not the fix is there. All build and test jobs (Linux and Windows) were skipped for this head, so CI has not run the PR's new checks yet. I have not found the cause of the build-type difference.

I did not check Windows or macOS, or a GPU other than lavapipe.

AI-assisted: yes

@JJenkx
JJenkx force-pushed the fix/initial-htile-depth-clear branch from 9870b37 to 8d44a5e Compare October 15, 2026 22:15
@JJenkx

JJenkx commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

Reproduced the unoptimized failure and corrected the fixture in 8d44a5e6c, rebased onto main 5d9dcc42d.

The small depth/stencil arrays did not cover their 64 KiB tiled footprints. Declaration-order placement put HTILE writes inside those ranges. With Release runtime libraries held fixed, -O0 -ftoplevel-reorder passed and -O3 -fno-toplevel-reorder failed at the same inherited-stencil assertion. The fixture now allocates complete plane footprints and checks the backing sizes; the assertions remain.

Corrected fixture at -O0 + Release runtime: RADV and lavapipe pass. Keeping that exact executable, restoring main's DepthSurface.cpp fails the initial-stencil-clear assertion on RADV and passes on lavapipe; restoring the fix passes both. SHA-256: 335a11180bf09d9651e41e67b6bd7622279dea644f7974c0e7e07bba287a51fb. The lavapipe production-negative pass is expected and was listed in the original report; RADV supplies that negative control.

Final normal Release build and six focused CTests pass on each driver, no skips. The updated description separates this isolated -O0 fixture result from a full unoptimized-runtime build, which I have not run, and links the exact validation source. No new native-game or Windows result is claimed. Thanks for identifying the fixture failure.

@Dextroid17

Copy link
Copy Markdown
Contributor

Re-ran the same check on head 8d44a5e, same setup as before except that the head is now based directly on main 5d9dcc4 instead of merged into it: lavapipe (Mesa 26.2.4, LLVM 23.1.1), GCC 16.2.1, a clean environment, ctest -R '^agc_driver_depth_(htile_write|fast_clear|fast_clear_submit)$', 3 runs each.

                       default build (no build type)   Release
 with this PR          3/3 pass                        3/3 pass
 fix reverted          3/3 pass                        3/3 pass

The failure I reported in the default build ("a fresh depth-only HTILE clear lost its initial depth or inherited stencil data") is gone with the full-footprint fixtures. That fits your explanation that the undersized arrays let HTILE writes land in neighbouring globals depending on layout, though I only tested the new head and did not rerun the old fixture on the new base.

This is a full unoptimized build (CMAKE_BUILD_TYPE empty), so it covers the case you said you had not run. On lavapipe the tests still pass with DepthSurface.cpp reverted to main, as you expected; I have no RADV here, so I did not check your negative control. The linux and windows build jobs were skipped again for this head.

AI-assisted: yes

@Neithennn

Copy link
Copy Markdown
Contributor

Windows NVIDIA run, since the description lists RADV and lavapipe only.

Windows 11 Pro 26200, NVIDIA GeForce RTX 4080 (driver 617.42), AMD Ryzen 7 5800X, WinLibs GCC 15.2.0 r7, Ninja, Release, bundled dependencies, BUILD_TESTING=ON, ANYPS5_NO_SHADER_CACHE=1. Head 14f92f555 merged onto main f51724078; full build succeeds.

  • agc_driver_depth_htile_write, agc_driver_depth_fast_clear, agc_driver_depth_fast_clear_submit, agc_driver_depth_surface_from_storage, agc_driver_depth_surface_last_writer, agc_driver_native_depth_clears, agc_driver_native_depth_clear_refusals, agc_driver_native_depth_retirement: 8/8 pass, with ANYPS5_REQUIRE_VULKAN=1.
  • Full ctest -j 8: 1397/1398. The failure is guest_memory (0xc0000409) in that run only: it passes 5/5 serial runs on this tree and passed on unchanged main on the same machine (1398/1398); this PR does not touch guest memory.

No title run.

AI-assisted: yes (runs done with Claude Code).

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 17, 2026
@JJenkx
JJenkx force-pushed the fix/initial-htile-depth-clear branch from 14f92f5 to cb113f2 Compare October 17, 2026 21:42
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Oct 17, 2026
@JJenkx
JJenkx force-pushed the fix/initial-htile-depth-clear branch from cb113f2 to 6326d05 Compare October 17, 2026 22:55
@github-actions github-actions Bot added unblocks title Names a title ID on the Unblocks line and removed needs rebase Conflicts with main, rebase needed labels Oct 17, 2026
@adriadam10 adriadam10 self-assigned this Oct 18, 2026
@adriadam10
adriadam10 merged commit f4e60cf into boykopovar:main Oct 19, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants