diff options
author | Kenneth Graunke <[email protected]> | 2019-05-20 23:25:40 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2019-05-21 15:05:38 -0700 |
commit | dc5dc727d5932c69aab2c7964228ca351ec5da7d (patch) | |
tree | 32bb6a7daf5e363d9c8b00bb5a36f47e12d837ff /src/gallium/drivers | |
parent | 4756864cdc5fee9602ab63a9fa2c4b459667a6c2 (diff) |
iris: Serialize the NIR to a blob we can use for shader cache purposes.
We will use a hash of the serialized NIR together with brw_prog_*_key
(for NOS) as the disk cache key, where the disk cache contains actual
assembly shaders.
Reviewed-by: Dylan Baker <[email protected]>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/iris/iris_context.h | 4 | ||||
-rw-r--r-- | src/gallium/drivers/iris/iris_program.c | 21 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/gallium/drivers/iris/iris_context.h b/src/gallium/drivers/iris/iris_context.h index 294f325d19d..a3e4da792e9 100644 --- a/src/gallium/drivers/iris/iris_context.h +++ b/src/gallium/drivers/iris/iris_context.h @@ -260,6 +260,10 @@ struct iris_uncompiled_shader { struct pipe_stream_output_info stream_output; + /* The serialized NIR (for the disk cache) and size in bytes. */ + void *ir_cache_binary; + uint32_t ir_cache_binary_size; + unsigned program_id; /** Bitfield of (1 << IRIS_NOS_*) flags. */ diff --git a/src/gallium/drivers/iris/iris_program.c b/src/gallium/drivers/iris/iris_program.c index 834a3661355..5c1af3c8a4b 100644 --- a/src/gallium/drivers/iris/iris_program.c +++ b/src/gallium/drivers/iris/iris_program.c @@ -38,6 +38,7 @@ #include "util/u_atomic.h" #include "compiler/nir/nir.h" #include "compiler/nir/nir_builder.h" +#include "compiler/nir/nir_serialize.h" #include "intel/compiler/brw_compiler.h" #include "intel/compiler/brw_nir.h" #include "iris_context.h" @@ -1458,6 +1459,26 @@ iris_create_uncompiled_shader(struct pipe_context *ctx, update_so_info(&ish->stream_output, nir->info.outputs_written); } + if (screen->disk_cache) { + /* Serialize the NIR to a binary blob that we can hash for the disk + * cache. First, drop unnecessary information (like variable names) + * so the serialized NIR is smaller, and also to let us detect more + * isomorphic shaders when hashing, increasing cache hits. + * + * We skip this step when not using the disk cache, as variable names + * are useful for inspecting and debugging shaders. + */ + nir_strip(nir); + + struct blob blob; + blob_init(&blob); + nir_serialize(&blob, ish->nir); + ish->ir_cache_binary = malloc(blob.size); + ish->ir_cache_binary_size = blob.size; + memcpy(ish->ir_cache_binary, blob.data, blob.size); + blob_finish(&blob); + } + return ish; } |