srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/crates/wayland/src/udev/render.rs
diff options
context:
space:
mode:
authorsrdusr <[email protected]>2025-05-15 20:45:00 +0200
committersrdusr <[email protected]>2025-05-15 20:45:00 +0200
commit54195f079810410eb9456348e7e44d382d3c4d3f (patch)
tree2e7a2a47c66eeec8a3762e8b4a04124e8227f9ab /crates/wayland/src/udev/render.rs
parent317b3b269cc526b410b6d0c0666e16ae84832ef9 (diff)
downloadsrdwm-54195f079810410eb9456348e7e44d382d3c4d3f.tar.gz
srdwm-54195f079810410eb9456348e7e44d382d3c4d3f.zip
Extend GPU rendering to every head, not just the first
Phase 2 of the GPU-rendering plan deliberately targeted a single head (GpuContext::output: Option<(crtc::Handle, GpuOutput)>) as a narrow proof that GBM+EGL+DrmCompositor rendering works at all on this hardware. DrmOutputManager already supports driving several crtcs at once - initialize_output is a per-crtc call on one shared manager, the same way anvil drives multiple outputs - so this was purely an unexercised restriction, not an architectural limit. GpuContext::output is now GpuContext::outputs: Vec<(crtc::Handle, GpuOutput)>, and udev/platform.rs calls initialize_output for every connected head in its own bring-up loop instead of only the first after that loop finishes. A head this fails for individually (already logged, not fatal) still just has no entry and falls back to the existing legacy Pixman path, unchanged from before. session.rs's VBlank handler and its VT-switch resume path (which excludes GPU-driven crtcs from the legacy set_crtc reassert loop, a different device fd that must never issue mode-set commands against a crtc DrmOutputManager already owns) both now look a crtc up in the Vec instead of comparing against a single stored one. render.rs's own render-loop lookup uses direct field access (gpu.outputs.iter_mut().find(...)) rather than an equivalent &mut self method: the borrow checker treats a method call as borrowing all of GpuContext, including gpu.renderer needed a few lines later for the same head, where direct field access lets it see the two borrows are disjoint. Still gated behind SRDWM_GPU=1 (unset by default) and untested on real multi-monitor hardware with the flag on - this machine has one display, so the actual multi-head path itself only gets exercised whenever it's set on hardware that has more than one.
Diffstat (limited to 'crates/wayland/src/udev/render.rs')
-rw-r--r--crates/wayland/src/udev/render.rs50
1 files changed, 28 insertions, 22 deletions
diff --git a/crates/wayland/src/udev/render.rs b/crates/wayland/src/udev/render.rs
index 6bf2979..cfc9efd 100644
--- a/crates/wayland/src/udev/render.rs
+++ b/crates/wayland/src/udev/render.rs
@@ -214,30 +214,36 @@ impl CompState {
let Some(udev) = self.udev.as_mut() else { return };
let head_crtc = udev.heads[index].crtc;
// Phase 2 of the GPU-rendering plan (`gpu.rs`'s own module doc
- // comment): the one head `initialize_output` was called for
- // (if `SRDWM_GPU=1` and everything up to that point succeeded)
- // renders a plain clear color through the real GBM+EGL+
- // DrmCompositor pipeline instead of anything below - no
- // window content, decorations, or cursor yet, deliberately
- // (see that module's own doc comment for why). Every other
- // head, and this same head whenever `udev.gpu`/its `output`
- // is `None`, falls straight through to the existing,
- // untouched Pixman path unchanged.
+ // comment), now extended to every head `initialize_output`
+ // succeeded for (`GpuContext::outputs`' own doc comment), not
+ // just the first: each renders a plain clear color through the
+ // real GBM+EGL+DrmCompositor pipeline instead of anything
+ // below - no window content, decorations, or cursor yet,
+ // deliberately (see that module's own doc comment for why).
+ // Any head `output_for_mut` finds nothing for - either
+ // `SRDWM_GPU` was never set, or `initialize_output` failed for
+ // this specific crtc - falls straight through to the
+ // existing, untouched Pixman path unchanged.
if let Some(gpu) = udev.gpu.as_mut() {
- if let Some((gpu_crtc, gpu_output)) = gpu.output.as_mut() {
- if *gpu_crtc == head_crtc {
- let elements: [smithay::backend::renderer::element::memory::MemoryRenderBufferRenderElement<smithay::backend::renderer::gles::GlesRenderer>; 0] = [];
- let clear_color = [0.05, 0.05, 0.08, 1.0];
- match gpu_output.render_frame(&mut gpu.renderer, &elements, clear_color, smithay::backend::drm::compositor::FrameFlags::DEFAULT) {
- Ok(res) if !res.is_empty => match gpu_output.queue_frame(None) {
- Ok(()) => {}
- Err(e) => log::warn!("udev: SRDWM_GPU=1 queue_frame failed for crtc {head_crtc:?}: {e:?}"),
- },
- Ok(_) => {}
- Err(e) => log::warn!("udev: SRDWM_GPU=1 render_frame failed for crtc {head_crtc:?}: {e:?}"),
- }
- continue;
+ // Direct field access (`gpu.outputs`), not `GpuContext::
+ // output_for_mut` - that method takes `&mut self`, which
+ // the borrow checker treats as borrowing all of `gpu`,
+ // including `gpu.renderer` needed a few lines below. Rust's
+ // disjoint-field-borrow analysis only sees through *direct*
+ // field access, not a method call, even one that (like
+ // this one) only actually touches `self.outputs`.
+ if let Some(gpu_output) = gpu.outputs.iter_mut().find(|(c, _)| *c == head_crtc).map(|(_, o)| o) {
+ let elements: [smithay::backend::renderer::element::memory::MemoryRenderBufferRenderElement<smithay::backend::renderer::gles::GlesRenderer>; 0] = [];
+ let clear_color = [0.05, 0.05, 0.08, 1.0];
+ match gpu_output.render_frame(&mut gpu.renderer, &elements, clear_color, smithay::backend::drm::compositor::FrameFlags::DEFAULT) {
+ Ok(res) if !res.is_empty => match gpu_output.queue_frame(None) {
+ Ok(()) => {}
+ Err(e) => log::warn!("udev: SRDWM_GPU=1 queue_frame failed for crtc {head_crtc:?}: {e:?}"),
+ },
+ Ok(_) => {}
+ Err(e) => log::warn!("udev: SRDWM_GPU=1 render_frame failed for crtc {head_crtc:?}: {e:?}"),
}
+ continue;
}
}