Mesa (master): nir/serialize: pack function has name and entry point into flags.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Nov 19 00:19:05 UTC 2019
Module: Mesa
Branch: master
Commit: 0fd6b8aa987dcdfbea497f333780b6ccba8a1517
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0fd6b8aa987dcdfbea497f333780b6ccba8a1517
Author: Dave Airlie <airlied at redhat.com>
Date: Tue Nov 19 08:16:22 2019 +1000
nir/serialize: pack function has name and entry point into flags.
Suggested by Jason.
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Reviewed-by: Karol Herbst <kherbst at redhat.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
---
src/compiler/nir/nir_serialize.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/compiler/nir/nir_serialize.c b/src/compiler/nir/nir_serialize.c
index b7ba8b7589f..5df498405d0 100644
--- a/src/compiler/nir/nir_serialize.c
+++ b/src/compiler/nir/nir_serialize.c
@@ -1069,7 +1069,10 @@ read_function_impl(read_ctx *ctx, nir_function *fxn)
static void
write_function(write_ctx *ctx, const nir_function *fxn)
{
- blob_write_uint32(ctx->blob, !!(fxn->name));
+ uint32_t flags = fxn->is_entrypoint;
+ if (fxn->name)
+ flags |= 0x2;
+ blob_write_uint32(ctx->blob, flags);
if (fxn->name)
blob_write_string(ctx->blob, fxn->name);
@@ -1083,8 +1086,6 @@ write_function(write_ctx *ctx, const nir_function *fxn)
blob_write_uint32(ctx->blob, val);
}
- blob_write_uint32(ctx->blob, fxn->is_entrypoint);
-
/* At first glance, it looks like we should write the function_impl here.
* However, call instructions need to be able to reference at least the
* function and those will get processed as we write the function_impls.
@@ -1095,7 +1096,8 @@ write_function(write_ctx *ctx, const nir_function *fxn)
static void
read_function(read_ctx *ctx)
{
- bool has_name = blob_read_uint32(ctx->blob);
+ uint32_t flags = blob_read_uint32(ctx->blob);
+ bool has_name = flags & 0x2;
char *name = has_name ? blob_read_string(ctx->blob) : NULL;
nir_function *fxn = nir_function_create(ctx->nir, name);
@@ -1110,7 +1112,7 @@ read_function(read_ctx *ctx)
fxn->params[i].bit_size = (val >> 8) & 0xff;
}
- fxn->is_entrypoint = blob_read_uint32(ctx->blob);
+ fxn->is_entrypoint = flags & 0x1;
}
void
More information about the mesa-commit
mailing list