Merge pull request #198 from mahkoh/jorth/gbmbo
drm: preserve GbmBos while they are in use
This commit is contained in:
commit
2742b23ebe
5 changed files with 25 additions and 7 deletions
|
|
@ -35,7 +35,7 @@ use {
|
|||
DrmPropertyType, DrmVersion, PropBlob, DRM_CLIENT_CAP_ATOMIC,
|
||||
DRM_MODE_ATOMIC_ALLOW_MODESET, DRM_MODE_ATOMIC_NONBLOCK, DRM_MODE_PAGE_FLIP_EVENT,
|
||||
},
|
||||
gbm::{GbmDevice, GBM_BO_USE_LINEAR, GBM_BO_USE_RENDERING, GBM_BO_USE_SCANOUT},
|
||||
gbm::{GbmBo, GbmDevice, GBM_BO_USE_LINEAR, GBM_BO_USE_RENDERING, GBM_BO_USE_SCANOUT},
|
||||
Modifier, INVALID_MODIFIER,
|
||||
},
|
||||
},
|
||||
|
|
@ -2593,12 +2593,12 @@ impl MetalBackend {
|
|||
Err(e) => return Err(MetalError::ImportFb(e)),
|
||||
};
|
||||
dev_fb.clear().map_err(MetalError::Clear)?;
|
||||
let (dev_tex, render_tex, render_fb) = if dev.id == render_ctx.dev_id {
|
||||
let (dev_tex, render_tex, render_fb, render_bo) = if dev.id == render_ctx.dev_id {
|
||||
let render_tex = match dev_img.to_texture() {
|
||||
Ok(fb) => fb,
|
||||
Err(e) => return Err(MetalError::ImportTexture(e)),
|
||||
};
|
||||
(None, render_tex, None)
|
||||
(None, render_tex, None, None)
|
||||
} else {
|
||||
// Create a _bridge_ BO in the render device
|
||||
let render_gfx_formats = render_ctx.gfx.formats();
|
||||
|
|
@ -2657,10 +2657,12 @@ impl MetalBackend {
|
|||
Err(e) => return Err(MetalError::ImportTexture(e)),
|
||||
};
|
||||
|
||||
(Some(dev_tex), render_tex, Some(render_fb))
|
||||
(Some(dev_tex), render_tex, Some(render_fb), Some(render_bo))
|
||||
};
|
||||
Ok(RenderBuffer {
|
||||
drm: drm_fb,
|
||||
_dev_bo: dev_bo,
|
||||
_render_bo: render_bo,
|
||||
dev_fb,
|
||||
dev_tex,
|
||||
render_tex,
|
||||
|
|
@ -2849,6 +2851,8 @@ impl MetalBackend {
|
|||
#[derive(Debug)]
|
||||
pub struct RenderBuffer {
|
||||
drm: Rc<DrmFramebuffer>,
|
||||
_dev_bo: GbmBo,
|
||||
_render_bo: Option<GbmBo>,
|
||||
// ctx = dev
|
||||
// buffer location = dev
|
||||
dev_fb: Rc<dyn GfxFramebuffer>,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use {
|
|||
},
|
||||
video::{
|
||||
drm::{ConnectorType, Drm, DrmError, DrmVersion},
|
||||
gbm::{GbmDevice, GbmError, GBM_BO_USE_RENDERING},
|
||||
gbm::{GbmBo, GbmDevice, GbmError, GBM_BO_USE_RENDERING},
|
||||
},
|
||||
wire_xcon::{
|
||||
ChangeProperty, ChangeWindowAttributes, ConfigureNotify, CreateCursor, CreatePixmap,
|
||||
|
|
@ -437,6 +437,7 @@ impl XBackend {
|
|||
};
|
||||
*image = Some(XImage {
|
||||
pixmap: Cell::new(pixmap),
|
||||
_bo: bo,
|
||||
fb: CloneCell::new(fb),
|
||||
tex: CloneCell::new(tex),
|
||||
idle: Cell::new(true),
|
||||
|
|
@ -1023,6 +1024,7 @@ struct XOutput {
|
|||
|
||||
struct XImage {
|
||||
pixmap: Cell<u32>,
|
||||
_bo: GbmBo,
|
||||
fb: CloneCell<Rc<dyn GfxFramebuffer>>,
|
||||
tex: CloneCell<Rc<dyn GfxTexture>>,
|
||||
idle: Cell<bool>,
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use {
|
|||
},
|
||||
video::{
|
||||
dmabuf::DmaBuf,
|
||||
gbm::{GbmError, GBM_BO_USE_LINEAR, GBM_BO_USE_RENDERING},
|
||||
gbm::{GbmBo, GbmError, GBM_BO_USE_LINEAR, GBM_BO_USE_RENDERING},
|
||||
Modifier, INVALID_MODIFIER, LINEAR_MODIFIER,
|
||||
},
|
||||
wire::{jay_screencast::*, JayScreencastId},
|
||||
|
|
@ -100,6 +100,7 @@ struct Pending {
|
|||
}
|
||||
|
||||
struct ScreencastBuffer {
|
||||
_bo: GbmBo,
|
||||
dmabuf: DmaBuf,
|
||||
fb: Rc<dyn GfxFramebuffer>,
|
||||
free: bool,
|
||||
|
|
@ -403,6 +404,7 @@ impl JayScreencast {
|
|||
let fb = ctx.clone().dmabuf_img(buffer.dmabuf())?.to_framebuffer()?;
|
||||
buffers.push(ScreencastBuffer {
|
||||
dmabuf: buffer.dmabuf().clone(),
|
||||
_bo: buffer,
|
||||
fb,
|
||||
free: true,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use {
|
|||
asyncevent::AsyncEvent, clonecell::CloneCell, copyhashmap::CopyHashMap,
|
||||
errorfmt::ErrorFmt, rc_eq::rc_eq,
|
||||
},
|
||||
video::gbm::GBM_BO_USE_RENDERING,
|
||||
video::gbm::{GbmBo, GBM_BO_USE_RENDERING},
|
||||
wire::{
|
||||
wp_fractional_scale_v1::PreferredScale, zwlr_layer_surface_v1::Configure,
|
||||
ZwpLinuxBufferParamsV1Id,
|
||||
|
|
@ -757,6 +757,7 @@ impl WindowData {
|
|||
let params = dmabuf.create_params();
|
||||
params.create(bo.dmabuf());
|
||||
let pending = Rc::new(GuiBufferPending {
|
||||
bo: Cell::new(Some(bo)),
|
||||
window: self.clone(),
|
||||
fb,
|
||||
params,
|
||||
|
|
@ -843,11 +844,13 @@ pub struct GuiBuffer {
|
|||
pub wl: Rc<UsrWlBuffer>,
|
||||
pub window: Rc<WindowData>,
|
||||
pub fb: Rc<dyn GfxFramebuffer>,
|
||||
pub _bo: Option<GbmBo>,
|
||||
pub free: Cell<bool>,
|
||||
pub size: (i32, i32),
|
||||
}
|
||||
|
||||
struct GuiBufferPending {
|
||||
pub bo: Cell<Option<GbmBo>>,
|
||||
pub window: Rc<WindowData>,
|
||||
pub fb: Rc<dyn GfxFramebuffer>,
|
||||
pub params: Rc<UsrLinuxBufferParams>,
|
||||
|
|
@ -892,6 +895,7 @@ impl UsrLinuxBufferParamsOwner for GuiBufferPending {
|
|||
wl: buffer,
|
||||
window: self.window.clone(),
|
||||
fb: self.fb.clone(),
|
||||
_bo: self.bo.take(),
|
||||
free: Cell::new(true),
|
||||
size: self.size,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -138,6 +138,12 @@ pub struct GbmBo {
|
|||
dmabuf: DmaBuf,
|
||||
}
|
||||
|
||||
impl Debug for GbmBo {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("GbmBo").finish_non_exhaustive()
|
||||
}
|
||||
}
|
||||
|
||||
pub struct GbmBoMap {
|
||||
bo: Rc<GbmBo>,
|
||||
data: *mut [u8],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue