summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_lower_samplers.c
diff options
context:
space:
mode:
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;