perf(agc): clear a storage image on the GPU when its guest memory holds one repeated pattern #24445
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/24445"
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 LeandroLP23 on 2026-11-20T16:35:25Z.
What
rep stoson the CPU every frame, so every frame took two 8 MiB uploads read from the host import, about 3.5 ms of GPU time on an RTX 5060 Ti. (Its two tiled 8-byte targets are filled by a non-temporalmemset32loop too, but reach the upload as partial uploads, which this change does not cover.)StorageTexture::uploadnow clears the image on the GPU when, for a whole-image upload of an uncompressed surface, the guest memory holds one 16-byte pattern from the first byte to the last. It is the path a DCC fast clear already takes: the clear is recorded into the open batch and counted as aclearupload.FillClearColorturns the pattern into the clear value and refuses a pattern a clear would not reproduce bit for bit; the scan stops at the first differing word, so a surface that is not uniform costs one short read. A uniform surface is read in full on the draw committer: in the same SuperTuxKart race (a run ofmain6bedd8e28dwith this change, #10442 and #24869 merged), that is 640 to 660 us per 8 MiB target on the i5-10600K (DDR4, about 13 GB/s), measured with a temporary counter, against about 1.75 ms of GPU time for the upload it replaces.APS5_NO_FILL_UPLOAD_CLEARuploads as before (ENVIRONMENT.md).DccKeysFirstWritegetsRunUniformFillClear: a surface without DCC keys filled with one texel must take the clear path and a surface with one other texel must not, both on unwatched and write-watched memory, and the written-back texels are checked in both cases.tools/pr_overlap.py --branchreports no overlapping open pull request.Tested
Windows 11 (10.0.26300), NVIDIA GeForce RTX 5060 Ti (NVIDIA 621.24), Intel i5-10600K, WinLibs GCC 15.2.0 r7, Release.
ctest -R '^agc_driver_dcc_keys|^agc_driver_graphics$|^agc_sampled_import_pieces$|^agc_driver_recorder$' -VwithANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer(layer 1.4.363), onmain7fa48cd1c6and with this change: 10 of 10 pass on both, the layer inserted in every log, nowas not found but was requested, 0VUID-lines.SuperTuxKart (PPSA69421) tutorial race, driving straight from the start (title_run with a pad timeline: Yes on the tutorial prompt, then cross held after the start), 10 s trace window 80 s after the first present (
APS5_TRACE_SECONDS=80:10),tools/trace_digest.py.main84e16538d4, then the same commit with this change, alternating it withAPS5_NO_FILL_UPLOAD_CLEAR=1on that build:GPU time per present drops by about 3.5 ms in every pair; frame p50 on
mainis bound by the draw committer waiting inRecorder.Sync, so it moves less and is noisy. WithAPS5_PROFILE_GPU=1on the same scene (three interleaved pairs on a stack of #7464, #10442 and #23866), thestorage-uploadclass goes from 4.0 uploads and 6.6 ms per present to 2.0 uploads and 2.9 ms, and twodcc-clearentries of 0.01 ms appear in their place; the two remaining uploads are partial uploads of tiled surfaces, which this change leaves alone. Working set and private bytes are unchanged (3.3 / 5.1 GB).Summary lines for the comparison, same scene and settings, one run each on real commits: the merge base
089d2df72eand this branch's headfd16189a6b. GPU busy 20.1 -> 16.7 ms per present, 156 -> 170 presents, frame p50 60.4 -> 52.6 ms.main (
089d2df72e):this PR (
fd16189a6b):Not run: the whole CTest suite, other titles, AMD and Intel GPUs. The traces (
aps5-trace-*.json.gzof the main and first change run) are available on request.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)Summary by CodeRabbit
APS5_NO_FILL_UPLOAD_CLEARsetting, which keeps matching uploads on the guest-memory upload path when enabled.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T17:29:17Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head
5ef62c622255c697087e29db34a235b8b5f37cdd. I read the supplied diff and targeted source ranges usingrepo_read.py; I did not run commands or tests.Results
Findings
Blocking
None.
Non-blocking
RunUniformFillClearverifies the upload-clear counter but does not assert that the nonuniform case took the CPU upload path. Its texel checks catch incorrect output, but an explicit upload-outcome check would make the regression test more directly confirm the intended path (core/libs/prx/libSceAgcDriver/tests/execution/DccKeysFirstWrite.cpp:598).Not verified
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpporcore/libs/prx/libSceAgcDriver/tests/execution/DccKeysFirstWrite.cpp; targeted ranges covered the changed lines and relevant helper logic. I read the changed line indocs/dev/ENVIRONMENT.md.core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp,core/libs/prx/libSceAgcDriver/tests/execution/DccKeysFirstWrite.cpp, anddocs/dev/ENVIRONMENT.md. Excluded: none.To get this to a good state
Nothing is required. Optionally assert that the nonuniform test case records a CPU upload.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T20:01:01Z.
Review: COMMENTED
Reviewed — no blocking findings
The change is coherent at the reviewed head, but I could not run the reported checks, so a formal approval is not justified.
What I ran
Reviewed head
fd16189a6b8e26ee8686254b3c8f844d9ada86f1using the prepared diff andrepo_read.pyfor targeted source context. No commands or tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The reported CTest runs, GPU performance traces, other titles, and AMD and Intel GPUs were not independently verified. Read:
Texture.cpp(changed lines and relevant clear logic),DccKeysFirstWrite.cpp(all changed lines and test context), andENVIRONMENT.md(changed line). No changed files were excluded from review;Texture.cppwas read throughrepo_read.pybecause it was too large for the prepared folder.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by throny on 2026-11-22T07:10:22Z.
Review: CHANGES_REQUESTED
GPU test run: ❌ five existing tests fail with this change
Basis: built and ran · head
fd16189a6bmerged ontomain851212fb98· Windows 11 Pro 26300, RTX 4080 (10de:2704, driver 610.88), WinLibs GCC 15.2.0 r7, Release ·ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1, Khronos validation layer (nightly 1.4.369)Checked
agc_*teststools/select_tests.pyselects: 1959 passed with this PR, 1966 onmain(the remainingmainfailure is the known #22670 flake). 0VUID-messages either way.mainagc_depth_copy_kept_bytesagc_driver_storage_guest_copy_releaseagc_driver_color_memo_fallback_enabled/_disabled/_verifyagc_driver_draw_recapture_on_changeFindings
agc_depth_copy_kept_bytes:AGC graphics: missing Vulkan function: vkCmdClearColorImage. The new GPU clear inTexture.cppasks the context for a function that this test's context doesn't provide, so the path needs to fall back (or the function table needs the entry) where it isn't available.agc_driver_storage_guest_copy_release:the CPU-path upload kept no copy of the guest bytes (0 of 1048576 bytes). Taking the GPU-clear path seems to skip the guest copy that later release logic relies on.agc_driver_color_memo_fallback_*:the reconciled color image lost the aliased depth write on readback. A pattern-filled guest range that also holds an aliased depth write is cleared instead of uploaded.Suggested action: limit the GPU clear to images whose guest bytes are only the repeated pattern and that keep no CPU copy, and fall back to the upload when
vkCmdClearColorImageisn't available.AI-assisted test run (Claude Code) · head
fd16189a6b· basemain851212fb98Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T11:54:05Z.
Review: APPROVED
Reviewed — looks good
The uniform-fill clear path and its guards look sound based on the inspected code; the author reports the targeted tests passed, but I did not run them.
What I ran
Reviewed head
4596847d38e6837fd6ea80598f18ed06ffc0ec15and the prepared diff withrepo_read.py. No tests or builds were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Texture.cppwas too large to include in the review folder, so I read only the changed regions and relevant helpers through the pinned reader. I read the full included text ofDccKeysFirstWrite.cppandENVIRONMENT.md; their changed sections and related fixture code were inspected. No files were excluded by any rule infiles.json(that file was not available through the reader). The full test suite, other titles, non-Windows platforms, and AMD/Intel GPUs were not verified. Performance results and test outcomes in the PR description are author-reported.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T17:42:26Z.
Review: COMMENTED
Reviewed — no blocking findings
The reviewed change has no verified blocking defects; the targeted code review is complete, but runtime checks were not run here.
What I ran
Reviewed head
5767085cb3add5923a826d0054f31ce7deb176bcusing the prepared review bundle and pinned repository reader. No commands or tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Runtime tests, the full test suite, other titles, and non-NVIDIA hardware were not verified. The full text of
Texture.cppwas excluded from the review folder due to size; its changed lines and relevant surrounding functions were read throughrepo_read.py. Read the changed code inTexture.cpp,DccKeysFirstWrite.cpp, andENVIRONMENT.md; no changed file was omitted from targeted review.To get this to a good state
Nothing is required. Optional: run the reported targeted CTest checks on this exact head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T04:32:57Z.
Review: APPROVED
Reviewed — looks good
Nothing in the inspected code establishes a blocking defect; the fast path is restricted to resident Windows guest memory, refuses pending writes and overlapping images or shadows, and only clears patterns with an exact format conversion.
What I ran
Reviewed head
c3a69af33ca540e6d7211cf534b28e8ccd5858d5. I read the prepared description, commit list, manifest, complete diff, review folder README, and the changed lines indocs/dev/ENVIRONMENT.md,DccKeysFirstWrite.cpp, andTexture.cpp. I also read targeted code inGuestMemory.cppandWindowsMappings.hppfor accessibility and residency behavior, plus the clear conversion and pending overlap logic inTexture.cpp.No commands or tests were run. The author reports Windows 11 Vulkan validation and performance runs in the description; those results were not reproduced here.
Results
Findings
Blocking
None found in the inspected code.
Non-blocking
None.
Not verified
The full
Texture.cppand full test file were not read; only relevant ranges and all changed lines were reviewed. No build, CTest, GPU, or console behavior was independently verified.files.jsonwas not available in the review folder; the folder README and manifest show the changed-file inclusion state. Performance measurements and test results in the PR description are author-reported.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T14:46:14Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the reviewed code supports the described optimization, with platform and full-suite coverage remaining unverified.
What I ran
Reviewed head
a0fdb582eee3b3948b576290c55967f82ed228b1usingrepo_read.pyreader tools. No tests or builds were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Tests, builds, full CTest suite, and behavior on non-Windows platforms or other GPUs were not run. The PR description reports targeted Windows/NVIDIA tests and measurements; these were not independently verified. Read:
Texture.cppchanged lines and relevant upload/helper code;GuestArena.hpp,GuestArena.cpp,GuestMemory.cpp,Recorder.hpp; changed sections inDccKeysFirstWrite.cpp; changed environment table inENVIRONMENT.md;description.md,commits.md,manifest.json, anddiff.patch. Excluded: no repository source file was excluded from this review;files.jsonwas unavailable as a separate document, so exclusion information was taken frommanifest.jsonand the reader's file listing. The full 8,797-lineTexture.cppand 1,498-line test file were not read in full.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T05:37:54Z.
Review: APPROVED
Reviewed — looks good
The reviewed changes at
e9e2649b200b893b599475d08e22fffd6878a2a0have no verified blocking defects; the uniform-fill clear is limited to eligible resident memory and preserves upload behavior when its safety checks fail.What I ran
No commands or tests were run. The author reports the CTest subset and performance measurements in the PR description; those results were not independently verified.
Files read:
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp(affected upload and helper ranges),core/libs/prx/libSceAgcDriver/tests/execution/DccKeysFirstWrite.cpp(affected fixture, test, and call-site ranges), anddocs/dev/ENVIRONMENT.md(the setting entry). Also readdescription.md,commits.md,manifest.json,files.json, anddiff.patch. No changed files were excluded by the supplied file rules.Results
Negative control
Not run. The added test covers a resident uniform surface and a resident surface with one differing texel; its execution was not independently verified.
Findings
Blocking
None.
Non-blocking
None.
Sources
Texture.cppat the reviewed commitDccKeysFirstWrite.cppat the reviewed commitENVIRONMENT.mdat the reviewed commitNot verified
The full
Texture.cppand test file were not read beyond the relevant ranges. The reported tests and performance results, other titles, other GPU vendors, and the full CTest suite were not independently verified.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-03T05:39:38Z.
Review: COMMENTED
Actionable comments
902a295d-868b-419a-969b-b0d3e8b51e4bReviewing files that changed from the base of the PR and between
cde48b5800ande9e2649b20.core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/execution/DccKeysFirstWrite.cppdocs/dev/ENVIRONMENT.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-03T08:47:50Z.
Review: COMMENTED
Actionable comments
a2a3f536-4de9-4bcf-96fa-bfc02ee64c92Reviewing files that changed from the base of the PR and between
e9e2649b20and415f1c383e.core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/execution/DccKeysFirstWrite.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T08:55:35Z.
Review: COMMENTED
Reviewed — no blocking findings
The changed upload path checks for a whole, resident, uniform surface before clearing it on the GPU; helper semantics and runtime behavior remain unverified.
What I ran
Reviewed head
415f1c383e329f76c5da852cf29c39473f49b009. I read the prepared diff for all three changed files and used the pinned reader forTexture.cpplines 3860–3985. No tests or builds were run; the test results in the PR description are author-reported.Results
Negative control
Not run; no assertion or change to the code under test was made.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
The full
Texture.cppfile and implementations of the called memory and recorder helpers were not read. Tests, other titles, and non-NVIDIA hardware were not verified.files.jsonlists no excluded changed files.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-03T09:35:20Z.
Review: COMMENTED
Actionable comments
filledPatternfrom the words that the scan checked.f0871b3f-b482-43e3-86fe-1eb294ae3e96Reviewing files that changed from the base of the PR and between
415f1c383eandfdecd4016c.core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T10:00:13Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
Reviewed head
fdecd4016c0ce35f635f9ac8de1850c078c16d5fagainst basemain; no merged-preview check. I used the pinned reader for targeted source inspection. No compiler or tests were run. The performance and test results below are author-reported.Results
Negative control
Not run; I did not alter the code or execute tests.
Findings
Blocking
None.
Non-blocking
Sources
FillClearColorcan reproduce. Changed upload path,FillClearColor.Not verified
Texture.cpp,DccKeysFirstWrite.cpp, andENVIRONMENT.md, plus helper and policy context inGuestBufferMemory.cpp,GuestMemory.cpp,AGENTS.md,CONTRIBUTING.md, and the performance report form. The manifest lists no excluded files. Unchanged portions outside the relevant ranges were not read.To get this to a good state
Nothing is required. As an optional follow-up, attach the trace files for the exact baseline and change captures so the performance report can be inspected.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-03T10:36:14Z.
Review: COMMENTED
Actionable comments
930aae5c-a1fe-457c-be46-30abd5d3b081Reviewing files that changed from the base of the PR and between
fdecd4016cand4d31222404.core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T11:01:10Z.
Review: COMMENTED
Reviewed — no blocking findings
I reviewed the prepared diff and the included test and documentation files; the full
Texture.cppsource was unavailable, so a formal approval is not justified.What I ran
Reviewed head
4d31222404bb12a6f23504e6afa7a7a85ad1ff98. I readdescription.md,commits.md,manifest.json,diff.patch,files.json, the changed sections ofDccKeysFirstWrite.cpp, and the changed section ofENVIRONMENT.md. I attempted to readTexture.cppwith the pinned reader, but its logging failed because the workspace is read-only. I did not run tests or builds.Results
Negative control
Not run; no tests were executed.
Findings
Blocking
None verified in the material read. The full implementation source was not available for review.
Non-blocking
None.
Sources
Not verified
The complete
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppimplementation was not read.DccKeysFirstWrite.cppanddocs/dev/ENVIRONMENT.mdwere read from the review folder;Texture.cppwas only available through the prepared diff. No files were excluded by the manifest rule list. Tests, other titles, and hardware behavior were not independently verified; performance and test results in the description are author-reported.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T21:46:06Z.
Review: COMMENTED
The repeated-fill path scans live guest bytes after collecting the write generation and then records both CPU baselines from the selected pattern. Please verify that the range stayed unchanged across the scan before accepting the clear, or document the ownership invariant that supplies that guarantee. The new uniform and last-texel-different cases use a stable fill and would not cover a concurrent ordinary guest write. The paired first-write fixture is queued on lavapipe. The reported performance result is from the author's RTX 5060 Ti run.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-04T01:37:21Z.
Review: COMMENTED
Actionable comments
61328d0e-8b07-429e-aaa0-364276ee16c0Reviewing files that changed from the base of the PR and between
4d31222404and246e0e98db.core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-04T02:04:14Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the inspected implementation and regression coverage support merging.
What I ran
Reviewed head
246e0e98db1b61fb905b2c6c27ae0ef13c4acb57usingrepo_read.pyat the pinned head. I inspected the changed upload logic and its clear-color, resident-memory, pending-overlap, and generation helpers; the changed test fixtures and cases; and the environment setting entry. I did not run tests or builds.Results
Negative control
Not run; the negative control is part of the compiled test, and tests were not run.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
The whole CTest suite, behavior on other titles and GPUs, and non-Windows behavior were not run or confirmed.
Texture.cppwas read in relevant ranges; the changed hunks and relevant context were inspected. The changed test and documentation hunks and relevant context were inspected. No files were excluded by the supplied review rules. The description's reported test and performance results were not independently reproduced.To get this to a good state
Nothing is required.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.