Fixed an issue with the Owen scramble hash.

Thanks to a tip from Matt Pharr.
This commit is contained in:
Nathan Vegdahl 2021-03-30 15:59:55 +09:00
parent f9deb9afb6
commit 87859f5258
2 changed files with 5 additions and 3 deletions

View File

@ -69,7 +69,7 @@ fn lk_scramble(mut n: u32, scramble: u32) -> u32 {
n = n.wrapping_add(n << 2); n = n.wrapping_add(n << 2);
n ^= n.wrapping_mul(0xfe9b5742); n ^= n.wrapping_mul(0xfe9b5742);
n = n.wrapping_add(scramble); n = n.wrapping_add(scramble);
n = n.wrapping_mul(scramble | 1); n = n.wrapping_mul((scramble >> 16) | 1);
n n
} }
@ -82,7 +82,7 @@ fn lk_scramble_int4(mut n: Int4, scramble: u32) -> Int4 {
n += n << 2; n += n << 2;
n ^= n * [0xfe9b5742; 4].into(); n ^= n * [0xfe9b5742; 4].into();
n += scramble; n += scramble;
n *= scramble | [1; 4].into(); n *= (scramble >> 16) | [1; 4].into();
n n
} }

View File

@ -22,7 +22,9 @@ pub(crate) mod sse {
} }
} }
pub fn get(self, i: usize) -> u32 { /// For testing.
#[allow(dead_code)]
fn get(self, i: usize) -> u32 {
let n: [u32; 4] = unsafe { std::mem::transmute(self) }; let n: [u32; 4] = unsafe { std::mem::transmute(self) };
n[i] n[i]
} }