Skip to content

fix(agc): compare the depth write base only when the depth plane is written - #6725

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
johandavidcm:fix/agc-depth-write-address
Oct 19, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
johandavidcm:fix/agc-depth-write-address

Conversation

@johandavidcm

Copy link
Copy Markdown
Contributor

What

decodeDepth required DB_Z_WRITE_BASE to equal DB_Z_READ_BASE whenever the depth plane was not read-only, also for draws that never write it. Yakuza 0 Director's Cut (PPSA31327, 01.015.000) stops on such a draw:

AGC graphics: depth read and written at different addresses is unsupported

A local diagnostic build (not part of this PR) printed the draw's registers:

Register Value
DB_DEPTH_CONTROL 0x00000701 (stencil test only: Z_ENABLE and Z_WRITE_ENABLE clear)
DB_RENDER_CONTROL 0
DB_DEPTH_VIEW 0
Z read / write base 0xed11340000 / 0
Stencil read / write base 0xed14280000 / 0xed14280000
DB_Z_INFO / DB_STENCIL_INFO 0xa2900983 / 0x20000181
DB_DEPTH_SIZE_XY 0x0a1f11ff (4608x2592)

The bases are now compared only when the depth plane can be written: a depth clear, a draw with both Z_ENABLE and Z_WRITE_ENABLE (the condition that sets depthWrite), or an expand pass with DEPTH_COMPRESS_DISABLE or STENCIL_COMPRESS_DISABLE in DB_RENDER_CONTROL, which still throws. The surface keeps the read base. The stencil check is unchanged.

Overlap: #6146 moves this check into its reworked decodeDepth and runs out-of-place expands (DB_RENDER_CONTROL & 0x60) from the draw precheck. It keeps the strict comparison for every other draw, so it does not pass this one (DB_RENDER_CONTROL 0). The behaviours are independent; I will rebase onto #6146 if it lands first.

Tested

Windows 11 Pro 26200, WinLibs GCC 15.2.0 (ucrt, posix, seh, r7), NVIDIA GeForce RTX 4070 (driver 617.42).

  • agc_driver_graphics: DepthStencilTests accepts a stencil-only draw, Z_WRITE_ENABLE without Z_ENABLE and a depth test without writes at another write base (depth not written, surface at the read base), and still rejects a written plane, a depth clear and DB_RENDER_CONTROL 0x20, 0x40 and 0x60 there.
  • 27 depth and stencil tests on the RTX 4070: 26 passed (agc_driver_depth_* (12), agc_driver_native_depth_* (3), agc_driver_native_multisample_depth, agc_driver_pipeline_optimized_readback_d16/d32 (4), agc_driver_readonly_resummarize, agc_driver_sample_mask_depth_stencil, agc_driver_stencil_ref_export_unused, agc_driver_stencil_replay, agc_driver_stencil_replay_no_gpl, agc_driver_graphics); agc_driver_stencil_ref_export skipped, the device lacks VK_EXT_shader_stencil_export.
  • PPSA31327: with this change the title reaches its menus, which respond to input. Starting a new game leaves a black screen while it loads and stops at CMASK fast clears of a mipmapped, 3D or array color target are unsupported. Reaching the menus also needs the local changes listed in the bring-up discussion.
  • tools/check_conventions.py --base origin/main passes.

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: none
  • Unblocks: PPSA31327 Yakuza 0 Director's Cut (PPSA31327) #6722
  • GPUs tested: NVIDIA GeForce RTX 4070, driver 617.42, Windows 11 Pro 26200
  • AI-assisted: yes

…ritten

decodeDepth required DB_Z_WRITE_BASE to equal DB_Z_READ_BASE whenever
the depth plane was not read-only, also for draws that never write it.
PPSA31327 01.015.000 stops there on a stencil-only draw:
DB_DEPTH_CONTROL 0x00000701 (Z_ENABLE and Z_WRITE_ENABLE clear),
DB_RENDER_CONTROL 0, DB_DEPTH_VIEW 0, Z read base 0xed11340000 and
Z write base 0, with equal stencil read and write bases.

