[Mesa-dev] [PATCH 32/32] r600/radeonsi: enable glsl/tgsi on-disk cache
Timothy Arceri
tarceri at itsqueeze.com
Tue Feb 14 00:52:45 UTC 2017
---
src/gallium/drivers/r600/r600_pipe.c | 10 ++++++++++
src/gallium/drivers/radeon/r600_pipe_common.c | 2 +-
src/gallium/drivers/radeon/r600_pipe_common.h | 1 +
src/gallium/drivers/radeonsi/si_pipe.c | 11 +++++++++++
src/gallium/include/pipe/p_screen.h | 3 +++
src/mesa/state_tracker/st_context.c | 2 ++
6 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c
index 5290f40..bdd8c0a 100644
--- a/src/gallium/drivers/r600/r600_pipe.c
+++ b/src/gallium/drivers/r600/r600_pipe.c
@@ -600,6 +600,7 @@ static void r600_destroy_screen(struct pipe_screen* pscreen)
compute_memory_pool_delete(rscreen->global_pool);
}
+ disk_cache_destroy(rscreen->b.b.disk_shader_cache);
r600_destroy_common_screen(&rscreen->b);
}
@@ -633,6 +634,15 @@ struct pipe_screen *r600_screen_create(struct radeon_winsys *ws)
return NULL;
}
+ uint32_t mesa_timestamp;
+ if (disk_cache_get_function_timestamp(r600_screen_create, &mesa_timestamp)) {
+ char *timestamp_str;
+ if (asprintf(×tamp_str, "%u", mesa_timestamp) != -1) {
+ rscreen->b.b.disk_shader_cache = disk_cache_create(r600_get_chip_name(&rscreen->b), timestamp_str);
+ free(timestamp_str);
+ }
+ }
+
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 95a6a48..4e5582f 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.c
+++ b/src/gallium/drivers/radeon/r600_pipe_common.c
@@ -722,7 +722,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";
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h
index 6eff9aa..0449d4d 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.h
+++ b/src/gallium/drivers/radeon/r600_pipe_common.h
@@ -765,6 +765,7 @@ 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);
/* 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 853d850..0bb95b1 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -712,6 +712,7 @@ static void si_destroy_screen(struct pipe_screen* pscreen)
}
}
pipe_mutex_destroy(sscreen->shader_parts_mutex);
+ disk_cache_destroy(sscreen->b.b.disk_shader_cache);
si_destroy_shader_cache(sscreen);
r600_destroy_common_screen(&sscreen->b);
}
@@ -801,6 +802,16 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws)
return NULL;
}
+ uint32_t mesa_timestamp, llvm_timestamp;
+ if (disk_cache_get_function_timestamp(radeonsi_screen_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.b.disk_shader_cache = disk_cache_create(r600_get_chip_name(&sscreen->b), timestamp_str);
+ free(timestamp_str);
+ }
+ }
+
si_handle_env_var_force_family(sscreen);
if (!debug_get_bool_option("RADEON_DISABLE_PERFCOUNTERS", false))
diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h
index b6203f1..6fd527f 100644
--- a/src/gallium/include/pipe/p_screen.h
+++ b/src/gallium/include/pipe/p_screen.h
@@ -42,6 +42,7 @@
#include "pipe/p_format.h"
#include "pipe/p_defines.h"
#include "pipe/p_video_enums.h"
+#include "util/disk_cache.h"
@@ -318,6 +319,8 @@ struct pipe_screen {
const void *(*get_compiler_options)(struct pipe_screen *screen,
enum pipe_shader_ir ir,
unsigned shader);
+
+ struct disk_cache *disk_shader_cache;
};
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 5523734..9e97eb7 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -551,6 +551,8 @@ struct st_context *st_create_context(gl_api api, struct pipe_context *pipe,
return NULL;
}
+ ctx->Cache = pipe->screen->disk_shader_cache;
+
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