summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2019-10-25 12:01:27 -0400
committerMarek Olšák <[email protected]>2019-11-05 23:35:31 -0500
commitd5768fcd45a1b9e77d7b5e3385edebc2ac2736f0 (patch)
tree547fe49d62f4386215f9f24d19b0f65febcdfb9c /src/compiler/nir
parent96e6ef80d932f12d3ed7ab5bc4aff6b370d6dc02 (diff)
nir/serialize: don't expand 16-bit variable state slots to 32 bits
the swizzle also needs only 16 bits Reviewed-by: Connor Abbott <[email protected]>
Diffstat (limited to 'src/compiler/nir')
-rw-r--r--src/compiler/nir/nir.h2
-rw-r--r--src/compiler/nir/nir_serialize.c10
2 files changed, 5 insertions, 7 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 3aa72a6a5c6..0dc604cce41 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -94,7 +94,7 @@ struct nir_builder;
*/
typedef struct {
gl_state_index16 tokens[STATE_LENGTH];
- int swizzle;
+ uint16_t swizzle;
} nir_state_slot;
typedef enum {
diff --git a/src/compiler/nir/nir_serialize.c b/src/compiler/nir/nir_serialize.c
index 558bd6c97a3..6c0d07f657e 100644
--- a/src/compiler/nir/nir_serialize.c
+++ b/src/compiler/nir/nir_serialize.c
@@ -142,9 +142,8 @@ write_variable(write_ctx *ctx, const nir_variable *var)
blob_write_bytes(ctx->blob, (uint8_t *) &var->data, sizeof(var->data));
blob_write_uint32(ctx->blob, var->num_state_slots);
for (unsigned i = 0; i < var->num_state_slots; i++) {
- for (unsigned j = 0; j < STATE_LENGTH; j++)
- blob_write_uint32(ctx->blob, var->state_slots[i].tokens[j]);
- blob_write_uint32(ctx->blob, var->state_slots[i].swizzle);
+ blob_write_bytes(ctx->blob, &var->state_slots[i],
+ sizeof(var->state_slots[i]));
}
blob_write_uint32(ctx->blob, !!(var->constant_initializer));
if (var->constant_initializer)
@@ -179,9 +178,8 @@ read_variable(read_ctx *ctx)
var->state_slots = ralloc_array(var, nir_state_slot,
var->num_state_slots);
for (unsigned i = 0; i < var->num_state_slots; i++) {
- for (unsigned j = 0; j < STATE_LENGTH; j++)
- var->state_slots[i].tokens[j] = blob_read_uint32(ctx->blob);
- var->state_slots[i].swizzle = blob_read_uint32(ctx->blob);
+ blob_copy_bytes(ctx->blob, &var->state_slots[i],
+ sizeof(var->state_slots[i]));
}
}
bool has_const_initializer = blob_read_uint32(ctx->blob);