summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2019-11-05 17:53:32 -0500
committerMarek Olšák <[email protected]>2019-11-23 00:02:10 -0500
commita0cd67d29203755cec7017a6894704d2a55bee06 (patch)
tree26cd02b37552392657a6e22ce31fdb60f624fd77 /src
parentca201bfe7060638cfd39a8d263df93cb0c39c75b (diff)
nir/serialize: try to put deref->var index into the unused bits of the header
Reviewed-by: Connor Abbott <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/compiler/nir/nir_serialize.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/compiler/nir/nir_serialize.c b/src/compiler/nir/nir_serialize.c
index 53b9f05d5fb..ddf12ae9b8d 100644
--- a/src/compiler/nir/nir_serialize.c
+++ b/src/compiler/nir/nir_serialize.c
@@ -100,12 +100,6 @@ write_lookup_object(write_ctx *ctx, const void *obj)
}
static void
-write_object(write_ctx *ctx, const void *obj)
-{
- blob_write_uint32(ctx->blob, write_lookup_object(ctx, obj));
-}
-
-static void
read_add_object(read_ctx *ctx, void *obj)
{
assert(ctx->next_idx < ctx->idx_table_len);
@@ -625,12 +619,19 @@ union packed_instr {
unsigned instr_type:4;
unsigned deref_type:3;
unsigned cast_type_same_as_last:1;
- unsigned mode:10;
- unsigned _pad:6;
+ unsigned mode:10; /* deref_var redefines this */
+ unsigned _pad:6; /* deref_var redefines this */
unsigned dest:8;
} deref;
struct {
unsigned instr_type:4;
+ unsigned deref_type:3;
+ unsigned _pad:1;
+ unsigned object_idx:16; /* if 0, the object ID is a separate uint32 */
+ unsigned dest:8;
+ } deref_var;
+ struct {
+ unsigned instr_type:4;
unsigned intrinsic:9;
unsigned num_components:3;
unsigned const_indices_encoding:2;
@@ -857,10 +858,18 @@ write_deref(write_ctx *ctx, const nir_deref_instr *deref)
header.deref.cast_type_same_as_last = deref->type == ctx->last_type;
}
+ unsigned var_idx = 0;
+ if (deref->deref_type == nir_deref_type_var) {
+ var_idx = write_lookup_object(ctx, deref->var);
+ if (var_idx && var_idx < (1 << 16))
+ header.deref_var.object_idx = var_idx;
+ }
+
write_dest(ctx, &deref->dest, header);
if (deref->deref_type == nir_deref_type_var) {
- write_object(ctx, deref->var);
+ if (!header.deref_var.object_idx)
+ blob_write_uint32(ctx->blob, var_idx);
return;
}
@@ -902,7 +911,11 @@ read_deref(read_ctx *ctx, union packed_instr header)
read_dest(ctx, &deref->dest, &deref->instr, header);
if (deref_type == nir_deref_type_var) {
- deref->var = read_object(ctx);
+ if (header.deref_var.object_idx)
+ deref->var = read_lookup_object(ctx, header.deref_var.object_idx);
+ else
+ deref->var = read_object(ctx);
+
deref->type = deref->var->type;
deref->mode = deref->var->data.mode;
return deref;