Repository navigation
perf(agc): write back a storage image spanning adjacent registered ranges on the GPU through each range's import - #5522
Conversation
CnRJay
left a comment
There was a problem hiding this comment.
This is the right fix for the cost #5321 exposes. A spanning image shouldn't pay a GPU→CPU round trip (copy out, wait for the queue, store on the CPU) when each piece has an import it can be copied into on the GPU. 119–158 such round trips per 10 s, at 2.4–3.3 GiB, is exactly the kind of hidden sync that keeps queue 0 from overlapping with the GPU.
Notes from reading the diff:
- The retry in
importSegmentsonly re-checks imports, not registrations.piecescomes fromRegisteredReadableCoversonce, outside the retry loop, whileHostImportsIdentity/HostImportsUnchangedonly prove that the imports didn't change. AGuestAllocationsmutation between the coverage walk and the copy (a range unregistered and reused while its import survives) is the case #5321 guards against with the drop. Taking the coverage walk inside the same attempt, or under the same proof, would close that window. Onmainthe single-import path has the same gap in principle, so this may not need to block, but the split path makes it more likely because it does more lookups. - When
segments.size() == 1,paddingSeeds(segments, ...)forwards to the single-import overload, butwriteBackWindowsstill allocatesimportCopiesas a vector of vectors and searches segments for every piece. That's negligible per write-back, just noting that the unchanged case now runs the general code too. - Per-segment
MarkShadowedfiltersshadowedbyrange.beginonly. A shadowed range that starts in one segment and ends in the next would be marked under the first import only. If the unit-alignment rule (no split inside a 64 KiB unit while unit shadows are on) guarantees this can't happen, aRequirethere would document it.
For the numbers: the table was measured with an earlier form of the correctness part and on an older bring-up base. Once #5321 lands, the aps5-summary.jsonl lines of main + #5321 against main + #5321 + this, from the same RoN scene with traces, would isolate this change. The current runs combine both.
|
Intel run for this PR: Intel UHD Graphics 770 (Raptor Lake iGPU of an i9-13900K), driver 32.0.101.6129, Windows 11, MinGW-w64 GCC 15.2.0 Release, device picked with
AI-assisted (Claude Code). |
adriadam10
left a comment
There was a problem hiding this comment.
This now conflicts with main: #5321 is merged, and #5760 (fix(agc): save the bytes a GPU-side store writes outside the write watch) changed the same code. The conflicts are not mechanical:
StorageTexture::writeBackWindows(Texture.hpp/Texture.cpp): main added theBuffer* saveparameter and thesavescopies from the tiled scratch; this PR replacesconst HostImport&withstd::span<const ImportSegment>andpaddingSeeds(segments, copied). Both signatures and the finalcopyBufferblock need to be combined, including the save copy next to the per-segment import copies.writeBackLayers, thesettlelambda: main'sadvances/MarkShadowed(*shadowImport, ...)version and this PR'sallKept/markShadowed(now)version differ in when the generation advances. Please say which behaviour should hold with pieces from several imports.- The block-less path (
copiestoimport->buffer) now also hassaveUnits/savedBytes, which have to work when the image spans several imports.
Could you rebase onto current main, keep #5760's save path working for the split pieces, and rerun agc_storage_split_writeback plus the agc_driver_* tests? A case in splitWriteBackTests with a spanning image outside the write watch would pin that combination.
…nges on the GPU through each range's import
53a4c00 to
ea3a215
Compare
|
@adriadam10 thanks, done in ea3a215, rebased onto
@CnRJay your two points are in the same head:
|
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
|
adriadam10
left a comment
There was a problem hiding this comment.
Re-checked ea3a215: the combination with #5321/#5760 is correct (writeBackWindows takes the segments and the Buffer* save, the save copies come from the same scratch at the image's own offsets, shadow marking is per segment). Build and the libSceAgcDriver ctest are green on lavapipe; the only red is agc_driver_tessellation (segfault), which also fails on main. agc_storage_split_writeback passes and fails with the non-test changes reverted. Not covered here: the RoN frame-rate numbers (Windows, RX 7900 XTX). Merging once the full Build is green.
Main now carries boykopovar#4450, boykopovar#4475 and Pipodi's pointer-in-record table columns (c794273), which replace our copies and our record-pointer columns; boykopovar#5181, boykopovar#5989, boykopovar#5906, boykopovar#5484 (live snapshot mismatches serve live bytes; our retry is dropped), boykopovar#5483, boykopovar#5522, boykopovar#4732, boykopovar#5792. Kept local: the two-lane wave64 hang fixes, boykopovar#5815, option 1 substitutes, image-table stores and set 0 tables, stencil remap, 10_11_11 blending, the VRAM share/spill, block-hash snapshots, diagnostics. Versions: disk FormatVersion 42, RuntimeAbi 17, request serializer v30, BdaAbi UnnormalizedWrap 11 / DirectImage 12. Notes in work/sync-20261013/*-3.md. AI-assisted: yes
What
With #5321, a storage image whose memory spans adjacent registered ranges is written back instead of dropped. No single host import covers such an image, so its write-back takes the CPU path: the driver copies the image out, waits for the queue and stores the changed bytes on the CPU. This change writes it back on the GPU through each range's own import, the way an image inside one import already is. On my Ready or Not bring-up build, an older base with other local changes, these CPU write-backs went from 119-158 per 10 s to none, and the frame rate from 2.17-2.53 to 3.00-3.33 FPS.
Requirestates.Tested
Windows 11 Pro 10.0.22631, Ryzen 7 7800X3D, RX 7900 XTX, WinLibs GCC 15.2.0, Release, on
maina050f85.splitWriteBackTestsintests/Recorder.cpp(ctestagc_storage_split_writeback): a 200x150 RGBA8 image over two adjacent registered ranges is cleared on the GPU and written back, and every texel has to land with no other byte changed. It runs with 3 mips split at 128 KiB, off a 64 KiB boundary split at 132 KiB, as a linear surface, and over two adjacent allocations, all through the GPU; and on the CPU path, with a second range of other access and with a split inside a 64 KiB unit while unit shadows are on.ctest -R "^agc_": 541 of 547 pass and 4 skip.agc_driver_layered_volume_vertex_no_gplandagc_driver_recorderfail, as they do onmaina050f85 on this GPU.Linux: not run.
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)