aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/nir/nir.h8
-rw-r--r--src/compiler/nir/nir_clone.c6
-rw-r--r--src/compiler/nir/nir_intrinsics.py2
-rw-r--r--src/compiler/nir/nir_serialize.c12
-rw-r--r--src/compiler/nir/nir_sweep.c2
5 files changed, 30 insertions, 0 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index e35bef612df..cc5f88d6f54 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2067,6 +2067,14 @@ typedef struct nir_shader {
* access plus one
*/
unsigned num_inputs, num_uniforms, num_outputs, num_shared;
+
+ /** Constant data associated with this shader.
+ *
+ * Constant data is loaded through load_constant intrinsics. See also
+ * nir_opt_large_constants.
+ */
+ void *constant_data;
+ unsigned constant_data_size;
} nir_shader;
static inline nir_function_impl *
diff --git a/src/compiler/nir/nir_clone.c b/src/compiler/nir/nir_clone.c
index 23bb17eeba3..989c5051a54 100644
--- a/src/compiler/nir/nir_clone.c
+++ b/src/compiler/nir/nir_clone.c
@@ -734,6 +734,12 @@ nir_shader_clone(void *mem_ctx, const nir_shader *s)
ns->num_outputs = s->num_outputs;
ns->num_shared = s->num_shared;
+ ns->constant_data_size = s->constant_data_size;
+ if (s->constant_data_size > 0) {
+ ns->constant_data = ralloc_size(ns, s->constant_data_size);
+ memcpy(ns->constant_data, s->constant_data, s->constant_data_size);
+ }
+
free_clone_state(&state);
return ns;
diff --git a/src/compiler/nir/nir_intrinsics.py b/src/compiler/nir/nir_intrinsics.py
index d9d0bbdfccf..44a5b76beb6 100644
--- a/src/compiler/nir/nir_intrinsics.py
+++ b/src/compiler/nir/nir_intrinsics.py
@@ -532,6 +532,8 @@ load("per_vertex_output", 2, [BASE, COMPONENT], [CAN_ELIMINATE])
load("shared", 1, [BASE], [CAN_ELIMINATE])
# src[] = { offset }. const_index[] = { base, range }
load("push_constant", 1, [BASE, RANGE], [CAN_ELIMINATE, CAN_REORDER])
+# src[] = { offset }. const_index[] = { base, range }
+load("constant", 1, [BASE, RANGE], [CAN_ELIMINATE, CAN_REORDER])
# Stores work the same way as loads, except now the first source is the value
# to store and the second (and possibly third) source specify where to store
diff --git a/src/compiler/nir/nir_serialize.c b/src/compiler/nir/nir_serialize.c
index cc4bf23aa0f..6a30738c2d7 100644
--- a/src/compiler/nir/nir_serialize.c
+++ b/src/compiler/nir/nir_serialize.c
@@ -1116,6 +1116,10 @@ nir_serialize(struct blob *blob, const nir_shader *nir)
write_function_impl(&ctx, fxn->impl);
}
+ blob_write_uint32(blob, nir->constant_data_size);
+ if (nir->constant_data_size > 0)
+ blob_write_bytes(blob, nir->constant_data, nir->constant_data_size);
+
*(uintptr_t *)(blob->data + idx_size_offset) = ctx.next_idx;
_mesa_hash_table_destroy(ctx.remap_table, NULL);
@@ -1169,6 +1173,14 @@ nir_deserialize(void *mem_ctx,
nir_foreach_function(fxn, ctx.nir)
fxn->impl = read_function_impl(&ctx, fxn);
+ ctx.nir->constant_data_size = blob_read_uint32(blob);
+ if (ctx.nir->constant_data_size > 0) {
+ ctx.nir->constant_data =
+ ralloc_size(ctx.nir, ctx.nir->constant_data_size);
+ blob_copy_bytes(blob, ctx.nir->constant_data,
+ ctx.nir->constant_data_size);
+ }
+
free(ctx.idx_table);
return ctx.nir;
diff --git a/src/compiler/nir/nir_sweep.c b/src/compiler/nir/nir_sweep.c
index b14bf139c1b..aab641388db 100644
--- a/src/compiler/nir/nir_sweep.c
+++ b/src/compiler/nir/nir_sweep.c
@@ -167,6 +167,8 @@ nir_sweep(nir_shader *nir)
sweep_function(nir, func);
}
+ ralloc_steal(nir, nir->constant_data);
+
/* Free everything we didn't steal back. */
ralloc_free(rubbish);
}