mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-11-01 12:45:56 +00:00
Only the depth plane of a depth surface reached guest memory: stencil lived in the host image alone. A title that moves stencil with buffer copies read stale bytes from the source plane, and the destination surface never saw what the copy wrote. Uncharted 4 clears its G-buffer stencil plane with a fill, then copies it into the lighting depth target and on into last frame's planes with a buffer copy kernel every frame; its lighting kept the stencil marks of earlier frames, so characters left trails and the image doubled while the camera moved. The stencil plane of a single-sample surface with the 64 KiB Z swizzle is now marked drawn when the surface is bound, stored whole when a read overlaps it (FlushDepthPlanes, like the depth plane) and reloaded from guest memory when a collected guest write changed it before the surface is bound or its stencil sampled, unless a stencil clear is pending. agc_driver_stencil_plane_memory draws stencil, reads the plane through FlushDepthPlanes, then writes it from the CPU and tests it with stencil EQUAL; it fails without the change. AI-assisted: yes