Upgrade Smithay (DrmCompositor changes)
Browse files at this commit1973b97cc2a51d697add3d9ad7210a4e6eba9183Parent: b3c6f0e5 changed files +56 -73
- Cargo.lock +2 -2
- Cargo.toml +1 -2
- src/backend/mod.rs +0 -8
- src/backend/tty.rs +49 -48
- src/niri.rs +4 -13
Cargo.lockmodified+2 -2
| @@ -3412,7 +3412,7 @@ checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" | |||
| 3412 | [[package]] | 3412 | [[package]] |
| 3413 | name = "smithay" | 3413 | name = "smithay" |
| 3414 | version = "0.3.0" | 3414 | version = "0.3.0" |
| 3415 | -source = "git+https://github.com/YaLTeR/smithay.git?branch=fix-vrr-cursor-plane-only#a1fec3b52902d51fa351c235cb4177ba7c14a675" | 3415 | +source = "git+https://github.com/Smithay/smithay.git#b595a1ca601b77d8bbcf6755602d6f18f2379eac" |
| 3416 | dependencies = [ | 3416 | dependencies = [ |
| 3417 | "appendlist", | 3417 | "appendlist", |
| 3418 | "bitflags 2.6.0", | 3418 | "bitflags 2.6.0", |
| @@ -3484,7 +3484,7 @@ dependencies = [ | |||
| 3484 | [[package]] | 3484 | [[package]] |
| 3485 | name = "smithay-drm-extras" | 3485 | name = "smithay-drm-extras" |
| 3486 | version = "0.1.0" | 3486 | version = "0.1.0" |
| 3487 | -source = "git+https://github.com/Smithay/smithay.git#5186cf7dec2472a91e3c248772954b1141dab7f2" | 3487 | +source = "git+https://github.com/Smithay/smithay.git#b595a1ca601b77d8bbcf6755602d6f18f2379eac" |
| 3488 | dependencies = [ | 3488 | dependencies = [ |
| 3489 | "drm", | 3489 | "drm", |
| 3490 | "libdisplay-info", | 3490 | "libdisplay-info", |
Cargo.tomlmodified+1 -2
| @@ -26,8 +26,7 @@ tracing-subscriber = { version = "0.3.19", features = ["env-filter"] } | |||
| 26 | tracy-client = { version = "0.18.0", default-features = false } | 26 | tracy-client = { version = "0.18.0", default-features = false } |
| 27 | 27 | ||
| 28 | [workspace.dependencies.smithay] | 28 | [workspace.dependencies.smithay] |
| 29 | -git = "https://github.com/YaLTeR/smithay.git" | 29 | +git = "https://github.com/Smithay/smithay.git" |
| 30 | -branch = "fix-vrr-cursor-plane-only" | ||
| 31 | # path = "../smithay" | 30 | # path = "../smithay" |
| 32 | default-features = false | 31 | default-features = false |
| 33 | 32 | ||
src/backend/mod.rsmodified+0 -8
| @@ -186,14 +186,6 @@ impl Backend { | |||
| 186 | } | 186 | } |
| 187 | } | 187 | } |
| 188 | 188 | ||
| 189 | - pub fn on_debug_config_changed(&mut self) { | ||
| 190 | - match self { | ||
| 191 | - Backend::Tty(tty) => tty.on_debug_config_changed(), | ||
| 192 | - Backend::Winit(_) => (), | ||
| 193 | - Backend::Headless(_) => (), | ||
| 194 | - } | ||
| 195 | - } | ||
| 196 | - | ||
| 197 | pub fn tty_checked(&mut self) -> Option<&mut Tty> { | 189 | pub fn tty_checked(&mut self) -> Option<&mut Tty> { |
| 198 | if let Self::Tty(v) = self { | 190 | if let Self::Tty(v) = self { |
| 199 | Some(v) | 191 | Some(v) |
src/backend/tty.rsmodified+49 -48
| @@ -18,7 +18,7 @@ use smithay::backend::allocator::dmabuf::Dmabuf; | |||
| 18 | use smithay::backend::allocator::format::FormatSet; | 18 | use smithay::backend::allocator::format::FormatSet; |
| 19 | use smithay::backend::allocator::gbm::{GbmAllocator, GbmBufferFlags, GbmDevice}; | 19 | use smithay::backend::allocator::gbm::{GbmAllocator, GbmBufferFlags, GbmDevice}; |
| 20 | use smithay::backend::allocator::Fourcc; | 20 | use smithay::backend::allocator::Fourcc; |
| 21 | -use smithay::backend::drm::compositor::{DrmCompositor, PrimaryPlaneElement}; | 21 | +use smithay::backend::drm::compositor::{DrmCompositor, FrameFlags, PrimaryPlaneElement}; |
| 22 | use smithay::backend::drm::{ | 22 | use smithay::backend::drm::{ |
| 23 | DrmDevice, DrmDeviceFd, DrmEvent, DrmEventMetadata, DrmEventTime, DrmNode, NodeType, VrrSupport, | 23 | DrmDevice, DrmDeviceFd, DrmEvent, DrmEventMetadata, DrmEventTime, DrmNode, NodeType, VrrSupport, |
| 24 | }; | 24 | }; |
| @@ -64,7 +64,7 @@ use crate::render_helpers::renderer::AsGlesRenderer; | |||
| 64 | use crate::render_helpers::{resources, shaders, RenderTarget}; | 64 | use crate::render_helpers::{resources, shaders, RenderTarget}; |
| 65 | use crate::utils::{get_monotonic_time, is_laptop_panel, logical_output}; | 65 | use crate::utils::{get_monotonic_time, is_laptop_panel, logical_output}; |
| 66 | 66 | ||
| 67 | -const SUPPORTED_COLOR_FORMATS: &[Fourcc] = &[Fourcc::Argb8888, Fourcc::Abgr8888]; | 67 | +const SUPPORTED_COLOR_FORMATS: [Fourcc; 2] = [Fourcc::Argb8888, Fourcc::Abgr8888]; |
| 68 | 68 | ||
| 69 | pub struct Tty { | 69 | pub struct Tty { |
| 70 | config: Rc<RefCell<Config>>, | 70 | config: Rc<RefCell<Config>>, |
| @@ -861,23 +861,6 @@ impl Tty { | |||
| 861 | .insert_if_missing(|| TtyOutputState { node, crtc }); | 861 | .insert_if_missing(|| TtyOutputState { node, crtc }); |
| 862 | output.user_data().insert_if_missing(|| output_name.clone()); | 862 | output.user_data().insert_if_missing(|| output_name.clone()); |
| 863 | 863 | ||
| 864 | - let mut planes = surface.planes().clone(); | ||
| 865 | - | ||
| 866 | - let config = self.config.borrow(); | ||
| 867 | - | ||
| 868 | - // Overlay planes are disabled by default as they cause weird performance issues on my | ||
| 869 | - // system. | ||
| 870 | - if !config.debug.enable_overlay_planes { | ||
| 871 | - planes.overlay.clear(); | ||
| 872 | - } | ||
| 873 | - | ||
| 874 | - // Cursor planes have bugs on some systems. | ||
| 875 | - let cursor_plane_gbm = if config.debug.disable_cursor_plane { | ||
| 876 | - None | ||
| 877 | - } else { | ||
| 878 | - Some(device.gbm.clone()) | ||
| 879 | - }; | ||
| 880 | - | ||
| 881 | let renderer = self.gpu_manager.single_renderer(&device.render_node)?; | 864 | let renderer = self.gpu_manager.single_renderer(&device.render_node)?; |
| 882 | let egl_context = renderer.as_ref().egl_context(); | 865 | let egl_context = renderer.as_ref().egl_context(); |
| 883 | let render_formats = egl_context.dmabuf_render_formats(); | 866 | let render_formats = egl_context.dmabuf_render_formats(); |
| @@ -916,7 +899,7 @@ impl Tty { | |||
| 916 | let res = DrmCompositor::new( | 899 | let res = DrmCompositor::new( |
| 917 | OutputModeSource::Auto(output.clone()), | 900 | OutputModeSource::Auto(output.clone()), |
| 918 | surface, | 901 | surface, |
| 919 | - Some(planes), | 902 | + None, |
| 920 | allocator.clone(), | 903 | allocator.clone(), |
| 921 | device.gbm.clone(), | 904 | device.gbm.clone(), |
| 922 | SUPPORTED_COLOR_FORMATS, | 905 | SUPPORTED_COLOR_FORMATS, |
| @@ -924,7 +907,7 @@ impl Tty { | |||
| 924 | // formats, even though we only ever render on the primary GPU. | 907 | // formats, even though we only ever render on the primary GPU. |
| 925 | render_formats.clone(), | 908 | render_formats.clone(), |
| 926 | device.drm.cursor_size(), | 909 | device.drm.cursor_size(), |
| 927 | - cursor_plane_gbm.clone(), | 910 | + Some(device.gbm.clone()), |
| 928 | ); | 911 | ); |
| 929 | 912 | ||
| 930 | let mut compositor = match res { | 913 | let mut compositor = match res { |
| @@ -942,21 +925,17 @@ impl Tty { | |||
| 942 | let surface = device | 925 | let surface = device |
| 943 | .drm | 926 | .drm |
| 944 | .create_surface(crtc, mode, &[connector.handle()])?; | 927 | .create_surface(crtc, mode, &[connector.handle()])?; |
| 945 | - let mut planes = surface.planes().clone(); | ||
| 946 | - if !config.debug.enable_overlay_planes { | ||
| 947 | - planes.overlay.clear(); | ||
| 948 | - } | ||
| 949 | 928 | ||
| 950 | DrmCompositor::new( | 929 | DrmCompositor::new( |
| 951 | OutputModeSource::Auto(output.clone()), | 930 | OutputModeSource::Auto(output.clone()), |
| 952 | surface, | 931 | surface, |
| 953 | - Some(planes), | 932 | + None, |
| 954 | allocator, | 933 | allocator, |
| 955 | device.gbm.clone(), | 934 | device.gbm.clone(), |
| 956 | SUPPORTED_COLOR_FORMATS, | 935 | SUPPORTED_COLOR_FORMATS, |
| 957 | render_formats, | 936 | render_formats, |
| 958 | device.drm.cursor_size(), | 937 | device.drm.cursor_size(), |
| 959 | - cursor_plane_gbm, | 938 | + Some(device.gbm.clone()), |
| 960 | ) | 939 | ) |
| 961 | .context("error creating DRM compositor")? | 940 | .context("error creating DRM compositor")? |
| 962 | } | 941 | } |
| @@ -965,7 +944,6 @@ impl Tty { | |||
| 965 | if self.debug_tint { | 944 | if self.debug_tint { |
| 966 | compositor.set_debug_flags(DebugFlags::TINT); | 945 | compositor.set_debug_flags(DebugFlags::TINT); |
| 967 | } | 946 | } |
| 968 | - compositor.use_direct_scanout(!config.debug.disable_direct_scanout); | ||
| 969 | 947 | ||
| 970 | let mut dmabuf_feedback = None; | 948 | let mut dmabuf_feedback = None; |
| 971 | if let Ok(primary_renderer) = self.gpu_manager.single_renderer(&self.primary_render_node) { | 949 | if let Ok(primary_renderer) = self.gpu_manager.single_renderer(&self.primary_render_node) { |
| @@ -1351,9 +1329,27 @@ impl Tty { | |||
| 1351 | draw_damage(&mut output_state.debug_damage_tracker, &mut elements); | 1329 | draw_damage(&mut output_state.debug_damage_tracker, &mut elements); |
| 1352 | } | 1330 | } |
| 1353 | 1331 | ||
| 1332 | + // Overlay planes are disabled by default as they cause weird performance issues on my | ||
| 1333 | + // system. | ||
| 1334 | + let mut flags = | ||
| 1335 | + FrameFlags::ALLOW_PRIMARY_PLANE_SCANOUT | FrameFlags::ALLOW_CURSOR_PLANE_SCANOUT; | ||
| 1336 | + { | ||
| 1337 | + let debug = &self.config.borrow().debug; | ||
| 1338 | + if debug.enable_overlay_planes { | ||
| 1339 | + flags.insert(FrameFlags::ALLOW_OVERLAY_PLANE_SCANOUT); | ||
| 1340 | + } | ||
| 1341 | + if debug.disable_direct_scanout { | ||
| 1342 | + flags.remove(FrameFlags::ALLOW_PRIMARY_PLANE_SCANOUT); | ||
| 1343 | + flags.remove(FrameFlags::ALLOW_OVERLAY_PLANE_SCANOUT); | ||
| 1344 | + } | ||
| 1345 | + if debug.disable_cursor_plane { | ||
| 1346 | + flags.remove(FrameFlags::ALLOW_CURSOR_PLANE_SCANOUT); | ||
| 1347 | + } | ||
| 1348 | + } | ||
| 1349 | + | ||
| 1354 | // Hand them over to the DRM. | 1350 | // Hand them over to the DRM. |
| 1355 | let drm_compositor = &mut surface.compositor; | 1351 | let drm_compositor = &mut surface.compositor; |
| 1356 | - match drm_compositor.render_frame::<_, _>(&mut renderer, &elements, [0.; 4]) { | 1352 | + match drm_compositor.render_frame::<_, _>(&mut renderer, &elements, [0.; 4], flags) { |
| 1357 | Ok(res) => { | 1353 | Ok(res) => { |
| 1358 | let needs_sync = res.needs_sync() | 1354 | let needs_sync = res.needs_sync() |
| 1359 | || self | 1355 | || self |
| @@ -1882,19 +1878,6 @@ impl Tty { | |||
| 1882 | self.refresh_ipc_outputs(niri); | 1878 | self.refresh_ipc_outputs(niri); |
| 1883 | } | 1879 | } |
| 1884 | 1880 | ||
| 1885 | - pub fn on_debug_config_changed(&mut self) { | ||
| 1886 | - let config = self.config.borrow(); | ||
| 1887 | - let debug = &config.debug; | ||
| 1888 | - let use_direct_scanout = !debug.disable_direct_scanout; | ||
| 1889 | - | ||
| 1890 | - // FIXME: reload other flags if possible? | ||
| 1891 | - for device in self.devices.values_mut() { | ||
| 1892 | - for surface in device.surfaces.values_mut() { | ||
| 1893 | - surface.compositor.use_direct_scanout(use_direct_scanout); | ||
| 1894 | - } | ||
| 1895 | - } | ||
| 1896 | - } | ||
| 1897 | - | ||
| 1898 | pub fn get_device_from_node(&mut self, node: DrmNode) -> Option<&mut OutputDevice> { | 1881 | pub fn get_device_from_node(&mut self, node: DrmNode) -> Option<&mut OutputDevice> { |
| 1899 | self.devices.get_mut(&node) | 1882 | self.devices.get_mut(&node) |
| 1900 | } | 1883 | } |
| @@ -2117,9 +2100,8 @@ fn surface_dmabuf_feedback( | |||
| 2117 | let surface = compositor.surface(); | 2100 | let surface = compositor.surface(); |
| 2118 | let planes = surface.planes(); | 2101 | let planes = surface.planes(); |
| 2119 | 2102 | ||
| 2120 | - let plane_formats = surface | 2103 | + let primary_plane_formats = surface.plane_info().formats.clone(); |
| 2121 | - .plane_info() | 2104 | + let primary_or_overlay_plane_formats = primary_plane_formats |
| 2122 | - .formats | ||
| 2123 | .iter() | 2105 | .iter() |
| 2124 | .chain(planes.overlay.iter().flat_map(|p| p.formats.iter())) | 2106 | .chain(planes.overlay.iter().flat_map(|p| p.formats.iter())) |
| 2125 | .copied() | 2107 | .copied() |
| @@ -2127,7 +2109,11 @@ fn surface_dmabuf_feedback( | |||
| 2127 | 2109 | ||
| 2128 | // We limit the scan-out trache to formats we can also render from so that there is always a | 2110 | // We limit the scan-out trache to formats we can also render from so that there is always a |
| 2129 | // fallback render path available in case the supplied buffer can not be scanned out directly. | 2111 | // fallback render path available in case the supplied buffer can not be scanned out directly. |
| 2130 | - let mut scanout_formats = plane_formats | 2112 | + let mut primary_scanout_formats = primary_plane_formats |
| 2113 | + .intersection(&primary_formats) | ||
| 2114 | + .copied() | ||
| 2115 | + .collect::<Vec<_>>(); | ||
| 2116 | + let mut primary_or_overlay_scanout_formats = primary_or_overlay_plane_formats | ||
| 2131 | .intersection(&primary_formats) | 2117 | .intersection(&primary_formats) |
| 2132 | .copied() | 2118 | .copied() |
| 2133 | .collect::<Vec<_>>(); | 2119 | .collect::<Vec<_>>(); |
| @@ -2135,17 +2121,32 @@ fn surface_dmabuf_feedback( | |||
| 2135 | // HACK: AMD iGPU + dGPU systems share some modifiers between the two, and yet cross-device | 2121 | // HACK: AMD iGPU + dGPU systems share some modifiers between the two, and yet cross-device |
| 2136 | // buffers produce a glitched scanout if the modifier is not Linear... | 2122 | // buffers produce a glitched scanout if the modifier is not Linear... |
| 2137 | if primary_render_node != surface_render_node { | 2123 | if primary_render_node != surface_render_node { |
| 2138 | - scanout_formats.retain(|f| f.modifier == Modifier::Linear); | 2124 | + primary_scanout_formats.retain(|f| f.modifier == Modifier::Linear); |
| 2125 | + primary_or_overlay_scanout_formats.retain(|f| f.modifier == Modifier::Linear); | ||
| 2139 | } | 2126 | } |
| 2140 | 2127 | ||
| 2141 | let builder = DmabufFeedbackBuilder::new(primary_render_node.dev_id(), primary_formats); | 2128 | let builder = DmabufFeedbackBuilder::new(primary_render_node.dev_id(), primary_formats); |
| 2142 | 2129 | ||
| 2130 | + trace!( | ||
| 2131 | + "primary scanout formats: {}, overlay adds: {}", | ||
| 2132 | + primary_scanout_formats.len(), | ||
| 2133 | + primary_or_overlay_scanout_formats.len() - primary_scanout_formats.len(), | ||
| 2134 | + ); | ||
| 2135 | + | ||
| 2136 | + // Prefer the primary-plane-only formats, then primary-or-overlay-plane formats. This will | ||
| 2137 | + // increase the chance of scanning out a client even with our disabled-by-default overlay | ||
| 2138 | + // planes. | ||
| 2143 | let scanout = builder | 2139 | let scanout = builder |
| 2144 | .clone() | 2140 | .clone() |
| 2145 | .add_preference_tranche( | 2141 | .add_preference_tranche( |
| 2146 | surface_render_node.dev_id(), | 2142 | surface_render_node.dev_id(), |
| 2147 | Some(TrancheFlags::Scanout), | 2143 | Some(TrancheFlags::Scanout), |
| 2148 | - scanout_formats, | 2144 | + primary_scanout_formats, |
| 2145 | + ) | ||
| 2146 | + .add_preference_tranche( | ||
| 2147 | + surface_render_node.dev_id(), | ||
| 2148 | + Some(TrancheFlags::Scanout), | ||
| 2149 | + primary_or_overlay_scanout_formats, | ||
| 2149 | ) | 2150 | ) |
| 2150 | .build()?; | 2151 | .build()?; |
| 2151 | 2152 | ||
src/niri.rsmodified+4 -13
| @@ -1107,7 +1107,6 @@ impl State { | |||
| 1107 | let mut preserved_output_config = None; | 1107 | let mut preserved_output_config = None; |
| 1108 | let mut window_rules_changed = false; | 1108 | let mut window_rules_changed = false; |
| 1109 | let mut layer_rules_changed = false; | 1109 | let mut layer_rules_changed = false; |
| 1110 | - let mut debug_config_changed = false; | ||
| 1111 | let mut shaders_changed = false; | 1110 | let mut shaders_changed = false; |
| 1112 | let mut cursor_inactivity_timeout_changed = false; | 1111 | let mut cursor_inactivity_timeout_changed = false; |
| 1113 | let mut old_config = self.niri.config.borrow_mut(); | 1112 | let mut old_config = self.niri.config.borrow_mut(); |
| @@ -1206,14 +1205,10 @@ impl State { | |||
| 1206 | cursor_inactivity_timeout_changed = true; | 1205 | cursor_inactivity_timeout_changed = true; |
| 1207 | } | 1206 | } |
| 1208 | 1207 | ||
| 1209 | - if config.debug != old_config.debug { | 1208 | + if config.debug.keep_laptop_panel_on_when_lid_is_closed |
| 1210 | - debug_config_changed = true; | 1209 | + != old_config.debug.keep_laptop_panel_on_when_lid_is_closed |
| 1211 | - | 1210 | + { |
| 1212 | - if config.debug.keep_laptop_panel_on_when_lid_is_closed | 1211 | + output_config_changed = true; |
| 1213 | - != old_config.debug.keep_laptop_panel_on_when_lid_is_closed | ||
| 1214 | - { | ||
| 1215 | - output_config_changed = true; | ||
| 1216 | - } | ||
| 1217 | } | 1212 | } |
| 1218 | 1213 | ||
| 1219 | *old_config = config; | 1214 | *old_config = config; |
| @@ -1246,10 +1241,6 @@ impl State { | |||
| 1246 | self.reload_output_config(); | 1241 | self.reload_output_config(); |
| 1247 | } | 1242 | } |
| 1248 | 1243 | ||
| 1249 | - if debug_config_changed { | ||
| 1250 | - self.backend.on_debug_config_changed(); | ||
| 1251 | - } | ||
| 1252 | - | ||
| 1253 | if window_rules_changed { | 1244 | if window_rules_changed { |
| 1254 | self.niri.recompute_window_rules(); | 1245 | self.niri.recompute_window_rules(); |
| 1255 | } | 1246 | } |