From dc47061e11fd62059ccde51ad64d6de44b582b2b Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Tue, 5 May 2026 17:58:31 +0200 Subject: [PATCH] rusticl/program: handle CL_INVALID_CONTEXT for clCompileProgram and clLinkProgram See https://github.com/KhronosGroup/OpenCL-Docs/pull/1453 Reviewed-by: Adam Jackson Part-of: --- src/gallium/frontends/rusticl/api/program.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/gallium/frontends/rusticl/api/program.rs b/src/gallium/frontends/rusticl/api/program.rs index baa4daf4074..c304e078a7b 100644 --- a/src/gallium/frontends/rusticl/api/program.rs +++ b/src/gallium/frontends/rusticl/api/program.rs @@ -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.