feat: hardware accelerated wayland apps

This commit is contained in:
Nova
2023-06-26 20:31:38 -04:00
parent 6efa3a909e
commit de46726d01
4 changed files with 317 additions and 359 deletions

660
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -70,7 +70,13 @@ version = "0.16.7"
git = "https://github.com/smithay/smithay.git" # Until we get stereokit to understand OES samplers and external textures
# path = "../smithay"
default-features = false
features = ["desktop", "renderer_gl", "wayland_frontend"]
features = [
"desktop",
"backend_egl",
"renderer_gl",
"use_system_lib",
"wayland_frontend",
]
version = "*"
optional = true

View File

@@ -17,6 +17,7 @@ use color_eyre::eyre::Result;
use directories::ProjectDirs;
use once_cell::sync::OnceCell;
use stardust_xr::server;
use std::mem::ManuallyDrop;
use std::path::PathBuf;
use std::process::{Command, Stdio};
use std::sync::Arc;
@@ -249,7 +250,7 @@ fn main() -> Result<()> {
});
#[cfg(feature = "wayland")]
drop(wayland);
let wayland = ManuallyDrop::new(wayland);
let _ = event_stop_tx.send(());
event_thread

View File

@@ -19,7 +19,7 @@ use sk::StereoKitDraw;
use smithay::backend::allocator::dmabuf::Dmabuf;
use smithay::backend::egl::EGLContext;
use smithay::backend::renderer::gles::GlesRenderer;
use smithay::backend::renderer::ImportDma;
use smithay::backend::renderer::{ImportDma, ImportEgl};
use smithay::reexports::wayland_server::{backend::GlobalId, Display, ListeningSocket};
use std::os::unix::prelude::AsRawFd;
use std::{
@@ -72,7 +72,7 @@ pub struct Wayland {
impl Wayland {
pub fn new() -> Result<Self> {
let egl_raw_handles = get_sk_egl()?;
let renderer = unsafe {
let mut renderer = unsafe {
GlesRenderer::new(EGLContext::from_raw(
egl_raw_handles.display,
egl_raw_handles.config,
@@ -82,6 +82,7 @@ impl Wayland {
let display: Display<WaylandState> = Display::new()?;
let display_handle = display.handle();
renderer.bind_wl_display(&display_handle)?;
let (dmabuf_tx, dmabuf_rx) = mpsc::unbounded_channel();
let display = Arc::new(Mutex::new(display));