diff options
author | Jason Ekstrand <[email protected]> | 2015-08-09 22:03:00 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-08-10 11:11:47 -0700 |
commit | 9901aeb1c74648cbe1aa1d18d590a689c844cbad (patch) | |
tree | f1aed71b165ccb8e32fa2d4fd19e2af87940cb5e /src | |
parent | 7e5d56394bd53607d0158b49f36ac1428acb7954 (diff) |
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 <[email protected]>
Reviewed-by: Roland Scheidegger <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/format_utils.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/mesa/main/format_utils.h b/src/mesa/main/format_utils.h index 00ec7774dd2..618f43d0aaa 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; } } |