main: Add driver cache blob fields to gl_program
authorJordan Justen <jordan.l.justen@intel.com>
Fri, 13 Oct 2017 20:00:23 +0000 (13:00 -0700)
committerJordan Justen <jordan.l.justen@intel.com>
Wed, 1 Nov 2017 06:36:53 +0000 (23:36 -0700)
These fields can be used to optionally save off a driver blob with the
program metadata. For example, serialized nir, or tgsi.

v3:
 * Rename serialized_nir* to driver_cache_blob*. (Tim)
 * Free memory. (Jason)

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/mesa/main/mtypes.h
src/mesa/program/program.c

index 2802a0e3605bb57da908ab6860ce3d6ae428be2b..b7a46aed5349c0c7d91934a80f4f3029ef95868a 100644 (file)
@@ -2079,6 +2079,10 @@ struct gl_program
 
    struct nir_shader *nir;
 
+   /* Saved and restored with metadata. Freed with ralloc. */
+   void *driver_cache_blob;
+   size_t driver_cache_blob_size;
+
    bool is_arb_asm; /** Is this an ARB assembly-style program */
 
    /** Is this program written to on disk shader cache */
index 0defa012aee9f1680c3d6e853fb387f758d58fb0..faf5b7fa28accfba0354232369ccebb30680d147 100644 (file)
@@ -279,6 +279,10 @@ _mesa_delete_program(struct gl_context *ctx, struct gl_program *prog)
       ralloc_free(prog->sh.BindlessImages);
    }
 
+   if (prog->driver_cache_blob) {
+      ralloc_free(prog->driver_cache_blob);
+   }
+
    ralloc_free(prog);
 }