Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/wiki/Configuration:-Debug-Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ debug {
### `disable-direct-scanout`

Disable direct scanout to both the primary plane and the overlay planes.
This also disables the scanout tranches in the DMA-BUF feedback sent to clients.

```kdl
debug {
Expand Down
8 changes: 1 addition & 7 deletions src/backend/tty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2840,13 +2840,7 @@ fn surface_dmabuf_feedback(
)
.build()?;

// If this is the primary node surface, send scanout formats in both tranches to avoid
// duplication.
let render = if surface_render_node == Some(primary_render_node) {
scanout.clone()
} else {
builder.build()?
};
let render = builder.build()?;

Ok(SurfaceDmabufFeedback { render, scanout })
}
Expand Down
64 changes: 23 additions & 41 deletions src/niri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ use smithay::wayland::compositor::{
CompositorState, HookId, SurfaceData, TraversalAction,
};
use smithay::wayland::cursor_shape::CursorShapeManagerState;
use smithay::wayland::dmabuf::DmabufState;
use smithay::wayland::dmabuf::{DmabufFeedback, DmabufState};
use smithay::wayland::fractional_scale::FractionalScaleManagerState;
use smithay::wayland::idle_inhibit::IdleInhibitManagerState;
use smithay::wayland::idle_notify::IdleNotifierState;
Expand Down Expand Up @@ -4930,36 +4930,39 @@ impl Niri {
) {
let _span = tracy_client::span!("Niri::send_dmabuf_feedbacks");

let disable_direct_scanout = self.config.borrow().debug.disable_direct_scanout;
let select_client_dmabuf_feedback =
|surface: &WlSurface, _: &SurfaceData| -> &DmabufFeedback {
if disable_direct_scanout {
// If direct scanout is disabled, scanout tranches cannot provide their intended
// benefit and can still make clients choose fragile scanout-oriented allocations.
return &feedback.render;
}

select_dmabuf_feedback(
surface,
render_element_states,
&feedback.render,
&feedback.scanout,
)
};

// We can unconditionally send the current output's feedback to regular and layer-shell
// surfaces, as they can only be displayed on a single output at a time. Even if a surface
// is currently invisible, this is the DMABUF feedback that it should know about.
for mapped in self.layout.windows_for_output(output) {
mapped.window.send_dmabuf_feedback(
output,
|_, _| Some(output.clone()),
|surface, _| {
select_dmabuf_feedback(
surface,
render_element_states,
&feedback.render,
&feedback.scanout,
)
},
select_client_dmabuf_feedback,
);
}

for surface in layer_map_for_output(output).layers() {
surface.send_dmabuf_feedback(
output,
|_, _| Some(output.clone()),
|surface, _| {
select_dmabuf_feedback(
surface,
render_element_states,
&feedback.render,
&feedback.scanout,
)
},
select_client_dmabuf_feedback,
);
}

Expand All @@ -4968,14 +4971,7 @@ impl Niri {
surface.wl_surface(),
output,
|_, _| Some(output.clone()),
|surface, _| {
select_dmabuf_feedback(
surface,
render_element_states,
&feedback.render,
&feedback.scanout,
)
},
select_client_dmabuf_feedback,
);
}

Expand All @@ -4984,14 +4980,7 @@ impl Niri {
surface,
output,
surface_primary_scanout_output,
|surface, _| {
select_dmabuf_feedback(
surface,
render_element_states,
&feedback.render,
&feedback.scanout,
)
},
select_client_dmabuf_feedback,
);
}

Expand All @@ -5000,14 +4989,7 @@ impl Niri {
surface,
output,
surface_primary_scanout_output,
|surface, _| {
select_dmabuf_feedback(
surface,
render_element_states,
&feedback.render,
&feedback.scanout,
)
},
select_client_dmabuf_feedback,
);
}
}
Expand Down