[Mesa-dev] [PATCH 19/68] glsl: skip shader cache unless program is a vs+fs

Timothy Arceri timothy.arceri at collabora.com
Wed Jun 1 06:23:00 UTC 2016


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

diff --git a/src/compiler/glsl/shader_cache.cpp b/src/compiler/glsl/shader_cache.cpp
index 74a4428..8b50ff6 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -52,6 +52,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;
@@ -399,7 +406,10 @@ shader_cache_write_program_metadata(struct gl_context *ctx,
     */
    if (!prog->_LinkedShaders[MESA_SHADER_VERTEX] ||
        !prog->_LinkedShaders[MESA_SHADER_FRAGMENT] ||
-       prog->_LinkedShaders[MESA_SHADER_GEOMETRY])
+       prog->_LinkedShaders[MESA_SHADER_GEOMETRY] ||
+       prog->_LinkedShaders[MESA_SHADER_TESS_EVAL] ||
+       prog->_LinkedShaders[MESA_SHADER_TESS_CTRL] ||
+       prog->_LinkedShaders[MESA_SHADER_COMPUTE])
       return;
 
    metadata = blob_create(NULL);
@@ -446,6 +456,14 @@ shader_cache_read_program_metadata(struct gl_context *ctx,
       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;
+      }
+   }
+
+   for (unsigned i = 0; i < prog->NumShaders; i++) {
       if (prog->Shaders[i]->Source == NULL)
          return false;
 
-- 
2.5.5



More information about the mesa-dev mailing list