Skip to content

Commit 27a4681

Browse files
committed
drm: WIP format_selection heuristic
1 parent 8161583 commit 27a4681

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

src/backend/drm/format_selection.rs

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
use drm::control::{connector, crtc, Mode};
2+
use drm_fourcc::{DrmFormat, DrmFourcc, DrmModifier};
3+
4+
use crate::backend::allocator::Allocator;
5+
6+
use super::{exporter::ExportFramebuffer, DrmDevice, DrmSurface};
7+
8+
pub struct SurfaceDefinition<'a> {
9+
pub crtc: crtc::Handle,
10+
pub mode: &'a Mode,
11+
pub connectors: &'a [connector::Handle],
12+
}
13+
14+
pub fn select_formats<'a, A: Allocator, F: ExportFramebuffer<A::Buffer>>(
15+
device: &DrmDevice,
16+
allocator: &mut A,
17+
framebuffer_exporter: &F,
18+
surfaces: impl IntoIterator<Item = SurfaceDefinition<'a>>,
19+
color_formats: impl IntoIterator<Item = DrmFourcc>,
20+
renderer_formats: impl IntoIterator<Item = DrmFormat>,
21+
) -> Vec<SurfaceFormat<'a>> {
22+
let surfaces = surfaces.into_iter();
23+
let color_formats = color_formats.into_iter().collect::<Vec<_>>();
24+
let mut surface_formats: Vec<SurfaceFormat<'a>> = Vec::with_capacity(surfaces.size_hint().0);
25+
26+
// TODO: Okay, so the idea is that we first check if we have a legacy device or atomic
27+
// In case we have a legacy device we just search for supported formats and test them accepting it might just flicker like hell...
28+
// For atomic issue test commits with:
29+
// - All planes except the primaries for the supplied surfaces disabled
30+
// - All crtc disabled except the passed ones
31+
// - Format by format...with some limit and then just use Invalid
32+
33+
todo!("Implement the actual format selection...")
34+
}
35+
36+
pub struct SurfaceFormat<'a> {
37+
pub surface: &'a DrmSurface,
38+
pub code: DrmFourcc,
39+
pub modifiers: Vec<DrmModifier>,
40+
}

src/backend/drm/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,10 @@ pub(crate) mod device;
7676
#[cfg(feature = "backend_drm")]
7777
pub mod dumb;
7878
mod error;
79+
pub mod exporter;
80+
pub mod format_selection;
7981
#[cfg(feature = "backend_gbm")]
8082
pub mod gbm;
81-
pub mod exporter;
8283
pub mod output;
8384

8485
mod surface;

0 commit comments

Comments
 (0)