* which will result in b being removed by the pass. Return false if
* combination wasn't possible.
*/
-typedef bool (*nir_combine_memory_barrier_cb)(
+typedef bool (*nir_combine_barrier_cb)(
nir_intrinsic_instr *a, nir_intrinsic_instr *b, void *data);
-bool nir_opt_combine_memory_barriers(nir_shader *shader,
- nir_combine_memory_barrier_cb combine_cb,
- void *data);
+bool nir_opt_combine_barriers(nir_shader *shader,
+ nir_combine_barrier_cb combine_cb,
+ void *data);
bool nir_opt_combine_stores(nir_shader *shader, nir_variable_mode modes);
#include "nir.h"
static bool
-nir_opt_combine_memory_barriers_impl(
- nir_function_impl *impl, nir_combine_memory_barrier_cb combine_cb, void *data)
+nir_opt_combine_barriers_impl(
+ nir_function_impl *impl, nir_combine_barrier_cb combine_cb, void *data)
{
bool progress = false;
}
nir_intrinsic_instr *current = nir_instr_as_intrinsic(instr);
- if (current->intrinsic != nir_intrinsic_scoped_barrier ||
- nir_intrinsic_execution_scope(current) != NIR_SCOPE_NONE) {
+ if (current->intrinsic != nir_intrinsic_scoped_barrier) {
prev = NULL;
continue;
}
return progress;
}
-/* Combine adjacent scoped memory barriers. */
+/* Combine adjacent scoped barriers. */
bool
-nir_opt_combine_memory_barriers(
- nir_shader *shader, nir_combine_memory_barrier_cb combine_cb, void *data)
+nir_opt_combine_barriers(
+ nir_shader *shader, nir_combine_barrier_cb combine_cb, void *data)
{
assert(combine_cb);
nir_foreach_function(function, shader) {
if (function->impl &&
- nir_opt_combine_memory_barriers_impl(function->impl, combine_cb, data)) {
+ nir_opt_combine_barriers_impl(function->impl, combine_cb, data)) {
progress = true;
}
}
}
static
-bool combine_all_barriers(nir_intrinsic_instr *a,
- nir_intrinsic_instr *b,
- void *data)
+bool combine_all_memory_barriers(nir_intrinsic_instr *a,
+ nir_intrinsic_instr *b,
+ void *data)
{
+ /* Only combine pure memory barriers */
+ if ((nir_intrinsic_execution_scope(a) != NIR_SCOPE_NONE) ||
+ (nir_intrinsic_execution_scope(b) != NIR_SCOPE_NONE))
+ return false;
+
/* Translation to backend IR will get rid of modes we don't care about, so
* no harm in always combining them.
*
OPT(nir_lower_bit_size, lower_bit_size_callback, (void *)compiler);
OPT(brw_nir_lower_scoped_barriers);
- OPT(nir_opt_combine_memory_barriers, combine_all_barriers, NULL);
+ OPT(nir_opt_combine_barriers, combine_all_memory_barriers, NULL);
do {
progress = false;