rusticl/program: handle CL_INVALID_CONTEXT for clCompileProgram and clLinkProgram

See https://github.com/KhronosGroup/OpenCL-Docs/pull/1453

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41358>
This commit is contained in:
Karol Herbst 2026-05-05 17:58:31 +02:00 committed by Marge Bot
parent 9e673e5773
commit dc47061e11

View file

@ -384,6 +384,12 @@ fn compile_program(
return Err(CL_INVALID_OPERATION);
}
// CL_INVALID_CONTEXT if the context associated with program and programs in
// input_headers are not the same.
if header.context != program.context {
return Err(CL_INVALID_CONTEXT);
}
headers.push(HeaderProgram {
// SAFETY: The OpenCL spec requires that there be a
// one-to-one correspondence between input_headers and
@ -448,6 +454,15 @@ pub fn link_program(
return Err(CL_INVALID_DEVICE);
}
// CL_INVALID_CONTEXT if the context associated with programs in input_programs is not the same
// as context.
if input_programs
.iter()
.any(|program| program.context != context)
{
return Err(CL_INVALID_CONTEXT);
}
// CL_INVALID_OPERATION if the compilation or build of a program executable for any of the
// devices listed in device_list by a previous call to clCompileProgram or clBuildProgram for
// program has not completed.