Skip to content

Commit

Permalink
drm: WIP format_selection heuristic
Browse files Browse the repository at this point in the history
  • Loading branch information
Drakulix committed Nov 28, 2024
1 parent 1fc13dd commit 15198e2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
40 changes: 40 additions & 0 deletions src/backend/drm/format_selection.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
use drm::control::{connector, crtc, Mode};
use drm_fourcc::{DrmFormat, DrmFourcc, DrmModifier};

use crate::backend::allocator::Allocator;

use super::{exporter::ExportFramebuffer, DrmDevice, DrmSurface};

pub struct SurfaceDefinition<'a> {
pub crtc: crtc::Handle,
pub mode: &'a Mode,
pub connectors: &'a [connector::Handle],
}

pub fn select_formats<'a, A: Allocator, F: ExportFramebuffer<A::Buffer>>(
device: &DrmDevice,
allocator: &mut A,
framebuffer_exporter: &F,
surfaces: impl IntoIterator<Item = SurfaceDefinition<'a>>,
color_formats: impl IntoIterator<Item = DrmFourcc>,
renderer_formats: impl IntoIterator<Item = DrmFormat>,
) -> Vec<SurfaceFormat<'a>> {
let surfaces = surfaces.into_iter();
let color_formats = color_formats.into_iter().collect::<Vec<_>>();
let mut surface_formats: Vec<SurfaceFormat<'a>> = Vec::with_capacity(surfaces.size_hint().0);

// TODO: Okay, so the idea is that we first check if we have a legacy device or atomic
// In case we have a legacy device we just search for supported formats and test them accepting it might just flicker like hell...
// For atomic issue test commits with:
// - All planes except the primaries for the supplied surfaces disabled
// - All crtc disabled except the passed ones
// - Format by format...with some limit and then just use Invalid

todo!("Implement the actual format selection...")
}

pub struct SurfaceFormat<'a> {
pub surface: &'a DrmSurface,
pub code: DrmFourcc,
pub modifiers: Vec<DrmModifier>,
}
3 changes: 2 additions & 1 deletion src/backend/drm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ pub(crate) mod device;
#[cfg(feature = "backend_drm")]
pub mod dumb;
mod error;
pub mod exporter;
pub mod format_selection;
#[cfg(feature = "backend_gbm")]
pub mod gbm;
pub mod exporter;
pub mod output;

mod surface;
Expand Down

0 comments on commit 15198e2

Please sign in to comment.