Skip to content

fix(agc): handle the fill kernel that reads its pattern from a buffer - #4465

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
mrzacarias:fix/agc-buffer-pattern-fill
Oct 14, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
mrzacarias:fix/agc-buffer-pattern-fill

Conversation

@mrzacarias

Copy link
Copy Markdown
Contributor

What

The fill HLE knows the 16-byte fill kernel that takes its pattern from the user SGPRs s[4:7]. Some titles use a variant that loads the pattern with s_buffer_load_dwordx4 through the V# in s[4:7] instead:

d7460004 04010c08 f4280302 fa000000 bf8cc07f 7e00020c 7e02020d 7e04020e 7e06020f e01c2000 80000004 bf810000

That variant ran as a shader, so a uniform fill over an HTILE was never seen as a depth fast clear. Vampire Crawlers clears its 1080p UI canvas HTILE this way every frame. The depth surface kept old depth, every UI draw (reverse-Z, GEQUAL) failed its depth test, and the screen stayed black while the 3D scene rendered into its own target.

matchesFillKernel now accepts the variant, and fillBuffer reads the 16-byte pattern from the V# base address, so the existing HTILE and DCC key handling applies. The descriptor's size and stride are not checked. depth_fast_clear_submit gets a case that fills with the buffer pattern 0xffffffff (no clear) and 0 (clear).

Context: #1 (comment)

Tested

macOS arm64 (M1 Pro, MoltenVK), on main plus a local macOS arm64 port, FEXCore runner. Vampire Crawlers: black screen before, renders and plays after. depth_fast_clear_submit: the new case fails without the fix and passes with it. agc_driver_graphics_tests, dword_pattern_fill, pattern_buffer_fill, fill_cover_keys, vertex_fetch pass. Linux and Windows not tested.

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 in TechnicalDebt
  • 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: PPSA30703 (Vampire Crawlers; no Game bring-up discussion yet)
  • AI-assisted: yes

The 16-byte fill kernel has a variant that loads its pattern with
s_buffer_load_dwordx4 through the V# in s[4:7] instead of taking it from
the user SGPRs. Vampire Crawlers (PPSA30703) clears its UI canvas HTILE
with it every frame; run as a shader, the depth surface never cleared and
every UI draw failed its GEQUAL depth test, leaving the screen black.
@mrzacarias mrzacarias mentioned this pull request Oct 12, 2026
@github-actions github-actions Bot added the agc libSceAgc* label Oct 12, 2026
@kr4y4

kr4y4 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Windows run, since the description lists Linux and Windows as not tested.

Setup: Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, CI configure flags, an RTX 4070 Laptop GPU and an Intel Raptor Lake-S iGPU. The head 3bc3e35 merged into main 2a5eca1.

  • agc_driver_depth_fast_clear_submit, depth_fast_clear, dword_pattern_fill, pattern_buffer_fill, fill_cover_keys, vertex_fetch and graphics pass on both GPUs with --repeat until-fail:3.
  • The new case runs on both: they store compute fills into imported guest memory, and the test ends with depth fast clear submit tests passed, not the without the compute fill line.
  • With main's BufferFill.cpp and the new test, agc_driver_depth_fast_clear_submit fails on both GPUs: a compute fill with the buffer pattern 0 over the HTILE did not clear the depth to DB_DEPTH_CLEAR (1.0).
  • Full suite (ctest --timeout 120 --parallel 4): 973 of 973 on the RTX 4070. On the iGPU 972 of 973; the one failure, agc_driver_f32_dot2_rounding, fails the same way on main (no shaderFloat64, test(agc): skip the f32 dot2 rounding test on devices without shaderFloat64 #4528).

Written with AI assistance.

@oneandonlydean oneandonlydean self-assigned this Oct 12, 2026
@oneandonlydean
oneandonlydean merged commit 7cc6cd8 into boykopovar:main Oct 14, 2026
9 of 10 checks passed
mrzacarias pushed a commit to mrzacarias/AnyPS5 that referenced this pull request Oct 15, 2026
Upstream main now carries the final versions of PRs boykopovar#1193, boykopovar#1201, boykopovar#1202, boykopovar#5216 and boykopovar#4465, so their
draft copies on this branch give way to main's: the snapshot ring, the pipeline identity memo, the
code-hash memo and APS5_RESIDENT_LINEAR_TARGETS are gone with them. The port of boykopovar#4943 (draw-cache
relocation across moved user-data pointers, not merged upstream) is dropped: the draw prefetch
replaces it.

Kept on top of main: the arm64 FEXCore runner and macOS libraries, the MoltenVK settings, rect-list
clip and cull distances, GPU-ordered in-place vertex inputs, the draw pipeline's spin-first locks and
lock-free overlap check, SharedVector binding flags, the result-memo admission, the draw prefetch
(APS5_DRAW_PREFETCH) and the 1D T# sample modes. New for arm64: fegetenv from the runner's guest
control words, and the direct-memory reuse map on macOS. On macOS the guest buffers keep one
descriptor array (no buffers_coherent or buffers_u8 aliases): MoltenVK aliases a descriptor array only
through Metal argument buffers, which the driver turns off, and Vampire Crawlers' first compute
pipeline failed to compile.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants