[Mesa-dev] [PATCH] i965: move disk cache from brw_context to intel_screen
Tapani Pälli
tapani.palli at intel.com
Mon Jan 29 12:39:28 UTC 2018
Now every context refers to same disk_cache instance in screen.
Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
Suggested-by: Emil Velikov <emil.velikov at collabora.com>
---
src/mesa/drivers/dri/i965/brw_context.c | 4 +---
src/mesa/drivers/dri/i965/brw_disk_cache.c | 6 +++---
src/mesa/drivers/dri/i965/brw_state.h | 2 +-
src/mesa/drivers/dri/i965/intel_screen.c | 5 +++++
src/mesa/drivers/dri/i965/intel_screen.h | 2 ++
5 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 07a234b367..addacf2cf8 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -1066,7 +1066,7 @@ brwCreateContext(gl_api api,
vbo_use_buffer_objects(ctx);
vbo_always_unmap_buffers(ctx);
- brw_disk_cache_init(brw);
+ brw->ctx.Cache = brw->screen->disk_cache;
return true;
}
@@ -1130,8 +1130,6 @@ intelDestroyContext(__DRIcontext * driContextPriv)
driDestroyOptionCache(&brw->optionCache);
- disk_cache_destroy(brw->ctx.Cache);
-
/* free the Mesa context */
_mesa_free_context_data(&brw->ctx);
diff --git a/src/mesa/drivers/dri/i965/brw_disk_cache.c b/src/mesa/drivers/dri/i965/brw_disk_cache.c
index 6196386425..f989456bcd 100644
--- a/src/mesa/drivers/dri/i965/brw_disk_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_disk_cache.c
@@ -404,7 +404,7 @@ brw_disk_cache_write_compute_program(struct brw_context *brw)
}
void
-brw_disk_cache_init(struct brw_context *brw)
+brw_disk_cache_init(struct intel_screen *screen)
{
#ifdef ENABLE_SHADER_CACHE
if (env_var_as_boolean("MESA_GLSL_CACHE_DISABLE", true))
@@ -412,7 +412,7 @@ brw_disk_cache_init(struct brw_context *brw)
char renderer[10];
MAYBE_UNUSED int len = snprintf(renderer, sizeof(renderer), "i965_%04x",
- brw->screen->deviceID);
+ screen->deviceID);
assert(len == sizeof(renderer) - 1);
const struct build_id_note *note =
@@ -425,6 +425,6 @@ brw_disk_cache_init(struct brw_context *brw)
char timestamp[41];
_mesa_sha1_format(timestamp, id_sha1);
- brw->ctx.Cache = disk_cache_create(renderer, timestamp, 0);
+ screen->disk_cache = disk_cache_create(renderer, timestamp, 0);
#endif
}
diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h
index ad508950f7..d29ae6b972 100644
--- a/src/mesa/drivers/dri/i965/brw_state.h
+++ b/src/mesa/drivers/dri/i965/brw_state.h
@@ -125,7 +125,7 @@ void gen8_write_pma_stall_bits(struct brw_context *brw,
uint32_t pma_stall_bits);
/* brw_disk_cache.c */
-void brw_disk_cache_init(struct brw_context *brw);
+void brw_disk_cache_init(struct intel_screen *screen);
bool brw_disk_cache_upload_program(struct brw_context *brw,
gl_shader_stage stage);
void brw_disk_cache_write_compute_program(struct brw_context *brw);
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index a4e34e9f2c..e1e520bc89 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -41,6 +41,7 @@
#include "compiler/nir/nir.h"
#include "utils.h"
+#include "util/disk_cache.h"
#include "util/xmlpool.h"
static const __DRIconfigOptionsExtension brw_config_options = {
@@ -1572,6 +1573,8 @@ intelDestroyScreen(__DRIscreen * sPriv)
brw_bufmgr_destroy(screen->bufmgr);
driDestroyOptionInfo(&screen->optionCache);
+ disk_cache_destroy(screen->disk_cache);
+
ralloc_free(screen);
sPriv->driverPrivate = NULL;
}
@@ -2683,6 +2686,8 @@ __DRIconfig **intelInitScreen2(__DRIscreen *dri_screen)
}
}
+ brw_disk_cache_init(screen);
+
return (const __DRIconfig**) intel_screen_make_configs(dri_screen);
}
diff --git a/src/mesa/drivers/dri/i965/intel_screen.h b/src/mesa/drivers/dri/i965/intel_screen.h
index 7948617b7f..ef2d08974e 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.h
+++ b/src/mesa/drivers/dri/i965/intel_screen.h
@@ -117,6 +117,8 @@ struct intel_screen
bool mesa_format_supports_texture[MESA_FORMAT_COUNT];
bool mesa_format_supports_render[MESA_FORMAT_COUNT];
enum isl_format mesa_to_isl_render_format[MESA_FORMAT_COUNT];
+
+ struct disk_cache *disk_cache;
};
extern void intelDestroyContext(__DRIcontext * driContextPriv);
--
2.14.3
More information about the mesa-dev
mailing list