[Mesa-dev] [PATCH 34/53] st/nine: Implement TEXCOORD special behaviours

Ilia Mirkin imirkin at alum.mit.edu
Wed Jan 7 16:56:44 PST 2015


On Wed, Jan 7, 2015 at 11:36 AM, Axel Davy <axel.davy at ens.fr> wrote:
> texcoord for ps < 1_4 should clamp between 0 and 1 the values.
>
> texcrd (texcoord ps 1_4) does not clamp and can be used with
> two modifiers _dw and _dz that means the channels are divided
> by w or z.
> Implement those in shared code, since the same modifiers can be used
> for texld ps 1_4.
>
> Signed-off-by: Axel Davy <axel.davy at ens.fr>
>
> Cc: "10.4" <mesa-stable at lists.freedesktop.org>
> ---
>  src/gallium/state_trackers/nine/nine_shader.c | 29 ++++++++++++++++++++++-----
>  1 file changed, 24 insertions(+), 5 deletions(-)
>
> diff --git a/src/gallium/state_trackers/nine/nine_shader.c b/src/gallium/state_trackers/nine/nine_shader.c
> index 899aee8..cf3f646 100644
> --- a/src/gallium/state_trackers/nine/nine_shader.c
> +++ b/src/gallium/state_trackers/nine/nine_shader.c
> @@ -937,6 +937,23 @@ tx_src_param(struct shader_translator *tx, const struct sm1_src_param *param)
>      if (param->rel)
>          src = ureg_src_indirect(src, tx_src_param(tx, param->rel));
>
> +    switch (param->mod) {
> +    case NINED3DSPSM_DW:
> +        tmp = tx_scratch(tx);
> +        ureg_MOV(ureg, tmp, src);
> +        ureg_DIV(ureg, tmp, ureg_src(tmp), ureg_swizzle(ureg_src(tmp), NINE_SWIZZLE4(W,W,W,W)));

Is DIV supported everywhere? You could do this as

tmp = RCP(thing)
tmp = MUL(tmp, src)

> +        src = ureg_src(tmp);
> +        break;
> +    case NINED3DSPSM_DZ:
> +        tmp = tx_scratch(tx);
> +        ureg_MOV(ureg, tmp, src);
> +        ureg_DIV(ureg, tmp, ureg_src(tmp), ureg_swizzle(ureg_src(tmp), NINE_SWIZZLE4(Z,Z,Z,Z)));
> +        src = ureg_src(tmp);
> +        break;
> +    default:
> +        break;
> +    }
> +
>      if (param->swizzle != NINED3DSP_NOSWIZZLE)
>          src = ureg_swizzle(src,
>                             (param->swizzle >> 0) & 0x3,
> @@ -979,7 +996,7 @@ tx_src_param(struct shader_translator *tx, const struct sm1_src_param *param)
>          break;
>      case NINED3DSPSM_DZ:
>      case NINED3DSPSM_DW:
> -        /* handled in instruction */
> +        /* Already handled*/
>          break;
>      case NINED3DSPSM_SIGN:
>          tmp = tx_scratch(tx);
> @@ -2049,7 +2066,8 @@ DECL_SPECIAL(TEXCOORD)
>      struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]);
>
>      tx_texcoord_alloc(tx, s);
> -    ureg_MOV(ureg, dst, tx->regs.vT[s]); /* XXX is this sufficient ? */
> +    ureg_MOV(ureg, ureg_writemask(ureg_saturate(dst), TGSI_WRITEMASK_XYZ), tx->regs.vT[s]);
> +    ureg_MOV(ureg, ureg_writemask(dst, TGSI_WRITEMASK_W), ureg_imm1f(tx->ureg, 1.0f));
>
>      return D3D_OK;
>  }
> @@ -2057,11 +2075,12 @@ DECL_SPECIAL(TEXCOORD)
>  DECL_SPECIAL(TEXCOORD_ps14)
>  {
>      struct ureg_program *ureg = tx->ureg;
> -    const unsigned s = tx->insn.src[0].idx;
> +    struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]);
>      struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]);
>
> -    tx_texcoord_alloc(tx, s);
> -    ureg_MOV(ureg, dst, tx->regs.vT[s]); /* XXX is this sufficient ? */
> +    assert(tx->insn.src[0].file == D3DSPR_TEXTURE);
> +
> +    ureg_MOV(ureg, dst, src);
>
>      return D3D_OK;
>  }
> --
> 2.1.3
>
> _______________________________________________
> 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