On Mon, May 11, 2015 at 4:50 AM, Tapani Pälli <tapani.pa...@intel.com> wrote: > This fixes bugs with special cases where we have arrays of > structures containing samplers or arrays of samplers. > > I've verified that patch results in calculating same index value as > returned by _mesa_get_sampler_uniform_value for IR. Patch makes > following ES3 conformance test pass: > > ES3-CTS.shaders.struct.uniform.sampler_array_fragment > > v2: remove unnecessary comment (Topi) > simplify changes and the overall code (Jason)
This looks way better! Thanks for working on this Tapani! Assuming this passes piglit, Reviewed-by: Jason Ekstrand <jason.ekstr...@intel.com> > Signed-off-by: Tapani Pälli <tapani.pa...@intel.com> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90114 > --- > src/glsl/nir/nir_lower_samplers.cpp | 31 ++++++++++++------------------- > 1 file changed, 12 insertions(+), 19 deletions(-) > > diff --git a/src/glsl/nir/nir_lower_samplers.cpp > b/src/glsl/nir/nir_lower_samplers.cpp > index 8fc5909..7a0b0a0 100644 > --- a/src/glsl/nir/nir_lower_samplers.cpp > +++ b/src/glsl/nir/nir_lower_samplers.cpp > @@ -70,19 +70,22 @@ lower_sampler(nir_tex_instr *instr, const struct > gl_shader_program *shader_progr > case nir_deref_type_array: { > nir_deref_array *deref_array = nir_deref_as_array(deref->child); > > + assert(deref_array->deref_array_type != > nir_deref_array_type_wildcard); > + > + if (deref_array->deref.child) { > + ralloc_asprintf_append(&name, "[%u]", > + deref_array->deref_array_type == nir_deref_array_type_direct ? > + deref_array->base_offset : 0); > + } else { > + assert(deref->child->type->base_type == GLSL_TYPE_SAMPLER); > + instr->sampler_index = deref_array->base_offset; > + } > + > /* XXX: We're assuming here that the indirect is the last array > * thing we have. This should be ok for now as we don't support > * arrays_of_arrays yet. > */ > - > - instr->sampler_index *= glsl_get_length(deref->type); > - switch (deref_array->deref_array_type) { > - case nir_deref_array_type_direct: > - instr->sampler_index += deref_array->base_offset; > - if (deref_array->deref.child) > - ralloc_asprintf_append(&name, "[%u]", > deref_array->base_offset); > - break; > - case nir_deref_array_type_indirect: { > + if (deref_array->deref_array_type == nir_deref_array_type_indirect) > { > /* First, we have to resize the array of texture sources */ > nir_tex_src *new_srcs = rzalloc_array(instr, nir_tex_src, > instr->num_srcs + 1); > @@ -106,16 +109,6 @@ lower_sampler(nir_tex_instr *instr, const struct > gl_shader_program *shader_progr > &deref_array->indirect); > > instr->sampler_array_size = glsl_get_length(deref->type); > - > - if (deref_array->deref.child) > - ralloc_strcat(&name, "[0]"); > - break; > - } > - > - case nir_deref_array_type_wildcard: > - unreachable("Cannot copy samplers"); > - default: > - unreachable("Invalid deref array type"); > } > break; > } > -- > 2.1.0 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev