rusticl/mem: move copy_to_rect into Buffer

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27376>
This commit is contained in:
Karol Herbst
2024-01-30 12:12:09 +01:00
committed by Marge Bot
parent e048d8c796
commit dd4096e7fd
2 changed files with 39 additions and 42 deletions
+1 -1
View File
@@ -1555,7 +1555,7 @@ fn enqueue_copy_buffer_rect(
event,
false,
Box::new(move |q, ctx| {
src.copy_to_rect(
src.copy_rect(
&dst,
q,
ctx,
+38 -41
View File
@@ -931,47 +931,6 @@ impl MemBase {
Ok(())
}
pub fn copy_to_rect(
&self,
dst: &Self,
q: &Queue,
ctx: &PipeContext,
region: &CLVec<usize>,
src_origin: &CLVec<usize>,
src_row_pitch: usize,
src_slice_pitch: usize,
dst_origin: &CLVec<usize>,
dst_row_pitch: usize,
dst_slice_pitch: usize,
) -> CLResult<()> {
assert!(self.is_buffer());
assert!(dst.is_buffer());
let (offset, size) =
CLVec::calc_offset_size(src_origin, region, [1, src_row_pitch, src_slice_pitch]);
let tx_src = self.tx(q, ctx, offset, size, RWFlags::RD)?;
let (offset, size) =
CLVec::calc_offset_size(dst_origin, region, [1, dst_row_pitch, dst_slice_pitch]);
let tx_dst = dst.tx(q, ctx, offset, size, RWFlags::WR)?;
// TODO check to use hw accelerated paths (e.g. resource_copy_region or blits)
sw_copy(
tx_src.ptr(),
tx_dst.ptr(),
region,
&CLVec::default(),
src_row_pitch,
src_slice_pitch,
&CLVec::default(),
dst_row_pitch,
dst_slice_pitch,
1,
);
Ok(())
}
/// Maps the queue associated device's resource.
///
/// Mapping resources could have been quite straightforward if OpenCL wouldn't allow for so
@@ -1055,6 +1014,44 @@ impl Buffer {
self.offset.checked_add(offset).ok_or(CL_OUT_OF_HOST_MEMORY)
}
pub fn copy_rect(
&self,
dst: &Self,
q: &Queue,
ctx: &PipeContext,
region: &CLVec<usize>,
src_origin: &CLVec<usize>,
src_row_pitch: usize,
src_slice_pitch: usize,
dst_origin: &CLVec<usize>,
dst_row_pitch: usize,
dst_slice_pitch: usize,
) -> CLResult<()> {
let (offset, size) =
CLVec::calc_offset_size(src_origin, region, [1, src_row_pitch, src_slice_pitch]);
let tx_src = self.tx(q, ctx, offset, size, RWFlags::RD)?;
let (offset, size) =
CLVec::calc_offset_size(dst_origin, region, [1, dst_row_pitch, dst_slice_pitch]);
let tx_dst = dst.tx(q, ctx, offset, size, RWFlags::WR)?;
// TODO check to use hw accelerated paths (e.g. resource_copy_region or blits)
sw_copy(
tx_src.ptr(),
tx_dst.ptr(),
region,
&CLVec::default(),
src_row_pitch,
src_slice_pitch,
&CLVec::default(),
dst_row_pitch,
dst_slice_pitch,
1,
);
Ok(())
}
pub fn fill(
&self,
q: &Queue,