gallium/util: let shader live cache users know if a hit occured
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Wed, 1 Apr 2020 08:47:14 +0000 (10:47 +0200)
committerPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Thu, 2 Apr 2020 06:31:37 +0000 (08:31 +0200)
This will be used in next commit.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4355>

src/gallium/auxiliary/util/u_live_shader_cache.c
src/gallium/auxiliary/util/u_live_shader_cache.h

index 9c59b5fd3cfb5e529d1c7083ce5aa347c4f57b22..a32c3748257b8788e250f6975cdddd4061dd93e0 100644 (file)
@@ -71,7 +71,8 @@ util_live_shader_cache_deinit(struct util_live_shader_cache *cache)
 void *
 util_live_shader_cache_get(struct pipe_context *ctx,
                            struct util_live_shader_cache *cache,
-                           const struct pipe_shader_state *state)
+                           const struct pipe_shader_state *state,
+                           bool* cache_hit)
 {
    struct blob blob = {0};
    unsigned ir_size;
@@ -124,6 +125,9 @@ util_live_shader_cache_get(struct pipe_context *ctx,
    }
    simple_mtx_unlock(&cache->lock);
 
+   if (cache_hit)
+      *cache_hit = (shader != NULL);
+
    /* Return if the shader already exists. */
    if (shader)
       return shader;
index 5d8cfc1bafc26aed615515efe164ddda9e7eb436..b6e6e32c76ea629d5ffd2c784cfc40281583c1e1 100644 (file)
@@ -80,7 +80,8 @@ util_live_shader_cache_deinit(struct util_live_shader_cache *cache);
 void *
 util_live_shader_cache_get(struct pipe_context *ctx,
                            struct util_live_shader_cache *cache,
-                           const struct pipe_shader_state *state);
+                           const struct pipe_shader_state *state,
+                           bool* cache_hit);
 
 void
 util_shader_reference(struct pipe_context *ctx,