diff options
author | Jason Ekstrand <[email protected]> | 2018-06-28 19:16:19 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2018-07-02 12:09:42 -0700 |
commit | c90f221e0a1f89332189dd5ec79dccf6b251ecf5 (patch) | |
tree | b4c2356897c19e02834d0f47d0107492cab6643a /src/compiler/nir/nir_serialize.c | |
parent | e8e159e9df40ee76468e05be073d94ec78d4bf32 (diff) |
nir: Add a concept of constant data associated with a shader
This commit adds a concept to NIR of having a blob of constant data
associated with a shader. Instead of being a UBO or uniform that can be
manipulated by the client, this constant data considered part of the
shader and remains constant across all invocations of the given shader
until the end of time. To access this constant data from the shader, we
add a new load_constant intrinsic. The intention is that drivers will
eventually lower load_constant intrinsics to load_ubo, load_uniform, or
something similar. Constant data will be used by the optimization pass
in the next commit but this concept may also be useful for OpenCL.
v2 (Jason Ekstrand):
- Rename num_constants to constant_data_size (anholt)
Reviewed-by: Timothy Arceri <[email protected]>
Reviewed-by: Iago Toral Quiroga <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_serialize.c')
-rw-r--r-- | src/compiler/nir/nir_serialize.c | 12 |
1 files changed, 12 insertions, 0 deletions
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; |