fix(shader): emit nothing for a vertex s_barrier that precedes every memory access #6613
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6613"
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 milescoviello on 2026-10-15T22:54:15Z.
What
A vertex-path program that touches LDS or GDS or writes memory refuses any
s_barrier:NGG passthrough programs (
VGT_SHADER_STAGES_ENPRIMGEN_EN + PRIMGEN_PASSTHRU_EN) start with thes_barrierthat ordersGS_ALLOC_REQ. Crimson Desert (PPSA25286) registers one, routing0x2402000, 2133 instructions. Its only barrier is at pc 0x20, after a few scalar instructions, and it writes a buffer about 7 KB later (buffer_atomic_addat 0x1e78, then threebuffer_store_dwordx4). Its registration preparation fails with the line above, and the draw that uses it rethrows it.A barrier that runs before every memory access of the program has nothing to order: no load, store, atomic, image or LDS access can happen before it in any wave. Such a barrier now emits nothing, the same as the barrier of a program with no memory access. The check walks the entry block and its straight-line successors. A barrier behind a memory access, a branch or a merge still throws.
Tested
Linux (Ubuntu 24.04, GCC 13.3, Release), RTX 4070 Ti, NVIDIA 595.99.
agc_vertex_barrier: a vertex program withs_barrierbefore ads_write_b32, and one with a scalar instruction ahead of the barrier, compile without anOpControlBarrier. The existing case with the LDS write before the barrier is still refused. Withmain'sSpirvFlowEmitter.cppthe new cases fail with the refusal above. 3 of 3 runs pass.^agc_vertex_barrier|^agc_driver_(ngg|vertex|mesh|graphics|prepared|tessellation)): 30 of 30 pass.Crimson Desert (PPSA25286) with #6612, which gets it past its first stop:
main5d9dcc42d+ #6612main5d9dcc42d+ #6612 + this PRValidated on Windows 11 with an AMD Radeon 860M (RDNA 3.5, driver 32.0.13058.8001) by @LeandroLP23 (comment), in one build of
main6efb7261bwith this head and 13 other pull requests:agc_vertex_barrierpasses 3 runs of 3. 713 of 716agc_*tests pass; the 3 that fail fail the same way onmainthere.Not checked on Intel or on a console.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T23:30:09Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cppcore/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cppdocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mdcore/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cppdocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mdcore/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cppdocs/dev/debt/shader.mdcore/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cppdocs/dev/debt/shader.mddocs/dev/debt/shader.mdcore/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cppdocs/dev/debt/shader.mddocs/dev/debt/shader.mdcore/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cppImported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-18T16:33:02Z.
AMD on Windows: the tests this PR names pass on an RDNA 3.5 GPU.
Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), Windows 11 26300, WinLibs GCC 15.2.0 r7, Release.
main6efb7261bwith this PR (1ce582ebc) merged, together with #7296, #7446, #7377, #7445, #6708, #6748, #6785, #6706, #7449, #7391, #7489, #7484, #7514. They were built once, so the result is for the combination; each merge was clean.agc_vertex_barrier: pass, 3 runs of 3.agc_*test on the combined build: 713 of 716 pass. The 3 that fail,agc_driver_host_import_lifetime,agc_driver_quad_pixel_maskandagc_driver_layered_volume_vertex_no_gpl, fail the same way on unchangedmainhere, so none comes from these PRs.AI-assisted
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-18T18:45:47Z.
Thanks @LeandroLP23 for the AMD run on Windows. I added it to the description.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-19T01:21:38Z.
Rebased onto
main0c25997a5a(7092dde6ee). The only conflict was indocs/dev/debt/shader.md, wheremainhad updated the clip/cull distance entry next to this PR'ss_barrierentry. Both are kept: this PR'ss_barriertext andmain's clip/cull text. The 35 tests matching^agc_vertex_barrier|^agc_driver_(ngg|vertex|mesh|graphics|prepared|tessellation)pass.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T07:40:09Z.
Checked the entry-block walk (entry has no predecessors, any branch/merge stops it, memory-access set covers const, LDS, buffer, address and image ops), the new tests (fail on main without the change; the LDS-before-barrier case still throws) and the TechnicalDebt line. Merging through the queue.