Repository navigation
fix(shader): declare the GDS buffer coherent - #4279
Merged
adriadam10 merged 1 commit intoOct 13, 2026
Merged
Conversation
10 tasks done
GDS is one memory for the whole GPU on AMD hardware: every work-group's ds_read and ds_write with gds see the others' writes, with no cache in between. The recompiler keeps it in a storage buffer that was not decorated Coherent, so on a GPU whose L1 caches storage buffer loads, NVIDIA's from Turing on among them, a plain GDS read could return a value cached before another work-group's GDS write. Atomics were not affected. The gds buffer is now declared Coherent. verifyCoherentGds in agc_shader_memory compiles a ds_read_b32 and a ds_write_b32 on GDS and checks that the gds buffer is Coherent.
Collaborator
|
Rebased onto current main (only an adjacent-test conflict in |
adriadam10
force-pushed
the
fix/shader-coherent-gds
branch
from
October 13, 2026 13:54
5328f13 to
0998eb4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The storage buffer that holds GDS is now declared
Coherent.Background.
ds_read/ds_writewithgdssees the others' writes, with no cache in between.gds,SpirvEmitterHelpers.cpp). Every GDS access goes through it: reads, writes and atomics (SpirvBufferAccess.cpp,ResourceKind::Gds).Coherent. On a GPU whose L1 caches storage-buffer loads (NVIDIA's from Turing on, among others), a plain GDS read could therefore return a value cached before another work-group's GDS write.Why results don't change.
Coherentonly stops loads and stores from being served by a non-coherent cache. A program without cross-work-group GDS traffic reads the same values. GDS traffic is small (counters and small tables), so the cost of going to L2 is negligible.Tested
Windows 11, MinGW-w64 GCC 15.2.0, Release, this branch on
mainat d146ec1. Devices:RTX 4060 Laptop (Ada, driver 591.86)
Intel UHD Graphics (Raptor Lake, driver 101.6790)
lavapipe from Mesa 25.2.8 (llvmpipe, LLVM 21.1.7): the version CI installs; Windows build with
GALLIUM_OVERRIDE_CPU_CAPS=avx.New
verifyCoherentGdsinagc_shader_memory:ds_read_b32and ads_write_b32withgdsand checks that thegdsbuffer is decoratedCoherent.coherent GDS: the gds buffer is not Coherent.agc_driver_gds_append_consumepasses on the RTX 4060 and the Intel UHD. lavapipe skips it.Shader and driver tests (
agc_driver_*,agc_shader_*,agc_spirv_*,vector_*,agc_masked_select,agc_validate_program,agc_denormal*,agc_float16_*; 338 tests):agc_driver_flat_loads*,agc_driver_global_loads*,agc_driver_flat_apertures*,agc_driver_pixel_interlock.agc_driver_ds_swizzleandagc_driver_f32_dot2_rounding, which fail the same way onmain.agc_driver_depth_fast_clear_submit, which also happens intermittently withmain's code.Limits.
gdsbit, so I don't know how often titles read GDS with plain loads.ds_append(25) andds_consume(2) appear, but they are atomics.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)