kms: Optimize buffer imports to secondary gpus

This commit is contained in:
Victoria Brekenfeld 2022-05-16 18:11:24 +02:00
parent 7de8d6e979
commit 46e679ec92
3 changed files with 76 additions and 41 deletions

View file

@ -1,6 +1,11 @@
// SPDX-License-Identifier: GPL-3.0-only
use crate::{config::Config, input::active_output, state::State, utils::SurfaceDropNotifier};
use crate::{
config::Config,
input::active_output,
state::{BackendData, State},
utils::SurfaceDropNotifier,
};
use smithay::{
backend::renderer::utils::on_commit_buffer_handler,
desktop::{
@ -309,14 +314,18 @@ fn check_grab_preconditions(
}
fn commit(surface: &WlSurface, state: &mut State) {
// TODO figure out which output the surface is on.
for output in state.common.shell.outputs() {
//.cloned().collect::<Vec<_>>().into_iter() {
let mut import_nodes = std::collections::HashSet::new();
for output in state.common.shell.outputs_for_surface(&surface) {
if let BackendData::Kms(ref mut kms_state) = &mut state.backend {
if let Some(target) = kms_state.target_node_for_output(&output) {
if import_nodes.insert(target) {
kms_state.try_early_import(surface, &output, target, &state.common.shell);
}
}
}
state
.backend
.schedule_render(&state.common.event_loop_handle, output);
// let space = state.common.spaces.active_space(output);
// get output for surface
.schedule_render(&state.common.event_loop_handle, &output);
}
let state = &mut state.common;

View file

@ -598,6 +598,15 @@ impl Shell {
}
}
pub fn outputs_for_surface(&self, surface: &WlSurface) -> impl Iterator<Item=Output> {
self.space_for_surface(surface)
.and_then(|w| if let Some(window) = w.space.window_for_surface(surface, WindowSurfaceType::ALL) {
Some(w.space.outputs_for_window(&window).into_iter())
} else { None })
.into_iter()
.flatten()
}
pub fn space_for_surface(&self, surface: &WlSurface) -> Option<&Workspace> {
self.spaces.iter().find(|workspace| {
workspace