[Mesa-dev] [PATCH 17/59] i965: fix is_zero(), is_one() and is_negative_one() for doubles

Kenneth Graunke kenneth at whitecape.org
Sat Apr 30 07:19:46 UTC 2016


On Friday, April 29, 2016 1:29:14 PM PDT Samuel Iglesias Gonsálvez wrote:
> From: Connor Abbott <connor.w.abbott at intel.com>
> 
> ---
>  src/mesa/drivers/dri/i965/brw_shader.cpp | 28 ++++++++++++++++++++++++----
>  1 file changed, 24 insertions(+), 4 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/
dri/i965/brw_shader.cpp
> index e5c43d2..d40937b 100644
> --- a/src/mesa/drivers/dri/i965/brw_shader.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
> @@ -664,7 +664,17 @@ backend_reg::is_zero() const
>     if (file != IMM)
>        return false;
>  
> -   return d == 0;
> +   switch (type) {
> +   case BRW_REGISTER_TYPE_F:
> +      return f == 0;

One thing I noticed here is that this will make it return true for -0.0f,
whereas it wouldn't before.  I think that's actually an improvement on
its own right :)

> +   case BRW_REGISTER_TYPE_DF:
> +      return df == 0;
> +   case BRW_REGISTER_TYPE_D:
> +   case BRW_REGISTER_TYPE_UD:
> +      return d == 0;
> +   default:
> +      return false;
> +   }
>  }
>  
>  bool
> @@ -673,9 +683,17 @@ backend_reg::is_one() const
>     if (file != IMM)
>        return false;
>  
> -   return type == BRW_REGISTER_TYPE_F
> -          ? f == 1.0
> -          : d == 1;
> +   switch (type) {
> +   case BRW_REGISTER_TYPE_F:
> +      return f == 1.0f;
> +   case BRW_REGISTER_TYPE_DF:
> +      return df == 1.0;
> +   case BRW_REGISTER_TYPE_D:
> +   case BRW_REGISTER_TYPE_UD:
> +      return d == 1;
> +   default:
> +      return false;
> +   }
>  }
>  
>  bool
> @@ -687,6 +705,8 @@ backend_reg::is_negative_one() const
>     switch (type) {
>     case BRW_REGISTER_TYPE_F:
>        return f == -1.0;
> +   case BRW_REGISTER_TYPE_DF:
> +      return df == -1.0;
>     case BRW_REGISTER_TYPE_D:
>        return d == -1;
>     default:
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160430/5ac9d5c7/attachment.sig>


More information about the mesa-dev mailing list