perf(agc): fill a DCC fast-clear surface by doubling copies #13527
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13527"
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 JJenkx on 2026-10-30T17:40:33Z.
What
FillDccClearwrites the texels of a surface whose DCC keys say it is fast-cleared. It built one element (4 to 16 bytes) and then copied it with onememcpyper element, so a 3840x2160 RGBA8 surface took about 8.3 million calls.ReadTextureSurfaceuses it for every upload of such a texture, so the cost recurs whenever a cleared texture is uploaded again.It now copies the first element, then copies the filled prefix onto the rest, doubling the filled length each time (about 25 calls for that surface). The last copy stops at the last whole element, and a trailing partial element is zeroed as before, so the bytes written are the same. A test in
TextureFormat.cppfills 1003 bytes with an 8-byteR16G16B16A16_SFLOAT1111 clear (125 elements and a 3-byte tail) and checks every byte. Making the doubling skip one byte per round makes it fail.Where it showed up. Afterimage (PPSA14053, UE4) on Windows runs its intro cinematic at about 10 fps on
main. In anAPS5_SAMPLE_WORKERrun the queue worker spends 65 % of its samples waiting inDrawPipeline::Drain/Enqueue. So the draw committer sets the pace, and in anAPS5_SAMPLE_COMMITTERruncachedTexture→ReadTextureSurface→FillDccCleartakes 21 % of the committer, most of itucrtbasememcpycalls on a few bytes each.Tested
Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, Radeon RX 6700 XT with AMD proprietary driver 26.10.1, WinLibs GCC 15.2.0 UCRT r7, Release,
BUILD_TESTING=ON.Performance (Afterimage PPSA14053 01.000.000, 3840x2160). Both
libSceAgcDriver.prxwere built in one build directory frommain556547da71:mainitself (SHA-256fe591ad3…), and this commit on it (37a0dbc26a,14370687…). All other libraries andapp.exeare identical. Every run started from a fresh save with the same scripted pad input (Start Game, New Game, intro). Caches were warm: each arm had run several times with its own shader cache before these runs, which then alternated. Each pair captures the same presents, 1900–2099, which are inside the intro cinematic in both arms. The arms reach different points of the intro by then, because the menus before it run for a fixed time at different frame rates. The intro's frame cost is flat, though: its 10 s frame p50 stays between 89.7 and 99.3 ms onmainand between 74.9 and 79.6 ms with this change, in the warm-up runs. The onlyAPS5_TRACE_*/APS5_PROFILE_*switch set isAPS5_TRACE_FRAMES=1900:200(recaptured after review; the first captures also setAPS5_TRACE_SUMMARY_EVERY).python tools/performance_compare.py --require-matching-context:mainGraphics.Draw(draw committer) ms per frameDriver.Packetms per frameGraphics.Drawms per frameDriver.Packetms per frameGPU busy per present: 53.9 → 47.4 and 53.1 → 49.9 ms. All four traces report dropped events, so the event detail is incomplete; the phase totals are not affected.
Summary lines (pair 1
main, pair 1 PR, pair 2main, pair 2 PR):Traces, summaries,
trace_digest.pyandperformance_compare.pyoutputs, library hashes, screenshots, the worker and committer sampler profiles (collapsed stacks and symbolized reports, from separate runs) and harness: afterimage-dcc-fill-doubling-ab-clean-20261030.tar.gz, SHA-256fefb0538c51d64310a184ae515f87528b9a42c2a1bc4bedba8607383d8b6e48e.Tests
agc_driver_graphics(its executable has 38 CTest entries) pass, 3 of 3 runs.VK_LAYER_KHRONOS_validation1.4.309:AlphaToCoverage,ClampedGlobalFill,DccKeyPresync,DccKeysFirstWrite,DrawWriteRanges,FillCoverKeys,LayeredVolumeSubmit,MemoryValueFill,PresentKeyWriterWait,SampleMultisampleTarget,SgprPatternFillKeys,Srgb8ColorTarget,StagedClearSampledRead.agc_driver_msaa_dcc_compared_import_2/4/8skip on this device.VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605, inagc_driver_srgb8_color_target.main556547da71reports the same one in that test; it is #11990 (open fixes #13006, #6782).python tools/check_conventions.py --base origin/main: all checks passed.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T17:45:03Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The fill optimization and added byte-level test look sound, but the paired performance captures set an additional tracing switch that the repository’s performance-report instructions prohibit for comparable measurements.
What I ran
Reviewed head
37a0dbc26ad169c4b03730c557d43d6c025f5843against base223b19ba0adb11b66893a57fa656ecf6bc4a45cf; the exact-head merge preview against that base was clean. The base used in the performance captures was556547da71c5; it is 14 commits behind the current base, and none of those intervening commits changed either PR path. Environment: Linux x86_64, Python 3.11.2, GCC 12.2.0. I did not build or compile.Commands and checks:
The supplied archive checksum matched the PR body. I reran the exact-head
trace_digest.pyandperformance_compare.pyoutputs on the attached traces; after normalizing CRLF/LF, all four digests and both pair reports matched the attached outputs byte-for-byte. The precheck's ABI-audit and test-quality helper subprocesses could not run because those local helper scripts are not present at the PR head; these are tool-availability errors, not findings in the patch.Results
git diff --checkUnedited output from checks
The precheck's two unavailable helper commands returned:
Findings
Blocking
APS5_TRACE_SUMMARY_EVERY=10alongsideAPS5_TRACE_FRAMES. The performance form says to set no otherAPS5_TRACE_*/APS5_PROFILE_*switch because it costs time; the build documentation specifically saysAPS5_TRACE_SUMMARY_EVERYadds timestamp recording and two clock reads per performance-timer scope. This changes the measured instrumentation overhead, so the supplied traces do not follow the required capture protocol. Please repeat the matched main/change captures with only the documented frame-window switch, then update the summary lines, traces, digests, and comparison. I checked the current main history: its 14 intervening commits touch neither changed PR path, so the existing baseline code itself is still representative for these files.Non-blocking
totals_full:false, which means the per-thread totals table did not overflow; aggregate summary totals remain available. The attachments therefore support aggregate comparisons but not complete event-level inspection.Sources
223b19ba0adb11b66893a57fa656ecf6bc4a45cf223b19ba0adb11b66893a57fa656ecf6bc4a45cf37a0dbc26ad169c4b03730c557d43d6c025f584337a0dbc26ad169c4b03730c557d43d6c025f5843Not verified
To get this to a good state
Please rerun the paired captures on the same machine, scene, and settings without
APS5_TRACE_SUMMARY_EVERY, then replace the four summary lines and attached traces and regenerate the digests/comparison. I will re-run the same checks against the updated head.