On Fri, Mar 30, 2018 at 9:35 PM, Eric Anholt <e...@anholt.net> wrote:
> Karol Herbst <kher...@redhat.com> writes:
>
>> Nvidia hardware can do that natively so there is no need to lower that to 
>> four
>> TG4s instructions.
>>
>> Signed-off-by: Karol Herbst <kher...@redhat.com>
>> ---
>>  src/compiler/glsl/glsl_to_nir.cpp | 25 ++++++++++++++++++-------
>>  src/compiler/nir/nir.h            |  9 ++++++++-
>>  src/compiler/nir/nir_print.c      |  9 +++++++++
>>  3 files changed, 35 insertions(+), 8 deletions(-)
>>
>> diff --git a/src/compiler/glsl/glsl_to_nir.cpp 
>> b/src/compiler/glsl/glsl_to_nir.cpp
>> index c4a6d52a5b2..4ea5f1616a7 100644
>> --- a/src/compiler/glsl/glsl_to_nir.cpp
>> +++ b/src/compiler/glsl/glsl_to_nir.cpp
>> @@ -2042,7 +2042,9 @@ nir_visitor::visit(ir_texture *ir)
>>        num_srcs++;
>>     if (ir->shadow_comparator != NULL)
>>        num_srcs++;
>> -   if (ir->offset != NULL)
>> +   if (ir->offset != NULL && ir->offset->type->is_array())
>> +      num_srcs += ir->offset->type->array_size();
>> +   else if (ir->offset != NULL)
>>        num_srcs++;
>>
>>     nir_tex_instr *instr = nir_tex_instr_create(this->shader, num_srcs);
>> @@ -2097,12 +2099,21 @@ nir_visitor::visit(ir_texture *ir)
>>
>>     if (ir->offset != NULL) {
>>        /* we don't support multiple offsets yet */
>> -      assert(ir->offset->type->is_vector() || 
>> ir->offset->type->is_scalar());
>> -
>> -      instr->src[src_number].src =
>> -         nir_src_for_ssa(evaluate_rvalue(ir->offset));
>> -      instr->src[src_number].src_type = nir_tex_src_offset;
>> -      src_number++;
>> +      if (ir->offset->type->is_vector() || ir->offset->type->is_scalar()) {
>> +         instr->src[src_number].src =
>> +            nir_src_for_ssa(evaluate_rvalue(ir->offset));
>> +         instr->src[src_number].src_type = nir_tex_src_offset;
>> +         src_number++;
>> +      } else if (ir->offset->type->is_array()) {
>> +         for (int i = 0; i < ir->offset->type->array_size(); i++) {
>> +            instr->src[src_number].src =
>> +               
>> nir_src_for_ssa(evaluate_rvalue(ir->offset->as_constant()->get_array_element(i)->as_rvalue()));
>> +            instr->src[src_number].src_type = 
>> (nir_tex_src_type)(nir_tex_src_offset + i);
>> +            src_number++;
>> +         }
>> +      } else {
>> +         assert(false);
>
> Maybe just do assert(ir->offset->type->is_array()) in the previous block
> instead of the extra else.  And optionally pull
> ir->offset->as_constant() out to a temporary for nicer column wrapping.
> Other than that, this seems good.
>

well the thing is, it only works with constants within the array. If
you have non constant values the code wouldn't assert on that. But I
will try to think about something nice there.

> Reviewed-by: Eric Anholt <e...@anholt.net>
>
> If I'm reading my specs right, I'll be able to use this on vc6, too.
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to