[Mesa-dev] [PATCH] prog_to_nir: Make RSQ properly take the absolute value of its argument.

Francisco Jerez currojerez at riseup.net
Thu Jun 4 02:10:57 PDT 2015


Kenneth Graunke <kenneth at whitecape.org> writes:

> I just botched this when writing the original code.
>
> From the ARB_vertex_program specification:
> "The RSQ instruction approximates the reciprocal of the square root of
>  the absolute value of the scalar operand and replicates it to all four
>  components of the result vector."
>
> Fixes a Glean vertProg1 subtest:
> RSQ test 2 (reciprocal square root of negative value)
>
> Cc: mesa-stable at lists.freedesktop.org
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90547
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>

Reviewed-by: Francisco Jerez <currojerez at riseup.net>

> ---
>  src/mesa/program/prog_to_nir.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/mesa/program/prog_to_nir.c b/src/mesa/program/prog_to_nir.c
> index e986e51..d3e3f15 100644
> --- a/src/mesa/program/prog_to_nir.c
> +++ b/src/mesa/program/prog_to_nir.c
> @@ -764,7 +764,8 @@ ptn_emit_instruction(struct ptn_compile *c, struct prog_instruction *prog_inst)
>  
>     switch (op) {
>     case OPCODE_RSQ:
> -      ptn_move_dest(b, dest, nir_frsq(b, ptn_channel(b, src[0], X)));
> +      ptn_move_dest(b, dest,
> +                    nir_frsq(b, nir_fabs(b, ptn_channel(b, src[0], X))));
>        break;
>  
>     case OPCODE_RCP:
> -- 
> 2.4.2
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 212 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150604/7daef5ed/attachment.sig>


More information about the mesa-dev mailing list