Skip to content

Commit 878007b

Browse files
committed
Implement as_{source,target} for image types
1 parent 2bf4430 commit 878007b

File tree

5 files changed

+497
-8
lines changed

5 files changed

+497
-8
lines changed

texel/src/buf.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2134,4 +2134,30 @@ mod tests {
21342134
);
21352135
}
21362136
}
2137+
2138+
#[test]
2139+
fn atomic_memory_move() {
2140+
const COPY_LEN: usize = 3 * core::mem::size_of::<MaxAtomic>();
2141+
const TOTAL_LEN: usize = 4 * core::mem::size_of::<MaxAtomic>();
2142+
2143+
for offset in 0..4 {
2144+
let data = [const { MaxAtomic::zero() }; 4];
2145+
let lhs = atomic_buf::new(&data[..]);
2146+
2147+
let data = [const { MaxAtomic::zero() }; 4];
2148+
let rhs = atomic_buf::new(&data[..]);
2149+
2150+
U8.store_atomic_slice(lhs.as_texels(U8).index(0..4), b"helo");
2151+
2152+
U8.atomic_memory_move(
2153+
lhs.as_texels(U8).index(offset..offset + COPY_LEN),
2154+
rhs.as_texels(U8).index(0..COPY_LEN),
2155+
);
2156+
2157+
let mut buffer = [0x42; TOTAL_LEN];
2158+
U8.load_atomic_slice(rhs.as_texels(U8), &mut buffer);
2159+
2160+
assert_eq!(buffer[..4], b"helo\0\0\0\0"[offset..][..4]);
2161+
}
2162+
}
21372163
}

texel/src/image/atomic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use crate::{BufferReuseError, Texel, TexelBuffer};
2525
/// manner.
2626
#[derive(Clone)]
2727
pub struct AtomicImage<Layout = Bytes> {
28-
inner: RawImage<AtomicBuffer, Layout>,
28+
pub(super) inner: RawImage<AtomicBuffer, Layout>,
2929
}
3030

3131
/// A partial view of an atomic image.
@@ -35,7 +35,7 @@ pub struct AtomicImage<Layout = Bytes> {
3535
/// by calling [`AtomicImage::as_ref`] or [`AtomicImage::checked_to_ref`].
3636
#[derive(Clone, PartialEq, Eq)]
3737
pub struct AtomicImageRef<'buf, Layout = &'buf Bytes> {
38-
inner: RawImage<&'buf atomic_buf, Layout>,
38+
pub(super) inner: RawImage<&'buf atomic_buf, Layout>,
3939
}
4040

4141
/// Image methods for all layouts.

texel/src/image/cell.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use core::cell::Cell;
1515
/// between threads. In particular the same buffer may be owned and viewed with different layouts.
1616
#[derive(Clone, PartialEq, Eq)]
1717
pub struct CellImage<Layout = Bytes> {
18-
inner: RawImage<CellBuffer, Layout>,
18+
pub(super) inner: RawImage<CellBuffer, Layout>,
1919
}
2020

2121
/// A partial view of an atomic image.
@@ -25,7 +25,7 @@ pub struct CellImage<Layout = Bytes> {
2525
/// by calling [`CellImage::as_ref`] or [`CellImage::checked_to_ref`].
2626
#[derive(Clone, PartialEq, Eq)]
2727
pub struct CellImageRef<'buf, Layout = &'buf Bytes> {
28-
inner: RawImage<&'buf cell_buf, Layout>,
28+
pub(super) inner: RawImage<&'buf cell_buf, Layout>,
2929
}
3030

3131
/// Image methods for all layouts.

0 commit comments

Comments
 (0)