tty: Don't store render formats

Actually, how did it even fork before? Pretty sure it was storing render
formats, not texture formats, but with render formats
weston-simple-dmabuf-feedback doesn't work?
This commit is contained in:
Ivan Molodetskikh
2024-01-01 10:18:22 +04:00
parent ac6ff7ff41
commit 655fe413fb
+9 -10
View File
@@ -8,16 +8,15 @@ use std::time::Duration;
use anyhow::{anyhow, Context}; use anyhow::{anyhow, Context};
use libc::dev_t; use libc::dev_t;
use smithay::backend::allocator::dmabuf::Dmabuf;
use smithay::backend::allocator::gbm::{GbmAllocator, GbmBufferFlags, GbmDevice}; use smithay::backend::allocator::gbm::{GbmAllocator, GbmBufferFlags, GbmDevice};
use smithay::backend::allocator::{Format as DrmFormat, Fourcc}; use smithay::backend::allocator::Fourcc;
use smithay::backend::drm::compositor::{DrmCompositor, PrimaryPlaneElement}; use smithay::backend::drm::compositor::{DrmCompositor, PrimaryPlaneElement};
use smithay::backend::drm::{DrmDevice, DrmDeviceFd, DrmEvent, DrmEventMetadata, DrmEventTime}; use smithay::backend::drm::{DrmDevice, DrmDeviceFd, DrmEvent, DrmEventMetadata, DrmEventTime};
use smithay::backend::egl::context::ContextPriority; use smithay::backend::egl::context::ContextPriority;
use smithay::backend::egl::{EGLContext, EGLDisplay}; use smithay::backend::egl::{EGLContext, EGLDisplay};
use smithay::backend::libinput::{LibinputInputBackend, LibinputSessionInterface}; use smithay::backend::libinput::{LibinputInputBackend, LibinputSessionInterface};
use smithay::backend::renderer::gles::{Capability, GlesRenderer, GlesTexture}; use smithay::backend::renderer::gles::{Capability, GlesRenderer, GlesTexture};
use smithay::backend::renderer::{Bind, DebugFlags, ImportDma, ImportEgl}; use smithay::backend::renderer::{DebugFlags, ImportDma, ImportEgl};
use smithay::backend::session::libseat::LibSeatSession; use smithay::backend::session::libseat::LibSeatSession;
use smithay::backend::session::{Event as SessionEvent, Session}; use smithay::backend::session::{Event as SessionEvent, Session};
use smithay::backend::udev::{self, UdevBackend, UdevEvent}; use smithay::backend::udev::{self, UdevBackend, UdevEvent};
@@ -70,7 +69,6 @@ struct OutputDevice {
id: dev_t, id: dev_t,
token: RegistrationToken, token: RegistrationToken,
gles: GlesRenderer, gles: GlesRenderer,
formats: HashSet<DrmFormat>,
drm_scanner: DrmScanner, drm_scanner: DrmScanner,
surfaces: HashMap<crtc::Handle, Surface>, surfaces: HashMap<crtc::Handle, Surface>,
// SAFETY: drop after all the objects used with them are dropped. // SAFETY: drop after all the objects used with them are dropped.
@@ -329,8 +327,6 @@ impl Tty {
}) })
.unwrap(); .unwrap();
let formats = Bind::<Dmabuf>::supported_formats(&gles).unwrap_or_default();
let default_feedback = DmabufFeedbackBuilder::new(device_id, gles.dmabuf_formats()) let default_feedback = DmabufFeedbackBuilder::new(device_id, gles.dmabuf_formats())
.build() .build()
.context("error building default dmabuf feedback")?; .context("error building default dmabuf feedback")?;
@@ -344,7 +340,6 @@ impl Tty {
drm, drm,
gbm, gbm,
gles, gles,
formats,
drm_scanner: DrmScanner::new(), drm_scanner: DrmScanner::new(),
surfaces: HashMap::new(), surfaces: HashMap::new(),
}); });
@@ -576,6 +571,10 @@ impl Tty {
planes.overlay.clear(); planes.overlay.clear();
} }
let egl_context = device.gles.egl_context();
let texture_formats = egl_context.dmabuf_texture_formats();
let render_formats = egl_context.dmabuf_render_formats();
let scanout_formats = planes let scanout_formats = planes
.primary .primary
.formats .formats
@@ -583,7 +582,7 @@ impl Tty {
.chain(planes.overlay.iter().flat_map(|p| &p.formats)) .chain(planes.overlay.iter().flat_map(|p| &p.formats))
.copied() .copied()
.collect::<HashSet<_>>(); .collect::<HashSet<_>>();
let scanout_formats = scanout_formats.intersection(&device.formats).copied(); let scanout_formats = scanout_formats.intersection(texture_formats).copied();
// Create the compositor. // Create the compositor.
let compositor = DrmCompositor::new( let compositor = DrmCompositor::new(
@@ -593,12 +592,12 @@ impl Tty {
allocator, allocator,
device.gbm.clone(), device.gbm.clone(),
SUPPORTED_COLOR_FORMATS, SUPPORTED_COLOR_FORMATS,
device.formats.clone(), render_formats.clone(),
device.drm.cursor_size(), device.drm.cursor_size(),
Some(device.gbm.clone()), Some(device.gbm.clone()),
)?; )?;
let dmabuf_feedback = DmabufFeedbackBuilder::new(device.id, device.formats.clone()) let dmabuf_feedback = DmabufFeedbackBuilder::new(device.id, texture_formats.clone())
.add_preference_tranche(device.id, Some(TrancheFlags::Scanout), scanout_formats) .add_preference_tranche(device.id, Some(TrancheFlags::Scanout), scanout_formats)
.build() .build()
.context("error building dmabuf feedback")?; .context("error building dmabuf feedback")?;