[Mesa-dev] [PATCH] nv50/ir: use round toward 0 when converting doubles to integers

Ilia Mirkin imirkin at alum.mit.edu
Mon Jun 6 19:30:11 UTC 2016


On Mon, Jun 6, 2016 at 3:25 PM, Samuel Pitoiset
<samuel.pitoiset at gmail.com> wrote:
> Like floats, we should use the round toward 0 mode instead of the
> nearest one (which is the default) for doubles to integers.
>
> This fixes all arb_gpu_shader_fp64 piglits which convert doubles to
> integers (16 tests).
>
> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
> Cc: "11.2 12.0" <mesa-stable at lists.freedesktop.org>
> ---
>  src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
> index cd98f70..fcd4b22 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
> @@ -3598,7 +3598,11 @@ Converter::handleInstruction(const struct tgsi_full_instruction *insn)
>           src0 = fetchSrc(0, pos);
>           src1 = fetchSrc(0, pos + 1);
>           mkOp2(OP_MERGE, TYPE_U64, dreg, src0, src1);
> -         mkCvt(OP_CVT, dstTy, dst0[c], srcTy, dreg);
> +         Instruction *cvt = mkCvt(OP_CVT, dstTy, dst0[c], srcTy, dreg);
> +         if (tgsi.getOpcode() == TGSI_OPCODE_D2I ||
> +             tgsi.getOpcode() == TGSI_OPCODE_D2U) {
> +            cvt->rnd = ROUND_Z;
> +         }

How about

if (!isFloatType(dstTy))
  cvt->rnd = ROUND_Z;

That way you're not explicitly listing out the opcodes. With that,

Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>

>           pos += 2;
>        }
>        break;
> --
> 2.8.3
>
> _______________________________________________
> 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