fix(agc): recognise the copy kernel as Demon's Souls 01.007.000 compiles it #8552
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8552"
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 Sam-mon7 on 2026-10-20T16:23:36Z.
What
The buffer copy HLE (
Driver::matchesCopyKernel) recognises its copy kernel,dst[i] = src[i % period]fori < countwith count and period read from a parameter buffer, by an FNV hash of its first 38 instruction words (0x6ec00fe8aa95f99a, added with #5 for PPSA01342). Demon's Souls PPSA01341 01.007.000 ships the same kernel compiled to a different instruction sequence: same descriptors (0x00014004source and destination,0x0004dfacparameters, strides 4/4/16), same parameter layout, 64x1x1 threads, the group id in s12, hash0xc771c42e4d069d62. None of its copies matched (copy HLE 0on every queue), so each one ran as a GPU dispatch. That hash is now accepted too: in the first 55 s of a run (boot to the debug menu) 5,187 copy kernels then match, 2,617 copied on the CPU (20.1 MiB) and 2,570 as GPU transfers (2,239 MiB).The kernel as this version ships it, decoded: the global index from the group id and lane,
s_buffer_loadof count and period from the parameter buffer, an early exit fori >= count,i % periodthrough the usual reciprocal sequence, thenbuffer_load_format_xfrom the source andbuffer_store_format_xto the destination (idxen).Question
Matching by a hash of the raw words breaks whenever a title or patch recompiles the kernel, as here. Would you prefer the matcher to recognise this kernel by its decoded shape instead (the two buffer instructions, the parameter loads and the bounds check), so that recompiled forms keep matching? That is a larger change, and I would do it as a separate PR if you want it.
Tested
Windows 11 (10.0.26200), winlibs GCC 15.2, Release. Tests run on this branch rebased onto
mainat6bef96df7(the validation and game runs usedmainat054852a76; nothing in the copy path changed in between).agc_driver_period_copy: the kernel as Demon's Souls 01.007.000 ships it, run through the driver. With the HLE the linear cases (one group, a period above the count, a partial last group) must take a copy path; a period below the count and a launch with more groups than the count needs must not; every case must producedst[i] = src[i % period].agc_driver_period_copy_no_hleruns the same cases as shader dispatches (APS5_NO_COPY_HLE=1), so the HLE and the shader are checked against the same results. Both pass with this change; withmain'sBufferCopy.cpp,agc_driver_period_copyfails withthe copy did not take the HLE path (one full group).agc_driver_period_copy,agc_driver_period_copy_no_hleandagc_driver_stream_copywithVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1andANYPS5_REQUIRE_VULKAN=1(ctest -V), onmain'sBufferCopy.cppand on this change: noVUID-line and nowas not found but was requested by env var VK_INSTANCE_LAYERSin either log.+r_Wants4K=WantsPerf, debug start menu to the Nexus, warm caches, noAPS5_PROFILE_*switches,APS5_TRACE_SUMMARY_EVERY=10. Both sides include #8394, which this title needs to start onmain. No speed claim: the Nexus frame rate did not change measurably (alternating runs, 0.23 and 0.33 fps without the change, 0.18 with it; the scene is bound by queue waits and GPU time).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