TEST_F(nir_load_store_vectorize_test, ubo_load_adjacent_memory_barrier)
{
create_load(nir_var_mem_ubo, 0, 0, 0x1);
- nir_builder_instr_insert(b, &nir_intrinsic_instr_create(b->shader, nir_intrinsic_memory_barrier)->instr);
+
+ nir_scoped_memory_barrier(b, NIR_SCOPE_DEVICE, NIR_MEMORY_ACQ_REL,
+ nir_var_mem_ssbo);
+
create_load(nir_var_mem_ubo, 0, 4, 0x2);
nir_validate_shader(b->shader, NULL);
TEST_F(nir_load_store_vectorize_test, ssbo_load_adjacent_memory_barrier)
{
create_load(nir_var_mem_ssbo, 0, 0, 0x1);
- nir_builder_instr_insert(b, &nir_intrinsic_instr_create(b->shader, nir_intrinsic_memory_barrier)->instr);
+
+ nir_scoped_memory_barrier(b, NIR_SCOPE_DEVICE, NIR_MEMORY_ACQ_REL,
+ nir_var_mem_ssbo);
+
create_load(nir_var_mem_ssbo, 0, 4, 0x2);
nir_validate_shader(b->shader, NULL);
TEST_F(nir_load_store_vectorize_test, ssbo_load_adjacent_memory_barrier_shared)
{
create_load(nir_var_mem_ssbo, 0, 0, 0x1);
- nir_builder_instr_insert(b, &nir_intrinsic_instr_create(b->shader, nir_intrinsic_memory_barrier_shared)->instr);
+
+ nir_scoped_memory_barrier(b, NIR_SCOPE_WORKGROUP, NIR_MEMORY_ACQ_REL,
+ nir_var_mem_shared);
+
create_load(nir_var_mem_ssbo, 0, 4, 0x2);
nir_validate_shader(b->shader, NULL);
class nir_combine_stores_test : public nir_vars_test {};
class nir_split_vars_test : public nir_vars_test {};
-void
-scoped_memory_barrier(nir_builder *b,
- nir_memory_semantics semantics,
- nir_variable_mode modes,
- nir_scope scope = NIR_SCOPE_DEVICE)
-{
- nir_intrinsic_instr *intrin =
- nir_intrinsic_instr_create(b->shader, nir_intrinsic_scoped_memory_barrier);
- nir_intrinsic_set_memory_semantics(intrin, semantics);
- nir_intrinsic_set_memory_modes(intrin, modes);
- nir_intrinsic_set_memory_scope(intrin, scope);
- nir_builder_instr_insert(b, &intrin->instr);
-}
-
} // namespace
TEST_F(nir_redundant_load_vars_test, duplicated_load)
nir_store_var(b, v[2], nir_load_var(b, v[0]), 1);
- nir_builder_instr_insert(b, &nir_intrinsic_instr_create(b->shader, nir_intrinsic_memory_barrier)->instr);
+ nir_scoped_memory_barrier(b, NIR_SCOPE_DEVICE, NIR_MEMORY_ACQ_REL,
+ nir_var_mem_ssbo);
nir_store_var(b, v[3], nir_load_var(b, v[1]), 1);
nir_load_var(b, x[0]);
- scoped_memory_barrier(b, NIR_MEMORY_ACQUIRE, nir_var_mem_ssbo);
+ nir_scoped_memory_barrier(b, NIR_SCOPE_DEVICE, NIR_MEMORY_ACQUIRE,
+ nir_var_mem_ssbo);
nir_load_var(b, x[0]);
nir_load_var(b, x[0]);
nir_load_var(b, x[1]);
- scoped_memory_barrier(b, NIR_MEMORY_ACQUIRE, nir_var_mem_ssbo);
+ nir_scoped_memory_barrier(b, NIR_SCOPE_DEVICE, NIR_MEMORY_ACQUIRE,
+ nir_var_mem_ssbo);
nir_load_var(b, x[0]);
nir_load_var(b, x[1]);
nir_load_var(b, y[0]);
nir_load_var(b, y[1]);
- scoped_memory_barrier(b, NIR_MEMORY_ACQUIRE, nir_var_mem_ssbo);
+ nir_scoped_memory_barrier(b, NIR_SCOPE_DEVICE, NIR_MEMORY_ACQUIRE,
+ nir_var_mem_ssbo);
nir_load_var(b, x[0]);
nir_load_var(b, x[1]);
nir_load_var(b, x[0]);
- scoped_memory_barrier(b, NIR_MEMORY_RELEASE, nir_var_mem_ssbo);
+ nir_scoped_memory_barrier(b, NIR_SCOPE_DEVICE, NIR_MEMORY_RELEASE,
+ nir_var_mem_ssbo);
nir_load_var(b, x[0]);
nir_load_var(b, x[0]);
nir_load_var(b, x[1]);
- scoped_memory_barrier(b, NIR_MEMORY_RELEASE, nir_var_mem_ssbo);
+ nir_scoped_memory_barrier(b, NIR_SCOPE_DEVICE, NIR_MEMORY_RELEASE,
+ nir_var_mem_ssbo);
nir_load_var(b, x[0]);
nir_load_var(b, x[1]);
nir_load_var(b, y[0]);
nir_load_var(b, y[1]);
- scoped_memory_barrier(b, NIR_MEMORY_RELEASE, nir_var_mem_ssbo);
+ nir_scoped_memory_barrier(b, NIR_SCOPE_DEVICE, NIR_MEMORY_RELEASE,
+ nir_var_mem_ssbo);
nir_load_var(b, x[0]);
nir_load_var(b, x[1]);
nir_store_var(b, x[0], nir_imm_int(b, 10), 1);
- scoped_memory_barrier(b, NIR_MEMORY_ACQUIRE, nir_var_mem_ssbo);
+ nir_scoped_memory_barrier(b, NIR_SCOPE_DEVICE, NIR_MEMORY_ACQUIRE,
+ nir_var_mem_ssbo);
nir_load_var(b, x[0]);
nir_store_var(b, x[0], nir_imm_int(b, 10), 1);
nir_store_var(b, x[1], nir_imm_int(b, 20), 1);
- scoped_memory_barrier(b, NIR_MEMORY_ACQUIRE, nir_var_mem_ssbo);
+ nir_scoped_memory_barrier(b, NIR_SCOPE_DEVICE, NIR_MEMORY_ACQUIRE,
+ nir_var_mem_ssbo);
nir_load_var(b, x[0]);
nir_load_var(b, x[1]);
nir_store_var(b, y[0], nir_imm_int(b, 30), 1);
nir_store_var(b, y[1], nir_imm_int(b, 40), 1);
- scoped_memory_barrier(b, NIR_MEMORY_ACQUIRE, nir_var_mem_ssbo);
+ nir_scoped_memory_barrier(b, NIR_SCOPE_DEVICE, NIR_MEMORY_ACQUIRE,
+ nir_var_mem_ssbo);
nir_load_var(b, x[0]);
nir_load_var(b, x[1]);
nir_store_var(b, x[0], nir_imm_int(b, 10), 1);
- scoped_memory_barrier(b, NIR_MEMORY_RELEASE, nir_var_mem_ssbo);
+ nir_scoped_memory_barrier(b, NIR_SCOPE_DEVICE, NIR_MEMORY_RELEASE,
+ nir_var_mem_ssbo);
nir_load_var(b, x[0]);
nir_store_var(b, x[0], nir_imm_int(b, 10), 1);
nir_store_var(b, x[1], nir_imm_int(b, 20), 1);
- scoped_memory_barrier(b, NIR_MEMORY_RELEASE, nir_var_mem_ssbo);
+ nir_scoped_memory_barrier(b, NIR_SCOPE_DEVICE, NIR_MEMORY_RELEASE,
+ nir_var_mem_ssbo);
nir_load_var(b, x[0]);
nir_load_var(b, x[1]);
nir_store_var(b, y[0], nir_imm_int(b, 30), 1);
nir_store_var(b, y[1], nir_imm_int(b, 40), 1);
- scoped_memory_barrier(b, NIR_MEMORY_RELEASE, nir_var_mem_ssbo);
+ nir_scoped_memory_barrier(b, NIR_SCOPE_DEVICE, NIR_MEMORY_RELEASE,
+ nir_var_mem_ssbo);
nir_load_var(b, x[0]);
nir_load_var(b, x[1]);
nir_copy_var(b, x[1], x[0]);
- scoped_memory_barrier(b, NIR_MEMORY_ACQUIRE, nir_var_mem_ssbo);
+ nir_scoped_memory_barrier(b, NIR_SCOPE_DEVICE, NIR_MEMORY_ACQUIRE,
+ nir_var_mem_ssbo);
nir_copy_var(b, x[2], x[1]);
nir_copy_var(b, y[0], x[0]);
- scoped_memory_barrier(b, NIR_MEMORY_ACQUIRE, nir_var_mem_ssbo);
+ nir_scoped_memory_barrier(b, NIR_SCOPE_DEVICE, NIR_MEMORY_ACQUIRE,
+ nir_var_mem_ssbo);
nir_copy_var(b, x[1], y[0]);
nir_copy_var(b, x[1], x[0]);
- scoped_memory_barrier(b, NIR_MEMORY_RELEASE, nir_var_mem_ssbo);
+ nir_scoped_memory_barrier(b, NIR_SCOPE_DEVICE, NIR_MEMORY_RELEASE,
+ nir_var_mem_ssbo);
nir_copy_var(b, x[2], x[1]);
nir_copy_var(b, y[0], x[0]);
- scoped_memory_barrier(b, NIR_MEMORY_RELEASE, nir_var_mem_ssbo);
+ nir_scoped_memory_barrier(b, NIR_SCOPE_DEVICE, NIR_MEMORY_RELEASE,
+ nir_var_mem_ssbo);
nir_copy_var(b, x[1], y[0]);
/* Because it is before the barrier, this will kill the previous store to that target. */
nir_store_var(b, v[0], nir_imm_int(b, 3), 1);
- nir_builder_instr_insert(b, &nir_intrinsic_instr_create(b->shader, nir_intrinsic_memory_barrier)->instr);
+ nir_scoped_memory_barrier(b, NIR_SCOPE_DEVICE, NIR_MEMORY_ACQ_REL,
+ nir_var_mem_ssbo);
nir_store_var(b, v[1], nir_imm_int(b, 4), 1);