From: Dave Airlie Date: Mon, 18 Nov 2019 22:19:34 +0000 (+1000) Subject: nir/serialize: fix serializing functions with no implementations. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1468a4f1f3a2e4c98c5d857a636233c356922807;p=mesa.git nir/serialize: fix serializing functions with no implementations. Store a flag stating if there was an implmentation, and use fxn->impl as a temporary flag between deserializsation stages. Reviewed-by: Marek Olšák Reviewed-by: Karol Herbst Reviewed-by: Jason Ekstrand --- diff --git a/src/compiler/nir/nir_serialize.c b/src/compiler/nir/nir_serialize.c index 5df498405d0..18398545220 100644 --- a/src/compiler/nir/nir_serialize.c +++ b/src/compiler/nir/nir_serialize.c @@ -25,6 +25,7 @@ #include "nir_control_flow.h" #include "util/u_dynarray.h" +#define NIR_SERIALIZE_FUNC_HAS_IMPL ((void *)(intptr_t)1) #define MAX_OBJECT_IDS (1 << 30) typedef struct { @@ -1072,6 +1073,8 @@ write_function(write_ctx *ctx, const nir_function *fxn) uint32_t flags = fxn->is_entrypoint; if (fxn->name) flags |= 0x2; + if (fxn->impl) + flags |= 0x4; blob_write_uint32(ctx->blob, flags); if (fxn->name) blob_write_string(ctx->blob, fxn->name); @@ -1113,6 +1116,8 @@ read_function(read_ctx *ctx) } fxn->is_entrypoint = flags & 0x1; + if (flags & 0x4) + fxn->impl = NIR_SERIALIZE_FUNC_HAS_IMPL; } void @@ -1172,7 +1177,8 @@ nir_serialize(struct blob *blob, const nir_shader *nir, bool strip) } nir_foreach_function(fxn, nir) { - write_function_impl(&ctx, fxn->impl); + if (fxn->impl) + write_function_impl(&ctx, fxn->impl); } blob_write_uint32(blob, nir->constant_data_size); @@ -1231,8 +1237,10 @@ nir_deserialize(void *mem_ctx, for (unsigned i = 0; i < num_functions; i++) read_function(&ctx); - nir_foreach_function(fxn, ctx.nir) - fxn->impl = read_function_impl(&ctx, fxn); + nir_foreach_function(fxn, ctx.nir) { + if (fxn->impl == NIR_SERIALIZE_FUNC_HAS_IMPL) + fxn->impl = read_function_impl(&ctx, fxn); + } ctx.nir->constant_data_size = blob_read_uint32(blob); if (ctx.nir->constant_data_size > 0) {