tty: Create allocator at device creation
Browse files at this commit5555e5578c14b6ce847ca8e54bfb2081dfd5b490Parent: a21aac91 changed file +7 -6
- src/backend/tty.rs +7 -6
src/backend/tty.rsmodified+7 -6
| @@ -140,6 +140,7 @@ pub struct OutputDevice { | |||
| 140 | // See https://github.com/Smithay/smithay/issues/1102. | 140 | // See https://github.com/Smithay/smithay/issues/1102. |
| 141 | drm: DrmDevice, | 141 | drm: DrmDevice, |
| 142 | gbm: GbmDevice<DrmDeviceFd>, | 142 | gbm: GbmDevice<DrmDeviceFd>, |
| 143 | + allocator: GbmAllocator<DrmDeviceFd>, | ||
| 143 | 144 | ||
| 144 | pub drm_lease_state: Option<DrmLeaseState>, | 145 | pub drm_lease_state: Option<DrmLeaseState>, |
| 145 | non_desktop_connectors: HashSet<(connector::Handle, crtc::Handle)>, | 146 | non_desktop_connectors: HashSet<(connector::Handle, crtc::Handle)>, |
| @@ -825,6 +826,9 @@ impl Tty { | |||
| 825 | } | 826 | } |
| 826 | } | 827 | } |
| 827 | 828 | ||
| 829 | + let gbm_flags = GbmBufferFlags::RENDERING | GbmBufferFlags::SCANOUT; | ||
| 830 | + let allocator = GbmAllocator::new(gbm.clone(), gbm_flags); | ||
| 831 | + | ||
| 828 | let token = niri | 832 | let token = niri |
| 829 | .event_loop | 833 | .event_loop |
| 830 | .insert_source(drm_notifier, move |event, meta, state| { | 834 | .insert_source(drm_notifier, move |event, meta, state| { |
| @@ -848,6 +852,7 @@ impl Tty { | |||
| 848 | render_node, | 852 | render_node, |
| 849 | drm, | 853 | drm, |
| 850 | gbm, | 854 | gbm, |
| 855 | + allocator, | ||
| 851 | drm_scanner: DrmScanner::new(), | 856 | drm_scanner: DrmScanner::new(), |
| 852 | surfaces: HashMap::new(), | 857 | surfaces: HashMap::new(), |
| 853 | known_crtcs: HashMap::new(), | 858 | known_crtcs: HashMap::new(), |
| @@ -1261,10 +1266,6 @@ impl Tty { | |||
| 1261 | } | 1266 | } |
| 1262 | } | 1267 | } |
| 1263 | 1268 | ||
| 1264 | - // Create GBM allocator. | ||
| 1265 | - let gbm_flags = GbmBufferFlags::RENDERING | GbmBufferFlags::SCANOUT; | ||
| 1266 | - let allocator = GbmAllocator::new(device.gbm.clone(), gbm_flags); | ||
| 1267 | - | ||
| 1268 | // Update the output mode. | 1269 | // Update the output mode. |
| 1269 | let (physical_width, physical_height) = connector.size().unwrap_or((0, 0)); | 1270 | let (physical_width, physical_height) = connector.size().unwrap_or((0, 0)); |
| 1270 | 1271 | ||
| @@ -1334,7 +1335,7 @@ impl Tty { | |||
| 1334 | OutputModeSource::Auto(output.clone()), | 1335 | OutputModeSource::Auto(output.clone()), |
| 1335 | surface, | 1336 | surface, |
| 1336 | None, | 1337 | None, |
| 1337 | - allocator.clone(), | 1338 | + device.allocator.clone(), |
| 1338 | GbmFramebufferExporter::new(device.gbm.clone(), device.render_node.into()), | 1339 | GbmFramebufferExporter::new(device.gbm.clone(), device.render_node.into()), |
| 1339 | SUPPORTED_COLOR_FORMATS, | 1340 | SUPPORTED_COLOR_FORMATS, |
| 1340 | // This is only used to pick a good internal format, so it can use the surface's render | 1341 | // This is only used to pick a good internal format, so it can use the surface's render |
| @@ -1364,7 +1365,7 @@ impl Tty { | |||
| 1364 | OutputModeSource::Auto(output.clone()), | 1365 | OutputModeSource::Auto(output.clone()), |
| 1365 | surface, | 1366 | surface, |
| 1366 | None, | 1367 | None, |
| 1367 | - allocator, | 1368 | + device.allocator.clone(), |
| 1368 | GbmFramebufferExporter::new(device.gbm.clone(), device.render_node.into()), | 1369 | GbmFramebufferExporter::new(device.gbm.clone(), device.render_node.into()), |
| 1369 | SUPPORTED_COLOR_FORMATS, | 1370 | SUPPORTED_COLOR_FORMATS, |
| 1370 | render_formats, | 1371 | render_formats, |