diff --git a/crates/horizon-client/src/gfx/cull.rs b/crates/horizon-client/src/gfx/cull.rs index 6926aab70..bcb738de3 100644 --- a/crates/horizon-client/src/gfx/cull.rs +++ b/crates/horizon-client/src/gfx/cull.rs @@ -273,7 +273,9 @@ impl Cull { } let mapped = r.buffer.slice(..r.slots.len() as u64 * 4); if let Ok(data) = mapped.get_mapped_range() { - let results: &[u32] = bytemuck::cast_slice(&data); + // The mapping isn't guaranteed to be 4-byte aligned (a Vega 11 + // on Windows panicked in cast_slice), so copy the words out. + let results: Vec = bytemuck::pod_collect_to_vec(&data); let (mut hidden, mut indices) = (0, 0u64); for (&result, &n) in results.iter().zip(&r.indices) { if result != r.stamp { @@ -283,7 +285,7 @@ impl Cull { } let share = indices as f32 / r.total.max(1) as f32; self.hidden = ([hidden, results.len()], share); - for (&slot, &result) in r.slots.iter().zip(results) { + for (&slot, &result) in r.slots.iter().zip(&results) { let slot = slot as usize; if slot >= self.seen.len() { self.seen.resize(slot + 1, false); diff --git a/crates/horizon-client/src/gfx/timing.rs b/crates/horizon-client/src/gfx/timing.rs index 5d2354234..8f8eee6ee 100644 --- a/crates/horizon-client/src/gfx/timing.rs +++ b/crates/horizon-client/src/gfx/timing.rs @@ -147,7 +147,8 @@ impl GpuTimer { continue; } if let Ok(data) = slot.buffer.slice(..).get_mapped_range() { - let stamps: &[u64] = bytemuck::cast_slice(&data); + // Read unaligned: the mapping isn't guaranteed to be 8-byte aligned. + let stamps: [u64; 2] = bytemuck::pod_read_unaligned(&data[..16]); let ticks = stamps[1].saturating_sub(stamps[0]); out.push((ticks as f64 * f64::from(self.period_ns) / 1e6) as f32); }