[Mesa-dev] [PATCH 2/3] gallium/ttn: add support for temp arrays

Eric Anholt eric at anholt.net
Thu Apr 9 23:13:25 PDT 2015


Rob Clark <robdclark at gmail.com> writes:
> From: Rob Clark <robclark at freedesktop.org>
>
> Since the rest of NIR really would rather have these as variables rather
> than registers, create a nir_variable per array.  But rather than
> completely re-arrange ttn to be variable based rather than register
> based, keep the registers.  In the cases where there is a matching var
> for the reg, ttn_emit_instruction will append the appropriate intrinsic
> to get things back from the shadow reg into the variable.
>
> NOTE: this doesn't quite handle TEMP[ADDR[]] when the DCL doesn't give
> an array id.  But those just kinda suck, and should really go away.
> AFAICT we don't get those from glsl.  Might be an issue for some other
> state tracker.
>
> v2: rework to use load_var/store_var with deref chains
> v3: create new "burner" reg for temporarily holding the (potentially
> writemask'd) dest after each instruction; add load_var to initialize
> temporary dest in case not all components are overwritten
> +/* generate either a constant or indirect deref chain for accessing an
> + * array variable.
> + */
> +static nir_deref_var *
> +ttn_array_deref(struct ttn_compile *c, nir_variable *var, unsigned offset,
> +                struct tgsi_ind_register *indirect)
> +{
> +   nir_builder *b = &c->build;
> +   nir_deref_var *deref = nir_deref_var_create(b->shader, var);
> +   nir_deref_array *arr = nir_deref_array_create(b->shader);
> +
> +   arr->base_offset = offset;
> +   arr->deref.type = glsl_get_array_element(var->type);
> +
> +   if (indirect) {
> +      arr->deref_array_type = nir_deref_array_type_indirect;
> +      arr->indirect = nir_src_for_reg(c->addr_reg);

I just noticed.  What i should have said here is "this should be
ttn_src_for_indirect(c, indirect)" instead.

> +   } else {
> +      arr->deref_array_type = nir_deref_array_type_direct;
> +   }
> +
> +   deref->deref.child = &arr->deref;
> +
> +   return deref;
> +}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150409/593cc58e/attachment-0001.sig>


More information about the mesa-dev mailing list