Skip to content

Commit

Permalink
rusticl/kernel: run opt/lower_memcpy later to fix a crash
Browse files Browse the repository at this point in the history
nir_opt_memcpy requires explicit types to function properly. So run them
after lowering vars to explicit types.

Cc: mesa-stable
Signed-off-by: Karol Herbst <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27068>
(cherry picked from commit f8966598940ad46fb1ff2cbd9c23013289ef0736)
  • Loading branch information
karolherbst authored and 1ace committed Jan 16, 2024
1 parent a34a657 commit 3cc0051
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .pick_status.json
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@
"description": "rusticl/kernel: run opt/lower_memcpy later to fix a crash",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null
Expand Down
14 changes: 8 additions & 6 deletions src/gallium/frontends/rusticl/core/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ where
res
}

fn opt_nir(nir: &mut NirShader, dev: &Device) {
fn opt_nir(nir: &mut NirShader, dev: &Device, has_explicit_types: bool) {
let nir_options = unsafe {
&*dev
.screen
Expand All @@ -342,7 +342,9 @@ fn opt_nir(nir: &mut NirShader, dev: &Device) {
}

progress |= nir_pass!(nir, nir_opt_deref);
progress |= nir_pass!(nir, nir_opt_memcpy);
if has_explicit_types {
progress |= nir_pass!(nir, nir_opt_memcpy);
}
progress |= nir_pass!(nir, nir_opt_dce);
progress |= nir_pass!(nir, nir_opt_undef);
progress |= nir_pass!(nir, nir_opt_constant_folding);
Expand Down Expand Up @@ -452,11 +454,10 @@ fn lower_and_optimize_nir(
printf_opts.max_buffer_size = dev.printf_buffer_size() as u32;
nir_pass!(nir, nir_lower_printf, &printf_opts);

opt_nir(nir, dev);
opt_nir(nir, dev, false);

let mut args = KernelArg::from_spirv_nir(args, nir);
let mut internal_args = Vec::new();
nir_pass!(nir, nir_lower_memcpy);

let dv_opts = nir_remove_dead_variables_options {
can_remove_var: Some(can_remove_var),
Expand Down Expand Up @@ -627,7 +628,8 @@ fn lower_and_optimize_nir(
Some(glsl_get_cl_type_size_align),
);

opt_nir(nir, dev);
opt_nir(nir, dev, true);
nir_pass!(nir, nir_lower_memcpy);

nir_pass!(
nir,
Expand Down Expand Up @@ -656,7 +658,7 @@ fn lower_and_optimize_nir(

nir_pass!(nir, nir_lower_convert_alu_types, None);

opt_nir(nir, dev);
opt_nir(nir, dev, true);

/* before passing it into drivers, assign locations as drivers might remove nir_variables or
* other things we depend on
Expand Down

0 comments on commit 3cc0051

Please sign in to comment.