From 6ea299755515d01981eefec5fb5476b9d6ee01ba Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Mon, 6 Jan 2025 19:32:55 +0100 Subject: [PATCH] rusticl/kernel: fix image_size of 1D buffer images We can't use the size of the backing resource, but have to rather specify how much of the buffer resource are used for the 1Dbuffer image. Cc: mesa-stable Reviewed-by: @LingMan (cherry picked from commit 90d83f4c30d2d18c157239e54bae9e70922d0b6b) Part-of: --- .pick_status.json | 2 +- src/gallium/frontends/rusticl/core/kernel.rs | 8 ++++++-- src/gallium/frontends/rusticl/mesa/pipe/context.rs | 3 ++- src/gallium/frontends/rusticl/mesa/pipe/resource.rs | 6 ++++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index d378b4d0e3b..8651e1b39e3 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1664,7 +1664,7 @@ "description": "rusticl/kernel: fix image_size of 1D buffer images", "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/kernel.rs b/src/gallium/frontends/rusticl/core/kernel.rs index ab7bc5c390e..b50dd1bd37c 100644 --- a/src/gallium/frontends/rusticl/core/kernel.rs +++ b/src/gallium/frontends/rusticl/core/kernel.rs @@ -1414,11 +1414,14 @@ impl Kernel { }; let format = image.pipe_format; + let size = + image.size.try_into().map_err(|_| CL_OUT_OF_RESOURCES)?; let (formats, orders) = if api_arg.kind == KernelArgType::Image { iviews.push(res.pipe_image_view( format, false, image.pipe_image_host_access(), + size, app_img_info.as_ref(), )); (&mut img_formats, &mut img_orders) @@ -1427,11 +1430,12 @@ impl Kernel { format, true, image.pipe_image_host_access(), + size, app_img_info.as_ref(), )); (&mut img_formats, &mut img_orders) } else { - sviews.push((res.clone(), format, app_img_info)); + sviews.push((res.clone(), format, size, app_img_info)); (&mut tex_formats, &mut tex_orders) }; @@ -1518,7 +1522,7 @@ impl Kernel { let mut sviews: Vec<_> = sviews .iter() - .map(|(s, f, aii)| ctx.create_sampler_view(s, *f, aii.as_ref())) + .map(|(s, f, size, aii)| ctx.create_sampler_view(s, *f, *size, aii.as_ref())) .collect(); let samplers: Vec<_> = samplers .iter() diff --git a/src/gallium/frontends/rusticl/mesa/pipe/context.rs b/src/gallium/frontends/rusticl/mesa/pipe/context.rs index b660b9c12e8..1e512bfd6a8 100644 --- a/src/gallium/frontends/rusticl/mesa/pipe/context.rs +++ b/src/gallium/frontends/rusticl/mesa/pipe/context.rs @@ -432,9 +432,10 @@ impl PipeContext { &self, res: &PipeResource, format: pipe_format, + size: u32, app_img_info: Option<&AppImgInfo>, ) -> *mut pipe_sampler_view { - let template = res.pipe_sampler_view_template(format, app_img_info); + let template = res.pipe_sampler_view_template(format, size, app_img_info); unsafe { let s_view = self.pipe.as_ref().create_sampler_view.unwrap()( diff --git a/src/gallium/frontends/rusticl/mesa/pipe/resource.rs b/src/gallium/frontends/rusticl/mesa/pipe/resource.rs index 7590824d0d3..abb8b356814 100644 --- a/src/gallium/frontends/rusticl/mesa/pipe/resource.rs +++ b/src/gallium/frontends/rusticl/mesa/pipe/resource.rs @@ -124,6 +124,7 @@ impl PipeResource { format: pipe_format, read_write: bool, host_access: u16, + size: u32, app_img_info: Option<&AppImgInfo>, ) -> PipeImageView { let pipe = PipeResource::as_ref(self); @@ -140,7 +141,7 @@ impl PipeResource { pipe_image_view__bindgen_ty_1 { buf: pipe_image_view__bindgen_ty_1__bindgen_ty_2 { offset: 0, - size: pipe.width0, + size: size, }, } } else { @@ -182,6 +183,7 @@ impl PipeResource { pub fn pipe_sampler_view_template( &self, format: pipe_format, + size: u32, app_img_info: Option<&AppImgInfo>, ) -> pipe_sampler_view { let mut res = pipe_sampler_view::default(); @@ -198,7 +200,7 @@ impl PipeResource { res.set_is_tex2d_from_buf(true); } else if res.target() == pipe_texture_target::PIPE_BUFFER { res.u.buf.offset = 0; - res.u.buf.size = self.as_ref().width0; + res.u.buf.size = size; } res