Repository navigation
perf(agc): serve a buffer range that crosses host import windows in place from one joined import - #22072
Conversation
…lace from one joined import A buffer range that starts inside one registered range and crosses into the next, across a host import window boundary, has no import that covers it, so every bind copied it through the CPU: a guest read that waits on the recorder's fence while holding the GPU mutex. UploadFinish now joins the adjacent registered ranges such a buffer crosses into one import and binds the buffer in place, as for any range one import covers. joinedRun accepts a buffer that starts inside the first crossed range when that range is no larger than the import window and the crossed ranges are at most two import windows longer than the buffer; a first range larger than the window keeps its own rule. The existing join path makes the import (alignment, import limit, budget and eviction, remembered failures and refusals), retires the per-window imports it overlaps, and findImport finds it on the next bind. Only non-sparse regions that are host-backed or writable take this join; a join that cannot be made leaves the range copied as before. APS5_NO_JOIN_STRADDLE=1 turns the join off. deviceLocalHasRoom no longer throws on a device without a device-local memory type; it reports no room instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This pull request is labeled |
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Windows NVIDIA check of head Setup: Windows 11 Home 10.0.26300, i9-13900K, RTX 4080 (
Every failure on the merge is on
Not checked: whether the joined import binds in place on Windows (no counter or log line checked), performance, AMD, Linux, titles. AI-assisted: yes |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
- Head reviewed:
d86f2cb161de60dee98520fee81478cdb9df64e2, basemain. - No build and no tests. The review host is Linux; the author's tests are Windows-only (MinGW).
- Read-only reader commands against the head, for example:
python3 repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp 1800 1860
python3 repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp 2325 2370
python3 repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp 6272 6300
python3 repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp 6736 6762
python3 repo_read.py cat core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp 700 724
python3 repo_read.py search deviceLocalHasRoom core/libs/prx/libSceAgcDriver
Results
| Check | Result | Note |
|---|---|---|
| Build and ctest (Windows) | not run | Author-reported only |
| Changed hunks read at head | passed | Reader, see above |
| Performance captures | not run | Author-reported, not checked |
Findings
Blocking
None.
Non-blocking
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp:6290: when no device-local memory type exists,deviceLocalHasRoomreturnsfalsebefore it storescheckedMs. The 250 ms throttle is then skipped, and the memory properties are queried on every call for that device. The case is unlikely on real hardware, so this is cosmetic.
Not verified
- The Windows test run and the two performance captures (author-reported; I did not run them).
- Driver behaviour of joined imports on NVIDIA and Windows, which the reader cannot show. The debt entry names the 8 MiB window as a choice that is not measured on RADV.
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp:2897: the newcoveredloop inspaceReadAcrossImportsTestsassumesAddressRanges()returns ranges in address order. I did not check that.- The overlap with #5372, #15658 and #22064 and the rebase order. I did not check those PRs.
- Files read:
GuestBufferMemory.cpp(changed hunks and their callers at head, through the reader),BdaResources.cpp(changed hunks and the setup it uses),ENVIRONMENT.mdandperf-agc-join-straddling-imports.md(from the diff). Excluded: none.
To get this to a good state
Nothing is required.
Optional: clear checkedMs (or return before the throttle check) in the no-device-local branch of deviceLocalHasRoom, and check the ordering of AddressRanges() in the new test loop.
kurexw
left a comment
There was a problem hiding this comment.
Tested on macOS 27.2 on an Apple M4. This is an x86-64 build under Rosetta with Apple clang 21.0.0, on MoltenVK 1.4.2 from the LunarG Vulkan SDK 1.4.363.1.
Method. The base was main at a72186d plus #22056 and #22074, which fix the macOS build of two other targets; both have since merged. I built the base and this PR merged onto it (a clean merge) in two separate build directories. I ran them alternately, base then PR, with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation and VK_LOADER_DEBUG=layer: three runs each. The pattern adds the tests named in the description to the BDA and graphics tests:
ctest --test-dir build -R '^agc_driver_graphics$|^agc_driver_bda_|^agc_bda_|^agc_graphics_profile_draw$|^agc_changed_copy|^agc_driver_host_import_|^agc_driver_partial_resident_alias$' -V
| base (3 runs) | This PR (3 runs) | |
|---|---|---|
| Passed | 22 of 23 | 22 of 23, the same tests |
agc_graphics_profile_draw (runs importJoinTests) |
Passed | Passed, with the PR's new straddling-buffer case |
agc_driver_host_import_windows |
Passed | Passed |
agc_driver_host_import_dma_buf_watch |
Skipped | Skipped |
| Layer inserts per run | 23 | 23 |
was not found but was requested |
0 | 0 |
VUID- lines |
16, all VUID-VkDeviceCreateInfo-sType-unique |
16, the same |
The 16 sType-unique lines come from device creation and appear on the base as often as with the PR, so this PR adds no validation errors.
Negative control. I kept this PR's test and restored the base's GuestBufferMemory.cpp. Then agc_graphics_profile_draw fails with a buffer bound from inside the first of two pieces no larger than the import window across the import window boundary was not joined and bound in place. So the join path runs on macOS: MoltenVK's host import accepts the joined range on the M4.
Not tested: the speed claim, since I have no title or capture here. I also didn't try APS5_NO_JOIN_STRADDLE=1.
|
Thanks @nicolasabosch. I have reviewed #22072 at d86f2cb and will cross-test that bounded policy rather than open a competing PR for my broad The fresh plain-main 007 run is still in startup: import audit resolves all 748 imports (zero absent/stub imports), but a warm run reaches a black saving screen and waits on an NVIDIA pipeline compilation. Bounded samples of the busy compiler thread are in nvgpucomp64.dll; no title data is uploaded. I will finish that guarded run before building the cross-test, and report exact heads and whether your straddling path covers the finite view. No FPS claim yet. AI-assisted: Codex. |
|
Windows RTX 5070 Ti cross-test of d86f2cb, cleanly merged onto main d642b4e as dbca313. Windows 11 Pro 10.0.26200, Ryzen 7 7800X3D, NVIDIA 617.42, WinLibs GCC 15.2 Release. Required Vulkan, shader cache disabled, Khronos validation explicitly requested, loader diagnostics enabled, portable layer 1.4.363. Five focused tests, three runs each on main and the merge:
Main: 15/15 pass. Merge: 15/15 pass. No skips; seven confirmed validation-layer insertions per run; no missing-layer warnings, VUIDs or SYNC-HAZARDs on either side. I added synthetic-only regressions on my fork, head 39828de: https://github.com/Scramblrrrr/AnyPS5/tree/codex/straddling-import-native-nov17 . The production change is yours unchanged. These cover a finite interior view crossing three small owners, overlapping growth to five owners, alternating-view reuse, a coherent pair in one build, owner removal, and native GPU byte readbacks with descriptor extent/offset checks. The synthetic fixture explicitly uses writable memory for your restricted path; an initial read-only snapshot fixture was outside that scope and was corrected before these results. Extended fixtures: another 15/15 pass, no skips and no validation errors. With exactly the same test executables, This covers my previous large-interior synthetic access shape under your bounded policy. I am holding the broader WIP rule rather than opening a competing production PR. No 007 performance or gameplay claim: my separate plain-main runtime is still limited by startup compilation and memory pressure. No game code, captures or raw logs are uploaded. AI-assisted: yes (Codex). |
…e-local type and sort ranges in the join test deviceLocalHasRoom now records the check time and no room before it returns on a device with no device-local memory type, so the 250 ms throttle holds there too instead of querying the memory properties on every call. The read-only V# test sorts the build's address ranges before walking them for coverage, so it does not depend on the order AddressRanges returns. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings
The changed hunks show no verified defect, but the review is incomplete: no build or test was run, and the full GuestBufferMemory.cpp was not read, so this is a comment, not an approval.
Nothing blocks this; the points below are optional.
What I ran
Exact head: 61cc86904ef77b8f1273d43fa415962453761763, base main. No build, no ctest, no validation-layer run. I read the run folder (description.md, commits.md, manifest.json, diff.patch, files.json) and the house rules, then read repository code at the head with repo_read.py:
repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp 1800 1850
repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp 1675 1690
repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp 6268 6302
repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp 6750 6765
repo_read.py search "hostBacked" core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
repo_read.py search "HostImportOffset" core/libs/prx/libSceAgcDriver
repo_read.py search "HostImportFor(" core/libs/prx/libSceAgcDriver/tests
Files read: GuestBufferMemory.cpp through its changed hunks in diff.patch and the ranges above, not the whole file (8124 lines, excluded from the run folder for size). tests/BdaResources.cpp, docs/dev/ENVIRONMENT.md and the debt fragment through their changed hunks in diff.patch; I did not open their full copies in files/. No file was excluded by rule.
Results
| Check | Result | Note |
|---|---|---|
| Changed hunks read | passed | all four files in files.json |
| Head code read | passed | ranges only, listed above |
Build and ctest |
not run | author reports 8/8 and 17/17 |
| Validation layer | not run | author reports no VUID- error |
| Performance captures | not run | author reports, not checked |
Findings
Blocking
None verified.
Non-blocking
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp:6290: on a device with no device-local memory type,deviceLocalHasRoomreturnsfalsefor everybytes, including0. The normal path returnsbytes <= room, which istruefor0when room is0. This branch also leavesliveShadowLimitat its previous value. Impact looks small; I did not check whether any caller passes0.
Sources
joinedRunwith the straddle clause:AnyPS5/core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
Lines 1837 to 1847 in 61cc869
continuesRun:AnyPS5/core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
Lines 1675 to 1677 in 61cc869
deviceLocalHasRoom:AnyPS5/core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
Lines 6275 to 6302 in 61cc869
UploadFinishjoin loop:AnyPS5/core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
Lines 6756 to 6761 in 61cc869
- Straddle test:
AnyPS5/core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
Lines 708 to 718 in 61cc869
Not verified
- No build or test was run. The
ctest, validation-layer and performance figures in the description are the author's; I did not confirm them. GuestBufferMemory.cppwas read only in the ranges above. Callers ofjoinedRunandimportJoinedoutside those ranges were not checked.continuesRunchecks readable, writable and gpu, but not host-backed. The straddle gate inUploadFinishchecks only the target region. I did not confirm whether a host-backed read-only region can join a neighbour that is not host-backed.- The debt clause is delivered through the new fragment. I did not check how the fragment is merged into the main host-imports entry.
- The Windows alias behaviour described in the debt text was not verified.
To get this to a good state
Nothing is required.
To move this to APPROVE, the next review needs the full GuestBufferMemory.cpp read, and the author's build and ctest output for head 61cc86904ef7 attached.
…y like the normal path On a device with no device-local memory type, deviceLocalHasRoom now records no room and the staging shadow limit of an empty heap, then answers through the same bytes <= room check as the normal path, so a 0-byte request gets the same answer on both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the review. Pushed Build and test output for head
|
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
- Head
58ef1c564bd48f92de6e100278b24af38fe64ff1, basemain. No merged-preview check. - Read the description, the commit list, the manifest and the diff from the review folder, then the changed regions at head with the repository reader:
python3 repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp 1800 1850
python3 repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp 2320 2375
python3 repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp 6266 6280
python3 repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp 6730 6770
python3 repo_read.py cat core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp 2860 2884
python3 repo_read.py search HostImportOffset core/libs/prx/libSceAgcDriver
python3 repo_read.py search hostBacked core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
python3 repo_read.py search shadowBytesLimit core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
python3 repo_read.py search "include <optional>" core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
- No build and no test run in this review.
Results
| Check | Result | Note |
|---|---|---|
| Changed hunks and their callers | passed | read at head, see What I ran |
| Performance table arithmetic | passed | percentages recompute from the figures given |
| Unit tests named in the description | not run | author-reported, Windows and MinGW |
| Validation layer run | not run | author-reported |
| Performance captures | not run | author-reported, traces not opened |
Findings
Blocking
None.
Non-blocking
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp:1845: the straddle bound compares againstend - begin.importJoinedmay widenendfirst (GuestBufferMemory.cpp:2335,end = high->base + high->bytes), so for a buffer that ends inside a joined import the allowed run is larger than "buffer plus two windows" in the description. The run stays bounded, so this is not a defect shown. Confirm that the wider bound is intended, or take the bound from the originalend.- The description says this change and #5372 both edit the
joinedRuncheck, and that the merge order must be agreed with its author. That is coordination, not a code defect.
Not verified
- Build and tests: none run here. The
agc_*test runs, theAPS5_NO_JOIN_STRADDLE=1negative control and the validation-layer run are author-reported. - Performance: the table arithmetic is consistent, but the captures and traces were not opened or reproduced. The second capture comes from another machine.
GuestBufferMemory.cppis 8124 lines. I read the changed hunks and the functions they call (joinedRun,crossedRun,importJoined,importRunAt,deviceLocalHasRoom, and the join loop inUploadFinish). How the join interacts withrefreshImports, budget eviction andfailedJoinswas not traced.deviceLocalHasRoomwith no device-local memory type: room is 0 and the shadow limit falls back to the default inshadowBytesLimit. Checked by reading; not run.- The definition of the
dissolvedImportscounter was not checked.HostImportOffsetis declared inGuestBufferMemory.hpp. - The new debt fragment was not compared with the other files in
docs/dev/debt/changes/. - #5372 was not read.
Sources
- Repository paths at
58ef1c564bd4:GuestBufferMemory.cpplines 1837–1847, 2333–2344, 6283–6299, 6756–6760;tests/BdaResources.cpplines 708–715 and 2878–2903. No permalinks are given.
To get this to a good state
Nothing is required.
Optional:
- Confirm the intended bound at
GuestBufferMemory.cpp:1845whenendwas widened. - Agree the merge order with #5372 and rebase whichever PR merges second.
Files: all four files in the reviewed list were covered. GuestBufferMemory.cpp was read in the ranges above, BdaResources.cpp by its diff and lines 2860–2884, and ENVIRONMENT.md and the debt fragment by their diff only. Nothing was excluded.
|
Ran the Tested section's tests with the Khronos validation layer on Linux and an NVIDIA GPU; the earlier NVIDIA runs are on Windows. Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release, NVIDIA GeForce RTX 4090 (vendor
No new AI-assisted: yes (Claude Code) |
…ned join span The straddle clause of the host-imports debt entry now says what joinedRun compares against: the buffer widened by importJoined to the whole of any joined import it starts or ends in, not the buffer alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks. The wider bound is intended: |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
- Head
4e740bb21f360a6f4685df024b96eeedd4602909(basemain), PR #22072, 4 files in the review folder. - Read the description, commit list, manifest,
files.jsonanddiff.patchfrom the review folder. - Read the changed code at head with the repository reader (
repo_read.py catonGuestBufferMemory.cpplines 1820–1850, 6270–6305, 6740–6760;repo_read.py searchforjoinedRun,shadowBytesLimit,HostImportOffset,memoryTypeCount,hostBacked,#include <optional>). - No build, no test run, no hosted CI check in this pass.
Results
| Check | Result | Note |
|---|---|---|
| Diff read | passed | four files, all changed hunks |
| Code paths at head | passed | join rule, room check and import pass match the description |
| Tests run here | not run | the test counts in the description are the author's |
| Perf captures | not run | numbers are author- and third-party-reported |
| Hosted CI | not run | head checks not inspected |
Commands
repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp 1820 1850
repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp 6270 6305
repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp 6740 6760
repo_read.py search shadowBytesLimit core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
repo_read.py search HostImportOffset core/libs/prx/libSceAgcDriver
repo_read.py search memoryTypeCount core/libs/prx/libSceAgcDriver
repo_read.py search hostBacked core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
Findings
Blocking
None.
Non-blocking
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp:6292— when no memory type is device-local, the new branch setsliveShadowLimittoshadowBytesLimit(0), which returns 256 MiB at head. The description says only that the check "reports no room". The room is 0, so nothing is staged there, but the shadow limit is a separate value. Say what it should be, or name the reason for 256 MiB.core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp:1845— the straddle rule reads correctly against the description: the first crossed range is at most one window, and the run is capped at the widened span plus two windows. No defect found, but the cap has no test that sits exactly at the boundary.
Not verified
- The build and the tests named in the description (8/8, 17/17, the validation-layer runs) were not run here. They are the author's results.
- The performance numbers and traces, from two machines, were not reproduced. The traces are external links that I did not open.
- Hosted CI for head
4e740bb21f36was not inspected. GuestBufferMemory.cppis 8124 lines. I read the changed hunks and the three ranges above, not the whole file. Where the diff's changed regions depend on helpers outside those ranges, I relied on the reader searches.- The four files were read through
diff.patch. I did not open their full texts infiles/. - The overlap with #5372 was not checked. I have no access to that PR from here.
- The NVIDIA driver and Windows alias behaviour in the debt fragment (
docs/dev/debt/changes/perf-agc-join-straddling-imports.md) was not verified.
To get this to a good state
Nothing is required.
Optional: state the shadow limit used when no device-local memory type exists (see the non-blocking point above). Rerun the listed tests on the next head, if the head changes.
Reviewed — changes requestedThis PR removes checks that keep stale graphics state and bad guest pointers out of the host. Several sync and descriptor paths can now skip needed waits or invalidations. Fourteen findings block merge. What I ran
Results
FindingsBlocking
Non-blocking
Not verified
To get this to a good stateFix the fourteen blocking findings first. Restore checked guest writes in the Render, resolver, and user-name exports. Restore the GCN conversion for table image words on both table paths. Make |
|
Current-head Windows cross-test: canonical I also ported the earlier test-only regressions onto this current stack. They can be cherry-picked separately from the heap work:
Both are public on codex/gpu-heap-imports-nov17. Only At that test-only head, five affected controls x 3 pass 15/15, four actual layer insertions/run, no skips or validation identifiers. With only RTX 5070 Ti, NVIDIA 617.42, Windows 11 26200, WinLibs GCC 15.2 r7, Release, SPIRV Tools OFF; pinned headers 1.4.340 and validation 1.4.363. |
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
Nothing blocks this change; the reviewed code supports the intended straddling import behavior, and the author-reported checks provide supporting evidence.
What I ran
Head reviewed: 7099836106bb93eb24928c11fc042b4a27f36658. I inspected the prepared diff and targeted source through repo_read.py; no commands or tests were run.
Results
| Check | Result | Note |
|---|---|---|
| Diff and changed code | passed | Targeted paths inspected |
| Tests | not run | Results in the description are author-reported |
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full text of core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp was excluded because it was too large for the review folder. I read targeted ranges covering the changed join logic, import creation, device-local room check, and UploadFinish call site. The other changed files were read at their changed sections: core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp, docs/dev/ENVIRONMENT.md, and docs/dev/debt/changes/perf-agc-join-straddling-imports.md. Tests, performance captures, and physical console behavior were not independently verified; the description reports the test and capture results.
To get this to a good state
Nothing is required.
|
One scope check on the changes-requested review above, to separate independent concerns from changes introduced by this PR. I compared both reviewed head
All fourteen blocking findings in that review cite files outside this topic diff (WaitMemory, GuestMemory, Texture, MultisampleTarget, Font, Net, UserService, ResourceMaterializer and SpirvEmitterHelpers). The current head's merge base with main is My earlier exact-head native and lifetime/offset/readback checks remain the evidence for the join itself. No new test pass is claimed for the fourteen separate findings. AI-assisted: yes. |
|
Windows 11 23H2 (22631), Ryzen 7 5700X, NVIDIA RTX 4060 (driver 616.56), WinLibs GCC 15.2.0 r7, Release, merged into All 53 tests the change reaches pass. |
What
A buffer range that starts inside one registered range and crosses into the next, across a host import window boundary, has no import that covers it, so
maincopies it through the CPU on every bind: a guest read that waits on the recorder's fence while holding the GPU mutex.UploadFinishnow joins the adjacent registered ranges such a buffer crosses into one import and binds the buffer in place, as for any range one import covers.joinedRunaccepts a buffer that starts inside the first crossed range when that range is no larger than the import window and the crossed ranges are at most two import windows longer than the span being joined (run.bytes <= end - begin + 2 * window). That span is the buffer, widened byimportJoinedto the whole of any joined import it starts or ends in, as for every join, so a buffer that ends inside an existing joined import is measured up to that import's end. This is intended: the new join replaces that import, so it must cover it. A first range larger than the window keeps the rule from perf(agc): join a buffer bound from inside a range larger than the import window into the small ranges after it #15658, whose test (a buffer bound from inside a range larger than the import window across more than a window of small ranges was joined) still passes.findImportfinds it on the next bind. Only non-sparse regions that are host-backed or writable take this join; a join that cannot be made leaves the range copied as before.APS5_NO_JOIN_STRADDLE=1turns the join off (newENVIRONMENT.mdrow).deviceLocalHasRoomno longer throws on a device without a device-local memory type; it reports no room instead.docs/dev/debt/changes/perf-agc-join-straddling-imports.md.Overlap: #5372 relaxes the same
joinedRuncheck for a buffer bound from inside a range (begin == run.base || run.bytes <= window) and edits the same assertion inimportJoinTests. The two rules differ: #5372 caps the joined run at one window and also widensimportJoinedto non-joined neighbouring imports; this change keeps the widening as it is and bounds the run by the buffer's size plus two windows. Whichever merges second needs a rebase on these lines; the order is to be agreed with its author.Tested
Windows 11 Pro, MinGW (GCC, Release), NVIDIA GeForce RTX 4070 Laptop GPU.
ctest -R '^(agc_graphics_profile_draw|agc_bda_staging.*|agc_changed_copy.*|agc_driver_host_import_windows|agc_driver_host_import_alias_failure|agc_driver_partial_resident_alias)$'passed (8/8). After review (61cc869):deviceLocalHasRoomkeeps its 250 ms throttle on a device with no device-local memory type, and the read-only V# test sorts the address ranges before checking coverage; the same 8 tests pass, with the validation layer and noVUID-error, andagc_driver_graphicsand theagc_driver_bda_*tests pass too (17/17).agc_graphics_profile_drawruns the BDA import-join tests:importJoinTestsnow binds 32 bytes from 16 bytes before the end of one 64 KiB piece into the next and requires one joined import over both pieces, bound in place with nothing copied;spaceReadAcrossImportsTeststakes a third build and requires the read-only V# across two imports to be bound in place at its offset in the joined import without dissolving the cached address space. WithAPS5_NO_JOIN_STRADDLE=1,agc_graphics_profile_drawfails (1 run): "a buffer bound from inside the first of two pieces no larger than the import window across the import window boundary was not joined and bound in place".Validation layer: the same tests on
main(ec9f142) and on this branch withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,VK_LOADER_DEBUG=layer,ANYPS5_NO_SHADER_CACHE=1andANYPS5_REQUIRE_VULKAN=1throughctest -V(Khronos validation layer 1.4.363.1): every log showsInsert instance layer "VK_LAYER_KHRONOS_validation"(11 times in each), none reportswas not found but was requested by env var VK_INSTANCE_LAYERS, and neither run logs aVUID-error.Performance (captured by @Logan1h on Windows 11, Ryzen 5 7500F, RTX 4070 SUPER, NVIDIA 621.24; paired 60 s captures of the same practice fight in EA SPORTS UFC 6 (PPSA23566, 01.004.000),
mainvs this change; traces andtrace_digest.pyoutputs attached):Traces and
trace_digest.pyoutputs (both traces reporttrace_droppedafter the queue-worker event buffer fills; the summary lines, phase totals and import counters are complete):b7aeb6f406with read-only diagnostics: event trace, digestThe GPU-busy increase comes from direct host-import reads replacing the CPU-side copies.
Second capture, of this port (with the guard for #15658's rule), on another machine (NVIDIA GeForce RTX 4070 Laptop GPU, driver 616.92, Intel Core i9-14900HX, Windows 11 Pro 26300): one 60 s capture each with
APS5_TRACE_SECONDS=660:60, warm shader caches, same scripted practice fight of EA SPORTS UFC 6 (PPSA23566, 01.004.000). Both builds aremain2a8a0d1 plus the pad-script commit of #22064, which only injects the scripted input.mainseconds 660:60 from present 11012: 55 presents, frame p50 1004.2 / p90 1086.4 / p99 5716.0 / max 5716.0 ms, GPU busy 288.6 ms per presentseconds 660:60 from present 12256: 173 presents, frame p50 327.7 / p90 356.0 / p99 394.0 / max 3685.6 ms, GPU busy 286.3 ms per presentTraces and
trace_digest.pyoutputs:main: trace, digest; this change: trace, digest.aps5-summary.jsonllinesmain:
{"commit":"241bfd31f250","dirty":false,"env":{"APS5_LAZY_SHADER_PREPARE":"1","APS5_PAD_SCRIPT":"<path>","APS5_TRACE_SECONDS":"660:60"},"gpu":"NVIDIA GeForce RTX 4070 Laptop GPU","driver":"NVIDIA 616.92","os":"Windows 10.0.26300","cpu":"Intel(R) Core(TM) i9-14900HX","cpu_threads":32,"memory_mib":32543,"title_id":"PPSA23566","title":"EA SPORTS™ UFC® 6","content_version":"01.004.000","resolution":"1920x1080","window":{"spec":"seconds 660:60","first_present":11012,"ms":60290.998},"presents":55,"frame_ms":{"p50":1004.223,"p90":1086.447,"p99":5716.009,"max":5716.009},"gpu_busy_ms_per_present":288.557,"worker_busy_pct":{"queue worker 0x0":98.497,"queue worker 0x29":9.422,"queue worker 0x2a":9.638,"queue worker 0x2b":9.261,"queue worker 0x2c":9.156,"queue worker 0x2d":9.287,"queue worker 0x2e":9.069,"queue worker 0x2f":9.205,"queue worker 0x28":14.485},"phase_totals_ms":{"Driver.Completion":1.369,"Driver.Dispatch":46604.504,"Driver.Dispatch.capture_resources":329.533,"Driver.Dispatch.decode_key_device_setup":1032.629,"Driver.Dispatch.lookup_cache":25.702,"Driver.Dispatch.materialize":85.816,"Driver.Dispatch.prepared_invocation":200.01,"Driver.Draw":43300.605,"Driver.Draw.device_setup":176.166,"Driver.Draw.draw_enqueued":39186.962,"Driver.Draw.post_compile_prepare":29.268,"Driver.Draw.prepare":542.715,"Driver.Draw.shader_compile_and_link":3092.764,"Driver.EndSubmission":131.14,"Driver.Packet":107197.022,"Driver.Packet.device_lock":90.675,"Driver.Packet.dispatch":46238.381,"Driver.Packet.draw":43359.308,"Driver.Packet.execute":4144.494,"Driver.Packet.flip_flush":1.678,"Driver.Packet.flush_between_packets":279.296,"Driver.Packet.memory_wait":12276.403,"Driver.Packet.pipeline_drain":135.683,"Driver.Packet.pipeline_prepare":119.436,"Driver.Packet.prepare_memory":147.483,"Driver.Packet.rendering_wait":0.044,"Driver.Present":160.045,"Driver.Present.acquire_image":0.671,"Driver.Present.device_setup":0.036,"Driver.Present.gpu_mutex_wait":0.397,"Driver.Present.inflight_wait":0.152,"Driver.Present.present_display_buffer":6.623,"Driver.Present.queue_present":23.361,"Driver.Present.release_and_callback":0.099,"Driver.Present.render_fence_wait":128.474,"Driver.Present.resize":0.17,"Driver.Present.validate":0.021,"Driver.Suspend":0.007,"GpuMutex.wait.dispatch":579.319,"GpuMutex.wait.draw":34467.577,"GpuMutex.wait.end":193.154,"GpuMutex.wait.fill":0.144,"GpuMutex.wait.flush":8.82,"GpuMutex.wait.hook":87.515,"GpuMutex.wait.indirect":1.69,"GpuMutex.wait.label":257.307,"GpuMutex.wait.other":17.339,"GpuMutex.wait.present":0.275,"GpuMutex.wait.wait":0.082,"Graphics.Draw":8776.731,"Graphics.Draw.draw_and_resource_release":8097.741,"Graphics.Draw.index_upload":349.797,"Graphics.Draw.validate":255.887,"Graphics.Draw.vertex_upload":30.893,"Graphics.DrawWithRecipe":24.054,"Graphics.DrawWithRecipe.draw_and_resource_release":23.52,"Graphics.DrawWithRecipe.index_upload":0.033,"Graphics.DrawWithRecipe.validate":0.247,"Graphics.DrawWithRecipe.vertex_upload":0.164,"Recorder.Reap":480.593,"Recorder.Submit":349.225,"Recorder.Sync":18536.37,"Recorder.WaitSerial":173.32,"Resources.Complete":41250.476,"Resources.Prepare":357.457,"Shader.DrawStage":2721.353,"Shader.DrawStage.capture_resources":1865.394,"Shader.DrawStage.materialize":529.432,"Shader.DrawStage.prepared_invocation":301.8,"Shader.PrepareArtifact":99.091,"Shader.ResolveAbi":11.236,"Shader.ResolveGraphicsAbi":15.284,"Shader.ResolveGraphicsStagesAbi":68.194,"VideoOut.Flip":162.068,"VideoOut.Flip.completion_mutex_wait":0.057,"VideoOut.Flip.config_mutex_wait":0.013,"VideoOut.Flip.frame_limit":0.049,"VideoOut.Flip.notify_game":0.773,"VideoOut.Flip.present":157.94,"VideoOut.Flip.validate":0.1,"VideoOut.Flip.vblank_wait":0.049,"VideoOut.Flip.window_prepare":0.107,"VideoOut.Flip.window_title":2.949,"VideoOut.Readiness":0.111,"VideoOut.Readiness.locks_validate":0.052,"Vulkan.Acquire":0.609,"Vulkan.Acquire.acquire_fence_wait":0.104,"Vulkan.Acquire.acquire_image":0.345,"Vulkan.Acquire.fence_reset":0.118,"Vulkan.Acquire.retired_swapchains":0.023,"Vulkan.ComputePipeline":1178.179,"Vulkan.Dispatch":41751.997,"Vulkan.Dispatch.command_record":302.137,"Vulkan.Dispatch.shader_resources":41440.951,"Vulkan.DispatchRecipe":49.353,"Vulkan.DispatchRecipe.command_record":49.075,"Vulkan.DrawFromRecipe":24.222,"Vulkan.GraphicsPipeline":3884.937,"Vulkan.GraphicsPipeline.create":3720.114,"Vulkan.GraphicsPipeline.modules_and_state":5.692,"Vulkan.GraphicsPipelineLibrary":3699.446,"Vulkan.GraphicsPipelineLink":0.068,"Vulkan.GraphicsPipelinePrebuild":160.695,"Vulkan.Present":5.044,"Vulkan.Present.command_record_scale":1.813,"Vulkan.Present.pixel_upload":0.189,"Vulkan.Present.queue_submit":3.0,"Vulkan.QueuePresent":23.274,"Vulkan.QueuePresent.queue_present":23.187,"Vulkan.Retire":128.451,"Vulkan.Retire.wait":127.082},"top_phases_ms_per_frame":{"Driver.Packet":1949.037,"Driver.Dispatch":847.355,"Driver.Packet.dispatch":840.698,"Driver.Packet.draw":788.351,"Driver.Draw":787.284,"Vulkan.Dispatch":759.127,"Vulkan.Dispatch.shader_resources":753.472,"Resources.Complete":750.009},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.copy":275,"Graphics.Barrier.dispatch-lead":37292,"Graphics.Barrier.dispatch-trail":41021,"Graphics.Barrier.draw":63780,"Graphics.Barrier.fill":1370,"Graphics.Barrier.indirect-args":5775,"Graphics.Barrier.input-mirror":12722,"Graphics.Barrier.label-run":31300,"Graphics.Barrier.present-blit":110,"Graphics.Barrier.shadow-publish":2684,"Graphics.Barrier.staging-in":19227,"Graphics.Barrier.staging-out":10104,"Graphics.Barrier.storage-upload":6220,"Graphics.Barrier.storage-writeback":15193,"Graphics.Barrier.template-refresh":112,"Graphics.BarrierMerged.dispatch-lead":15279,"Graphics.BarrierMerged.fill":280,"Graphics.BarrierMerged.label-run":46,"Graphics.BarrierMerged.shadow-publish":2598,"Graphics.BarrierMerged.staging-in":12750,"Graphics.BarrierMerged.staging-out":10104,"Graphics.BarrierMerged.storage-writeback":5707,"Graphics.Copy":49189,"Graphics.Copy.bytes":4693849204,"Graphics.RenderPass":29821,"Graphics.RenderPass.Close.command":24136,"Graphics.RenderPass.Close.image":207,"Graphics.RenderPass.Close.key":694,"Graphics.RenderPass.Close.label":46,"Graphics.RenderPass.Close.new-batch":4738,"Graphics.RenderPass.Continued":214387},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":43.573,"events_lost":105056,"totals_full":false}},"trace":"aps5-trace-241bfd31f250-56360.json.gz"}this change:
{"commit":"951c551bc9aa","dirty":false,"env":{"APS5_LAZY_SHADER_PREPARE":"1","APS5_PAD_SCRIPT":"<path>","APS5_TRACE_SECONDS":"660:60"},"gpu":"NVIDIA GeForce RTX 4070 Laptop GPU","driver":"NVIDIA 616.92","os":"Windows 10.0.26300","cpu":"Intel(R) Core(TM) i9-14900HX","cpu_threads":32,"memory_mib":32543,"title_id":"PPSA23566","title":"EA SPORTS™ UFC® 6","content_version":"01.004.000","resolution":"1920x1080","window":{"spec":"seconds 660:60","first_present":12256,"ms":60007.258},"presents":173,"frame_ms":{"p50":327.693,"p90":355.977,"p99":393.988,"max":3685.623},"gpu_busy_ms_per_present":286.305,"worker_busy_pct":{"queue worker 0x0":97.075,"queue worker 0x29":6.129,"queue worker 0x2a":5.75,"queue worker 0x2b":5.647,"queue worker 0x2c":5.564,"queue worker 0x2d":5.997,"queue worker 0x2e":6.017,"queue worker 0x2f":6.119,"queue worker 0x28":6.414},"phase_totals_ms":{"Driver.Completion":5.105,"Driver.Dispatch":21000.758,"Driver.Dispatch.capture_resources":1033.387,"Driver.Dispatch.decode_key_device_setup":8231.868,"Driver.Dispatch.lookup_cache":79.466,"Driver.Dispatch.materialize":195.253,"Driver.Dispatch.prepared_invocation":128.629,"Driver.Draw":25465.232,"Driver.Draw.device_setup":502.835,"Driver.Draw.draw_enqueued":13010.736,"Driver.Draw.post_compile_prepare":95.599,"Driver.Draw.prepare":1422.206,"Driver.Draw.shader_compile_and_link":8936.42,"Driver.EndSubmission":74.439,"Driver.Packet":86757.596,"Driver.Packet.device_lock":279.236,"Driver.Packet.dispatch":20886.213,"Driver.Packet.draw":25630.148,"Driver.Packet.execute":16601.845,"Driver.Packet.flip_flush":4.597,"Driver.Packet.flush_between_packets":713.768,"Driver.Packet.memory_wait":20839.432,"Driver.Packet.pipeline_drain":445.837,"Driver.Packet.pipeline_prepare":363.48,"Driver.Packet.prepare_memory":457.171,"Driver.Packet.rendering_wait":0.127,"Driver.Present":622.309,"Driver.Present.acquire_image":2.023,"Driver.Present.device_setup":0.084,"Driver.Present.gpu_mutex_wait":0.923,"Driver.Present.inflight_wait":0.37,"Driver.Present.present_display_buffer":22.243,"Driver.Present.queue_present":69.773,"Driver.Present.release_and_callback":0.276,"Driver.Present.render_fence_wait":526.15,"Driver.Present.resize":0.297,"Driver.Present.validate":0.042,"Driver.Suspend":0.025,"GpuMutex.wait.dispatch":1440.778,"GpuMutex.wait.draw":1463.771,"GpuMutex.wait.end":41.721,"GpuMutex.wait.fill":1.473,"GpuMutex.wait.flush":7.316,"GpuMutex.wait.hook":62.989,"GpuMutex.wait.indirect":2.001,"GpuMutex.wait.label":63.899,"GpuMutex.wait.other":0.415,"GpuMutex.wait.present":0.617,"GpuMutex.wait.wait":0.224,"Graphics.Draw":24298.114,"Graphics.Draw.draw_and_resource_release":22491.769,"Graphics.Draw.index_upload":873.097,"Graphics.Draw.validate":730.447,"Graphics.Draw.vertex_upload":83.563,"Graphics.DrawWithRecipe":1228.21,"Graphics.DrawWithRecipe.draw_and_resource_release":1227.011,"Graphics.DrawWithRecipe.index_upload":0.077,"Graphics.DrawWithRecipe.validate":0.501,"Graphics.DrawWithRecipe.vertex_upload":0.395,"Recorder.Reap":269.959,"Recorder.Submit":594.874,"Recorder.Sync":1289.406,"Recorder.WaitSerial":1.813,"Resources.Complete":1529.767,"Resources.Prepare":5108.823,"Shader.DrawStage":7831.879,"Shader.DrawStage.capture_resources":5773.837,"Shader.DrawStage.materialize":1257.134,"Shader.DrawStage.prepared_invocation":723.537,"Shader.ResolveAbi":8.495,"Shader.ResolveGraphicsAbi":4.62,"Shader.ResolveGraphicsStagesAbi":33.547,"VideoOut.Flip":633.815,"VideoOut.Flip.completion_mutex_wait":0.202,"VideoOut.Flip.config_mutex_wait":0.02,"VideoOut.Flip.frame_limit":0.088,"VideoOut.Flip.notify_game":3.402,"VideoOut.Flip.present":619.439,"VideoOut.Flip.validate":0.154,"VideoOut.Flip.vblank_wait":0.09,"VideoOut.Flip.window_prepare":0.342,"VideoOut.Flip.window_title":9.921,"VideoOut.Readiness":0.34,"VideoOut.Readiness.locks_validate":0.15,"Vulkan.Acquire":1.856,"Vulkan.Acquire.acquire_fence_wait":0.303,"Vulkan.Acquire.acquire_image":1.077,"Vulkan.Acquire.fence_reset":0.307,"Vulkan.Acquire.retired_swapchains":0.11,"Vulkan.Dispatch":3191.183,"Vulkan.Dispatch.command_record":740.064,"Vulkan.Dispatch.shader_resources":2425.451,"Vulkan.DispatchRecipe":95.959,"Vulkan.DispatchRecipe.command_record":95.192,"Vulkan.DrawFromRecipe":1228.706,"Vulkan.GraphicsPipeline":3341.821,"Vulkan.GraphicsPipeline.create":3339.881,"Vulkan.GraphicsPipeline.modules_and_state":1.928,"Vulkan.GraphicsPipelineLibrary":3339.71,"Vulkan.GraphicsPipelineLink":0.072,"Vulkan.Present":17.294,"Vulkan.Present.command_record_scale":5.809,"Vulkan.Present.pixel_upload":1.804,"Vulkan.Present.queue_submit":9.541,"Vulkan.QueuePresent":69.54,"Vulkan.QueuePresent.queue_present":69.265,"Vulkan.Retire":526.052,"Vulkan.Retire.wait":522.385},"top_phases_ms_per_frame":{"Driver.Packet":501.489,"Driver.Packet.draw":148.151,"Driver.Draw":147.198,"Graphics.Draw":140.452,"Graphics.Draw.draw_and_resource_release":130.01,"Driver.Dispatch":121.392,"Driver.Packet.dispatch":120.73,"Driver.Packet.memory_wait":120.459},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.copy":1730,"Graphics.Barrier.dispatch-lead":112832,"Graphics.Barrier.dispatch-trail":126670,"Graphics.Barrier.draw":156041,"Graphics.Barrier.fill":4329,"Graphics.Barrier.indirect-args":18165,"Graphics.Barrier.input-mirror":22081,"Graphics.Barrier.label-run":89268,"Graphics.Barrier.present-blit":346,"Graphics.Barrier.shadow-publish":3846,"Graphics.Barrier.staging-in":55934,"Graphics.Barrier.staging-out":33831,"Graphics.Barrier.storage-upload":17572,"Graphics.Barrier.storage-writeback":32467,"Graphics.Barrier.template-refresh":235,"Graphics.BarrierMerged.dispatch-lead":50168,"Graphics.BarrierMerged.fill":863,"Graphics.BarrierMerged.label-run":506,"Graphics.BarrierMerged.shadow-publish":3812,"Graphics.BarrierMerged.staging-in":46816,"Graphics.BarrierMerged.staging-out":33831,"Graphics.BarrierMerged.storage-writeback":12224,"Graphics.Copy":137616,"Graphics.Copy.bytes":16620575032,"Graphics.RenderPass":74879,"Graphics.RenderPass.Close.command":60657,"Graphics.RenderPass.Close.image":667,"Graphics.RenderPass.Close.key":1745,"Graphics.RenderPass.Close.label":506,"Graphics.RenderPass.Close.new-batch":11304,"Graphics.RenderPass.Continued":704660},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":13.956,"events_lost":804261,"totals_full":false},"draw committer":{"events_full_after_s":45.686,"events_lost":72982,"totals_full":false}},"trace":"aps5-trace-951c551bc9aa-43844.json.gz"}Checklist
main; no other open PR implements the same functions (perf(agc-driver): join a buffer bound from inside a range across the ranges it crosses #5372 changes the samejoinedRuncheck; see What)NotImplemented_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)🤖 Generated with Claude Code