rusticl/program: skip linking compiled binaries

Applications can do their own caching, but are in any case required to
properly "compiler" the binaries via clBuildProgram or clCompileProgram +
clLinkPrograms.

In any case, there is no point building something if we already have the
result.

Signed-off-by: Karol Herbst <git@karolherbst.de>
Reviewed-by: Nora Allen <blackcatgames@protonmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23847>
This commit is contained in:
Karol Herbst 2023-06-25 00:41:00 +02:00
parent 18f1087a21
commit 0759759658

View file

@ -525,6 +525,16 @@ impl Program {
}
let mut d = info.dev_build_mut(dev);
// skip compilation if we already have the right thing.
if self.is_bin() {
if d.bin_type == CL_PROGRAM_BINARY_TYPE_EXECUTABLE && !lib
|| d.bin_type == CL_PROGRAM_BINARY_TYPE_LIBRARY && lib
{
return true;
}
}
let spirvs = [d.spirv.as_ref().unwrap()];
let (spirv, log) = spirv::SPIRVBin::link(&spirvs, lib);
@ -690,6 +700,10 @@ impl Program {
})
}
pub fn is_bin(&self) -> bool {
matches!(self.src, ProgramSourceType::Binary)
}
pub fn is_il(&self) -> bool {
matches!(self.src, ProgramSourceType::Il(_))
}