mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-21 05:58:22 +02:00
rusticl: validate input_programs binary type in clLinkProgram
According to the OpenCL 3.0 specification (Section 5.8.7), clLinkProgram must return CL_INVALID_OPERATION if the rules for devices containing compiled binaries or libraries as described in the input_programs argument are not followed. For each device, either ALL or NONE of the input programs must contain a compiled binary or library. Mixed cases are invalid. Suggested-by: LingMan <18294-LingMan@users.noreply.gitlab.freedesktop.org> Signed-off-by: jiajia Qian <jiajia.qian@nxp.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41980>
This commit is contained in:
parent
0a1df0a626
commit
4d92a069ff
1 changed files with 20 additions and 0 deletions
|
|
@ -474,6 +474,26 @@ pub fn link_program(
|
|||
return Err(CL_INVALID_OPERATION);
|
||||
}
|
||||
|
||||
// CL_INVALID_OPERATION if the rules for devices containing compiled binaries
|
||||
// or libraries as described in input_programs argument above are not followed.
|
||||
// For each device, either ALL or NONE of the input programs must contain a
|
||||
// compiled binary or library. Mixed cases are invalid.
|
||||
for device in &devices {
|
||||
let mut has_binary = input_programs.iter().map(|program| {
|
||||
matches!(
|
||||
program.bin_type(device),
|
||||
CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT | CL_PROGRAM_BINARY_TYPE_LIBRARY
|
||||
)
|
||||
});
|
||||
let all_equal = match has_binary.next() {
|
||||
Some(maybe_binary) => has_binary.all(|v| maybe_binary == v),
|
||||
None => true,
|
||||
};
|
||||
if !all_equal {
|
||||
return Err(CL_INVALID_OPERATION);
|
||||
}
|
||||
}
|
||||
|
||||
// SAFETY: options is a valid C String or NULL.
|
||||
let options = unsafe { CStr::from_ptr_or_empty(&options) };
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue