Add `feat-monado-timings` build feature

This commit is contained in:
Aleksander 2026-03-28 11:07:32 +01:00
parent 80277e0c12
commit 8ad31cfa28
4 changed files with 119 additions and 84 deletions

View File

@ -9,11 +9,11 @@ repository = "https://github.com/wlx-team/wayvr"
keywords = [ keywords = [
"linux", "linux",
"openvr", "openvr",
"openxr",
"x11",
"wayland",
"openvr-overlay", "openvr-overlay",
"openxr",
"openxr-overlay", "openxr-overlay",
"wayland",
"x11",
] ]
categories = ["games"] categories = ["games"]
@ -32,11 +32,11 @@ glam = { workspace = true, features = ["mint", "serde"] }
idmap = { workspace = true, features = ["serde"] } idmap = { workspace = true, features = ["serde"] }
idmap-derive.workspace = true idmap-derive.workspace = true
log.workspace = true log.workspace = true
rust-embed.workspace = true
regex.workspace = true regex.workspace = true
slotmap.workspace = true rust-embed.workspace = true
serde = { workspace = true, features = ["rc"] } serde = { workspace = true, features = ["rc"] }
serde_json.workspace = true serde_json.workspace = true
slotmap.workspace = true
strum.workspace = true strum.workspace = true
vulkano.workspace = true vulkano.workspace = true
vulkano-shaders.workspace = true vulkano-shaders.workspace = true
@ -45,7 +45,6 @@ xdg.workspace = true
ash = "^0.38.0" # must match vulkano ash = "^0.38.0" # must match vulkano
bytes = { version = "1.11.1" } bytes = { version = "1.11.1" }
chrono = { version = "0.4.42", features = ["unstable-locales"] } chrono = { version = "0.4.42", features = ["unstable-locales"] }
pure-rust-locales = "0.8.2"
chrono-tz = "0.10.4" chrono-tz = "0.10.4"
config = "0.15.19" config = "0.15.19"
dbus = { version = "0.9.9" } dbus = { version = "0.9.9" }
@ -58,15 +57,16 @@ interprocess = { version = "2.2.3" }
json = { version = "0.12.4", optional = true } json = { version = "0.12.4", optional = true }
json5 = "1.3.0" json5 = "1.3.0"
libc = "0.2.178" libc = "0.2.178"
smol = { workspace = true }
libmonado = { git = "https://github.com/oo8dev/libmonado-rs.git", rev = "fc39940a64dea2df080a0d2c974c7d651006241f", optional = true } libmonado = { git = "https://github.com/oo8dev/libmonado-rs.git", rev = "fc39940a64dea2df080a0d2c974c7d651006241f", optional = true }
log-panics = { version = "2.1.0", features = ["with-backtrace"] } log-panics = { version = "2.1.0", features = ["with-backtrace"] }
mint = "0.5.9" mint = "0.5.9"
openxr = { version = "0.21.0", features = ["linked", "mint"], optional = true } openxr = { version = "0.21.0", features = ["linked", "mint"], optional = true }
ovr_overlay = { features = [ ovr_overlay = { git = "https://github.com/galister/ovr_overlay_oyasumi", rev = "e477bd2a9e04293ea68c1e7529ef2cb131f32acc", features = [
"ovr_input", "ovr_input",
"ovr_system", "ovr_system",
], git = "https://github.com/galister/ovr_overlay_oyasumi", rev = "e477bd2a9e04293ea68c1e7529ef2cb131f32acc", optional = true } ], optional = true }
prost = { version = "0.14.3", optional = true }
pure-rust-locales = "0.8.2"
rosc = { version = "0.11.4", optional = true } rosc = { version = "0.11.4", optional = true }
serde_json5 = "0.2.1" serde_json5 = "0.2.1"
serde_yaml = "0.9.34" serde_yaml = "0.9.34"
@ -75,33 +75,34 @@ smallvec = "1.15.1"
smithay = { version = "0.7.0", default-features = false, features = [ smithay = { version = "0.7.0", default-features = false, features = [
"backend_vulkan", "backend_vulkan",
"desktop", "desktop",
"xwayland",
"wayland_frontend", "wayland_frontend",
"xwayland",
] } ] }
smol = { workspace = true }
sysinfo = { version = "0.37" } sysinfo = { version = "0.37" }
thiserror = "2.0" thiserror = "2.0"
tracing-subscriber = { version = "0.3.22", features = ["env-filter"] }
tracing = "0.1.43" tracing = "0.1.43"
uuid = { version = "1.19.0", features = ["v4", "fast-rng"] } tracing-subscriber = { version = "0.3.22", features = ["env-filter"] }
uuid = { version = "1.19.0", features = ["fast-rng", "v4"] }
wayland-client = { workspace = true } wayland-client = { workspace = true }
winit = { version = "0.30.12", optional = true } winit = { version = "0.30.12", optional = true }
xcb = { version = "1.6.0", optional = true, features = [ xcb = { version = "1.6.0", features = [
"as-raw-xcb-connection", "as-raw-xcb-connection",
] } ], optional = true }
xkbcommon = { version = "0.8.0" } # 0.9.0 breaks keymap import on some distros xkbcommon = { version = "0.8.0" } # 0.9.0 breaks keymap import on some distros
prost = { version = "0.14.3", optional = true }
[build-dependencies] [build-dependencies]
regex.workspace = true regex.workspace = true
[features] [features]
default = ["openvr", "openxr", "osc", "x11", "wayland"] default = ["openvr", "openxr", "osc", "wayland", "x11"]
openvr = ["dep:ovr_overlay", "dep:json"] as-raw-xcb-connection = []
openxr = ["dep:openxr", "dep:libmonado", "dep:prost"] feat-monado-metrics = []
openvr = ["dep:json", "dep:ovr_overlay"]
openxr = ["dep:libmonado", "dep:openxr", "dep:prost"]
osc = ["dep:rosc"] osc = ["dep:rosc"]
x11 = ["dep:xcb", "wlx-capture/xshm", "xkbcommon/x11"]
wayland = ["pipewire", "wlx-capture/wlr", "xkbcommon/wayland"]
pipewire = ["wlx-capture/pipewire"] pipewire = ["wlx-capture/pipewire"]
uidev = ["dep:winit"] uidev = ["dep:winit"]
wayland = ["pipewire", "wlx-capture/wlr", "xkbcommon/wayland"]
x11 = ["dep:xcb", "wlx-capture/xshm", "xkbcommon/x11"]
xcb = ["dep:xcb"] xcb = ["dep:xcb"]
as-raw-xcb-connection = []

