diff options
author | Jason Ekstrand <[email protected]> | 2017-09-14 16:49:53 -0700 |
---|---|---|
committer | Jordan Justen <[email protected]> | 2017-10-31 23:36:53 -0700 |
commit | 54f691311c1f56c6aed693c21e820e4dd52b7f20 (patch) | |
tree | 62223980b06b1b9f3688a4bed4a773d13184baa9 /src/compiler/nir/nir_serialize.c | |
parent | 120da009755414ba62b0f902a67ad22004b9a304 (diff) |
nir: Add hooks for testing serialization
Reviewed-by: Timothy Arceri <[email protected]>
Reviewed-by: Jordan Justen <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_serialize.c')
-rw-r--r-- | src/compiler/nir/nir_serialize.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_serialize.c b/src/compiler/nir/nir_serialize.c index bb6a5d86f29..7951258a202 100644 --- a/src/compiler/nir/nir_serialize.c +++ b/src/compiler/nir/nir_serialize.c @@ -1199,3 +1199,22 @@ nir_deserialize(void *mem_ctx, return ctx.nir; } + +nir_shader * +nir_shader_serialize_deserialize(void *mem_ctx, nir_shader *s) +{ + const struct nir_shader_compiler_options *options = s->options; + + struct blob writer; + blob_init(&writer); + nir_serialize(&writer, s); + ralloc_free(s); + + struct blob_reader reader; + blob_reader_init(&reader, writer.data, writer.size); + nir_shader *ns = nir_deserialize(mem_ctx, options, &reader); + + blob_finish(&writer); + + return ns; +} |