wl_buffer: remember client dmabuf when converting udmabuf to shm
This commit is contained in:
parent
7122b89cb9
commit
d90ddba50a
5 changed files with 12 additions and 9 deletions
|
|
@ -54,7 +54,7 @@ pub struct WlBuffer {
|
||||||
pub client: Rc<Client>,
|
pub client: Rc<Client>,
|
||||||
pub rect: Rect,
|
pub rect: Rect,
|
||||||
pub format: &'static Format,
|
pub format: &'static Format,
|
||||||
pub dmabuf: Option<DmaBuf>,
|
pub client_dmabuf: Option<DmaBuf>,
|
||||||
render_ctx_version: Cell<u32>,
|
render_ctx_version: Cell<u32>,
|
||||||
pub storage: RefCell<Option<WlBufferStorage>>,
|
pub storage: RefCell<Option<WlBufferStorage>>,
|
||||||
shm: bool,
|
shm: bool,
|
||||||
|
|
@ -80,7 +80,7 @@ impl WlBuffer {
|
||||||
format: &'static Format,
|
format: &'static Format,
|
||||||
width: i32,
|
width: i32,
|
||||||
height: i32,
|
height: i32,
|
||||||
dmabuf: Option<DmaBuf>,
|
client_dmabuf: Option<DmaBuf>,
|
||||||
storage: Option<WlBufferStorage>,
|
storage: Option<WlBufferStorage>,
|
||||||
shm: bool,
|
shm: bool,
|
||||||
color: Option<[u32; 4]>,
|
color: Option<[u32; 4]>,
|
||||||
|
|
@ -93,7 +93,7 @@ impl WlBuffer {
|
||||||
format,
|
format,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
dmabuf,
|
client_dmabuf,
|
||||||
render_ctx_version: Cell::new(client.state.render_ctx_version.get()),
|
render_ctx_version: Cell::new(client.state.render_ctx_version.get()),
|
||||||
storage: RefCell::new(storage),
|
storage: RefCell::new(storage),
|
||||||
shm,
|
shm,
|
||||||
|
|
@ -109,7 +109,7 @@ impl WlBuffer {
|
||||||
id: WlBufferId,
|
id: WlBufferId,
|
||||||
client: &Rc<Client>,
|
client: &Rc<Client>,
|
||||||
format: &'static Format,
|
format: &'static Format,
|
||||||
dmabuf: DmaBuf,
|
client_dmabuf: DmaBuf,
|
||||||
img: &Rc<dyn GfxImage>,
|
img: &Rc<dyn GfxImage>,
|
||||||
) -> Rc<Self> {
|
) -> Rc<Self> {
|
||||||
Self::new(
|
Self::new(
|
||||||
|
|
@ -118,7 +118,7 @@ impl WlBuffer {
|
||||||
format,
|
format,
|
||||||
img.width(),
|
img.width(),
|
||||||
img.height(),
|
img.height(),
|
||||||
Some(dmabuf),
|
Some(client_dmabuf),
|
||||||
Some(WlBufferStorage::Dmabuf {
|
Some(WlBufferStorage::Dmabuf {
|
||||||
img: img.clone(),
|
img: img.clone(),
|
||||||
tex: None,
|
tex: None,
|
||||||
|
|
@ -136,6 +136,7 @@ impl WlBuffer {
|
||||||
offset: usize,
|
offset: usize,
|
||||||
width: i32,
|
width: i32,
|
||||||
height: i32,
|
height: i32,
|
||||||
|
client_dmabuf: Option<DmaBuf>,
|
||||||
stride: i32,
|
stride: i32,
|
||||||
format: &'static Format,
|
format: &'static Format,
|
||||||
mem: &Rc<ClientMem>,
|
mem: &Rc<ClientMem>,
|
||||||
|
|
@ -182,7 +183,7 @@ impl WlBuffer {
|
||||||
format,
|
format,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
None,
|
client_dmabuf,
|
||||||
Some(WlBufferStorage::Shm {
|
Some(WlBufferStorage::Shm {
|
||||||
dmabuf_buffer_params,
|
dmabuf_buffer_params,
|
||||||
mem,
|
mem,
|
||||||
|
|
@ -256,7 +257,7 @@ impl WlBuffer {
|
||||||
let Some(ctx) = self.client.state.render_ctx.get() else {
|
let Some(ctx) = self.client.state.render_ctx.get() else {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
let Some(dmabuf) = &self.dmabuf else {
|
let Some(dmabuf) = &self.client_dmabuf else {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
let img = match ctx.dmabuf_img(dmabuf) {
|
let img = match ctx.dmabuf_img(dmabuf) {
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@ impl WlShmPoolRequestHandler for WlShmPool {
|
||||||
req.offset as usize,
|
req.offset as usize,
|
||||||
req.width,
|
req.width,
|
||||||
req.height,
|
req.height,
|
||||||
|
None,
|
||||||
req.stride,
|
req.stride,
|
||||||
format,
|
format,
|
||||||
&self.mem.get(),
|
&self.mem.get(),
|
||||||
|
|
|
||||||
|
|
@ -252,7 +252,7 @@ impl Drop for SurfaceBuffer {
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if let Some(dmabuf) = &self.buffer.dmabuf {
|
if let Some(dmabuf) = &self.buffer.client_dmabuf {
|
||||||
for (_, sync_file) in &sync_files {
|
for (_, sync_file) in &sync_files {
|
||||||
if let Err(e) = dmabuf.import_sync_file(DMA_BUF_SYNC_READ, sync_file) {
|
if let Err(e) = dmabuf.import_sync_file(DMA_BUF_SYNC_READ, sync_file) {
|
||||||
log::error!("Could not import sync file: {}", ErrorFmt(e));
|
log::error!("Could not import sync file: {}", ErrorFmt(e));
|
||||||
|
|
|
||||||
|
|
@ -703,7 +703,7 @@ impl CommitDataCollector {
|
||||||
self.shm_uploads += 1;
|
self.shm_uploads += 1;
|
||||||
}
|
}
|
||||||
if !pending.explicit_sync
|
if !pending.explicit_sync
|
||||||
&& let Some(dmabuf) = &buffer.dmabuf
|
&& let Some(dmabuf) = &buffer.client_dmabuf
|
||||||
{
|
{
|
||||||
for plane in &dmabuf.planes {
|
for plane in &dmabuf.planes {
|
||||||
self.implicit_dmabufs.push(plane.fd.clone());
|
self.implicit_dmabufs.push(plane.fd.clone());
|
||||||
|
|
|
||||||
|
|
@ -131,6 +131,7 @@ impl ZwpLinuxBufferParamsV1 {
|
||||||
p.offset as usize,
|
p.offset as usize,
|
||||||
dmabuf.width,
|
dmabuf.width,
|
||||||
dmabuf.height,
|
dmabuf.height,
|
||||||
|
Some(dmabuf.clone()),
|
||||||
p.stride as _,
|
p.stride as _,
|
||||||
format.format,
|
format.format,
|
||||||
&client_mem,
|
&client_mem,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue