[Mesa-dev] [PATCH] tgsi/lowering: add support to lower TXP
Ilia Mirkin
imirkin at alum.mit.edu
Sat Dec 6 13:01:26 PST 2014
On Sat, Dec 6, 2014 at 3:27 PM, Rob Clark <robdclark at gmail.com> wrote:
> From: Rob Clark <robclark at freedesktop.org>
>
> Signed-off-by: Rob Clark <robclark at freedesktop.org>
> ---
> For adreno a4xx, we need to lower all TXP, for a3xx, we need to just
> lower for certain texture types.
Seems reasonable. Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>
>
> src/gallium/auxiliary/tgsi/tgsi_lowering.c | 35 ++++++++++++++++++++----------
> src/gallium/auxiliary/tgsi/tgsi_lowering.h | 3 +++
> 2 files changed, 27 insertions(+), 11 deletions(-)
>
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_lowering.c b/src/gallium/auxiliary/tgsi/tgsi_lowering.c
> index b6b18db..079a0ebe 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_lowering.c
> +++ b/src/gallium/auxiliary/tgsi/tgsi_lowering.c
> @@ -1031,7 +1031,10 @@ transform_samp(struct tgsi_transform_context *tctx,
> struct tgsi_full_instruction new_inst;
> /* mask is clamped coords, pmask is all coords (for projection): */
> unsigned mask = 0, pmask = 0, smask;
> + unsigned tex = inst->Texture.Texture;
> unsigned opcode = inst->Instruction.Opcode;
> + bool lower_txp = (opcode == TGSI_OPCODE_TXP) &&
> + (ctx->config->lower_TXP & (1 << tex));
>
> if (opcode == TGSI_OPCODE_TXB2) {
> samp = &inst->Src[2];
> @@ -1043,14 +1046,14 @@ transform_samp(struct tgsi_transform_context *tctx,
> smask = 1 << samp->Register.Index;
>
> /* check if we actually need to lower this one: */
> - if (!(ctx->saturate & smask))
> + if (!(ctx->saturate & smask) && !lower_txp)
> return -1;
>
> /* figure out which coordinates need saturating:
> * - RECT textures should not get saturated
> * - array index coords should not get saturated
> */
> - switch (inst->Texture.Texture) {
> + switch (tex) {
> case TGSI_TEXTURE_3D:
> case TGSI_TEXTURE_CUBE:
> case TGSI_TEXTURE_CUBE_ARRAY:
> @@ -1090,7 +1093,7 @@ transform_samp(struct tgsi_transform_context *tctx,
> /* sanity check.. driver could be asking to saturate a non-
> * existent coordinate component:
> */
> - if (!mask)
> + if (!mask && !lower_txp)
> return -1;
>
> /* MOV tmpA, src0 */
> @@ -1126,8 +1129,10 @@ transform_samp(struct tgsi_transform_context *tctx,
> }
>
> /* MOV_SAT tmpA.<mask>, tmpA */
> - create_mov(tctx, &ctx->tmp[A].dst, &ctx->tmp[A].src, mask,
> - TGSI_SAT_ZERO_ONE);
> + if (mask) {
> + create_mov(tctx, &ctx->tmp[A].dst, &ctx->tmp[A].src, mask,
> + TGSI_SAT_ZERO_ONE);
> + }
>
> /* modify the texture samp instruction to take fixed up coord: */
> new_inst = *inst;
> @@ -1462,6 +1467,7 @@ tgsi_transform_lowering(const struct tgsi_lowering_config *config,
> OPCS(DPH) ||
> OPCS(DP2) ||
> OPCS(DP2A) ||
> + OPCS(TXP) ||
> ctx.two_side_colors ||
> ctx.saturate))
> return NULL;
> @@ -1529,12 +1535,19 @@ tgsi_transform_lowering(const struct tgsi_lowering_config *config,
> newlen += DP2A_GROW * OPCS(DP2A);
> numtmp = MAX2(numtmp, DOTP_TMP);
> }
> - if (ctx.saturate) {
> - int n = info->opcode_count[TGSI_OPCODE_TEX] +
> - info->opcode_count[TGSI_OPCODE_TXP] +
> - info->opcode_count[TGSI_OPCODE_TXB] +
> - info->opcode_count[TGSI_OPCODE_TXB2] +
> - info->opcode_count[TGSI_OPCODE_TXL];
> + if (ctx.saturate || config->lower_TXP) {
> + int n = 0;
> +
> + if (ctx.saturate) {
> + n = info->opcode_count[TGSI_OPCODE_TEX] +
> + info->opcode_count[TGSI_OPCODE_TXP] +
> + info->opcode_count[TGSI_OPCODE_TXB] +
> + info->opcode_count[TGSI_OPCODE_TXB2] +
> + info->opcode_count[TGSI_OPCODE_TXL];
> + } else if (config->lower_TXP) {
> + n = info->opcode_count[TGSI_OPCODE_TXP];
> + }
> +
> newlen += SAMP_GROW * n;
> numtmp = MAX2(numtmp, SAMP_TMP);
> }
> diff --git a/src/gallium/auxiliary/tgsi/tgsi_lowering.h b/src/gallium/auxiliary/tgsi/tgsi_lowering.h
> index 55e1507..52c204f 100644
> --- a/src/gallium/auxiliary/tgsi/tgsi_lowering.h
> +++ b/src/gallium/auxiliary/tgsi/tgsi_lowering.h
> @@ -69,6 +69,9 @@ struct tgsi_lowering_config
> unsigned lower_DP2:1;
> unsigned lower_DP2A:1;
>
> + /* bitmask of (1 << TGSI_TEXTURE_type): */
> + unsigned lower_TXP;
> +
> /* To emulate certain texture wrap modes, this can be used
> * to saturate the specified tex coord to [0.0, 1.0]. The
> * bits are according to sampler #, ie. if, for example:
> --
> 1.9.3
>
More information about the mesa-dev
mailing list