1
0
Fork 0
forked from wry/wry

video: add udmabuf allocator

This commit is contained in:
Julian Orth 2024-09-01 20:23:04 +02:00
parent 2579834a60
commit 62cd29056a
33 changed files with 883 additions and 256 deletions

View file

@ -1,5 +1,6 @@
use {
crate::{
allocator::Allocator,
format::{Format, XRGB8888},
gfx_api::{
BufferResvUser, GfxApiOpt, GfxContext, GfxError, GfxFormat, GfxFramebuffer, GfxImage,
@ -240,8 +241,8 @@ impl GfxContext for GlRenderContext {
self.reset_status()
}
fn render_node(&self) -> Rc<CString> {
self.render_node()
fn render_node(&self) -> Option<Rc<CString>> {
Some(self.render_node())
}
fn formats(&self) -> Rc<AHashMap<u32, GfxFormat>> {
@ -278,8 +279,8 @@ impl GfxContext for GlRenderContext {
.map_err(|e| e.into())
}
fn gbm(&self) -> &GbmDevice {
&self.gbm
fn allocator(&self) -> Rc<dyn Allocator> {
self.gbm.clone()
}
fn gfx_api(&self) -> GfxApi {
@ -299,7 +300,7 @@ impl GfxContext for GlRenderContext {
Ok(Rc::new(Framebuffer { ctx: self, gl: fb }))
}
fn sync_obj_ctx(&self) -> &Rc<SyncObjCtx> {
&self.sync_ctx
fn sync_obj_ctx(&self) -> Option<&Rc<SyncObjCtx>> {
Some(&self.sync_ctx)
}
}

View file

@ -17,6 +17,7 @@ mod util;
use {
crate::{
allocator::Allocator,
async_engine::AsyncEngine,
format::Format,
gfx_api::{
@ -31,7 +32,7 @@ use {
video::{
dmabuf::DmaBuf,
drm::{sync_obj::SyncObjCtx, Drm, DrmError},
gbm::{GbmDevice, GbmError},
gbm::GbmError,
},
},
ahash::AHashMap,
@ -209,8 +210,8 @@ impl GfxContext for Context {
None
}
fn render_node(&self) -> Rc<CString> {
self.0.device.render_node.clone()
fn render_node(&self) -> Option<Rc<CString>> {
Some(self.0.device.render_node.clone())
}
fn formats(&self) -> Rc<AHashMap<u32, GfxFormat>> {
@ -255,8 +256,8 @@ impl GfxContext for Context {
Ok(tex as _)
}
fn gbm(&self) -> &GbmDevice {
&self.0.device.gbm
fn allocator(&self) -> Rc<dyn Allocator> {
self.0.device.gbm.clone()
}
fn gfx_api(&self) -> GfxApi {
@ -276,8 +277,8 @@ impl GfxContext for Context {
Ok(fb)
}
fn sync_obj_ctx(&self) -> &Rc<SyncObjCtx> {
&self.0.device.sync_ctx
fn sync_obj_ctx(&self) -> Option<&Rc<SyncObjCtx>> {
Some(&self.0.device.sync_ctx)
}
}

View file

@ -49,7 +49,7 @@ use {
pub struct VulkanDevice {
pub(super) physical_device: PhysicalDevice,
pub(super) render_node: Rc<CString>,
pub(super) gbm: GbmDevice,
pub(super) gbm: Rc<GbmDevice>,
pub(super) sync_ctx: Rc<SyncObjCtx>,
pub(super) instance: Rc<VulkanInstance>,
pub(super) device: Device,
@ -276,7 +276,7 @@ impl VulkanInstance {
physical_device: phy_dev,
render_node,
sync_ctx: Rc::new(SyncObjCtx::new(gbm.drm.fd())),
gbm,
gbm: Rc::new(gbm),
instance: self.clone(),
device,
external_memory_fd,