From 868ae6a2624e88acb4f7a5ce7e3738ba0b3bad22 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Tue, 3 Jun 2025 09:08:41 +0200 Subject: [PATCH] rusticl/kernel: implement CL_INVALID_ARG_VALUE for image args in clSetKernelArg Cc: mesa-stable Part-of: --- src/gallium/frontends/rusticl/api/kernel.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/gallium/frontends/rusticl/api/kernel.rs b/src/gallium/frontends/rusticl/api/kernel.rs index e4dfa94a5aa..cc772ef021e 100644 --- a/src/gallium/frontends/rusticl/api/kernel.rs +++ b/src/gallium/frontends/rusticl/api/kernel.rs @@ -439,6 +439,19 @@ fn set_kernel_arg( { 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 if !arg.dead => { @@ -463,7 +476,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. }