[Mesa-dev] [PATCH 16/77] glsl: skip shader cache unless program is made up of vs or fs

Timothy Arceri timothy.arceri at collabora.com
Mon Oct 3 06:04:35 UTC 2016


---
 src/compiler/glsl/shader_cache.cpp | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/compiler/glsl/shader_cache.cpp b/src/compiler/glsl/shader_cache.cpp
index 529ec71..2fb8330 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -53,6 +53,13 @@ extern "C" {
 }
 
 static void
+compile_shaders(struct gl_context *ctx, struct gl_shader_program *prog) {
+   for (unsigned i = 0; i < prog->NumShaders; i++) {
+      _mesa_glsl_compile_shader(ctx, prog->Shaders[i], false, false, true);
+   }
+}
+
+static void
 encode_type_to_blob(struct blob *blob, const glsl_type *type)
 {
    uint32_t encoding;
@@ -479,6 +486,13 @@ shader_cache_read_program_metadata(struct gl_context *ctx,
    if (!cache)
       return false;
 
+   for (unsigned i = 0; i < prog->NumShaders; i++) {
+      if (prog->Shaders[i]->Stage != MESA_SHADER_VERTEX &&
+          prog->Shaders[i]->Stage != MESA_SHADER_FRAGMENT) {
+         compile_shaders(ctx, prog);
+         return false;
+      }
+   }
 
    /* Include bindings when creating sha1. These bindings change the resulting
     * binary so they are just as important as the shader source.
-- 
2.7.4



More information about the mesa-dev mailing list