Upgrade Smithay (DrmCompositor changes)

This commit is contained in:
Ivan Molodetskikh
2025-01-04 09:09:24 +03:00
parent b3c6f0e661
commit 1973b97cc2
5 changed files with 56 additions and 73 deletions
Generated
+2 -2
View File
@@ -3412,7 +3412,7 @@ checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c"
[[package]] [[package]]
name = "smithay" name = "smithay"
version = "0.3.0" version = "0.3.0"
source = "git+https://github.com/YaLTeR/smithay.git?branch=fix-vrr-cursor-plane-only#a1fec3b52902d51fa351c235cb4177ba7c14a675" source = "git+https://github.com/Smithay/smithay.git#b595a1ca601b77d8bbcf6755602d6f18f2379eac"
dependencies = [ dependencies = [
"appendlist", "appendlist",
"bitflags 2.6.0", "bitflags 2.6.0",
@@ -3484,7 +3484,7 @@ dependencies = [
[[package]] [[package]]
name = "smithay-drm-extras" name = "smithay-drm-extras"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/Smithay/smithay.git#5186cf7dec2472a91e3c248772954b1141dab7f2" source = "git+https://github.com/Smithay/smithay.git#b595a1ca601b77d8bbcf6755602d6f18f2379eac"
dependencies = [ dependencies = [
"drm", "drm",
"libdisplay-info", "libdisplay-info",
+1 -2
View File
@@ -26,8 +26,7 @@ tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
tracy-client = { version = "0.18.0", default-features = false } tracy-client = { version = "0.18.0", default-features = false }
[workspace.dependencies.smithay] [workspace.dependencies.smithay]
git = "https://github.com/YaLTeR/smithay.git" git = "https://github.com/Smithay/smithay.git"
branch = "fix-vrr-cursor-plane-only"
# path = "../smithay" # path = "../smithay"
default-features = false default-features = false
-8
View File
@@ -186,14 +186,6 @@ impl Backend {
} }
} }
pub fn on_debug_config_changed(&mut self) {
match self {
Backend::Tty(tty) => tty.on_debug_config_changed(),
Backend::Winit(_) => (),
Backend::Headless(_) => (),
}
}
pub fn tty_checked(&mut self) -> Option<&mut Tty> { pub fn tty_checked(&mut self) -> Option<&mut Tty> {
if let Self::Tty(v) = self { if let Self::Tty(v) = self {
Some(v) Some(v)
+49 -48
View File
@@ -18,7 +18,7 @@ use smithay::backend::allocator::dmabuf::Dmabuf;
use smithay::backend::allocator::format::FormatSet; use smithay::backend::allocator::format::FormatSet;
use smithay::backend::allocator::gbm::{GbmAllocator, GbmBufferFlags, GbmDevice}; use smithay::backend::allocator::gbm::{GbmAllocator, GbmBufferFlags, GbmDevice};
use smithay::backend::allocator::Fourcc; use smithay::backend::allocator::Fourcc;
use smithay::backend::drm::compositor::{DrmCompositor, PrimaryPlaneElement}; use smithay::backend::drm::compositor::{DrmCompositor, FrameFlags, PrimaryPlaneElement};
use smithay::backend::drm::{ use smithay::backend::drm::{
DrmDevice, DrmDeviceFd, DrmEvent, DrmEventMetadata, DrmEventTime, DrmNode, NodeType, VrrSupport, DrmDevice, DrmDeviceFd, DrmEvent, DrmEventMetadata, DrmEventTime, DrmNode, NodeType, VrrSupport,
}; };
@@ -64,7 +64,7 @@ use crate::render_helpers::renderer::AsGlesRenderer;
use crate::render_helpers::{resources, shaders, RenderTarget}; use crate::render_helpers::{resources, shaders, RenderTarget};
use crate::utils::{get_monotonic_time, is_laptop_panel, logical_output}; use crate::utils::{get_monotonic_time, is_laptop_panel, logical_output};
const SUPPORTED_COLOR_FORMATS: &[Fourcc] = &[Fourcc::Argb8888, Fourcc::Abgr8888]; const SUPPORTED_COLOR_FORMATS: [Fourcc; 2] = [Fourcc::Argb8888, Fourcc::Abgr8888];
pub struct Tty { pub struct Tty {
config: Rc<RefCell<Config>>, config: Rc<RefCell<Config>>,
@@ -861,23 +861,6 @@ impl Tty {
.insert_if_missing(|| TtyOutputState { node, crtc }); .insert_if_missing(|| TtyOutputState { node, crtc });
output.user_data().insert_if_missing(|| output_name.clone()); output.user_data().insert_if_missing(|| output_name.clone());
let mut planes = surface.planes().clone();
let config = self.config.borrow();
// Overlay planes are disabled by default as they cause weird performance issues on my
// system.
if !config.debug.enable_overlay_planes {
planes.overlay.clear();
}
// Cursor planes have bugs on some systems.
let cursor_plane_gbm = if config.debug.disable_cursor_plane {
None
} else {
Some(device.gbm.clone())
};
let renderer = self.gpu_manager.single_renderer(&device.render_node)?; let renderer = self.gpu_manager.single_renderer(&device.render_node)?;
let egl_context = renderer.as_ref().egl_context(); let egl_context = renderer.as_ref().egl_context();
let render_formats = egl_context.dmabuf_render_formats(); let render_formats = egl_context.dmabuf_render_formats();
@@ -916,7 +899,7 @@ impl Tty {
let res = DrmCompositor::new( let res = DrmCompositor::new(
OutputModeSource::Auto(output.clone()), OutputModeSource::Auto(output.clone()),
surface, surface,
Some(planes), None,
allocator.clone(), allocator.clone(),
device.gbm.clone(), device.gbm.clone(),
SUPPORTED_COLOR_FORMATS, SUPPORTED_COLOR_FORMATS,
@@ -924,7 +907,7 @@ impl Tty {
// formats, even though we only ever render on the primary GPU. // formats, even though we only ever render on the primary GPU.
render_formats.clone(), render_formats.clone(),
device.drm.cursor_size(), device.drm.cursor_size(),
cursor_plane_gbm.clone(), Some(device.gbm.clone()),
); );
let mut compositor = match res { let mut compositor = match res {
@@ -942,21 +925,17 @@ impl Tty {
let surface = device let surface = device
.drm .drm
.create_surface(crtc, mode, &[connector.handle()])?; .create_surface(crtc, mode, &[connector.handle()])?;
let mut planes = surface.planes().clone();
if !config.debug.enable_overlay_planes {
planes.overlay.clear();
}
DrmCompositor::new( DrmCompositor::new(
OutputModeSource::Auto(output.clone()), OutputModeSource::Auto(output.clone()),
surface, surface,
Some(planes), None,
allocator, allocator,
device.gbm.clone(), device.gbm.clone(),
SUPPORTED_COLOR_FORMATS, SUPPORTED_COLOR_FORMATS,
render_formats, render_formats,
device.drm.cursor_size(), device.drm.cursor_size(),
cursor_plane_gbm, Some(device.gbm.clone()),
) )
.context("error creating DRM compositor")? .context("error creating DRM compositor")?
} }
@@ -965,7 +944,6 @@ impl Tty {
if self.debug_tint { if self.debug_tint {
compositor.set_debug_flags(DebugFlags::TINT); compositor.set_debug_flags(DebugFlags::TINT);
} }
compositor.use_direct_scanout(!config.debug.disable_direct_scanout);
let mut dmabuf_feedback = None; let mut dmabuf_feedback = None;
if let Ok(primary_renderer) = self.gpu_manager.single_renderer(&self.primary_render_node) { if let Ok(primary_renderer) = self.gpu_manager.single_renderer(&self.primary_render_node) {
@@ -1351,9 +1329,27 @@ impl Tty {
draw_damage(&mut output_state.debug_damage_tracker, &mut elements); draw_damage(&mut output_state.debug_damage_tracker, &mut elements);
} }
// Overlay planes are disabled by default as they cause weird performance issues on my
// system.
let mut flags =
FrameFlags::ALLOW_PRIMARY_PLANE_SCANOUT | FrameFlags::ALLOW_CURSOR_PLANE_SCANOUT;
{
let debug = &self.config.borrow().debug;
if debug.enable_overlay_planes {
flags.insert(FrameFlags::ALLOW_OVERLAY_PLANE_SCANOUT);
}
if debug.disable_direct_scanout {
flags.remove(FrameFlags::ALLOW_PRIMARY_PLANE_SCANOUT);
flags.remove(FrameFlags::ALLOW_OVERLAY_PLANE_SCANOUT);
}
if debug.disable_cursor_plane {
flags.remove(FrameFlags::ALLOW_CURSOR_PLANE_SCANOUT);
}
}
// Hand them over to the DRM. // Hand them over to the DRM.
let drm_compositor = &mut surface.compositor; let drm_compositor = &mut surface.compositor;
match drm_compositor.render_frame::<_, _>(&mut renderer, &elements, [0.; 4]) { match drm_compositor.render_frame::<_, _>(&mut renderer, &elements, [0.; 4], flags) {
Ok(res) => { Ok(res) => {
let needs_sync = res.needs_sync() let needs_sync = res.needs_sync()
|| self || self
@@ -1882,19 +1878,6 @@ impl Tty {
self.refresh_ipc_outputs(niri); self.refresh_ipc_outputs(niri);
} }
pub fn on_debug_config_changed(&mut self) {
let config = self.config.borrow();
let debug = &config.debug;
let use_direct_scanout = !debug.disable_direct_scanout;
// FIXME: reload other flags if possible?
for device in self.devices.values_mut() {
for surface in device.surfaces.values_mut() {
surface.compositor.use_direct_scanout(use_direct_scanout);
}
}
}
pub fn get_device_from_node(&mut self, node: DrmNode) -> Option<&mut OutputDevice> { pub fn get_device_from_node(&mut self, node: DrmNode) -> Option<&mut OutputDevice> {
self.devices.get_mut(&node) self.devices.get_mut(&node)
} }
@@ -2117,9 +2100,8 @@ fn surface_dmabuf_feedback(
let surface = compositor.surface(); let surface = compositor.surface();
let planes = surface.planes(); let planes = surface.planes();
let plane_formats = surface let primary_plane_formats = surface.plane_info().formats.clone();
.plane_info() let primary_or_overlay_plane_formats = primary_plane_formats
.formats
.iter() .iter()
.chain(planes.overlay.iter().flat_map(|p| p.formats.iter())) .chain(planes.overlay.iter().flat_map(|p| p.formats.iter()))
.copied() .copied()
@@ -2127,7 +2109,11 @@ fn surface_dmabuf_feedback(
// We limit the scan-out trache to formats we can also render from so that there is always a // We limit the scan-out trache to formats we can also render from so that there is always a
// fallback render path available in case the supplied buffer can not be scanned out directly. // fallback render path available in case the supplied buffer can not be scanned out directly.
let mut scanout_formats = plane_formats let mut primary_scanout_formats = primary_plane_formats
.intersection(&primary_formats)
.copied()
.collect::<Vec<_>>();
let mut primary_or_overlay_scanout_formats = primary_or_overlay_plane_formats
.intersection(&primary_formats) .intersection(&primary_formats)
.copied() .copied()
.collect::<Vec<_>>(); .collect::<Vec<_>>();
@@ -2135,17 +2121,32 @@ fn surface_dmabuf_feedback(
// HACK: AMD iGPU + dGPU systems share some modifiers between the two, and yet cross-device // HACK: AMD iGPU + dGPU systems share some modifiers between the two, and yet cross-device
// buffers produce a glitched scanout if the modifier is not Linear... // buffers produce a glitched scanout if the modifier is not Linear...
if primary_render_node != surface_render_node { if primary_render_node != surface_render_node {
scanout_formats.retain(|f| f.modifier == Modifier::Linear); primary_scanout_formats.retain(|f| f.modifier == Modifier::Linear);
primary_or_overlay_scanout_formats.retain(|f| f.modifier == Modifier::Linear);
} }
let builder = DmabufFeedbackBuilder::new(primary_render_node.dev_id(), primary_formats); let builder = DmabufFeedbackBuilder::new(primary_render_node.dev_id(), primary_formats);
trace!(
"primary scanout formats: {}, overlay adds: {}",
primary_scanout_formats.len(),
primary_or_overlay_scanout_formats.len() - primary_scanout_formats.len(),
);
// Prefer the primary-plane-only formats, then primary-or-overlay-plane formats. This will
// increase the chance of scanning out a client even with our disabled-by-default overlay
// planes.
let scanout = builder let scanout = builder
.clone() .clone()
.add_preference_tranche( .add_preference_tranche(
surface_render_node.dev_id(), surface_render_node.dev_id(),
Some(TrancheFlags::Scanout), Some(TrancheFlags::Scanout),
scanout_formats, primary_scanout_formats,
)
.add_preference_tranche(
surface_render_node.dev_id(),
Some(TrancheFlags::Scanout),
primary_or_overlay_scanout_formats,
) )
.build()?; .build()?;
+4 -13
View File
@@ -1107,7 +1107,6 @@ impl State {
let mut preserved_output_config = None; let mut preserved_output_config = None;
let mut window_rules_changed = false; let mut window_rules_changed = false;
let mut layer_rules_changed = false; let mut layer_rules_changed = false;
let mut debug_config_changed = false;
let mut shaders_changed = false; let mut shaders_changed = false;
let mut cursor_inactivity_timeout_changed = false; let mut cursor_inactivity_timeout_changed = false;
let mut old_config = self.niri.config.borrow_mut(); let mut old_config = self.niri.config.borrow_mut();
@@ -1206,14 +1205,10 @@ impl State {
cursor_inactivity_timeout_changed = true; cursor_inactivity_timeout_changed = true;
} }
if config.debug != old_config.debug { if config.debug.keep_laptop_panel_on_when_lid_is_closed
debug_config_changed = true; != old_config.debug.keep_laptop_panel_on_when_lid_is_closed
{
if config.debug.keep_laptop_panel_on_when_lid_is_closed output_config_changed = true;
!= old_config.debug.keep_laptop_panel_on_when_lid_is_closed
{
output_config_changed = true;
}
} }
*old_config = config; *old_config = config;
@@ -1246,10 +1241,6 @@ impl State {
self.reload_output_config(); self.reload_output_config();
} }
if debug_config_changed {
self.backend.on_debug_config_changed();
}
if window_rules_changed { if window_rules_changed {
self.niri.recompute_window_rules(); self.niri.recompute_window_rules();
} }