Skip to content

perf(agc): serve a buffer range that crosses host import windows in place from one joined import - #22072

Merged
oneandonlydean merged 5 commits into
boykopovar:mainfrom
nicolasabosch:perf/agc-join-straddling-imports
Nov 20, 2026
Merged

oneandonlydean merged 5 commits into
boykopovar:mainfrom
nicolasabosch:perf/agc-join-straddling-imports

Conversation

@nicolasabosch

@nicolasabosch nicolasabosch commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

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 main copies it through the CPU on every bind: 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 span being joined (run.bytes <= end - begin + 2 * window). That span is the buffer, widened by importJoined to 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.
  • 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 (new ENVIRONMENT.md row).
  • deviceLocalHasRoom no longer throws on a device without a device-local memory type; it reports no room instead.
  • The host-imports debt entry gains one clause for this join, through the fragment docs/dev/debt/changes/perf-agc-join-straddling-imports.md.

Overlap: #5372 relaxes the same joinedRun check for a buffer bound from inside a range (begin == run.base || run.bytes <= window) and edits the same assertion in importJoinTests. The two rules differ: #5372 caps the joined run at one window and also widens importJoined to 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): deviceLocalHasRoom keeps 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 no VUID- error, and agc_driver_graphics and the agc_driver_bda_* tests pass too (17/17). agc_graphics_profile_draw runs the BDA import-join tests: importJoinTests now 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; spaceReadAcrossImportsTests takes 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. With APS5_NO_JOIN_STRADDLE=1, agc_graphics_profile_draw fails (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 with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LOADER_DEBUG=layer, ANYPS5_NO_SHADER_CACHE=1 and ANYPS5_REQUIRE_VULKAN=1 through ctest -V (Khronos validation layer 1.4.363.1): every log shows Insert instance layer "VK_LAYER_KHRONOS_validation" (11 times in each), none reports was not found but was requested by env var VK_INSTANCE_LAYERS, and neither run logs a VUID- 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), main vs this change; traces and trace_digest.py outputs attached):

Metric main change Change
frame p50 753.153 ms 415.194 ms -44.9%
frame p90 948.136 ms 608.772 ms -35.8%
presents 86 138 +60.5%
GPU busy/present 227.081 ms 253.884 ms +11.8%

Traces and trace_digest.py outputs (both traces report trace_dropped after the queue-worker event buffer fills; the summary lines, phase totals and import counters are complete):

The 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 are main 2a8a0d1 plus the pad-script commit of #22064, which only injects the scripted input.

main this change
summary line seconds 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 present seconds 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 present

Traces and trace_digest.py outputs: main: trace, digest; this change: trace, digest.

aps5-summary.jsonl lines

main:

{"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

  • Based on current 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 same joinedRun check; see What)
  • 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: NVIDIA GeForce RTX 4070 Laptop GPU, driver 616.92, Windows 11 Pro 26300 (tests); RTX 4070 SUPER, driver 621.24 (captures, by @Logan1h)
  • AI-assisted: yes

🤖 Generated with Claude Code

…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>
@github-actions github-actions Bot added perf Performance change perf numbers missing perf pull request without a before and after summary line labels Nov 17, 2026
@github-actions

Copy link
Copy Markdown

This pull request is labeled perf, so it needs the summary line of a capture on main and one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste both aps5-summary.jsonl lines, attach the two traces and add the output of tools/trace_digest.py.

