diff options
author | Jason Ekstrand <[email protected]> | 2017-10-16 08:50:23 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2017-10-17 07:36:00 -0700 |
commit | 41c75b5354e5d4382786ff853f6f5143a0fe4c6d (patch) | |
tree | caa4501a38cb4bf61dd0652c7f9cf85800bb3fb0 /src/compiler/nir/nir.c | |
parent | 31fb7bbe0be83b2ad769568829a006855639bee8 (diff) |
nir: Add a helper for adding texture instruction sources
Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir.c')
-rw-r--r-- | src/compiler/nir/nir.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index afd4d1a7236..5bc07b7e506 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -542,6 +542,28 @@ nir_tex_instr_create(nir_shader *shader, unsigned num_srcs) } void +nir_tex_instr_add_src(nir_tex_instr *tex, + nir_tex_src_type src_type, + nir_src src) +{ + nir_tex_src *new_srcs = rzalloc_array(tex, nir_tex_src, + tex->num_srcs + 1); + + for (unsigned i = 0; i < tex->num_srcs; i++) { + new_srcs[i].src_type = tex->src[i].src_type; + nir_instr_move_src(&tex->instr, &new_srcs[i].src, + &tex->src[i].src); + } + + ralloc_free(tex->src); + tex->src = new_srcs; + + tex->src[tex->num_srcs].src_type = src_type; + nir_instr_rewrite_src(&tex->instr, &tex->src[tex->num_srcs].src, src); + tex->num_srcs++; +} + +void nir_tex_instr_remove_src(nir_tex_instr *tex, unsigned src_idx) { assert(src_idx < tex->num_srcs); |