rusticl/kernel: sweep nir to reduce peak memory usage

Signed-off-by: Karol Herbst <kherbst@redhat.com>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15439>
This commit is contained in:
Karol Herbst 2022-03-18 16:24:30 +01:00 committed by Marge Bot
parent 7c7cbad1c3
commit a23af19f86
2 changed files with 7 additions and 0 deletions

View file

@ -174,6 +174,8 @@ fn lower_and_optimize_nir_pre_inputs(nir: &mut NirShader, lib_clc: &NirShader) {
} {}
nir.inline(lib_clc);
nir.remove_non_entrypoints();
// that should free up tons of memory
nir.sweep_mem();
while {
let mut progress = false;
progress |= nir.pass0(nir_copy_prop);
@ -326,6 +328,7 @@ fn lower_and_optimize_nir_late(
nir.pass1(nir_lower_convert_alu_types, None);
nir.pass0(nir_opt_dce);
dev.screen.finalize_nir(nir);
nir.sweep_mem();
res
}

View file

@ -81,6 +81,10 @@ impl NirShader {
unsafe { nir_shader_clone(ptr::null_mut(), self.nir.as_ptr()) }
}
pub fn sweep_mem(&self) {
unsafe { nir_sweep(self.nir.as_ptr()) }
}
pub fn pass0<R>(&mut self, pass: unsafe extern "C" fn(*mut nir_shader) -> R) -> R {
unsafe { pass(self.nir.as_ptr()) }
}