summaryrefslogtreecommitdiff
path: root/src/compiler/nir/nir_serialize.c
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2019-11-21 20:24:08 -0500
committerMarek Olšák <marek.olsak@amd.com>2019-11-23 00:02:10 -0500
commitad40715f3595537cfcc3d489f86d6c4dd7f34cc6 (patch)
treedf7384520e6334845fd451164ec525712fdb0b79 /src/compiler/nir/nir_serialize.c
parentc028449c011c395ed64eb2d873c0efb4deb2c6e8 (diff)
nir/serialize: support any num_components for remaining instructions
Only NPOT vectors greater than vec4 use the extra uint32. This is for instructions that share the dest code. load_const and undef already support 1-16 in the header. Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
Diffstat (limited to 'src/compiler/nir/nir_serialize.c')
-rw-r--r--src/compiler/nir/nir_serialize.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/compiler/nir/nir_serialize.c b/src/compiler/nir/nir_serialize.c
index e16c1074285..50f009d5c07 100644
--- a/src/compiler/nir/nir_serialize.c
+++ b/src/compiler/nir/nir_serialize.c
@@ -141,6 +141,8 @@ decode_bit_size_3bits(uint8_t bit_size)
return 0;
}
+#define NUM_COMPONENTS_IS_SEPARATE_7 7
+
static uint8_t
encode_num_components_in_3bits(uint8_t num_components)
{
@@ -151,8 +153,8 @@ encode_num_components_in_3bits(uint8_t num_components)
if (num_components == 16)
return 6;
- unreachable("invalid number in num_components");
- return 0;
+ /* special value indicating that num_components is in the next uint32 */
+ return NUM_COMPONENTS_IS_SEPARATE_7;
}
static uint8_t
@@ -732,6 +734,10 @@ write_dest(write_ctx *ctx, const nir_dest *dst, union packed_instr header,
blob_write_uint32(ctx->blob, header.u32);
}
+ if (dest.ssa.is_ssa &&
+ dest.ssa.num_components == NUM_COMPONENTS_IS_SEPARATE_7)
+ blob_write_uint32(ctx->blob, dst->ssa.num_components);
+
if (dst->is_ssa) {
write_add_object(ctx, &dst->ssa);
if (dest.ssa.has_name)
@@ -753,8 +759,11 @@ read_dest(read_ctx *ctx, nir_dest *dst, nir_instr *instr,
if (dest.ssa.is_ssa) {
unsigned bit_size = decode_bit_size_3bits(dest.ssa.bit_size);
- unsigned num_components =
- decode_num_components_in_3bits(dest.ssa.num_components);
+ unsigned num_components;
+ if (dest.ssa.num_components == NUM_COMPONENTS_IS_SEPARATE_7)
+ num_components = blob_read_uint32(ctx->blob);
+ else
+ num_components = decode_num_components_in_3bits(dest.ssa.num_components);
char *name = dest.ssa.has_name ? blob_read_string(ctx->blob) : NULL;
nir_ssa_dest_init(instr, dst, num_components, bit_size, name);
read_add_object(ctx, &dst->ssa);