rusticl/mem: add restrictions for CL_DEPTH, CL_DEPTH_STENCIL and msaa images
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30831>
This commit is contained in:
@@ -394,6 +394,12 @@ fn validate_image_format<'a>(
|
||||
.pixel_size()
|
||||
.ok_or(CL_INVALID_IMAGE_FORMAT_DESCRIPTOR)?;
|
||||
|
||||
// Depth images with an image channel order of CL_DEPTH_STENCIL can only be created using the
|
||||
// clCreateFromGLTexture API
|
||||
if format.image_channel_order == CL_DEPTH_STENCIL {
|
||||
return Err(CL_INVALID_IMAGE_FORMAT_DESCRIPTOR);
|
||||
}
|
||||
|
||||
// special validation
|
||||
let valid_combination = match format.image_channel_data_type {
|
||||
CL_UNORM_SHORT_565 | CL_UNORM_SHORT_555 | CL_UNORM_INT_101010 => {
|
||||
@@ -1714,6 +1720,11 @@ fn enqueue_read_image(
|
||||
return Err(CL_INVALID_OPERATION);
|
||||
}
|
||||
|
||||
// Not supported with depth stencil or msaa images.
|
||||
if i.image_format.image_channel_order == CL_DEPTH_STENCIL || i.image_desc.num_samples > 0 {
|
||||
return Err(CL_INVALID_OPERATION);
|
||||
}
|
||||
|
||||
// CL_INVALID_VALUE if origin or region is NULL.
|
||||
// CL_INVALID_VALUE if ptr is NULL.
|
||||
if origin.is_null() || region.is_null() || ptr.is_null() {
|
||||
@@ -1793,6 +1804,11 @@ fn enqueue_write_image(
|
||||
return Err(CL_INVALID_OPERATION);
|
||||
}
|
||||
|
||||
// Not supported with depth stencil or msaa images.
|
||||
if i.image_format.image_channel_order == CL_DEPTH_STENCIL || i.image_desc.num_samples > 0 {
|
||||
return Err(CL_INVALID_OPERATION);
|
||||
}
|
||||
|
||||
// CL_INVALID_VALUE if origin or region is NULL.
|
||||
// CL_INVALID_VALUE if ptr is NULL.
|
||||
if origin.is_null() || region.is_null() || ptr.is_null() {
|
||||
@@ -1868,6 +1884,15 @@ fn enqueue_copy_image(
|
||||
return Err(CL_IMAGE_FORMAT_MISMATCH);
|
||||
}
|
||||
|
||||
// Not supported with depth stencil or msaa images.
|
||||
if src_image.image_format.image_channel_order == CL_DEPTH_STENCIL
|
||||
|| dst_image.image_format.image_channel_order == CL_DEPTH_STENCIL
|
||||
|| src_image.image_desc.num_samples > 0
|
||||
|| dst_image.image_desc.num_samples > 0
|
||||
{
|
||||
return Err(CL_INVALID_OPERATION);
|
||||
}
|
||||
|
||||
// CL_INVALID_VALUE if src_origin, dst_origin, or region is NULL.
|
||||
if src_origin.is_null() || dst_origin.is_null() || region.is_null() {
|
||||
return Err(CL_INVALID_VALUE);
|
||||
@@ -1922,6 +1947,11 @@ fn enqueue_fill_image(
|
||||
return Err(CL_INVALID_CONTEXT);
|
||||
}
|
||||
|
||||
// Not supported with depth stencil or msaa images.
|
||||
if i.image_format.image_channel_order == CL_DEPTH_STENCIL || i.image_desc.num_samples > 0 {
|
||||
return Err(CL_INVALID_OPERATION);
|
||||
}
|
||||
|
||||
// CL_INVALID_VALUE if fill_color is NULL.
|
||||
// CL_INVALID_VALUE if origin or region is NULL.
|
||||
if fill_color.is_null() || origin.is_null() || region.is_null() {
|
||||
@@ -1977,6 +2007,11 @@ fn enqueue_copy_buffer_to_image(
|
||||
return Err(CL_INVALID_CONTEXT);
|
||||
}
|
||||
|
||||
// Not supported with depth stencil or msaa images.
|
||||
if dst.image_format.image_channel_order == CL_DEPTH_STENCIL || dst.image_desc.num_samples > 0 {
|
||||
return Err(CL_INVALID_OPERATION);
|
||||
}
|
||||
|
||||
// CL_INVALID_VALUE if dst_origin or region is NULL.
|
||||
if dst_origin.is_null() || region.is_null() {
|
||||
return Err(CL_INVALID_VALUE);
|
||||
@@ -2032,6 +2067,11 @@ fn enqueue_copy_image_to_buffer(
|
||||
return Err(CL_INVALID_CONTEXT);
|
||||
}
|
||||
|
||||
// Not supported with depth stencil or msaa images.
|
||||
if src.image_format.image_channel_order == CL_DEPTH_STENCIL || src.image_desc.num_samples > 0 {
|
||||
return Err(CL_INVALID_OPERATION);
|
||||
}
|
||||
|
||||
// CL_INVALID_VALUE if src_origin or region is NULL.
|
||||
if src_origin.is_null() || region.is_null() {
|
||||
return Err(CL_INVALID_VALUE);
|
||||
@@ -2092,6 +2132,11 @@ fn enqueue_map_image(
|
||||
return Err(CL_INVALID_CONTEXT);
|
||||
}
|
||||
|
||||
// Not supported with depth stencil or msaa images.
|
||||
if i.image_format.image_channel_order == CL_DEPTH_STENCIL || i.image_desc.num_samples > 0 {
|
||||
return Err(CL_INVALID_OPERATION);
|
||||
}
|
||||
|
||||
// CL_INVALID_VALUE if origin or region is NULL.
|
||||
// CL_INVALID_VALUE if image_row_pitch is NULL.
|
||||
if origin.is_null() || region.is_null() || image_row_pitch.is_null() {
|
||||
|
||||
@@ -252,6 +252,13 @@ impl Device {
|
||||
for f in FORMATS {
|
||||
let mut fs = HashMap::new();
|
||||
for t in CL_IMAGE_TYPES {
|
||||
// depth images are only valid for 2D and 2DArray
|
||||
if [CL_DEPTH, CL_DEPTH_STENCIL].contains(&f.cl_image_format.image_channel_order)
|
||||
&& ![CL_MEM_OBJECT_IMAGE2D, CL_MEM_OBJECT_IMAGE2D_ARRAY].contains(&t)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// the CTS doesn't test them, so let's not advertize them by accident if they are
|
||||
// broken
|
||||
if t == CL_MEM_OBJECT_IMAGE1D_BUFFER
|
||||
@@ -298,7 +305,7 @@ impl Device {
|
||||
|
||||
// Restrict supported formats with 1DBuffer images. This is an OpenCL CTS workaround.
|
||||
// See https://github.com/KhronosGroup/OpenCL-CTS/issues/1889
|
||||
let image1d_mask = fs[&CL_MEM_OBJECT_IMAGE1D];
|
||||
let image1d_mask = fs.get(&CL_MEM_OBJECT_IMAGE1D).copied().unwrap_or_default();
|
||||
if let Some(entry) = fs.get_mut(&CL_MEM_OBJECT_IMAGE1D_BUFFER) {
|
||||
*entry &= image1d_mask;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user