summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Justen <jordan.l.justen@intel.com>2017-02-25 02:30:06 -0800
committerJordan Justen <jordan.l.justen@intel.com>2017-10-22 12:40:41 -0700
commit72cd0fab53978ecd7713348f4dc43e5b75793096 (patch)
tree11a6b2b55e43fef426b3cdd4b254ef204bd0364e
parent41fe2210c3823a49f9bccd65f9db6b1649050c27 (diff)
i965: Initialize disk shader cache if MESA_GLSL_CACHE_DISABLE is falsei965-shader-cache-v3
Double negative FTW! For now, the shader cache is disabled by default on i965 to allow us to verify its stability. In other words, to enable the shader cache on i965, set MESA_GLSL_CACHE_DISABLE to false or 0. If the variable is unset, then the shader cache will be disabled. We use the build-id of i965_dri.so for the timestamp, and the pci device id for the device name. v2: * Simplify code by forcing link to include build id sha. (Matt) v3: * Don't use a for loop with snprintf for bin to hex. (Matt) * Assume fixed length render and timestamp string to further simplify code. Cc: Matt Turner <mattst88@gmail.com> Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
-rw-r--r--docs/relnotes/17.3.0.html1
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.c2
-rw-r--r--src/mesa/drivers/dri/i965/brw_disk_cache.c29
-rw-r--r--src/mesa/drivers/dri/i965/brw_state.h1
4 files changed, 33 insertions, 0 deletions
diff --git a/docs/relnotes/17.3.0.html b/docs/relnotes/17.3.0.html
index b156158da5..e8d4cc0016 100644
--- a/docs/relnotes/17.3.0.html
+++ b/docs/relnotes/17.3.0.html
@@ -53,6 +53,7 @@ Note: some of the new features are only available with certain drivers.
<li>GL_EXT_memory_object_fd on radeonsi</li>
<li>EGL_ANDROID_native_fence_sync on radeonsi with a future kernel (possibly 4.15)</li>
<li>EGL_IMG_context_priority on i965</li>
+<li>Disk shader cache support for i965 when MESA_GLSL_CACHE_DISABLE environment variable is set to "0" or "false"</li>
</ul>
<h2>Bug fixes</h2>
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 949ec4a2a3..bb9474035c 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -1037,6 +1037,8 @@ brwCreateContext(gl_api api,
brw->dri_config_options_sha1);
brw->ctx.Const.dri_config_options_sha1 = brw->dri_config_options_sha1;
+ brw_disk_cache_init(brw);
+
return true;
}
diff --git a/src/mesa/drivers/dri/i965/brw_disk_cache.c b/src/mesa/drivers/dri/i965/brw_disk_cache.c
index 9af893d40a..22670e3166 100644
--- a/src/mesa/drivers/dri/i965/brw_disk_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_disk_cache.c
@@ -26,6 +26,8 @@
#include "compiler/glsl/shader_cache.h"
#include "compiler/nir/nir_serialize.h"
#include "main/mtypes.h"
+#include "util/build_id.h"
+#include "util/debug.h"
#include "util/disk_cache.h"
#include "util/macros.h"
#include "util/mesa-sha1.h"
@@ -460,3 +462,30 @@ brw_disk_cache_write_compute_program(struct brw_context *brw)
MESA_SHADER_COMPUTE);
}
}
+
+void
+brw_disk_cache_init(struct brw_context *brw)
+{
+#ifdef ENABLE_SHADER_CACHE
+ if (env_var_as_boolean("MESA_GLSL_CACHE_DISABLE", true))
+ return;
+
+ char renderer[10];
+ int len = snprintf(renderer, sizeof(renderer), "i965_%04x",
+ brw->screen->deviceID);
+ assert(len == sizeof(renderer) - 1);
+
+ const struct build_id_note *note =
+ build_id_find_nhdr_for_addr(brw_disk_cache_init);
+ int id_size = build_id_length(note);
+ assert(note && id_size == 20 /* sha1 */);
+
+ const uint8_t *id_sha1 = build_id_data(note);
+ assert(id_sha1);
+
+ char timestamp[41];
+ _mesa_sha1_format(timestamp, id_sha1);
+
+ brw->ctx.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 c98b7facd5..927e77920e 100644
--- a/src/mesa/drivers/dri/i965/brw_state.h
+++ b/src/mesa/drivers/dri/i965/brw_state.h
@@ -132,6 +132,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);
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);