The bases are now compared only when the depth plane can be written: a
depth clear, a draw with both Z_ENABLE and Z_WRITE_ENABLE (the condition
that sets depthWrite), or an expand pass with DEPTH_COMPRESS_DISABLE or
STENCIL_COMPRESS_DISABLE in DB_RENDER_CONTROL, which still throws. The
surface keeps the read base. The stencil check is unchanged.

DepthStencilTests accepts a stencil-only draw, Z_WRITE_ENABLE without
Z_ENABLE and a depth test without writes at another write base, and
still rejects a written plane, a depth clear and the compress-disable
bits there.
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1191 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
PR 1395 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 4040 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 5441 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 5499 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 5500 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 5925 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6146 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6188 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6194 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6235 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6280 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6548 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6636 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6683 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6741 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6808 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6970 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6972 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6977 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
PR 7085 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7254 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7256 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7332 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7426 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7659 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp

@savvaniss

Copy link
Copy Markdown
Contributor

Intel and AMD Windows data: no failures from this change.

Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built, ANYPS5_NO_SHADER_CACHE=1, serial CTest, main 47a266cf9. Intel UHD Graphics 770 (8086:a780, 32-wide subgroups), driver 32.0.101.7088. AMD Radeon RX 9070 XT (1002:7550, 64-wide subgroups), driver 32.0.31041.1004, with VkCache emptied first.

UHD 770 RX 9070 XT
This head c8f7fc06e merged into main: the 16 tests built from tests/Graphics.cpp, ×3 pass pass

Full CTest (--parallel 4) with six open PRs merged into main (#6638, #6604, #6014, #6773, #6772, #6725): the same failures as main alone on both GPUs, nothing new. main alone: UHD 770 1392 of 1398, RX 9070 XT 1396 of 1398. The failures are image tables (#6647) and sample_multisample_target (#6971) on Intel, and quad_pixel_mask (#6255) and layered_volume_vertex_no_gpl (#4768) on AMD.

AI-assisted: yes (Claude Code)

@johandavidcm

Copy link
Copy Markdown
Contributor Author

Thanks @savvaniss for the Intel and AMD runs.

@EagleBearerYS the overlap comment lists #6146 on the same lines of decodeDepth (L288-289). The changes are independent: #6146 runs out-of-place expands (DB_RENDER_CONTROL & 0x60) from the draw precheck and keeps the strict base comparison for every other draw, while #6725 skips the comparison only when the depth plane cannot be written (no depth clear, not both Z_ENABLE and Z_WRITE_ENABLE, no DB_RENDER_CONTROL & 0x60), so an expand still throws in decodeDepth and your precheck path is unchanged. PPSA31327's stencil-only draw (DB_DEPTH_CONTROL 0x701, DB_RENDER_CONTROL 0, Z write base 0) stops on the strict comparison with or without #6146.

As #6725 is a two-line change, I suggest it goes first; on your side the conflict resolves by using its condition in the Require you move to the top of decodeDepth. If you prefer #6146 first, I will rebase #6725 onto it and set Depends on: #6146. Which order works for you?

Manual check of the PRs the overlap comment could not compare: #1395 also edits this Require (it adds a copying || exception for its experimental depth copy recognition) but is far behind main and conflicts with it; #4650 only reads depthWrite elsewhere; the others do not touch the base comparison in decodeDepth or the DepthStencilTests block this PR extends.

@johandavidcm

Copy link
Copy Markdown
Contributor Author

@oneandonlydean, could you take a look when you have time?

@github-actions github-actions Bot added the unblocks title Names a title ID on the Unblocks line label Oct 18, 2026
@adriadam10 adriadam10 self-assigned this Oct 19, 2026
@adriadam10
adriadam10 merged commit d5bbceb into boykopovar:main Oct 19, 2026
9 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked decodeDepth again against current main: depthWritten matches the condition that sets depthWrite (Z_ENABLE and Z_WRITE_ENABLE, depth clear) plus the DB_RENDER_CONTROL & 0x60 expand case, which still throws. The stencil check is untouched. The new DepthStencilTests cases pin both the accepted draws (0x711, 0x715, 0x713) and the rejected ones (0x717, clear, 0x20/0x40/0x60) at a different write base, and the stencil-only draw would have thrown before. Third-party Intel/AMD Windows runs from @savvaniss are clean. Merged.

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.

3 participants