[Mesa-dev] [PATCH] r300g: implement GLSL disk shader caching

Dieter N├╝tzel Dieter at nuetzel-hh.de
Sat Jun 8 00:55:51 UTC 2019


Hello Rui,

do you have some numbers with/without shader caching enabled, handy?
I didn't have r300 hardware anylonger...

Thanks!

Dieter

Am 07.06.2019 13:19, schrieb rsalvaterra at gmail.com:
> From: Rui Salvaterra <rsalvaterra at gmail.com>
> 
> This implements GLSL disk shader caching for the R300-R500 series of 
> AMD GPUs.
> 
> Signed-off-by: Rui Salvaterra <rsalvaterra at gmail.com>
> ---
>  src/gallium/drivers/r300/r300_screen.c | 38 +++++++++++++++++++++++++-
>  src/gallium/drivers/r300/r300_screen.h |  3 ++
>  2 files changed, 40 insertions(+), 1 deletion(-)
> 
> diff --git a/src/gallium/drivers/r300/r300_screen.c
> b/src/gallium/drivers/r300/r300_screen.c
> index d26cf901a7b..b9df321de86 100644
> --- a/src/gallium/drivers/r300/r300_screen.c
> +++ b/src/gallium/drivers/r300/r300_screen.c
> @@ -80,11 +80,42 @@ static const char* chip_families[] = {
>      "ATI RV570"
>  };
> 
> +static const char* r300_get_family_name(struct r300_screen* 
> r300screen)
> +{
> +    return chip_families[r300screen->caps.family];
> +}
> +
>  static const char* r300_get_name(struct pipe_screen* pscreen)
>  {
>      struct r300_screen* r300screen = r300_screen(pscreen);
> 
> -    return chip_families[r300screen->caps.family];
> +    return r300_get_family_name(r300screen);
> +}
> +
> +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(r300_get_family_name(r300screen),
> +                                      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)
> @@ -745,6 +776,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 +828,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 +841,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 <stdio.h>
> @@ -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; */


More information about the mesa-dev mailing list