refactor: use dmabuf v4 instead of bind_display
This commit is contained in:
31
Cargo.lock
generated
31
Cargo.lock
generated
@@ -808,30 +808,6 @@ dependencies = [
|
|||||||
"pin-utils",
|
"pin-utils",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "gbm"
|
|
||||||
version = "0.12.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f2ec389cda876966cf824111bf6e533fb934c711d473498279964a990853b3c6"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 1.3.2",
|
|
||||||
"drm",
|
|
||||||
"drm-fourcc",
|
|
||||||
"gbm-sys",
|
|
||||||
"libc",
|
|
||||||
"wayland-backend",
|
|
||||||
"wayland-server",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "gbm-sys"
|
|
||||||
version = "0.2.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b63eba9b9b7a231514482deb08759301c9f9f049ac6869403f381834ebfeaf67"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "getrandom"
|
name = "getrandom"
|
||||||
version = "0.2.10"
|
version = "0.2.10"
|
||||||
@@ -1991,8 +1967,9 @@ dependencies = [
|
|||||||
"calloop",
|
"calloop",
|
||||||
"cgmath",
|
"cgmath",
|
||||||
"downcast-rs",
|
"downcast-rs",
|
||||||
|
"drm",
|
||||||
|
"drm-ffi",
|
||||||
"drm-fourcc",
|
"drm-fourcc",
|
||||||
"gbm",
|
|
||||||
"gl_generator",
|
"gl_generator",
|
||||||
"indexmap 1.9.3",
|
"indexmap 1.9.3",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
@@ -2005,12 +1982,10 @@ dependencies = [
|
|||||||
"tempfile",
|
"tempfile",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tracing",
|
"tracing",
|
||||||
"wayland-backend",
|
|
||||||
"wayland-protocols",
|
"wayland-protocols",
|
||||||
"wayland-protocols-misc",
|
"wayland-protocols-misc",
|
||||||
"wayland-protocols-wlr",
|
"wayland-protocols-wlr",
|
||||||
"wayland-server",
|
"wayland-server",
|
||||||
"wayland-sys",
|
|
||||||
"xkbcommon",
|
"xkbcommon",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2629,9 +2604,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "96b2a02ac608e07132978689a6f9bf4214949c85998c247abadd4f4129b1aa06"
|
checksum = "96b2a02ac608e07132978689a6f9bf4214949c85998c247abadd4f4129b1aa06"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dlib",
|
"dlib",
|
||||||
"libc",
|
|
||||||
"log",
|
"log",
|
||||||
"memoffset 0.7.1",
|
|
||||||
"pkg-config",
|
"pkg-config",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -72,9 +72,8 @@ git = "https://github.com/smithay/smithay.git" # Until we get stereokit to under
|
|||||||
default-features = false
|
default-features = false
|
||||||
features = [
|
features = [
|
||||||
"desktop",
|
"desktop",
|
||||||
"backend_egl",
|
"backend_drm",
|
||||||
"renderer_gl",
|
"renderer_gl",
|
||||||
"use_system_lib",
|
|
||||||
"wayland_frontend",
|
"wayland_frontend",
|
||||||
]
|
]
|
||||||
version = "*"
|
version = "*"
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ use sk::StereoKitDraw;
|
|||||||
use smithay::backend::allocator::dmabuf::Dmabuf;
|
use smithay::backend::allocator::dmabuf::Dmabuf;
|
||||||
use smithay::backend::egl::EGLContext;
|
use smithay::backend::egl::EGLContext;
|
||||||
use smithay::backend::renderer::gles::GlesRenderer;
|
use smithay::backend::renderer::gles::GlesRenderer;
|
||||||
use smithay::backend::renderer::{ImportDma, ImportEgl};
|
use smithay::backend::renderer::ImportDma;
|
||||||
use smithay::reexports::wayland_server::{backend::GlobalId, Display, ListeningSocket};
|
use smithay::reexports::wayland_server::{backend::GlobalId, Display, ListeningSocket};
|
||||||
use std::os::unix::prelude::AsRawFd;
|
use std::os::unix::prelude::AsRawFd;
|
||||||
use std::{
|
use std::{
|
||||||
@@ -82,7 +82,6 @@ impl Wayland {
|
|||||||
|
|
||||||
let display: Display<WaylandState> = Display::new()?;
|
let display: Display<WaylandState> = Display::new()?;
|
||||||
let display_handle = display.handle();
|
let display_handle = display.handle();
|
||||||
renderer.bind_wl_display(&display_handle)?;
|
|
||||||
|
|
||||||
let (dmabuf_tx, dmabuf_rx) = mpsc::unbounded_channel();
|
let (dmabuf_tx, dmabuf_rx) = mpsc::unbounded_channel();
|
||||||
let display = Arc::new(Mutex::new(display));
|
let display = Arc::new(Mutex::new(display));
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ use rustc_hash::FxHashMap;
|
|||||||
use smithay::{
|
use smithay::{
|
||||||
backend::{
|
backend::{
|
||||||
allocator::dmabuf::Dmabuf,
|
allocator::dmabuf::Dmabuf,
|
||||||
|
egl::EGLDevice,
|
||||||
renderer::{gles::GlesRenderer, ImportDma},
|
renderer::{gles::GlesRenderer, ImportDma},
|
||||||
},
|
},
|
||||||
delegate_dmabuf, delegate_output, delegate_shm,
|
delegate_dmabuf, delegate_output, delegate_shm,
|
||||||
@@ -24,14 +25,17 @@ use smithay::{
|
|||||||
wayland::{
|
wayland::{
|
||||||
buffer::BufferHandler,
|
buffer::BufferHandler,
|
||||||
compositor::{CompositorClientState, CompositorState},
|
compositor::{CompositorClientState, CompositorState},
|
||||||
dmabuf::{self, DmabufGlobal, DmabufHandler, DmabufState, ImportError},
|
dmabuf::{
|
||||||
|
self, DmabufFeedback, DmabufFeedbackBuilder, DmabufGlobal, DmabufHandler, DmabufState,
|
||||||
|
ImportError,
|
||||||
|
},
|
||||||
shell::kde::decoration::KdeDecorationState,
|
shell::kde::decoration::KdeDecorationState,
|
||||||
shm::{ShmHandler, ShmState},
|
shm::{ShmHandler, ShmState},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use std::sync::{Arc, Weak};
|
use std::sync::{Arc, Weak};
|
||||||
use tokio::sync::mpsc::UnboundedSender;
|
use tokio::sync::mpsc::UnboundedSender;
|
||||||
use tracing::info;
|
use tracing::{info, warn};
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct ClientState {
|
pub struct ClientState {
|
||||||
@@ -59,8 +63,7 @@ pub struct WaylandState {
|
|||||||
// pub xdg_activation_state: XdgActivationState,
|
// pub xdg_activation_state: XdgActivationState,
|
||||||
pub kde_decoration_state: KdeDecorationState,
|
pub kde_decoration_state: KdeDecorationState,
|
||||||
pub shm_state: ShmState,
|
pub shm_state: ShmState,
|
||||||
dmabuf_state: DmabufState,
|
dmabuf_state: (DmabufState, DmabufGlobal, Option<DmabufFeedback>),
|
||||||
_dmabuf_global: DmabufGlobal,
|
|
||||||
dmabuf_tx: UnboundedSender<Dmabuf>,
|
dmabuf_tx: UnboundedSender<Dmabuf>,
|
||||||
pub output: Output,
|
pub output: Output,
|
||||||
pub seats: FxHashMap<ClientId, Arc<SeatData>>,
|
pub seats: FxHashMap<ClientId, Arc<SeatData>>,
|
||||||
@@ -78,11 +81,44 @@ impl WaylandState {
|
|||||||
let kde_decoration_state =
|
let kde_decoration_state =
|
||||||
KdeDecorationState::new::<Self>(&display_handle, DecorationMode::Server);
|
KdeDecorationState::new::<Self>(&display_handle, DecorationMode::Server);
|
||||||
let shm_state = ShmState::new::<Self>(&display_handle, vec![]);
|
let shm_state = ShmState::new::<Self>(&display_handle, vec![]);
|
||||||
let mut dmabuf_state = DmabufState::new();
|
let render_node = EGLDevice::device_for_display(renderer.egl_context().display())
|
||||||
let dmabuf_global = dmabuf_state.create_global::<Self>(
|
.and_then(|device| device.try_get_render_node());
|
||||||
&display_handle,
|
|
||||||
renderer.dmabuf_formats().collect::<Vec<_>>(),
|
let dmabuf_default_feedback = match render_node {
|
||||||
);
|
Ok(Some(node)) => {
|
||||||
|
let dmabuf_formats = renderer.dmabuf_formats().collect::<Vec<_>>();
|
||||||
|
let dmabuf_default_feedback =
|
||||||
|
DmabufFeedbackBuilder::new(node.dev_id(), dmabuf_formats)
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
Some(dmabuf_default_feedback)
|
||||||
|
}
|
||||||
|
Ok(None) => {
|
||||||
|
warn!("failed to query render node, dmabuf will use v3");
|
||||||
|
None
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
warn!(?err, "failed to egl device for display, dmabuf will use v3");
|
||||||
|
None
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// if we failed to build dmabuf feedback we fall back to dmabuf v3
|
||||||
|
// Note: egl on Mesa requires either v4 or wl_drm (initialized with bind_wl_display)
|
||||||
|
let dmabuf_state = if let Some(default_feedback) = dmabuf_default_feedback {
|
||||||
|
let mut dmabuf_state = DmabufState::new();
|
||||||
|
let dmabuf_global = dmabuf_state.create_global_with_default_feedback::<WaylandState>(
|
||||||
|
&display_handle,
|
||||||
|
&default_feedback,
|
||||||
|
);
|
||||||
|
(dmabuf_state, dmabuf_global, Some(default_feedback))
|
||||||
|
} else {
|
||||||
|
let dmabuf_formats = renderer.dmabuf_formats().collect::<Vec<_>>();
|
||||||
|
let mut dmabuf_state = DmabufState::new();
|
||||||
|
let dmabuf_global =
|
||||||
|
dmabuf_state.create_global::<WaylandState>(&display_handle, dmabuf_formats);
|
||||||
|
(dmabuf_state, dmabuf_global, None)
|
||||||
|
};
|
||||||
|
|
||||||
let output = Output::new(
|
let output = Output::new(
|
||||||
"1x".to_owned(),
|
"1x".to_owned(),
|
||||||
smithay::output::PhysicalProperties {
|
smithay::output::PhysicalProperties {
|
||||||
@@ -121,7 +157,6 @@ impl WaylandState {
|
|||||||
kde_decoration_state,
|
kde_decoration_state,
|
||||||
shm_state,
|
shm_state,
|
||||||
dmabuf_state,
|
dmabuf_state,
|
||||||
_dmabuf_global: dmabuf_global,
|
|
||||||
dmabuf_tx,
|
dmabuf_tx,
|
||||||
output,
|
output,
|
||||||
seats: FxHashMap::default(),
|
seats: FxHashMap::default(),
|
||||||
@@ -149,7 +184,7 @@ impl ShmHandler for WaylandState {
|
|||||||
}
|
}
|
||||||
impl DmabufHandler for WaylandState {
|
impl DmabufHandler for WaylandState {
|
||||||
fn dmabuf_state(&mut self) -> &mut DmabufState {
|
fn dmabuf_state(&mut self) -> &mut DmabufState {
|
||||||
&mut self.dmabuf_state
|
&mut self.dmabuf_state.0
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dmabuf_imported(
|
fn dmabuf_imported(
|
||||||
|
|||||||
Reference in New Issue
Block a user