pipewire pause/resume, update wlx-capture, pipewire dmabuf preps
This commit is contained in:
68
Cargo.lock
generated
68
Cargo.lock
generated
@@ -288,7 +288,7 @@ dependencies = [
|
||||
"futures-lite 2.2.0",
|
||||
"parking",
|
||||
"polling 3.3.2",
|
||||
"rustix 0.38.30",
|
||||
"rustix 0.38.31",
|
||||
"slab",
|
||||
"tracing",
|
||||
"windows-sys 0.52.0",
|
||||
@@ -338,7 +338,7 @@ dependencies = [
|
||||
"cfg-if",
|
||||
"event-listener 3.1.0",
|
||||
"futures-lite 1.13.0",
|
||||
"rustix 0.38.30",
|
||||
"rustix 0.38.31",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
@@ -365,7 +365,7 @@ dependencies = [
|
||||
"cfg-if",
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
"rustix 0.38.30",
|
||||
"rustix 0.38.31",
|
||||
"signal-hook-registry",
|
||||
"slab",
|
||||
"windows-sys 0.48.0",
|
||||
@@ -683,7 +683,7 @@ dependencies = [
|
||||
"bitflags 2.4.2",
|
||||
"log",
|
||||
"polling 3.3.2",
|
||||
"rustix 0.38.30",
|
||||
"rustix 0.38.31",
|
||||
"slab",
|
||||
"thiserror",
|
||||
]
|
||||
@@ -695,7 +695,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f0ea9b9476c7fad82841a8dbb380e2eae480c21910feba80725b46931ed8f02"
|
||||
dependencies = [
|
||||
"calloop 0.12.4",
|
||||
"rustix 0.38.30",
|
||||
"rustix 0.38.31",
|
||||
"wayland-backend 0.3.3",
|
||||
"wayland-client 0.31.2",
|
||||
]
|
||||
@@ -1070,9 +1070,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "darling"
|
||||
version = "0.20.4"
|
||||
version = "0.20.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da01daa5f6d41c91358398e8db4dde38e292378da1f28300b59ef4732b879454"
|
||||
checksum = "fc5d6b04b3fd0ba9926f945895de7d806260a2d7431ba82e7edaecb043c4c6b8"
|
||||
dependencies = [
|
||||
"darling_core",
|
||||
"darling_macro",
|
||||
@@ -1080,9 +1080,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "darling_core"
|
||||
version = "0.20.4"
|
||||
version = "0.20.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f44f6238b948a3c6c3073cdf53bb0c2d5e024ee27e0f35bfe9d556a12395808a"
|
||||
checksum = "04e48a959bcd5c761246f5d090ebc2fbf7b9cd527a492b07a67510c108f1e7e3"
|
||||
dependencies = [
|
||||
"fnv",
|
||||
"ident_case",
|
||||
@@ -1093,9 +1093,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "darling_macro"
|
||||
version = "0.20.4"
|
||||
version = "0.20.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d2d88bd93979b1feb760a6b5c531ac5ba06bd63e74894c377af02faee07b9cd"
|
||||
checksum = "1d1545d67a2149e1d93b7e5c7752dce5a7426eb5d1357ddcfd89336b94444f77"
|
||||
dependencies = [
|
||||
"darling_core",
|
||||
"quote",
|
||||
@@ -1729,9 +1729,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.2.1"
|
||||
version = "2.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "433de089bd45971eecf4668ee0ee8f4cec17db4f8bd8f7bc3197a6ce37aa7d9b"
|
||||
checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown 0.14.3",
|
||||
@@ -1790,7 +1790,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0bad00257d07be169d870ab665980b06cdb366d792ad690bf2e76876dc503455"
|
||||
dependencies = [
|
||||
"hermit-abi 0.3.4",
|
||||
"rustix 0.38.30",
|
||||
"rustix 0.38.31",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
@@ -1900,9 +1900,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.152"
|
||||
version = "0.2.153"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7"
|
||||
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
@@ -2580,7 +2580,7 @@ dependencies = [
|
||||
"cfg-if",
|
||||
"concurrent-queue",
|
||||
"pin-project-lite",
|
||||
"rustix 0.38.30",
|
||||
"rustix 0.38.31",
|
||||
"tracing",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
@@ -2841,9 +2841,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.30"
|
||||
version = "0.38.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca"
|
||||
checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949"
|
||||
dependencies = [
|
||||
"bitflags 2.4.2",
|
||||
"errno",
|
||||
@@ -2969,7 +2969,7 @@ version = "0.9.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "adf8a49373e98a4c5f0ceb5d05aa7c648d75f63774981ed95b7c7443bbd50c6e"
|
||||
dependencies = [
|
||||
"indexmap 2.2.1",
|
||||
"indexmap 2.2.2",
|
||||
"itoa",
|
||||
"ryu",
|
||||
"serde",
|
||||
@@ -3096,7 +3096,7 @@ dependencies = [
|
||||
"libc",
|
||||
"log",
|
||||
"memmap2 0.9.4",
|
||||
"rustix 0.38.30",
|
||||
"rustix 0.38.31",
|
||||
"thiserror",
|
||||
"wayland-backend 0.3.3",
|
||||
"wayland-client 0.31.2",
|
||||
@@ -3224,7 +3224,7 @@ dependencies = [
|
||||
"cfg-if",
|
||||
"fastrand 2.0.1",
|
||||
"redox_syscall 0.4.1",
|
||||
"rustix 0.38.30",
|
||||
"rustix 0.38.31",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
@@ -3334,7 +3334,7 @@ version = "0.19.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
|
||||
dependencies = [
|
||||
"indexmap 2.2.1",
|
||||
"indexmap 2.2.2",
|
||||
"toml_datetime",
|
||||
"winnow",
|
||||
]
|
||||
@@ -3345,7 +3345,7 @@ version = "0.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338"
|
||||
dependencies = [
|
||||
"indexmap 2.2.1",
|
||||
"indexmap 2.2.2",
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
@@ -3496,7 +3496,7 @@ dependencies = [
|
||||
"crossbeam-queue",
|
||||
"half",
|
||||
"heck",
|
||||
"indexmap 2.2.1",
|
||||
"indexmap 2.2.2",
|
||||
"libloading 0.8.1",
|
||||
"objc",
|
||||
"once_cell",
|
||||
@@ -3649,7 +3649,7 @@ checksum = "9d50fa61ce90d76474c87f5fc002828d81b32677340112b4ef08079a9d459a40"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"downcast-rs",
|
||||
"rustix 0.38.30",
|
||||
"rustix 0.38.31",
|
||||
"scoped-tls",
|
||||
"smallvec",
|
||||
"wayland-sys 0.31.1",
|
||||
@@ -3675,7 +3675,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "82fb96ee935c2cea6668ccb470fb7771f6215d1691746c2d896b447a00ad3f1f"
|
||||
dependencies = [
|
||||
"bitflags 2.4.2",
|
||||
"rustix 0.38.30",
|
||||
"rustix 0.38.31",
|
||||
"wayland-backend 0.3.3",
|
||||
"wayland-scanner 0.31.1",
|
||||
]
|
||||
@@ -3708,7 +3708,7 @@ version = "0.31.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "71ce5fa868dd13d11a0d04c5e2e65726d0897be8de247c0c5a65886e283231ba"
|
||||
dependencies = [
|
||||
"rustix 0.38.30",
|
||||
"rustix 0.38.31",
|
||||
"wayland-client 0.31.2",
|
||||
"xcursor",
|
||||
]
|
||||
@@ -3850,7 +3850,7 @@ dependencies = [
|
||||
"either",
|
||||
"home",
|
||||
"once_cell",
|
||||
"rustix 0.38.30",
|
||||
"rustix 0.38.31",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4129,7 +4129,7 @@ dependencies = [
|
||||
"percent-encoding",
|
||||
"raw-window-handle 0.6.0",
|
||||
"redox_syscall 0.3.5",
|
||||
"rustix 0.38.30",
|
||||
"rustix 0.38.31",
|
||||
"sctk-adwaita",
|
||||
"smithay-client-toolkit 0.18.0",
|
||||
"smol_str",
|
||||
@@ -4150,9 +4150,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.5.35"
|
||||
version = "0.5.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1931d78a9c73861da0134f453bb1f790ce49b2e30eba8410b4b79bac72b46a2d"
|
||||
checksum = "818ce546a11a9986bc24f93d0cdf38a8a1a400f1473ea8c82e59f6e0ffab9249"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
@@ -4160,7 +4160,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "wlx-capture"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/galister/wlx-capture#9532ba1cc95453fd78d620a621c5073d10996d6c"
|
||||
source = "git+https://github.com/galister/wlx-capture#19fe836043dca52f273a4c487780608c5f56b157"
|
||||
dependencies = [
|
||||
"ashpd",
|
||||
"drm-fourcc",
|
||||
@@ -4238,7 +4238,7 @@ dependencies = [
|
||||
"libc",
|
||||
"libloading 0.8.1",
|
||||
"once_cell",
|
||||
"rustix 0.38.30",
|
||||
"rustix 0.38.31",
|
||||
"x11rb-protocol",
|
||||
]
|
||||
|
||||
|
||||
@@ -66,9 +66,9 @@ impl OverlayData<OpenVrOverlayData> {
|
||||
|
||||
pub(super) fn after_input(&mut self, overlay: &mut OverlayManager, app: &mut AppState) {
|
||||
if self.state.want_visible && !self.data.visible {
|
||||
self.show(overlay, app);
|
||||
self.show_internal(overlay, app);
|
||||
} else if !self.state.want_visible && self.data.visible {
|
||||
self.hide(overlay);
|
||||
self.hide_internal(overlay, app);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ impl OverlayData<OpenVrOverlayData> {
|
||||
}
|
||||
}
|
||||
|
||||
fn show(&mut self, overlay: &mut OverlayManager, app: &mut AppState) {
|
||||
fn show_internal(&mut self, overlay: &mut OverlayManager, app: &mut AppState) {
|
||||
let handle = match self.data.handle {
|
||||
Some(handle) => handle,
|
||||
None => self.initialize(overlay, app),
|
||||
@@ -92,9 +92,10 @@ impl OverlayData<OpenVrOverlayData> {
|
||||
panic!("Failed to show overlay: {}", e);
|
||||
}
|
||||
self.data.visible = true;
|
||||
self.backend.resume(app);
|
||||
}
|
||||
|
||||
fn hide(&mut self, overlay: &mut OverlayManager) {
|
||||
fn hide_internal(&mut self, overlay: &mut OverlayManager, app: &mut AppState) {
|
||||
let Some(handle) = self.data.handle else {
|
||||
return;
|
||||
};
|
||||
@@ -103,6 +104,7 @@ impl OverlayData<OpenVrOverlayData> {
|
||||
panic!("Failed to hide overlay: {}", e);
|
||||
}
|
||||
self.data.visible = false;
|
||||
self.backend.pause(app);
|
||||
}
|
||||
|
||||
pub(super) fn upload_color(&self, overlay: &mut OverlayManager) {
|
||||
|
||||
@@ -204,6 +204,10 @@ pub fn openxr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
|
||||
}
|
||||
}
|
||||
|
||||
overlays
|
||||
.iter_mut()
|
||||
.for_each(|o| o.after_input(&mut app_state));
|
||||
|
||||
let (_, views) = xr_state
|
||||
.session
|
||||
.locate_views(
|
||||
|
||||
@@ -6,12 +6,14 @@ use super::{swapchain::SwapchainRenderData, transform_to_posef, XrState};
|
||||
use crate::{
|
||||
backend::{openxr::swapchain::create_swapchain_render_data, overlay::OverlayData},
|
||||
graphics::WlxCommandBuffer,
|
||||
state::AppState,
|
||||
};
|
||||
use vulkano::image::view::ImageView;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct OpenXrOverlayData {
|
||||
last_view: Option<Arc<ImageView>>,
|
||||
last_visible: bool,
|
||||
pub(super) swapchain: Option<SwapchainRenderData>,
|
||||
pub(super) init: bool,
|
||||
}
|
||||
@@ -67,4 +69,15 @@ impl OverlayData<OpenXrOverlayData> {
|
||||
});
|
||||
Some(quad)
|
||||
}
|
||||
|
||||
pub(super) fn after_input(&mut self, app: &mut AppState) {
|
||||
if self.data.last_visible != self.state.want_visible {
|
||||
if self.state.want_visible {
|
||||
self.backend.resume(app);
|
||||
} else {
|
||||
self.backend.pause(app);
|
||||
}
|
||||
}
|
||||
self.data.last_visible = self.state.want_visible;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,6 +169,17 @@ where
|
||||
pub fn view(&mut self) -> Option<Arc<ImageView>> {
|
||||
self.backend.view()
|
||||
}
|
||||
pub fn set_visible(&mut self, app: &mut AppState, visible: bool) {
|
||||
let old_visible = self.state.want_visible;
|
||||
self.state.want_visible = visible;
|
||||
if visible != old_visible {
|
||||
if visible {
|
||||
self.backend.resume(app);
|
||||
} else {
|
||||
self.backend.pause(app);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait OverlayRenderer {
|
||||
|
||||
@@ -127,7 +127,9 @@ impl WlxGraphics {
|
||||
use winit::event_loop::EventLoop;
|
||||
|
||||
let event_loop = EventLoop::new().unwrap();
|
||||
let instance_extensions = Surface::required_extensions(&event_loop).unwrap();
|
||||
let mut instance_extensions = Surface::required_extensions(&event_loop).unwrap();
|
||||
|
||||
instance_extensions.khr_get_physical_device_properties2 = true;
|
||||
|
||||
let instance_extensions_raw = instance_extensions
|
||||
.clone()
|
||||
@@ -320,18 +322,20 @@ impl WlxGraphics {
|
||||
|
||||
#[cfg(feature = "openvr")]
|
||||
pub fn new_openvr(
|
||||
vk_instance_extensions: InstanceExtensions,
|
||||
mut vk_instance_extensions: InstanceExtensions,
|
||||
mut vk_device_extensions_fn: impl FnMut(&PhysicalDevice) -> DeviceExtensions,
|
||||
) -> Arc<Self> {
|
||||
#[cfg(debug_assertions)]
|
||||
let layers = vec!["VK_LAYER_KHRONOS_validation".to_owned()];
|
||||
#[cfg(not(debug_assertions))]
|
||||
//#[cfg(debug_assertions)]
|
||||
//let layers = vec!["VK_LAYER_KHRONOS_validation".to_owned()];
|
||||
//#[cfg(not(debug_assertions))]
|
||||
let layers = vec![];
|
||||
|
||||
let library = VulkanLibrary::new().unwrap();
|
||||
|
||||
log::debug!("Instance exts for runtime: {:?}", &vk_instance_extensions);
|
||||
|
||||
vk_instance_extensions.khr_get_physical_device_properties2 = true;
|
||||
|
||||
let instance = Instance::new(
|
||||
library,
|
||||
InstanceCreateInfo {
|
||||
|
||||
@@ -12,7 +12,10 @@ use std::{
|
||||
};
|
||||
use vulkano::{command_buffer::CommandBufferUsage, image::view::ImageView};
|
||||
use wlx_capture::{
|
||||
frame::WlxFrame,
|
||||
frame::{
|
||||
DrmFormat, WlxFrame, DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888, DRM_FORMAT_XBGR8888,
|
||||
DRM_FORMAT_XRGB8888,
|
||||
},
|
||||
pipewire::{pipewire_select_screen, PipewireCapture},
|
||||
wayland::{wayland_client::protocol::wl_output::Transform, WlxClient, WlxOutput},
|
||||
wlr_dmabuf::WlrDmabufCapture,
|
||||
@@ -33,6 +36,8 @@ use crate::{
|
||||
state::{AppSession, AppState},
|
||||
};
|
||||
|
||||
static DRM_FORMATS: once_cell::sync::OnceCell<Vec<DrmFormat>> = once_cell::sync::OnceCell::new();
|
||||
|
||||
pub struct ScreenInteractionHandler {
|
||||
next_scroll: Instant,
|
||||
next_move: Instant,
|
||||
@@ -154,7 +159,37 @@ impl OverlayRenderer for ScreenRenderer {
|
||||
}
|
||||
fn render(&mut self, app: &mut AppState) {
|
||||
let receiver = self.receiver.get_or_insert_with(|| {
|
||||
let rx = self.capture.init();
|
||||
let _drm_formats = DRM_FORMATS.get_or_init({
|
||||
let graphics = app.graphics.clone();
|
||||
move || {
|
||||
let possible_formats = [
|
||||
DRM_FORMAT_ABGR8888.into(),
|
||||
DRM_FORMAT_XBGR8888.into(),
|
||||
DRM_FORMAT_ARGB8888.into(),
|
||||
DRM_FORMAT_XRGB8888.into(),
|
||||
];
|
||||
let mut final_formats = vec![];
|
||||
|
||||
for &f in &possible_formats {
|
||||
let vk_fmt = fourcc_to_vk(f);
|
||||
let Ok(props) = graphics.device.physical_device().format_properties(vk_fmt)
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
final_formats.push(DrmFormat {
|
||||
fourcc: f,
|
||||
modifiers: props
|
||||
.drm_format_modifier_properties
|
||||
.iter()
|
||||
.map(|m| m.drm_format_modifier)
|
||||
.collect(),
|
||||
})
|
||||
}
|
||||
final_formats
|
||||
}
|
||||
});
|
||||
|
||||
let rx = self.capture.init(&[]); // TODO: use drm_formats
|
||||
self.capture.request_new_frame();
|
||||
rx
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user