mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-24 02:01:18 +07:00
Add debug flag to wait for frame completion
This commit is contained in:
+4
-2
@@ -7,6 +7,7 @@ use smithay::backend::renderer::gles::GlesRenderer;
|
|||||||
use smithay::output::Output;
|
use smithay::output::Output;
|
||||||
use smithay::wayland::dmabuf::DmabufFeedback;
|
use smithay::wayland::dmabuf::DmabufFeedback;
|
||||||
|
|
||||||
|
use crate::config::Config;
|
||||||
use crate::input::CompositorMod;
|
use crate::input::CompositorMod;
|
||||||
use crate::niri::OutputRenderElements;
|
use crate::niri::OutputRenderElements;
|
||||||
use crate::Niri;
|
use crate::Niri;
|
||||||
@@ -46,13 +47,14 @@ impl Backend {
|
|||||||
|
|
||||||
pub fn render(
|
pub fn render(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
config: &Config,
|
||||||
niri: &mut Niri,
|
niri: &mut Niri,
|
||||||
output: &Output,
|
output: &Output,
|
||||||
elements: &[OutputRenderElements<GlesRenderer>],
|
elements: &[OutputRenderElements<GlesRenderer>],
|
||||||
) -> Option<&DmabufFeedback> {
|
) -> Option<&DmabufFeedback> {
|
||||||
match self {
|
match self {
|
||||||
Backend::Tty(tty) => tty.render(niri, output, elements),
|
Backend::Tty(tty) => tty.render(config, niri, output, elements),
|
||||||
Backend::Winit(winit) => winit.render(niri, output, elements),
|
Backend::Winit(winit) => winit.render(config, niri, output, elements),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-5
@@ -8,7 +8,7 @@ use anyhow::{anyhow, Context};
|
|||||||
use smithay::backend::allocator::dmabuf::Dmabuf;
|
use smithay::backend::allocator::dmabuf::Dmabuf;
|
||||||
use smithay::backend::allocator::gbm::{GbmAllocator, GbmBufferFlags, GbmDevice};
|
use smithay::backend::allocator::gbm::{GbmAllocator, GbmBufferFlags, GbmDevice};
|
||||||
use smithay::backend::allocator::{Format as DrmFormat, Fourcc};
|
use smithay::backend::allocator::{Format as DrmFormat, Fourcc};
|
||||||
use smithay::backend::drm::compositor::DrmCompositor;
|
use smithay::backend::drm::compositor::{DrmCompositor, PrimaryPlaneElement};
|
||||||
use smithay::backend::drm::{DrmDevice, DrmDeviceFd, DrmEvent, DrmEventTime};
|
use smithay::backend::drm::{DrmDevice, DrmDeviceFd, DrmEvent, DrmEventTime};
|
||||||
use smithay::backend::egl::{EGLContext, EGLDisplay};
|
use smithay::backend::egl::{EGLContext, EGLDisplay};
|
||||||
use smithay::backend::libinput::{LibinputInputBackend, LibinputSessionInterface};
|
use smithay::backend::libinput::{LibinputInputBackend, LibinputSessionInterface};
|
||||||
@@ -33,6 +33,7 @@ use smithay::wayland::dmabuf::{DmabufFeedbackBuilder, DmabufGlobal, DmabufState,
|
|||||||
use smithay_drm_extras::drm_scanner::{DrmScanEvent, DrmScanner};
|
use smithay_drm_extras::drm_scanner::{DrmScanEvent, DrmScanner};
|
||||||
use smithay_drm_extras::edid::EdidInfo;
|
use smithay_drm_extras::edid::EdidInfo;
|
||||||
|
|
||||||
|
use crate::config::Config;
|
||||||
use crate::niri::{OutputRenderElements, State};
|
use crate::niri::{OutputRenderElements, State};
|
||||||
use crate::utils::get_monotonic_time;
|
use crate::utils::get_monotonic_time;
|
||||||
use crate::{LoopData, Niri};
|
use crate::{LoopData, Niri};
|
||||||
@@ -626,6 +627,7 @@ impl Tty {
|
|||||||
|
|
||||||
pub fn render(
|
pub fn render(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
config: &Config,
|
||||||
niri: &mut Niri,
|
niri: &mut Niri,
|
||||||
output: &Output,
|
output: &Output,
|
||||||
elements: &[OutputRenderElements<GlesRenderer>],
|
elements: &[OutputRenderElements<GlesRenderer>],
|
||||||
@@ -645,10 +647,12 @@ impl Tty {
|
|||||||
Ok(res) => {
|
Ok(res) => {
|
||||||
assert!(!res.needs_sync());
|
assert!(!res.needs_sync());
|
||||||
|
|
||||||
// if let PrimaryPlaneElement::Swapchain(element) = res.primary_element {
|
if config.debug.wait_for_frame_completion_before_queueing {
|
||||||
// let _span = tracy_client::span!("wait for sync");
|
if let PrimaryPlaneElement::Swapchain(element) = res.primary_element {
|
||||||
// element.sync.wait();
|
let _span = tracy_client::span!("wait for completion");
|
||||||
// }
|
element.sync.wait();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if res.damage.is_some() {
|
if res.damage.is_some() {
|
||||||
let presentation_feedbacks =
|
let presentation_feedbacks =
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ use smithay::reexports::winit::window::WindowBuilder;
|
|||||||
use smithay::utils::Transform;
|
use smithay::utils::Transform;
|
||||||
use smithay::wayland::dmabuf::DmabufFeedback;
|
use smithay::wayland::dmabuf::DmabufFeedback;
|
||||||
|
|
||||||
|
use crate::config::Config;
|
||||||
use crate::niri::OutputRenderElements;
|
use crate::niri::OutputRenderElements;
|
||||||
use crate::utils::get_monotonic_time;
|
use crate::utils::get_monotonic_time;
|
||||||
use crate::{LoopData, Niri};
|
use crate::{LoopData, Niri};
|
||||||
@@ -136,6 +137,7 @@ impl Winit {
|
|||||||
|
|
||||||
pub fn render(
|
pub fn render(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
config: &Config,
|
||||||
niri: &mut Niri,
|
niri: &mut Niri,
|
||||||
output: &Output,
|
output: &Output,
|
||||||
elements: &[OutputRenderElements<GlesRenderer>],
|
elements: &[OutputRenderElements<GlesRenderer>],
|
||||||
@@ -149,6 +151,11 @@ impl Winit {
|
|||||||
.render_output(self.backend.renderer(), age, elements, [0.1, 0.1, 0.1, 1.0])
|
.render_output(self.backend.renderer(), age, elements, [0.1, 0.1, 0.1, 1.0])
|
||||||
.unwrap();
|
.unwrap();
|
||||||
if let Some(damage) = res.damage {
|
if let Some(damage) = res.damage {
|
||||||
|
if config.debug.wait_for_frame_completion_before_queueing {
|
||||||
|
let _span = tracy_client::span!("wait for completion");
|
||||||
|
res.sync.wait();
|
||||||
|
}
|
||||||
|
|
||||||
self.backend.submit(Some(&damage)).unwrap();
|
self.backend.submit(Some(&damage)).unwrap();
|
||||||
|
|
||||||
let mut presentation_feedbacks = niri.take_presentation_feedbacks(output, &res.states);
|
let mut presentation_feedbacks = niri.take_presentation_feedbacks(output, &res.states);
|
||||||
|
|||||||
@@ -130,6 +130,8 @@ pub struct DebugConfig {
|
|||||||
pub animation_slowdown: f64,
|
pub animation_slowdown: f64,
|
||||||
#[knuffel(child)]
|
#[knuffel(child)]
|
||||||
pub screen_cast_in_non_session_instances: bool,
|
pub screen_cast_in_non_session_instances: bool,
|
||||||
|
#[knuffel(child)]
|
||||||
|
pub wait_for_frame_completion_before_queueing: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for DebugConfig {
|
impl Default for DebugConfig {
|
||||||
@@ -137,6 +139,7 @@ impl Default for DebugConfig {
|
|||||||
Self {
|
Self {
|
||||||
animation_slowdown: 1.,
|
animation_slowdown: 1.,
|
||||||
screen_cast_in_non_session_instances: false,
|
screen_cast_in_non_session_instances: false,
|
||||||
|
wait_for_frame_completion_before_queueing: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-3
@@ -690,7 +690,9 @@ impl Niri {
|
|||||||
// Timer::immediate() adds a millisecond of delay for some reason.
|
// Timer::immediate() adds a millisecond of delay for some reason.
|
||||||
// This should be fixed in calloop v0.11: https://github.com/Smithay/calloop/issues/142
|
// This should be fixed in calloop v0.11: https://github.com/Smithay/calloop/issues/142
|
||||||
let idle = self.event_loop.insert_idle(move |data| {
|
let idle = self.event_loop.insert_idle(move |data| {
|
||||||
data.state.niri.redraw(&mut data.state.backend, &output);
|
data.state
|
||||||
|
.niri
|
||||||
|
.redraw(&data.state.config, &mut data.state.backend, &output);
|
||||||
});
|
});
|
||||||
state.queued_redraw = Some(idle);
|
state.queued_redraw = Some(idle);
|
||||||
}
|
}
|
||||||
@@ -835,7 +837,7 @@ impl Niri {
|
|||||||
elements
|
elements
|
||||||
}
|
}
|
||||||
|
|
||||||
fn redraw(&mut self, backend: &mut Backend, output: &Output) {
|
fn redraw(&mut self, config: &Config, backend: &mut Backend, output: &Output) {
|
||||||
let _span = tracy_client::span!("Niri::redraw");
|
let _span = tracy_client::span!("Niri::redraw");
|
||||||
|
|
||||||
let state = self.output_state.get_mut(output).unwrap();
|
let state = self.output_state.get_mut(output).unwrap();
|
||||||
@@ -852,7 +854,7 @@ impl Niri {
|
|||||||
let elements = self.render(backend.renderer(), output);
|
let elements = self.render(backend.renderer(), output);
|
||||||
|
|
||||||
// Hand it over to the backend.
|
// Hand it over to the backend.
|
||||||
let dmabuf_feedback = backend.render(self, output, &elements);
|
let dmabuf_feedback = backend.render(config, self, output, &elements);
|
||||||
|
|
||||||
// Send the dmabuf feedbacks.
|
// Send the dmabuf feedbacks.
|
||||||
if let Some(feedback) = dmabuf_feedback {
|
if let Some(feedback) = dmabuf_feedback {
|
||||||
|
|||||||
Reference in New Issue
Block a user