i965: move disk cache from brw_context to intel_screen
authorTapani Pälli <tapani.palli@intel.com>
Fri, 26 Jan 2018 06:20:07 +0000 (08:20 +0200)
committerTapani Pälli <tapani.palli@intel.com>
Tue, 30 Jan 2018 06:42:51 +0000 (08:42 +0200)
Now every context refers to same disk_cache instance in screen.

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Suggested-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
src/mesa/drivers/dri/i965/brw_context.c
src/mesa/drivers/dri/i965/brw_disk_cache.c
src/mesa/drivers/dri/i965/brw_state.h
src/mesa/drivers/dri/i965/intel_screen.c
src/mesa/drivers/dri/i965/intel_screen.h

index 07a234b367fefd1d05ac9e67b9e41f4907604980..addacf2cf80c63029c5e19051276fb63526c2325 100644 (file)
@@ -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);
 
index 6196386425d3eb1281dd61fa32c5fd0bef9f97f8..f989456bcde3252779305215c4f6b35a45051991 100644 (file)
@@ -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
 }
index ad508950f78f21b972cef88d7c5fa80ee7c7e67c..d29ae6b972f2caf16d0d2789b2b3ca5a583d89d0 100644 (file)
@@ -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);
index a4e34e9f2cf43907a75f31f9ebfea21e52807492..e1e520bc89950894d130aceaa2f8266193f60078 100644 (file)
@@ -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);
 }
 
index 7948617b7f07e12f773744b61b598bb89b7c1264..ef2d08974ed5b14ac705be5d2c23940ee1d11cb5 100644 (file)
@@ -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);