[Mesa-dev] [PATCH] radv: Translate x/y to x*(1.0/y).

Connor Abbott cwabbott0 at gmail.com
Sat Apr 22 20:46:18 UTC 2017


You can also set lower_fdiv in nir_shader_compiler_options, and then
NIR will do this for you, plus NIR's algebraic optimizations will have
the chance to work on the lowered form. Your choice though.

On Sat, Apr 22, 2017 at 3:55 PM, Bas Nieuwenhuizen
<bas at basnieuwenhuizen.nl> wrote:
> Moves from accurate divides to rcp and rsq. No new CTS failures.
>
> Signed-off-by: Bas Nieuwenhuizen <basni at google.com>
> ---
>  src/amd/common/ac_nir_to_llvm.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
> index 514c9e9ca35..081a2c2d26e 100644
> --- a/src/amd/common/ac_nir_to_llvm.c
> +++ b/src/amd/common/ac_nir_to_llvm.c
> @@ -1588,7 +1588,9 @@ static void visit_alu(struct nir_to_llvm_context *ctx, nir_alu_instr *instr)
>         case nir_op_fdiv:
>                 src[0] = to_float(ctx, src[0]);
>                 src[1] = to_float(ctx, src[1]);
> -               result = ac_build_fdiv(&ctx->ac, src[0], src[1]);
> +
> +               result = ac_build_fdiv(&ctx->ac, ctx->f32one, src[1]);
> +               result = LLVMBuildFMul(ctx->builder, src[0], result, "");
>                 break;
>         case nir_op_frcp:
>                 src[0] = to_float(ctx, src[0]);
> --
> 2.12.2
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list