diff options
author | Kenneth Graunke <[email protected]> | 2015-03-25 02:11:52 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2015-03-27 21:16:33 -0700 |
commit | 75c922e0fed41acf28318b082f7f915c752ffe74 (patch) | |
tree | c32699d617b848d4b163a2ef981db84926036c6e /src/glsl/nir/nir_builder.h | |
parent | 74fd226e34d0cf5e9ff43174ae69b4a66f5de1ab (diff) |
nir: Add nir_builder helpers for creating load_const intrinsics.
Both prog->nir and tgsi->nir will want to use these.
Signed-off-by: Kenneth Graunke <[email protected]>
Reviewed-by: Connor Abbott <[email protected]>
Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/glsl/nir/nir_builder.h')
-rw-r--r-- | src/glsl/nir/nir_builder.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/glsl/nir/nir_builder.h b/src/glsl/nir/nir_builder.h index 7c4f7fd96cd..fe6cb37c439 100644 --- a/src/glsl/nir/nir_builder.h +++ b/src/glsl/nir/nir_builder.h @@ -47,6 +47,41 @@ nir_builder_insert_after_cf_list(nir_builder *build, build->cf_node_list = cf_node_list; } +static inline nir_ssa_def * +nir_build_imm(nir_builder *build, unsigned num_components, nir_const_value value) +{ + nir_load_const_instr *load_const = + nir_load_const_instr_create(build->shader, num_components); + if (!load_const) + return NULL; + + load_const->value = value; + + nir_instr_insert_after_cf_list(build->cf_node_list, &load_const->instr); + + return &load_const->def; +} + +static inline nir_ssa_def * +nir_imm_float(nir_builder *build, float x) +{ + nir_const_value v = { { .f = {x, 0, 0, 0} } }; + return nir_build_imm(build, 1, v); +} + +static inline nir_ssa_def * +nir_imm_vec4(nir_builder *build, float x, float y, float z, float w) +{ + nir_const_value v = { { .f = {x, y, z, w} } }; + return nir_build_imm(build, 4, v); +} + +static inline nir_ssa_def * +nir_imm_int(nir_builder *build, int x) +{ + nir_const_value v = { { .i = {x, 0, 0, 0} } }; + return nir_build_imm(build, 1, v); +} static inline nir_ssa_def * nir_build_alu(nir_builder *build, nir_op op, nir_ssa_def *src0, |