agx: handle cross-workgroup memory barriers

there's no prior art for this, but experimentally this seems to do the right
thing.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29179>
This commit is contained in:
Alyssa Rosenzweig 2024-04-10 13:46:20 -04:00 committed by Marge Bot
parent c22ce3cab9
commit a948244058

View file

@ -1341,9 +1341,21 @@ agx_emit_intrinsic(agx_builder *b, nir_intrinsic_instr *instr)
if (nir_intrinsic_memory_scope(instr) != SCOPE_NONE) {
nir_variable_mode modes = nir_intrinsic_memory_modes(instr);
if (modes & (nir_var_mem_global | nir_var_image))
if (modes & (nir_var_mem_global | nir_var_image)) {
agx_memory_barrier(b);
/* Pull out all the big hammers to make cross-workgroup memory
* barriers work. Found experimentally, seems to work on G13G at
* least.
*
* TODO: check on other models, we may need more barriers for G13D.
*/
if (nir_intrinsic_memory_scope(instr) >= SCOPE_QUEUE_FAMILY) {
agx_memory_barrier_2(b);
agx_unknown_barrier_1(b);
}
}
if (modes & nir_var_image) {
agx_image_barrier_1(b);
agx_image_barrier_2(b);