summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2019-11-11 22:33:49 -0500
committerMarek Olšák <[email protected]>2019-11-23 00:02:10 -0500
commita2df670b1419296060d6914eb9a930171a38092c (patch)
tree42ba8836fbd9effb30d7b09f29b3ed82821254b2 /src/compiler/nir
parenta5c5388234a4d3ec8e05d15f1b9663b19342cdf5 (diff)
nir/serialize: serialize writemask for vec8 and vec16
Reviewed-by: Connor Abbott <[email protected]>
Diffstat (limited to 'src/compiler/nir')
-rw-r--r--src/compiler/nir/nir_serialize.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/compiler/nir/nir_serialize.c b/src/compiler/nir/nir_serialize.c
index 8877fc81ae7..c64acfe3f18 100644
--- a/src/compiler/nir/nir_serialize.c
+++ b/src/compiler/nir/nir_serialize.c
@@ -806,6 +806,7 @@ static void
write_alu(write_ctx *ctx, const nir_alu_instr *alu)
{
unsigned num_srcs = nir_op_infos[alu->op].num_inputs;
+ unsigned dst_components = nir_dest_num_components(alu->dest.dest);
/* 9 bits for nir_op */
STATIC_ASSERT(nir_num_opcodes <= 512);
@@ -826,13 +827,16 @@ write_alu(write_ctx *ctx, const nir_alu_instr *alu)
header.alu.writemask_or_two_swizzles = alu->src[0].swizzle[0];
if (num_srcs > 1)
header.alu.writemask_or_two_swizzles |= alu->src[1].swizzle[0] << 2;
- } else if (!alu->dest.dest.is_ssa) {
- /* For registers, this field is a writemask. */
+ } else if (!alu->dest.dest.is_ssa && dst_components <= 4) {
+ /* For vec4 registers, this field is a writemask. */
header.alu.writemask_or_two_swizzles = alu->dest.write_mask;
}
write_dest(ctx, &alu->dest.dest, header, alu->instr.type);
+ if (!alu->dest.dest.is_ssa && dst_components > 4)
+ blob_write_uint32(ctx->blob, alu->dest.write_mask);
+
if (header.alu.packed_src_ssa_16bit) {
for (unsigned i = 0; i < num_srcs; i++) {
assert(alu->src[i].src.is_ssa);
@@ -888,6 +892,16 @@ read_alu(read_ctx *ctx, union packed_instr header)
read_dest(ctx, &alu->dest.dest, &alu->instr, header);
+ unsigned dst_components = nir_dest_num_components(alu->dest.dest);
+
+ if (alu->dest.dest.is_ssa) {
+ alu->dest.write_mask = u_bit_consecutive(0, dst_components);
+ } else if (dst_components <= 4) {
+ alu->dest.write_mask = header.alu.writemask_or_two_swizzles;
+ } else {
+ alu->dest.write_mask = blob_read_uint32(ctx->blob);
+ }
+
if (header.alu.packed_src_ssa_16bit) {
for (unsigned i = 0; i < num_srcs; i++) {
nir_alu_src *src = &alu->src[i];
@@ -930,13 +944,6 @@ read_alu(read_ctx *ctx, union packed_instr header)
}
}
- if (alu->dest.dest.is_ssa) {
- alu->dest.write_mask =
- u_bit_consecutive(0, alu->dest.dest.ssa.num_components);
- } else {
- alu->dest.write_mask = header.alu.writemask_or_two_swizzles;
- }
-
if (header.alu.packed_src_ssa_16bit &&
alu->dest.dest.is_ssa) {
alu->src[0].swizzle[0] = header.alu.writemask_or_two_swizzles & 0x3;