mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 02:28:10 +02:00
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@linux.intel.com> Reviewed-by: Roland Scheidegger <sroland@vmware.com>
This commit is contained in:
parent
7e5d56394b
commit
9901aeb1c7
1 changed files with 3 additions and 1 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue