nir/tex_instr: Add a nir_tex_src struct and dynamically allocate the src array

This solves a number of problems.  First is the ability to change the
number of sources that a texture instruction has.  Second, it solves the
delema that may occur if a texture instruction has more than 4 sources.

Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
This commit is contained in:
Jason Ekstrand
2015-01-09 20:01:13 -08:00
parent dcb1acdea0
commit 4aa6162f6e
7 changed files with 51 additions and 43 deletions

View File

@@ -94,13 +94,16 @@ lower_sampler(nir_tex_instr *instr, struct gl_shader_program *shader_program,
case nir_deref_array_type_indirect: {
assert(!has_indirect);
assert(instr->num_srcs < 4);
nir_instr_rewrite_src(&instr->instr, &instr->src[instr->num_srcs],
nir_src_copy(deref_array->indirect, mem_ctx));
instr->src_type[instr->num_srcs] = nir_tex_src_sampler_offset;
instr->src = reralloc(mem_ctx, instr->src, nir_tex_src,
instr->num_srcs + 1);
memset(&instr->src[instr->num_srcs], 0, sizeof *instr->src);
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_src_copy(deref_array->indirect, mem_ctx));
instr->sampler_array_size = glsl_get_length(deref->type);
nir_src empty;