From 1bbc997bef340a8ed8fceede40de030389284a86 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Thu, 8 Jun 2023 14:42:00 +0200 Subject: [PATCH] rusticl: fix clippy errors on image_slice_pitch change to usize That field got changed from `unsigned` to `uintptr_t` on the C side, so now we can drop a bit of code dealing with conversions to `usize`. Fixes: 68735f4e860 ("treewide: use uint64_t / (u)intptr_t in image address calculations") Signed-off-by: Karol Herbst Part-of: --- src/gallium/frontends/rusticl/core/context.rs | 2 +- src/gallium/frontends/rusticl/core/memory.rs | 16 ++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/gallium/frontends/rusticl/core/context.rs b/src/gallium/frontends/rusticl/core/context.rs index 3f1dbdc78aa..9f7404780b6 100644 --- a/src/gallium/frontends/rusticl/core/context.rs +++ b/src/gallium/frontends/rusticl/core/context.rs @@ -132,7 +132,7 @@ impl Context { if !user_ptr.is_null() { let bx = desc.bx()?; let stride = desc.row_pitch()?; - let layer_stride = desc.slice_pitch()?; + let layer_stride = desc.slice_pitch(); res.iter() .filter(|(_, r)| copy || !r.is_user) diff --git a/src/gallium/frontends/rusticl/core/memory.rs b/src/gallium/frontends/rusticl/core/memory.rs index df9dc17fa16..1511b44ce1b 100644 --- a/src/gallium/frontends/rusticl/core/memory.rs +++ b/src/gallium/frontends/rusticl/core/memory.rs @@ -127,7 +127,7 @@ pub trait CLImageDescInfo { fn pixels(&self) -> usize; fn bx(&self) -> CLResult; fn row_pitch(&self) -> CLResult; - fn slice_pitch(&self) -> CLResult; + fn slice_pitch(&self) -> usize; fn width(&self) -> CLResult; fn height(&self) -> CLResult; fn size(&self) -> CLVec; @@ -204,10 +204,8 @@ impl CLImageDescInfo for cl_image_desc { .map_err(|_| CL_OUT_OF_HOST_MEMORY) } - fn slice_pitch(&self) -> CLResult { + fn slice_pitch(&self) -> usize { self.image_slice_pitch - .try_into() - .map_err(|_| CL_OUT_OF_HOST_MEMORY) } fn width(&self) -> CLResult { @@ -679,7 +677,7 @@ impl Mem { src_pitch[0] = bpp; if self.is_image_from_buffer() { src_pitch[1] = self.image_desc.row_pitch()? as usize; - src_pitch[2] = self.image_desc.slice_pitch()? as usize; + src_pitch[2] = self.image_desc.slice_pitch(); } else { src_pitch[1] = region[0] * bpp; src_pitch[2] = region[0] * region[1] * bpp; @@ -707,7 +705,7 @@ impl Mem { dst_pitch[0] = bpp; if dst_base.is_image_from_buffer() { dst_pitch[1] = dst_base.image_desc.row_pitch()? as usize; - dst_pitch[2] = dst_base.image_desc.slice_pitch()? as usize; + dst_pitch[2] = dst_base.image_desc.slice_pitch(); } else { dst_pitch[1] = region[0] * bpp; dst_pitch[2] = region[0] * region[1] * bpp; @@ -820,7 +818,7 @@ impl Mem { if self.is_parent_buffer() { let strides = ( self.image_desc.row_pitch()? as usize, - self.image_desc.slice_pitch()? as usize, + self.image_desc.slice_pitch(), ); ctx.clear_image_buffer(res, &new_pattern, origin, region, strides, pixel_size); } else { @@ -888,9 +886,7 @@ impl Mem { src_row_pitch .try_into() .map_err(|_| CL_OUT_OF_HOST_MEMORY)?, - src_slice_pitch - .try_into() - .map_err(|_| CL_OUT_OF_HOST_MEMORY)?, + src_slice_pitch, ); } Ok(())