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 <tarceri@itsqueeze.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
Jason Ekstrand
2018-06-28 19:16:19 -07:00
parent e8e159e9df
commit c90f221e0a
5 changed files with 30 additions and 0 deletions

View File

@@ -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 *