Skip to content

perf(agc): record unimported labels in large allocations through a 64 KiB import window - #26718

Merged
oneandonlydean merged 15 commits into
boykopovar:mainfrom
root-over:perf/agc-label-imports
Nov 25, 2026
Merged

oneandonlydean merged 15 commits into
boykopovar:mainfrom
root-over:perf/agc-label-imports

Conversation

@root-over

@root-over root-over commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

What

Since #7464 a queue-0 label whose guest memory no host import covers syncs the recorder and is stored on the CPU (WriteLabelOnGpu reason 7). That keeps the small blocks #7464 measured (mapped every frame, 64 KiB or less) from being imported for their labels. A label in a large allocation that the host import budget refuses takes the same path, so each one waits for every batch in flight.

Cult of the Lamb (PPSA06465) on a Renoir APU hits this in gameplay: the budget there is 586 MiB, the title's labels land in 16 MiB and 4 MiB allocations the budget refuses, and Recorder.Sync takes 63.3 ms of the draw committer per frame (trace below). The labels are few (64 in 130 s in a counting build, in 12 allocations), but each one drains the GPU.

This PR imports a 64 KiB window of such an allocation for the label and records the label on the GPU:

  • importWindowBounds and windowRun take the window as a parameter (default unchanged).
  • A new ImportRequester::Label ("label" in the host import report). WriteLabelOnGpu requests it before taking reason 7; when the window imports, the label is recorded on the GPU as a covered label is.
  • The window is max(64 KiB, hostImportAlignment). An allocation no larger than the window gets no label import, so perf(agc): keep unimported label stores on the CPU #7464's small blocks keep the CPU path unchanged.
  • Label windows are outside the host import budget, its eviction and the remembered refusals (the budget refuses a window exactly when it refused the allocation): their bytes, retired ones still pinned included, are left out of the pinned total the budget compares, the budget's eviction (evictableBytes, retireLeastRecent) skips them, and a normal import that replaces a label window gets no credit for its bytes. They have a limit of their own: at most 16 MiB of windows are live. Past it, the least recently used label window that the import eviction rule would let go (not held by a build, not used in this or the previous frame) is retired and rewatched as retireLeastRecent does; when none can go, the label keeps reason 7.
  • HostImportCounts::labelBytes reports the live window bytes (; 1.5 MiB of label windows in the report).

agc_driver_label_import_window (and its _draw_pipeline / _plan_verify variants) leaves an unregistered 64 KiB gap after each of its blocks, so no import of one block covers the next, and checks that a label in a 1 MiB allocation over the budget is recorded on the GPU (reason 0) through exactly one 64 KiB window and lands without touching its neighbours; that a label in a 64 KiB allocation still returns reason 7 without importing; that labels fill the windows to 16 MiB, that a label past the limit keeps reason 7 while every window is held, and that after a build the least recently used window is retired (and rewatched as before), the newer ones stay and every label lands; and that with the windows full, a normal import within the budget is made without retiring the earlier normal import or a label window; and that a normal import over the budget that would replace a label window, with APS5_IMPORT_RETIRE_CREDIT on, does not leave normal imports over the budget.

#26384 also imports labelled memory, after a mapping outlived three flips, through the budgeted HostImportFor. On this machine it does not change Cult of the Lamb (table below), since the budget still refuses these allocations; the two changes touch the same line of WriteLabelOnGpu and should compose (a settled mapping imports through #26384, a refused large one through its window).

Tested

Ubuntu 26.04 (Linux 7.0.0-43), GCC 15.2.0, Release, Ryzen 5 5625U, AMD Radeon Graphics (RADV RENOIR, gfx90c), Mesa 26.0.8, on main e68be05111.

GPU tests, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer, validation layer 1.4.341, ctest -R '^agc_driver_(graphics|label_import_window.*|unimported_label_order.*|same_queue_label_wait.*|cpu_label_wake|label_.*|host_import_.*)$' -V:

main e68be05111 this branch b1c9409abd
Result 21 of 21 pass 24 of 24 pass (the 21 and the three new tests)
Insert instance layer "VK_LAYER_KHRONOS_validation" 30 33
was not found but was requested by env var VK_INSTANCE_LAYERS 0 0
VUID- 0 0