View File

@ -1,18 +1,26 @@
#[cfg(feature = "feat-monado-metrics")]
use crate::subsystem::monado_metrics::{self, metrics_fd::MonadoMetricsFd}; use crate::subsystem::monado_metrics::{self, metrics_fd::MonadoMetricsFd};
pub struct MonadoState { pub struct MonadoState {
pub ipc: libmonado::Monado, pub ipc: libmonado::Monado,
#[cfg(feature = "feat-monado-metrics")]
pub metrics: Option<MonadoMetricsFd>, pub metrics: Option<MonadoMetricsFd>,
} }
impl MonadoState { impl MonadoState {
pub fn new() -> anyhow::Result<Self> { pub fn new() -> anyhow::Result<Self> {
let ipc = libmonado::Monado::auto_connect().map_err(|s| anyhow::anyhow!("{s}"))?; let ipc = libmonado::Monado::auto_connect().map_err(|s| anyhow::anyhow!("{s}"))?;
let res = Self { ipc, metrics: None }; let res = Self {
ipc,
#[cfg(feature = "feat-monado-metrics")]
metrics: None,
};
Ok(res) Ok(res)
} }
pub fn update(&mut self) { pub fn update(&mut self) {
#[cfg(feature = "feat-monado-metrics")]
if let Some(metrics) = &mut self.metrics { if let Some(metrics) = &mut self.metrics {
metrics.update(); metrics.update();
@ -23,6 +31,8 @@ impl MonadoState {
} }
pub fn set_metrics_enabled(&mut self, enabled: bool) -> anyhow::Result<()> { pub fn set_metrics_enabled(&mut self, enabled: bool) -> anyhow::Result<()> {
#[cfg(feature = "feat-monado-metrics")]
{
if enabled { if enabled {
if self.metrics.is_none() { if self.metrics.is_none() {
log::info!("Starting Monado metrics"); log::info!("Starting Monado metrics");
@ -36,6 +46,12 @@ impl MonadoState {
} }
self.metrics = None; self.metrics = None;
} }
}
#[cfg(not(feature = "feat-monado-metrics"))]
{
#[allow(path_statements)]
enabled;
}
Ok(()) Ok(())
} }

View File

@ -533,6 +533,8 @@ impl DashInterface<AppState> for DashInterfaceLive {
#[cfg(feature = "openxr")] #[cfg(feature = "openxr")]
fn monado_metrics_set_enabled(&mut self, app: &mut AppState, enabled: bool) -> bool { fn monado_metrics_set_enabled(&mut self, app: &mut AppState, enabled: bool) -> bool {
#[cfg(feature = "feat-monado-metrics")]
{
let Some(monado) = &mut app.monado_state else { let Some(monado) = &mut app.monado_state else {
return false; return false;
}; };
@ -541,9 +543,16 @@ impl DashInterface<AppState> for DashInterfaceLive {
log::error!("failed to enable metrics: {e:?}"); log::error!("failed to enable metrics: {e:?}");
return false; return false;
} }
true true
} }
#[cfg(not(feature = "feat-monado-metrics"))]
#[allow(path_statements)]
{
app;
enabled;
false
}
}
#[cfg(feature = "openxr")] #[cfg(feature = "openxr")]
#[allow(clippy::match_same_arms)] #[allow(clippy::match_same_arms)]
@ -551,10 +560,11 @@ impl DashInterface<AppState> for DashInterfaceLive {
&mut self, &mut self,
app: &mut AppState, app: &mut AppState,
) -> Vec<dash_interface::MonadoDumpSessionFrame> { ) -> Vec<dash_interface::MonadoDumpSessionFrame> {
#[cfg(feature = "feat-monado-metrics")]
{
let Some(monado) = &mut app.monado_state else { let Some(monado) = &mut app.monado_state else {
return Vec::new(); return Vec::new();
}; };
let Some(metrics) = &mut monado.metrics else { let Some(metrics) = &mut monado.metrics else {
return Vec::new(); // metrics not enabled or not available return Vec::new(); // metrics not enabled or not available
}; };
@ -594,6 +604,13 @@ impl DashInterface<AppState> for DashInterfaceLive {
}) })
.collect() .collect()
} }
#[cfg(not(feature = "feat-monado-metrics"))]
#[allow(path_statements)]
{
app;
Vec::new()
}
}
#[cfg(not(feature = "openxr"))] #[cfg(not(feature = "openxr"))]
fn monado_client_list( fn monado_client_list(

View File

@ -7,4 +7,5 @@ pub mod notifications;
pub mod osc; pub mod osc;
#[cfg(feature = "openxr")] #[cfg(feature = "openxr")]
#[cfg(feature = "feat-monado-metrics")]
pub mod monado_metrics; pub mod monado_metrics;