fix(agc): assemble layered stencil plane views through DepthPlaneCopy #26579
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/26579"
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 birdmarty on 2026-11-24T05:54:15Z.
What
DepthSurfaceTexturepreviously forced every stencil view throughDepthSurface::Sampled(sampled = !cropped && (stencil || (!layered && !integer))), which accepts only a single slice (depthOrLastArray == 0). Multi-slicek2DArrayorkCubeviews over a resident depth surface's stencil plane threwsampling the stencil plane of depth surface ... is not implemented, even though multi-slice depth-plane views already assemble their slices throughDepthPlaneCopy.This change routes layered (
k2DArraywithdepthOrLastArray != 0, orkCube) single-sampleR8_UINTandR8_UNORMstencil views throughDepthPlaneCopy, copying each resident slice fromVK_IMAGE_ASPECT_STENCIL_BITand detiling any non-resident slice from guest memory into a 4-byte-aligned staging stride. Single-slice stencil views stay onDepthSurface::Sampled(no extra copy forR8_UINT), and unsupported 1-byte formats (such asR8_SINT), multi-mip views, out-of-rangebaseArrayvalues, and multisampled arrays still throw.Changes
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp:stencil && layeredsingle-sample views toDepthPlaneCopy(sampled = !cropped && !layered && (stencil || !integer)), acceptingVK_FORMAT_R8_UINTandVK_FORMAT_R8_UNORMand keepingHasStencil(found->hostFormat)as the host-format check for stencil planes.DepthPlaneCopyfor 1-byte stencil formats (VK_FORMAT_R8_UINT,VK_FORMAT_R8_UNORM):texelBytes(),sourceAspect()(VK_IMAGE_ASPECT_STENCIL_BIT),aspect()(VK_IMAGE_ASPECT_COLOR_BIT), 4-byte-alignedstagingLayerStride(forVUID-VkBufferImageCopy-bufferOffset-09101and 4-byte detiler range alignment),{.pipeBankXor = resource.pipeBankXor}onTextureDetiler::Dispatch, andpipeBankXorinGuestLayer's cache key.stencilSlice(device, address, base)viaplaneSurface(device, address)matching only active, non-retired 1-sample stencil-bearing owners of the same extent (never resurrecting a displaced older surface), callSyncStencilFromMemoryandApplyFastClearper matched slice, and keyplaneCopies()bybase.stencilAddressfor stencil views.core/libs/prx/libSceAgcDriver/tests/execution/DepthPlaneSampling.cpp: addStencilArrayCase(3-slice 160x90R8_UINT2D array mixing 2 resident drawn stencil slices and 1 guest-memory tiled slice,baseArray = 1, redraw refresh, 2D shader image view, and displacement by a newer different-extent owner),StencilCubeCase(6-face 128x128R8_UINTcube),StencilUnormArrayCase(2-slice 128x128R8_UNORM2D array), and refusal checks (R8_SINT,baseArray > lastArray).core/libs/prx/libSceAgcDriver/tests/DepthSurfaceReuse.cpp: verify a 2-sliceR8_UINT2D array over aD16_UNORM_S8_UINTsurface stored asD24_UNORM_S8_UINTcopiesVK_IMAGE_ASPECT_STENCIL_BITinto anR8_UINTVK_IMAGE_ASPECT_COLOR_BITarray image, and does not reuse a displaced older slice.docs/dev/debt/changes/fix-agc-layered-stencil-plane-sampling.md: document layered stencil plane sampling scope and remaining gaps.Tested
Windows 11 Pro (build 26300), Intel Core i9-9900K, AMD Radeon RX 6800 (AMD driver 26.10.1, Windows driver 32.0.21045.16010, Vulkan 1.4.315), MinGW-w64 GCC 15.3.0, Release,
main441fa65119.Focused set (
agc_driver_graphics,agc_driver_depth_plane_sampling,agc_driver_depth_plane_sampling_evicting,agc_driver_depth_plane_guest_layers,agc_driver_stencil_plane_memory,agc_driver_stencil_copy_draw,agc_driver_depth_copy_draw,agc_driver_depth_plane_fill,agc_driver_depth_plane_buffer_memory,agc_driver_depth_surface_last_writer) withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(1.4.363.0) andVK_LOADER_DEBUG=layer:main441fa65119VUID-linesWithout the fix (
origin/main'sDepthSurface.cppwith this branch's tests), bothagc_driver_depth_plane_samplingandagc_driver_graphicsfail withAGC graphics: sampling the stencil plane of depth surface ... as a ... texture of guest format 5 (vk 13), tile mode 4, dimension 2, levels 0-0, slice 0 is not implemented.Kingdom Come: Deliverance II (
PPSA21704,01.052.000):160x90D32_SFLOAT_S8_UINTdepth/stencil slices spaced0x10000bytes apart (0x23c20f0000..0x23c22e0000,kZ64KBX,pipeBankXor = 0) and samples them in a compute shader as a 32-slicek2DArrayofR8_UINT(guest format 5).maine60b2f74ad+ PR #26578 (fix/agc-ucp-cull-only-without-clip-planes), aborts at ~178–229 s entering the outdoor Siege of Suchdol transition withsampling the stencil plane of depth surface 0x23c22f0000 (160x90, vk format 130) as a 160x90 texture of guest format 5 (vk 13), tile mode 4, dimension 2, levels 0-0, slice 0 is not implemented(reproduced twice).maine60b2f74ad+ PR #26578 + this change (no diagnostics), passes the stop cleanly across 4 consecutive runs: renders the outdoor Siege of Suchdol battlements and valley (~20–26 FPS), completes the post-cutscene loading screen (~47–59 FPS), and enters live first-person 3D gameplay ("Main quest started: Last Rites", aiming crossbow, walking up the ramparts stairs, game saving) with 0 visual glitches and 0 driver errors.py -3 tools/check_conventions.py --base origin/mainandpy -3 tools/debt_fold.py --checkpass.py -3 tools/pr_overlap.py --branch fix/agc-layered-stencil-plane-sampling(2,594 open PRs): all 9 line-adjacent PRs (#10894, #18185, #19697, #20041, #22531, #22778, #24083, #24327, #25610) and 19 conflicting PRs (#1368, #1395, #6808, #7256, #7642, #9508, #9895, #9950, #10193, #11444, #11551, #13863, #13920, #13928, #13929, #15621, #20315, #22062, #22647) were checked manually; none implements layered stencil plane sampling (#1368is stale/conflicting from Oct 2026 beforeDepthPlaneCopy).Not tested: multi-mip layered stencil views, multisampled stencil arrays, console hardware, other GPUs, Linux.
Checklist
main; no other open PR implements the same functionsNotImplemented_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)mainand this change, 0 VUIDs