@github-actions github-actions Bot removed the perf numbers missing perf pull request without a before and after summary line label Nov 17, 2026
@github-actions github-actions Bot added docs agc libSceAgc* labels Nov 17, 2026
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

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 1896 docs/dev/ENVIRONMENT.md
PR 4448 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 4472 docs/dev/ENVIRONMENT.md
PR 5372 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 6186 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/ENVIRONMENT.md
PR 6197 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/src/GuestBufferMemory.cpp
PR 6924 docs/dev/ENVIRONMENT.md
PR 7275 docs/dev/ENVIRONMENT.md
PR 7642 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
docs/dev/ENVIRONMENT.md
PR 7643 docs/dev/ENVIRONMENT.md
PR 8246 docs/dev/ENVIRONMENT.md
PR 9345 docs/dev/ENVIRONMENT.md
PR 9356 docs/dev/ENVIRONMENT.md
PR 9387 docs/dev/ENVIRONMENT.md
PR 9508 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
docs/dev/ENVIRONMENT.md
PR 9712 docs/dev/ENVIRONMENT.md
PR 9852 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/ENVIRONMENT.md
PR 10193 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
docs/dev/ENVIRONMENT.md
PR 10442 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
docs/dev/ENVIRONMENT.md
PR 10443 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/ENVIRONMENT.md
PR 11435 docs/dev/ENVIRONMENT.md
PR 11436 docs/dev/ENVIRONMENT.md
PR 12157 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 12324 docs/dev/ENVIRONMENT.md
PR 12746 docs/dev/ENVIRONMENT.md
PR 12840 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
docs/dev/ENVIRONMENT.md
PR 12849 docs/dev/ENVIRONMENT.md
PR 12944 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 13148 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 13809 docs/dev/ENVIRONMENT.md
PR 13863 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/ENVIRONMENT.md
PR 13920 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/ENVIRONMENT.md
PR 13928 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
docs/dev/ENVIRONMENT.md
PR 13929 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
docs/dev/ENVIRONMENT.md
PR 14262 docs/dev/ENVIRONMENT.md
PR 15296 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 15529 docs/dev/ENVIRONMENT.md
PR 15548 docs/dev/ENVIRONMENT.md
PR 15570 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/ENVIRONMENT.md
PR 15621 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 16753 docs/dev/ENVIRONMENT.md
PR 16793 docs/dev/ENVIRONMENT.md
PR 16831 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/ENVIRONMENT.md
PR 17347 docs/dev/ENVIRONMENT.md
PR 17611 docs/dev/ENVIRONMENT.md
PR 17719 docs/dev/ENVIRONMENT.md
PR 17729 docs/dev/ENVIRONMENT.md
PR 17943 docs/dev/ENVIRONMENT.md
PR 18029 docs/dev/ENVIRONMENT.md
PR 18173 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/ENVIRONMENT.md
PR 18226 docs/dev/ENVIRONMENT.md
PR 18293 docs/dev/ENVIRONMENT.md
PR 18369 docs/dev/ENVIRONMENT.md
PR 19054 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
docs/dev/ENVIRONMENT.md
PR 19130 docs/dev/ENVIRONMENT.md
PR 19445 docs/dev/ENVIRONMENT.md
PR 19697 docs/dev/ENVIRONMENT.md
PR 20041 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/ENVIRONMENT.md
PR 20172 docs/dev/ENVIRONMENT.md
PR 20187 docs/dev/ENVIRONMENT.md
PR 20315 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/ENVIRONMENT.md
PR 20519 docs/dev/ENVIRONMENT.md
PR 21238 docs/dev/ENVIRONMENT.md
PR 21708 docs/dev/ENVIRONMENT.md
PR 22025 docs/dev/ENVIRONMENT.md
PR 22190 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/ENVIRONMENT.md
PR 22424 docs/dev/ENVIRONMENT.md
PR 22434 docs/dev/ENVIRONMENT.md
PR 22546 docs/dev/ENVIRONMENT.md
PR 22647 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/ENVIRONMENT.md
PR 22697 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/ENVIRONMENT.md
PR 22944 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/ENVIRONMENT.md
PR 23229 docs/dev/ENVIRONMENT.md
PR 23234 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 23243 docs/dev/ENVIRONMENT.md
PR 23244 docs/dev/ENVIRONMENT.md
PR 23248 docs/dev/ENVIRONMENT.md

@NathanFahey23

Copy link
Copy Markdown
Contributor

Windows NVIDIA check of head d86f2cb161, merged with --no-ff onto main 595b2f04de (9b89754b8f, clean merge).

Setup: Windows 11 Home 10.0.26300, i9-13900K, RTX 4080 (10de:2704), driver 32.0.16.2101, WinLibs GCC 15.2.0 Release, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1. GPU set: ctest -R '^(agc_|shader|video_out|guest_video)' --parallel 4 with the Khronos validation layer.

main 595b2f04de merge 9b89754b8f
GPU set 2006/2010 2007/2010
failures stencil_plane_memory, store_over_untracked, cached_image_multisample_guard, upload_cache_read_only_flush (Not Run) stencil_plane_memory, store_over_untracked, upload_cache_read_only_flush (Not Run)
VUID- lines 0 0

Every failure on the merge is on main too:

agc_driver_graphics, the test that builds the changed BdaResources.cpp, passes on both sides, as do its three _dump_* variants and the agc_driver_bda_* tests. The homebrew set (Jelly5, VLC, DriftCheck, PS5SX2, DOOM, 30 s each) renders on the merge.

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 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; the points below are optional.

What I ran

  • Head reviewed: d86f2cb161de60dee98520fee81478cdb9df64e2, base main.
  • 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, deviceLocalHasRoom returns false before it stores checkedMs. 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 new covered loop in spaceReadAcrossImportsTests assumes AddressRanges() 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.md and perf-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 kurexw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@Scramblrrrr

