} 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));
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 {
&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 {
pipe_image_view {
resource: self.pipe(),
format: format,
- access: access,
+ access: access | host_access,
shader_access: shader_access,
u: u,
}