diff --git a/.pick_status.json b/.pick_status.json index 4e001133a83..c445212ce59 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -24,7 +24,7 @@ "description": "rusticl/memory: assume minimum image_height of 1", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/gallium/frontends/rusticl/api/memory.rs b/src/gallium/frontends/rusticl/api/memory.rs index 2778012daf2..479059714a5 100644 --- a/src/gallium/frontends/rusticl/api/memory.rs +++ b/src/gallium/frontends/rusticl/api/memory.rs @@ -21,6 +21,7 @@ use rusticl_proc_macros::cl_info_entrypoint; use std::alloc; use std::alloc::Layout; +use std::cmp; use std::cmp::Ordering; use std::mem::{self, MaybeUninit}; use std::os::raw::c_void; @@ -512,7 +513,7 @@ fn validate_image_desc( desc.image_row_pitch = desc.image_width * elem_size; } if desc.image_slice_pitch == 0 { - desc.image_slice_pitch = desc.image_row_pitch * desc.image_height; + desc.image_slice_pitch = desc.image_row_pitch * cmp::max(1, desc.image_height); } if has_buf_parent && desc.image_type != CL_MEM_OBJECT_IMAGE1D_BUFFER { @@ -533,8 +534,7 @@ fn validate_image_desc( } if dims == 3 || array { - let valid_slice_pitch = - desc.image_row_pitch * if dims == 1 { 1 } else { desc.image_height }; + let valid_slice_pitch = desc.image_row_pitch * cmp::max(1, desc.image_height); if desc.image_slice_pitch == 0 { desc.image_slice_pitch = valid_slice_pitch; } else if desc.image_slice_pitch < valid_slice_pitch @@ -721,7 +721,11 @@ impl CLInfo for cl_mem { CL_IMAGE_NUM_MIP_LEVELS => cl_prop::(mem.image_desc.num_mip_levels), CL_IMAGE_NUM_SAMPLES => cl_prop::(mem.image_desc.num_samples), CL_IMAGE_ROW_PITCH => cl_prop::(mem.image_desc.image_row_pitch), - CL_IMAGE_SLICE_PITCH => cl_prop::(mem.image_desc.image_slice_pitch), + CL_IMAGE_SLICE_PITCH => cl_prop::(if mem.image_desc.dims() == 1 { + 0 + } else { + mem.image_desc.image_slice_pitch + }), CL_IMAGE_WIDTH => cl_prop::(mem.image_desc.image_width), _ => return Err(CL_INVALID_VALUE), })