From 3052498f1ef7e1eabb62d8ccf8ed268290c19772 Mon Sep 17 00:00:00 2001 From: Rui Salvaterra Date: Thu, 6 Jun 2019 20:38:08 +0100 Subject: [PATCH] r300g: implement disk shader cache This implements glsl disk shader caching for the r300-r500 series of amd gpus. Signed-off-by: Rui Salvaterra --- src/gallium/drivers/r300/r300_screen.c | 31 ++++++++++++++++++++++++++ src/gallium/drivers/r300/r300_screen.h | 3 +++ 2 files changed, 34 insertions(+) diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index d26cf901a7b..fe96f222cfe 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -87,6 +87,32 @@ static const char* r300_get_name(struct pipe_screen* pscreen) return chip_families[r300screen->caps.family]; } +static void r300_disk_cache_create(struct r300_screen* r300screen) +{ + struct mesa_sha1 ctx; + unsigned char sha1[20]; + char cache_id[20 * 2 + 1]; + + _mesa_sha1_init(&ctx); + if (!disk_cache_get_function_identifier(r300_disk_cache_create, + &ctx)) + return; + + _mesa_sha1_final(&ctx, sha1); + disk_cache_format_hex_id(cache_id, sha1, 20 * 2); + + r300screen->disk_shader_cache = + disk_cache_create(chip_families[r300screen->caps.family], + cache_id, + r300screen->debug); +} + +static struct disk_cache* r300_get_disk_shader_cache(struct pipe_screen* pscreen) +{ + struct r300_screen* r300screen = r300_screen(pscreen); + return r300screen->disk_shader_cache; +} + static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param) { struct r300_screen* r300screen = r300_screen(pscreen); @@ -745,6 +771,8 @@ static void r300_destroy_screen(struct pipe_screen* pscreen) mtx_destroy(&r300screen->cmask_mutex); slab_destroy_parent(&r300screen->pool_transfers); + disk_cache_destroy(r300screen->disk_shader_cache); + if (rws) rws->destroy(rws); @@ -795,6 +823,7 @@ struct pipe_screen* r300_screen_create(struct radeon_winsys *rws, r300screen->screen.get_name = r300_get_name; r300screen->screen.get_vendor = r300_get_vendor; r300screen->screen.get_device_vendor = r300_get_device_vendor; + r300screen->screen.get_disk_shader_cache = r300_get_disk_shader_cache; r300screen->screen.get_param = r300_get_param; r300screen->screen.get_shader_param = r300_get_shader_param; r300screen->screen.get_paramf = r300_get_paramf; @@ -807,6 +836,8 @@ struct pipe_screen* r300_screen_create(struct radeon_winsys *rws, r300_init_screen_resource_functions(r300screen); + r300_disk_cache_create(r300screen); + slab_create_parent(&r300screen->pool_transfers, sizeof(struct pipe_transfer), 64); (void) mtx_init(&r300screen->cmask_mutex, mtx_plain); diff --git a/src/gallium/drivers/r300/r300_screen.h b/src/gallium/drivers/r300/r300_screen.h index 952dc341ab7..b28de008304 100644 --- a/src/gallium/drivers/r300/r300_screen.h +++ b/src/gallium/drivers/r300/r300_screen.h @@ -27,6 +27,7 @@ #include "r300_chipset.h" #include "radeon/radeon_winsys.h" #include "pipe/p_screen.h" +#include "util/disk_cache.h" #include "util/slab.h" #include "os/os_thread.h" #include @@ -44,6 +45,8 @@ struct r300_screen { /** Combination of DBG_xxx flags */ unsigned debug; + struct disk_cache *disk_shader_cache; + struct slab_parent_pool pool_transfers; /* The MSAA texture with CMASK access; */ -- 2.21.0