The whole ^agc_ suite (2064 tests) under the same layer on an earlier head of this branch (5bb725a05f, before the retire rule took the import eviction rule and the rewatch): 2063 pass, 1921 layer inserts, 0 VUID-; the failure is agc_driver_cvt_f32_f64_denormal_result, which fails on main on this GPU (#26142). Every commit builds on its own and the new test passes from the commit that adds it.

Negative controls, each a local revert of one rule, agc_driver_label_import_window:

  • without the Label request in WriteLabelOnGpu: a label in an allocation over the import budget was not recorded on the GPU (reason 7)
  • without the small-allocation rule: a label in an allocation no larger than a window did not keep its CPU path (reason 0)
  • without the 16 MiB limit: a label past the limit while every label window is held did not keep its CPU path (reason 0)
  • without the retire: a label past the limit was not recorded on the GPU once older windows were released (reason 7)
  • with label windows counted in the normal budget (the previous head d71f6b1da4): cannot record work on a fresh allocation (the normal import is refused)
  • with label windows counted as replaced bytes (d2d884ab94): label bytes were credited to a normal import over the normal budget

python3 tools/check_conventions.py --base origin/main and python3 tools/debt_fold.py --check pass.

Cult of the Lamb (PPSA06465, 01.000.023), 1920x1080, the same converted title and save each run; a recorded pad route (APS5_PAD_REPLAY) goes from the title screen into gameplay, 150 s per run, the numbers are the mean over the 10 s intervals from 90 s (gameplay). Runs alternate the arms by swapping the build's libs directory.

Arm Commit FPS per run mean frame p50 ms
this PR d71f6b1da4 10.70, 10.76, 10.47, 10.32, 10.16, 10.23 10.44 92.8 – 98.1
main e68be05111 8.68, 8.33 8.51 115.7 – 120.4

After the budget fix (d2d884ab94), a batch in round order against the previous head and main (the second main run crashed in the game, a guest free() at app.elf+0x1697553, before the measured window, and is left out):

Arm Commit FPS per run mean frame p50 ms
this PR d2d884ab94 12.40, 12.41, 12.05, 12.43 12.32 80.2 – 81.8
previous head d71f6b1da4 12.18, 12.55 12.37 79.5 – 82.2
main e68be05111 10.68 10.68 93.3

All arms run faster in this batch than in the one above (the machine, not the code: main is the same build); the gap between this PR and main is 15 % here and 23 % above.

An earlier batch in round order (this PR's previous head 5bb725a05f, which differs only in the retire path these runs never reach, at most 12 windows here), with #26384's head 81f6333f36 merged into the same main (c9b670179e, local merge); a first round that ran while a build was compiling is left out:

Arm FPS per run mean
this PR (5bb725a05f) 10.41, 10.19, 10.22 10.27
main 9.20, 8.33, 9.05 8.86
main + #26384 8.46, 8.90, 8.47 8.61

Traces, summary lines and digests, SHA-256 3ce8f74d236b733486d4f4e9d5433a6adb54c2ab69847a372765a519a05cd337.

Performance report

One run each with APS5_TRACE_SECONDS=100:10 (gameplay), same machine, route and build as above, main first.

Summary lines (main, this PR)
{"commit":"e68be05111f4","dirty":false,"env":{"APS5_PAD_REPLAY":"<path>","APS5_TRACE_SECONDS":"100:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"AMD Radeon Graphics (RADV RENOIR)","driver":"radv Mesa 26.0.8-1ubuntu0.3","os":"Linux 7.0.0-43-generic","cpu":"AMD Ryzen 5 5625U with Radeon Graphics","cpu_threads":12,"memory_mib":14780,"title_id":"PPSA06465","title":"Cult Of The Lamb","content_version":"01.000.023","resolution":"1920x1080","window":{"spec":"seconds 100:10","first_present":2621,"ms":10042.602},"presents":84,"frame_ms":{"p50":119.804,"p90":123.244,"p99":129.290,"max":129.290},"gpu_busy_ms_per_present":63.116,"worker_busy_pct":{"queue worker 0x0":98.658},"phase_totals_ms":{"Driver.Completion":1.665,"Driver.Dispatch":4988.975,"Driver.Dispatch.decode_key_device_setup":4885.676,"Driver.Dispatch.lookup_cache":2.243,"Driver.Draw":2941.627,"Driver.Draw.device_setup":109.802,"Driver.Draw.draw_enqueued":1280.234,"Driver.Draw.post_compile_prepare":94.856,"Driver.Draw.prepare":172.870,"Driver.Draw.shader_compile_and_link":1253.254,"Driver.EndSubmission":104.649,"Driver.Packet":9801.417,"Driver.Packet.device_lock":16.526,"Driver.Packet.dispatch":4990.045,"Driver.Packet.draw":2961.952,"Driver.Packet.execute":331.258,"Driver.Packet.flip_flush":0.379,"Driver.Packet.flush_between_packets":64.388,"Driver.Packet.memory_wait":2.121,"Driver.Packet.pipeline_drain":272.948,"Driver.Packet.pipeline_prepare":33.930,"Driver.Packet.prepare_memory":32.337,"Driver.Packet.rendering_wait":0.351,"Driver.Present":106.706,"Driver.Present.acquire_image":12.392,"Driver.Present.device_setup":0.134,"Driver.Present.gpu_mutex_wait":2.841,"Driver.Present.inflight_wait":0.486,"Driver.Present.present_display_buffer":28.040,"Driver.Present.queue_present":7.895,"Driver.Present.release_and_callback":0.172,"Driver.Present.render_fence_wait":54.172,"Driver.Present.resize":0.283,"Driver.Present.validate":0.083,"Driver.Suspend":0.052,"GpuMutex.wait.draw":0.663,"GpuMutex.wait.end":2.356,"GpuMutex.wait.fill":62.483,"GpuMutex.wait.flush":0.010,"GpuMutex.wait.label":3.033,"GpuMutex.wait.other":0.270,"GpuMutex.wait.present":2.383,"Graphics.Draw":2514.812,"Graphics.Draw.draw_and_resource_release":1640.947,"Graphics.Draw.index_upload":362.057,"Graphics.Draw.validate":116.269,"Graphics.Draw.vertex_upload":377.608,"Graphics.DrawWithRecipe":764.420,"Graphics.DrawWithRecipe.draw_and_resource_release":521.302,"Graphics.DrawWithRecipe.index_upload":96.836,"Graphics.DrawWithRecipe.validate":23.862,"Graphics.DrawWithRecipe.vertex_upload":113.562,"Graphics.Submit":42.120,"Graphics.Submit.command_end":0.457,"Graphics.Submit.queue_submit":41.465,"Graphics.Wait":49.492,"Graphics.Wait.fence_wait":42.241,"Recorder.Reap":35.972,"Recorder.Submit":573.550,"Recorder.Sync":5314.751,"Resources.Complete":459.512,"Resources.Prepare":143.664,"Shader.DrawStage":662.996,"Shader.DrawStage.capture_resources":294.714,"Shader.DrawStage.materialize":235.988,"Shader.DrawStage.prepared_invocation":123.919,"Shader.ResolveAbi":269.729,"Shader.ResolveGraphicsAbi":130.874,"Shader.ResolveGraphicsStagesAbi":244.151,"VideoOut.Flip":114.012,"VideoOut.Flip.completion_mutex_wait":0.136,"VideoOut.Flip.config_mutex_wait":0.016,"VideoOut.Flip.frame_limit":0.093,"VideoOut.Flip.notify_game":4.245,"VideoOut.Flip.present":108.079,"VideoOut.Flip.validate":0.237,"VideoOut.Flip.vblank_wait":0.145,"VideoOut.Flip.window_prepare":0.263,"VideoOut.Flip.window_title":0.570,"VideoOut.Readiness":0.640,"VideoOut.Readiness.locks_validate":0.203,"Vulkan.Acquire":11.916,"Vulkan.Acquire.acquire_fence_wait":0.630,"Vulkan.Acquire.acquire_image":9.531,"Vulkan.Acquire.fence_reset":1.622,"Vulkan.Acquire.retired_swapchains":0.080,"Vulkan.Dispatch":19.678,"Vulkan.Dispatch.command_record":4.998,"Vulkan.Dispatch.shader_resources":14.478,"Vulkan.DrawFromRecipe":775.404,"Vulkan.Present":24.182,"Vulkan.Present.command_record_scale":9.174,"Vulkan.Present.pixel_upload":0.456,"Vulkan.Present.queue_submit":14.346,"Vulkan.QueuePresent":7.504,"Vulkan.QueuePresent.queue_present":7.312,"Vulkan.Retire":67.176,"Vulkan.Retire.wait":51.987},"top_phases_ms_per_frame":{"Driver.Packet":116.684,"Recorder.Sync":63.271,"Driver.Packet.dispatch":59.405,"Driver.Dispatch":59.393,"Driver.Dispatch.decode_key_device_setup":58.163,"Driver.Packet.draw":35.261,"Driver.Draw":35.019,"Graphics.Draw":29.938},"owned_draw_counts":{"OwnedDraw.evicted_other":8037},"graphics_track":{"Graphics.Barrier.dispatch-lead":168,"Graphics.Barrier.dispatch-trail":168,"Graphics.Barrier.draw":21031,"Graphics.Barrier.input-mirror":3669,"Graphics.Barrier.label-run":3750,"Graphics.Barrier.present-blit":168,"Graphics.Copy":4509,"Graphics.Copy.bytes":58538402,"Graphics.RenderPass":8648,"Graphics.RenderPass.Close.command":2385,"Graphics.RenderPass.Close.image":169,"Graphics.RenderPass.Close.key":1255,"Graphics.RenderPass.Close.new-batch":4839,"Graphics.RenderPass.Continued":20077},"trace_dropped":false,"trace":"aps5-trace-e68be05111f4-783481.json.gz"}
{"commit":"d71f6b1da47d","dirty":false,"env":{"APS5_PAD_REPLAY":"<path>","APS5_TRACE_SECONDS":"100:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"AMD Radeon Graphics (RADV RENOIR)","driver":"radv Mesa 26.0.8-1ubuntu0.3","os":"Linux 7.0.0-43-generic","cpu":"AMD Ryzen 5 5625U with Radeon Graphics","cpu_threads":12,"memory_mib":14780,"title_id":"PPSA06465","title":"Cult Of The Lamb","content_version":"01.000.023","resolution":"1920x1080","window":{"spec":"seconds 100:10","first_present":2854,"ms":10002.023},"presents":100,"frame_ms":{"p50":99.824,"p90":103.789,"p99":106.417,"max":106.417},"gpu_busy_ms_per_present":67.510,"worker_busy_pct":{"queue worker 0x0":92.329},"phase_totals_ms":{"Driver.Completion":1.476,"Driver.Dispatch":4713.343,"Driver.Dispatch.decode_key_device_setup":4582.449,"Driver.Dispatch.lookup_cache":2.273,"Driver.Draw":2736.510,"Driver.Draw.device_setup":153.957,"Driver.Draw.draw_enqueued":458.604,"Driver.Draw.post_compile_prepare":135.428,"Driver.Draw.prepare":225.442,"Driver.Draw.shader_compile_and_link":1722.310,"Driver.EndSubmission":26.152,"Driver.Packet":9207.026,"Driver.Packet.device_lock":21.258,"Driver.Packet.dispatch":4714.701,"Driver.Packet.draw":2765.994,"Driver.Packet.execute":952.060,"Driver.Packet.flip_flush":14.515,"Driver.Packet.flush_between_packets":72.555,"Driver.Packet.memory_wait":0.683,"Driver.Packet.pipeline_drain":149.731,"Driver.Packet.pipeline_prepare":46.215,"Driver.Packet.prepare_memory":41.860,"Driver.Packet.rendering_wait":0.496,"Driver.Present":606.008,"Driver.Present.acquire_image":21.141,"Driver.Present.device_setup":0.171,"Driver.Present.gpu_mutex_wait":2.057,"Driver.Present.inflight_wait":0.624,"Driver.Present.present_display_buffer":30.593,"Driver.Present.queue_present":8.688,"Driver.Present.release_and_callback":0.224,"Driver.Present.render_fence_wait":541.829,"Driver.Present.resize":0.347,"Driver.Present.validate":0.091,"Driver.Suspend":0.065,"GpuMutex.wait.draw":1.589,"GpuMutex.wait.end":0.096,"GpuMutex.wait.fill":96.052,"GpuMutex.wait.flush":0.183,"GpuMutex.wait.label":1.258,"GpuMutex.wait.other":0.996,"GpuMutex.wait.present":1.504,"Graphics.Draw":3094.431,"Graphics.Draw.draw_and_resource_release":1987.475,"Graphics.Draw.index_upload":454.210,"Graphics.Draw.validate":154.208,"Graphics.Draw.vertex_upload":475.695,"Graphics.DrawWithRecipe":954.950,"Graphics.DrawWithRecipe.draw_and_resource_release":621.603,"Graphics.DrawWithRecipe.index_upload":136.635,"Graphics.DrawWithRecipe.validate":28.879,"Graphics.DrawWithRecipe.vertex_upload":157.000,"Graphics.Submit":51.678,"Graphics.Submit.command_end":0.520,"Graphics.Submit.queue_submit":50.961,"Graphics.Wait":3092.210,"Graphics.Wait.fence_wait":3067.077,"Recorder.Reap":161.709,"Recorder.Submit":742.044,"Recorder.Sync":433.125,"Resources.Complete":471.301,"Resources.Prepare":151.998,"Shader.DrawStage":913.808,"Shader.DrawStage.capture_resources":417.214,"Shader.DrawStage.materialize":315.062,"Shader.DrawStage.prepared_invocation":170.004,"Shader.ResolveAbi":448.169,"Shader.ResolveGraphicsAbi":202.552,"Shader.ResolveGraphicsStagesAbi":405.910,"VideoOut.Flip":613.464,"VideoOut.Flip.completion_mutex_wait":0.167,"VideoOut.Flip.config_mutex_wait":0.022,"VideoOut.Flip.frame_limit":0.109,"VideoOut.Flip.notify_game":4.031,"VideoOut.Flip.present":607.368,"VideoOut.Flip.validate":0.250,"VideoOut.Flip.vblank_wait":0.168,"VideoOut.Flip.window_prepare":0.299,"VideoOut.Flip.window_title":0.750,"VideoOut.Readiness":0.455,"VideoOut.Readiness.locks_validate":0.237,"Vulkan.Acquire":20.642,"Vulkan.Acquire.acquire_fence_wait":0.859,"Vulkan.Acquire.acquire_image":17.705,"Vulkan.Acquire.fence_reset":1.885,"Vulkan.Acquire.retired_swapchains":0.110,"Vulkan.Dispatch":11.364,"Vulkan.Dispatch.command_record":4.686,"Vulkan.Dispatch.shader_resources":6.452,"Vulkan.DrawFromRecipe":967.731,"Vulkan.Present":25.621,"Vulkan.Present.command_record_scale":9.304,"Vulkan.Present.pixel_upload":0.535,"Vulkan.Present.queue_submit":15.564,"Vulkan.QueuePresent":8.256,"Vulkan.QueuePresent.queue_present":8.061,"Vulkan.Retire":542.205,"Vulkan.Retire.wait":539.016},"top_phases_ms_per_frame":{"Driver.Packet":92.070,"Driver.Packet.dispatch":47.147,"Driver.Dispatch":47.133,"Driver.Dispatch.decode_key_device_setup":45.824,"Graphics.Draw":30.944,"Graphics.Wait":30.922,"Graphics.Wait.fence_wait":30.671,"Driver.Packet.draw":27.660},"owned_draw_counts":{"OwnedDraw.evicted_other":7286},"graphics_track":{"Graphics.Barrier.dispatch-trail":200,"Graphics.Barrier.draw":23001,"Graphics.Barrier.input-mirror":4521,"Graphics.Barrier.label-run":14759,"Graphics.Barrier.present-blit":200,"Graphics.BarrierMerged.dispatch-lead":200,"Graphics.Copy":5521,"Graphics.Copy.bytes":75153324,"Graphics.RenderPass":10886,"Graphics.RenderPass.Close.command":3000,"Graphics.RenderPass.Close.image":464,"Graphics.RenderPass.Close.key":1618,"Graphics.RenderPass.Close.new-batch":5804,"Graphics.RenderPass.Continued":23987},"trace_dropped":false,"trace":"aps5-trace-d71f6b1da47d-784006.json.gz"}
tools/trace_digest.py, main

seconds 100:10 from present 2621: 84 presents, frame p50 119.8 / p90 123.2 / p99 129.3 / max 129.3 ms, GPU busy 63.1 ms per present
AMD Radeon Graphics (RADV RENOIR), radv Mesa 26.0.8-1ubuntu0.3, Linux 7.0.0-43-generic, 1920x1080, commit e68be05, dropped: no

Slowest frames (largest slices inside each, inclusive)

  • present 2655: 129.3 ms at 4043 ms: Driver.Packet (queue worker 0x0) 122.2, Recorder.Sync (draw committer) 65.4, batch (gpu) 62.1, Driver.Packet.dispatch (queue worker 0x0) 56.6
  • present 2671: 127.0 ms at 5966 ms: Driver.Packet (queue worker 0x0) 120.1, Recorder.Sync (draw committer) 64.6, batch (gpu) 62.4, Driver.Packet.dispatch (queue worker 0x0) 58.2
  • present 2652: 126.4 ms at 3679 ms: Driver.Packet (queue worker 0x0) 120.1, Recorder.Sync (draw committer) 65.4, batch (gpu) 61.5, Driver.Packet.dispatch (queue worker 0x0) 60.7
  • present 2681: 125.3 ms at 7174 ms: Driver.Packet (queue worker 0x0) 117.9, Driver.Packet.dispatch (queue worker 0x0) 67.5, Driver.Dispatch (queue worker 0x0) 67.5, Driver.Dispatch.decode_key_device_setup (queue worker 0x0) 66.7
  • present 2697: 124.9 ms at 9089 ms: Driver.Packet (queue worker 0x0) 118.7, Recorder.Sync (draw committer) 68.8, batch (gpu) 63.6, Driver.Packet.dispatch (queue worker 0x0) 63.3

Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)

  • present 2655: 129.3 ms at 4043 ms, persistence 17.1 ms
  • present 2697: 124.9 ms at 9089 ms, persistence 12.7 ms
  • present 2671: 127.0 ms at 5966 ms, persistence 11.9 ms
  • present 2631: 123.3 ms at 1184 ms, persistence 10.6 ms
  • present 2652: 126.4 ms at 3679 ms, persistence 9.9 ms
  • present 2623: 123.0 ms at 235 ms, persistence 9.0 ms
  • present 2687: 123.2 ms at 7890 ms, persistence 8.4 ms
  • present 2625: 122.9 ms at 472 ms, persistence 8.4 ms
  • present 2681: 125.3 ms at 7174 ms, persistence 7.3 ms
  • present 2646: 121.8 ms at 2969 ms, persistence 7.2 ms

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
queue worker 0x0 112.4 (94 %) 1.3 (1 %) 5.9 26.4 Driver.Packet 111.9, Driver.EndSubmission 1.2
draw committer 106.7 (89 %) 0.7 (1 %) 12.2 6.2 Recorder.Sync 63.3, Graphics.Draw 29.9
presenter 0.7 (1 %) 0.7 (1 %) 118.2 0.1 VideoOut.Flip 1.4
tools/trace_digest.py, this PR

seconds 100:10 from present 2854: 100 presents, frame p50 99.8 / p90 103.8 / p99 106.4 / max 106.4 ms, GPU busy 67.5 ms per present
AMD Radeon Graphics (RADV RENOIR), radv Mesa 26.0.8-1ubuntu0.3, Linux 7.0.0-43-generic, 1920x1080, commit d71f6b1, dropped: no

Slowest frames (largest slices inside each, inclusive)

  • present 2903: 106.4 ms at 4893 ms: Driver.Packet (queue worker 0x0) 90.5, batch (gpu) 67.8, Driver.Packet.dispatch (queue worker 0x0) 41.8, Driver.Dispatch (queue worker 0x0) 41.8
  • present 2923: 105.4 ms at 6904 ms: Driver.Packet (queue worker 0x0) 90.8, batch (gpu) 65.0, Driver.Packet.dispatch (queue worker 0x0) 45.5, Driver.Dispatch (queue worker 0x0) 45.5
  • present 2883: 105.0 ms at 2874 ms: Driver.Packet (queue worker 0x0) 91.3, batch (gpu) 66.2, Driver.Packet.dispatch (queue worker 0x0) 47.2, Driver.Dispatch (queue worker 0x0) 47.2
  • present 2947: 104.9 ms at 9295 ms: Driver.Packet (queue worker 0x0) 89.6, batch (gpu) 66.8, Driver.Packet.dispatch (queue worker 0x0) 45.5, Driver.Dispatch (queue worker 0x0) 45.5
  • present 2899: 104.8 ms at 4486 ms: Driver.Packet (queue worker 0x0) 91.1, batch (gpu) 68.4, Driver.Packet.dispatch (queue worker 0x0) 50.4, Driver.Dispatch (queue worker 0x0) 50.4

Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)

  • present 2903: 106.4 ms at 4893 ms, persistence 10.2 ms
  • present 2923: 105.4 ms at 6904 ms, persistence 9.2 ms
  • present 2947: 104.9 ms at 9295 ms, persistence 8.2 ms
  • present 2915: 104.6 ms at 6102 ms, persistence 8.0 ms
  • present 2883: 105.0 ms at 2874 ms, persistence 7.9 ms
  • present 2875: 103.3 ms at 2080 ms, persistence 7.0 ms
  • present 2869: 103.0 ms at 1484 ms, persistence 6.8 ms
  • present 2936: 103.4 ms at 8193 ms, persistence 5.9 ms
  • present 2896: 103.8 ms at 4181 ms, persistence 5.8 ms
  • present 2885: 104.2 ms at 3078 ms, persistence 5.5 ms

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
queue worker 0x0 86.0 (86 %) 7.5 (8 %) 6.5 28.2 Driver.Packet 86.7, Driver.EndSubmission 0.2
draw committer 52.8 (53 %) 30.9 (31 %) 16.3 6.8 Graphics.Draw 30.9, Vulkan.DrawFromRecipe 9.7
presenter 0.7 (1 %) 5.4 (5 %) 93.9 0.1 VideoOut.Flip 6.1

In the window, Recorder.Sync on the draw committer goes from 63.3 to 4.3 ms per frame, presents from 84 to 100 and frame p50 from 119.8 to 99.8 ms. GPU busy per present goes from 63.1 to 67.5 ms, as the GPU now runs the label stores and the committer feeds it faster.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: AMD Radeon Graphics (RADV RENOIR, gfx90c), Mesa 26.0.8, Ubuntu 26.04 Linux
  • AI-assisted: yes

…lpers

importWindowBounds and windowRun read rangeImportWindow themselves. They
now take the window as a parameter that defaults to it, so a caller can
import a narrower window of a large registered range. No caller changes.
ImportRequester gains Label, named "label" in the host import report,
for imports a label store makes so it can be recorded on the GPU. No
import is requested with it yet; the report test now lists it.
… window

A queue-0 label whose memory no import covers synced the recorder and was
stored on the CPU (boykopovar#7464). That is cheap for the small blocks it was made
for, which the title maps every frame, but a label in a large allocation
that the import budget refuses waits for every batch in flight each time.
In Cult of the Lamb (PPSA06465) on a Renoir APU, whose import budget is
586 MiB, the labels land in 16 MiB allocations and the sync costs about
60 ms per frame in gameplay.

Such a label now requests a 64 KiB window of its allocation (Label
requester) and is recorded on the GPU when the window imports. An
allocation no larger than the window keeps the CPU path, so the small
blocks of boykopovar#7464 are still not imported.
The budget refuses a label window exactly when the label's allocation was
refused, so the window rarely imported. Label windows now bypass the
budget, its eviction and the remembered refusals, and have a limit of
their own: at most 16 MiB of windows are live. A window past the limit
retires the least recently used label window that the import eviction
rule would let go (not held by a build, not used in the current or the
previous frame) and rewatches what it unwatched, as retireLeastRecent
does; when no window can go the label keeps the CPU path. Retiring and
clearing the imports keep the label bytes in step.
HostImportCounts carries the live bytes of label windows, and the host
import report appends them when there are any.
… window

agc_driver_label_import_window lowers the import budget below a 1 MiB
allocation and stores a label in it. The label must be recorded on the
GPU (reason 0) through one 64 KiB label window, pin exactly that window,
count it as label bytes and land without touching its neighbours.
A label in a 64 KiB allocation must still return reason 7 without making
an import, as boykopovar#7464 requires for the small blocks titles map per frame.
…etire

Labels fill the label windows to 16 MiB. Before any build every window is
held, so the next label keeps its CPU path and the windows do not grow.
After a build the next label is recorded on the GPU: the least recently
used window (the first case's) is retired, the newer ones stay and every
label lands.
@github-actions github-actions Bot added the perf Performance change label Nov 24, 2026

@mihiii1337 mihiii1337 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes for two independent, reproducible blockers at d71f6b1da47d06934e29acc32308f891d417c091 (recorded base d1d700affa94d499003c1fec960e745dca2e23d5).

  1. The Windows fixture does not isolate small. FillBuffer(work) runs before the small-block check, and separately registered VirtualAlloc blocks can be adjacent. The import run can therefore already cover small, so line 123 observes GPU reason 0 instead of exercising the intended CPU fallback. On the clean exact head, all three registered variants fail at that assertion on both physical GPUs below. With only a scratch fixture change that reserves one extra unregistered 64 KiB after each registered block, the same production source passes 3/3 on each GPU. Please make the fixture guarantee that separation (or otherwise prove that small is not already covered before testing the label-only path).

  2. Label windows still consume the normal host-import budget. The label admission path bypasses the normal budget guard at GuestBufferMemory.cpp:2548-2549, but every label is added to state.liveBytes at :2782-2785. pinnedTotal includes all liveBytes (:617-618), and the normal admission/remaining-budget paths use that total. retireLeastRecent (:2037-2049) also does not exclude .label. A scratch-only regression first admitted a normal control import, filled the label pool to 16 MiB, then requested a fresh normal import and checked that neither the control nor the labels were evicted. All three variants fail on both GPUs with label windows consumed the normal host import budget. That contradicts the stated separation from the normal host-import budget and its eviction. Please account label windows outside the normal budget and exclude them from normal-budget eviction, with a regression that requests a new normal import after filling the label pool.

Windows 11 build 26300, Release, WinLibs GCC 15.2.0 r7. Physical devices: Intel A78B (driver 101.6127, Vulkan 1.3.295) and NVIDIA RTX 4070 Laptop (driver 621.01). Khronos validation 1.4.369 was enabled at instance/device level with synchronization validation; no VUID or SYNC errors were emitted.

Tests on each GPU:

  • clean exact head: agc_driver_label_import_window, _draw_pipeline, _plan_verify: 0/3, fixture assertion above;
  • isolated-block scratch fixture, production unchanged: 3/3;
  • same fixture plus normal-budget probe: 0/3, budget assertion above.

The scratch changes were not committed or pushed. AI-assisted: yes.

@upipibi

upipibi commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

RTX 3070 run of d71f6b1da4, merged with --no-ff onto main 17220db6a3: the new agc_driver_label_import_window tests fail on Windows / NVIDIA, all three variants in all 3 runs, at the small-allocation check.

Tested

  • NVIDIA GeForce RTX 3070 (driver 616.56, subgroup 32), Windows 11 Pro 26100, WinLibs GCC 15.2.0, Ninja, Release; ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation.
  • ctest -R "^(agc_driver_label_import_window.*|agc_bda_.*)$", 3 runs each:
    • main: agc_bda_atomics, agc_bda_staging, agc_bda_staging_bound 3/3 passed in all 3 runs.
    • this PR: those 3 pass. agc_driver_label_import_window, _draw_pipeline and _plan_verify fail in every run with
      AGC graphics: a label in an allocation no larger than a window did not keep its CPU path (reason 0).
  • So here the label in the 64 KiB allocation is recorded on the GPU (reason 0), where the test expects perf(agc): keep unimported label stores on the CPU #7464's CPU path (reason 7). The description's run is on Linux / RADV (Renoir), where it passes. On this machine something covers that small allocation before the label is written: an earlier import, or the Windows host import rules. I haven't looked into which.
  • Validation layer inserted in every Vulkan test, 0 VUID- messages. Build: 0 failed targets.

Not tested: AMD on Windows, Linux, titles.

AI-assisted (Claude Code).

@github-actions github-actions Bot added build agc libSceAgc* labels Nov 24, 2026
@zedekvdb

Copy link
Copy Markdown
Contributor

Windows run, since the Tested section is Linux (RADV) only: on an NVIDIA Quadro P3200 the three new tests fail with this head, while the 22 existing tests of the set pass on both sides.

Setup: Windows 11 Pro 10.0.26300, NVIDIA Quadro P3200 (Pascal, 10de:1bbb), driver 582.42, Vulkan API 1.4.312, WinLibs GCC 15.2.0 r7, Release, main 7f99fbd60d. VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ANYPS5_GPU="Quadro P3200", the ctest -R set from the description, -j 1 -V, 2 runs per side. Every Vulkan test selects the Quadro P3200 with the layer inserted; there are no VUID- messages.

main This head (d71f6b1da4)
The 22 existing tests (agc_driver_graphics, label_*, host_import_*, unimported_label_order*, same_queue_label_wait*) 2 of 2 2 of 2
agc_driver_label_import_window, _draw_pipeline, _plan_verify (new) fail, 2 of 2 runs

agc_driver_label_trap_committer_resolve is Not Run on both sides here because its executable is EXCLUDE_FROM_ALL.

All three new tests stop at the same check, after the large-allocation case passes:

AGC graphics: a label in an allocation no larger than a window did not keep its CPU path (reason 0)

The cause is the test's block layout on Windows, not the label path. With a temporary fprintf before the small store (not part of this PR):

work=0xfc00000000 small=0xfc00010000 label=0xfc00010080 covers=1 existing=1 base=0xfc00000000 bytes=0x20000 joined=0 ranges=2

On Windows the 64 KiB VirtualAlloc blocks work and small are next to each other, and the import made for device->FillBuffer(work.Address(), ...) is 128 KiB and covers both allocations (ranges=2). So HostImportCovers is already true for the small label in WriteLabelOnGpu, the new ImportRequester::Label path isn't reached, and the label goes to the GPU through the existing import (reason 0). On Linux the blocks come from aligned_alloc instead, which may be why the RADV run passes; I haven't checked the Linux layout.

Allocating small so it can't sit next to work (for example with an unmapped gap between them, or by checking HostImportCovers is false before the store) would make the test check the window path on Windows too.

AI-assisted: yes (Claude Code)

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

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.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 26384 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp L3282

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.

Pull request Shared files not compared
PR 1395 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 4040 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 4448 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 4472 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 4847 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 5372 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 5925 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6186 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6188 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6197 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 6412 core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 6481 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7002 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 7643 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 9356 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 9387 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 9508 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 9852 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 10193 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 10442 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 10492 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 10497 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 10652 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 11435 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 11436 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 11483 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 12157 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 12828 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 12840 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 12944 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 13148 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 13863 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 13920 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 13928 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 13929 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 14871 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 15295 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 15296 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 15297 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 15570 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 15621 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 16571 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 16831 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 17056 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 18173 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 19557 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 19697 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 20030 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 20111 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 20172 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 20186 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 20248 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 20315 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 20519 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 20580 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 21059 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 21238 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 21649 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 22071 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 22190 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 22424 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 22531 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 22550 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 22647 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 23058 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 24327 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 24661 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 25010 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 25610 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 26165 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 26197 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no blocking findings

Nothing blocks this change based on the inspected code; the targeted source and test logic support the stated label-window behavior, though not every changed file was read.

What I ran

Reviewed head d71f6b1da47d06934e29acc32308f891d417c091 using the prepared diff and repo_read.py for targeted source ranges. No build or tests were run during this review.

Results

Check Result Note
Diff and targeted source review passed Label window paths inspected
Tests not run Author-reported results are not review-run results
Full changed-file review not run Some changed files were not read in full

Findings

Blocking

None identified in the inspected code.

Non-blocking

None.

Not verified

The full text of core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp and core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp was excluded from the review folder for size; targeted relevant ranges were read through repo_read.py. Other changed files read: core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp, core/libs/prx/libSceAgcDriver/tests/execution/LabelImportWindow.cpp, and review/commits.md. core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp, core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_label_import_window_tests.cmake, review/description.md, and review/manifest.json were not read in full. No independent build, test run, platform check, or console behavior was verified.

To get this to a good state

Nothing is required. The behavior has focused coverage described in the change, but those tests were not run in this review.

@root-over

Copy link
Copy Markdown
Contributor Author

Thanks to all three of you for the Windows runs and the diagnosis. Both points were right; fixed in three commits on top (27bee6cace, 1f5177db5d, d2d884ab94), nothing rewritten.

  1. Test fixture. Each GuestBlock now allocates 64 KiB more than it registers, so registered blocks are always separated by an unregistered gap and the import made for work cannot run into small. The small-allocation case also checks HostImportCovers is false before the store, so if the layout ever covers it again the test says so instead of reporting reason 0.

  2. Budget separation. Label windows were added to liveBytes, so pinnedTotal charged them to the normal budget, and retireLeastRecent / evictableBytes could retire them. Now pinnedTotal leaves out labelBytes and the bytes of retired label imports still pinned (tracked in retiredLabelBytes), the heap budget query still gets every import (importedTotal), and both eviction helpers skip label imports. The new check fills the windows to 16 MiB with a normal import live, then requests a fresh normal import within the budget and requires it to be made, the earlier normal import to stay and no label window to be retired. On the previous head it fails in all three variants (cannot record work on a fresh allocation).

Re-run on the Renoir: the focused set passes 24/24 (33 layer inserts, 0 VUID-), and a new Cult of the Lamb batch keeps the gain (12.32 fps vs 10.68 on main, same as the previous head at 12.37). The description is updated. I can't reproduce the Windows layout here, so a re-run on one of your machines would be welcome.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no blocking findings

Nothing blocks this review; the findings below are optional.

What I ran

Reviewed head d2d884ab94ceecd76e055cbca107b64aaff97cfe. No commands or tests were run; I reviewed the prepared diff and targeted source ranges. The test and performance results in the PR description are author-reported.

Results

Check Result Note
Diff and targeted source review passed Prepared artifacts and relevant code inspected
Tests and negative controls not run Results are author-reported

Findings

Blocking

None found in the code inspected.

Non-blocking

None.

Not verified

The full text of VulkanDevice.cpp and GuestBufferMemory.cpp was not read; I inspected their relevant changed hunks and surrounding code through repo_read.py. The full text of GuestBufferMemory.hpp, BdaResources.cpp, and LabelImportWindow.cpp was read. The new CMake test registration file was not read. No repository tests, builds, negative controls, or performance runs were performed. The supplied manifest identifies six changed files; five were inspected at least in part, and the CMake registration was not inspected. The PR’s test and performance claims were not independently verified.

To get this to a good state

Nothing is required. Optional: run the reported checks on this exact head and inspect the CMake registration file before treating the review as complete.

@mihiii1337 mihiii1337 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two original blockers are fixed on exact head d2d884ab94ceecd76e055cbca107b64aaff97cfe: the separated Windows fixture and the full-label-pool normal-budget case both pass. A separate overlapping-range case still lets label bytes count as normal-budget replacement credit when APS5_IMPORT_RETIRE_CREDIT=1.

importRunAt adds every overlapping import to replaced at GuestBufferMemory.cpp:2537-2543, including .label entries. pinnedTotal deliberately excludes label bytes. The immediate-credit path then computes live = pinned - replaced, so a normal import can subtract a label window that was never charged to the normal budget.

Independent Windows 11 reproduction on the exact production head:

  1. Retain one 64 KiB label window inside a five-window registered allocation.
  2. Advance the build so the label import is replaceable.
  3. Set the normal budget to current normal live bytes plus four windows.
  4. With APS5_IMPORT_RETIRE_CREDIT=1, request a normal import covering all five windows.

That request should be refused: normal live plus five windows exceeds the normal budget by one window, and the overlapping label window is outside that budget. Instead it succeeds on both physical devices, failing the test-only assertion label bytes were credited to a normal import over the normal budget:

  • Intel A78B: CTest exit 8;
  • NVIDIA RTX 4070 Laptop: CTest exit 8.

The local regression changed only LabelImportWindow.cpp; it was not committed or pushed. Before adding it, the stock exact-head trio passed 3/3 on Intel and 3/3 on NVIDIA with Vulkan required, shader cache disabled, and Khronos validation enabled. Conventions and git diff --check also pass.

Please exclude label entries from normal replacement credit (or track normal replacement bytes separately) and add an overlapping label-to-normal regression with retire credit enabled. I did not reproduce the issue with the default-off retire-credit path.

AI-assisted: yes.

@root-over

Copy link
Copy Markdown
Contributor Author

Thanks for the re-run and the third case; right again. Fixed in 420c0dfcdc, regression in b1c9409abd.

importRunAt now adds only non-label entries to replaced, so the credit a normal import gets for the imports it replaces covers only bytes that were charged to the normal budget. The same subtraction also runs when retires free at once (no active recorder), not only with APS5_IMPORT_RETIRE_CREDIT, so the fix covers both.

The new case follows your steps: it imports one 64 KiB label window in the middle of a five-window allocation, runs a build so the window can be replaced, sets the normal budget to the normal live bytes plus four windows, turns retire credit on and requests a normal import of the whole allocation, then requires the normal live bytes (live minus label windows) to stay within the budget. Without the fix it fails in all three variants with label bytes were credited to a normal import over the normal budget.

On the Renoir: the focused set passes 24/24 (33 layer inserts, 0 VUID-), agc_bda_* 3/3, conventions pass. The description is updated.

@root-over
root-over requested a review from mihiii1337 November 25, 2026 14:00

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

Nothing blocks this change; the evidence inspected supports merging.

What I ran

Reviewed head b1c9409abdd8bc98a1288857e0185a7bc07b05a6 using the pinned repo_read.py reader. No commands or tests were run by me; test and performance results below are reported by the author.

Results

Check Result Note
Changed code review passed Reviewed the changed implementation and test lines
Author-reported tests not run 24 targeted tests and negative controls reported passing
Author-reported conventions not run Convention and debt checks reported passing
Console performance not run Hardware measurements supplied by the author

Findings

Blocking

None.

Non-blocking

None.

Not verified

I read every changed line listed as reviewed in the manifest. The full GuestBufferMemory.cpp and VulkanDevice.cpp files were excluded from the prepared review folder; I used the reader for the relevant changed implementation ranges. I did not independently run tests, convention checks, performance captures, or console behavior checks. The reader did not provide files.json; the folder listing and manifest identify all six changed files and show their included/excluded status.

To get this to a good state

Nothing is required.

@upipibi

upipibi commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@root-over Re-run at b1c9409abd, merged with --no-ff onto main 098c73473f, on the RTX 3070 (616.56), Windows 11: the third case is fixed here too.

tree agc_driver_label_import_window* + agc_bda_*, 3 runs validation layer
main 3 of 3 pass each run (the label-import tests don't exist there yet) inserted, 0 VUIDs
this PR 6 of 6 pass each run, incl. the three label-import-window tests inserted, 0 VUIDs

AI-assisted (Claude Code). Synthetic tests only.

@mihiii1337 mihiii1337 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed exact head b1c9409abdd8bc98a1288857e0185a7bc07b05a6. The overlapping label-to-normal budget blocker is fixed: replacement credit now excludes label imports, and the committed regression recreates the five-window request under a four-window normal budget with retire credit enabled, then verifies normal live bytes stay within that budget.

Independent Windows 11 verification on the exact head:

  • native Release build of agc_driver_label_import_window_tests completed;
  • agc_driver_label_import_window, _draw_pipeline, and _plan_verify: 3/3 passed on Intel A78B;
  • the same trio: 3/3 passed on NVIDIA RTX 4070 Laptop;
  • Vulkan was required, shader cache disabled, and the Khronos validation layer requested in both runs;
  • tools/check_conventions.py --base d1d700affa94d499003c1fec960e745dca2e23d5 and git diff --check passed.

The hosted checks for this fresh head are still queued. I did not run a title or console test. No blocking finding remains in the reviewed fix.

AI-assisted: yes.

@root-over
root-over marked this pull request as ready for review November 25, 2026 15:29
@oneandonlydean
oneandonlydean merged commit 684ee92 into boykopovar:main Nov 25, 2026
14 of 20 checks passed
@root-over
root-over deleted the perf/agc-label-imports branch November 26, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build perf Performance change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants