perf(shader): store 8- and 16-bit buffer components as bytes in graphics stages #27371

Merged
DerKarussellbremser merged 1 commit from upstream-pr/27371 into main 2026-11-29 12:32:00 +00:00
DerKarussellbremser commented 2026-11-26 00:10:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DerKarussellbremser on 2026-11-26T00:10:00Z.


What

A formatted store of an 8- or 16-bit component into a bound buffer goes through the byte view of the buffers (buffers_u8, #4250) only in compute shaders. Every other stage still patches the dword around the component with a compare-exchange loop (writeBuffer in SpirvRuntimeBuffer.cpp), because the draw-time validator refused the byte view when #4250 was written. A pixel shader that stores bytes from every covered pixel then spends its time in those loops: all its invocations contend for the same dwords.

Assassin's Creed Black Flag Resynced (PPSA28183, 01.006.038) does this in its first menu, Image Calibration. One draw there has a pixel shader with 2,168 code words that stores 8- or 16-bit components with formatted buffer stores; its module holds 294 compare-exchange loops, and each execution of the draw takes about 1.7 s of GPU time on an RTX 2060 at 1920x1080. The menu presents once every 2.7 s.

With this change:

  • byteBuffers declares the byte view in every stage. It uses the descriptor set that the stage's other buffer views use (RuntimeAbi::FragmentDescriptorSet for a pixel shader with a fragment set), where it had set 0 fixed.
  • ShaderValidation accepts the view: u8 elements in an aliased view of the guest buffers, next to u32 and u64, and SPV_KHR_8bit_storage in a shader without a fault buffer. The StorageBuffer8BitAccess capability was already accepted for every shader, and the shader device profile requires it.

Loads, dword stores and stores through GPU-selected descriptors (BDA) are unchanged. Without the capability the compare-exchange path remains.

This also fixes a wrong result in graphics stages. The compare-exchange path shifts the component mask inside one dword, so a 16-bit component whose two bytes straddle a dword loses its high byte. The byte view stores both bytes. The new execution test shows it (below). The fallback path itself still has that defect; it is a separate change.

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, on main 63b2e14408.

  • New case in aliasedBufferViewTests (agc_driver_graphics): a pixel shader with a formatted 8_8_8_8 store declares buffers and buffers_u8, passes ValidateShaders, and is refused with duplicate SPIR-V resource binding once the Aliased decorations are replaced. Red on the base: with SpirvRuntimeBuffer.cpp and ShaderValidation.cpp as on main it fails with the pixel shader declared the guest buffers as buffers, not as the expected 2 aliased variables.
  • New agc_driver_pixel_formatted_store_unaligned: a 64x32 draw whose pixel shader runs the eight stores of agc_driver_formatted_store_unaligned (8- and 16-bit components at misaligned offsets, some of them across a dword) into a 64-byte lane per pixel, as wave64 and wave32, and checks all 131,072 output bytes including the untouched neighbours. Red on the base: wave64 pixel (0, 0) byte 4 is 170, expected 239, the high byte of the 16-bit store at offset 3. Green here.
  • agc_driver_formatted_store, agc_driver_formatted_store_unaligned, agc_driver_runtime_formatted_store, agc_formatted_buffer_byte_stores and agc_driver_graphics pass.
  • Validation layer (Vulkan SDK 1.4.363.1, VK_LAYER_KHRONOS_validation, its loading confirmed with VK_LOADER_DEBUG=layer): agc_driver_pixel_formatted_store_unaligned, agc_driver_formatted_store_unaligned, agc_driver_formatted_store and agc_driver_runtime_formatted_store run without a validation message.
  • tools/check_conventions.py --base origin/main passes.
  • tools/pr_overlap.py --branch perf/graphics-byte-stores: 111 open pull requests share files. 66 were compared and do not overlap. 45 conflict with main and could not be compared; I searched their diffs for byteBuffers, buffers_u8, the 8-bit extension and capability, the aliased-view checks and aliasedBufferViewTests. None declares the byte view outside compute or changes which buffer views the validator accepts. #9356, #9387, #10193, #13928, #13929 and #15548 edit the same one-line extension check for other extensions and will need a textual merge there.
  • Not covered: Linux, macOS (MoltenVK), AMD and Intel GPUs, and stages other than pixel on a device (vertex, tessellation, geometry and mesh shaders take the same writeBuffer path, but no test here executes a store in them).

Black Flag, Image Calibration menu. Same machine, same session, warm caches (each build ran the scene before its capture), fresh profile and the same scripted input, APS5_TRACE_SECONDS=420:30 with no profile switch and the log not redirected. The window lies in the menu for both builds; the title reaches the menu 110 to 190 s after its first present.

main 63b2e14408 this PR 72c61e439d
presents in the window 12 in 32.1 s 41 in 30.3 s
frame time p50 / p90 2664 / 3007 ms 735 / 797 ms
GPU busy per present 1976 ms 275 ms
Driver.Packet.memory_wait per frame 2442 ms 506 ms
Vulkan.Dispatch per frame 2159 ms 249 ms

In separate runs with APS5_PROFILE_GPU=1 and APS5_PROFILE_GPU_DRAWS=1 (on 6b59b8f5e7, the base this was developed on), the draw of that pixel shader took 6,849 to 7,044 ms of GPU time for 4 executions per 10 s before, and 8 ms for 13 executions after. A frame dump of the menu from each build matches except for the animated parts (97.4 % identical pixels at 480x270).

What limits the menu now is a second draw at about 72 ms of GPU time per execution, unchanged by this PR, and queue 0x20, whose worker is busy 99.7 % of the window.

Summary lines
{"commit":"63b2e14408f9","dirty":false,"env":{"APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"420: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":"PPSA28183","title":"Assassin's Creed™ Black Flag Resynced","content_version":"01.006.038","resolution":"1920x1080","window":{"spec":"seconds 420:30","first_present":1187,"ms":32084.438},"presents":12,"frame_ms":{"p50":2663.994,"p90":3007.435,"p99":3052.642,"max":3052.642},"gpu_busy_ms_per_present":1976.248,"worker_busy_pct":{"queue worker 0x20":99.961,"queue worker 0x0":92.755},"phase_totals_ms":{"Driver.Completion":4.274,"Driver.Dispatch":30530.530,"Driver.Dispatch.capture_resources":821.654,"Driver.Dispatch.decode_key_device_setup":2964.860,"Driver.Dispatch.lookup_cache":9.886,"Driver.Dispatch.materialize":176.238,"Driver.Dispatch.prepared_invocation":21.796,"Driver.Draw":686.672,"Driver.Draw.device_setup":7.412,"Driver.Draw.draw_enqueued":96.594,"Driver.Draw.post_compile_prepare":7.832,"Driver.Draw.prepare":31.871,"Driver.Draw.shader_compile_and_link":225.269,"Driver.EndSubmission":127.144,"Driver.Packet":61700.438,"Driver.Packet.device_lock":6.977,"Driver.Packet.dispatch":30570.110,"Driver.Packet.draw":688.792,"Driver.Packet.execute":25.547,"Driver.Packet.flip_flush":0.083,"Driver.Packet.flush_between_packets":276.777,"Driver.Packet.memory_wait":29308.869,"Driver.Packet.pipeline_drain":761.777,"Driver.Packet.pipeline_prepare":11.614,"Driver.Packet.prepare_memory":13.432,"Driver.Packet.rendering_wait":0.021,"Driver.Present":105.687,"Driver.Present.acquire_image":0.456,"Driver.Present.device_setup":0.044,"Driver.Present.gpu_mutex_wait":89.680,"Driver.Present.inflight_wait":0.072,"Driver.Present.present_display_buffer":7.598,"Driver.Present.queue_present":4.068,"Driver.Present.release_and_callback":0.112,"Driver.Present.render_fence_wait":3.518,"Driver.Present.resize":0.112,"Driver.Present.validate":0.007,"Driver.Suspend":0.004,"GpuMutex.wait.dispatch":224.755,"GpuMutex.wait.draw":15.261,"GpuMutex.wait.end":73.229,"GpuMutex.wait.fill":0.061,"GpuMutex.wait.flush":66.810,"GpuMutex.wait.hook":51.791,"GpuMutex.wait.indirect":2.242,"GpuMutex.wait.label":100.462,"GpuMutex.wait.other":14.302,"GpuMutex.wait.present":89.595,"GpuMutex.wait.wait":76.953,"Graphics.Draw":3788.572,"Graphics.Draw.draw_and_resource_release":3569.472,"Graphics.Draw.index_upload":4.486,"Graphics.Draw.validate":30.426,"Graphics.Draw.vertex_upload":5.573,"Graphics.DrawWithRecipe":0.344,"Graphics.DrawWithRecipe.draw_and_resource_release":0.097,"Graphics.DrawWithRecipe.index_upload":0.005,"Graphics.DrawWithRecipe.validate":0.043,"Graphics.DrawWithRecipe.vertex_upload":0.029,"Recorder.Reap":40.752,"Recorder.Submit":331.694,"Recorder.Sync":3855.319,"Recorder.WaitSerial":0.907,"Resources.Complete":26075.977,"Resources.Prepare":317.787,"Shader.DrawStage":213.280,"Shader.DrawStage.capture_resources":81.950,"Shader.DrawStage.materialize":121.629,"Shader.DrawStage.prepared_invocation":8.832,"Shader.ResolveAbi":11.688,"Shader.ResolveGraphicsAbi":36.279,"Shader.ResolveGraphicsStagesAbi":195.458,"VideoOut.Flip":121.564,"VideoOut.Flip.completion_mutex_wait":0.212,"VideoOut.Flip.config_mutex_wait":0.003,"VideoOut.Flip.frame_limit":0.013,"VideoOut.Flip.notify_game":2.874,"VideoOut.Flip.present":105.095,"VideoOut.Flip.validate":0.054,"VideoOut.Flip.vblank_wait":0.014,"VideoOut.Flip.window_prepare":0.033,"VideoOut.Flip.window_title":13.249,"VideoOut.Readiness":0.052,"VideoOut.Readiness.locks_validate":0.019,"Vulkan.Acquire":0.425,"Vulkan.Acquire.acquire_fence_wait":0.055,"Vulkan.Acquire.acquire_image":0.227,"Vulkan.Acquire.fence_reset":0.051,"Vulkan.Acquire.retired_swapchains":0.015,"Vulkan.Dispatch":25912.259,"Vulkan.Dispatch.command_record":131.433,"Vulkan.Dispatch.shader_resources":25773.035,"Vulkan.DispatchRecipe":0.195,"Vulkan.DispatchRecipe.command_record":0.192,"Vulkan.DrawFromRecipe":0.372,"Vulkan.Present":6.358,"Vulkan.Present.command_record_scale":1.159,"Vulkan.Present.pixel_upload":0.794,"Vulkan.Present.queue_submit":4.363,"Vulkan.QueuePresent":3.869,"Vulkan.QueuePresent.queue_present":3.814,"Vulkan.Retire":3.503,"Vulkan.Retire.wait":1.952},"top_phases_ms_per_frame":{"Driver.Packet":5141.703,"Driver.Packet.dispatch":2547.509,"Driver.Dispatch":2544.211,"Driver.Packet.memory_wait":2442.406,"Resources.Complete":2172.998,"Vulkan.Dispatch":2159.355,"Vulkan.Dispatch.shader_resources":2147.753,"Recorder.Sync":321.277},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.copy":192,"Graphics.Barrier.dcc-clear":96,"Graphics.Barrier.dcc-keys":72,"Graphics.Barrier.dispatch-lead":3203,"Graphics.Barrier.dispatch-trail":4152,"Graphics.Barrier.draw":1549,"Graphics.Barrier.fill":395,"Graphics.Barrier.indirect-args":540,"Graphics.Barrier.label-run":6994,"Graphics.Barrier.present-blit":24,"Graphics.Barrier.shadow-publish":1299,"Graphics.Barrier.staging-in":3516,"Graphics.Barrier.staging-out":1068,"Graphics.Barrier.storage-upload":7284,"Graphics.Barrier.storage-writeback":8083,"Graphics.BarrierMerged.dispatch-lead":2029,"Graphics.BarrierMerged.fill":53,"Graphics.BarrierMerged.shadow-publish":1161,"Graphics.BarrierMerged.staging-in":1019,"Graphics.BarrierMerged.staging-out":1068,"Graphics.BarrierMerged.storage-writeback":1990,"Graphics.Copy":4540,"Graphics.Copy.bytes":4136508916,"Graphics.RenderPass":620,"Graphics.RenderPass.Close.command":255,"Graphics.RenderPass.Close.image":48,"Graphics.RenderPass.Close.key":56,"Graphics.RenderPass.Close.new-batch":261,"Graphics.RenderPass.Continued":183},"trace_dropped":false,"trace":"aps5-trace-63b2e14408f9-1056.json.gz"}
{"commit":"72c61e439d6e","dirty":false,"env":{"APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"420: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":"PPSA28183","title":"Assassin's Creed™ Black Flag Resynced","content_version":"01.006.038","resolution":"1920x1080","window":{"spec":"seconds 420:30","first_present":1601,"ms":30341.538},"presents":41,"frame_ms":{"p50":735.023,"p90":796.609,"p99":852.204,"max":852.204},"gpu_busy_ms_per_present":275.136,"worker_busy_pct":{"queue worker 0x20":99.734,"queue worker 0x0":73.061},"phase_totals_ms":{"Driver.Completion":14.316,"Driver.Dispatch":25238.856,"Driver.Dispatch.capture_resources":2148.047,"Driver.Dispatch.decode_key_device_setup":9881.463,"Driver.Dispatch.lookup_cache":222.163,"Driver.Dispatch.materialize":614.255,"Driver.Dispatch.prepared_invocation":73.909,"Driver.Draw":2390.928,"Driver.Draw.device_setup":24.171,"Driver.Draw.draw_enqueued":340.534,"Driver.Draw.post_compile_prepare":20.233,"Driver.Draw.prepare":102.116,"Driver.Draw.shader_compile_and_link":830.014,"Driver.EndSubmission":655.523,"Driver.Packet":51758.989,"Driver.Packet.device_lock":23.310,"Driver.Packet.dispatch":25382.394,"Driver.Packet.draw":2398.449,"Driver.Packet.execute":85.038,"Driver.Packet.flip_flush":0.560,"Driver.Packet.flush_between_packets":703.049,"Driver.Packet.memory_wait":20731.611,"Driver.Packet.pipeline_drain":2230.111,"Driver.Packet.pipeline_prepare":37.274,"Driver.Packet.prepare_memory":42.735,"Driver.Packet.rendering_wait":0.913,"Driver.Present":72.773,"Driver.Present.acquire_image":1.256,"Driver.Present.device_setup":0.088,"Driver.Present.gpu_mutex_wait":17.394,"Driver.Present.inflight_wait":0.241,"Driver.Present.present_display_buffer":21.576,"Driver.Present.queue_present":11.099,"Driver.Present.release_and_callback":0.211,"Driver.Present.render_fence_wait":20.656,"Driver.Present.resize":0.168,"Driver.Present.validate":0.027,"Driver.Suspend":0.026,"GpuMutex.wait.dispatch":782.863,"GpuMutex.wait.draw":47.201,"GpuMutex.wait.end":446.534,"GpuMutex.wait.fill":0.796,"GpuMutex.wait.flush":142.645,"GpuMutex.wait.hook":117.282,"GpuMutex.wait.indirect":66.971,"GpuMutex.wait.label":357.693,"GpuMutex.wait.present":17.122,"GpuMutex.wait.wait":21.469,"Graphics.Draw":12757.782,"Graphics.Draw.draw_and_resource_release":11319.993,"Graphics.Draw.index_upload":43.175,"Graphics.Draw.validate":105.935,"Graphics.Draw.vertex_upload":19.938,"Graphics.DrawWithRecipe":31.313,"Graphics.DrawWithRecipe.draw_and_resource_release":28.981,"Graphics.DrawWithRecipe.index_upload":0.023,"Graphics.DrawWithRecipe.validate":0.205,"Graphics.DrawWithRecipe.vertex_upload":0.356,"Recorder.Reap":171.165,"Recorder.Submit":1075.708,"Recorder.Sync":118.285,"Recorder.WaitSerial":2.076,"Resources.Complete":10737.991,"Resources.Prepare":963.096,"Shader.DrawStage":784.801,"Shader.DrawStage.capture_resources":271.805,"Shader.DrawStage.materialize":479.488,"Shader.DrawStage.prepared_invocation":30.488,"Shader.ResolveAbi":122.250,"Shader.ResolveGraphicsAbi":148.991,"Shader.ResolveGraphicsStagesAbi":683.381,"VideoOut.Flip":82.735,"VideoOut.Flip.completion_mutex_wait":0.139,"VideoOut.Flip.config_mutex_wait":0.023,"VideoOut.Flip.frame_limit":0.062,"VideoOut.Flip.notify_game":9.520,"VideoOut.Flip.present":63.489,"VideoOut.Flip.validate":0.095,"VideoOut.Flip.vblank_wait":0.053,"VideoOut.Flip.window_prepare":0.170,"VideoOut.Flip.window_title":6.129,"VideoOut.Readiness":0.293,"VideoOut.Readiness.locks_validate":0.069,"Vulkan.Acquire":1.154,"Vulkan.Acquire.acquire_fence_wait":0.198,"Vulkan.Acquire.acquire_image":0.705,"Vulkan.Acquire.fence_reset":0.171,"Vulkan.Acquire.retired_swapchains":0.048,"Vulkan.Dispatch":10199.842,"Vulkan.Dispatch.command_record":438.680,"Vulkan.Dispatch.shader_resources":9735.335,"Vulkan.DispatchRecipe":2.718,"Vulkan.DispatchRecipe.command_record":2.670,"Vulkan.DrawFromRecipe":31.465,"Vulkan.Present":17.003,"Vulkan.Present.command_record_scale":8.537,"Vulkan.Present.pixel_upload":2.984,"Vulkan.Present.queue_submit":5.364,"Vulkan.QueuePresent":10.559,"Vulkan.QueuePresent.queue_present":10.422,"Vulkan.Retire":20.368,"Vulkan.Retire.wait":11.491},"top_phases_ms_per_frame":{"Driver.Packet":1262.414,"Driver.Packet.dispatch":619.083,"Driver.Dispatch":615.582,"Driver.Packet.memory_wait":505.649,"Graphics.Draw":311.165,"Graphics.Draw.draw_and_resource_release":276.097,"Resources.Complete":261.902,"Vulkan.Dispatch":248.777},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.copy":205,"Graphics.Barrier.dcc-clear":328,"Graphics.Barrier.dcc-keys":246,"Graphics.Barrier.dispatch-lead":11231,"Graphics.Barrier.dispatch-trail":14233,"Graphics.Barrier.draw":5410,"Graphics.Barrier.fill":1291,"Graphics.Barrier.indirect-args":1962,"Graphics.Barrier.label-run":22910,"Graphics.Barrier.present-blit":82,"Graphics.Barrier.shadow-publish":4298,"Graphics.Barrier.staging-in":11684,"Graphics.Barrier.staging-out":3576,"Graphics.Barrier.storage-upload":21839,"Graphics.Barrier.storage-writeback":27347,"Graphics.BarrierMerged.dispatch-lead":6926,"Graphics.BarrierMerged.fill":197,"Graphics.BarrierMerged.shadow-publish":3846,"Graphics.BarrierMerged.staging-in":3594,"Graphics.BarrierMerged.staging-out":3576,"Graphics.BarrierMerged.storage-writeback":6752,"Graphics.Copy":14965,"Graphics.Copy.bytes":14609072632,"Graphics.RenderPass":2137,"Graphics.RenderPass.Close.command":872,"Graphics.RenderPass.Close.image":164,"Graphics.RenderPass.Close.key":190,"Graphics.RenderPass.Close.new-batch":912,"Graphics.RenderPass.Continued":666},"trace_dropped":false,"trace":"aps5-trace-72c61e439d6e-36496.json.gz"}

The two traces (aps5-trace-63b2e14408f9-1056.json.gz, aps5-trace-72c61e439d6e-36496.json.gz) follow in a comment.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5501443158 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27371). Originally posted by [DerKarussellbremser](https://github.com/DerKarussellbremser) on 2026-11-26T00:10:00Z. --- ### What A formatted store of an 8- or 16-bit component into a bound buffer goes through the byte view of the buffers (`buffers_u8`, #4250) only in compute shaders. Every other stage still patches the dword around the component with a compare-exchange loop (`writeBuffer` in `SpirvRuntimeBuffer.cpp`), because the draw-time validator refused the byte view when #4250 was written. A pixel shader that stores bytes from every covered pixel then spends its time in those loops: all its invocations contend for the same dwords. Assassin's Creed Black Flag Resynced (PPSA28183, 01.006.038) does this in its first menu, Image Calibration. One draw there has a pixel shader with 2,168 code words that stores 8- or 16-bit components with formatted buffer stores; its module holds 294 compare-exchange loops, and each execution of the draw takes about 1.7 s of GPU time on an RTX 2060 at 1920x1080. The menu presents once every 2.7 s. With this change: - `byteBuffers` declares the byte view in every stage. It uses the descriptor set that the stage's other buffer views use (`RuntimeAbi::FragmentDescriptorSet` for a pixel shader with a fragment set), where it had set 0 fixed. - `ShaderValidation` accepts the view: u8 elements in an aliased view of the guest buffers, next to u32 and u64, and `SPV_KHR_8bit_storage` in a shader without a fault buffer. The `StorageBuffer8BitAccess` capability was already accepted for every shader, and the shader device profile requires it. Loads, dword stores and stores through GPU-selected descriptors (BDA) are unchanged. Without the capability the compare-exchange path remains. This also fixes a wrong result in graphics stages. The compare-exchange path shifts the component mask inside one dword, so a 16-bit component whose two bytes straddle a dword loses its high byte. The byte view stores both bytes. The new execution test shows it (below). The fallback path itself still has that defect; it is a separate change. ### 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, on `main` `63b2e14408`. - New case in `aliasedBufferViewTests` (`agc_driver_graphics`): a pixel shader with a formatted 8_8_8_8 store declares `buffers` and `buffers_u8`, passes `ValidateShaders`, and is refused with `duplicate SPIR-V resource binding` once the `Aliased` decorations are replaced. **Red on the base:** with `SpirvRuntimeBuffer.cpp` and `ShaderValidation.cpp` as on `main` it fails with `the pixel shader declared the guest buffers as buffers, not as the expected 2 aliased variables`. - New `agc_driver_pixel_formatted_store_unaligned`: a 64x32 draw whose pixel shader runs the eight stores of `agc_driver_formatted_store_unaligned` (8- and 16-bit components at misaligned offsets, some of them across a dword) into a 64-byte lane per pixel, as wave64 and wave32, and checks all 131,072 output bytes including the untouched neighbours. **Red on the base:** `wave64 pixel (0, 0) byte 4 is 170, expected 239`, the high byte of the 16-bit store at offset 3. Green here. - `agc_driver_formatted_store`, `agc_driver_formatted_store_unaligned`, `agc_driver_runtime_formatted_store`, `agc_formatted_buffer_byte_stores` and `agc_driver_graphics` pass. - Validation layer (Vulkan SDK 1.4.363.1, `VK_LAYER_KHRONOS_validation`, its loading confirmed with `VK_LOADER_DEBUG=layer`): `agc_driver_pixel_formatted_store_unaligned`, `agc_driver_formatted_store_unaligned`, `agc_driver_formatted_store` and `agc_driver_runtime_formatted_store` run without a validation message. - `tools/check_conventions.py --base origin/main` passes. - `tools/pr_overlap.py --branch perf/graphics-byte-stores`: 111 open pull requests share files. 66 were compared and do not overlap. 45 conflict with `main` and could not be compared; I searched their diffs for `byteBuffers`, `buffers_u8`, the 8-bit extension and capability, the aliased-view checks and `aliasedBufferViewTests`. None declares the byte view outside compute or changes which buffer views the validator accepts. #9356, #9387, #10193, #13928, #13929 and #15548 edit the same one-line extension check for other extensions and will need a textual merge there. - Not covered: Linux, macOS (MoltenVK), AMD and Intel GPUs, and stages other than pixel on a device (vertex, tessellation, geometry and mesh shaders take the same `writeBuffer` path, but no test here executes a store in them). **Black Flag, Image Calibration menu.** Same machine, same session, warm caches (each build ran the scene before its capture), fresh profile and the same scripted input, `APS5_TRACE_SECONDS=420:30` with no profile switch and the log not redirected. The window lies in the menu for both builds; the title reaches the menu 110 to 190 s after its first present. | | `main` `63b2e14408` | this PR `72c61e439d` | |---|---|---| | presents in the window | 12 in 32.1 s | 41 in 30.3 s | | frame time p50 / p90 | 2664 / 3007 ms | 735 / 797 ms | | GPU busy per present | 1976 ms | 275 ms | | `Driver.Packet.memory_wait` per frame | 2442 ms | 506 ms | | `Vulkan.Dispatch` per frame | 2159 ms | 249 ms | In separate runs with `APS5_PROFILE_GPU=1` and `APS5_PROFILE_GPU_DRAWS=1` (on `6b59b8f5e7`, the base this was developed on), the draw of that pixel shader took 6,849 to 7,044 ms of GPU time for 4 executions per 10 s before, and 8 ms for 13 executions after. A frame dump of the menu from each build matches except for the animated parts (97.4 % identical pixels at 480x270). What limits the menu now is a second draw at about 72 ms of GPU time per execution, unchanged by this PR, and queue 0x20, whose worker is busy 99.7 % of the window. <details><summary>Summary lines</summary> ```json {"commit":"63b2e14408f9","dirty":false,"env":{"APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"420: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":"PPSA28183","title":"Assassin's Creed™ Black Flag Resynced","content_version":"01.006.038","resolution":"1920x1080","window":{"spec":"seconds 420:30","first_present":1187,"ms":32084.438},"presents":12,"frame_ms":{"p50":2663.994,"p90":3007.435,"p99":3052.642,"max":3052.642},"gpu_busy_ms_per_present":1976.248,"worker_busy_pct":{"queue worker 0x20":99.961,"queue worker 0x0":92.755},"phase_totals_ms":{"Driver.Completion":4.274,"Driver.Dispatch":30530.530,"Driver.Dispatch.capture_resources":821.654,"Driver.Dispatch.decode_key_device_setup":2964.860,"Driver.Dispatch.lookup_cache":9.886,"Driver.Dispatch.materialize":176.238,"Driver.Dispatch.prepared_invocation":21.796,"Driver.Draw":686.672,"Driver.Draw.device_setup":7.412,"Driver.Draw.draw_enqueued":96.594,"Driver.Draw.post_compile_prepare":7.832,"Driver.Draw.prepare":31.871,"Driver.Draw.shader_compile_and_link":225.269,"Driver.EndSubmission":127.144,"Driver.Packet":61700.438,"Driver.Packet.device_lock":6.977,"Driver.Packet.dispatch":30570.110,"Driver.Packet.draw":688.792,"Driver.Packet.execute":25.547,"Driver.Packet.flip_flush":0.083,"Driver.Packet.flush_between_packets":276.777,"Driver.Packet.memory_wait":29308.869,"Driver.Packet.pipeline_drain":761.777,"Driver.Packet.pipeline_prepare":11.614,"Driver.Packet.prepare_memory":13.432,"Driver.Packet.rendering_wait":0.021,"Driver.Present":105.687,"Driver.Present.acquire_image":0.456,"Driver.Present.device_setup":0.044,"Driver.Present.gpu_mutex_wait":89.680,"Driver.Present.inflight_wait":0.072,"Driver.Present.present_display_buffer":7.598,"Driver.Present.queue_present":4.068,"Driver.Present.release_and_callback":0.112,"Driver.Present.render_fence_wait":3.518,"Driver.Present.resize":0.112,"Driver.Present.validate":0.007,"Driver.Suspend":0.004,"GpuMutex.wait.dispatch":224.755,"GpuMutex.wait.draw":15.261,"GpuMutex.wait.end":73.229,"GpuMutex.wait.fill":0.061,"GpuMutex.wait.flush":66.810,"GpuMutex.wait.hook":51.791,"GpuMutex.wait.indirect":2.242,"GpuMutex.wait.label":100.462,"GpuMutex.wait.other":14.302,"GpuMutex.wait.present":89.595,"GpuMutex.wait.wait":76.953,"Graphics.Draw":3788.572,"Graphics.Draw.draw_and_resource_release":3569.472,"Graphics.Draw.index_upload":4.486,"Graphics.Draw.validate":30.426,"Graphics.Draw.vertex_upload":5.573,"Graphics.DrawWithRecipe":0.344,"Graphics.DrawWithRecipe.draw_and_resource_release":0.097,"Graphics.DrawWithRecipe.index_upload":0.005,"Graphics.DrawWithRecipe.validate":0.043,"Graphics.DrawWithRecipe.vertex_upload":0.029,"Recorder.Reap":40.752,"Recorder.Submit":331.694,"Recorder.Sync":3855.319,"Recorder.WaitSerial":0.907,"Resources.Complete":26075.977,"Resources.Prepare":317.787,"Shader.DrawStage":213.280,"Shader.DrawStage.capture_resources":81.950,"Shader.DrawStage.materialize":121.629,"Shader.DrawStage.prepared_invocation":8.832,"Shader.ResolveAbi":11.688,"Shader.ResolveGraphicsAbi":36.279,"Shader.ResolveGraphicsStagesAbi":195.458,"VideoOut.Flip":121.564,"VideoOut.Flip.completion_mutex_wait":0.212,"VideoOut.Flip.config_mutex_wait":0.003,"VideoOut.Flip.frame_limit":0.013,"VideoOut.Flip.notify_game":2.874,"VideoOut.Flip.present":105.095,"VideoOut.Flip.validate":0.054,"VideoOut.Flip.vblank_wait":0.014,"VideoOut.Flip.window_prepare":0.033,"VideoOut.Flip.window_title":13.249,"VideoOut.Readiness":0.052,"VideoOut.Readiness.locks_validate":0.019,"Vulkan.Acquire":0.425,"Vulkan.Acquire.acquire_fence_wait":0.055,"Vulkan.Acquire.acquire_image":0.227,"Vulkan.Acquire.fence_reset":0.051,"Vulkan.Acquire.retired_swapchains":0.015,"Vulkan.Dispatch":25912.259,"Vulkan.Dispatch.command_record":131.433,"Vulkan.Dispatch.shader_resources":25773.035,"Vulkan.DispatchRecipe":0.195,"Vulkan.DispatchRecipe.command_record":0.192,"Vulkan.DrawFromRecipe":0.372,"Vulkan.Present":6.358,"Vulkan.Present.command_record_scale":1.159,"Vulkan.Present.pixel_upload":0.794,"Vulkan.Present.queue_submit":4.363,"Vulkan.QueuePresent":3.869,"Vulkan.QueuePresent.queue_present":3.814,"Vulkan.Retire":3.503,"Vulkan.Retire.wait":1.952},"top_phases_ms_per_frame":{"Driver.Packet":5141.703,"Driver.Packet.dispatch":2547.509,"Driver.Dispatch":2544.211,"Driver.Packet.memory_wait":2442.406,"Resources.Complete":2172.998,"Vulkan.Dispatch":2159.355,"Vulkan.Dispatch.shader_resources":2147.753,"Recorder.Sync":321.277},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.copy":192,"Graphics.Barrier.dcc-clear":96,"Graphics.Barrier.dcc-keys":72,"Graphics.Barrier.dispatch-lead":3203,"Graphics.Barrier.dispatch-trail":4152,"Graphics.Barrier.draw":1549,"Graphics.Barrier.fill":395,"Graphics.Barrier.indirect-args":540,"Graphics.Barrier.label-run":6994,"Graphics.Barrier.present-blit":24,"Graphics.Barrier.shadow-publish":1299,"Graphics.Barrier.staging-in":3516,"Graphics.Barrier.staging-out":1068,"Graphics.Barrier.storage-upload":7284,"Graphics.Barrier.storage-writeback":8083,"Graphics.BarrierMerged.dispatch-lead":2029,"Graphics.BarrierMerged.fill":53,"Graphics.BarrierMerged.shadow-publish":1161,"Graphics.BarrierMerged.staging-in":1019,"Graphics.BarrierMerged.staging-out":1068,"Graphics.BarrierMerged.storage-writeback":1990,"Graphics.Copy":4540,"Graphics.Copy.bytes":4136508916,"Graphics.RenderPass":620,"Graphics.RenderPass.Close.command":255,"Graphics.RenderPass.Close.image":48,"Graphics.RenderPass.Close.key":56,"Graphics.RenderPass.Close.new-batch":261,"Graphics.RenderPass.Continued":183},"trace_dropped":false,"trace":"aps5-trace-63b2e14408f9-1056.json.gz"} {"commit":"72c61e439d6e","dirty":false,"env":{"APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"420: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":"PPSA28183","title":"Assassin's Creed™ Black Flag Resynced","content_version":"01.006.038","resolution":"1920x1080","window":{"spec":"seconds 420:30","first_present":1601,"ms":30341.538},"presents":41,"frame_ms":{"p50":735.023,"p90":796.609,"p99":852.204,"max":852.204},"gpu_busy_ms_per_present":275.136,"worker_busy_pct":{"queue worker 0x20":99.734,"queue worker 0x0":73.061},"phase_totals_ms":{"Driver.Completion":14.316,"Driver.Dispatch":25238.856,"Driver.Dispatch.capture_resources":2148.047,"Driver.Dispatch.decode_key_device_setup":9881.463,"Driver.Dispatch.lookup_cache":222.163,"Driver.Dispatch.materialize":614.255,"Driver.Dispatch.prepared_invocation":73.909,"Driver.Draw":2390.928,"Driver.Draw.device_setup":24.171,"Driver.Draw.draw_enqueued":340.534,"Driver.Draw.post_compile_prepare":20.233,"Driver.Draw.prepare":102.116,"Driver.Draw.shader_compile_and_link":830.014,"Driver.EndSubmission":655.523,"Driver.Packet":51758.989,"Driver.Packet.device_lock":23.310,"Driver.Packet.dispatch":25382.394,"Driver.Packet.draw":2398.449,"Driver.Packet.execute":85.038,"Driver.Packet.flip_flush":0.560,"Driver.Packet.flush_between_packets":703.049,"Driver.Packet.memory_wait":20731.611,"Driver.Packet.pipeline_drain":2230.111,"Driver.Packet.pipeline_prepare":37.274,"Driver.Packet.prepare_memory":42.735,"Driver.Packet.rendering_wait":0.913,"Driver.Present":72.773,"Driver.Present.acquire_image":1.256,"Driver.Present.device_setup":0.088,"Driver.Present.gpu_mutex_wait":17.394,"Driver.Present.inflight_wait":0.241,"Driver.Present.present_display_buffer":21.576,"Driver.Present.queue_present":11.099,"Driver.Present.release_and_callback":0.211,"Driver.Present.render_fence_wait":20.656,"Driver.Present.resize":0.168,"Driver.Present.validate":0.027,"Driver.Suspend":0.026,"GpuMutex.wait.dispatch":782.863,"GpuMutex.wait.draw":47.201,"GpuMutex.wait.end":446.534,"GpuMutex.wait.fill":0.796,"GpuMutex.wait.flush":142.645,"GpuMutex.wait.hook":117.282,"GpuMutex.wait.indirect":66.971,"GpuMutex.wait.label":357.693,"GpuMutex.wait.present":17.122,"GpuMutex.wait.wait":21.469,"Graphics.Draw":12757.782,"Graphics.Draw.draw_and_resource_release":11319.993,"Graphics.Draw.index_upload":43.175,"Graphics.Draw.validate":105.935,"Graphics.Draw.vertex_upload":19.938,"Graphics.DrawWithRecipe":31.313,"Graphics.DrawWithRecipe.draw_and_resource_release":28.981,"Graphics.DrawWithRecipe.index_upload":0.023,"Graphics.DrawWithRecipe.validate":0.205,"Graphics.DrawWithRecipe.vertex_upload":0.356,"Recorder.Reap":171.165,"Recorder.Submit":1075.708,"Recorder.Sync":118.285,"Recorder.WaitSerial":2.076,"Resources.Complete":10737.991,"Resources.Prepare":963.096,"Shader.DrawStage":784.801,"Shader.DrawStage.capture_resources":271.805,"Shader.DrawStage.materialize":479.488,"Shader.DrawStage.prepared_invocation":30.488,"Shader.ResolveAbi":122.250,"Shader.ResolveGraphicsAbi":148.991,"Shader.ResolveGraphicsStagesAbi":683.381,"VideoOut.Flip":82.735,"VideoOut.Flip.completion_mutex_wait":0.139,"VideoOut.Flip.config_mutex_wait":0.023,"VideoOut.Flip.frame_limit":0.062,"VideoOut.Flip.notify_game":9.520,"VideoOut.Flip.present":63.489,"VideoOut.Flip.validate":0.095,"VideoOut.Flip.vblank_wait":0.053,"VideoOut.Flip.window_prepare":0.170,"VideoOut.Flip.window_title":6.129,"VideoOut.Readiness":0.293,"VideoOut.Readiness.locks_validate":0.069,"Vulkan.Acquire":1.154,"Vulkan.Acquire.acquire_fence_wait":0.198,"Vulkan.Acquire.acquire_image":0.705,"Vulkan.Acquire.fence_reset":0.171,"Vulkan.Acquire.retired_swapchains":0.048,"Vulkan.Dispatch":10199.842,"Vulkan.Dispatch.command_record":438.680,"Vulkan.Dispatch.shader_resources":9735.335,"Vulkan.DispatchRecipe":2.718,"Vulkan.DispatchRecipe.command_record":2.670,"Vulkan.DrawFromRecipe":31.465,"Vulkan.Present":17.003,"Vulkan.Present.command_record_scale":8.537,"Vulkan.Present.pixel_upload":2.984,"Vulkan.Present.queue_submit":5.364,"Vulkan.QueuePresent":10.559,"Vulkan.QueuePresent.queue_present":10.422,"Vulkan.Retire":20.368,"Vulkan.Retire.wait":11.491},"top_phases_ms_per_frame":{"Driver.Packet":1262.414,"Driver.Packet.dispatch":619.083,"Driver.Dispatch":615.582,"Driver.Packet.memory_wait":505.649,"Graphics.Draw":311.165,"Graphics.Draw.draw_and_resource_release":276.097,"Resources.Complete":261.902,"Vulkan.Dispatch":248.777},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.copy":205,"Graphics.Barrier.dcc-clear":328,"Graphics.Barrier.dcc-keys":246,"Graphics.Barrier.dispatch-lead":11231,"Graphics.Barrier.dispatch-trail":14233,"Graphics.Barrier.draw":5410,"Graphics.Barrier.fill":1291,"Graphics.Barrier.indirect-args":1962,"Graphics.Barrier.label-run":22910,"Graphics.Barrier.present-blit":82,"Graphics.Barrier.shadow-publish":4298,"Graphics.Barrier.staging-in":11684,"Graphics.Barrier.staging-out":3576,"Graphics.Barrier.storage-upload":21839,"Graphics.Barrier.storage-writeback":27347,"Graphics.BarrierMerged.dispatch-lead":6926,"Graphics.BarrierMerged.fill":197,"Graphics.BarrierMerged.shadow-publish":3846,"Graphics.BarrierMerged.staging-in":3594,"Graphics.BarrierMerged.staging-out":3576,"Graphics.BarrierMerged.storage-writeback":6752,"Graphics.Copy":14965,"Graphics.Copy.bytes":14609072632,"Graphics.RenderPass":2137,"Graphics.RenderPass.Close.command":872,"Graphics.RenderPass.Close.image":164,"Graphics.RenderPass.Close.key":190,"Graphics.RenderPass.Close.new-batch":912,"Graphics.RenderPass.Continued":666},"trace_dropped":false,"trace":"aps5-trace-72c61e439d6e-36496.json.gz"} ``` </details> The two traces (`aps5-trace-63b2e14408f9-1056.json.gz`, `aps5-trace-72c61e439d6e-36496.json.gz`) follow in a comment. ### 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
MarcZX10 commented 2026-11-26 00:24:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T00:24:18Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this; the points below are optional.

What I ran

Reviewed head 72c61e439d6e22244a2dcd4a4a73a7ce202e1dad using the prepared diff and pinned repository reader. No build or runtime commands were run.

Results

Check Result Note
Changed-code review passed Read three changed files and targeted test/CMake context
Build and device tests not run Results in the description are author-reported

Findings

Blocking

None.

Non-blocking

None.

Not verified

core/libs/prx/libSceAgcDriver/tests/Graphics.cpp was excluded from the review bundle because it is too large; I read the relevant added test lines through the repository reader. I did not run checks or verify behavior on other platforms, GPUs, or shader stages. Other changes listed in the manifest were read: core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp, core/libs/prx/libSceAgcDriver/tests/execution/PixelFormattedStoreUnaligned.cpp, and core/shader/recompiler/SpirvBackend/src/SpirvRuntimeBuffer.cpp.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6066881451 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27371#pullrequestreview-6066881451). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-26T00:24:18Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this; the points below are optional. ## What I ran Reviewed head `72c61e439d6e22244a2dcd4a4a73a7ce202e1dad` using the prepared diff and pinned repository reader. No build or runtime commands were run. ## Results | Check | Result | Note | |---|---|---| | Changed-code review | passed | Read three changed files and targeted test/CMake context | | Build and device tests | not run | Results in the description are author-reported | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` was excluded from the review bundle because it is too large; I read the relevant added test lines through the repository reader. I did not run checks or verify behavior on other platforms, GPUs, or shader stages. Other changes listed in the manifest were read: `core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp`, `core/libs/prx/libSceAgcDriver/tests/execution/PixelFormattedStoreUnaligned.cpp`, and `core/shader/recompiler/SpirvBackend/src/SpirvRuntimeBuffer.cpp`. ## To get this to a good state Nothing is required.
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!27371
No description provided.