[Mesa-dev] [PATCH] etnaviv: enable glsl/tgsi on-disk cache
Emil Velikov
emil.l.velikov at gmail.com
Tue Feb 20 19:10:06 UTC 2018
On 20 February 2018 at 18:36, Christian Gmeiner
<christian.gmeiner at gmail.com> wrote:
> Signed-off-by: Christian Gmeiner <christian.gmeiner at gmail.com>
> ---
> src/gallium/drivers/etnaviv/etnaviv_screen.c | 36 ++++++++++++++++++++++++++++
> src/gallium/drivers/etnaviv/etnaviv_screen.h | 2 ++
> 2 files changed, 38 insertions(+)
>
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c b/src/gallium/drivers/etnaviv/etnaviv_screen.c
> index 3dd628bd9b..361745214c 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
> @@ -79,6 +79,8 @@ etna_screen_destroy(struct pipe_screen *pscreen)
> {
> struct etna_screen *screen = etna_screen(pscreen);
>
> + disk_cache_destroy(screen->disk_shader_cache);
> +
> if (screen->pipe)
> etna_pipe_del(screen->pipe);
>
> @@ -94,6 +96,36 @@ etna_screen_destroy(struct pipe_screen *pscreen)
> FREE(screen);
> }
>
> +static void etna_disk_cache_create(struct etna_screen *screen)
> +{
> + uint32_t mesa_timestamp;
> +
> + if (disk_cache_get_function_timestamp(etna_disk_cache_create,
> + &mesa_timestamp)) {
> + char *timestamp_str;
> + int res = -1;
> +
> + res = asprintf(×tamp_str, "%u", mesa_timestamp);
> + if (res != -1) {
> + char name[128];
> +
> + util_snprintf(name, sizeof(name), "gc%x_%04x", screen->model,
> + screen->revision);
> +
> + screen->disk_shader_cache = disk_cache_create(name, timestamp_str, 0);
> + free(timestamp_str);
Fly-by comment:
I wish we had something like systemd's DECIMAL_STR_MAX/DECIMAL_STR_WIDTH macros.
Allocating/freeing <16 bytes of memory is plain silly.
-Emil
More information about the etnaviv
mailing list