From e3e31868558eb30b17b3b8dbe9f832ad1e976d3d Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 14 Mar 2022 10:04:42 -0400 Subject: [PATCH] lavapipe: strip unneeded scoped barriers most of these do nothing and can't be emitted without breaking shaders Reviewed-by: Dave Airlie Part-of: --- src/gallium/frontends/lavapipe/lvp_pipeline.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/gallium/frontends/lavapipe/lvp_pipeline.c b/src/gallium/frontends/lavapipe/lvp_pipeline.c index e158489..da71793 100644 --- a/src/gallium/frontends/lavapipe/lvp_pipeline.c +++ b/src/gallium/frontends/lavapipe/lvp_pipeline.c @@ -566,6 +566,29 @@ scan_pipeline_info(struct lvp_pipeline *pipeline, nir_shader *nir) } +static bool +remove_scoped_barriers_impl(nir_builder *b, nir_instr *instr, void *data) +{ + if (instr->type != nir_instr_type_intrinsic) + return false; + nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr); + if (intr->intrinsic != nir_intrinsic_scoped_barrier) + return false; + if (data) { + if (nir_intrinsic_memory_scope(intr) == NIR_SCOPE_WORKGROUP || + nir_intrinsic_memory_scope(intr) == NIR_SCOPE_DEVICE) + return false; + } + nir_instr_remove(instr); + return true; +} + +static bool +remove_scoped_barriers(nir_shader *nir, bool is_compute) +{ + return nir_shader_instructions_pass(nir, remove_scoped_barriers_impl, nir_metadata_dominance, (void*)is_compute); +} + static void lvp_shader_compile_to_ir(struct lvp_pipeline *pipeline, struct vk_shader_module *module, @@ -637,6 +660,9 @@ lvp_shader_compile_to_ir(struct lvp_pipeline *pipeline, free(spec_entries); + if (nir->info.stage != MESA_SHADER_TESS_CTRL) + NIR_PASS_V(nir, remove_scoped_barriers, nir->info.stage == MESA_SHADER_COMPUTE); + const struct nir_lower_sysvals_to_varyings_options sysvals_to_varyings = { .frag_coord = true, .point_coord = true, -- 2.7.4