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

@ -376,7 +376,7 @@ fn render_texture(ctx: &GlRenderContext, tex: &CopyTexture) {
fn handle_explicit_sync(ctx: &GlRenderContext, texture: &Texture, sync: &AcquireSync) {
let sync_file = match sync {
AcquireSync::None | AcquireSync::Implicit => return,
AcquireSync::None | AcquireSync::Implicit | AcquireSync::Unnecessary => return,
AcquireSync::SyncFile { sync_file } => sync_file,
};
let sync_file = match uapi::fcntl_dupfd_cloexec(sync_file.raw(), 0) {

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) {

View file

@ -28,7 +28,7 @@ use {
utils::oserror::OsError,
video::{
dmabuf::DmaBuf,
drm::{Drm, DrmError},
drm::{sync_obj::SyncObjCtx, Drm, DrmError},
gbm::{GbmDevice, GbmError},
},
},
@ -93,7 +93,7 @@ pub enum VulkanError {
LoadImageProperties(#[source] vk::Result),
#[error("Device does not support rending and texturing from the XRGB8888 format")]
XRGB8888,
#[error("Device does not support syncobj import")]
#[error("Device does not support sync obj import")]
SyncobjImport,
#[error("Could not start a command buffer")]
BeginCommandBuffer(vk::Result),
@ -270,6 +270,10 @@ impl GfxContext for Context {
.create_shm_texture(format, width, height, stride, &[], true)?;
Ok(fb)
}
fn sync_obj_ctx(&self) -> &Rc<SyncObjCtx> {
&self.0.device.sync_ctx
}
}
impl Drop for Context {

View file

@ -10,7 +10,10 @@ use {
util::OnDrop,
VulkanError,
},
video::{drm::Drm, gbm::GbmDevice},
video::{
drm::{sync_obj::SyncObjCtx, Drm},
gbm::GbmDevice,
},
},
ahash::AHashMap,
arrayvec::ArrayVec,
@ -43,6 +46,7 @@ pub struct VulkanDevice {
pub(super) physical_device: PhysicalDevice,
pub(super) render_node: Rc<CString>,
pub(super) gbm: GbmDevice,
pub(super) sync_ctx: Rc<SyncObjCtx>,
pub(super) instance: Rc<VulkanInstance>,
pub(super) device: Device,
pub(super) external_memory_fd: ExternalMemoryFd,
@ -279,6 +283,7 @@ impl VulkanInstance {
Ok(Rc::new(VulkanDevice {
physical_device: phy_dev,
render_node,
sync_ctx: Rc::new(SyncObjCtx::new(gbm.drm.fd())),
gbm,
instance: self.clone(),
device,

View file

@ -574,6 +574,7 @@ impl VulkanRenderer {
.map_err(|e| VulkanError::Dupfd(e.into()))?;
import_sync_file(fd)?;
}
AcquireSync::Unnecessary => {}
}
}
Ok(())