diff options
author | Jason Ekstrand <[email protected]> | 2015-01-09 20:01:13 -0800 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-01-15 07:20:24 -0800 |
commit | 4aa6162f6ecf96c7400c17c310eba0cfd0f5e083 (patch) | |
tree | bf3038964219161441349f7881224dc733a937fe /src/glsl/nir/nir_lower_samplers.cpp | |
parent | dcb1acdea00a8f2c29777ff4078832df9d5b40ce (diff) |
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 <[email protected]>
Diffstat (limited to 'src/glsl/nir/nir_lower_samplers.cpp')
-rw-r--r-- | src/glsl/nir/nir_lower_samplers.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/glsl/nir/nir_lower_samplers.cpp b/src/glsl/nir/nir_lower_samplers.cpp index 5e90a4ce82e..99f31fc0281 100644 --- a/src/glsl/nir/nir_lower_samplers.cpp +++ b/src/glsl/nir/nir_lower_samplers.cpp @@ -94,12 +94,15 @@ 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); + 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], + nir_instr_rewrite_src(&instr->instr, + &instr->src[instr->num_srcs - 1].src, nir_src_copy(deref_array->indirect, mem_ctx)); - instr->src_type[instr->num_srcs] = nir_tex_src_sampler_offset; - instr->num_srcs++; instr->sampler_array_size = glsl_get_length(deref->type); |