rusticl: correctly check global argument size
authorItalo Nicola <italonicola@collabora.com>
Thu, 6 Oct 2022 12:32:03 +0000 (12:32 +0000)
committerMarge Bot <emma+marge@anholt.net>
Sat, 15 Oct 2022 02:23:04 +0000 (02:23 +0000)
As the spec that is quoted in the comment says, if the argument is a
memory object, arg_size should be different than sizeof(cl_mem). The
previous verification only worked if the underlying type has the same
size as sizeof(cl_mem).

Signed-off-by: Italo Nicola <italonicola@collabora.com>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18985>

src/gallium/frontends/rusticl/api/kernel.rs

index 06cc13b..d635829 100644 (file)
@@ -240,6 +240,11 @@ pub fn set_kernel_arg(
                     return Err(CL_INVALID_ARG_SIZE);
                 }
             }
+            KernelArgType::MemGlobal => {
+                if arg_size != std::mem::size_of::<cl_mem>() {
+                    return Err(CL_INVALID_ARG_SIZE);
+                }
+            }
             _ => {
                 if arg.size != arg_size {
                     return Err(CL_INVALID_ARG_SIZE);