mesa: Add disk shader cache driver blob callback
authorJordan Justen <jordan.l.justen@intel.com>
Mon, 9 Apr 2018 00:56:34 +0000 (17:56 -0700)
committerJordan Justen <jordan.l.justen@intel.com>
Tue, 10 Jul 2018 06:02:28 +0000 (23:02 -0700)
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/compiler/glsl/shader_cache.cpp
src/mesa/main/dd.h

index 042f3a60f5b33af317de1403808126337b73d38b..31d0aa629665c8a757642350f39d6d0f094fa763 100644 (file)
@@ -102,6 +102,14 @@ shader_cache_write_program_metadata(struct gl_context *ctx,
    struct blob metadata;
    blob_init(&metadata);
 
+   if (ctx->Driver.ShaderCacheSerializeDriverBlob) {
+      for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
+         struct gl_linked_shader *sh = prog->_LinkedShaders[i];
+         if (sh)
+            ctx->Driver.ShaderCacheSerializeDriverBlob(ctx, sh->Program);
+      }
+   }
+
    serialize_glsl_program(&metadata, ctx, prog);
 
    struct cache_item_metadata cache_item_metadata;
index 1b048d3ff8e8b19afa2f230b9934925de8bf3822..7081d5867000523be5c1cd82763da872ae9ae2fe 100644 (file)
@@ -1282,6 +1282,21 @@ struct dd_function_table {
                                 struct gl_semaphore_object *semObj,
                                 int fd);
    /*@}*/
+
+   /**
+    * \name Disk shader cache functions
+    */
+   /*@{*/
+   /**
+    * Called to initialize gl_program::driver_cache_blob (and size) with a
+    * ralloc allocated buffer.
+    *
+    * This buffer will be saved and restored as part of the gl_program
+    * serialization and deserialization.
+    */
+   void (*ShaderCacheSerializeDriverBlob)(struct gl_context *ctx,
+                                          struct gl_program *prog);
+   /*@}*/
 };