[Mesa-dev] [PATCH] mesa/format_utils: Add src_bits == dst_bits cases to [us]norm functions

Neil Roberts neil at linux.intel.com
Mon Aug 10 04:35:54 PDT 2015


Jason Ekstrand <jason at jlekstrand.net> writes:

> @@ -151,8 +153,10 @@ _mesa_snorm_to_snorm(int x, unsigned src_bits, unsigned dst_bits)
>        return -MAX_INT(dst_bits);
>     else if (src_bits < dst_bits)
>        return EXTEND_NORMALIZED_INT(x, src_bits - 1, dst_bits - 1);
> -   else
> +   else if (src_bits > dst_bits)
>        return x >> (src_bits - dst_bits);
> +   else
> +      return x;
>  }

This part seems pretty unnecessary as it seems pretty unlikely that a
compiler couldn't optimise away x >> 0. However I'm happy if you want to
land it anyway for consistency.

If you wanted to optimise it a bit more you could move the
if(src_bits==dst_bits) to above the first if statement because I think
it would be tricky the for the compiler to optimise that away.

Either way,

Reviewed-by: Neil Roberts <neil at linux.intel.com>

Regards,
- Neil


More information about the mesa-dev mailing list