[Mesa-dev] [PATCH 40/40] r600/radeonsi: enable glsl/tgsi on-disk cache
Marek Olšák
maraeo at gmail.com
Fri Feb 10 11:25:21 UTC 2017
I don't see anything radeonsi-specific here. Is there any reason this
has to be in radeonsi?
Also, all pipe_screen functions must be thread-safe, so a mutex around
checking and setting disk_shader_cache should be used.
if _mesa_create_cache_version_string was in src/util, you wouldn't
have to pass it via the parameter.
Marek
On Tue, Feb 7, 2017 at 4:42 AM, Timothy Arceri <tarceri at itsqueeze.com> wrote:
> ---
> src/gallium/drivers/radeon/r600_pipe_common.c | 17 +++++++++++++++++
> src/gallium/drivers/radeon/r600_pipe_common.h | 2 ++
> src/gallium/include/pipe/p_screen.h | 3 +++
> src/mesa/state_tracker/st_context.c | 6 ++++++
> 4 files changed, 28 insertions(+)
>
> diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c
> index 95a6a48..d7d5362 100644
> --- a/src/gallium/drivers/radeon/r600_pipe_common.c
> +++ b/src/gallium/drivers/radeon/r600_pipe_common.c
> @@ -27,6 +27,7 @@
> #include "r600_pipe_common.h"
> #include "r600_cs.h"
> #include "tgsi/tgsi_parse.h"
> +#include "util/disk_cache.h"
> #include "util/list.h"
> #include "util/u_draw_quad.h"
> #include "util/u_memory.h"
> @@ -772,6 +773,20 @@ static const char* r600_get_chip_name(struct r600_common_screen *rscreen)
> }
> }
>
> +static struct disk_cache* r600_create_disk_cache(struct pipe_screen *pscreen,
> + const char *mesa_version)
> +{
> + struct r600_common_screen *rscreen = (struct r600_common_screen*)pscreen;
> +
> + if (rscreen->disk_shader_cache)
> + return rscreen->disk_shader_cache;
> +
> + struct disk_cache *cache = disk_cache_create(r600_get_chip_name(rscreen), mesa_version);
> + rscreen->disk_shader_cache = cache;
> +
> + return rscreen->disk_shader_cache;
> +}
> +
> static const char* r600_get_name(struct pipe_screen* pscreen)
> {
> struct r600_common_screen *rscreen = (struct r600_common_screen*)pscreen;
> @@ -1224,6 +1239,7 @@ bool r600_common_screen_init(struct r600_common_screen *rscreen,
> rscreen->info.drm_minor, rscreen->info.drm_patchlevel,
> kernel_version, llvm_string);
>
> + rscreen->b.create_disk_cache = r600_create_disk_cache;
> rscreen->b.get_name = r600_get_name;
> rscreen->b.get_vendor = r600_get_vendor;
> rscreen->b.get_device_vendor = r600_get_device_vendor;
> @@ -1314,6 +1330,7 @@ void r600_destroy_common_screen(struct r600_common_screen *rscreen)
> pipe_mutex_destroy(rscreen->gpu_load_mutex);
> pipe_mutex_destroy(rscreen->aux_context_lock);
> rscreen->aux_context->destroy(rscreen->aux_context);
> + disk_cache_destroy(rscreen->disk_shader_cache);
>
> slab_destroy_parent(&rscreen->pool_transfers);
>
> diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h
> index 6eff9aa..72c2df9 100644
> --- a/src/gallium/drivers/radeon/r600_pipe_common.h
> +++ b/src/gallium/drivers/radeon/r600_pipe_common.h
> @@ -400,6 +400,8 @@ struct r600_common_screen {
> bool has_cp_dma;
> bool has_streamout;
>
> + struct disk_cache *disk_shader_cache;
> +
> struct slab_parent_pool pool_transfers;
>
> /* Texture filter settings. */
> diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h
> index b6203f1..90f6c93 100644
> --- a/src/gallium/include/pipe/p_screen.h
> +++ b/src/gallium/include/pipe/p_screen.h
> @@ -318,6 +318,9 @@ struct pipe_screen {
> const void *(*get_compiler_options)(struct pipe_screen *screen,
> enum pipe_shader_ir ir,
> unsigned shader);
> +
> + struct disk_cache *(*create_disk_cache)(struct pipe_screen *screen,
> + const char *mesa_version);
> };
>
>
> diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
> index 5523734..658faba 100644
> --- a/src/mesa/state_tracker/st_context.c
> +++ b/src/mesa/state_tracker/st_context.c
> @@ -551,6 +551,12 @@ struct st_context *st_create_context(gl_api api, struct pipe_context *pipe,
> return NULL;
> }
>
> + if (pipe->screen->create_disk_cache) {
> + ctx->Cache =
> + pipe->screen->create_disk_cache(pipe->screen,
> + _mesa_create_cache_version_string());
> + }
> +
> st_init_driver_flags(&ctx->DriverFlags);
>
> /* XXX: need a capability bit in gallium to query if the pipe
> --
> 2.9.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list