diff options
author | Karol Herbst <kherbst@redhat.com> | 2024-08-07 13:37:00 +0200 |
---|---|---|
committer | Eric Engestrom <eric@engestrom.ch> | 2024-08-16 17:31:20 +0200 |
commit | 042c23cba1db3fc21597e04e2394eb559f738199 (patch) | |
tree | a1aedaaf2b68f877c63ce17c56c93c8e51566a60 /src/gallium | |
parent | 66aa172910c41439a3d861a7036f96129fef4fd0 (diff) |
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: 20c90fed5a0 ("rusticl: added")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30655>
(cherry picked from commit 5d0c870c005da77a3ff03eb97709988f823cf559)
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/frontends/rusticl/api/memory.rs | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/gallium/frontends/rusticl/api/memory.rs b/src/gallium/frontends/rusticl/api/memory.rs index 6bf170ce728..80911d88e76 100644 --- a/src/gallium/frontends/rusticl/api/memory.rs +++ b/src/gallium/frontends/rusticl/api/memory.rs @@ -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); |