debug: Fix running with new kms backend
This commit is contained in:
parent
bfbf20d61d
commit
ddcb435632
7 changed files with 93 additions and 90 deletions
|
|
@ -90,11 +90,14 @@ pub use self::timings::Timings;
|
||||||
use super::{drm_helpers, render::gles::GbmGlowBackend};
|
use super::{drm_helpers, render::gles::GbmGlowBackend};
|
||||||
|
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
static INTEL_LOGO: &'static [u8] = include_bytes!("../resources/icons/intel.svg");
|
use smithay_egui::EguiState;
|
||||||
|
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
static AMD_LOGO: &'static [u8] = include_bytes!("../resources/icons/amd.svg");
|
static INTEL_LOGO: &'static [u8] = include_bytes!("../../../../resources/icons/intel.svg");
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
static NVIDIA_LOGO: &'static [u8] = include_bytes!("../resources/icons/nvidia.svg");
|
static AMD_LOGO: &'static [u8] = include_bytes!("../../../../resources/icons/amd.svg");
|
||||||
|
#[cfg(feature = "debug")]
|
||||||
|
static NVIDIA_LOGO: &'static [u8] = include_bytes!("../../../../resources/icons/nvidia.svg");
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Surface {
|
pub struct Surface {
|
||||||
|
|
@ -640,6 +643,19 @@ impl SurfaceThreadState {
|
||||||
unsafe { GlowRenderer::new(egl) }.context("Failed to create renderer")?;
|
unsafe { GlowRenderer::new(egl) }.context("Failed to create renderer")?;
|
||||||
init_shaders(renderer.borrow_mut()).context("Failed to initialize shaders")?;
|
init_shaders(renderer.borrow_mut()).context("Failed to initialize shaders")?;
|
||||||
|
|
||||||
|
#[cfg(feature = "debug")]
|
||||||
|
{
|
||||||
|
self.egui
|
||||||
|
.load_svg(&mut renderer, String::from("intel"), INTEL_LOGO)
|
||||||
|
.unwrap();
|
||||||
|
self.egui
|
||||||
|
.load_svg(&mut renderer, String::from("amd"), AMD_LOGO)
|
||||||
|
.unwrap();
|
||||||
|
self.egui
|
||||||
|
.load_svg(&mut renderer, String::from("nvidia"), NVIDIA_LOGO)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
self.api.as_mut().add_node(node, gbm, renderer);
|
self.api.as_mut().add_node(node, gbm, renderer);
|
||||||
/*
|
/*
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -647,20 +663,6 @@ impl SurfaceThreadState {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#[cfg(feature = "debug")]
|
|
||||||
{
|
|
||||||
let renderer = self.api.single_renderer(node);
|
|
||||||
self.egui
|
|
||||||
.load_svg(renderer, String::from("intel"), INTEL_LOGO)
|
|
||||||
.unwrap();
|
|
||||||
self.egui
|
|
||||||
.load_svg(renderer, String::from("amd"), AMD_LOGO)
|
|
||||||
.unwrap();
|
|
||||||
self.egui
|
|
||||||
.load_svg(renderer, String::from("nvidia"), NVIDIA_LOGO)
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -840,13 +842,6 @@ impl SurfaceThreadState {
|
||||||
};
|
};
|
||||||
|
|
||||||
self.timings.start_render(&self.clock);
|
self.timings.start_render(&self.clock);
|
||||||
#[cfg(feature = "debug")]
|
|
||||||
if let Some(rd) = self.timings.rd.as_mut() {
|
|
||||||
rd.start_frame_capture(
|
|
||||||
renderer.glow_renderer().egl_context().get_context_handle(),
|
|
||||||
std::ptr::null(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut elements = {
|
let mut elements = {
|
||||||
let shell = self.shell.read().unwrap();
|
let shell = self.shell.read().unwrap();
|
||||||
|
|
|
||||||
|
|
@ -148,23 +148,25 @@ impl Timings {
|
||||||
.unwrap_or(Duration::ZERO)
|
.unwrap_or(Duration::ZERO)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
pub fn max_frametime(&self, window: usize) -> Duration {
|
||||||
pub fn max_time_to_display(&self) -> Duration {
|
|
||||||
self.previous_frames
|
self.previous_frames
|
||||||
.iter()
|
.iter()
|
||||||
.map(|f| f.time_to_display())
|
.rev()
|
||||||
|
.take(window)
|
||||||
|
.map(|f| f.frame_time())
|
||||||
.max()
|
.max()
|
||||||
.unwrap_or(Duration::ZERO)
|
.unwrap_or(Duration::ZERO)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn min_time_to_display(&self) -> Duration {
|
pub fn min_frametime(&self, window: usize) -> Duration {
|
||||||
self.previous_frames
|
self.previous_frames
|
||||||
.iter()
|
.iter()
|
||||||
.map(|f| f.time_to_display())
|
.rev()
|
||||||
|
.take(window)
|
||||||
|
.map(|f| f.frame_time())
|
||||||
.min()
|
.min()
|
||||||
.unwrap_or(Duration::ZERO)
|
.unwrap_or(Duration::ZERO)
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
pub fn avg_rendertime(&self) -> Duration {
|
pub fn avg_rendertime(&self) -> Duration {
|
||||||
if self.previous_frames.is_empty() {
|
if self.previous_frames.is_empty() {
|
||||||
|
|
@ -178,7 +180,7 @@ impl Timings {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn avg_frametime(&self, window: usize) -> Duration {
|
pub fn avg_frametime(&self, window: usize) -> Duration {
|
||||||
if self.previous_frames.is_empty() {
|
if self.previous_frames.is_empty() || window == 0 {
|
||||||
return MIN_RENDER_TIME;
|
return MIN_RENDER_TIME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,6 @@ use smithay::{
|
||||||
utils::{Buffer as BufferCoords, Logical, Physical, Point, Rectangle, Scale},
|
utils::{Buffer as BufferCoords, Logical, Physical, Point, Rectangle, Scale},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "debug")]
|
|
||||||
use smithay::backend::renderer::{element::texture::TextureRenderElement, gles::GlesTexture};
|
|
||||||
|
|
||||||
use super::{cursor::CursorRenderElement, GlMultiError, GlMultiFrame, GlMultiRenderer};
|
use super::{cursor::CursorRenderElement, GlMultiError, GlMultiFrame, GlMultiRenderer};
|
||||||
|
|
||||||
pub enum CosmicElement<R>
|
pub enum CosmicElement<R>
|
||||||
|
|
|
||||||
|
|
@ -508,7 +508,7 @@ where
|
||||||
let output_geo = output.geometry();
|
let output_geo = output.geometry();
|
||||||
let scale = output.current_scale().fractional_scale();
|
let scale = output.current_scale().fractional_scale();
|
||||||
|
|
||||||
if let Some((state, timings)) = _fps.as_mut() {
|
if let Some((state, timings)) = _fps {
|
||||||
let debug_active = shell.read().unwrap().debug_active;
|
let debug_active = shell.read().unwrap().debug_active;
|
||||||
let fps_overlay = fps_ui(
|
let fps_overlay = fps_ui(
|
||||||
_gpu,
|
_gpu,
|
||||||
|
|
@ -523,7 +523,7 @@ where
|
||||||
),
|
),
|
||||||
scale,
|
scale,
|
||||||
)
|
)
|
||||||
.map_err(<R as Renderer>::Error::from)
|
.map_err(FromGlesError::from_gles_error)
|
||||||
.map_err(RenderError::Rendering)?;
|
.map_err(RenderError::Rendering)?;
|
||||||
elements.push(fps_overlay.into());
|
elements.push(fps_overlay.into());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
113
src/debug.rs
113
src/debug.rs
|
|
@ -4,8 +4,8 @@ use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
backend::kms::Timings,
|
backend::kms::Timings,
|
||||||
shell::focus::target::{KeyboardFocusTarget, PointerFocusTarget},
|
shell::focus::target::{KeyboardFocusTarget, PointerFocusTarget, PointerFocusToplevel},
|
||||||
state::{Common, Fps},
|
State,
|
||||||
};
|
};
|
||||||
use egui::{load::SizedTexture, Color32, Vec2};
|
use egui::{load::SizedTexture, Color32, Vec2};
|
||||||
use smithay::{
|
use smithay::{
|
||||||
|
|
@ -18,10 +18,11 @@ use smithay::{
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
desktop::WindowSurface,
|
desktop::WindowSurface,
|
||||||
input::keyboard::xkb,
|
input::{keyboard::xkb, Seat},
|
||||||
reexports::wayland_server::Resource,
|
reexports::wayland_server::Resource,
|
||||||
utils::{Logical, Rectangle},
|
utils::{Logical, Rectangle, Time},
|
||||||
};
|
};
|
||||||
|
use smithay_egui::EguiState;
|
||||||
|
|
||||||
pub const ELEMENTS_COLOR: Color32 = Color32::from_rgb(70, 198, 115);
|
pub const ELEMENTS_COLOR: Color32 = Color32::from_rgb(70, 198, 115);
|
||||||
pub const RENDER_COLOR: Color32 = Color32::from_rgb(29, 114, 58);
|
pub const RENDER_COLOR: Color32 = Color32::from_rgb(29, 114, 58);
|
||||||
|
|
@ -41,18 +42,20 @@ pub fn fps_ui<'a>(
|
||||||
use egui_plot::{Bar, BarChart, Legend, Plot};
|
use egui_plot::{Bar, BarChart, Legend, Plot};
|
||||||
|
|
||||||
let (max, min, avg, avg_fps) = (
|
let (max, min, avg, avg_fps) = (
|
||||||
timings.max_frametime().as_secs_f64(),
|
timings.max_rendertime().as_secs_f64(),
|
||||||
timings.min_frametime().as_secs_f64(),
|
timings.min_rendertime().as_secs_f64(),
|
||||||
timings.avg_frametime().as_secs_f64(),
|
timings.avg_rendertime().as_secs_f64(),
|
||||||
timings.avg_fps(),
|
timings.avg_fps(),
|
||||||
);
|
);
|
||||||
let (max_disp, min_disp) = (
|
|
||||||
timings.max_time_to_display().as_secs_f64(),
|
|
||||||
timings.min_time_to_display().as_secs_f64(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let amount = avg_fps.round() as usize * 2;
|
let amount = avg_fps.round() as usize * 2;
|
||||||
let ((bars_elements, bars_render), (bars_screencopy, bars_displayed)): (
|
let (max_disp, min_disp, avg_disp) = (
|
||||||
|
timings.min_frametime(amount).as_secs_f64(),
|
||||||
|
timings.max_frametime(amount).as_secs_f64(),
|
||||||
|
timings.avg_frametime(amount).as_secs_f64(),
|
||||||
|
);
|
||||||
|
|
||||||
|
let ((bars_elements, bars_render), (bars_submitted, bars_displayed)): (
|
||||||
(Vec<Bar>, Vec<Bar>),
|
(Vec<Bar>, Vec<Bar>),
|
||||||
(Vec<Bar>, Vec<Bar>),
|
(Vec<Bar>, Vec<Bar>),
|
||||||
) = timings
|
) = timings
|
||||||
|
|
@ -65,19 +68,17 @@ pub fn fps_ui<'a>(
|
||||||
.map(|(i, frame)| {
|
.map(|(i, frame)| {
|
||||||
let elements_val = frame.render_duration_elements.as_secs_f64();
|
let elements_val = frame.render_duration_elements.as_secs_f64();
|
||||||
let render_val = frame.render_duration_draw.as_secs_f64();
|
let render_val = frame.render_duration_draw.as_secs_f64();
|
||||||
let submitted_val = frame
|
let submitted_val =
|
||||||
.presentation_submitted
|
Time::elapsed(&frame.render_start, frame.presentation_submitted).as_secs_f64();
|
||||||
.as_ref()
|
let displayed_val =
|
||||||
.map(|val| val.as_secs_f64())
|
Time::elapsed(&frame.render_start, frame.presentation_presented).as_secs_f64();
|
||||||
.unwrap_or(0.0);
|
|
||||||
let displayed_val = frame.duration_displayed.as_secs_f64();
|
|
||||||
|
|
||||||
let transformed_elements =
|
let transformed_elements =
|
||||||
((elements_val - min_disp) / (max_disp - min_disp) * 255.0).round() as u8;
|
((elements_val - min_disp) / (max_disp - min_disp) * 255.0).round() as u8;
|
||||||
let transformed_render =
|
let transformed_render =
|
||||||
((render_val - min_disp) / (max_disp - min_disp) * 255.0).round() as u8;
|
((render_val - min_disp) / (max_disp - min_disp) * 255.0).round() as u8;
|
||||||
let transformed_screencopy =
|
let transformed_submitted =
|
||||||
((screencopy_val - min_disp) / (max_disp - min_disp) * 255.0).round() as u8;
|
((submitted_val - min_disp) / (max_disp - min_disp) * 255.0).round() as u8;
|
||||||
let transformed_displayed =
|
let transformed_displayed =
|
||||||
((displayed_val - min_disp) / (max_disp - min_disp) * 255.0).round() as u8;
|
((displayed_val - min_disp) / (max_disp - min_disp) * 255.0).round() as u8;
|
||||||
(
|
(
|
||||||
|
|
@ -86,7 +87,7 @@ pub fn fps_ui<'a>(
|
||||||
Bar::new(i as f64, transformed_render as f64).fill(RENDER_COLOR),
|
Bar::new(i as f64, transformed_render as f64).fill(RENDER_COLOR),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
Bar::new(i as f64, transformed_screencopy as f64).fill(SCREENCOPY_COLOR),
|
Bar::new(i as f64, transformed_submitted as f64).fill(SUBMITTED_COLOR),
|
||||||
Bar::new(i as f64, transformed_displayed as f64).fill(DISPLAY_COLOR),
|
Bar::new(i as f64, transformed_displayed as f64).fill(DISPLAY_COLOR),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
@ -134,7 +135,7 @@ pub fn fps_ui<'a>(
|
||||||
}
|
}
|
||||||
|
|
||||||
if !debug_active {
|
if !debug_active {
|
||||||
ui.label("Press Super+Escape for debug overlay");
|
ui.label("Press Super+Ctrl+Escape for debug overlay");
|
||||||
} else {
|
} else {
|
||||||
ui.set_max_width(300.0);
|
ui.set_max_width(300.0);
|
||||||
ui.separator();
|
ui.separator();
|
||||||
|
|
@ -158,19 +159,24 @@ pub fn fps_ui<'a>(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
ui.label(egui::RichText::new(format!("FPS: {:>7.3}", avg_fps)).heading());
|
ui.label(egui::RichText::new(format!("FPS: {:>7.3}", avg_fps)).heading());
|
||||||
ui.label("Frame Times:");
|
ui.label("Render Times:");
|
||||||
ui.label(egui::RichText::new(format!("avg: {:>7.6}", avg)).code());
|
ui.label(egui::RichText::new(format!("avg: {:>7.6}", avg)).code());
|
||||||
ui.label(egui::RichText::new(format!("min: {:>7.6}", min)).code());
|
ui.label(egui::RichText::new(format!("min: {:>7.6}", min)).code());
|
||||||
ui.label(egui::RichText::new(format!("max: {:>7.6}", max)).code());
|
ui.label(egui::RichText::new(format!("max: {:>7.6}", max)).code());
|
||||||
|
ui.label("Frame Times:");
|
||||||
|
ui.label(egui::RichText::new(format!("avg: {:>7.6}", avg_disp)).code());
|
||||||
|
ui.label(egui::RichText::new(format!("min: {:>7.6}", min_disp)).code());
|
||||||
|
ui.label(egui::RichText::new(format!("max: {:>7.6}", max_disp)).code());
|
||||||
|
|
||||||
let elements_chart = BarChart::new(bars_elements).vertical();
|
let elements_chart = BarChart::new(bars_elements).vertical();
|
||||||
let render_chart = BarChart::new(bars_render)
|
let render_chart = BarChart::new(bars_render)
|
||||||
.stack_on(&[&elements_chart])
|
.stack_on(&[&elements_chart])
|
||||||
.vertical();
|
.vertical();
|
||||||
let screencopy_chart = BarChart::new(bars_screencopy)
|
let submitted_chart = BarChart::new(bars_submitted)
|
||||||
.stack_on(&[&elements_chart, &render_chart])
|
.stack_on(&[&elements_chart, &render_chart])
|
||||||
.vertical();
|
.vertical();
|
||||||
let display_chart = BarChart::new(bars_displayed)
|
let display_chart = BarChart::new(bars_displayed)
|
||||||
.stack_on(&[&elements_chart, &render_chart, &screencopy_chart])
|
.stack_on(&[&elements_chart, &render_chart, &submitted_chart])
|
||||||
.vertical();
|
.vertical();
|
||||||
|
|
||||||
Plot::new("FPS")
|
Plot::new("FPS")
|
||||||
|
|
@ -184,7 +190,7 @@ pub fn fps_ui<'a>(
|
||||||
.show(ui, |plot_ui| {
|
.show(ui, |plot_ui| {
|
||||||
plot_ui.bar_chart(elements_chart);
|
plot_ui.bar_chart(elements_chart);
|
||||||
plot_ui.bar_chart(render_chart);
|
plot_ui.bar_chart(render_chart);
|
||||||
plot_ui.bar_chart(screencopy_chart);
|
plot_ui.bar_chart(submitted_chart);
|
||||||
plot_ui.bar_chart(display_chart);
|
plot_ui.bar_chart(display_chart);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -280,38 +286,39 @@ fn format_pointer_focus(focus: Option<PointerFocusTarget>) -> String {
|
||||||
use PointerFocusTarget::*;
|
use PointerFocusTarget::*;
|
||||||
|
|
||||||
match focus {
|
match focus {
|
||||||
Some(Element(x)) => match x {
|
Some(WlSurface { surface, toplevel }) => match toplevel {
|
||||||
x if x.is_stack() => format!(
|
Some(PointerFocusToplevel::Surface(window)) => {
|
||||||
"Stacked Window {} ({})",
|
format!(
|
||||||
match x.active_window().0.underlying_surface() {
|
"Window {} ({})",
|
||||||
WindowSurface::Wayland(t) => t.wl_surface().id().protocol_id(),
|
match window.0.underlying_surface() {
|
||||||
WindowSurface::X11(x) => x.window_id(),
|
WindowSurface::Wayland(_) => surface.id().protocol_id(),
|
||||||
},
|
WindowSurface::X11(x) => x.window_id(),
|
||||||
x.active_window().title()
|
},
|
||||||
),
|
window.title()
|
||||||
x if x.is_window() => format!(
|
)
|
||||||
"Window {} ({})",
|
}
|
||||||
match x.active_window().0.underlying_surface() {
|
Some(PointerFocusToplevel::Popup(_)) => {
|
||||||
WindowSurface::Wayland(t) => t.wl_surface().id().protocol_id(),
|
format!("Popup {}", surface.id().protocol_id())
|
||||||
WindowSurface::X11(x) => x.window_id(),
|
}
|
||||||
},
|
_ => format!("Surface {}", surface.id().protocol_id()),
|
||||||
x.active_window().title()
|
|
||||||
),
|
|
||||||
_ => unreachable!(),
|
|
||||||
},
|
},
|
||||||
Some(Fullscreen(x)) => format!(
|
Some(StackUI(stack)) => format!(
|
||||||
"Fullscreen {} ({})",
|
"Stack SSD {} ({})",
|
||||||
match x.0.underlying_surface() {
|
match stack.active().0.underlying_surface() {
|
||||||
WindowSurface::Wayland(t) => t.wl_surface().id().protocol_id(),
|
WindowSurface::Wayland(t) => t.wl_surface().id().protocol_id(),
|
||||||
WindowSurface::X11(x) => x.window_id(),
|
WindowSurface::X11(x) => x.window_id(),
|
||||||
},
|
},
|
||||||
x.title()
|
stack.active().title()
|
||||||
),
|
),
|
||||||
Some(LayerSurface(x)) => format!("LayerSurface {}", x.wl_surface().id().protocol_id()),
|
Some(WindowUI(window)) => format!(
|
||||||
Some(Popup(x)) => format!("Popup {}", x.wl_surface().id().protocol_id()),
|
"Window SSD {} ({})",
|
||||||
Some(OverrideRedirect(x)) => format!("Override Redirect {}", x.window_id()),
|
match window.surface().0.underlying_surface() {
|
||||||
Some(PointerFocusTarget::ResizeFork(x)) => format!("Resize Fork {:?}", x.node),
|
WindowSurface::Wayland(t) => t.wl_surface().id().protocol_id(),
|
||||||
Some(LockSurface(x)) => format!("LockSurface {}", x.wl_surface().id().protocol_id()),
|
WindowSurface::X11(x) => x.window_id(),
|
||||||
|
},
|
||||||
|
window.surface().title()
|
||||||
|
),
|
||||||
|
Some(ResizeFork(_)) => String::from("Resize UI"),
|
||||||
None => format!("None"),
|
None => format!("None"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,8 @@ use egui_plot::{Corner, Legend, Plot, PlotPoints, Polygon};
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
use smithay::backend::renderer::{element::texture::TextureRenderElement, gles::GlesTexture};
|
use smithay::backend::renderer::{element::texture::TextureRenderElement, gles::GlesTexture};
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
|
use smithay::desktop::WindowSurface;
|
||||||
|
#[cfg(feature = "debug")]
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
|
|
||||||
|
|
@ -218,7 +218,7 @@ pub struct Shell {
|
||||||
resize_indicator: Option<ResizeIndicator>,
|
resize_indicator: Option<ResizeIndicator>,
|
||||||
|
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
debug_active: bool,
|
pub debug_active: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue