dmabuf: cache is_disjoint property
This commit is contained in:
parent
f00202f149
commit
0884a5c656
9 changed files with 27 additions and 14 deletions
|
|
@ -69,6 +69,7 @@ async fn run(screenshot: Rc<Screenshot>) {
|
||||||
format: XRGB8888,
|
format: XRGB8888,
|
||||||
modifier: ev.modifier,
|
modifier: ev.modifier,
|
||||||
planes,
|
planes,
|
||||||
|
is_disjoint: Default::default(),
|
||||||
};
|
};
|
||||||
res.push(Ok((buf, Some(ev.drm_dev))));
|
res.push(Ok((buf, Some(ev.drm_dev))));
|
||||||
});
|
});
|
||||||
|
|
@ -96,6 +97,7 @@ async fn run(screenshot: Rc<Screenshot>) {
|
||||||
format: XRGB8888,
|
format: XRGB8888,
|
||||||
modifier: ev.modifier,
|
modifier: ev.modifier,
|
||||||
planes: planes.take(),
|
planes: planes.take(),
|
||||||
|
is_disjoint: Default::default(),
|
||||||
};
|
};
|
||||||
res.push(Ok((buf, dev.take())))
|
res.push(Ok((buf, dev.take())))
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -230,6 +230,7 @@ impl VulkanBoAllocator {
|
||||||
format: format.format,
|
format: format.format,
|
||||||
modifier: modifier.modifier,
|
modifier: modifier.modifier,
|
||||||
planes,
|
planes,
|
||||||
|
is_disjoint: Default::default(),
|
||||||
};
|
};
|
||||||
unsafe {
|
unsafe {
|
||||||
let cmd = data.command_buffer.buffer;
|
let cmd = data.command_buffer.buffer;
|
||||||
|
|
|
||||||
|
|
@ -142,6 +142,7 @@ impl WlDrmRequestHandler for WlDrm {
|
||||||
format,
|
format,
|
||||||
modifier: INVALID_MODIFIER,
|
modifier: INVALID_MODIFIER,
|
||||||
planes: PlaneVec::new(),
|
planes: PlaneVec::new(),
|
||||||
|
is_disjoint: Default::default(),
|
||||||
};
|
};
|
||||||
if req.stride0 > 0 {
|
if req.stride0 > 0 {
|
||||||
dmabuf.planes.push(DmaBufPlane {
|
dmabuf.planes.push(DmaBufPlane {
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,7 @@ impl ZwpLinuxBufferParamsV1 {
|
||||||
format: format.format,
|
format: format.format,
|
||||||
modifier,
|
modifier,
|
||||||
planes: PlaneVec::new(),
|
planes: PlaneVec::new(),
|
||||||
|
is_disjoint: Default::default(),
|
||||||
};
|
};
|
||||||
let mut planes: Vec<_> = self.planes.borrow_mut().drain_values().collect();
|
let mut planes: Vec<_> = self.planes.borrow_mut().drain_values().collect();
|
||||||
planes.sort_by_key(|a| a.plane_idx);
|
planes.sort_by_key(|a| a.plane_idx);
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ impl TestJayScreenshot {
|
||||||
format: XRGB8888,
|
format: XRGB8888,
|
||||||
modifier: ev.modifier,
|
modifier: ev.modifier,
|
||||||
planes,
|
planes,
|
||||||
|
is_disjoint: Default::default(),
|
||||||
})));
|
})));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -73,6 +74,7 @@ impl TestJayScreenshot {
|
||||||
format: XRGB8888,
|
format: XRGB8888,
|
||||||
modifier: ev.modifier,
|
modifier: ev.modifier,
|
||||||
planes: self.planes.take(),
|
planes: self.planes.take(),
|
||||||
|
is_disjoint: Default::default(),
|
||||||
})));
|
})));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -162,6 +162,7 @@ impl Allocator for Udmabuf {
|
||||||
format,
|
format,
|
||||||
modifier: LINEAR_MODIFIER,
|
modifier: LINEAR_MODIFIER,
|
||||||
planes,
|
planes,
|
||||||
|
is_disjoint: Default::default(),
|
||||||
};
|
};
|
||||||
Ok(Rc::new(UdmabufBo {
|
Ok(Rc::new(UdmabufBo {
|
||||||
buf: dmabuf,
|
buf: dmabuf,
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use {
|
||||||
video::{LINEAR_MODIFIER, Modifier},
|
video::{LINEAR_MODIFIER, Modifier},
|
||||||
},
|
},
|
||||||
arrayvec::ArrayVec,
|
arrayvec::ArrayVec,
|
||||||
std::{rc::Rc, sync::OnceLock},
|
std::{cell::OnceCell, rc::Rc, sync::OnceLock},
|
||||||
uapi::{
|
uapi::{
|
||||||
_IOW, _IOWR, OwnedFd,
|
_IOW, _IOWR, OwnedFd,
|
||||||
c::{self, dev_t, ioctl},
|
c::{self, dev_t, ioctl},
|
||||||
|
|
@ -30,6 +30,7 @@ pub struct DmaBuf {
|
||||||
pub format: &'static Format,
|
pub format: &'static Format,
|
||||||
pub modifier: Modifier,
|
pub modifier: Modifier,
|
||||||
pub planes: PlaneVec<DmaBufPlane>,
|
pub planes: PlaneVec<DmaBufPlane>,
|
||||||
|
pub is_disjoint: OnceCell<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const MAX_PLANES: usize = 4;
|
pub const MAX_PLANES: usize = 4;
|
||||||
|
|
@ -38,23 +39,25 @@ pub type PlaneVec<T> = ArrayVec<T, MAX_PLANES>;
|
||||||
|
|
||||||
impl DmaBuf {
|
impl DmaBuf {
|
||||||
pub fn is_disjoint(&self) -> bool {
|
pub fn is_disjoint(&self) -> bool {
|
||||||
if self.planes.len() <= 1 {
|
*self.is_disjoint.get_or_init(|| {
|
||||||
return false;
|
if self.planes.len() <= 1 {
|
||||||
}
|
return false;
|
||||||
let stat = match uapi::fstat(self.planes[0].fd.raw()) {
|
}
|
||||||
Ok(s) => s,
|
let stat = match uapi::fstat(self.planes[0].fd.raw()) {
|
||||||
_ => return true,
|
|
||||||
};
|
|
||||||
for plane in &self.planes[1..] {
|
|
||||||
let stat2 = match uapi::fstat(plane.fd.raw()) {
|
|
||||||
Ok(s) => s,
|
Ok(s) => s,
|
||||||
_ => return true,
|
_ => return true,
|
||||||
};
|
};
|
||||||
if stat2.st_ino != stat.st_ino {
|
for plane in &self.planes[1..] {
|
||||||
return true;
|
let stat2 = match uapi::fstat(plane.fd.raw()) {
|
||||||
|
Ok(s) => s,
|
||||||
|
_ => return true,
|
||||||
|
};
|
||||||
|
if stat2.st_ino != stat.st_ino {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
false
|
||||||
false
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn udmabuf_size(&self) -> Option<usize> {
|
pub fn udmabuf_size(&self) -> Option<usize> {
|
||||||
|
|
|
||||||
|
|
@ -202,6 +202,7 @@ unsafe fn export_bo(dmabuf_ids: &DmaBufIds, bo: *mut Bo) -> Result<DmaBuf, GbmEr
|
||||||
}
|
}
|
||||||
planes
|
planes
|
||||||
},
|
},
|
||||||
|
is_disjoint: Default::default(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -155,6 +155,7 @@ impl JayScreencastEventHandler for UsrJayScreencast {
|
||||||
format,
|
format,
|
||||||
modifier: ev.modifier,
|
modifier: ev.modifier,
|
||||||
planes: mem::take(self.pending_planes.borrow_mut().deref_mut()),
|
planes: mem::take(self.pending_planes.borrow_mut().deref_mut()),
|
||||||
|
is_disjoint: Default::default(),
|
||||||
});
|
});
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue