From 80ce5dcae8f9db929fa46d3f41e8971ebef75790 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Tue, 22 Apr 2025 13:42:57 +0200 Subject: [PATCH] rusticl/device: fix panic when disabling 3D image write support Cc: mesa-stable Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12985 Reviewed-by: @LingMan Part-of: (cherry picked from commit 6f080ac5324b7cf1d394ea1a08a8002be74326f6) --- .pick_status.json | 2 +- src/gallium/frontends/rusticl/core/device.rs | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 1cfff910291..891fb163d21 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -154,7 +154,7 @@ "description": "rusticl/device: fix panic when disabling 3D image write support", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/gallium/frontends/rusticl/core/device.rs b/src/gallium/frontends/rusticl/core/device.rs index 6d0480a7a2f..5ad2d9c7d56 100644 --- a/src/gallium/frontends/rusticl/core/device.rs +++ b/src/gallium/frontends/rusticl/core/device.rs @@ -366,11 +366,14 @@ impl Device { // if we can't advertize 3d image write ext, we have to disable them all if !self.caps.has_3d_image_writes { - for f in &mut self.formats.values_mut() { - *f.get_mut(&CL_MEM_OBJECT_IMAGE3D).unwrap() &= !cl_mem_flags::from( - CL_MEM_WRITE_ONLY | CL_MEM_READ_WRITE | CL_MEM_KERNEL_READ_AND_WRITE, - ); - } + self.formats + .values_mut() + .filter_map(|f| f.get_mut(&CL_MEM_OBJECT_IMAGE3D)) + .for_each(|flags| { + *flags &= !cl_mem_flags::from( + CL_MEM_WRITE_ONLY | CL_MEM_READ_WRITE | CL_MEM_KERNEL_READ_AND_WRITE, + ) + }); } // we require formatted loads