nir/opt_barriers: Add a default callback
Absent any knowledge about the hardware, if the backend wants to combine barriers we should try to combine all barriers. 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/23181>
This commit is contained in:
committed by
Marge Bot
parent
ecd295bb8b
commit
2da3a6e1b9
@@ -23,6 +23,20 @@
|
||||
|
||||
#include "nir.h"
|
||||
|
||||
static bool
|
||||
combine_all_barriers(nir_intrinsic_instr *a, nir_intrinsic_instr *b, void *_)
|
||||
{
|
||||
nir_intrinsic_set_memory_modes(
|
||||
a, nir_intrinsic_memory_modes(a) | nir_intrinsic_memory_modes(b));
|
||||
nir_intrinsic_set_memory_semantics(
|
||||
a, nir_intrinsic_memory_semantics(a) | nir_intrinsic_memory_semantics(b));
|
||||
nir_intrinsic_set_memory_scope(
|
||||
a, MAX2(nir_intrinsic_memory_scope(a), nir_intrinsic_memory_scope(b)));
|
||||
nir_intrinsic_set_execution_scope(
|
||||
a, MAX2(nir_intrinsic_execution_scope(a), nir_intrinsic_execution_scope(b)));
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
nir_opt_combine_barriers_impl(
|
||||
nir_function_impl *impl, nir_combine_barrier_cb combine_cb, void *data)
|
||||
@@ -69,7 +83,9 @@ bool
|
||||
nir_opt_combine_barriers(
|
||||
nir_shader *shader, nir_combine_barrier_cb combine_cb, void *data)
|
||||
{
|
||||
assert(combine_cb);
|
||||
/* Default to combining everything. Only some backends can do better. */
|
||||
if (!combine_cb)
|
||||
combine_cb = combine_all_barriers;
|
||||
|
||||
bool progress = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user