rusticl/mem: properly set pipe_image_view::access
authorKarol Herbst <kherbst@redhat.com>
Mon, 23 Oct 2023 17:17:16 +0000 (19:17 +0200)
committerEric Engestrom <eric@engestrom.ch>
Mon, 30 Oct 2023 15:47:32 +0000 (15:47 +0000)
Cc: mesa-stable
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25837>
(cherry picked from commit abd8ef84ff4034a8f159f4743dc025dbfde8b837)

.pick_status.json
src/gallium/frontends/rusticl/core/kernel.rs
src/gallium/frontends/rusticl/core/memory.rs
src/gallium/frontends/rusticl/mesa/pipe/resource.rs

index 28636b6..06ede16 100644 (file)
         "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
index 09ab0bd..21a604c 100644 (file)
@@ -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));
index c7f3c3b..55cf374 100644 (file)
@@ -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 {
index 521b8c5..3b80756 100644 (file)
@@ -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,
         }