rusticl/mem: do not check against image base alignment for 1Dbuffer images

The CL cap in question is only valid for 2D images created from buffer.

Fixes: 20c90fed5a ("rusticl: added")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30655>
This commit is contained in:
Karol Herbst 2024-08-07 13:37:00 +02:00 committed by Marge Bot
parent cc2dbb8ea5
commit 5d0c870c00

View file

@ -635,6 +635,25 @@ fn validate_buffer(
if desc.image_row_pitch * desc.image_height > mem.size {
return Err(err);
}
// If the buffer object specified by mem_object was created with
// CL_MEM_USE_HOST_PTR, the host_ptr specified to clCreateBuffer or
// clCreateBufferWithProperties must be aligned to the maximum of the
// CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT value for all devices in the
// context associated with the buffer specified by mem_object that support
// images.
if mem.flags & CL_MEM_USE_HOST_PTR as cl_mem_flags != 0 {
for dev in &mem.context.devs {
// CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT is only relevant for 2D
// images created from a buffer object.
let addr_alignment = dev.image_base_address_alignment();
if addr_alignment == 0 {
return Err(CL_INVALID_OPERATION);
} else if !is_alligned(host_ptr, addr_alignment as usize) {
return Err(err);
}
}
}
}
_ => return Err(err),
}
@ -694,21 +713,6 @@ fn validate_buffer(
_ => return Err(err),
}
// If the buffer object specified by mem_object was created with CL_MEM_USE_HOST_PTR, the
// host_ptr specified to clCreateBuffer or clCreateBufferWithProperties must be aligned to
// the maximum of the CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT value for all devices in the
// context associated with the buffer specified by mem_object that support images.
if mem.flags & CL_MEM_USE_HOST_PTR as cl_mem_flags != 0 {
for dev in &mem.context.devs {
let addr_alignment = dev.image_base_address_alignment();
if addr_alignment == 0 {
return Err(CL_INVALID_OPERATION);
} else if !is_alligned(host_ptr, addr_alignment as usize) {
return Err(err);
}
}
}
validate_matching_buffer_flags(mem, flags)?;
flags = inherit_mem_flags(flags, mem);