From 7a49da0a48f8bdb3c13f6d5e033954c3f475d319 Mon Sep 17 00:00:00 2001 From: kossLAN Date: Fri, 29 May 2026 21:19:57 -0400 Subject: [PATCH] metal: split video object model --- src/backends/metal/video.rs | 377 ++------------------ src/backends/metal/video/copy_device.rs | 13 +- src/backends/metal/video/hardware_cursor.rs | 13 +- src/backends/metal/video/lease.rs | 11 +- src/backends/metal/video/model.rs | 364 +++++++++++++++++++ 5 files changed, 424 insertions(+), 354 deletions(-) create mode 100644 src/backends/metal/video/model.rs diff --git a/src/backends/metal/video.rs b/src/backends/metal/video.rs index 2d8c5365..3d1a82ec 100644 --- a/src/backends/metal/video.rs +++ b/src/backends/metal/video.rs @@ -1,6 +1,7 @@ mod copy_device; mod hardware_cursor; mod lease; +mod model; mod properties; #[allow(unused_imports)] @@ -8,6 +9,12 @@ pub use { copy_device::CopyDeviceHolder, hardware_cursor::{MetalHardwareCursor, MetalHardwareCursorChange}, lease::{MetalLease, MetalLeaseData}, + model::{ + ConnectorDisplayData, ConnectorFutures, FrontState, HandleEvents, MetalConnector, + MetalCrtc, MetalDrmDevice, MetalDrmDeviceData, MetalEncoder, MetalLeaseId, MetalLeaseIds, + MetalPlane, MetalRenderContext, PendingDrmDevice, PersistentDisplayData, PlaneFormat, + PlaneType, + }, properties::{DefaultProperty, TypedProperty}, }; @@ -17,13 +24,13 @@ use properties::{ use { crate::{ - async_engine::{Phase, SpawnedFuture}, + async_engine::Phase, backend::{ - BackendColorSpace, BackendConnectorState, BackendDrmDevice, BackendDrmLease, - BackendDrmLessee, BackendEotfs, BackendEvent, BackendGammaLut, BackendGammaLutElement, + BackendColorSpace, BackendConnectorState, BackendDrmDevice, BackendDrmLessee, + BackendEotfs, BackendEvent, BackendGammaLut, BackendGammaLutElement, BackendLuminance, CONCAP_CONNECTOR, CONCAP_MODE_SETTING, CONCAP_PHYSICAL_DISPLAY, Connector, ConnectorCaps, ConnectorEvent, ConnectorId, ConnectorKernelId, DrmDeviceId, - HardwareCursor, HardwareCursorUpdate, Mode, MonitorInfo, OutputId, + Mode, MonitorInfo, OutputId, transaction::{ BackendConnectorTransaction, BackendConnectorTransactionError, BackendConnectorTransactionType, BackendConnectorTransactionTypeDyn, @@ -31,37 +38,32 @@ use { }, backends::metal::{ MetalBackend, MetalError, - allocator::RenderBuffer, present::{ - DEFAULT_POST_COMMIT_MARGIN, DEFAULT_PRE_COMMIT_MARGIN, DirectScanoutCache, - POST_COMMIT_MARGIN_DELTA, PresentFb, + DEFAULT_POST_COMMIT_MARGIN, DEFAULT_PRE_COMMIT_MARGIN, POST_COMMIT_MARGIN_DELTA, }, transaction::{DrmConnectorState, DrmCrtcState, DrmPlaneState, MetalDeviceTransaction}, }, - cmm::{cmm_description::ColorDescription, cmm_primaries::Primaries}, - copy_device::{CopyDevice, CopyDeviceRegistry}, + cmm::cmm_primaries::Primaries, drm_feedback::DrmFeedback, edid::{CtaDataBlock, Descriptor, EdidExtension}, - format::{Format, XRGB8888}, - gfx_api::{FdSync, GfxApi, GfxContext, GfxFramebuffer}, + format::XRGB8888, + gfx_api::GfxApi, ifs::wp_presentation_feedback::{KIND_HW_COMPLETION, KIND_VSYNC, KIND_ZERO_COPY}, - state::State, tree::OutputNode, udev::UdevDevice, utils::{ - asyncevent::AsyncEvent, binary_search_map::BinarySearchMap, bitflags::BitflagsExt, - cell_ext::CellExt, clonecell::CloneCell, copyhashmap::CopyHashMap, errorfmt::ErrorFmt, - geometric_decay::GeometricDecay, numcell::NumCell, on_change::OnChange, - opaque_cell::OpaqueCell, ordered_float::F64, oserror::OsError, + binary_search_map::BinarySearchMap, bitflags::BitflagsExt, cell_ext::CellExt, + clonecell::CloneCell, copyhashmap::CopyHashMap, errorfmt::ErrorFmt, + geometric_decay::GeometricDecay, numcell::NumCell, ordered_float::F64, + oserror::OsError, }, video::{ - INVALID_MODIFIER, Modifier, - dmabuf::DmaBufId, + INVALID_MODIFIER, drm::{ ConnectorStatus, ConnectorType, DRM_CLIENT_CAP_ATOMIC, DrmBlob, DrmCardResources, - DrmConnector, DrmCrtc, DrmEncoder, DrmError, DrmEvent, DrmFb, DrmLease, DrmMaster, - DrmModeInfo, DrmObject, DrmPlane, DrmProperty, DrmPropertyDefinition, - DrmPropertyType, DrmVersion, HDMI_EOTF_TRADITIONAL_GAMMA_SDR, drm_mode_modeinfo, + DrmConnector, DrmCrtc, DrmEncoder, DrmError, DrmEvent, DrmFb, DrmMaster, + DrmObject, DrmPlane, DrmProperty, DrmPropertyDefinition, DrmPropertyType, + DrmVersion, HDMI_EOTF_TRADITIONAL_GAMMA_SDR, drm_mode_modeinfo, hdr_output_metadata, }, gbm::GbmDevice, @@ -69,82 +71,18 @@ use { }, ahash::{AHashMap, AHashSet}, bstr::{BString, ByteSlice}, - indexmap::{IndexSet, indexset}, + indexmap::indexset, isnt::std_1::collections::IsntHashMapExt, std::{ - cell::{Cell, OnceCell, RefCell}, + cell::{Cell, RefCell}, collections::hash_map::Entry, - ffi::CString, - fmt::{Debug, Formatter}, mem, ops::DerefMut, rc::Rc, }, - uapi::{ - OwnedFd, - c::{self, dev_t}, - }, + uapi::c::{self, dev_t}, }; -pub struct PendingDrmDevice { - pub id: DrmDeviceId, - pub devnum: c::dev_t, - pub devnode: CString, -} - -#[derive(Debug)] -pub struct MetalRenderContext { - pub dev_id: DrmDeviceId, - pub gfx: Rc, - pub gbm: Rc, - pub devnode: CString, - pub copy_device: Rc, -} - - -pub struct MetalDrmDevice { - pub backend: Rc, - pub id: DrmDeviceId, - pub devnum: c::dev_t, - pub devnode: CString, - pub master: Rc, - pub supports_kms: bool, - pub crtcs: AHashMap>, - pub encoders: AHashMap>, - pub planes: AHashMap>, - pub cursor_width: u64, - pub cursor_height: u64, - pub supports_async_commit: bool, - pub gbm: Rc, - pub handle_events: HandleEvents, - pub ctx: CloneCell>, - pub copy_device: Rc, - pub on_change: OnChange, - pub direct_scanout_enabled: Cell>, - pub is_nvidia: bool, - pub _is_amd: bool, - pub lease_ids: MetalLeaseIds, - pub leases: CopyHashMap, - pub leases_to_break: CopyHashMap, - pub paused: Cell, - pub min_post_commit_margin: Cell, -} - -impl Debug for MetalDrmDevice { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - f.debug_struct("MetalDrmDevice").finish_non_exhaustive() - } -} - -impl MetalDrmDevice { - pub fn is_render_device(&self) -> bool { - if let Some(ctx) = self.backend.ctx.get() { - return ctx.dev_id == self.id; - } - false - } -} - impl BackendDrmDevice for MetalDrmDevice { fn id(&self) -> DrmDeviceId { self.id @@ -326,180 +264,6 @@ impl BackendDrmDevice for MetalDrmDevice { } } -pub struct HandleEvents { - pub handle_events: Cell>>, -} - -impl Debug for HandleEvents { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - f.debug_struct("HandleEvents").finish_non_exhaustive() - } -} - -#[derive(Debug)] -pub struct MetalDrmDeviceData { - pub dev: Rc, - pub connectors: CopyHashMap>, - pub futures: CopyHashMap, -} - -#[derive(Debug)] -pub struct PersistentDisplayData { - pub state: RefCell, -} - - -#[derive(Debug)] -pub struct ConnectorDisplayData { - pub crtc_id: DrmProperty, - pub crtcs: BinarySearchMap, 8>, - pub first_mode: Mode, - pub modes: Vec, - pub persistent: Rc, - pub refresh: u32, - pub non_desktop: bool, - pub non_desktop_effective: bool, - pub vrr_capable: bool, - pub _vrr_refresh_max_nsec: u64, - pub default_properties: Vec, - pub untyped_properties: AHashMap, - - pub connector_id: ConnectorKernelId, - pub output_id: Rc, - - pub connection: ConnectorStatus, - pub mm_width: u32, - pub mm_height: u32, - pub _subpixel: u32, - - pub supports_bt2020: bool, - pub supports_pq: bool, - pub primaries: Primaries, - pub luminance: Option, - - pub colorspace: Option, - pub hdr_metadata: Option, - pub drm_state: DrmConnectorState, -} - -impl ConnectorDisplayData { - fn update_refresh(&mut self, dev: &MetalDrmDevice) { - self.refresh = 0; - if self.drm_state.crtc_id.is_none() { - return; - } - let Some(crtc) = dev.crtcs.get(&self.drm_state.crtc_id) else { - return; - }; - let drm_state = &*crtc.drm_state.borrow(); - let Some(mode) = &drm_state.mode else { - return; - }; - let refresh_rate_mhz = mode.refresh_rate_millihz(); - if refresh_rate_mhz != 0 { - self.refresh = (1_000_000_000_000u64 / refresh_rate_mhz as u64) as u32; - } - } - - fn update_non_desktop_effective(&mut self) { - let state = &*self.persistent.state.borrow(); - self.non_desktop_effective = - !state.enabled || state.non_desktop_override.unwrap_or(self.non_desktop); - } - - pub fn update_cached_fields(&mut self, dev: &MetalDrmDevice) { - self.update_refresh(dev); - self.update_non_desktop_effective(); - } -} - -linear_ids!(MetalLeaseIds, MetalLeaseId, u64); - -#[derive(Copy, Clone, Debug, PartialEq, Eq)] -pub enum FrontState { - Removed, - Disconnected, - Connected { non_desktop: bool }, - Unavailable, -} - -pub struct MetalConnector { - pub id: DrmConnector, - pub kernel_id: Cell, - pub master: Rc, - pub state: Rc, - - pub dev: Rc, - pub backend: Rc, - - pub connector_id: ConnectorId, - - pub buffers: CloneCell>>, - pub color_description: CloneCell>, - - pub lease: Cell>, - - pub buffers_idle: Cell, - pub crtc_idle: Cell, - pub has_damage: NumCell, - pub cursor_changed: Cell, - pub cursor_damage: Cell, - pub next_vblank_nsec: Cell, - - pub display: RefCell, - - pub frontend_state: Cell, - - pub primary_plane: CloneCell>>, - pub cursor_plane: CloneCell>>, - - pub crtc: CloneCell>>, - - pub on_change: OnChange, - - pub present_trigger: AsyncEvent, - - pub cursor_x: Cell, - pub cursor_y: Cell, - pub cursor_enabled: Cell, - pub cursor_buffers: CloneCell>>, - pub cursor_swap_buffer: Cell, - pub cursor_sync: CloneCell>, - - pub drm_feedback: CloneCell>>, - pub scanout_buffers: RefCell>, - pub active_framebuffer: RefCell>, - pub next_framebuffer: OpaqueCell>, - pub direct_scanout_active: Cell, - - pub version: NumCell, - pub expected_sequence: Cell>, - pub pre_commit_margin: Cell, - pub pre_commit_margin_decay: GeometricDecay, - pub post_commit_margin: Cell, - pub post_commit_margin_decay: GeometricDecay, - pub vblank_miss_sec: Cell, - pub vblank_miss_this_sec: NumCell, - pub presentation_is_sync: Cell, - pub presentation_is_zero_copy: Cell, -} - -impl Debug for MetalConnector { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - f.debug_struct("MetalConnnector").finish_non_exhaustive() - } -} - -pub struct ConnectorFutures { - pub _present: SpawnedFuture<()>, -} - -impl Debug for ConnectorFutures { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - f.debug_struct("ConnectorFutures").finish_non_exhaustive() - } -} - impl MetalConnector { pub fn send_connected(self: &Rc) { let dd = &*self.display.borrow(); @@ -792,95 +556,6 @@ impl Connector for MetalConnector { } } -pub struct MetalCrtc { - pub id: DrmCrtc, - pub idx: usize, - pub master: Rc, - pub default_properties: Vec, - pub untyped_properties: RefCell>, - - pub lease: Cell>, - - pub possible_planes: BinarySearchMap, 8>, - - pub connector: CloneCell>>, - pub pending_flip: CloneCell>>, - - pub active: DrmProperty, - pub mode_id: DrmProperty, - pub vrr_enabled: DrmProperty, - pub out_fence_ptr: DrmProperty, - pub gamma_lut: Option, - pub gamma_lut_size: Option, - pub drm_state: RefCell, - - pub sequence: Cell, - pub have_queued_sequence: Cell, - pub needs_vblank_emulation: Cell, -} - -impl Debug for MetalCrtc { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - f.debug_struct("MetalCrtc").finish_non_exhaustive() - } -} - -#[derive(Debug)] -pub struct MetalEncoder { - pub id: DrmEncoder, - pub crtcs: AHashMap>, -} - -#[derive(Debug, Copy, Clone, Eq, PartialEq)] -pub enum PlaneType { - Overlay, - Primary, - Cursor, -} - -#[derive(Debug)] -pub struct PlaneFormat { - pub format: &'static Format, - pub modifiers: IndexSet, -} - -pub struct MetalPlane { - pub id: DrmPlane, - pub master: Rc, - pub default_properties: Vec, - pub untyped_properties: RefCell>, - - pub ty: PlaneType, - - pub possible_crtcs: u32, - pub formats: AHashMap, - - pub lease: Cell>, - - pub mode_w: Cell, - pub mode_h: Cell, - - pub crtc_id: DrmProperty, - pub crtc_x: DrmProperty, - pub crtc_y: DrmProperty, - pub crtc_w: DrmProperty, - pub crtc_h: DrmProperty, - pub src_x: DrmProperty, - pub src_y: DrmProperty, - pub src_w: DrmProperty, - pub src_h: DrmProperty, - pub in_fence_fd: DrmProperty, - pub fb_id: DrmProperty, - - pub drm_state: RefCell, -} - -impl Debug for MetalPlane { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - f.debug_struct("MetalPlane").finish_non_exhaustive() - } -} - fn get_connectors( backend: &Rc, dev: &Rc, diff --git a/src/backends/metal/video/copy_device.rs b/src/backends/metal/video/copy_device.rs index 09d75824..29c0b3fe 100644 --- a/src/backends/metal/video/copy_device.rs +++ b/src/backends/metal/video/copy_device.rs @@ -1,4 +1,15 @@ -use super::*; +use { + crate::{ + copy_device::{CopyDevice, CopyDeviceRegistry}, + utils::errorfmt::ErrorFmt, + }, + std::{ + cell::OnceCell, + fmt::{Debug, Formatter}, + rc::Rc, + }, + uapi::c::dev_t, +}; pub struct CopyDeviceHolder { pub registry: Rc, diff --git a/src/backends/metal/video/hardware_cursor.rs b/src/backends/metal/video/hardware_cursor.rs index 3eacbb68..47dfb134 100644 --- a/src/backends/metal/video/hardware_cursor.rs +++ b/src/backends/metal/video/hardware_cursor.rs @@ -1,4 +1,15 @@ -use super::*; +use { + super::MetalConnector, + crate::{ + backend::{HardwareCursor, HardwareCursorUpdate}, + backends::metal::allocator::RenderBuffer, + gfx_api::{FdSync, GfxFramebuffer}, + }, + std::{ + fmt::{Debug, Formatter}, + rc::Rc, + }, +}; pub struct MetalHardwareCursor { pub connector: Rc, diff --git a/src/backends/metal/video/lease.rs b/src/backends/metal/video/lease.rs index cef6cb8d..b681c0cc 100644 --- a/src/backends/metal/video/lease.rs +++ b/src/backends/metal/video/lease.rs @@ -1,4 +1,13 @@ -use super::*; +use { + super::{FrontState, MetalConnector, MetalCrtc, MetalDrmDevice, MetalLeaseId, MetalPlane}, + crate::{ + backend::{BackendDrmLease, BackendDrmLessee, ConnectorEvent}, + utils::errorfmt::ErrorFmt, + video::drm::DrmLease, + }, + std::{cell::Cell, rc::Rc}, + uapi::OwnedFd, +}; pub struct MetalLeaseData { pub lease: DrmLease, diff --git a/src/backends/metal/video/model.rs b/src/backends/metal/video/model.rs new file mode 100644 index 00000000..c220b8cb --- /dev/null +++ b/src/backends/metal/video/model.rs @@ -0,0 +1,364 @@ +use { + super::{copy_device::CopyDeviceHolder, lease::MetalLeaseData, properties::DefaultProperty}, + crate::{ + async_engine::SpawnedFuture, + backend::{ + BackendConnectorState, BackendLuminance, ConnectorEvent, ConnectorId, + ConnectorKernelId, DrmDeviceId, DrmEvent, Mode, OutputId, + }, + backends::metal::{ + MetalBackend, + allocator::RenderBuffer, + present::{DirectScanoutCache, PresentFb}, + transaction::{DrmConnectorState, DrmCrtcState, DrmPlaneState}, + }, + cmm::{cmm_description::ColorDescription, cmm_primaries::Primaries}, + drm_feedback::DrmFeedback, + format::Format, + gfx_api::{FdSync, GfxContext}, + state::State, + utils::{ + asyncevent::AsyncEvent, binary_search_map::BinarySearchMap, clonecell::CloneCell, + copyhashmap::CopyHashMap, geometric_decay::GeometricDecay, numcell::NumCell, + on_change::OnChange, opaque_cell::OpaqueCell, + }, + video::{ + Modifier, + dmabuf::DmaBufId, + drm::{ + ConnectorStatus, DrmConnector, DrmCrtc, DrmEncoder, DrmMaster, DrmModeInfo, + DrmObject, DrmPlane, DrmProperty, + }, + gbm::GbmDevice, + }, + }, + ahash::AHashMap, + indexmap::IndexSet, + std::{ + cell::{Cell, RefCell}, + ffi::CString, + fmt::{Debug, Formatter}, + rc::Rc, + }, + uapi::c, +}; + +pub struct PendingDrmDevice { + pub id: DrmDeviceId, + pub devnum: c::dev_t, + pub devnode: CString, +} + +#[derive(Debug)] +pub struct MetalRenderContext { + pub dev_id: DrmDeviceId, + pub gfx: Rc, + pub gbm: Rc, + pub devnode: CString, + pub copy_device: Rc, +} + +pub struct MetalDrmDevice { + pub backend: Rc, + pub id: DrmDeviceId, + pub devnum: c::dev_t, + pub devnode: CString, + pub master: Rc, + pub supports_kms: bool, + pub crtcs: AHashMap>, + pub encoders: AHashMap>, + pub planes: AHashMap>, + pub cursor_width: u64, + pub cursor_height: u64, + pub supports_async_commit: bool, + pub gbm: Rc, + pub handle_events: HandleEvents, + pub ctx: CloneCell>, + pub copy_device: Rc, + pub on_change: OnChange, + pub direct_scanout_enabled: Cell>, + pub is_nvidia: bool, + pub _is_amd: bool, + pub lease_ids: MetalLeaseIds, + pub leases: CopyHashMap, + pub leases_to_break: CopyHashMap, + pub paused: Cell, + pub min_post_commit_margin: Cell, +} + +impl Debug for MetalDrmDevice { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + f.debug_struct("MetalDrmDevice").finish_non_exhaustive() + } +} + +impl MetalDrmDevice { + pub fn is_render_device(&self) -> bool { + if let Some(ctx) = self.backend.ctx.get() { + return ctx.dev_id == self.id; + } + false + } +} + +pub struct HandleEvents { + pub handle_events: Cell>>, +} + +impl Debug for HandleEvents { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + f.debug_struct("HandleEvents").finish_non_exhaustive() + } +} + +#[derive(Debug)] +pub struct MetalDrmDeviceData { + pub dev: Rc, + pub connectors: CopyHashMap>, + pub futures: CopyHashMap, +} + +#[derive(Debug)] +pub struct PersistentDisplayData { + pub state: RefCell, +} + +#[derive(Debug)] +pub struct ConnectorDisplayData { + pub crtc_id: DrmProperty, + pub crtcs: BinarySearchMap, 8>, + pub first_mode: Mode, + pub modes: Vec, + pub persistent: Rc, + pub refresh: u32, + pub non_desktop: bool, + pub non_desktop_effective: bool, + pub vrr_capable: bool, + pub _vrr_refresh_max_nsec: u64, + pub default_properties: Vec, + pub untyped_properties: AHashMap, + + pub connector_id: ConnectorKernelId, + pub output_id: Rc, + + pub connection: ConnectorStatus, + pub mm_width: u32, + pub mm_height: u32, + pub _subpixel: u32, + + pub supports_bt2020: bool, + pub supports_pq: bool, + pub primaries: Primaries, + pub luminance: Option, + + pub colorspace: Option, + pub hdr_metadata: Option, + pub drm_state: DrmConnectorState, +} + +impl ConnectorDisplayData { + fn update_refresh(&mut self, dev: &MetalDrmDevice) { + self.refresh = 0; + if self.drm_state.crtc_id.is_none() { + return; + } + let Some(crtc) = dev.crtcs.get(&self.drm_state.crtc_id) else { + return; + }; + let drm_state = &*crtc.drm_state.borrow(); + let Some(mode) = &drm_state.mode else { + return; + }; + let refresh_rate_mhz = mode.refresh_rate_millihz(); + if refresh_rate_mhz != 0 { + self.refresh = (1_000_000_000_000u64 / refresh_rate_mhz as u64) as u32; + } + } + + fn update_non_desktop_effective(&mut self) { + let state = &*self.persistent.state.borrow(); + self.non_desktop_effective = + !state.enabled || state.non_desktop_override.unwrap_or(self.non_desktop); + } + + pub fn update_cached_fields(&mut self, dev: &MetalDrmDevice) { + self.update_refresh(dev); + self.update_non_desktop_effective(); + } +} + +linear_ids!(MetalLeaseIds, MetalLeaseId, u64); + +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum FrontState { + Removed, + Disconnected, + Connected { non_desktop: bool }, + Unavailable, +} + +pub struct MetalConnector { + pub id: DrmConnector, + pub kernel_id: Cell, + pub master: Rc, + pub state: Rc, + + pub dev: Rc, + pub backend: Rc, + + pub connector_id: ConnectorId, + + pub buffers: CloneCell>>, + pub color_description: CloneCell>, + + pub lease: Cell>, + + pub buffers_idle: Cell, + pub crtc_idle: Cell, + pub has_damage: NumCell, + pub cursor_changed: Cell, + pub cursor_damage: Cell, + pub next_vblank_nsec: Cell, + + pub display: RefCell, + + pub frontend_state: Cell, + + pub primary_plane: CloneCell>>, + pub cursor_plane: CloneCell>>, + + pub crtc: CloneCell>>, + + pub on_change: OnChange, + + pub present_trigger: AsyncEvent, + + pub cursor_x: Cell, + pub cursor_y: Cell, + pub cursor_enabled: Cell, + pub cursor_buffers: CloneCell>>, + pub cursor_swap_buffer: Cell, + pub cursor_sync: CloneCell>, + + pub drm_feedback: CloneCell>>, + pub scanout_buffers: RefCell>, + pub active_framebuffer: RefCell>, + pub next_framebuffer: OpaqueCell>, + pub direct_scanout_active: Cell, + + pub version: NumCell, + pub expected_sequence: Cell>, + pub pre_commit_margin: Cell, + pub pre_commit_margin_decay: GeometricDecay, + pub post_commit_margin: Cell, + pub post_commit_margin_decay: GeometricDecay, + pub vblank_miss_sec: Cell, + pub vblank_miss_this_sec: NumCell, + pub presentation_is_sync: Cell, + pub presentation_is_zero_copy: Cell, +} + +impl Debug for MetalConnector { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + f.debug_struct("MetalConnnector").finish_non_exhaustive() + } +} + +pub struct ConnectorFutures { + pub _present: SpawnedFuture<()>, +} + +impl Debug for ConnectorFutures { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ConnectorFutures").finish_non_exhaustive() + } +} + +pub struct MetalCrtc { + pub id: DrmCrtc, + pub idx: usize, + pub master: Rc, + pub default_properties: Vec, + pub untyped_properties: RefCell>, + + pub lease: Cell>, + + pub possible_planes: BinarySearchMap, 8>, + + pub connector: CloneCell>>, + pub pending_flip: CloneCell>>, + + pub active: DrmProperty, + pub mode_id: DrmProperty, + pub vrr_enabled: DrmProperty, + pub out_fence_ptr: DrmProperty, + pub gamma_lut: Option, + pub gamma_lut_size: Option, + pub drm_state: RefCell, + + pub sequence: Cell, + pub have_queued_sequence: Cell, + pub needs_vblank_emulation: Cell, +} + +impl Debug for MetalCrtc { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + f.debug_struct("MetalCrtc").finish_non_exhaustive() + } +} + +#[derive(Debug)] +pub struct MetalEncoder { + pub id: DrmEncoder, + pub crtcs: AHashMap>, +} + +#[derive(Debug, Copy, Clone, Eq, PartialEq)] +pub enum PlaneType { + Overlay, + Primary, + Cursor, +} + +#[derive(Debug)] +pub struct PlaneFormat { + pub format: &'static Format, + pub modifiers: IndexSet, +} + +pub struct MetalPlane { + pub id: DrmPlane, + pub master: Rc, + pub default_properties: Vec, + pub untyped_properties: RefCell>, + + pub ty: PlaneType, + + pub possible_crtcs: u32, + pub formats: AHashMap, + + pub lease: Cell>, + + pub mode_w: Cell, + pub mode_h: Cell, + + pub crtc_id: DrmProperty, + pub crtc_x: DrmProperty, + pub crtc_y: DrmProperty, + pub crtc_w: DrmProperty, + pub crtc_h: DrmProperty, + pub src_x: DrmProperty, + pub src_y: DrmProperty, + pub src_w: DrmProperty, + pub src_h: DrmProperty, + pub in_fence_fd: DrmProperty, + pub fb_id: DrmProperty, + + pub drm_state: RefCell, +} + +impl Debug for MetalPlane { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + f.debug_struct("MetalPlane").finish_non_exhaustive() + } +}