lavapipe: strip unneeded scoped barriers

most of these do nothing and can't be emitted without breaking shaders

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15377>
This commit is contained in:
Mike Blumenkrantz
2022-03-14 10:04:42 -04:00
committed by Marge Bot
parent a83ea0253f
commit e3e3186855

View File

@@ -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,