1
0
Fork 0
forked from wry/wry

wayland: implement linux-drm-syncobj-v1

This commit is contained in:
Julian Orth 2024-03-21 20:54:21 +01:00
parent 816315170f
commit aaf73d6fdc
29 changed files with 1507 additions and 35 deletions

View file

@ -14,7 +14,11 @@ use {
renderer::{framebuffer::Framebuffer, image::Image},
GfxGlState, RenderError, Texture,
},
video::{dmabuf::DmaBuf, drm::Drm, gbm::GbmDevice},
video::{
dmabuf::DmaBuf,
drm::{sync_obj::SyncObjCtx, Drm},
gbm::GbmDevice,
},
},
ahash::AHashMap,
jay_config::video::GfxApi,
@ -53,6 +57,7 @@ pub(crate) struct TexProgs {
pub(in crate::gfx_apis::gl) struct GlRenderContext {
pub(crate) ctx: Rc<EglContext>,
pub gbm: Rc<GbmDevice>,
pub sync_ctx: Rc<SyncObjCtx>,
pub(crate) render_node: Rc<CString>,
@ -128,6 +133,7 @@ impl GlRenderContext {
Ok(Self {
ctx: ctx.clone(),
gbm: ctx.dpy.gbm.clone(),
sync_ctx: Rc::new(SyncObjCtx::new(ctx.dpy.gbm.drm.fd())),
render_node: node.clone(),
@ -271,4 +277,8 @@ impl GfxContext for GlRenderContext {
})?;
Ok(Rc::new(Framebuffer { ctx: self, gl: fb }))
}
fn sync_obj_ctx(&self) -> &Rc<SyncObjCtx> {
&self.sync_ctx
}
}

View file

@ -67,7 +67,7 @@ impl Framebuffer {
pub fn render(
&self,
ops: Vec<GfxApiOpt>,
mut ops: Vec<GfxApiOpt>,
clear: Option<&Color>,
) -> Result<Option<SyncFile>, RenderError> {
let gles = self.ctx.ctx.dpy.gles;
@ -89,6 +89,7 @@ impl Framebuffer {
}
Ok(fd)
});
ops.clear();
*self.ctx.gfx_ops.borrow_mut() = ops;
res
}
@ -100,9 +101,7 @@ impl GfxFramebuffer for Framebuffer {
}
fn take_render_ops(&self) -> Vec<GfxApiOpt> {
let mut ops = mem::take(&mut *self.ctx.gfx_ops.borrow_mut());
ops.clear();
ops
mem::take(&mut *self.ctx.gfx_ops.borrow_mut())
}
fn physical_size(&self) -> (i32, i32) {