aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2020-01-07 14:40:53 -0600
committerMarge Bot <[email protected]>2020-01-13 17:23:47 +0000
commitba43b66dc996988ec326d35395e9699ea4f66fdf (patch)
treeff8ffbdd00b4b08f3507a3762db2d9d6e7e8f654 /src/compiler
parenta4125b4d261df39189f67dffaa5c90c0f6f66fe6 (diff)
nir/glsl: Emit memory barriers as part of barrier()
The GLSL barrier() intrinsic does an implicit shared memory barrier in compute shaders and an implicit TCS patch output barrier in tessellation control shaders. We'd like NIR's barrier intrinsic to just be a control flow barrier and not have memory implications. To satisfy this, we need to add an extra memory barrier in front of each nir_intrinsic_barrier. Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3307>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/glsl/glsl_to_nir.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp
index 479832b5ab0..4ab620142b0 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -2701,6 +2701,18 @@ nir_visitor::visit(ir_dereference_array *ir)
void
nir_visitor::visit(ir_barrier *)
{
+ if (shader->info.stage == MESA_SHADER_COMPUTE) {
+ nir_intrinsic_instr *shared_barrier =
+ nir_intrinsic_instr_create(this->shader,
+ nir_intrinsic_memory_barrier_shared);
+ nir_builder_instr_insert(&b, &shared_barrier->instr);
+ } else if (shader->info.stage == MESA_SHADER_TESS_CTRL) {
+ nir_intrinsic_instr *patch_barrier =
+ nir_intrinsic_instr_create(this->shader,
+ nir_intrinsic_memory_barrier_tcs_patch);
+ nir_builder_instr_insert(&b, &patch_barrier->instr);
+ }
+
nir_intrinsic_instr *instr =
nir_intrinsic_instr_create(this->shader, nir_intrinsic_barrier);
nir_builder_instr_insert(&b, &instr->instr);