1
0
Fork 0
forked from wry/wry

backend: add getters

This commit is contained in:
Julian Orth 2026-03-07 11:46:32 +01:00
parent 042070ee99
commit acec4c7f09
3 changed files with 19 additions and 9 deletions

View file

@ -540,6 +540,9 @@ pub trait BackendDrmDevice {
fn version(&self) -> Result<DrmVersion, DrmError>; fn version(&self) -> Result<DrmVersion, DrmError>;
fn set_direct_scanout_enabled(&self, enabled: bool); fn set_direct_scanout_enabled(&self, enabled: bool);
fn is_render_device(&self) -> bool; fn is_render_device(&self) -> bool;
fn direct_scanout_enabled(&self) -> bool {
false
}
fn create_lease( fn create_lease(
self: Rc<Self>, self: Rc<Self>,
lessee: Rc<dyn BackendDrmLessee>, lessee: Rc<dyn BackendDrmLessee>,
@ -551,6 +554,10 @@ pub trait BackendDrmDevice {
fn set_flip_margin(&self, margin: u64) { fn set_flip_margin(&self, margin: u64) {
let _ = margin; let _ = margin;
} }
#[expect(dead_code)]
fn flip_margin(&self) -> Option<u64> {
None
}
} }
pub trait BackendDrmLease { pub trait BackendDrmLease {

View file

@ -1,6 +1,6 @@
use { use {
crate::{ crate::{
backend::Connector, backend::{BackendDrmDevice, Connector},
backends::metal::{ backends::metal::{
MetalError, MetalError,
allocator::{RenderBuffer, RenderBufferCopy}, allocator::{RenderBuffer, RenderBufferCopy},
@ -814,13 +814,6 @@ impl MetalConnector {
data data
} }
fn direct_scanout_enabled(&self) -> bool {
self.dev
.direct_scanout_enabled
.get()
.unwrap_or(self.state.direct_scanout_enabled.get())
}
fn prepare_present_fb( fn prepare_present_fb(
&self, &self,
cd: &Rc<ColorDescription>, cd: &Rc<ColorDescription>,
@ -832,7 +825,7 @@ impl MetalConnector {
) -> Result<PresentFb, MetalError> { ) -> Result<PresentFb, MetalError> {
self.trim_scanout_cache(); self.trim_scanout_cache();
let try_direct_scanout = try_direct_scanout let try_direct_scanout = try_direct_scanout
&& self.direct_scanout_enabled() && self.dev.direct_scanout_enabled()
// at least on AMD, using a FB on a different device for rendering will fail // at least on AMD, using a FB on a different device for rendering will fail
// and destroy the render context. it's possible to work around this by waiting // and destroy the render context. it's possible to work around this by waiting
// until the FB is no longer being scanned out, but if a notification pops up // until the FB is no longer being scanned out, but if a notification pops up

View file

@ -186,6 +186,12 @@ impl BackendDrmDevice for MetalDrmDevice {
Some(self.id) == self.backend.ctx.get().map(|c| c.dev_id) Some(self.id) == self.backend.ctx.get().map(|c| c.dev_id)
} }
fn direct_scanout_enabled(&self) -> bool {
self.direct_scanout_enabled
.get()
.unwrap_or(self.backend.state.direct_scanout_enabled.get())
}
fn create_lease( fn create_lease(
self: Rc<Self>, self: Rc<Self>,
lessee: Rc<dyn BackendDrmLessee>, lessee: Rc<dyn BackendDrmLessee>,
@ -314,6 +320,10 @@ impl BackendDrmDevice for MetalDrmDevice {
} }
} }
} }
fn flip_margin(&self) -> Option<u64> {
Some(self.min_post_commit_margin.get())
}
} }
pub struct HandleEvents { pub struct HandleEvents {