mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-05-31 12:17:06 +02:00
better unrolled ver
This commit is contained in:
parent
144e20800f
commit
7d591b3bd9
1 changed files with 6 additions and 3 deletions
|
|
@ -589,10 +589,13 @@ static TexelWeightParams DecodeBlockInfo(InputBitStream& strm) {
|
||||||
|
|
||||||
// Replicates low num_bits such that [(to_bit - 1):(to_bit - 1 - from_bit)]
|
// Replicates low num_bits such that [(to_bit - 1):(to_bit - 1 - from_bit)]
|
||||||
// is the same as [(num_bits - 1):0] and repeats all the way down.
|
// is the same as [(num_bits - 1):0] and repeats all the way down.
|
||||||
|
// to_bit range is expected from 0 to 8
|
||||||
|
// num_bits range is from 0 to 7
|
||||||
[[nodiscard]] constexpr u32 Replicate(u32 v, u32 num_bits, u32 to_bit) {
|
[[nodiscard]] constexpr u32 Replicate(u32 v, u32 num_bits, u32 to_bit) {
|
||||||
auto val = v;
|
auto val = v & ((1 << num_bits) - 1);
|
||||||
for (; num_bits < to_bit; num_bits <<= 1)
|
val |= val << (num_bits << 0);
|
||||||
val |= val << u32(num_bits);
|
val |= val << (num_bits << 1);
|
||||||
|
val |= val << (num_bits << 2);
|
||||||
auto const val_mask = u32(1 << to_bit) - 1;
|
auto const val_mask = u32(1 << to_bit) - 1;
|
||||||
return (v & ~val_mask) | (val & val_mask);
|
return (v & ~val_mask) | (val & val_mask);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue