virtio-gpu: Respect offset parameter in TransferToHost2d command

Modify Transfer3D::new_2d to accept an offset argument, ensuring
it is correctly initialized.
This change ensures the offset is no longer ignored during 2D
transfers to the host, hence it addresses potential issues
that could arise with data transfer alignment.

Change-Id: I83a7436e825e1fa6e44fb46d921dd84a799baa93
Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/5785895
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
(cherry picked from commit a3ec3b77dbcfa44defd91775c6ecfc5af605d42c)

Reason for cherry-pick: CL was initially merged to `chromeos` branch by
mistake; never made it to `main` branch.

BUG=None
Test=builds

Change-Id: Ic7f720e59c6f43b3477e891f6da91acc23cde0fb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5838083
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
Dorinda Bassey 2024-08-14 14:57:25 +02:00 committed by crosvm LUCI
parent cdaf2bd57f
commit 5204e5db2d
3 changed files with 4 additions and 3 deletions

View file

@ -448,6 +448,7 @@ impl Frontend {
info.r.y.to_native(),
info.r.width.to_native(),
info.r.height.to_native(),
info.offset.to_native(),
);
self.virtio_gpu.transfer_write(0, resource_id, transfer)
}

View file

@ -382,7 +382,7 @@ impl VirtioGpuScanout {
.framebuffer_region(surface_id, 0, 0, self.width, self.height)
.ok_or(ErrUnspec)?;
let mut transfer = Transfer3D::new_2d(0, 0, self.width, self.height);
let mut transfer = Transfer3D::new_2d(0, 0, self.width, self.height, 0);
transfer.stride = fb.stride();
let fb_slice = fb.as_volatile_slice();
let buf = IoSliceMut::new(

View file

@ -616,7 +616,7 @@ pub struct Transfer3D {
impl Transfer3D {
/// Constructs a 2 dimensional XY box in 3 dimensional space with unit depth and zero
/// displacement on the Z axis.
pub fn new_2d(x: u32, y: u32, w: u32, h: u32) -> Transfer3D {
pub fn new_2d(x: u32, y: u32, w: u32, h: u32, offset: u64) -> Transfer3D {
Transfer3D {
x,
y,
@ -627,7 +627,7 @@ impl Transfer3D {
level: 0,
stride: 0,
layer_stride: 0,
offset: 0,
offset,
}
}