feat(agc): draw DB stencil copies with a driver pixel program #16025
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/16025"
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 XatiX on 2026-11-05T11:13:40Z.
What
A DB copy with
STENCIL_COPYset inDB_RENDER_CONTROL(bit 3, alone or withCOPY_CENTROIDorCOPY_SAMPLE) was refused withDB_RENDER_CONTROL depth copy, resummarize or decompress is unsupported. PPSA06866 stops on it on the first loading screen with 0x88, and PPSA05666 sends the same value (#5499, #7649).DecodeDepthCopyPassnow accepts a stencil copy into a single-sampleR8_UINTcolor target and refuses one without a stencil plane, into any other format, or combined with a depth copy. The draw is replaced by a driver pixel program, as the depth copy already is forR32_SFLOAT. It fetches the selected sample of the stencil plane through a descriptor with format 5 and no HTILE, and exports it on the first two channels (SPI_SHADER_COL_FORMAT2, shader mask 3), so a target that swaps or masks to green also gets the value. The two programs (one and two samples) are added toDriverOwnedProgram, so their code is not captured as guest memory.What the console DB writes for a stencil copy is not measured. The export on both channels follows the registers PPSA06866 sets (
CB_COLOR0_INFO0x00050c04,CB_TARGET_MASK0x2,CB_SHADER_MASK0x3).Tests:
agc_driver_stencil_copy_draw. Two stencil draws write 0x25 and then 0x5a over a shifted triangle, the copy runs, and every texel is compared with reference draws of each triangle: the copied value inside the copy's triangle, nothing outside it or in the row padding (theR8_UINTrows are 256 bytes apart). Cases: one sample with 0x88 and 0x08; two samples with 0x88 and 0x108, where the shifted draw is masked to sample 1, so the sample 0 copy must not see it and the sample 1 copy must; and both two-sample cases again into PPSA06866's alternate-swap target written through green.agc_driver_graphics: decode of a stencil copy for one and two samples, its source descriptor, and the three refusals.agc_driver_builtin_program_memory: the stencil copy programs are not captured, as for the depth copy.Tested
ANYPS5_ENABLE_SPIRV_TOOLS=OFF.ctest -V -R "stencil_copy|depth_copy|stencil_known|builtin_program|native_multisample_depth|agc_driver_graphics"withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1andANYPS5_REQUIRE_VULKAN=1. Each log starts with its tested commit and these variables.7b6ac7fb8f, onmain8eca0f607d): 7/7 passed.main8eca0f607d:agc_driver_stencil_copy_drawfails withDB_RENDER_CONTROL depth copy, resummarize or decompress is unsupported (register 0x0 = 0x00000088), the error PPSA06866 stops on. Only that test runs in the control, because the other new checks call functionsmaindoes not have.VUID-line or skips a test. Logs: attached in the first comment.main7ad9749ed0plus only this commit (asddf1290fb7; since then only a test case was added and the branch was rebased): noDB_RENDER_CONTROLrefusal, it reaches the first loading screen and its bar advances (563 presents in the first 10 s), and it stops about 19 s after launch onnative multisample depth publication cannot distinguish an unwritten byte from a same-value guest store. That is the next stop on this title (blocker 4 in #13726), not part of this change. The log does not show whether a stencil copy ran before that point: on plainmainblocker 2 came 26 to 35 s in, and the driver logs no stencil copy that succeeds.tools/check_conventions.pypasses. No open PR found for stencil copy.Found while writing the test, not changed here: a guest's stencil bytes are not loaded into a new stencil plane. A stencil EQUAL 0x25 draw over stencil memory filled with 0x25 passed on 0 of 256 texels. The test writes both values with draws, so it does not depend on this.
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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-08T15:48:33Z.
Review: COMMENTED
Ran
7b6ac7fb8fmerged onmain302864d48con Windows 11 x64 (WinLibs GCC 15.2), on an NVIDIA laptop GPU (Turing, driver 621) and an Intel iGPU (driver 101.70xx), withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(Khronos validation layer 1.4.368),ctest -R '^(agc_driver_graphics$|agc_driver_builtin_program_memory|agc_driver_stencil_copy)' -V:mainmain(DepthCopyPass::stenciland the newDepthCopySourceWordsargument come with this PR), so there's no run of the tests without the change.agc_driver_graphicsopen none). No log haswas not found but was requested by env var VK_INSTANCE_LAYERS, and no log on either side has aVUID-. To be sure validation messages reach these logs, the same layer with best practices on printed 28BestPractices-warnings into anagc_driver_recorderlog on each GPU.AI-assisted: yes.