Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion crates/xcl/src/hle/d3d12x/sparse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ impl Hasher for FxHasher {
}
#[inline]
fn finish(&self) -> u64 {
self.0
// Tile addresses are 64 KiB aligned. Move mixed bits into the low bucket-index bits.
self.0.rotate_right(23)
}
}

Expand Down Expand Up @@ -1487,6 +1488,21 @@ pub fn forget_buffer(res: usize) {
mod tests {
use super::*;

#[test]
fn aligned_tile_addresses_spread_across_hash_buckets() {
use std::hash::BuildHasher;

let hasher = BuildHasherDefault::<FxHasher>::default();
let mut used = [false; 256];
for tile in 0..used.len() {
let address = (1usize << 32) + tile * TILE;
let bucket = hasher.hash_one(address) as usize & (used.len() - 1);
used[bucket] = true;
}
let occupied = used.iter().filter(|&&bucket| bucket).count();
assert!(occupied >= used.len() / 2, "256 aligned addresses used {occupied} buckets");
}

/// Only the 64-byte chunks the CPU changed are sent again – the rest of the page may hold
/// what the GPU wrote.
#[test]
Expand Down
Loading