[Mesa-dev] [PATCH 4/4] r600/radeonsi: enable glsl/tgsi on-disk cache
Timothy Arceri
tarceri at itsqueeze.com
Mon Feb 20 00:15:35 UTC 2017
---
src/gallium/drivers/r600/r600_pipe.c | 19 +++++++++++++++++++
src/gallium/drivers/radeon/r600_pipe_common.c | 8 +++++++-
src/gallium/drivers/radeon/r600_pipe_common.h | 5 +++++
src/gallium/drivers/radeonsi/si_pipe.c | 19 +++++++++++++++++++
src/mesa/state_tracker/st_context.c | 2 ++
5 files changed, 52 insertions(+), 1 deletion(-)
diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c
index 1803c26..162ebe8 100644
--- a/src/gallium/drivers/r600/r600_pipe.c
+++ b/src/gallium/drivers/r600/r600_pipe.c
@@ -601,6 +601,7 @@ static void r600_destroy_screen(struct pipe_screen* pscreen)
compute_memory_pool_delete(rscreen->global_pool);
}
+ disk_cache_destroy(rscreen->b.disk_shader_cache);
r600_destroy_common_screen(&rscreen->b);
}
@@ -614,6 +615,21 @@ static struct pipe_resource *r600_resource_create(struct pipe_screen *screen,
return r600_resource_create_common(screen, templ);
}
+static void r600_disk_cache_create(struct r600_screen *rscreen)
+{
+ uint32_t mesa_timestamp;
+ if (disk_cache_get_function_timestamp(r600_disk_cache_create,
+ &mesa_timestamp)) {
+ char *timestamp_str;
+ if (asprintf(×tamp_str, "%u", mesa_timestamp) != -1) {
+ rscreen->b.disk_shader_cache =
+ disk_cache_create(r600_get_chip_name(&rscreen->b),
+ timestamp_str);
+ free(timestamp_str);
+ }
+ }
+}
+
struct pipe_screen *r600_screen_create(struct radeon_winsys *ws)
{
struct r600_screen *rscreen = CALLOC_STRUCT(r600_screen);
@@ -625,6 +641,7 @@ struct pipe_screen *r600_screen_create(struct radeon_winsys *ws)
/* Set functions first. */
rscreen->b.b.context_create = r600_create_context;
rscreen->b.b.destroy = r600_destroy_screen;
+ rscreen->b.b.get_disk_shader_cache = r600_get_disk_shader_cache;
rscreen->b.b.get_param = r600_get_param;
rscreen->b.b.get_shader_param = r600_get_shader_param;
rscreen->b.b.resource_create = r600_resource_create;
@@ -634,6 +651,8 @@ struct pipe_screen *r600_screen_create(struct radeon_winsys *ws)
return NULL;
}
+ r600_disk_cache_create(rscreen);
+
if (rscreen->b.info.chip_class >= EVERGREEN) {
rscreen->b.b.is_format_supported = evergreen_is_format_supported;
} else {
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c
index 1781584..a0ebcdd 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.c
+++ b/src/gallium/drivers/radeon/r600_pipe_common.c
@@ -729,7 +729,7 @@ static const char* r600_get_device_vendor(struct pipe_screen* pscreen)
return "AMD";
}
-static const char* r600_get_chip_name(struct r600_common_screen *rscreen)
+const char* r600_get_chip_name(struct r600_common_screen *rscreen)
{
switch (rscreen->info.family) {
case CHIP_R600: return "AMD R600";
@@ -779,6 +779,12 @@ static const char* r600_get_chip_name(struct r600_common_screen *rscreen)
}
}
+struct disk_cache *r600_get_disk_shader_cache(struct pipe_screen *pscreen)
+{
+ struct r600_common_screen *rscreen = (struct r600_common_screen*)pscreen;
+ 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;
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h
index e8dbf5d..120bceb 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.h
+++ b/src/gallium/drivers/radeon/r600_pipe_common.h
@@ -36,6 +36,7 @@
#include "radeon/radeon_winsys.h"
+#include "util/disk_cache.h"
#include "util/u_blitter.h"
#include "util/list.h"
#include "util/u_range.h"
@@ -404,6 +405,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. */
@@ -768,6 +771,8 @@ void radeon_save_cs(struct radeon_winsys *ws, struct radeon_winsys_cs *cs,
struct radeon_saved_cs *saved);
void radeon_clear_saved_cs(struct radeon_saved_cs *saved);
bool r600_check_device_reset(struct r600_common_context *rctx);
+const char* r600_get_chip_name(struct r600_common_screen *rscreen);
+struct disk_cache *r600_get_disk_shader_cache(struct pipe_screen *screen);
/* r600_gpu_load.c */
void r600_gpu_load_kill_thread(struct r600_common_screen *rscreen);
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
index 843c6b3..da45e51 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -714,6 +714,7 @@ static void si_destroy_screen(struct pipe_screen* pscreen)
}
}
pipe_mutex_destroy(sscreen->shader_parts_mutex);
+ disk_cache_destroy(sscreen->b.disk_shader_cache);
si_destroy_shader_cache(sscreen);
r600_destroy_common_screen(&sscreen->b);
}
@@ -778,6 +779,21 @@ static void si_handle_env_var_force_family(struct si_screen *sscreen)
exit(1);
}
+static void si_disk_cache_create(struct si_screen *sscreen)
+{
+ uint32_t mesa_timestamp, llvm_timestamp;
+ if (disk_cache_get_function_timestamp(si_disk_cache_create, &mesa_timestamp) &&
+ disk_cache_get_function_timestamp(LLVMInitializeAMDGPUTargetInfo, &llvm_timestamp)) {
+ char *timestamp_str;
+ if (asprintf(×tamp_str, "%u_%u", mesa_timestamp, llvm_timestamp) != -1) {
+ sscreen->b.disk_shader_cache =
+ disk_cache_create(r600_get_chip_name(&sscreen->b),
+ timestamp_str);
+ free(timestamp_str);
+ }
+ }
+}
+
struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws)
{
struct si_screen *sscreen = CALLOC_STRUCT(si_screen);
@@ -790,6 +806,7 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws)
/* Set functions first. */
sscreen->b.b.context_create = si_create_context;
sscreen->b.b.destroy = si_destroy_screen;
+ sscreen->b.b.get_disk_shader_cache = r600_get_disk_shader_cache;
sscreen->b.b.get_param = si_get_param;
sscreen->b.b.get_shader_param = si_get_shader_param;
sscreen->b.b.resource_create = r600_resource_create_common;
@@ -803,6 +820,8 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws)
return NULL;
}
+ si_disk_cache_create(sscreen);
+
si_handle_env_var_force_family(sscreen);
if (!debug_get_bool_option("RADEON_DISABLE_PERFCOUNTERS", false))
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index f4ad6d8..153f01c 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -538,6 +538,8 @@ struct st_context *st_create_context(gl_api api, struct pipe_context *pipe,
return NULL;
}
+ ctx->Cache = pipe->screen->get_disk_shader_cache(pipe->screen);
+
st_init_driver_flags(&ctx->DriverFlags);
/* XXX: need a capability bit in gallium to query if the pipe
--
2.9.3
More information about the mesa-dev
mailing list