perf(agc): clear a fast-cleared sampled texture on the GPU #13648
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13648"
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-30T21:25:50Z.
What
A sampled texture made from a surface whose DCC keys hold a fast-clear code goes through
cachedTexture's snapshot path, which costs:ReadTextureSurface→FillDccClearwrites the clear texel over the whole surface on the CPU;Textureconstructor copies those bytes into a staging buffer;A target that is cleared every frame and sampled while cleared pays all of this each time it is looked up anew. Afterimage (PPSA14053, UE4) does this throughout its intro:
APS5_PROFILE_DRAWcounts about 330–800 key-driven clear uploads per 10 s there, and the draw committer is the critical path.This change clears the image with
vkCmdClearColorImageinstead, recorded in the same recorder batch the upload used. It applies when:SampledTextureFormatis the format the clear texel is encoded in (DccClearTextureFormat);ClearColorForTexel, the conversion multisampled targets already use for their fast clears);Every other case keeps the upload. A clear-code cache entry keeps no snapshot: a clear-code hit never compares bytes (
ShaderResources.cpp, the*keys != Uncompressed && *keys != ClearSinglehit), so the bytes were only an upload source. The[textures]line ofAPS5_PROFILE_DRAWcounts these textures as "cleared on the GPU", andSampledTexturesCleared()reports them for the new test.Test.
tests/execution/SampledClearKeys.cpp(agc_driver_sampled_clear_keys) samples a 128x128 RGBA8 64 KiB-tiled surface filled with0x5a:On the GPU, forcing the computed clear's red channel to 0.5 makes it fail with
1111 fast clear: component 0 of thread 0 is 0.501961 (0x3f008081), expected 1.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. Every result below is for this PR's heada8202ea542(a8202ea542c7e0d749b5b7d419b5ec5188d54712), against its parentmaind3118d1946(d3118d19463159be42daf0ae5ff7f16975dcc902).GPU tests under validation.
ctest --repeat until-fail:3withVK_LAYER_KHRONOS_validation1.4.309, each SHA built and run on its own:a8202ea542maind3118d1946agc_driver_sampled_clear_keys)agc_driver_msaa_dcc_compared_import_2/4/8VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605The entries are the new test plus the 13 execution tests that use DCC keys:
AlphaToCoverage,ClampedGlobalFill,DccKeyPresync,DccKeysFirstWrite,DrawWriteRanges,FillCoverKeys,LayeredVolumeSubmit,MemoryValueFill,PresentKeyWriterWait,SampleMultisampleTarget,SgprPatternFillKeys,Srgb8ColorTargetandStagedClearSampledRead. The one VUID comes fromagc_driver_srgb8_color_targeton both SHAs; it is #11990. Each run records its source SHA and the test executables' SHA-256 insource.txt.Forcing the computed clear's red channel to 0.5 makes the new test fail:
1111 fast clear: component 0 of thread 0 is 0.501961 (0x3f008081), expected 1. The 42 CTest entries ofagc_driver_graphics_testsandagc_driver_testspass on the CPU (2 GPU-only skips).Performance (Afterimage PPSA14053 01.000.000, 3840x2160).
APS5_TRACE_SECONDS=450:4(the onlyAPS5_TRACE_*/APS5_PROFILE_*switch) captures 450–454 s. The screenshots at 452 s show the same frame in every run.libSceAgcDriver.prxwere built in one build directory (mainSHA-2564d6e2ebe…, this PR46383e9d…); all other libraries andapp.exeare identical.mainm2 with PR g1, andmainm3 with PR g2. An earliermainrun (m1) hit its time cap before its trace was written and is not used.The bundled reports use non-strict comparison. From an AnyPS5 checkout, with
EVIDENCEset to the unpacked bundle directory:The timed windows have run-specific
window.first_presentvalues (6027 vs 8892, and 5975 vs 8850), so--require-matching-contextexits on that field. The recorded title, content, GPU, driver, OS, resolution andseconds 450:4window match; screenshots verify the same stationary MOVE scene. No trace dropped events:mainGraphics.Draw(draw committer) ms per frameGraphics.Drawms per frameEach window holds 47–48 presents on
mainand 70 with this PR. This is independent of #13527, which makesFillDccClearitself cheaper for the surfaces that still use it.Summary lines (pair 1
main, pair 1 PR, pair 2main, pair 2 PR):Traces, summaries, digests, comparisons, screenshots, library hashes, the harness scripts and both validation runs (
result.json,ctest.log,ctest.xml,source.txt): afterimage-gpuclear-exact-head-20261031.tar.gz, SHA-256002e2479f1bd372bab2e615b21d9e34025e9f503b4a1302390ab2cbbe38f92b7.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-30T21:40:28Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The implementation has a focused source test, but the required performance and Vulkan evidence does not establish results for the exact PR head or compare the required common tests against
main.What I ran
Reviewed head
a8202ea542c7e0d749b5b7d419b5ec5188d54712against PR base58858dfce97d2b9f997aaaf51f56199410271df0. The no-build merge preview against target tipd4de5943f6890884107de9388d9654bf30841bacwas clean. Environment: Debian 12, Linux x86-64, Python 3.11.2, Git 2.39.5, GCC 12.2.0. I did not configure, build, compile, or run C++ tests locally.Results
git diff --checkpassed with no output; conventions and PR template passed.d4de5943f6890884107de9388d9654bf30841bac; no dependency declared.tests/execution/*.cppCMake glob at the reviewed head, so this is a false positive.8691bcea00138e6275ed8bbd1685b6883a6f78fedd202250adef8622d2790116. I regenerated all four trace digests and both summary comparisons; recorded contexts match, but the candidate summary lines identifyfeb800995331, not reviewed heada8202ea542c7e0d749b5b7d419b5ec5188d54712. The Tested text separately names5ff7a60c…. All four summaries report dropped trace events.gpuclear-dccresult reports three repetitions and 87 validation-layer insertions, with three device-specific tests skipped. The bundle has no correspondingmainrun, and the result does not identify the tested source SHA.Unedited output from the checks and bundle
Test-quality helper output:
Regenerated digest headers:
Unedited output from the two
performance_compare.pycommands:The precheck itself reported
Conclusion: checks failedbecause its isolated archive lackedtools/pr_abi_audit.pyandtools/pr_test_quality.py; its diff check, conventions, and live mergeability check passed. The hosted Windows job was still pending at final refresh.Findings
Blocking
a8202ea542c7e0d749b5b7d419b5ec5188d54712, but the attached candidate summaries and regenerated digests identifyfeb800995331; the Tested text names5ff7a60c…. These are not the PR head, and neither candidate short SHA resolves in the PR head repository. Since the PR title and body make a speed claim, the repository requires a main/change capture pair with summary lines and traces from the same machine and scene. Please attach a fresh candidate capture built from the reviewed head (or the new head after your update), with its matching summary line and trace digest output. The baseline can remain if it still represents the same main build and capture context.mainand the change, then comparison for newly introduced VUIDs. The bundle contains only one DCC-key test run, does not identify its source SHA, and has nomainresult. Please run the shared DCC-key test set that exists on both revisions withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1, andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationon the same machine/GPU; attach both exact-head logs, confirm the validation layer was inserted, and report the VUID comparison. Run the newsampled_clear_keystest on the PR head as well.Non-blocking
1111, and0000keys and verifies both sampled values and the clear counter. The heuristic registration warning is resolved by the CMake glob. I found no additional source-level blocker in the inspected diff.Sources
Not verified
main/PR Vulkan validation comparison is present. I did not run hardware, console, macOS or NVIDIA tests.To get this to a good state
Update the performance and paired Vulkan validation evidence for the exact PR head, including raw commands, summaries, traces, digest output and the VUID comparison. I will rerun the same relevant no-build checks and inspect the evidence against the new head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T01:39:12Z.
Review: APPROVED
Reviewed — looks good
The exact-head performance captures and paired Vulkan logs address the earlier evidence gaps; I found no blocking source issue in the reviewed change.
What I ran
Reviewed head
a8202ea542c7e0d749b5b7d419b5ec5188d54712, based on58858dfce97d2b9f997aaaf51f56199410271df0. The precheck's current-main merge preview was clean. Environment: Debian Linux, Python 3.11.2; I did not build or compile AnyPS5.The capture and CTest artifacts were supplied by the author. I checked their SHA/source records, reran all four trace digests, and compared the UTF-8-decoded CTest logs. The reports identify Windows 11, Ryzen 9 5950X, Radeon RX 6700 XT, and AMD driver 26.10.1; I did not independently run on that machine.
Results
trace-digest.md.VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605occurs 18 times in each log.d3118d194631and exact PR heada8202ea542c7; reported p50 changes are −32.7% and −32.8%, with GPU-busy changes −10.4% and −8.5%. The recorded title, content, GPU, driver, OS, resolution and timed capture window match.Selected raw output
Negative control
agc_driver_sampled_clear_keyschecks the fast-clear sampled valueFindings
Blocking
None found in the reviewed source or the supplied exact-head evidence.
Non-blocking
--require-matching-contextcommand exits becausewindow.first_presentdiffers between timed runs. The supplied comparison reports still provide the pair metrics; please make the command reproducible by using the non-strict comparison invocation and noting that the present index is run-specific.Sources
Not verified
No local build, C++ test run, console test, or independent GPU/performance capture was performed. The GPU captures, Vulkan runs, and mutation result are author-provided; I verified the supplied revisions, digests and logs.