From: Jordan Justen Date: Wed, 28 Feb 2018 09:39:27 +0000 (-0800) Subject: i965: Move brw_program_*serialize_nir to brw_program_binary.c X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f4c154afc19a6bf71a1c9b088384b2f293b09095;p=mesa.git i965: Move brw_program_*serialize_nir to brw_program_binary.c This will allow get_program_binary to add the gen program into its serialization in addition to just the nir program. Signed-off-by: Jordan Justen Reviewed-by: Timothy Arceri --- diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c index 915c42bd522..7a85678f86d 100644 --- a/src/mesa/drivers/dri/i965/brw_program.c +++ b/src/mesa/drivers/dri/i965/brw_program.c @@ -41,7 +41,6 @@ #include "util/ralloc.h" #include "compiler/glsl/ir.h" #include "compiler/glsl/glsl_to_nir.h" -#include "compiler/nir/nir_serialize.h" #include "brw_program.h" #include "brw_context.h" @@ -839,39 +838,3 @@ brw_assign_common_binding_table_offsets(const struct gen_device_info *devinfo, assert(next_binding_table_offset <= BRW_MAX_SURFACES); return next_binding_table_offset; } - -void -brw_program_serialize_nir(struct gl_context *ctx, struct gl_program *prog) -{ - if (prog->driver_cache_blob) - return; - - struct blob writer; - blob_init(&writer); - nir_serialize(&writer, prog->nir); - prog->driver_cache_blob = ralloc_size(NULL, writer.size); - memcpy(prog->driver_cache_blob, writer.data, writer.size); - prog->driver_cache_blob_size = writer.size; - blob_finish(&writer); -} - -void -brw_program_deserialize_nir(struct gl_context *ctx, struct gl_program *prog, - gl_shader_stage stage) -{ - if (!prog->nir) { - assert(prog->driver_cache_blob && prog->driver_cache_blob_size > 0); - const struct nir_shader_compiler_options *options = - 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); - } - - if (prog->driver_cache_blob) { - ralloc_free(prog->driver_cache_blob); - prog->driver_cache_blob = NULL; - prog->driver_cache_blob_size = 0; - } -} diff --git a/src/mesa/drivers/dri/i965/brw_program_binary.c b/src/mesa/drivers/dri/i965/brw_program_binary.c index f1b327de4b3..099279ef37e 100644 --- a/src/mesa/drivers/dri/i965/brw_program_binary.c +++ b/src/mesa/drivers/dri/i965/brw_program_binary.c @@ -23,6 +23,7 @@ #include +#include "compiler/nir/nir_serialize.h" #include "util/build_id.h" #include "util/mesa-sha1.h" @@ -60,6 +61,42 @@ brw_get_program_binary_driver_sha1(struct gl_context *ctx, uint8_t *sha1) memcpy(sha1, driver_sha1, sizeof(uint8_t) * 20); } +void +brw_program_serialize_nir(struct gl_context *ctx, struct gl_program *prog) +{ + if (prog->driver_cache_blob) + return; + + struct blob writer; + blob_init(&writer); + nir_serialize(&writer, prog->nir); + prog->driver_cache_blob = ralloc_size(NULL, writer.size); + memcpy(prog->driver_cache_blob, writer.data, writer.size); + prog->driver_cache_blob_size = writer.size; + blob_finish(&writer); +} + +void +brw_program_deserialize_nir(struct gl_context *ctx, struct gl_program *prog, + gl_shader_stage stage) +{ + if (!prog->nir) { + assert(prog->driver_cache_blob && prog->driver_cache_blob_size > 0); + const struct nir_shader_compiler_options *options = + 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); + } + + if (prog->driver_cache_blob) { + ralloc_free(prog->driver_cache_blob); + prog->driver_cache_blob = NULL; + prog->driver_cache_blob_size = 0; + } +} + /* This is just a wrapper around brw_program_deserialize_nir() as i965 * doesn't need gl_shader_program like other drivers do. */