mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-23 19:10:21 +01:00
rusticl/memory: don't map more than necessary for copy operations
Signed-off-by: Karol Herbst <kherbst@redhat.com> Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15439>
This commit is contained in:
parent
98cd1c4253
commit
40215c8084
1 changed files with 26 additions and 8 deletions
|
|
@ -203,6 +203,16 @@ fn create_box(
|
|||
})
|
||||
}
|
||||
|
||||
fn buffer_offset_size(
|
||||
origin: &CLVec<usize>,
|
||||
region: &CLVec<usize>,
|
||||
row_pitch: usize,
|
||||
slice_pitch: usize,
|
||||
) -> (usize, usize) {
|
||||
let pitch = [1, row_pitch, slice_pitch];
|
||||
(*origin * pitch, *region * pitch)
|
||||
}
|
||||
|
||||
impl Mem {
|
||||
pub fn new_buffer(
|
||||
context: Arc<Context>,
|
||||
|
|
@ -603,7 +613,10 @@ impl Mem {
|
|||
dst_slice_pitch: usize,
|
||||
) -> CLResult<()> {
|
||||
if self.is_buffer() {
|
||||
let tx = self.tx(q, ctx, 0, self.size)?;
|
||||
let (offset, size) =
|
||||
buffer_offset_size(dst_origin, region, dst_row_pitch, dst_slice_pitch);
|
||||
let tx = self.tx(q, ctx, offset, size)?;
|
||||
|
||||
sw_copy(
|
||||
src,
|
||||
tx.ptr(),
|
||||
|
|
@ -611,7 +624,7 @@ impl Mem {
|
|||
src_origin,
|
||||
src_row_pitch,
|
||||
src_slice_pitch,
|
||||
dst_origin,
|
||||
&CLVec::default(),
|
||||
dst_row_pitch,
|
||||
dst_slice_pitch,
|
||||
1,
|
||||
|
|
@ -660,7 +673,9 @@ impl Mem {
|
|||
let pixel_size;
|
||||
|
||||
if self.is_buffer() {
|
||||
tx = self.tx(q, ctx, 0, self.size)?;
|
||||
let (offset, size) =
|
||||
buffer_offset_size(src_origin, region, src_row_pitch, src_slice_pitch);
|
||||
tx = self.tx(q, ctx, offset, size)?;
|
||||
pixel_size = 1;
|
||||
} else {
|
||||
assert!(dst_origin == &CLVec::default());
|
||||
|
|
@ -677,7 +692,7 @@ impl Mem {
|
|||
tx.ptr(),
|
||||
dst,
|
||||
region,
|
||||
src_origin,
|
||||
&CLVec::default(),
|
||||
src_row_pitch,
|
||||
src_slice_pitch,
|
||||
dst_origin,
|
||||
|
|
@ -705,18 +720,21 @@ impl Mem {
|
|||
assert!(self.is_buffer());
|
||||
assert!(dst.is_buffer());
|
||||
|
||||
let tx_src = self.tx(q, ctx, 0, self.size)?;
|
||||
let tx_dst = dst.tx(q, ctx, 0, self.size)?;
|
||||
let (offset, size) = buffer_offset_size(src_origin, region, src_row_pitch, src_slice_pitch);
|
||||
let tx_src = self.tx(q, ctx, offset, size)?;
|
||||
|
||||
let (offset, size) = buffer_offset_size(dst_origin, region, dst_row_pitch, dst_slice_pitch);
|
||||
let tx_dst = dst.tx(q, ctx, offset, size)?;
|
||||
|
||||
// TODO check to use hw accelerated paths (e.g. resource_copy_region or blits)
|
||||
sw_copy(
|
||||
tx_src.ptr(),
|
||||
tx_dst.ptr(),
|
||||
region,
|
||||
src_origin,
|
||||
&CLVec::default(),
|
||||
src_row_pitch,
|
||||
src_slice_pitch,
|
||||
dst_origin,
|
||||
&CLVec::default(),
|
||||
dst_row_pitch,
|
||||
dst_slice_pitch,
|
||||
1,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue