Mesa (master): st/mesa: don' t mark the program as in cache_fallback when there is cache miss

Timothy Arceri tarceri at kemper.freedesktop.org
Fri May 19 22:36:04 UTC 2017


Module: Mesa
Branch: master
Commit: 80e643345ed0d8d3263b4ee23dd2998f0da170a8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=80e643345ed0d8d3263b4ee23dd2998f0da170a8

Author: Timothy Arceri <tarceri at itsqueeze.com>
Date:   Thu May 18 15:10:08 2017 +1000

st/mesa: don't mark the program as in cache_fallback when there is cache miss

When we fallback currently the gl_program objects are re-allocated.

This is likely to change when the i965 cache lands, but for now
this fixes a crash when using MESA_GLSL=cache_fb. This env var
simulates the fallback path taken when a tgsi cache item doesn't
exist due to being evicted previously or some kind of error.

Unlike i965 we are always falling back at link time so it's safe to
just re-allocate everything. We will be unnecessarily freeing and
re-allocate a bunch of things here but it's probably not a huge deal,
and can be changed when the i965 code lands.

Fixes: 0e9991f957e2 ("glsl: don't reference shader prog data during cache fallback")

Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>

---

 src/compiler/glsl/shader_cache.cpp       | 2 +-
 src/mesa/main/mtypes.h                   | 7 +++++++
 src/mesa/state_tracker/st_shader_cache.c | 2 +-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/compiler/glsl/shader_cache.cpp b/src/compiler/glsl/shader_cache.cpp
index 800d3a2913..dd56501258 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -1292,7 +1292,7 @@ shader_cache_read_program_metadata(struct gl_context *ctx,
       return false;
 
    struct disk_cache *cache = ctx->Cache;
-   if (!cache || prog->data->cache_fallback)
+   if (!cache || prog->data->cache_fallback || prog->data->skip_cache)
       return false;
 
    /* Include bindings when creating sha1. These bindings change the resulting
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index d060f8f7d3..d47c428936 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2814,6 +2814,13 @@ struct gl_shader_program_data
 
    bool cache_fallback;
 
+   /* TODO: This used by Gallium drivers to skip the cache on tgsi fallback.
+    * All structures (gl_program, uniform storage, etc) will get recreated
+    * even though we have already loaded them from cache. Once the i965 cache
+    * lands we should switch to using the cache_fallback support.
+    */
+   bool skip_cache;
+
    /** List of all active resources after linking. */
    struct gl_program_resource *ProgramResourceList;
    unsigned NumProgramResourceList;
diff --git a/src/mesa/state_tracker/st_shader_cache.c b/src/mesa/state_tracker/st_shader_cache.c
index 45438e56bd..31c3430aa4 100644
--- a/src/mesa/state_tracker/st_shader_cache.c
+++ b/src/mesa/state_tracker/st_shader_cache.c
@@ -391,7 +391,7 @@ fallback_recompile:
       _mesa_glsl_compile_shader(ctx, prog->Shaders[i], false, false, true);
    }
 
-   prog->data->cache_fallback = true;
+   prog->data->skip_cache = true;
    _mesa_glsl_link_shader(ctx, prog);
 
    return true;




More information about the mesa-commit mailing list