Module: Mesa
Branch: main
Commit: 07597596588973cea5bfe064ecc4017dd24357be
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=07597596588973cea5bfe064ecc4017dd24357be

Author: Karol Herbst <[email protected]>
Date:   Sun Jun 25 00:41:00 2023 +0200

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 <[email protected]>
Reviewed-by: Nora Allen <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23847>

---

 src/gallium/frontends/rusticl/core/program.rs | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/gallium/frontends/rusticl/core/program.rs 
b/src/gallium/frontends/rusticl/core/program.rs
index 2df9d9ab574..72840bd0765 100644
--- a/src/gallium/frontends/rusticl/core/program.rs
+++ b/src/gallium/frontends/rusticl/core/program.rs
@@ -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(_))
     }

Reply via email to