perf(shader): store 8- and 16-bit buffer components as bytes #4250
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4250"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by shahulmubeen-a on 2026-10-12T02:22:22Z.
What
A formatted store of an 8- or 16-bit component into a bound buffer patched the dword around it with a compare-exchange loop (
writeBufferinSpirvRuntimeBuffer.cpp). Ghost of Yōtei's light-culling compute pass (program0x800038be00, 240x135 groups per frame) stores millions of such components per dispatch and took 426 ms of GPU time per dispatch on an RTX 4070 Ti SUPER, which held the logo phase at 1.9 fps.Such stores now go through a byte view of the bound buffers (
buffers_u8, an aliased declaration of the buffers binding, defined on the first narrow store): oneOpStoreper byte underStorageBuffer8BitAccess, which the shader device profile already requires. Without the capability the compare-exchange path remains. Loads, dword stores and stores through GPU-selected descriptors (BDA) are unchanged. On amainwithbuffers_coherent(#4240 era) the byte view takes part in the sameAliaseddecoration set.Discussed in #675: @Celegans12 took commit c92ae6e5 of this branch into their Yōtei build, it passed their focused checks there, and they asked for it as a PR.
Tested
Windows 11 Pro, AMD Ryzen 9 7950X, NVIDIA RTX 4070 Ti SUPER (Vulkan 1.4, subgroup 32), MinGW-w64 GCC 15.2.0, Release, rebased on
mainceb342b94.agc_formatted_buffer_byte_stores(new): compiles a formatted 8_8_8_8 store with and withoutStorageBuffer8BitAccessand checks the byte view, one byte store per component, no compare-exchange loop, and the fallback without the capability. It fails onmain(the module keeps the compare-exchange loop).agc_driver_buffer_formatandagc_driver_formatted_store: 8- and 16-bit formatted stores executed on the device, untouched neighbouring bytes checked.tools/check_conventions.py --base origin/main: passes.0x800038be00dispatch 426 -> 10.7 ms of GPU time, 1.9 -> 11 fps (APS5_PROFILE_GPU=1); the title then runs through its loading, first-boot menus and into the intro cutscene with further local work.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-12T08:26:16Z.
I tried #4250 in Yotei and the new byte view runs into the draw-time validator. A pixel shader with a byte store (0x80003a6b00) declares
buffers_u8next tobuffers, andShaderValidationrefuses it with "duplicate SPIR-V resource binding". It also only acceptsSPV_KHR_8bit_storagein shaders with a fault buffer. Compute isn't validated, which is probably why the tests here didn't catch it.mainhas the same problem with the views it already emits (buffers_coherentfor GLC,buffers_u64for 64-bit atomics), so I've opened #4381 for those. The u8 part only makes sense with your view, so I kept it as one commit on top of your head and #4381's commit: Celegans12/AnyPS5@f61a578af2 (branchtopics/agc-aliased-buffer-views-4250). It accepts the extension like itsStorageBuffer8BitAccesscapability, lets an aliased guest buffer view hold u8 elements, and adds two pixel-shader cases toagc_driver_graphics: a byte store, and a GLC byte store next to a plain load. Those fail with #4250 alone and with #4381 alone, and pass with both.Would you like to pick it into #4250, or should I send it as a follow-up once one of the two lands?
Imported from boykopovar/AnyPS5. Originally posted by shahulmubeen-a on 2026-10-12T14:10:13Z.
Thanks for catching that, and for #4381.
Let's go with option B: keep #4250 as is and have your u8 extension land as a follow-up once #4250 and #4381 are both in. Picking your commit into #4250 now would make it depend on #4381 to merge, and #4250 would stop being single-topic (byte/short stores, no validator changes) — easier to review and merge as is. Nothing about #4250 needs it either: it only touches compute dispatches, which
ShaderValidationdoesn't check, so the duplicate-binding refusal you found never fires on the path #4250 covers.Go ahead and open yours whenever suits you; happy to rebase #4250 on top if #4381 lands first and you'd rather sequence it that way.
(AI-assisted: written with Claude.)
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T13:34:57Z.
Review: CHANGES_REQUESTED
Thanks for the profile numbers. Two things block this, plus a conflict:
ShaderValidation.cpp(main, after #4381 merged): an aliased view is accepted only if its elements are u32, or u64 in an aliased guest buffer view (the "descriptor block member must be a runtime array of u32, or of u64..." check).buffers_u8is still refused, so any vertex/tessellation/pixel shader with an 8/16-bit formatted store is rejected at draw time, where it used to work through the compare-exchange path. This is the case @Celegans12 hit with0x80003a6b00; "compute isn't validated" doesn't make it safe for the other stages. Either teach the validator the u8 aliased view (andSPV_KHR_8bit_storagefor those stages) in this PR, or only emit the byte view for compute and keep the compare-exchange path elsewhere, with a test for each stage.FormattedBufferByteStores.cpponly counts SPIR-V instructions (byte stores, no compare-exchange), so it pins the IR shape, not values. Please add an execution test in the style ofagc_driver_formatted_storethat stores 8- and 16-bit components with a misaligned offset and checks the neighbouring bytes, including a store that crosses a dword.mainincore/libs/prx/libSceAgcDriver/CMakeLists.txt(test registration next to a new block); please rebase.Imported from boykopovar/AnyPS5. Originally posted by shahulmubeen-a on 2026-10-13T14:13:42Z.
Thank you for the comment @adriadam10
main(the conflict was the test registration inCMakeLists.txt). Took the second option from the review: the byte view is now emitted only for compute, and every other stage keeps the compare-exchange path, so the validator never seesbuffers_u8.agc_formatted_buffer_byte_storesnow also compiles a vertex shader and checks it keeps the dword patch (nobuffers_u8, no 8-bit capability)agc_driver_formatted_store_unalignedstores 8- and 16-bit components at misaligned offsets, including stores that cross a dword, and checks every output byte including the untouched neighbours.(AI-assisted: written with Claude.)
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T14:42:46Z.
Review: APPROVED
Rebased onto current
main(only conflict: the test registration list inlibSceAgcDriver/CMakeLists.txt), no logic changes.agc_formatted_buffer_byte_storesandagc_driver_formatted_store_unalignedpass on the rebased tree; the only failure in the scoped ctest run isagc_driver_tessellation(segfault inside RADV's pipeline-library link, a graphics path this PR doesn't touch). Merging once the full Build is green.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T14:45:33Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterHelpers.hppL35core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvTypes.cppL115core/shader/recompiler/SpirvBackend/src/SpirvRuntimeBuffer.cppL199-200core/libs/prx/libSceAgcDriver/CMakeLists.txtL1215