aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2023-09-03 14:22:04 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2023-09-03 14:22:04 +0400
commitcc1c9d93254df120fc1041e121cb3b5edd00ffc9 (patch)
treeb39afcd0df6d74ec10bf511aed23b16ce105fe11 /src/backend
parent03a9fd8af3bbd8a0e6dbc33516dce83cce564166 (diff)
downloadniri-cc1c9d93254df120fc1041e121cb3b5edd00ffc9.tar.gz
niri-cc1c9d93254df120fc1041e121cb3b5edd00ffc9.tar.bz2
niri-cc1c9d93254df120fc1041e121cb3b5edd00ffc9.zip
Add initial dmabuf feedback implementation
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/tty.rs24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/backend/tty.rs b/src/backend/tty.rs
index eec796f1..2db762fc 100644
--- a/src/backend/tty.rs
+++ b/src/backend/tty.rs
@@ -12,7 +12,7 @@ use smithay::backend::drm::{DrmDevice, DrmDeviceFd, DrmEvent, DrmEventTime};
use smithay::backend::egl::{EGLContext, EGLDisplay};
use smithay::backend::libinput::{LibinputInputBackend, LibinputSessionInterface};
use smithay::backend::renderer::gles::{GlesRenderer, GlesTexture};
-use smithay::backend::renderer::{Bind, DebugFlags, ImportEgl};
+use smithay::backend::renderer::{Bind, DebugFlags, ImportDma, ImportEgl};
use smithay::backend::session::libseat::LibSeatSession;
use smithay::backend::session::{Event as SessionEvent, Session};
use smithay::backend::udev::{self, UdevBackend, UdevEvent};
@@ -27,10 +27,11 @@ use smithay::reexports::nix::fcntl::OFlag;
use smithay::reexports::nix::libc::dev_t;
use smithay::reexports::wayland_protocols::wp::presentation_time::server::wp_presentation_feedback;
use smithay::utils::DeviceFd;
+use smithay::wayland::dmabuf::{DmabufFeedbackBuilder, DmabufGlobal, DmabufState};
use smithay_drm_extras::drm_scanner::{DrmScanEvent, DrmScanner};
use smithay_drm_extras::edid::EdidInfo;
-use crate::niri::OutputRenderElements;
+use crate::niri::{OutputRenderElements, State};
use crate::{LoopData, Niri};
const BACKGROUND_COLOR: [f32; 4] = [0.1, 0.1, 0.1, 1.];
@@ -59,6 +60,8 @@ struct OutputDevice {
formats: HashSet<DrmFormat>,
drm_scanner: DrmScanner,
surfaces: HashMap<crtc::Handle, GbmDrmCompositor>,
+ dmabuf_state: DmabufState,
+ dmabuf_global: DmabufGlobal,
}
#[derive(Debug, Clone, Copy)]
@@ -331,6 +334,13 @@ impl Tty {
let formats = Bind::<Dmabuf>::supported_formats(&gles).unwrap_or_default();
+ let mut dmabuf_state = DmabufState::new();
+ let default_feedback = DmabufFeedbackBuilder::new(device_id, gles.dmabuf_formats())
+ .build()
+ .unwrap();
+ let dmabuf_global = dmabuf_state
+ .create_global_with_default_feedback::<State>(&niri.display_handle, &default_feedback);
+
self.output_device = Some(OutputDevice {
id: device_id,
token,
@@ -340,6 +350,8 @@ impl Tty {
formats,
drm_scanner: DrmScanner::new(),
surfaces: HashMap::new(),
+ dmabuf_state,
+ dmabuf_global,
});
self.device_changed(device_id, niri);
@@ -394,7 +406,11 @@ impl Tty {
}
let mut device = self.output_device.take().unwrap();
+ device
+ .dmabuf_state
+ .destroy_global::<State>(&niri.display_handle, device.dmabuf_global);
device.gles.unbind_wl_display();
+
niri.event_loop.remove(device.token);
}
@@ -582,6 +598,10 @@ impl Tty {
}
}
}
+
+ pub fn dmabuf_state(&mut self) -> &mut DmabufState {
+ &mut self.output_device.as_mut().unwrap().dmabuf_state
+ }
}
fn refresh_interval(mode: DrmMode) -> Duration {