summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_lower_samplers.c
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2017-10-16 08:50:23 -0700
committerJason Ekstrand <[email protected]>2017-10-17 07:36:00 -0700
commit41c75b5354e5d4382786ff853f6f5143a0fe4c6d (patch)
treecaa4501a38cb4bf61dd0652c7f9cf85800bb3fb0 /src/compiler/nir/nir_lower_samplers.c
parent31fb7bbe0be83b2ad769568829a006855639bee8 (diff)
nir: Add a helper for adding texture instruction sources
Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_lower_samplers.c')
-rw-r--r--src/compiler/nir/nir_lower_samplers.c27
1 files changed, 2 insertions, 25 deletions
diff --git a/src/compiler/nir/nir_lower_samplers.c b/src/compiler/nir/nir_lower_samplers.c
index 0c4e91b000f..f75fb1afe88 100644
--- a/src/compiler/nir/nir_lower_samplers.c
+++ b/src/compiler/nir/nir_lower_samplers.c
@@ -109,32 +109,9 @@ lower_sampler(nir_tex_instr *instr, const struct gl_shader_program *shader_progr
assert(array_elements >= 1);
indirect = nir_umin(b, indirect, nir_imm_int(b, array_elements - 1));
- /* First, we have to resize the array of texture sources */
- nir_tex_src *new_srcs = rzalloc_array(instr, nir_tex_src,
- instr->num_srcs + 2);
-
- for (unsigned i = 0; i < instr->num_srcs; i++) {
- new_srcs[i].src_type = instr->src[i].src_type;
- nir_instr_move_src(&instr->instr, &new_srcs[i].src,
- &instr->src[i].src);
- }
-
- ralloc_free(instr->src);
- instr->src = new_srcs;
-
- /* Now we can go ahead and move the source over to being a
- * first-class texture source.
- */
- instr->src[instr->num_srcs].src_type = nir_tex_src_texture_offset;
- instr->num_srcs++;
- nir_instr_rewrite_src(&instr->instr,
- &instr->src[instr->num_srcs - 1].src,
+ nir_tex_instr_add_src(instr, nir_tex_src_texture_offset,
nir_src_for_ssa(indirect));
-
- instr->src[instr->num_srcs].src_type = nir_tex_src_sampler_offset;
- instr->num_srcs++;
- nir_instr_rewrite_src(&instr->instr,
- &instr->src[instr->num_srcs - 1].src,
+ nir_tex_instr_add_src(instr, nir_tex_src_sampler_offset,
nir_src_for_ssa(indirect));
instr->texture_array_size = array_elements;