From 65bd87bd35789e4062766097745f894e6b7c1984 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Mon, 23 Oct 2023 19:17:16 +0200 Subject: [PATCH] rusticl/mem: properly set pipe_image_view::access Cc: mesa-stable Signed-off-by: Karol Herbst Part-of: (cherry picked from commit abd8ef84ff4034a8f159f4743dc025dbfde8b837) --- .pick_status.json | 2 +- src/gallium/frontends/rusticl/core/kernel.rs | 14 ++++++++++++-- src/gallium/frontends/rusticl/core/memory.rs | 13 +++++++++++++ src/gallium/frontends/rusticl/mesa/pipe/resource.rs | 3 ++- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 28636b6..06ede16 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -744,7 +744,7 @@ "description": "rusticl/mem: properly set pipe_image_view::access", "nominated": true, "nomination_type": 0, - "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 09ab0bd..21a604c 100644 --- a/src/gallium/frontends/rusticl/core/kernel.rs +++ b/src/gallium/frontends/rusticl/core/kernel.rs @@ -919,10 +919,20 @@ impl Kernel { } else { let format = mem.pipe_format; let (formats, orders) = if arg.kind == KernelArgType::Image { - iviews.push(res.pipe_image_view(format, false, app_img_info.as_ref())); + iviews.push(res.pipe_image_view( + format, + false, + mem.pipe_image_host_access(), + app_img_info.as_ref(), + )); (&mut img_formats, &mut img_orders) } else if arg.kind == KernelArgType::RWImage { - iviews.push(res.pipe_image_view(format, true, app_img_info.as_ref())); + iviews.push(res.pipe_image_view( + format, + true, + mem.pipe_image_host_access(), + app_img_info.as_ref(), + )); (&mut img_formats, &mut img_orders) } else { sviews.push((res.clone(), format, app_img_info)); diff --git a/src/gallium/frontends/rusticl/core/memory.rs b/src/gallium/frontends/rusticl/core/memory.rs index c7f3c3b..55cf374 100644 --- a/src/gallium/frontends/rusticl/core/memory.rs +++ b/src/gallium/frontends/rusticl/core/memory.rs @@ -1231,6 +1231,19 @@ impl Mem { Ok(()) } + + pub fn pipe_image_host_access(&self) -> u16 { + // those flags are all mutually exclusive + (if bit_check(self.flags, CL_MEM_HOST_READ_ONLY) { + PIPE_IMAGE_ACCESS_READ + } else if bit_check(self.flags, CL_MEM_HOST_WRITE_ONLY) { + PIPE_IMAGE_ACCESS_WRITE + } else if bit_check(self.flags, CL_MEM_HOST_NO_ACCESS) { + 0 + } else { + PIPE_IMAGE_ACCESS_READ_WRITE + }) as u16 + } } impl Drop for Mem { diff --git a/src/gallium/frontends/rusticl/mesa/pipe/resource.rs b/src/gallium/frontends/rusticl/mesa/pipe/resource.rs index 521b8c5..3b80756 100644 --- a/src/gallium/frontends/rusticl/mesa/pipe/resource.rs +++ b/src/gallium/frontends/rusticl/mesa/pipe/resource.rs @@ -82,6 +82,7 @@ impl PipeResource { &self, format: pipe_format, read_write: bool, + host_access: u16, app_img_info: Option<&AppImgInfo>, ) -> pipe_image_view { let u = if let Some(app_img_info) = app_img_info { @@ -130,7 +131,7 @@ impl PipeResource { pipe_image_view { resource: self.pipe(), format: format, - access: access, + access: access | host_access, shader_access: shader_access, u: u, } -- 2.7.4