Skip to content

Commit

Permalink
ByteAddressableBuffer fixes (#179)
Browse files Browse the repository at this point in the history
* ByteAddressableBuffer: fix debug printf mispile, segfaulting debug printf validation layer

* ByteAddressableBuffer: fix oob calculation thinking all buffers are only `len / 4` long
  • Loading branch information
Firestar99 authored Dec 17, 2024
1 parent d9dba91 commit 8f55382
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions crates/spirv-std/src/byte_addressable_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,12 @@ fn bounds_check<T>(data: &[u32], byte_index: u32) {
if byte_index % 4 != 0 {
panic!("`byte_index` should be a multiple of 4");
}
if byte_index + sizeof > data.len() as u32 {
let last_byte = byte_index + sizeof;
let last_byte = byte_index + sizeof;
let len = data.len() as u32 * 4;
if byte_index + sizeof > len {
panic!(
"index out of bounds: the len is {} but loading {} bytes at `byte_index` {} reads until {} (exclusive)",
data.len(),
sizeof,
byte_index,
last_byte,
len, sizeof, byte_index, last_byte,
);
}
}
Expand Down

0 comments on commit 8f55382

Please sign in to comment.