Copy link
Copy Markdown
Contributor

Thanks @nicolasabosch. I have reviewed #22072 at d86f2cb and will cross-test that bounded policy rather than open a competing PR for my broad access >= window rule. I will retain our existing WIP branch as a reference and bring over any useful synthetic/GPU readback regressions without changing your path restrictions.

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.

@Scramblrrrr

Scramblrrrr commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

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:

^agc_driver_graphics$|^agc_graphics_profile_draw$|^agc_driver_host_import_windows$|^agc_sparse_run_import(_copied)?$

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, APS5_NO_JOIN_STRADDLE=1 makes both agc_driver_graphics and agc_sparse_run_import fail their intended join assertions; removing the flag passes both again. Executable hashes were unchanged across this negative/recovery control. The native finite-view case therefore demonstrably uses the joined import on this Windows GPU, rather than merely passing a copy fallback.

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 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

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, deviceLocalHasRoom returns false for every bytes, including 0. The normal path returns bytes <= room, which is true for 0 when room is 0. This branch also leaves liveShadowLimit at its previous value. Impact looks small; I did not check whether any caller passes 0.

Sources

  • joinedRun with the straddle clause:
    ImportRun joinedRun(const GuestAllocations::Lease& lease, std::uint64_t begin, std::uint64_t end, bool straddling = false) {
    const auto window = importWindow.load(std::memory_order_relaxed);
    if (window == 0) return {};
    auto run = crossedRun(lease, begin, end);
    if (run.ranges.empty()) return run;
    if (std::all_of(run.ranges.begin(), run.ranges.end(), [window](const auto& range) { return range->bytes > window; })) return run;
    if (begin == run.base) return run;
    if (run.ranges.front()->bytes > window && run.bytes - run.ranges.front()->bytes <= window) return run;
    if (straddling && run.ranges.front()->bytes <= window && run.bytes <= end - begin + 2 * window) return run;
    return {};
    }
  • continuesRun:
    bool continuesRun(const GuestAllocations::Range& before, const GuestAllocations::Range& after) {
    return before.address + before.bytes == after.address && before.readable && after.readable && before.writable == after.writable && before.gpu == after.gpu;
    }
  • deviceLocalHasRoom:
    bool deviceLocalHasRoom(const Context& context, std::size_t bytes) {
    if (deviceLocalFullForTests.load(std::memory_order_relaxed)) return false;
    static std::atomic<std::int64_t> checkedMs{std::numeric_limits<std::int64_t>::min()};
    static std::atomic<std::uint64_t> room{std::numeric_limits<std::uint64_t>::max()};
    static std::atomic<VkDevice> checkedDevice{VK_NULL_HANDLE};
    const auto nowMs = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
    if (const auto last = checkedMs.load(std::memory_order_relaxed); last == std::numeric_limits<std::int64_t>::min() || nowMs - last >= 250 || checkedDevice.load(std::memory_order_relaxed) != context.device) {
    checkedDevice.store(context.device, std::memory_order_relaxed);
    VkPhysicalDeviceMemoryBudgetPropertiesEXT reported{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_BUDGET_PROPERTIES_EXT};
    VkPhysicalDeviceMemoryProperties2 properties{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2, &reported};
    if (context.memoryProperties2 != nullptr && context.physical != VK_NULL_HANDLE) context.memoryProperties2(context.physical, &properties);
    std::optional<std::uint32_t> deviceHeap;
    for (std::uint32_t index = 0; index < context.memory.memoryTypeCount && !deviceHeap; ++index) {
    if ((context.memory.memoryTypes[index].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) != 0) deviceHeap = context.memory.memoryTypes[index].heapIndex;
    }
    if (!deviceHeap) {
    room.store(0, std::memory_order_relaxed);
    checkedMs.store(nowMs, std::memory_order_relaxed);
    return false;
    }
    const auto heap = *deviceHeap;
    const auto budget = reported.heapBudget[heap];
    const auto usage = reported.heapUsage[heap];
    room.store(budget == 0 ? std::numeric_limits<std::uint64_t>::max() : usage + budget / 8u < budget ? budget - budget / 8u - usage : 0u, std::memory_order_relaxed);
    liveShadowLimit.store(shadowBytesLimit(budget != 0 ? budget : context.memory.memoryHeaps[heap].size), std::memory_order_relaxed);
    checkedMs.store(nowMs, std::memory_order_relaxed);
    }
    return bytes <= room.load(std::memory_order_relaxed);
  • UploadFinish join loop:
    const bool straddleJoins = joinStraddleEnabled();
    for (const auto& region : regions) {
    if (!region.pending || region.mirror != nullptr || region.direct != nullptr || sparseHeapCandidate(region)) continue;
    if (findImport(state, region.begin, region.end) != nullptr || runCovers(importRanges(), region.begin, region.end)) continue;
    static_cast<void>(importJoined(context, state, region.begin, region.end, importRanges(), straddleJoins && !region.sparse && (region.hostBacked || region.writable)));
    }
  • Straddle test:
    auto* heap = guest + 3 * large + 2 * piece;
    change(heap, piece, true);
    change(heap + piece, piece, true);
    const auto heapBase = reinterpret_cast<std::uintptr_t>(heap);
    const auto crossing = heapBase + piece - 16;
    const auto [straddledBuffer, straddledCopied] = bind(crossing);
    const auto* straddled = HostImportFor(importing, crossing, 32);
    Require(straddled != nullptr && straddled->joined && straddled->base == heapBase && straddled->bytes == 2 * piece && straddledBuffer == straddled->buffer && straddledCopied == 0, "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");
    const auto [piecesBuffer, piecesCopied] = bind(heapBase, 2 * piece);
    const auto* pieces = HostImportFor(importing, heapBase, 2 * piece);
    Require(pieces != nullptr && pieces->base == heapBase && pieces->bytes == 2 * piece && piecesBuffer == pieces->buffer && piecesCopied == 0, "a buffer bound exactly over two pieces no larger than the import window was not imported as one");

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.cpp was read only in the ranges above. Callers of joinedRun and importJoined outside those ranges were not checked.
  • continuesRun checks readable, writable and gpu, but not host-backed. The straddle gate in UploadFinish checks 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>
@nicolasabosch

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Pushed 58ef1c564bd for the non-blocking point: on a device with no device-local memory type, deviceLocalHasRoom now stores no room and shadowBytesLimit(0) as the staging shadow limit, then answers through the same bytes <= room check as the normal path, so a 0-byte request gets the same answer on both.

Build and test output for head 58ef1c564bd (Windows 11 Pro 26300, WinLibs GCC, Release, NVIDIA GeForce RTX 4070 Laptop GPU, driver 616.92):

  • Build: log. The only failed target is agc_driver_upload_cache_read_only_flush_tests, the MinGW setenv break on main that fix(tests): set the upload cache test's environment with _putenv_s on Windows #19899 fixes.
  • Focused tests, 17/17 passed: log.
  • The import-join set with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1, ctest -V, 8/8 passed: 11 Insert instance layer "VK_LAYER_KHRONOS_validation" lines, no was not found but was requested, no VUID-: log.
ctest output
Test project D:/Proyectos/AnyPS5_prC/build
      Start 2238: agc_driver_bda_device
      Start 2437: agc_driver_graphics
      Start 2427: agc_graphics_profile_draw
      Start 1465: agc_driver_bda_span_reads
      Start 2240: agc_driver_bda_span_reads_draw_pipeline
      Start 2241: agc_driver_bda_span_reads_plan_verify
 1/17 Test #2241: agc_driver_bda_span_reads_plan_verify .............   Passed    1.01 sec
      Start 1464: agc_driver_bda_anchor_reads
 2/17 Test #1465: agc_driver_bda_span_reads .........................   Passed    1.03 sec
      Start 1701: agc_driver_host_import_windows
 3/17 Test #2240: agc_driver_bda_span_reads_draw_pipeline ...........   Passed    1.03 sec
      Start 2512: agc_driver_partial_resident_alias
 4/17 Test #2238: agc_driver_bda_device .............................   Passed    1.45 sec
      Start 2511: agc_driver_host_import_alias_failure
 5/17 Test #1464: agc_driver_bda_anchor_reads .......................   Passed    0.86 sec
 6/17 Test #2512: agc_driver_partial_resident_alias .................   Passed    0.85 sec
      Start 2804: agc_bda_staging
      Start 2829: agc_changed_copy
 7/17 Test #2511: agc_driver_host_import_alias_failure ..............   Passed    0.67 sec
      Start 2806: agc_bda_staging_bound
 8/17 Test #2804: agc_bda_staging ...................................   Passed    0.72 sec
      Start 2835: agc_driver_bda_reads_shadowed_results
 9/17 Test #2829: agc_changed_copy ..................................   Passed    0.73 sec
      Start 2836: agc_driver_bda_reads_shadowed_results_per_build
10/17 Test #1701: agc_driver_host_import_windows ....................   Passed    1.66 sec
      Start 2831: agc_changed_copy_always
11/17 Test #2806: agc_bda_staging_bound .............................   Passed    0.59 sec
      Start 2239: agc_driver_bda_device_selection_cpu
12/17 Test #2239: agc_driver_bda_device_selection_cpu ...............   Passed    0.02 sec
13/17 Test #2835: agc_driver_bda_reads_shadowed_results .............   Passed    0.64 sec
14/17 Test #2836: agc_driver_bda_reads_shadowed_results_per_build ...   Passed    0.63 sec
15/17 Test #2831: agc_changed_copy_always ...........................   Passed    0.62 sec
16/17 Test #2437: agc_driver_graphics ...............................   Passed   10.27 sec
17/17 Test #2427: agc_graphics_profile_draw .........................   Passed   10.41 sec

100% tests passed, 0 tests failed out of 17

Total Test time (real) =  10.59 sec

On the host-backed question: I haven't checked that path yet, so I'm not claiming anything about it here.

@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; the points below are optional.

What I ran

  • Head 58ef1c564bd48f92de6e100278b24af38fe64ff1, base main. 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 against end - begin. importJoined may widen end first (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 original end.
  • The description says this change and #5372 both edit the joinedRun check, 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, the APS5_NO_JOIN_STRADDLE=1 negative 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.cpp is 8124 lines. I read the changed hunks and the functions they call (joinedRun, crossedRun, importJoined, importRunAt, deviceLocalHasRoom, and the join loop in UploadFinish). How the join interacts with refreshImports, budget eviction and failedJoins was not traced.
  • deviceLocalHasRoom with no device-local memory type: room is 0 and the shadow limit falls back to the default in shadowBytesLimit. Checked by reading; not run.
  • The definition of the dissolvedImports counter was not checked. HostImportOffset is declared in GuestBufferMemory.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.cpp lines 1837–1847, 2333–2344, 6283–6299, 6756–6760; tests/BdaResources.cpp lines 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:1845 when end was 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.

@domx4q

domx4q commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

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 0x10de, device 0x2684, Ada, subgroup 32), proprietary driver 620.70.06, Vulkan 1.4.357, Khronos validation layer 1.4.363.1. Head 58ef1c564b merged onto main 1adc0e2f4b with --no-ff, clean merge. Main baseline is a Release build of 1adc0e2f4b on the same machine.

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer \
ctest --test-dir build -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|agc_driver_graphics|agc_driver_bda_.*)$' -V
main 1adc0e2f4b this PR
Result 13 passed, 2 skipped, of 15 13 passed, 2 skipped, of 15
Insert instance layer "VK_LAYER_KHRONOS_validation" 14 14
was not found but was requested by env var VK_INSTANCE_LAYERS 0 0
VUID- none none

