perf(shader): read a read-only buffer's base misalignment at run time #27812

Open
DerKarussellbremser wants to merge 4 commits from upstream-pr/27812 into main
DerKarussellbremser commented 2026-11-27 13:36:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DerKarussellbremser on 2026-11-27T13:36:51Z.


What

A buffer V# whose base is not on a DWORD boundary is bound from the DWORD below, and every access shifts by the base's low two bits. Those two bits are a specialization constant of the module (BufferBase + index * BufferWords + 3). A program is therefore specialized, and its pipeline compiled by the driver, once per combination of base alignments of its buffers.

Horizon Zero Dawn Remastered (PPSA13428, 01.008.001) binds read-only buffers at bases with address & 3 of 0, 1 and 2 to the same compute programs. In a 900 s run from an empty shader cache on main, 166 of 382 specialized compute modules were a second or later variant of a program, and 155 of those differed from another variant of the same program only in this constant. Each module is about 200 KiB of SPIR-V and takes the driver about a second to compile, on the thread that executes the dispatches.

For a buffer the program neither writes nor uses atomically, the module now takes the two bits from the buffer's byte offset (memoryByteOffsets), which the driver already passes for every bound buffer. Its low two bits are the base's: GuestBufferMemory::Descriptor requires the bound view to start on a DWORD and sets the offset to the distance from there. The binding plan no longer emits the constant for those buffers, so descriptors that differ only in base alignment share one module. The value is available inside the formatted-load helper function as well, where the byte offset is a parameter.

Written and atomic buffers keep the constant. An unaligned store is a compare-exchange loop on two words, and #4152 (item 15) found that leaving those loops in every module hung an RTX 4090. A read has no loop: it is a second load and two shifts, selected by the two bits.

Tested

Windows 11 Home 10.0.26200, i7-10750H, 16 GB, NVIDIA GeForce RTX 2060 6 GB, driver 610.91, WinLibs GCC 15.2.0 r7 UCRT, Release.

  • agc_shader_disk_cache checks that the binding plan of a read-only buffer whose base is 2 bytes off a DWORD has no misalignment constant. The check next to it, that an atomic buffer records its misalignment, is unchanged.
    • Red on the base: with the recompiler as on main it fails with a read-only V# off a DWORD boundary specialized its module on the misalignment.
  • agc_guarded_memory_loads traces the loads of an emitted module for a given misalignment. Its evaluator returned 0 for every push-data load and supplied the misalignment through the constant only; it now returns the misalignment for the push-data load too, which is where a read-only buffer takes it from. Without that the unaligned cases read one word instead of two (plain guest reads: 2; expected: 2 3).
  • ctest -R "unaligned|buffer_format|formatted|runtime_buffer_spans|guarded_memory_loads|shader_disk_cache|^agc_driver_graphics" on main f73d791b3d with this change: 40 of 40 pass. That includes agc_formatted_buffer_once, which checks that registration form has no more compare-exchanges than the specialized form, and the device tests for unaligned bases (agc_driver_buffer_unaligned_base, agc_driver_formatted_store_unaligned, agc_driver_buffer_atomic_unaligned).
  • agc_driver_dispatch_move (review, 2ba7d8b57b, test only): one compiled vector program runs with its input two bytes past a DWORD, one byte past it and back, over data whose bytes all differ; every lane reads the four bytes at its own offset, and the copy of the template from one base onto the other is refused (checked 1, moved 0, refused 1). With the validation layer loaded agc_driver_dispatch_move and agc_driver_dispatch_move_depth pass, no VUID- line.
  • tools/check_conventions.py --base origin/main passes.
  • tools/pr_overlap.py --branch perf/shader-read-misalignment-at-run-time: 40 open PRs touch one of the five files, 22 of them the three recompiler files. I compared those 22 from their fetched heads: none changes where the direct path takes the base misalignment from. #21971 and #22071 call baseMisalignment and work with either source. #20248 (opt-in native buffer descriptor tables) reads the two bits from the V# word in its own table path.
  • spirv-val --target-env vulkan1.3 on 120 modules the title produced with this change (16 vertex, 23 pixel, 81 compute): all valid.
  • Horizon Zero Dawn Remastered, 900 s from an empty shader cache, scripted input, main 00b15fcbb0 against the same commit with this change:
main this change
specialized compute modules written 382 365
distinct programs among them 216 295
second or later variants 166 70
of those, differing in a buffer's misalignment 155 0
compute pipelines created 322 306
median module size 208 KiB 206 KiB
GPU time per present in the menu (median of 10 s intervals) 9.30 ms 9.12 ms

The title compiles about as many pipelines in the same time, but 37 % more of them are programs it had not compiled yet. It does not get the title past this phase: both runs are still compiling new programs when they end (one present every 40 to 90 s), and on an earlier base a second run on the warm cache found 244 more programs. The 70 remaining variants differ in image swizzle constants (a null T# against an R-only one), which this PR does not touch.

  • The title runs above are on 00b15fcbb0. The branch is on f73d791b3d; I rebuilt it there and ran the ctest set above, but did not repeat the title comparison on that commit.
  • Performance capture as the Performance report form asks, added 2026-11-29: Horizon Zero Dawn Remastered, the opening sequence from 100 to 130 s after the first present, 3840x2160, APS5_TRACE_SECONDS=100:30, no other trace or profile switch, log not redirected, the same scripted input. Each side ran the scene once before (200 s) on its own shader cache and was restarted. main 69d574e9a2 against the same commit with this branch merged (768548584f, pushed as capture/pr-27812-on-main-69d574e, because the branch itself sits on f73d791b3d):
main 69d574e9a2 with this change 768548584f
presents in the window 754 in 30.0 s 893 in 30.0 s
frame time p50 / p90 33.37 / 34.99 ms 33.37 / 33.64 ms
frame time p99 / max 231.1 / 627.2 ms 46.2 / 65.0 ms
GPU busy per present 9.95 ms 9.60 ms
Driver.Dispatch per frame 18.95 ms 14.38 ms

The median frame is the title's 30 fps limit on both sides; the difference is the long frames. main has five frames of 270 to 630 ms in the window, the merged build none above 65 ms. I have not traced what those frames on main wait for, and a 200 s warm-up does not guarantee that every variant of the window was already in the cache, so I read this as consistent with fewer variants to specialize, not as proof of it. One capture per side.

Summary lines
{"commit":"69d574e9a2cc","dirty":false,"env":{"APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"100:30"},"gpu":"NVIDIA GeForce RTX 2060","driver":"NVIDIA 610.91","os":"Windows 10.0.26200","cpu":"Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz","cpu_threads":12,"memory_mib":16221,"title_id":"PPSA13428","title":"Horizon Zero Dawn™ Remastered","content_version":"01.008.001","resolution":"3840x2160","window":{"spec":"seconds 100:30","first_present":3147,"ms":30013.303},"presents":754,"frame_ms":{"p50":33.372,"p90":34.994,"p99":231.131,"max":627.211},"gpu_busy_ms_per_present":9.949,"worker_busy_pct":{"queue worker 0x0":59.854,"queue worker 0x20":0.018,"queue worker 0x28":0.176,"queue worker 0x30":0.214,"queue worker 0x38":0.150,"queue worker 0x40":0.156,"queue worker 0x48":0.154,"queue worker 0x50":0.218,"queue worker 0x21":0.227,"queue worker 0x29":0.191,"queue worker 0x31":0.179,"queue worker 0x39":0.166,"queue worker 0x41":0.144,"queue worker 0x49":0.193},"phase_totals_ms":{"DrawPipeline.Drain.packet.not_candidate":325.877,"DrawPipeline.Drain.packet.rendering":2963.459,"DrawPipeline.Drain.submission.suspend":213.150,"Driver.Completion":83.398,"Driver.Dispatch":14288.546,"Driver.Dispatch.capture_resources":6863.014,"Driver.Dispatch.decode_key_device_setup":320.850,"Driver.Dispatch.lookup_cache":135.119,"Driver.Dispatch.materialize":1432.917,"Driver.Dispatch.prepared_invocation":12.034,"Driver.Draw":196.310,"Driver.Draw.device_setup":23.258,"Driver.Draw.draw_enqueued":29.334,"Driver.Draw.post_compile_prepare":4.388,"Driver.Draw.prepare":46.698,"Driver.Draw.shader_compile_and_link":86.353,"Driver.EndSubmission":258.678,"Driver.FinisherDrain":2.878,"Driver.MemoryWait.entry.memory":35.874,"Driver.MemoryWait.entry.store.queue_0x0":0.028,"Driver.Packet":18274.522,"Driver.Packet.device_lock":17.673,"Driver.Packet.dispatch":14326.381,"Driver.Packet.draw":201.647,"Driver.Packet.execute":54.474,"Driver.Packet.flip_flush":15.037,"Driver.Packet.flush_between_packets":431.336,"Driver.Packet.memory_wait":38.300,"Driver.Packet.pipeline_drain":2989.046,"Driver.Packet.pipeline_prepare":28.700,"Driver.Packet.prepare_memory":34.199,"Driver.Packet.rendering_wait":12.884,"Driver.Present":2688.664,"Driver.Present.acquire_image":21.105,"Driver.Present.device_setup":0.904,"Driver.Present.gpu_mutex_wait":749.621,"Driver.Present.inflight_wait":3.982,"Driver.Present.present_display_buffer":306.337,"Driver.Present.queue_present":141.359,"Driver.Present.release_and_callback":16.020,"Driver.Present.render_fence_wait":1444.352,"Driver.Present.resize":3.210,"Driver.Present.validate":0.450,"Driver.Suspend":0.656,"GpuMutex.wait.dispatch":45.624,"GpuMutex.wait.draw":4.031,"GpuMutex.wait.end":4.842,"GpuMutex.wait.flush":14.264,"GpuMutex.wait.hook":12.466,"GpuMutex.wait.label":53.419,"GpuMutex.wait.other":1.181,"GpuMutex.wait.present":746.339,"GpuMutex.wait.wait":637.047,"Graphics.Draw":1921.204,"Graphics.Draw.draw_and_resource_release":1911.238,"Graphics.Draw.index_upload":0.367,"Graphics.Draw.validate":6.560,"Graphics.Draw.vertex_upload":1.099,"Graphics.DrawWithRecipe":1130.116,"Graphics.DrawWithRecipe.draw_and_resource_release":752.629,"Graphics.DrawWithRecipe.index_upload":0.887,"Graphics.DrawWithRecipe.validate":5.967,"Graphics.DrawWithRecipe.vertex_upload":3.880,"Recorder.Reap":89.767,"Recorder.Submit":667.346,"Recorder.Sync":16.469,"Recorder.WaitSerial":23.889,"Resources.Complete":1150.480,"Resources.Prepare":225.757,"Shader.DrawStage":21.596,"Shader.DrawStage.capture_resources":12.581,"Shader.DrawStage.materialize":4.766,"Shader.DrawStage.prepared_invocation":3.901,"Shader.Register":84.777,"Shader.ResolveAbi":30.698,"Shader.ResolveGraphicsAbi":6.885,"Shader.ResolveGraphicsStagesAbi":49.344,"VideoOut.Flip":22194.446,"VideoOut.Flip.completion_mutex_wait":8.201,"VideoOut.Flip.config_mutex_wait":3.202,"VideoOut.Flip.frame_limit":3.364,"VideoOut.Flip.notify_game":40.093,"VideoOut.Flip.present":2684.982,"VideoOut.Flip.validate":1.549,"VideoOut.Flip.vblank_wait":19472.616,"VideoOut.Flip.window_prepare":2.832,"VideoOut.Flip.window_title":6.759,"VideoOut.Readiness":3.744,"VideoOut.Readiness.locks_validate":1.879,"Vulkan.Acquire":19.449,"Vulkan.Acquire.acquire_fence_wait":3.407,"Vulkan.Acquire.acquire_image":11.662,"Vulkan.Acquire.fence_reset":3.093,"Vulkan.Acquire.retired_swapchains":0.773,"Vulkan.Dispatch":762.285,"Vulkan.Dispatch.command_record":149.586,"Vulkan.Dispatch.shader_resources":608.715,"Vulkan.DispatchRecipe":196.477,"Vulkan.DispatchRecipe.command_record":182.717,"Vulkan.DrawFromRecipe":1135.952,"Vulkan.Present":170.590,"Vulkan.Present.command_record_scale":59.863,"Vulkan.Present.pixel_upload":7.053,"Vulkan.Present.queue_submit":101.293,"Vulkan.QueuePresent":137.355,"Vulkan.QueuePresent.queue_present":134.868,"Vulkan.Retire":1443.959,"Vulkan.Retire.wait":1427.185},"top_phases_ms_per_frame":{"VideoOut.Flip":29.436,"VideoOut.Flip.vblank_wait":25.826,"Driver.Packet":24.237,"Driver.Packet.dispatch":19.001,"Driver.Dispatch":18.950,"Driver.Dispatch.capture_resources":9.102,"Driver.Packet.pipeline_drain":3.964,"DrawPipeline.Drain.packet.rendering":3.930},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.copy":1440,"Graphics.Barrier.dispatch-lead":5358,"Graphics.Barrier.dispatch-trail":6297,"Graphics.Barrier.draw":8883,"Graphics.Barrier.label-run":18482,"Graphics.Barrier.present-blit":1508,"Graphics.Barrier.shadow-publish":4,"Graphics.Barrier.staging-in":4452,"Graphics.Barrier.staging-out":2029,"Graphics.Barrier.storage-upload":16,"Graphics.Barrier.storage-writeback":8,"Graphics.BarrierMerged.copy":400,"Graphics.BarrierMerged.dispatch-lead":939,"Graphics.BarrierMerged.shadow-publish":4,"Graphics.BarrierMerged.staging-in":1555,"Graphics.BarrierMerged.staging-out":2029,"Graphics.Copy":6413,"Graphics.Copy.bytes":13170679216,"Graphics.RenderPass":4602,"Graphics.RenderPass.Close.command":735,"Graphics.RenderPass.Close.image":359,"Graphics.RenderPass.Close.key":1547,"Graphics.RenderPass.Close.new-batch":1960,"Graphics.RenderPass.Continued":703},"trace_dropped":false,"trace":"aps5-trace-69d574e9a2cc-74352.json.gz"}
{"commit":"768548584fc3","dirty":false,"env":{"APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"100:30"},"gpu":"NVIDIA GeForce RTX 2060","driver":"NVIDIA 610.91","os":"Windows 10.0.26200","cpu":"Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz","cpu_threads":12,"memory_mib":16221,"title_id":"PPSA13428","title":"Horizon Zero Dawn™ Remastered","content_version":"01.008.001","resolution":"3840x2160","window":{"spec":"seconds 100:30","first_present":3117,"ms":30029.991},"presents":893,"frame_ms":{"p50":33.368,"p90":33.636,"p99":46.196,"max":64.992},"gpu_busy_ms_per_present":9.604,"worker_busy_pct":{"queue worker 0x0":57.734,"queue worker 0x20":0.017,"queue worker 0x28":0.189,"queue worker 0x30":0.227,"queue worker 0x38":0.166,"queue worker 0x40":0.138,"queue worker 0x48":0.205,"queue worker 0x50":0.179,"queue worker 0x21":0.194,"queue worker 0x29":0.178,"queue worker 0x31":0.153,"queue worker 0x39":0.185,"queue worker 0x41":0.193,"queue worker 0x49":0.206},"phase_totals_ms":{"DrawPipeline.Drain.packet.not_candidate":303.045,"DrawPipeline.Drain.packet.rendering":3854.064,"DrawPipeline.Drain.submission.suspend":276.495,"Driver.Completion":136.468,"Driver.Dispatch":12840.060,"Driver.Dispatch.capture_resources":8388.013,"Driver.Dispatch.decode_key_device_setup":405.747,"Driver.Dispatch.lookup_cache":157.285,"Driver.Dispatch.materialize":1754.555,"Driver.Dispatch.prepared_invocation":11.965,"Driver.Draw":243.768,"Driver.Draw.device_setup":28.196,"Driver.Draw.draw_enqueued":36.692,"Driver.Draw.post_compile_prepare":5.317,"Driver.Draw.prepare":58.268,"Driver.Draw.shader_compile_and_link":107.781,"Driver.EndSubmission":322.325,"Driver.FinisherDrain":3.394,"Driver.MemoryWait.entry.memory":47.616,"Driver.Packet":17544.386,"Driver.Packet.device_lock":18.027,"Driver.Packet.dispatch":12883.149,"Driver.Packet.draw":250.167,"Driver.Packet.execute":63.349,"Driver.Packet.flip_flush":10.477,"Driver.Packet.flush_between_packets":188.513,"Driver.Packet.memory_wait":50.465,"Driver.Packet.pipeline_drain":3880.822,"Driver.Packet.pipeline_prepare":28.661,"Driver.Packet.prepare_memory":37.217,"Driver.Packet.rendering_wait":4.192,"Driver.Present":3205.470,"Driver.Present.acquire_image":25.590,"Driver.Present.device_setup":1.126,"Driver.Present.gpu_mutex_wait":212.273,"Driver.Present.inflight_wait":5.216,"Driver.Present.present_display_buffer":367.132,"Driver.Present.queue_present":157.443,"Driver.Present.release_and_callback":23.916,"Driver.Present.render_fence_wait":2407.135,"Driver.Present.resize":3.507,"Driver.Present.validate":0.543,"Driver.Suspend":0.644,"GpuMutex.wait.dispatch":76.788,"GpuMutex.wait.draw":17.729,"GpuMutex.wait.end":3.899,"GpuMutex.wait.flush":3.406,"GpuMutex.wait.hook":2.171,"GpuMutex.wait.label":69.312,"GpuMutex.wait.other":5.301,"GpuMutex.wait.present":208.338,"GpuMutex.wait.wait":128.672,"Graphics.Draw":2493.405,"Graphics.Draw.draw_and_resource_release":2482.610,"Graphics.Draw.index_upload":0.350,"Graphics.Draw.validate":7.166,"Graphics.Draw.vertex_upload":1.150,"Graphics.DrawWithRecipe":1472.772,"Graphics.DrawWithRecipe.draw_and_resource_release":932.038,"Graphics.DrawWithRecipe.index_upload":1.097,"Graphics.DrawWithRecipe.validate":7.561,"Graphics.DrawWithRecipe.vertex_upload":5.215,"Recorder.Reap":108.034,"Recorder.Submit":535.378,"Recorder.Sync":84.320,"Recorder.WaitSerial":31.374,"Resources.Complete":1129.007,"Resources.Prepare":163.689,"Shader.DrawStage":25.337,"Shader.DrawStage.capture_resources":14.925,"Shader.DrawStage.materialize":5.473,"Shader.DrawStage.prepared_invocation":4.445,"Shader.Register":86.215,"Shader.ResolveAbi":37.755,"Shader.ResolveGraphicsAbi":8.683,"Shader.ResolveGraphicsStagesAbi":64.935,"VideoOut.Flip":22737.090,"VideoOut.Flip.completion_mutex_wait":5.580,"VideoOut.Flip.config_mutex_wait":4.136,"VideoOut.Flip.frame_limit":3.982,"VideoOut.Flip.notify_game":65.531,"VideoOut.Flip.present":3209.865,"VideoOut.Flip.validate":1.876,"VideoOut.Flip.vblank_wait":19461.409,"VideoOut.Flip.window_prepare":3.236,"VideoOut.Flip.window_title":10.512,"VideoOut.Readiness":4.948,"VideoOut.Readiness.locks_validate":2.741,"Vulkan.Acquire":23.594,"Vulkan.Acquire.acquire_fence_wait":4.741,"Vulkan.Acquire.acquire_image":13.370,"Vulkan.Acquire.fence_reset":3.912,"Vulkan.Acquire.retired_swapchains":0.969,"Vulkan.Dispatch":654.224,"Vulkan.Dispatch.command_record":171.165,"Vulkan.Dispatch.shader_resources":479.196,"Vulkan.DispatchRecipe":173.349,"Vulkan.DispatchRecipe.command_record":172.010,"Vulkan.DrawFromRecipe":1480.184,"Vulkan.Present":202.651,"Vulkan.Present.command_record_scale":70.576,"Vulkan.Present.pixel_upload":11.820,"Vulkan.Present.queue_submit":117.144,"Vulkan.QueuePresent":152.709,"Vulkan.QueuePresent.queue_present":149.819,"Vulkan.Retire":2406.762,"Vulkan.Retire.wait":2384.333},"top_phases_ms_per_frame":{"VideoOut.Flip":25.461,"VideoOut.Flip.vblank_wait":21.793,"Driver.Packet":19.647,"Driver.Packet.dispatch":14.427,"Driver.Dispatch":14.379,"Driver.Dispatch.capture_resources":9.393,"Driver.Packet.pipeline_drain":4.346,"DrawPipeline.Drain.packet.rendering":4.316},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.copy":48,"Graphics.Barrier.dispatch-lead":6317,"Graphics.Barrier.dispatch-trail":7185,"Graphics.Barrier.draw":10444,"Graphics.Barrier.label-run":18784,"Graphics.Barrier.present-blit":1786,"Graphics.Barrier.shadow-publish":4,"Graphics.Barrier.staging-in":3577,"Graphics.Barrier.staging-out":1815,"Graphics.Barrier.storage-upload":16,"Graphics.Barrier.storage-writeback":8,"Graphics.BarrierMerged.copy":12,"Graphics.BarrierMerged.dispatch-lead":868,"Graphics.BarrierMerged.shadow-publish":4,"Graphics.BarrierMerged.staging-in":1796,"Graphics.BarrierMerged.staging-out":1815,"Graphics.Copy":6342,"Graphics.Copy.bytes":14490206232,"Graphics.RenderPass":5369,"Graphics.RenderPass.Close.command":810,"Graphics.RenderPass.Close.image":332,"Graphics.RenderPass.Close.key":1923,"Graphics.RenderPass.Close.new-batch":2304,"Graphics.RenderPass.Continued":772},"trace_dropped":false,"trace":"aps5-trace-768548584fc3-87116.json.gz"}

The two traces (aps5-trace-69d574e9a2cc-74352.json.gz, aps5-trace-768548584fc3-87116.json.gz) follow in a comment.

  • Not covered: Linux and macOS, AMD and Intel GPUs. The run measures no GPU cost in the menu, where few of these buffers are read; I have no measurement of a scene that reads them heavily, because the title does not reach one on this machine.

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: NVIDIA GeForce RTX 2060, driver 610.91, Windows 11 Home 10.0.26200
  • AI-assisted: yes

🤖 Generated with Claude Code

https://claude.ai/code/session_011TXsSW8zeAgKgHLCFsYwM3

Summary by CodeRabbit

  • Bug Fixes

    • Read-only buffers now use their actual runtime alignment when needed, improving handling of buffers whose starting address is misaligned.
    • Buffer-base misalignment specialization is no longer applied to read-only buffers that rely on runtime alignment.
    • Buffer moves that change alignment are now rejected in cases where the existing dispatch cannot safely handle the change.
  • Tests

    • Added coverage for misaligned read-only buffers, alignment changes during dispatch moves, and specialization selection.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5527559832 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27812). Originally posted by [DerKarussellbremser](https://github.com/DerKarussellbremser) on 2026-11-27T13:36:51Z. --- ### What A buffer V# whose base is not on a DWORD boundary is bound from the DWORD below, and every access shifts by the base's low two bits. Those two bits are a specialization constant of the module (`BufferBase + index * BufferWords + 3`). A program is therefore specialized, and its pipeline compiled by the driver, once per combination of base alignments of its buffers. Horizon Zero Dawn Remastered (PPSA13428, 01.008.001) binds read-only buffers at bases with `address & 3` of 0, 1 and 2 to the same compute programs. In a 900 s run from an empty shader cache on `main`, 166 of 382 specialized compute modules were a second or later variant of a program, and 155 of those differed from another variant of the same program only in this constant. Each module is about 200 KiB of SPIR-V and takes the driver about a second to compile, on the thread that executes the dispatches. For a buffer the program neither writes nor uses atomically, the module now takes the two bits from the buffer's byte offset (`memoryByteOffsets`), which the driver already passes for every bound buffer. Its low two bits are the base's: `GuestBufferMemory::Descriptor` requires the bound view to start on a DWORD and sets the offset to the distance from there. The binding plan no longer emits the constant for those buffers, so descriptors that differ only in base alignment share one module. The value is available inside the formatted-load helper function as well, where the byte offset is a parameter. Written and atomic buffers keep the constant. An unaligned store is a compare-exchange loop on two words, and #4152 (item 15) found that leaving those loops in every module hung an RTX 4090. A read has no loop: it is a second load and two shifts, selected by the two bits. ### Tested Windows 11 Home 10.0.26200, i7-10750H, 16 GB, NVIDIA GeForce RTX 2060 6 GB, driver 610.91, WinLibs GCC 15.2.0 r7 UCRT, Release. - `agc_shader_disk_cache` checks that the binding plan of a read-only buffer whose base is 2 bytes off a DWORD has no misalignment constant. The check next to it, that an atomic buffer records its misalignment, is unchanged. - **Red on the base:** with the recompiler as on `main` it fails with `a read-only V# off a DWORD boundary specialized its module on the misalignment`. - `agc_guarded_memory_loads` traces the loads of an emitted module for a given misalignment. Its evaluator returned 0 for every push-data load and supplied the misalignment through the constant only; it now returns the misalignment for the push-data load too, which is where a read-only buffer takes it from. Without that the unaligned cases read one word instead of two (`plain guest reads: 2; expected: 2 3`). - `ctest -R "unaligned|buffer_format|formatted|runtime_buffer_spans|guarded_memory_loads|shader_disk_cache|^agc_driver_graphics"` on `main` `f73d791b3d` with this change: 40 of 40 pass. That includes `agc_formatted_buffer_once`, which checks that registration form has no more compare-exchanges than the specialized form, and the device tests for unaligned bases (`agc_driver_buffer_unaligned_base`, `agc_driver_formatted_store_unaligned`, `agc_driver_buffer_atomic_unaligned`). - `agc_driver_dispatch_move` (review, `2ba7d8b57b`, test only): one compiled vector program runs with its input two bytes past a DWORD, one byte past it and back, over data whose bytes all differ; every lane reads the four bytes at its own offset, and the copy of the template from one base onto the other is refused (`checked 1, moved 0, refused 1`). With the validation layer loaded `agc_driver_dispatch_move` and `agc_driver_dispatch_move_depth` pass, no `VUID-` line. - `tools/check_conventions.py --base origin/main` passes. - `tools/pr_overlap.py --branch perf/shader-read-misalignment-at-run-time`: 40 open PRs touch one of the five files, 22 of them the three recompiler files. I compared those 22 from their fetched heads: none changes where the direct path takes the base misalignment from. #21971 and #22071 call `baseMisalignment` and work with either source. #20248 (opt-in native buffer descriptor tables) reads the two bits from the V# word in its own table path. - `spirv-val --target-env vulkan1.3` on 120 modules the title produced with this change (16 vertex, 23 pixel, 81 compute): all valid. - **Horizon Zero Dawn Remastered**, 900 s from an empty shader cache, scripted input, `main` `00b15fcbb0` against the same commit with this change: | | `main` | this change | |---|---|---| | specialized compute modules written | 382 | 365 | | distinct programs among them | 216 | 295 | | second or later variants | 166 | 70 | | of those, differing in a buffer's misalignment | 155 | 0 | | compute pipelines created | 322 | 306 | | median module size | 208 KiB | 206 KiB | | GPU time per present in the menu (median of 10 s intervals) | 9.30 ms | 9.12 ms | The title compiles about as many pipelines in the same time, but 37 % more of them are programs it had not compiled yet. It does not get the title past this phase: both runs are still compiling new programs when they end (one present every 40 to 90 s), and on an earlier base a second run on the warm cache found 244 more programs. The 70 remaining variants differ in image swizzle constants (a null T# against an R-only one), which this PR does not touch. - The title runs above are on `00b15fcbb0`. The branch is on `f73d791b3d`; I rebuilt it there and ran the ctest set above, but did not repeat the title comparison on that commit. - **Performance capture** as the Performance report form asks, added 2026-11-29: Horizon Zero Dawn Remastered, the opening sequence from 100 to 130 s after the first present, 3840x2160, `APS5_TRACE_SECONDS=100:30`, no other trace or profile switch, log not redirected, the same scripted input. Each side ran the scene once before (200 s) on its own shader cache and was restarted. `main` `69d574e9a2` against the same commit with this branch merged (`768548584f`, pushed as [`capture/pr-27812-on-main-69d574e`](https://github.com/DerKarussellbremser/AnyPS5/tree/capture/pr-27812-on-main-69d574e), because the branch itself sits on `f73d791b3d`): | | `main` `69d574e9a2` | with this change `768548584f` | |---|---|---| | presents in the window | 754 in 30.0 s | 893 in 30.0 s | | frame time p50 / p90 | 33.37 / 34.99 ms | 33.37 / 33.64 ms | | frame time p99 / max | 231.1 / 627.2 ms | 46.2 / 65.0 ms | | GPU busy per present | 9.95 ms | 9.60 ms | | `Driver.Dispatch` per frame | 18.95 ms | 14.38 ms | The median frame is the title's 30 fps limit on both sides; the difference is the long frames. `main` has five frames of 270 to 630 ms in the window, the merged build none above 65 ms. I have not traced what those frames on `main` wait for, and a 200 s warm-up does not guarantee that every variant of the window was already in the cache, so I read this as consistent with fewer variants to specialize, not as proof of it. One capture per side. <details><summary>Summary lines</summary> ```json {"commit":"69d574e9a2cc","dirty":false,"env":{"APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"100:30"},"gpu":"NVIDIA GeForce RTX 2060","driver":"NVIDIA 610.91","os":"Windows 10.0.26200","cpu":"Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz","cpu_threads":12,"memory_mib":16221,"title_id":"PPSA13428","title":"Horizon Zero Dawn™ Remastered","content_version":"01.008.001","resolution":"3840x2160","window":{"spec":"seconds 100:30","first_present":3147,"ms":30013.303},"presents":754,"frame_ms":{"p50":33.372,"p90":34.994,"p99":231.131,"max":627.211},"gpu_busy_ms_per_present":9.949,"worker_busy_pct":{"queue worker 0x0":59.854,"queue worker 0x20":0.018,"queue worker 0x28":0.176,"queue worker 0x30":0.214,"queue worker 0x38":0.150,"queue worker 0x40":0.156,"queue worker 0x48":0.154,"queue worker 0x50":0.218,"queue worker 0x21":0.227,"queue worker 0x29":0.191,"queue worker 0x31":0.179,"queue worker 0x39":0.166,"queue worker 0x41":0.144,"queue worker 0x49":0.193},"phase_totals_ms":{"DrawPipeline.Drain.packet.not_candidate":325.877,"DrawPipeline.Drain.packet.rendering":2963.459,"DrawPipeline.Drain.submission.suspend":213.150,"Driver.Completion":83.398,"Driver.Dispatch":14288.546,"Driver.Dispatch.capture_resources":6863.014,"Driver.Dispatch.decode_key_device_setup":320.850,"Driver.Dispatch.lookup_cache":135.119,"Driver.Dispatch.materialize":1432.917,"Driver.Dispatch.prepared_invocation":12.034,"Driver.Draw":196.310,"Driver.Draw.device_setup":23.258,"Driver.Draw.draw_enqueued":29.334,"Driver.Draw.post_compile_prepare":4.388,"Driver.Draw.prepare":46.698,"Driver.Draw.shader_compile_and_link":86.353,"Driver.EndSubmission":258.678,"Driver.FinisherDrain":2.878,"Driver.MemoryWait.entry.memory":35.874,"Driver.MemoryWait.entry.store.queue_0x0":0.028,"Driver.Packet":18274.522,"Driver.Packet.device_lock":17.673,"Driver.Packet.dispatch":14326.381,"Driver.Packet.draw":201.647,"Driver.Packet.execute":54.474,"Driver.Packet.flip_flush":15.037,"Driver.Packet.flush_between_packets":431.336,"Driver.Packet.memory_wait":38.300,"Driver.Packet.pipeline_drain":2989.046,"Driver.Packet.pipeline_prepare":28.700,"Driver.Packet.prepare_memory":34.199,"Driver.Packet.rendering_wait":12.884,"Driver.Present":2688.664,"Driver.Present.acquire_image":21.105,"Driver.Present.device_setup":0.904,"Driver.Present.gpu_mutex_wait":749.621,"Driver.Present.inflight_wait":3.982,"Driver.Present.present_display_buffer":306.337,"Driver.Present.queue_present":141.359,"Driver.Present.release_and_callback":16.020,"Driver.Present.render_fence_wait":1444.352,"Driver.Present.resize":3.210,"Driver.Present.validate":0.450,"Driver.Suspend":0.656,"GpuMutex.wait.dispatch":45.624,"GpuMutex.wait.draw":4.031,"GpuMutex.wait.end":4.842,"GpuMutex.wait.flush":14.264,"GpuMutex.wait.hook":12.466,"GpuMutex.wait.label":53.419,"GpuMutex.wait.other":1.181,"GpuMutex.wait.present":746.339,"GpuMutex.wait.wait":637.047,"Graphics.Draw":1921.204,"Graphics.Draw.draw_and_resource_release":1911.238,"Graphics.Draw.index_upload":0.367,"Graphics.Draw.validate":6.560,"Graphics.Draw.vertex_upload":1.099,"Graphics.DrawWithRecipe":1130.116,"Graphics.DrawWithRecipe.draw_and_resource_release":752.629,"Graphics.DrawWithRecipe.index_upload":0.887,"Graphics.DrawWithRecipe.validate":5.967,"Graphics.DrawWithRecipe.vertex_upload":3.880,"Recorder.Reap":89.767,"Recorder.Submit":667.346,"Recorder.Sync":16.469,"Recorder.WaitSerial":23.889,"Resources.Complete":1150.480,"Resources.Prepare":225.757,"Shader.DrawStage":21.596,"Shader.DrawStage.capture_resources":12.581,"Shader.DrawStage.materialize":4.766,"Shader.DrawStage.prepared_invocation":3.901,"Shader.Register":84.777,"Shader.ResolveAbi":30.698,"Shader.ResolveGraphicsAbi":6.885,"Shader.ResolveGraphicsStagesAbi":49.344,"VideoOut.Flip":22194.446,"VideoOut.Flip.completion_mutex_wait":8.201,"VideoOut.Flip.config_mutex_wait":3.202,"VideoOut.Flip.frame_limit":3.364,"VideoOut.Flip.notify_game":40.093,"VideoOut.Flip.present":2684.982,"VideoOut.Flip.validate":1.549,"VideoOut.Flip.vblank_wait":19472.616,"VideoOut.Flip.window_prepare":2.832,"VideoOut.Flip.window_title":6.759,"VideoOut.Readiness":3.744,"VideoOut.Readiness.locks_validate":1.879,"Vulkan.Acquire":19.449,"Vulkan.Acquire.acquire_fence_wait":3.407,"Vulkan.Acquire.acquire_image":11.662,"Vulkan.Acquire.fence_reset":3.093,"Vulkan.Acquire.retired_swapchains":0.773,"Vulkan.Dispatch":762.285,"Vulkan.Dispatch.command_record":149.586,"Vulkan.Dispatch.shader_resources":608.715,"Vulkan.DispatchRecipe":196.477,"Vulkan.DispatchRecipe.command_record":182.717,"Vulkan.DrawFromRecipe":1135.952,"Vulkan.Present":170.590,"Vulkan.Present.command_record_scale":59.863,"Vulkan.Present.pixel_upload":7.053,"Vulkan.Present.queue_submit":101.293,"Vulkan.QueuePresent":137.355,"Vulkan.QueuePresent.queue_present":134.868,"Vulkan.Retire":1443.959,"Vulkan.Retire.wait":1427.185},"top_phases_ms_per_frame":{"VideoOut.Flip":29.436,"VideoOut.Flip.vblank_wait":25.826,"Driver.Packet":24.237,"Driver.Packet.dispatch":19.001,"Driver.Dispatch":18.950,"Driver.Dispatch.capture_resources":9.102,"Driver.Packet.pipeline_drain":3.964,"DrawPipeline.Drain.packet.rendering":3.930},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.copy":1440,"Graphics.Barrier.dispatch-lead":5358,"Graphics.Barrier.dispatch-trail":6297,"Graphics.Barrier.draw":8883,"Graphics.Barrier.label-run":18482,"Graphics.Barrier.present-blit":1508,"Graphics.Barrier.shadow-publish":4,"Graphics.Barrier.staging-in":4452,"Graphics.Barrier.staging-out":2029,"Graphics.Barrier.storage-upload":16,"Graphics.Barrier.storage-writeback":8,"Graphics.BarrierMerged.copy":400,"Graphics.BarrierMerged.dispatch-lead":939,"Graphics.BarrierMerged.shadow-publish":4,"Graphics.BarrierMerged.staging-in":1555,"Graphics.BarrierMerged.staging-out":2029,"Graphics.Copy":6413,"Graphics.Copy.bytes":13170679216,"Graphics.RenderPass":4602,"Graphics.RenderPass.Close.command":735,"Graphics.RenderPass.Close.image":359,"Graphics.RenderPass.Close.key":1547,"Graphics.RenderPass.Close.new-batch":1960,"Graphics.RenderPass.Continued":703},"trace_dropped":false,"trace":"aps5-trace-69d574e9a2cc-74352.json.gz"} {"commit":"768548584fc3","dirty":false,"env":{"APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"100:30"},"gpu":"NVIDIA GeForce RTX 2060","driver":"NVIDIA 610.91","os":"Windows 10.0.26200","cpu":"Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz","cpu_threads":12,"memory_mib":16221,"title_id":"PPSA13428","title":"Horizon Zero Dawn™ Remastered","content_version":"01.008.001","resolution":"3840x2160","window":{"spec":"seconds 100:30","first_present":3117,"ms":30029.991},"presents":893,"frame_ms":{"p50":33.368,"p90":33.636,"p99":46.196,"max":64.992},"gpu_busy_ms_per_present":9.604,"worker_busy_pct":{"queue worker 0x0":57.734,"queue worker 0x20":0.017,"queue worker 0x28":0.189,"queue worker 0x30":0.227,"queue worker 0x38":0.166,"queue worker 0x40":0.138,"queue worker 0x48":0.205,"queue worker 0x50":0.179,"queue worker 0x21":0.194,"queue worker 0x29":0.178,"queue worker 0x31":0.153,"queue worker 0x39":0.185,"queue worker 0x41":0.193,"queue worker 0x49":0.206},"phase_totals_ms":{"DrawPipeline.Drain.packet.not_candidate":303.045,"DrawPipeline.Drain.packet.rendering":3854.064,"DrawPipeline.Drain.submission.suspend":276.495,"Driver.Completion":136.468,"Driver.Dispatch":12840.060,"Driver.Dispatch.capture_resources":8388.013,"Driver.Dispatch.decode_key_device_setup":405.747,"Driver.Dispatch.lookup_cache":157.285,"Driver.Dispatch.materialize":1754.555,"Driver.Dispatch.prepared_invocation":11.965,"Driver.Draw":243.768,"Driver.Draw.device_setup":28.196,"Driver.Draw.draw_enqueued":36.692,"Driver.Draw.post_compile_prepare":5.317,"Driver.Draw.prepare":58.268,"Driver.Draw.shader_compile_and_link":107.781,"Driver.EndSubmission":322.325,"Driver.FinisherDrain":3.394,"Driver.MemoryWait.entry.memory":47.616,"Driver.Packet":17544.386,"Driver.Packet.device_lock":18.027,"Driver.Packet.dispatch":12883.149,"Driver.Packet.draw":250.167,"Driver.Packet.execute":63.349,"Driver.Packet.flip_flush":10.477,"Driver.Packet.flush_between_packets":188.513,"Driver.Packet.memory_wait":50.465,"Driver.Packet.pipeline_drain":3880.822,"Driver.Packet.pipeline_prepare":28.661,"Driver.Packet.prepare_memory":37.217,"Driver.Packet.rendering_wait":4.192,"Driver.Present":3205.470,"Driver.Present.acquire_image":25.590,"Driver.Present.device_setup":1.126,"Driver.Present.gpu_mutex_wait":212.273,"Driver.Present.inflight_wait":5.216,"Driver.Present.present_display_buffer":367.132,"Driver.Present.queue_present":157.443,"Driver.Present.release_and_callback":23.916,"Driver.Present.render_fence_wait":2407.135,"Driver.Present.resize":3.507,"Driver.Present.validate":0.543,"Driver.Suspend":0.644,"GpuMutex.wait.dispatch":76.788,"GpuMutex.wait.draw":17.729,"GpuMutex.wait.end":3.899,"GpuMutex.wait.flush":3.406,"GpuMutex.wait.hook":2.171,"GpuMutex.wait.label":69.312,"GpuMutex.wait.other":5.301,"GpuMutex.wait.present":208.338,"GpuMutex.wait.wait":128.672,"Graphics.Draw":2493.405,"Graphics.Draw.draw_and_resource_release":2482.610,"Graphics.Draw.index_upload":0.350,"Graphics.Draw.validate":7.166,"Graphics.Draw.vertex_upload":1.150,"Graphics.DrawWithRecipe":1472.772,"Graphics.DrawWithRecipe.draw_and_resource_release":932.038,"Graphics.DrawWithRecipe.index_upload":1.097,"Graphics.DrawWithRecipe.validate":7.561,"Graphics.DrawWithRecipe.vertex_upload":5.215,"Recorder.Reap":108.034,"Recorder.Submit":535.378,"Recorder.Sync":84.320,"Recorder.WaitSerial":31.374,"Resources.Complete":1129.007,"Resources.Prepare":163.689,"Shader.DrawStage":25.337,"Shader.DrawStage.capture_resources":14.925,"Shader.DrawStage.materialize":5.473,"Shader.DrawStage.prepared_invocation":4.445,"Shader.Register":86.215,"Shader.ResolveAbi":37.755,"Shader.ResolveGraphicsAbi":8.683,"Shader.ResolveGraphicsStagesAbi":64.935,"VideoOut.Flip":22737.090,"VideoOut.Flip.completion_mutex_wait":5.580,"VideoOut.Flip.config_mutex_wait":4.136,"VideoOut.Flip.frame_limit":3.982,"VideoOut.Flip.notify_game":65.531,"VideoOut.Flip.present":3209.865,"VideoOut.Flip.validate":1.876,"VideoOut.Flip.vblank_wait":19461.409,"VideoOut.Flip.window_prepare":3.236,"VideoOut.Flip.window_title":10.512,"VideoOut.Readiness":4.948,"VideoOut.Readiness.locks_validate":2.741,"Vulkan.Acquire":23.594,"Vulkan.Acquire.acquire_fence_wait":4.741,"Vulkan.Acquire.acquire_image":13.370,"Vulkan.Acquire.fence_reset":3.912,"Vulkan.Acquire.retired_swapchains":0.969,"Vulkan.Dispatch":654.224,"Vulkan.Dispatch.command_record":171.165,"Vulkan.Dispatch.shader_resources":479.196,"Vulkan.DispatchRecipe":173.349,"Vulkan.DispatchRecipe.command_record":172.010,"Vulkan.DrawFromRecipe":1480.184,"Vulkan.Present":202.651,"Vulkan.Present.command_record_scale":70.576,"Vulkan.Present.pixel_upload":11.820,"Vulkan.Present.queue_submit":117.144,"Vulkan.QueuePresent":152.709,"Vulkan.QueuePresent.queue_present":149.819,"Vulkan.Retire":2406.762,"Vulkan.Retire.wait":2384.333},"top_phases_ms_per_frame":{"VideoOut.Flip":25.461,"VideoOut.Flip.vblank_wait":21.793,"Driver.Packet":19.647,"Driver.Packet.dispatch":14.427,"Driver.Dispatch":14.379,"Driver.Dispatch.capture_resources":9.393,"Driver.Packet.pipeline_drain":4.346,"DrawPipeline.Drain.packet.rendering":4.316},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.copy":48,"Graphics.Barrier.dispatch-lead":6317,"Graphics.Barrier.dispatch-trail":7185,"Graphics.Barrier.draw":10444,"Graphics.Barrier.label-run":18784,"Graphics.Barrier.present-blit":1786,"Graphics.Barrier.shadow-publish":4,"Graphics.Barrier.staging-in":3577,"Graphics.Barrier.staging-out":1815,"Graphics.Barrier.storage-upload":16,"Graphics.Barrier.storage-writeback":8,"Graphics.BarrierMerged.copy":12,"Graphics.BarrierMerged.dispatch-lead":868,"Graphics.BarrierMerged.shadow-publish":4,"Graphics.BarrierMerged.staging-in":1796,"Graphics.BarrierMerged.staging-out":1815,"Graphics.Copy":6342,"Graphics.Copy.bytes":14490206232,"Graphics.RenderPass":5369,"Graphics.RenderPass.Close.command":810,"Graphics.RenderPass.Close.image":332,"Graphics.RenderPass.Close.key":1923,"Graphics.RenderPass.Close.new-batch":2304,"Graphics.RenderPass.Continued":772},"trace_dropped":false,"trace":"aps5-trace-768548584fc3-87116.json.gz"} ``` </details> The two traces (`aps5-trace-69d574e9a2cc-74352.json.gz`, `aps5-trace-768548584fc3-87116.json.gz`) follow in a comment. - Not covered: Linux and macOS, AMD and Intel GPUs. The run measures no GPU cost in the menu, where few of these buffers are read; I have no measurement of a scene that reads them heavily, because the title does not reach one on this machine. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 2060, driver 610.91, Windows 11 Home 10.0.26200 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_011TXsSW8zeAgKgHLCFsYwM3 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Read-only buffers now use their actual runtime alignment when needed, improving handling of buffers whose starting address is misaligned. * Buffer-base misalignment specialization is no longer applied to read-only buffers that rely on runtime alignment. * Buffer moves that change alignment are now rejected in cases where the existing dispatch cannot safely handle the change. * **Tests** * Added coverage for misaligned read-only buffers, alignment changes during dispatch moves, and specialization selection. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
MarcZX10 commented 2026-11-27 14:00:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T14:00:32Z.

Review: COMMENTED


Reviewed — no blocking findings

The targeted code review found no verified blocking defect; execution checks were unavailable in this review session.

What I ran

Reviewed head e6396891f0b530c0209db7bc248cee316d7904b6 using the prepared review bundle and pinned-head reader. No build or tests were run here.

Results

Check Result Note
Targeted code review passed Changed logic and relevant callers inspected
Build and tests not run Could not execute commands in this session
Author reported checks not run Results in the PR description were not independently verified

Findings

Blocking

None verified in the inspected code.

Non-blocking

None.

Sources

Not verified

No tests, build, or runtime checks were performed. Read the PR description, commits, manifest, diff, and relevant ranges in all five changed files; full file text beyond those ranges was not read. files.json was not available through the reader; the manifest lists all five changed files as included, with no excluded changed files shown.

To get this to a good state

Nothing is required. Optional: run the PR's reported checks on this head to independently confirm the reported results.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6089263705 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27812#pullrequestreview-6089263705). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-27T14:00:32Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The targeted code review found no verified blocking defect; execution checks were unavailable in this review session. ## What I ran Reviewed head `e6396891f0b530c0209db7bc248cee316d7904b6` using the prepared review bundle and pinned-head reader. No build or tests were run here. ## Results | Check | Result | Note | |---|---|---| | Targeted code review | passed | Changed logic and relevant callers inspected | | Build and tests | not run | Could not execute commands in this session | | Author reported checks | not run | Results in the PR description were not independently verified | ## Findings ### Blocking None verified in the inspected code. ### Non-blocking None. ## Sources - [Descriptor binding specialization](https://github.com/boykopovar/AnyPS5/blob/e6396891f0b530c0209db7bc248cee316d7904b6/core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp) - [Runtime misalignment handling](https://github.com/boykopovar/AnyPS5/blob/e6396891f0b530c0209db7bc248cee316d7904b6/core/shader/recompiler/SpirvBackend/src/SpirvRuntimeBuffer.cpp) ## Not verified No tests, build, or runtime checks were performed. Read the PR description, commits, manifest, diff, and relevant ranges in all five changed files; full file text beyond those ranges was not read. `files.json` was not available through the reader; the manifest lists all five changed files as included, with no excluded changed files shown. ## To get this to a good state Nothing is required. Optional: run the PR's reported checks on this head to independently confirm the reported results.
MarcZX10 commented 2026-11-28 06:25:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T06:25:35Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the review supports merging.

What I ran

Reviewed head 49ef7c2d06aeccd81ad4c65a0b166f6db7c87bc4. I read the prepared description, commit list, manifest, diff, all six included changed files, and the excluded changed file’s relevant functions through repo_read.py. No test or build commands were run.

Results

Check Result Note
Diff and targeted source review passed Seven changed files reviewed
Tests and build not run Author reports checks; not run here

Findings

Blocking

None.

Non-blocking

None.

Not verified

Tests, builds, and hardware behavior were not verified in this review. ShaderResources.cpp was excluded from the prepared full-text bundle; only the relevant moved-buffer functions were read through the reader. All other changed files listed in the manifest were read. No changed files were excluded by files.json rules beyond that file’s size limit.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6096263931 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27812#pullrequestreview-6096263931). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-28T06:25:35Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the review supports merging. ## What I ran Reviewed head `49ef7c2d06aeccd81ad4c65a0b166f6db7c87bc4`. I read the prepared description, commit list, manifest, diff, all six included changed files, and the excluded changed file’s relevant functions through `repo_read.py`. No test or build commands were run. ## Results | Check | Result | Note | |---|---|---| | Diff and targeted source review | passed | Seven changed files reviewed | | Tests and build | not run | Author reports checks; not run here | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified Tests, builds, and hardware behavior were not verified in this review. `ShaderResources.cpp` was excluded from the prepared full-text bundle; only the relevant moved-buffer functions were read through the reader. All other changed files listed in the manifest were read. No changed files were excluded by `files.json` rules beyond that file’s size limit. ## To get this to a good state Nothing is required.
Plyxen commented 2026-12-03 12:37:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-03T12:37:57Z.

Review: APPROVED


I read the diff at 49ef7c2d06. Windows 11, GCC 15.2, merged into main at daa61711afe together with other open PRs (so not an isolated build), with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 and VK_LAYER_KHRONOS_validation on an RTX 5080 (621.24) and a Radeon iGPU (26.11.2).

  • agc_shader_disk_cache, agc_driver_dispatch_move and agc_guarded_memory_loads: pass on both GPUs. The loader log shows the layer inserted and no "was not found" line, and neither run has a VUID- or SYNC-HAZARD line.
  • Control (the same tree with only this PR's source change taken out): agc_shader_disk_cache and agc_driver_dispatch_move fail.

Not checked: the pipeline counts in the body, and a title.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6169958880 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27812#pullrequestreview-6169958880). Originally posted by [Plyxen](https://github.com/Plyxen) on 2026-12-03T12:37:57Z. **Review:** APPROVED --- I read the diff at `49ef7c2d06`. Windows 11, GCC 15.2, merged into `main` at `daa61711afe` together with other open PRs (so not an isolated build), with `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1` and `VK_LAYER_KHRONOS_validation` on an RTX 5080 (621.24) and a Radeon iGPU (26.11.2). - `agc_shader_disk_cache`, `agc_driver_dispatch_move` and `agc_guarded_memory_loads`: pass on both GPUs. The loader log shows the layer inserted and no "was not found" line, and neither run has a `VUID-` or `SYNC-HAZARD` line. - Control (the same tree with only this PR's source change taken out): `agc_shader_disk_cache` and `agc_driver_dispatch_move` fail. Not checked: the pipeline counts in the body, and a title. AI-assisted: yes (Claude Code)
ligmaSec commented 2026-12-03 20:55:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T20:55:18Z.

Review: COMMENTED


Can the dispatch fixture also reuse the same compiled shader for a nonzero-to-nonzero change, for example base +2 to base +1, with asymmetric data and a vector read that spans two words? The added scalar case moves from +2 to an aligned base and reads the DWORD below the descriptor. That covers the move refusal and scalar alignment, while the proposed case exercises live offset changes and the shifted load through the same module.

Source review at 49ef7c2d06. The head trial-merges onto 6ef4f2f73b. Focused Linux checks are queued.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6178382540 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27812#pullrequestreview-6178382540). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T20:55:18Z. **Review:** COMMENTED --- Can the dispatch fixture also reuse the same compiled shader for a nonzero-to-nonzero change, for example base +2 to base +1, with asymmetric data and a vector read that spans two words? The added scalar case moves from +2 to an aligned base and reads the DWORD below the descriptor. That covers the move refusal and scalar alignment, while the proposed case exercises live offset changes and the shifted load through the same module. Source review at `49ef7c2d06`. The head trial-merges onto `6ef4f2f73b`. Focused Linux checks are queued. AI-assisted: yes.
MarcZX10 commented 2026-12-04 00:34:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-04T00:34:30Z.

Review: APPROVED


Reviewed — looks good

The reviewed change removes read-only buffer base misalignment from pipeline specialization while preserving the runtime offset and refusing unsafe dispatch-template moves.

What I ran

Reviewed head 2ba7d8b57b960fd124df8727146478d4d491e058 against main using the pinned repo_read.py reader and the prepared diff. No merged-preview check was run. No tests or builds were run; test and performance results in the description are author-reported. The review environment was limited to the reader and shell; no compiler or test toolchain was used.

python3 repo_read.py cat <repository-path> <line> <line>
python3 repo_read.py search <pattern> <repository-path>

Read all seven changed files listed under reviewed in files.json, including changed lines in ShaderResources.cpp through the reader. files.json lists no excluded files.

Results

Check Result Note
Changed-source review passed All seven changed files read
Tests and build not run Author-reported results only
Performance capture not run Author-reported results only

Negative control

Not run; no tests were run during this review.

Findings

Blocking

None.

Non-blocking

None.

Sources

Not verified

I did not run the tests or independently verify the described title runs, performance captures, or console behavior. Those results are reported by the author. All changed source files were read; no files were excluded by files.json.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6181178852 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27812#pullrequestreview-6181178852). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-12-04T00:34:30Z. **Review:** APPROVED --- # Reviewed — looks good The reviewed change removes read-only buffer base misalignment from pipeline specialization while preserving the runtime offset and refusing unsafe dispatch-template moves. ## What I ran Reviewed head `2ba7d8b57b960fd124df8727146478d4d491e058` against `main` using the pinned `repo_read.py` reader and the prepared diff. No merged-preview check was run. No tests or builds were run; test and performance results in the description are author-reported. The review environment was limited to the reader and shell; no compiler or test toolchain was used. ```text python3 repo_read.py cat <repository-path> <line> <line> python3 repo_read.py search <pattern> <repository-path> ``` Read all seven changed files listed under `reviewed` in `files.json`, including changed lines in `ShaderResources.cpp` through the reader. `files.json` lists no excluded files. ## Results | Check | Result | Note | |---|---|---| | Changed-source review | passed | All seven changed files read | | Tests and build | not run | Author-reported results only | | Performance capture | not run | Author-reported results only | ## Negative control Not run; no tests were run during this review. ## Findings ### Blocking None. ### Non-blocking None. ## Sources - [ShaderResources.cpp at reviewed head](https://github.com/DerKarussellbremser/AnyPS5/blob/2ba7d8b57b960fd124df8727146478d4d491e058/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp) - [DescriptorBindingBuilder.cpp at reviewed head](https://github.com/DerKarussellbremser/AnyPS5/blob/2ba7d8b57b960fd124df8727146478d4d491e058/core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp) - [SpirvRuntimeBuffer.cpp at reviewed head](https://github.com/DerKarussellbremser/AnyPS5/blob/2ba7d8b57b960fd124df8727146478d4d491e058/core/shader/recompiler/SpirvBackend/src/SpirvRuntimeBuffer.cpp) ## Not verified I did not run the tests or independently verify the described title runs, performance captures, or console behavior. Those results are reported by the author. All changed source files were read; no files were excluded by `files.json`. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-12-04 09:07:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-04T09:07:00Z.

Review: APPROVED


Reviewed — looks good

The reviewed change removes read-only buffer base misalignment from pipeline specialization and obtains it from descriptor offsets at run time; I found no verified blocking defects.

What I ran

Reviewed head 1298bfe8d0aca0ea52664b557ee7b9e348968720. I inspected the prepared diff and manifest, then used repo_read.py to read relevant source ranges and search descriptor offset usage. I did not run tests or compile anything. The test and performance results in the PR description are author-reported.

Results

Check Result Note
Changed code review passed All seven changed files reviewed
Automated checks not run PR description reports passing checks
Console behavior not run Hardware results are author-reported

Negative control

Not run by me. The PR description reports a red-on-base check for the specialization change.

Findings

Blocking

None.

Non-blocking

None.

Sources

Not verified

I did not independently verify the author-reported test runs, SPIR-V validation, performance captures, or behavior on other hardware. The six changed files included in the review folder were read in relevant sections; the excluded ShaderResources.cpp was read through repo_read.py at the changed code and surrounding logic.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6186271584 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27812#pullrequestreview-6186271584). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-12-04T09:07:00Z. **Review:** APPROVED --- # Reviewed — looks good The reviewed change removes read-only buffer base misalignment from pipeline specialization and obtains it from descriptor offsets at run time; I found no verified blocking defects. ## What I ran Reviewed head `1298bfe8d0aca0ea52664b557ee7b9e348968720`. I inspected the prepared diff and manifest, then used `repo_read.py` to read relevant source ranges and search descriptor offset usage. I did not run tests or compile anything. The test and performance results in the PR description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | All seven changed files reviewed | | Automated checks | not run | PR description reports passing checks | | Console behavior | not run | Hardware results are author-reported | ## Negative control Not run by me. The PR description reports a red-on-base check for the specialization change. ## Findings ### Blocking None. ### Non-blocking None. ## Sources - [Runtime descriptor misalignment and scalar loads](https://github.com/boykopovar/AnyPS5/blob/1298bfe8d0aca0ea52664b557ee7b9e348968720/core/shader/recompiler/SpirvBackend/src/SpirvRuntimeBuffer.cpp#L256-L265) - [Binding-plan specialization selection](https://github.com/boykopovar/AnyPS5/blob/1298bfe8d0aca0ea52664b557ee7b9e348968720/core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp#L530-L540) - [Moved-buffer alignment checks](https://github.com/boykopovar/AnyPS5/blob/1298bfe8d0aca0ea52664b557ee7b9e348968720/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp#L7758-L7764) ## Not verified I did not independently verify the author-reported test runs, SPIR-V validation, performance captures, or behavior on other hardware. The six changed files included in the review folder were read in relevant sections; the excluded `ShaderResources.cpp` was read through `repo_read.py` at the changed code and surrounding logic. ## To get this to a good state Nothing is required.
Plyxen commented 2026-12-04 16:23:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-04T16:23:08Z.

Review: APPROVED


Re-verified head 1298bfe8d0 on Windows 11 with GCC 15.2, applied alone to main 484b0368d3. The new commit adds the moving unaligned-base case to DispatchMove.cpp. Run with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation and VK_LOADER_DEBUG=layer (layer 1.4.363).

agc_shader_disk_cache, agc_driver_dispatch_move, agc_guarded_memory_loads main this PR PR tests, sources reverted
RTX 5080 (621.24) 3/3 3/3 1/3 (dispatch_move and shader_disk_cache fail)
AMD Radeon iGPU (26.11.2) 3/3 3/3 1/3 (same two fail)

Each log shows the loader inserting the layer, and none has a VUID-.

Not checked: a title, or a timing comparison.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6192576314 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27812#pullrequestreview-6192576314). Originally posted by [Plyxen](https://github.com/Plyxen) on 2026-12-04T16:23:08Z. **Review:** APPROVED --- Re-verified head 1298bfe8d0 on Windows 11 with GCC 15.2, applied alone to main 484b0368d3. The new commit adds the moving unaligned-base case to `DispatchMove.cpp`. Run with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` and `VK_LOADER_DEBUG=layer` (layer 1.4.363). | `agc_shader_disk_cache`, `agc_driver_dispatch_move`, `agc_guarded_memory_loads` | main | this PR | PR tests, sources reverted | |---|---|---|---| | RTX 5080 (621.24) | 3/3 | 3/3 | 1/3 (`dispatch_move` and `shader_disk_cache` fail) | | AMD Radeon iGPU (26.11.2) | 3/3 | 3/3 | 1/3 (same two fail) | Each log shows the loader inserting the layer, and none has a `VUID-`. Not checked: a title, or a timing comparison. AI-assisted: yes (Claude Code)
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/27812:upstream-pr/27812'
git switch 'upstream-pr/27812'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/27812'
git switch 'upstream-pr/27812'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/27812'
git switch 'upstream-pr/27812'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/27812'
git switch 'main'
git merge --squash 'upstream-pr/27812'
git switch 'main'
git merge --ff-only 'upstream-pr/27812'
git switch 'main'
git merge 'upstream-pr/27812'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!27812
No description provided.