From 814ec368d5bd6f5aea2bfbc5c1b232837aaf0d69 Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Thu, 25 Jan 2018 12:17:57 +1100 Subject: [PATCH] glsl: free driver_cache_blob once program written to cache --- src/compiler/glsl/shader_cache.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/compiler/glsl/shader_cache.cpp b/src/compiler/glsl/shader_cache.cpp index 5e1682b351..f4a6128b6a 100644 --- a/src/compiler/glsl/shader_cache.cpp +++ b/src/compiler/glsl/shader_cache.cpp @@ -104,6 +104,23 @@ shader_cache_write_program_metadata(struct gl_context *ctx, serialize_glsl_program(&metadata, ctx, prog); + /* Now that the program has been written to the cache free any serialised + * blob that may have been created by the drivers backend. If we don't do + * this it can interfere with ARB_get_program_binary. + */ + for (unsigned stage = 0; stage < MESA_SHADER_STAGES; stage++) { + if (!prog->_LinkedShaders[stage]) + continue; + + struct gl_program *glprog = prog->_LinkedShaders[stage]->Program; + if (glprog->driver_cache_blob == NULL) + continue; + + ralloc_free(glprog->driver_cache_blob); + glprog->driver_cache_blob = NULL; + glprog->driver_cache_blob_size = 0; + } + struct cache_item_metadata cache_item_metadata; cache_item_metadata.type = CACHE_ITEM_TYPE_GLSL; cache_item_metadata.keys = -- 2.14.3