1
0
Fork 0
forked from wry/wry

Merge pull request #735 from mahkoh/jorth/wl-shm-blocker

surface: don't access shm buffers if there are buffer blockers
This commit is contained in:
mahkoh 2026-02-11 11:22:20 +01:00 committed by GitHub
commit 346c6a7345
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 19 additions and 17 deletions

View file

@ -54,7 +54,7 @@ pub struct WlBuffer {
pub client: Rc<Client>,
pub rect: Rect,
pub format: &'static Format,
pub dmabuf: Option<DmaBuf>,
pub client_dmabuf: Option<DmaBuf>,
render_ctx_version: Cell<u32>,
pub storage: RefCell<Option<WlBufferStorage>>,
shm: bool,
@ -80,7 +80,7 @@ impl WlBuffer {
format: &'static Format,
width: i32,
height: i32,
dmabuf: Option<DmaBuf>,
client_dmabuf: Option<DmaBuf>,
storage: Option<WlBufferStorage>,
shm: bool,
color: Option<[u32; 4]>,
@ -93,7 +93,7 @@ impl WlBuffer {
format,
width,
height,
dmabuf,
client_dmabuf,
render_ctx_version: Cell::new(client.state.render_ctx_version.get()),
storage: RefCell::new(storage),
shm,
@ -109,7 +109,7 @@ impl WlBuffer {
id: WlBufferId,
client: &Rc<Client>,
format: &'static Format,
dmabuf: DmaBuf,
client_dmabuf: DmaBuf,
img: &Rc<dyn GfxImage>,
) -> Rc<Self> {
Self::new(
@ -118,7 +118,7 @@ impl WlBuffer {
format,
img.width(),
img.height(),
Some(dmabuf),
Some(client_dmabuf),
Some(WlBufferStorage::Dmabuf {
img: img.clone(),
tex: None,
@ -136,6 +136,7 @@ impl WlBuffer {
offset: usize,
width: i32,
height: i32,
client_dmabuf: Option<DmaBuf>,
stride: i32,
format: &'static Format,
mem: &Rc<ClientMem>,
@ -182,7 +183,7 @@ impl WlBuffer {
format,
width,
height,
None,
client_dmabuf,
Some(WlBufferStorage::Shm {
dmabuf_buffer_params,
mem,
@ -256,7 +257,7 @@ impl WlBuffer {
let Some(ctx) = self.client.state.render_ctx.get() else {
return false;
};
let Some(dmabuf) = &self.dmabuf else {
let Some(dmabuf) = &self.client_dmabuf else {
return false;
};
let img = match ctx.dmabuf_img(dmabuf) {

View file

@ -68,6 +68,7 @@ impl WlShmPoolRequestHandler for WlShmPool {
req.offset as usize,
req.width,
req.height,
None,
req.stride,
format,
&self.mem.get(),

View file

@ -252,7 +252,7 @@ impl Drop for SurfaceBuffer {
}
return;
}
if let Some(dmabuf) = &self.buffer.dmabuf {
if let Some(dmabuf) = &self.buffer.client_dmabuf {
for (_, sync_file) in &sync_files {
if let Err(e) = dmabuf.import_sync_file(DMA_BUF_SYNC_READ, sync_file) {
log::error!("Could not import sync file: {}", ErrorFmt(e));

View file

@ -471,16 +471,15 @@ impl NodeRef<Entry> {
match &self.kind {
EntryKind::Commit(c) => {
let mut has_unmet_dependencies = false;
if c.sync_obj.get() > 0 {
has_unmet_dependencies = true;
}
if c.pending_uploads.get() > 0 {
check_shm_uploads(c)?;
let may_access_buffer = c.sync_obj.get() == 0 && c.num_pending_polls.get() == 0;
if may_access_buffer {
if c.pending_uploads.get() > 0 {
has_unmet_dependencies = true;
check_shm_uploads(c)?;
if c.pending_uploads.get() > 0 {
has_unmet_dependencies = true;
}
}
}
if c.num_pending_polls.get() > 0 {
} else {
has_unmet_dependencies = true;
}
let tl = &c.surface.commit_timeline;
@ -703,7 +702,7 @@ impl CommitDataCollector {
self.shm_uploads += 1;
}
if !pending.explicit_sync
&& let Some(dmabuf) = &buffer.dmabuf
&& let Some(dmabuf) = &buffer.client_dmabuf
{
for plane in &dmabuf.planes {
self.implicit_dmabufs.push(plane.fd.clone());

View file

@ -131,6 +131,7 @@ impl ZwpLinuxBufferParamsV1 {
p.offset as usize,
dmabuf.width,
dmabuf.height,
Some(dmabuf.clone()),
p.stride as _,
format.format,
&client_mem,