Re: [Mesa-dev] [PATCH v3 28/34] i965: add cache fallback support using serialized nir
On Sunday, October 29, 2017 5:21:47 PM PDT Jordan Justen wrote: > On 2017-10-29 01:11:32, Kenneth Graunke wrote: > > On Sunday, October 22, 2017 1:01:36 PM PDT Jordan Justen wrote: > > > 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 > > >. 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 > > > Acked-by: Timothy Arceri > > > --- > > > src/mesa/drivers/dri/i965/brw_disk_cache.c | 27 > > > ++- > > > 1 file changed, 26 insertions(+), 1 deletion(-) > > > > > > diff --git a/src/mesa/drivers/dri/i965/brw_disk_cache.c > > > b/src/mesa/drivers/dri/i965/brw_disk_cache.c > > > index 503c6c7b499..9af893d40a7 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" > > > @@ -58,6 +59,27 @@ gen_shader_sha1(struct brw_context *brw, struct > > > gl_program *prog, > > > _mesa_sha1_compute(manifest, strlen(manifest), out_sha1); > > > } > > > > > > +static void > > > +fallback_to_full_recompile(struct brw_context *brw, struct gl_program > > > *prog, > > > > It's not exactly a full recompile anymore, maybe rename this to > > recompile_from_nir? Or fallback_to_partial_recompile? > > Good point. I guess eventually we'll recompile from nir, but at this > point we are just restoring the nir program. What about > restore_serialized_nir_shader? Reviewed-by from you with that? > > -Jordan Sure. Reviewed-by: Kenneth Graunke signature.asc Description: This is a digitally signed message part. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v3 28/34] i965: add cache fallback support using serialized nir
On 2017-10-29 01:11:32, Kenneth Graunke wrote: > On Sunday, October 22, 2017 1:01:36 PM PDT Jordan Justen wrote: > > 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 > >. 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 > > Acked-by: Timothy Arceri > > --- > > src/mesa/drivers/dri/i965/brw_disk_cache.c | 27 ++- > > 1 file changed, 26 insertions(+), 1 deletion(-) > > > > diff --git a/src/mesa/drivers/dri/i965/brw_disk_cache.c > > b/src/mesa/drivers/dri/i965/brw_disk_cache.c > > index 503c6c7b499..9af893d40a7 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" > > @@ -58,6 +59,27 @@ gen_shader_sha1(struct brw_context *brw, struct > > gl_program *prog, > > _mesa_sha1_compute(manifest, strlen(manifest), out_sha1); > > } > > > > +static void > > +fallback_to_full_recompile(struct brw_context *brw, struct gl_program > > *prog, > > It's not exactly a full recompile anymore, maybe rename this to > recompile_from_nir? Or fallback_to_partial_recompile? Good point. I guess eventually we'll recompile from nir, but at this point we are just restoring the nir program. What about restore_serialized_nir_shader? Reviewed-by from you with that? -Jordan > > > + 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(, prog->driver_cache_blob, > > + prog->driver_cache_blob_size); > > + prog->nir = nir_deserialize(NULL, options, ); > > + } > > +} > > + > > static void > > write_blob_program_data(struct blob *binary, const void *program, > > size_t program_size, > > @@ -280,6 +302,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; > > > > @@ -293,7 +318,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. */ > > + fallback_to_full_recompile(brw, prog, stage); > > return false; > > } > > > > > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v3 28/34] i965: add cache fallback support using serialized nir
On Sunday, October 22, 2017 1:01:36 PM PDT Jordan Justen wrote: > 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 >. 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 > Acked-by: Timothy Arceri > --- > src/mesa/drivers/dri/i965/brw_disk_cache.c | 27 ++- > 1 file changed, 26 insertions(+), 1 deletion(-) > > diff --git a/src/mesa/drivers/dri/i965/brw_disk_cache.c > b/src/mesa/drivers/dri/i965/brw_disk_cache.c > index 503c6c7b499..9af893d40a7 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" > @@ -58,6 +59,27 @@ gen_shader_sha1(struct brw_context *brw, struct gl_program > *prog, > _mesa_sha1_compute(manifest, strlen(manifest), out_sha1); > } > > +static void > +fallback_to_full_recompile(struct brw_context *brw, struct gl_program *prog, It's not exactly a full recompile anymore, maybe rename this to recompile_from_nir? Or fallback_to_partial_recompile? > + 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(, prog->driver_cache_blob, > + prog->driver_cache_blob_size); > + prog->nir = nir_deserialize(NULL, options, ); > + } > +} > + > static void > write_blob_program_data(struct blob *binary, const void *program, > size_t program_size, > @@ -280,6 +302,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; > > @@ -293,7 +318,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. */ > + fallback_to_full_recompile(brw, prog, stage); > return false; > } > > signature.asc Description: This is a digitally signed message part. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 28/34] 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. 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 Acked-by: Timothy Arceri --- src/mesa/drivers/dri/i965/brw_disk_cache.c | 27 ++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_disk_cache.c b/src/mesa/drivers/dri/i965/brw_disk_cache.c index 503c6c7b499..9af893d40a7 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" @@ -58,6 +59,27 @@ gen_shader_sha1(struct brw_context *brw, struct gl_program *prog, _mesa_sha1_compute(manifest, strlen(manifest), out_sha1); } +static void +fallback_to_full_recompile(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(, prog->driver_cache_blob, + prog->driver_cache_blob_size); + prog->nir = nir_deserialize(NULL, options, ); + } +} + static void write_blob_program_data(struct blob *binary, const void *program, size_t program_size, @@ -280,6 +302,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; @@ -293,7 +318,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. */ + fallback_to_full_recompile(brw, prog, stage); return false; } -- 2.15.0.rc0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev