diff options
author | Jordan Justen <[email protected]> | 2017-10-18 19:25:48 -0700 |
---|---|---|
committer | Jordan Justen <[email protected]> | 2017-10-31 23:36:54 -0700 |
commit | c3a8ae105ca4c6abdd967bd569b9605967cfcf25 (patch) | |
tree | 550864eabd93d8c66388f4de39394b1470561731 | |
parent | a4078b819f648fb8e2b6dde8f6017f46a38c54f2 (diff) |
i965: add cache fallback support using serialized nir
If the i965 gen program cannot be loaded from the cache, then we
fallback to using a serialized nir program.
This is based on "i965: add cache fallback support" by Timothy Arceri
<[email protected]>. Tim's version was written to fallback
to compiling from source, and therefore had to be much more complex.
After Connor and Jason implemented nir serialization, I was able to
rewrite and greatly simplify this patch.
Signed-off-by: Jordan Justen <[email protected]>
Acked-by: Timothy Arceri <[email protected]>
Reviewed-by: Jason Ekstrand <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_disk_cache.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_disk_cache.c b/src/mesa/drivers/dri/i965/brw_disk_cache.c index f05ef853bfc..73202d571f9 100644 --- a/src/mesa/drivers/dri/i965/brw_disk_cache.c +++ b/src/mesa/drivers/dri/i965/brw_disk_cache.c @@ -24,6 +24,7 @@ #include "compiler/blob.h" #include "compiler/glsl/ir_uniform.h" #include "compiler/glsl/shader_cache.h" +#include "compiler/nir/nir_serialize.h" #include "main/mtypes.h" #include "util/disk_cache.h" #include "util/macros.h" @@ -59,6 +60,27 @@ gen_shader_sha1(struct brw_context *brw, struct gl_program *prog, } static void +restore_serialized_nir_shader(struct brw_context *brw, struct gl_program *prog, + gl_shader_stage stage) +{ + prog->program_written_to_cache = false; + if (brw->ctx._Shader->Flags & GLSL_CACHE_INFO) { + fprintf(stderr, "falling back to nir %s.\n", + _mesa_shader_stage_to_abbrev(prog->info.stage)); + } + + if (!prog->nir) { + assert(prog->driver_cache_blob && prog->driver_cache_blob_size > 0); + const struct nir_shader_compiler_options *options = + brw->ctx.Const.ShaderCompilerOptions[stage].NirOptions; + struct blob_reader reader; + blob_reader_init(&reader, prog->driver_cache_blob, + prog->driver_cache_blob_size); + prog->nir = nir_deserialize(NULL, options, &reader); + } +} + +static void write_blob_program_data(struct blob *binary, gl_shader_stage stage, const void *program, struct brw_stage_prog_data *prog_data) @@ -258,6 +280,9 @@ brw_disk_cache_upload_program(struct brw_context *brw, gl_shader_stage stage) prog->sh.LinkedTransformFeedback->api_enabled) return false; + if (brw->ctx._Shader->Flags & GLSL_CACHE_FALLBACK) + goto fail; + if (prog->sh.data->LinkStatus != linking_skipped) goto fail; @@ -271,7 +296,7 @@ brw_disk_cache_upload_program(struct brw_context *brw, gl_shader_stage stage) return true; fail: - /*FIXME: Fall back and compile from source here. */ + restore_serialized_nir_shader(brw, prog, stage); return false; } |