agc_graphics_profile_draw (with the new import-join cases), agc_driver_host_import_windows, agc_driver_graphics, agc_bda_staging, agc_bda_staging_bound, agc_changed_copy, agc_changed_copy_always and the agc_driver_bda_* tests pass on both sides. The two skips are the same on both sides: agc_driver_bda_reads_shadowed_results and _per_build, skipped, the device reports watched host memory written when it imports or reads it. agc_driver_host_import_alias_failure and agc_driver_partial_resident_alias do not exist in the Linux build on either side. Every device selection picked the RTX 4090. This is a correctness check only; I did not measure timings.

No new VUID- errors; all focused tests pass or skip identically on Ada.

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>
@nicolasabosch

Copy link
Copy Markdown
Contributor Author

Thanks. The wider bound is intended: importJoined widens begin/end to the whole of any joined import the buffer starts or ends in before calling joinedRun, as it does for every join, because the new import replaces that one and has to cover it. So the straddle bound is measured against that widened span, not the buffer alone. Taking it from the original end would refuse a buffer that ends inside an existing joined import and leave it copied. The captures in the description were made with this behaviour, so I kept the code and fixed the wording instead: 4e740bb21f3 updates the debt clause, and the description now says what the bound is compared against.

@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; the points below are optional.

What I ran

  • Head 4e740bb21f360a6f4685df024b96eeedd4602909 (base main), PR #22072, 4 files in the review folder.
  • Read the description, commit list, manifest, files.json and diff.patch from the review folder.
  • Read the changed code at head with the repository reader (repo_read.py cat on GuestBufferMemory.cpp lines 1820–1850, 6270–6305, 6740–6760; repo_read.py search for joinedRun, 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 sets liveShadowLimit to shadowBytesLimit(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 4e740bb21f36 was not inspected.
  • GuestBufferMemory.cpp is 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 in files/.
  • 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.

@MarcZX10

Copy link
Copy Markdown
Contributor

Reviewed — changes requested

This 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

  • Read the automated review output for head 4e740bb.
  • No tests or builds were run for this review.

Results

Check Result Note
Merge risk High Stale textures, buffers, or descriptors are possible. Some API calls can fault instead of returning an error.
Security architecture Moderate Bad output pointers can fault the host process instead of returning an error. No privilege escalation or remote path was shown.
Inline findings 24 14 blocking and 10 non-blocking.

Findings

Blocking

  • core/libs/prx/libSceAgcDriver/Execution/src/Driver/Synchronization/WaitMemory.cpp:156: The own-label check skips the epoch bump when the label value matches a recorded queue store. A CPU write can restore the same label value after that store. A later collect of the awaited range in the same epoch can then return an old generation and miss the CPU write. Require the exception only when no CPU write to the range can have happened since the matched store. Confirm the store stamp ordering against received first. If that ordering cannot be shown, keep the bump.
  • core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp:2708: storeOwn advances the proof serial only on entry. The store runs later under the tracker lock, and nothing advances the serial after it. A consumer can read the serial before the store lands, pass validation, and reuse a stale proof in the same epoch. Advance the serial again after the store and its stamping finish. Cover every return path, including the early returns. Release the tracker lock first where needed. Keep the entry advance.
  • Texture.cpp:2545: storeOwn advances the proof serial only on entry (GuestMemory.cpp:2708). The store callback runs later, under the tracker lock (2724-2741), and no serial change follows it. A proof consumer can read the post-entry serial before the store completes. Its validation can pass before the store takes the tracker lock. The consumer then stores that serial as its proof key (Texture.cpp:2551-2560). The same-epoch reuse check (Texture.cpp:2545-2550) compares only the serials, so the stale proof is reused after the store changes memory.
  • Texture.cpp:2551: storeOwn advances the proof serial only on entry (GuestMemory.cpp:2708). The store callback runs later, under the tracker lock (2724-2741), and no serial change follows it. A proof consumer can read the post-entry serial before the store completes. Its validation can pass before the store takes the tracker lock. The consumer then stores that serial as its proof key (Texture.cpp:2551-2560). The same-epoch reuse check (Texture.cpp:2545-2550) compares only the serials, so the stale proof is reused after the store changes memory.
  • core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp:2161: The retirement path and the FMASK guard-add path no longer bump guardedGeneration. BdaResources reuses tables when this generation is unchanged. A table built before either change can pass that check. Retired ranges then stay excluded, and newly guarded ranges stay included. Bump the generation on both paths whenever the exclusion set changes. Follow the active-flag erase pattern nearby. Do not bump when the set is unchanged.
  • MultisampleTarget.cpp:2169: ExcludeMultisampleTargetRanges reports guardedGeneration, and BdaResources reuses tables when that generation is unchanged. The retirement path at MultisampleTarget.cpp:2161 and the FMASK guard-add path no longer increment guardedGeneration. A table built before either change can therefore pass TableGuardCurrent without recomputation. A retired range stays excluded, or a newly guarded range stays included. Restore the increment on both paths. Use the same pattern as the active-flag erase at MultisampleTarget.cpp:2169.
  • core/libs/prx/libSceFont/src/Render.cpp:567: The attribute result is written directly to the caller's pointer. If the glyph is valid but the output points to unmapped or read-only memory, the write faults. The old checked copy returned an error instead. Restore the checked copy-out and its error return. Valid writable outputs must still receive 0x10 or 0x11.
  • core/libs/prx/libSceNet/Export.cpp:3070: sceNetResolverStartNtoa writes its result directly. A bad non-null output pointer faults instead of returning NET_EFAULT. In async mode, the fault also skips complete_async_lookup. Use checked copy-out and return NET_EFAULT on failure. Keep the synchronous return and the async completion behavior.
  • core/libs/prx/libSceNet/Export.cpp:3081: Same defect in the second resolver output path. Use checked copy-out, return NET_EFAULT on failure, and make sure async completion still runs.
  • core/libs/prx/libSceNet/Export.cpp:3093: Same defect in the third resolver output path. Use checked copy-out, return NET_EFAULT on failure, and make sure async completion still runs.
  • core/libs/prx/libSceUserService/Export.cpp:465: The user-name export uses an unchecked memset in the short-buffer branch. A valid user ID with a non-null read-only buffer now faults. The removed guest-copy path returned USER_SERVICE_ERROR_INVALID_ARGUMENT here. Use checked guest writes and return that error on failure. Keep zeroing writable short buffers before returning USER_SERVICE_ERROR_BUFFER_TOO_SHORT. This also weakens fault containment. Under default fatal-signal handling, the whole emulation process can end instead of the call failing.
  • core/libs/prx/libSceUserService/Export.cpp:468: Same defect in the full-size branch, which uses an unchecked strncpy. Use checked guest writes and return USER_SERVICE_ERROR_INVALID_ARGUMENT on failure.
  • core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp:2179: The GCN conversion for table image words was removed. The direct descriptor path still converts these words. Table entries without a resource view now reach the RDNA decoder in GCN layout. The decoder then reads format and size fields from the wrong positions. Registered-array views also use unconverted words. Restore the conversion on both the normalization path and the table lookup path. Keep the existing GCN gating and descriptor-validity checks. Sampler words and non-GCN descriptors must stay unchanged.
  • core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterHelpers.hpp:301: AtomicUpdateTyped always emits the device-scope barrier for non-LDS atomics. It ignores APS5_NO_ATOMIC_BARRIER. The previous path checked this switch. This breaks the documented diagnostic opt-out for these updates. Apply the same opt-out check here. Keep the resource-specific memory semantics and the LDS lock guard.

Non-blocking

  • core/libs/prx/libSceAgcDriver/Execution/src/Driver/Memory/BufferCopy.cpp:211: The table copy calls FinishLeaseWork(), which waits for the newest deferred lease, including read-only batches. Use FinishLeaseWrites() here. Today, a copy that follows a deferred read-only draw waits on that draw while it holds the GPU mutex. Repeated draw and copy sequences then serialize CPU and GPU work. Writing-lease waits must stay the same.
  • core/libs/prx/libSceAgcDriver/Execution/src/Driver/Memory/BufferCopy.cpp:240: The indexed copy path has the same FinishLeaseWork() call. Change it to FinishLeaseWrites() as well.
  • core/libs/tests/GuestFstatFault.cpp:137: The seccomp fault-injection check fails when the kernel has no seccomp filter support. The child then exits with status 2, even if guest copying works. Skip this check when filter installation is unavailable. Keep asserting it when installation succeeds. Apply the same handling to RequireNonEfaultFailureThrows and to the matching check in GuestOutputPointerFault.cpp. Other errors must still fail the test.
  • docs/dev/debt/libSceUserService.md:155: The PR edits the consolidated debt file directly. The repository rule says a PR adds its own fragment instead. Restore the existing sceUserServiceGetUserName entry. Move this update into a branch debt fragment under the libSceUserService section, with a uniquely matching change operation.
  • docs/dev/debt/shader.md:54: The PR edits this debt entry directly, including "Device fence after atomics." Restore the entry and represent the change as a change operation in a debt fragment.
  • docs/dev/debt/shader.md:64: The PR edits this debt entry directly. Restore it and move the change into a debt fragment.
  • docs/dev/debt/shader.md:293: The PR edits this debt entry directly. Restore it and move the change into a debt fragment.
  • tools/tests/test_check_conventions_blob_reads.py:27: The fixture's git helper does not disable tag signing. With tag.gpgsign set globally, creating the base tag fails without a message, and the repository() fixture fails before its assertions run. Add tag.gpgsign=false next to the existing user.email and commit.gpgsign overrides. Keep the other arguments.
  • tools/tests/test_check_conventions_env_reference.py:20: The fixture's git helper does not disable tag signing. Tags created through git("tag", ...) depend on the developer's global settings. Add tag.gpgsign=false next to the existing commit signing override so fixture tags stay lightweight.
  • tools/tests/test_check_main_sync.py:30: The helper does not disable tag signing. The literal-base tag can fail on a machine with global tag signing enabled. Set tag.gpgsign=false and keep the existing identity and environment values.

Not verified

  • No tests or builds were run. Whether the sync, epoch, and descriptor problems appear in real games or in the test suites is unknown.
  • The ordering claims behind the WaitMemory and GuestMemory findings were not confirmed. In particular, the stamp ordering relative to received was not checked.
  • The same-epoch proof reuse path in Texture.cpp and the table-guard path in MultisampleTarget.cpp were not traced beyond the cited lines.
  • The check on core/libs/prx/libSceAgcDriver/tests/Recorder.cpp did not finish, and its output was cut off. The reported items were not verified. They include a dangling lifetime at lines 9251 and 9310, an unhandled exception in an entry point at 17101, missing returns at 10786, 10865, and 10869, and possible null-pointer arithmetic at 9820, 10291, 13216, 13402, and 15883.
  • Wording in docs/dev/debt/shader.md and docs/dev/debt/libSceUserService.md was not fully checked.
  • core/libs/tests/GuestOutputPointerFault.cpp was not read directly. The note about it comes from the summary of the GuestFstatFault finding.
  • The security note on the user-name export assumes default fatal-signal handling in the host. This was not reproduced.
  • Most of the PR was not checked line by line. This includes the switch to process_vm syscalls for guest copies, the fixed timed-wait lead, the dynamic loader unregistration change, straddling buffer imports, the 4096-entry draw-cache default, the removed PE export bounds checks in tools/symbolize_samples.py, and the removed audio mastering test.

To get this to a good state

Fix 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 AtomicUpdateTyped honor APS5_NO_ATOMIC_BARRIER. Restore the guardedGeneration bumps on both MultisampleTarget paths and the proof-serial advance in storeOwn. Make the same-epoch proof reuse in Texture.cpp safe against a store that has not finished. Tighten the own-label wait exception, or keep the epoch bump when the ordering cannot be shown. Then make the non-blocking changes. Use writes-only lease waits in both copy paths. Skip the seccomp checks when filter installation is unavailable. Move the debt edits into fragments. Disable tag signing in the three tools test fixtures. Rerun the AGC driver, libc, libkernel, guest, shader recompiler, and tools test suites. Run the fault tests on a kernel with seccomp and on one without it. Then request a new review of the updated head.

@Scramblrrrr

Copy link
Copy Markdown
Contributor

Current-head Windows cross-test: canonical 4e740bb21f360a6f4685df024b96eeedd4602909 combines with main 561a8c4b942685a2737f428c391432c34b9d46f4, #9508 7d4214c1, #22550 and the independent sparse-page correction. Production integration 2195fa9f9cfc744da8869da3e1c609b4db09b8e7 passes 70 selected native cases x 3 = 210/210, zero skips, 89 actual Khronos layer insertions/run and no VUID/SYNC identifiers. Same 21 shared controls passed 63/63 on main, 21 real insertions/run.

I also ported the earlier test-only regressions onto this current stack. They can be cherry-picked separately from the heap work:

  • d3b5998bd3: bounded interior/import-owner lifetime checks, exact returned descriptor offset/extent, two views sharing one import, and real Vulkan buffer-transfer readbacks across alternating finite views.
  • d6da6cd329708599d11601cdc747bbc0f64083ad: exercise the writable path in the policy cases.

Both are public on codex/gpu-heap-imports-nov17. Only tests/BdaResources.cpp and tests/Recorder.cpp differ from the production integration; no additional production changes. The real transfer compares every returned byte with guest memory and checks that alternating views retain their shared import. This is a buffer/descriptor-data regression, not a new shader-instruction semantics claim.

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 APS5_NO_JOIN_STRADDLE=1, the policy case and native sparse-run case both fail their intended interior-view join assertions; the native case has an actual layer insertion and zero VUIDs. Removing the flag passes both cases three times (6/6), same fixture EXE hashes, one actual insertion/run and no VUIDs. The standalone policy case reaches its assertion before Vulkan initialization; I am not counting that alone as GPU validation.

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. ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_GPU=NVIDIA, requested Khronos layer with loader insertion confirmed. No Linux/AMD qualification or title performance gain claimed. The updated matched 007 runtime has just started under its guard; previous heap-only warm traces still showed substantial copies and resource preparation. Raw title code, captures and traces remain local. AI-assisted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@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 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.

@Scramblrrrr

Copy link
Copy Markdown
Contributor

One scope check on the changes-requested review above, to separate independent concerns from changes introduced by this PR.

I compared both reviewed head 4e740bb21f360a6f4685df024b96eeedd4602909 and current canonical head 7099836106bb93eb24928c11fc042b4a27f36658 against their merge bases with current upstream main. In both cases the topic diff contains only:

  • Graphics/src/GuestBufferMemory.cpp
  • tests/BdaResources.cpp
  • docs/dev/ENVIRONMENT.md
  • docs/dev/debt/changes/perf-agc-join-straddling-imports.md

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 18b40c99bf516ed2770c066c0c3fec2020d849cd. This PR therefore does not introduce the removals attributed to it in those files. The review may still identify independent issues in shared code; this diff check does not prove those behaviors correct or replace a reproducer.

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.

@ShootanoJumper

Copy link
Copy Markdown
Contributor

Windows 11 23H2 (22631), Ryzen 7 5700X, NVIDIA RTX 4060 (driver 616.56), WinLibs GCC 15.2.0 r7, Release, merged into main ed1def4dd4 with git merge --no-ff.

All 53 tests the change reaches pass.
No validation layer is installed here, so this says nothing about VUID- errors.

@oneandonlydean
oneandonlydean merged commit 5dcb2b0 into boykopovar:main Nov 20, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs perf Performance change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants