Repository navigation
perf(agc): reuse unchanged depth layers with source invalidation - #22
Draft
p3n1cillin wants to merge 3 commits into
Draft
p3n1cillin wants to merge 3 commits into
p3n1cillin wants to merge 3 commits into
Conversation
Sampling a depth surface as a 2D array, a cube or its integer bits copies its planes into a per-use image. Each use read every slice no depth surface holds from guest memory and detiled it again, even when nothing had written it since: in one level of a heavier title that was about 165,000 layer reads, about 650 GiB, in a five-minute run. A slice read from guest memory now stays in the copy's staging buffer with the write generation it was read at. The next use reads and detiles it again only when its address, size or tiling changed, the write tracker reports a write since, or recorded GPU work writes the range; a slice a depth surface held in between is read again. Without write watching every use reads, as before.
Sampling a depth array, cube or R16_UINT view of depth surfaces went through DepthPlaneCopy::Refresh on every use. Each use copied every slice a depth surface holds into the staging buffer and the whole staging buffer into the copy image, with three ALL_COMMANDS barriers, although nothing had written the slices since the previous use. Each depth surface now carries a write serial, bumped when a draw binds it as its depth target, when a pending fast clear is applied and when a storage image's writes are transferred into it. The copy keeps the image and serial of every slice it copied. A use copies only the slices whose surface or serial changed and the guest layers that changed (as before), and records nothing when none did. A slice whose surface is the depth target of the latest depth draw is copied at every use until another depth target is bound, since that draw may still be recorded after the copy. Test: agc_driver_depth_plane_guest_layers counts the recorded slice copies and copy fills; a second use with nothing written records none (it records one of each without this change), a draw to a slice's surface or a CPU write to a guest layer copies only that layer.
This was referenced Oct 10, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Repeated sampling of a mixed resident/guest depth array uploaded and detiled every guest layer and copied the entire array on every use. The measured ASTRO BOT boot had a 1536x1536, 16-layer array with 14 guest layers: 126 MiB per refresh, often 59 refreshes in one slow frame. The preceding six-minute profile accumulated 2,517,557,575,680 guest-upload bytes and 124.211 s in the CPU guest-upload stage across 19,055 refreshes.
Integrates upstream #2490, commit
5f0e7304189174bbfc033f37138b06ed15e4e77a, and #2491, commit8085ddae5d8326194483da312e50ed9a3d96c702, onto the local ASTRO BOT integration stack. Preserves their authorship, caller buffer-pool reuse, kept-upload byte accounting and the existing CPU/GPU profiling. Unchanged guest layers retain their detiled contents; unchanged resident slices use their write serial; partial copies preserve the other image layers. Unwatched guest ranges retain per-use reads.Native tests exposed three additional invalidation gaps, addressed here:
PAGE_NOACCESSmust be read as zeros rather than reuse its former pixels. Reuse now includes the guest mapping generation and mip layout identity.Validation on Windows, GCC 15.2, NVIDIA RTX 5070, driver 617.42:
34e1ebc06cf63a45, format 26.Measured ASTRO BOT PPSA21564 v01.007.000 run at e105fc2, RTX 5070 / driver 617.42, 16 GiB host imports, profiling enabled, preserved shader namespace and pipeline cache. Six-minute timed boot/title diagnostic; the monitor intentionally stopped it at the deadline. No builds or tests overlapped the game. All game/collector/monitor processes are terminal.
The candidate uploaded the 14 guest layers once (132,120,576 bytes), then reused them through 74,567 depth refreshes across 2,043 measured frames containing that metric. Recorded only 8,172 array updates. Late GPU staging-in class reports were 1.81-1.84 ms/present, versus 244-338 ms/present in the previous capture; these are inclusive class timings, not exclusive attribution to this function.
Shader cache: 1,831 hits, zero misses/writes. No fatal abort, device loss, BDA fault, presentation failure, alternate-heap allocation or host-pool reclamation report. The captured final image is the ASTRO BOT title with PRESS ANY BUTTON; diagonal banding remains.
One run per build; matching frame counters do not control animation position or run-to-run variance. Entire-run averages include startup and differing time spent in each stage. Full-game completion, correct graphics/audio, controller progression, saves, stable 60 FPS and other-title runtime regression testing remain unverified. The next performance work is CPU draw recording/resource validation and frequent recorder waits now exposed after removing repeated depth transfers.
Linux validation of this local integration remains pending; upstream reports Linux testing of its changes.
Depends on #21. This is a draft integration PR in the personal fork. Original upstream commits are by Dean Galvin; conflict resolution, invalidation guards and expanded tests are AI-assisted. Private game assets, frame captures and diagnostic dumps are excluded from source control and public records.