On Mon, Aug 10, 2015 at 4:35 AM, Neil Roberts <[email protected]> wrote: > Jason Ekstrand <[email protected]> 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.
You're right. I probably shouldn't worry about x >> 0. > 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. That's not quite right. The first if statement is to "sanitize" the value. For an 8-bit snorm, they could pass in -128 which is slightly less than -1.0 and we want them to get -127 (-1.0) back out. > Either way, > > Reviewed-by: Neil Roberts <[email protected]> Thanks! > > Regards, > - Neil _______________________________________________ mesa-dev mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/mesa-dev
