debug: Drop FPS struct for kms timings

This commit is contained in:
Victoria Brekenfeld 2024-06-07 20:07:16 +02:00 committed by Victoria Brekenfeld
parent 0c11c0f959
commit cc0bbb61e3
6 changed files with 44 additions and 284 deletions

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
use std::{
borrow::{Borrow, BorrowMut},
borrow::Borrow,
cell::RefCell,
collections::HashMap,
sync::{Arc, RwLock, Weak},
@ -66,12 +66,17 @@ use smithay::{
},
};
#[cfg(feature = "debug")]
use smithay_egui::EguiState;
pub mod animations;
pub mod cursor;
pub mod element;
use self::element::{AsGlowRenderer, CosmicElement};
use super::kms::Timings;
pub type GlMultiRenderer<'a> =
MultiRenderer<'a, 'a, GbmGlowBackend<DrmDeviceFd>, GbmGlowBackend<DrmDeviceFd>>;
pub type GlMultiFrame<'a, 'frame> =
@ -456,6 +461,9 @@ where
elements
}
#[cfg(not(feature = "debug"))]
pub type EguiState = ();
#[profiling::function]
pub fn workspace_elements<R>(
_gpu: Option<&DrmNode>,
@ -466,8 +474,8 @@ pub fn workspace_elements<R>(
previous: Option<(WorkspaceHandle, usize, WorkspaceDelta)>,
current: (WorkspaceHandle, usize),
cursor_mode: CursorMode,
_fps: &mut Option<&mut Fps>,
exclude_workspace_overview: bool,
_fps: Option<(&EguiState, &Timings)>,
) -> Result<Vec<CosmicElement<R>>, RenderError<R>>
where
R: Renderer + ImportAll + ImportMem + AsGlowRenderer,
@ -500,13 +508,15 @@ where
let output_geo = output.geometry();
let scale = output.current_scale().fractional_scale();
if let Some(fps) = _fps.as_mut() {
if let Some((state, timings)) = _fps.as_mut() {
let debug_active = shell.read().unwrap().debug_active;
let fps_overlay = fps_ui(
_gpu,
shell,
theme,
debug_active,
seats.iter(),
renderer.glow_renderer_mut(),
*fps,
state,
timings,
Rectangle::from_loc_and_size(
(0, 0),
(output_geo.size.w.min(400), output_geo.size.h.min(800)),
@ -954,7 +964,6 @@ pub fn render_output<'d, R, Target, OffTarget>(
now: Time<Monotonic>,
output: &Output,
cursor_mode: CursorMode,
fps: Option<&mut Fps>,
) -> Result<RenderOutputResult<'d>, RenderError<R>>
where
R: Renderer
@ -995,7 +1004,6 @@ where
previous_workspace,
workspace,
cursor_mode,
fps,
false,
);
@ -1108,7 +1116,6 @@ pub fn render_workspace<'d, R, Target, OffTarget>(
previous: Option<(WorkspaceHandle, usize, WorkspaceDelta)>,
current: (WorkspaceHandle, usize),
cursor_mode: CursorMode,
mut fps: Option<&mut Fps>,
exclude_workspace_overview: bool,
) -> Result<(RenderOutputResult<'d>, Vec<CosmicElement<R>>), RenderError<R>>
where
@ -1126,10 +1133,6 @@ where
CosmicMappedRenderElement<R>: RenderElement<R>,
WorkspaceRenderElement<R>: RenderElement<R>,
{
if let Some(ref mut fps) = fps {
fps.start();
}
let mut elements: Vec<CosmicElement<R>> = workspace_elements(
gpu,
renderer,
@ -1139,8 +1142,8 @@ where
previous,
current,
cursor_mode,
&mut fps,
exclude_workspace_overview,
None,
)?;
if let Some(additional_damage) = additional_damage {
@ -1154,10 +1157,6 @@ where
);
}
if let Some(fps) = fps.as_mut() {
fps.elements();
}
renderer.bind(target).map_err(RenderError::Rendering)?;
let res = damage_tracker.render_output(
renderer,
@ -1166,9 +1165,5 @@ where
CLEAR_COLOR, // TODO use a theme neutral color
);
if let Some(fps) = fps.as_mut() {
fps.render();
}
res.map(|res| (res, elements))
}

View file

@ -31,12 +31,9 @@ use smithay::{
utils::Transform,
wayland::dmabuf::DmabufFeedbackBuilder,
};
use std::{cell::RefCell, time::Duration};
use std::{borrow::BorrowMut, cell::RefCell, time::Duration};
use tracing::{error, info, warn};
#[cfg(feature = "debug")]
use crate::state::Fps;
use super::render::{init_shaders, CursorMode};
#[derive(Debug)]
@ -45,8 +42,6 @@ pub struct WinitState {
pub backend: WinitGraphicsBackend<GlowRenderer>,
output: Output,
damage_tracker: OutputDamageTracker,
#[cfg(feature = "debug")]
fps: Fps,
}
impl WinitState {
@ -68,10 +63,6 @@ impl WinitState {
state.clock.now(),
&self.output,
CursorMode::NotDefault,
#[cfg(not(feature = "debug"))]
None,
#[cfg(feature = "debug")]
Some(&mut self.fps),
) {
Ok(RenderOutputResult { damage, states, .. }) => {
self.backend
@ -80,8 +71,6 @@ impl WinitState {
self.backend
.submit(damage.map(|x| x.as_slice()))
.with_context(|| "Failed to submit buffer for display")?;
#[cfg(feature = "debug")]
self.fps.displayed();
state.send_frames(&self.output);
state.update_primary_output(&self.output, &states);
state.send_dmabuf_feedback(&self.output, &states, |_| None);
@ -215,15 +204,10 @@ pub fn init_backend(
.map_err(|_| anyhow::anyhow!("Failed to init eventloop timer for winit"))?;
event_ping.ping();
#[cfg(feature = "debug")]
let fps = Fps::new(backend.renderer());
state.backend = BackendData::Winit(WinitState {
backend,
output: output.clone(),
damage_tracker: OutputDamageTracker::from_output(&output),
#[cfg(feature = "debug")]
fps,
});
state

View file

@ -38,12 +38,9 @@ use smithay::{
utils::{DeviceFd, Transform},
wayland::dmabuf::DmabufFeedbackBuilder,
};
use std::{cell::RefCell, os::unix::io::OwnedFd, time::Duration};
use std::{borrow::BorrowMut, cell::RefCell, os::unix::io::OwnedFd, time::Duration};
use tracing::{debug, error, info, warn};
#[cfg(feature = "debug")]
use crate::state::Fps;
use super::render::init_shaders;
#[derive(Debug)]
@ -149,8 +146,6 @@ impl X11State {
render: ping.clone(),
dirty: false,
pending: true,
#[cfg(feature = "debug")]
fps: Fps::new(&mut self.renderer),
});
// schedule first render
@ -203,8 +198,6 @@ pub struct Surface {
render: ping::Ping,
dirty: bool,
pending: bool,
#[cfg(feature = "debug")]
fps: Fps,
}
impl Surface {
@ -223,17 +216,11 @@ impl Surface {
state.clock.now(),
&self.output,
render::CursorMode::NotDefault,
#[cfg(not(feature = "debug"))]
None,
#[cfg(feature = "debug")]
Some(&mut self.fps),
) {
Ok(RenderOutputResult { damage, states, .. }) => {
self.surface
.submit()
.with_context(|| "Failed to submit buffer for display")?;
#[cfg(feature = "debug")]
self.fps.displayed();
state.send_frames(&self.output);
state.update_primary_output(&self.output, &states);
state.send_dmabuf_feedback(&self.output, &states, |_| None);