[Mesa-dev] [PATCH v2 23/78] i965/nir/vec4: Implement load_uniform intrinsic

Jason Ekstrand jason at jlekstrand.net
Fri Jul 24 16:42:10 PDT 2015


On Thu, Jul 23, 2015 at 3:17 AM, Eduardo Lima Mitev <elima at igalia.com> wrote:
> From: Iago Toral Quiroga <itoral at igalia.com>
>
> For the indirect case we need to take the index delivered by
> NIR and compute the parent uniform that we are accessing (the one
> that we uploaded to a surface) and the constant offset into that
> surface.
> ---
>  src/mesa/drivers/dri/i965/brw_vec4_nir.cpp | 26 ++++++++++++++++++++++++--
>  1 file changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
> index 7e37d6b..c7f76e6 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
> @@ -527,10 +527,32 @@ vec4_visitor::nir_emit_intrinsic(nir_intrinsic_instr *instr)
>     }
>
>     case nir_intrinsic_load_uniform_indirect:
> +      has_indirect = true;
>        /* fallthrough */
> -   case nir_intrinsic_load_uniform:
> -      /* @TODO: Not yet implemented */
> +   case nir_intrinsic_load_uniform: {
> +      int uniform = instr->const_index[0];
> +
> +      dest = get_nir_dest(instr->dest);
> +
> +      if (has_indirect) {
> +         /* Split addressing into uniform and offset */
> +         int offset = uniform - nir_uniform_driver_location[uniform];
> +         assert(offset >= 0);
> +
> +         uniform -= offset;

This looks a little interesting.  Why are you subtracting off the
offset and then setting the reg_offset?

To answer my own question, my best guess is that NIR's "everything is
an array" philosophy falls flat on its face in the presence of
indirectly addressable push constants.  If this is the case, then I
can't think of anything better either; keep it.

> +         assert(uniform >= 0);
> +
> +         src = src_reg(dst_reg(UNIFORM, uniform));
> +         src.reg_offset = offset;
> +         src_reg tmp = get_nir_src(instr->src[0], BRW_REGISTER_TYPE_D, 1);
> +         src.reladdr = new(mem_ctx) src_reg(tmp);
> +      } else {
> +         src = src_reg(dst_reg(UNIFORM, uniform));
> +      }
> +
> +      emit(MOV(dest, src));
>        break;
> +   }
>
>     case nir_intrinsic_atomic_counter_read:
>     case nir_intrinsic_atomic_counter_inc:
> --
> 2.1.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list