Mesa (master): mesa/format_utils: Add src_bits == dst_bits cases to unorm_to_unorm
Jason Ekstrand
jekstrand at kemper.freedesktop.org
Mon Aug 10 18:12:07 UTC 2015
Module: Mesa
Branch: master
Commit: 9901aeb1c74648cbe1aa1d18d590a689c844cbad
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9901aeb1c74648cbe1aa1d18d590a689c844cbad
Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date: Sun Aug 9 22:03:00 2015 -0700
mesa/format_utils: Add src_bits == dst_bits cases to unorm_to_unorm
This better ensures that the src_bits == dst_bits case gets optimized away.
Reviewed-by: Neil Roberts <neil at linux.intel.com>
Reviewed-by: Roland Scheidegger <sroland at vmware.com>
---
src/mesa/main/format_utils.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/mesa/main/format_utils.h b/src/mesa/main/format_utils.h
index 00ec777..618f43d 100644
--- a/src/mesa/main/format_utils.h
+++ b/src/mesa/main/format_utils.h
@@ -99,7 +99,7 @@ _mesa_unorm_to_unorm(unsigned x, unsigned src_bits, unsigned dst_bits)
{
if (src_bits < dst_bits) {
return EXTEND_NORMALIZED_INT(x, src_bits, dst_bits);
- } else {
+ } else if (src_bits > dst_bits) {
unsigned src_half = (1 << (src_bits - 1)) - 1;
if (src_bits + dst_bits > sizeof(x) * 8) {
@@ -109,6 +109,8 @@ _mesa_unorm_to_unorm(unsigned x, unsigned src_bits, unsigned dst_bits)
} else {
return (x * MAX_UINT(dst_bits) + src_half) / MAX_UINT(src_bits);
}
+ } else {
+ return x;
}
}
More information about the mesa-commit
mailing list