[Mesa-dev] [PATCH 26/27] i965: Initialize disk shader cache when INTEL_SHADER_CACHE env var is set
Matt Turner
mattst88 at gmail.com
Thu Sep 14 00:20:45 UTC 2017
On 08/19, Jordan Justen wrote:
>We use the build-id of i965_dri.so for the timestamp, and the name
>from i965_pci_ids.h for the device name.
>
>Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
>---
> src/mesa/drivers/dri/i965/brw_context.c | 2 ++
> src/mesa/drivers/dri/i965/brw_disk_cache.c | 45 ++++++++++++++++++++++++++++++
> src/mesa/drivers/dri/i965/brw_state.h | 1 +
> 3 files changed, 48 insertions(+)
>
>diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
>index 3904bc708b..5d7d555f79 100644
>--- a/src/mesa/drivers/dri/i965/brw_context.c
>+++ b/src/mesa/drivers/dri/i965/brw_context.c
>@@ -1014,6 +1014,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 036b56225e..ef5380126a 100644
>--- a/src/mesa/drivers/dri/i965/brw_disk_cache.c
>+++ b/src/mesa/drivers/dri/i965/brw_disk_cache.c
>@@ -29,6 +29,8 @@
> #include "main/mtypes.h"
> #include "main/shaderobj.h"
> #include "program/program.h"
>+#include "util/build_id.h"
>+#include "util/debug.h"
> #include "util/disk_cache.h"
> #include "util/macros.h"
> #include "util/mesa-sha1.h"
>@@ -652,3 +654,46 @@ 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("INTEL_SHADER_CACHE", false))
>+ return;
>+
>+ char *renderer = NULL;
>+ int len = asprintf(&renderer, "i965_%04x", brw->screen->deviceID);
>+ if (len < 0) {
>+ renderer = strdup("i965");
>+ }
>+ if (renderer == NULL)
>+ return;
>+
>+ const struct build_id_note *note = build_id_find_nhdr("i965_dri.so");
This will require a small rebase onto Chad's commit 5c98d3825ccbe
Also, we should just force the build-id to be present rather than having
code to handle the case when it isn't.
Just add -Wl,--build-id=sha1 to i965_dri.so's LDFLAGS. See
src/intel/Makefile.vulkan.am for example.
With that, this code becomes a lot simpler.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170913/50684d50/attachment.sig>
More information about the mesa-dev
mailing list