diff options
author | Jason Ekstrand <[email protected]> | 2019-06-04 17:50:22 -0500 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2019-06-05 20:07:28 +0000 |
commit | fe2fc30cb559f7ef99c07bd219c057b011242cb4 (patch) | |
tree | 84686069b2d5afded4df1c14f2d777462a28bfd7 /src/compiler/nir/nir_serialize.c | |
parent | 9eba6d9a880558c89a72cbafd873d4fe1247928d (diff) |
nir: Don't replace the nir_shader when NIR_TEST_SERIALIZE=1
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108957
Reviewed-by: Kenneth Graunke <[email protected]>
Reviewed-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_serialize.c')
-rw-r--r-- | src/compiler/nir/nir_serialize.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/compiler/nir/nir_serialize.c b/src/compiler/nir/nir_serialize.c index e9e84bf8aaa..43a39ac1a5a 100644 --- a/src/compiler/nir/nir_serialize.c +++ b/src/compiler/nir/nir_serialize.c @@ -1202,21 +1202,28 @@ nir_deserialize(void *mem_ctx, return ctx.nir; } -nir_shader * -nir_shader_serialize_deserialize(void *mem_ctx, nir_shader *s) +void +nir_shader_serialize_deserialize(nir_shader *shader) { - const struct nir_shader_compiler_options *options = s->options; + const struct nir_shader_compiler_options *options = shader->options; struct blob writer; blob_init(&writer); - nir_serialize(&writer, s); - ralloc_free(s); + nir_serialize(&writer, shader); + + /* Delete all of dest's ralloc children but leave dest alone */ + void *dead_ctx = ralloc_context(NULL); + ralloc_adopt(dead_ctx, shader); + ralloc_free(dead_ctx); + + dead_ctx = ralloc_context(NULL); struct blob_reader reader; blob_reader_init(&reader, writer.data, writer.size); - nir_shader *ns = nir_deserialize(mem_ctx, options, &reader); + nir_shader *copy = nir_deserialize(dead_ctx, options, &reader); blob_finish(&writer); - return ns; + nir_shader_replace(shader, copy); + ralloc_free(dead_ctx); } |