rusticl/kernel: implement CL_INVALID_ARG_VALUE for image args in clSetKernelArg

Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35305>
(cherry picked from commit 868ae6a262)
This commit is contained in:
Karol Herbst 2025-06-03 09:08:41 +02:00 committed by Eric Engestrom
parent 250f423546
commit ef0df70f62
2 changed files with 15 additions and 2 deletions

View file

@ -674,7 +674,7 @@
"description": "rusticl/kernel: implement CL_INVALID_ARG_VALUE for image args in clSetKernelArg",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -437,6 +437,20 @@ fn set_kernel_arg(
KernelArgType::Image | KernelArgType::RWImage | KernelArgType::Texture => {
let img: *const cl_mem = arg_value.cast();
let img = Image::arc_from_raw(*img)?;
// CL_INVALID_ARG_VALUE if the argument is an image declared with the read_only
// qualifier and arg_value refers to an image object created with cl_mem_flags
// of CL_MEM_WRITE_ONLY or if the image argument is declared with the write_only
// qualifier and arg_value refers to an image object created with cl_mem_flags
// of CL_MEM_READ_ONLY.
if arg.kind == KernelArgType::Texture
&& bit_check(img.flags, CL_MEM_WRITE_ONLY)
|| arg.kind == KernelArgType::Image
&& bit_check(img.flags, CL_MEM_READ_ONLY)
{
return Err(CL_INVALID_ARG_VALUE);
}
KernelArgValue::Image(Arc::downgrade(&img))
}
KernelArgType::Sampler => {
@ -452,7 +466,6 @@ fn set_kernel_arg(
}
//• CL_INVALID_DEVICE_QUEUE for an argument declared to be of type queue_t when the specified arg_value is not a valid device queue object. This error code is missing before version 2.0.
//• CL_INVALID_ARG_VALUE if the argument is an image declared with the read_only qualifier and arg_value refers to an image object created with cl_mem_flags of CL_MEM_WRITE_ONLY or if the image argument is declared with the write_only qualifier and arg_value refers to an image object created with cl_mem_flags of CL_MEM_READ_ONLY.
//• CL_MAX_SIZE_RESTRICTION_EXCEEDED if the size in bytes of the memory object (if the argument is a memory object) or arg_size (if the argument is declared with local qualifier) exceeds a language- specified maximum size restriction for this argument, such as the MaxByteOffset SPIR-V decoration. This error code is missing before version 2.2.
}