nir/opt_barrier: Generalize to control barriers
For GLSL, we want to optimize code like memoryBarrierBuffer(); controlBarrier(); into a single scoped_barrier intrinsic for the backend to consume. Now that backends can get scoped_barriers everywhere, what's left is enabling backends to combine these barriers together. We already have an Intel-specific pass for combining memory barriers; it just needs a teensy bit of generalization to allow combining all sorts of barriers together. This avoids code quality regression on Asahi when switching to purely scoped barriers. It's probably useful for other backends too. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Caio Oliveira <caio.oliveira@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21661>
This commit is contained in:

committed by
Marge Bot

parent
83fd7a5ed1
commit
952bd63d6d
@@ -5720,12 +5720,12 @@ bool nir_opt_constant_folding(nir_shader *shader);
|
||||
* 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);
|
||||
|
||||
|
@@ -24,8 +24,8 @@
|
||||
#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;
|
||||
|
||||
@@ -39,8 +39,7 @@ nir_opt_combine_memory_barriers_impl(
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -65,10 +64,10 @@ nir_opt_combine_memory_barriers_impl(
|
||||
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);
|
||||
|
||||
@@ -76,7 +75,7 @@ nir_opt_combine_memory_barriers(
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user