[Mesa-dev] [PATCH 4/8] util/disk_cache: make disk_cache_put() compatible with u_queue

Grazvydas Ignotas notasas at gmail.com
Fri Mar 10 13:06:42 UTC 2017


On Fri, Mar 10, 2017 at 4:28 AM, Timothy Arceri <tarceri at itsqueeze.com> wrote:
> ---
>  src/compiler/glsl/shader_cache.cpp              |  5 ++++-
>  src/compiler/glsl/tests/cache_test.c            | 29 ++++++++++++++++++++-----
>  src/gallium/drivers/radeonsi/si_state_shaders.c |  9 ++++++--
>  src/mesa/state_tracker/st_shader_cache.c        |  5 ++++-
>  src/util/disk_cache.c                           | 27 +++++++++++++----------
>  src/util/disk_cache.h                           |  7 ++----
>  6 files changed, 55 insertions(+), 27 deletions(-)
>
> diff --git a/src/compiler/glsl/shader_cache.cpp b/src/compiler/glsl/shader_cache.cpp
> index 6e2c527..1865e96 100644
> --- a/src/compiler/glsl/shader_cache.cpp
> +++ b/src/compiler/glsl/shader_cache.cpp
> @@ -1269,21 +1269,24 @@ shader_cache_write_program_metadata(struct gl_context *ctx,
>
>     char sha1_buf[41];
>     for (unsigned i = 0; i < prog->NumShaders; i++) {
>        disk_cache_put_key(cache, prog->Shaders[i]->sha1);
>        if (ctx->_Shader->Flags & GLSL_CACHE_INFO) {
>           fprintf(stderr, "marking shader: %s\n",
>                   _mesa_sha1_format(sha1_buf, prog->Shaders[i]->sha1));
>        }
>     }
>
> -   disk_cache_put(cache, prog->data->sha1, metadata->data, metadata->size);
> +   struct disk_cache_put_job *dc_job =
> +      disk_cache_create_put_job(cache, prog->data->sha1, metadata->data,
> +                                metadata->size, metadata);
> +   disk_cache_put(dc_job, 0);

I don't think open coding every callsite like this is a good idea, it
will make the maintenance of this code hard. I suggest making a new
disk_cache_put() (same prototype) that takes care of creating the job
itself, and then call the current renamed ..._put() with the job arg
by itself (same for util_queue_* stuff added by later patches). Then
you don't have to expose struct disk_cache_put_job (and later struct
disk_cache itself) in the headers, those things are disk_cache
implementation details really.

GraÅžvydas


More information about the mesa-dev mailing list