summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2019-11-19 08:19:34 +1000
committerDave Airlie <[email protected]>2019-11-19 09:30:32 +1000
commit1468a4f1f3a2e4c98c5d857a636233c356922807 (patch)
tree687f84eacb29459144bf6add511f1af4f3efabea /src/compiler
parent0fd6b8aa987dcdfbea497f333780b6ccba8a1517 (diff)
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 <[email protected]> Reviewed-by: Karol Herbst <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/nir/nir_serialize.c14
1 files changed, 11 insertions, 3 deletions
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) {