diff --git a/src/backends/metal/video.rs b/src/backends/metal/video.rs index 470f87ca..17290f12 100644 --- a/src/backends/metal/video.rs +++ b/src/backends/metal/video.rs @@ -36,10 +36,12 @@ use { }, }, ahash::{AHashMap, AHashSet}, + arrayvec::ArrayVec, bstr::{BString, ByteSlice}, indexmap::{indexset, IndexSet}, jay_config::video::GfxApi, std::{ + any::Any, cell::{Cell, RefCell}, ffi::CString, fmt::{Debug, Formatter}, @@ -222,7 +224,7 @@ pub struct MetalConnector { pub cursor_x: Cell, pub cursor_y: Cell, pub cursor_enabled: Cell, - pub cursor_buffers: CloneCell>>, + pub cursor_buffers: CloneCell>>, pub cursor_front_buffer: NumCell, pub cursor_swap_buffer: Cell, @@ -241,7 +243,7 @@ pub struct MetalHardwareCursor { pub cursor_enabled_pending: Cell, pub cursor_x_pending: Cell, pub cursor_y_pending: Cell, - pub cursor_buffers: Rc<[RenderBuffer; 2]>, + pub cursor_buffers: Rc<[RenderBuffer; 3]>, pub have_changes: Cell, } @@ -253,7 +255,7 @@ impl HardwareCursor for MetalHardwareCursor { } fn get_buffer(&self) -> Rc { - let buffer = (self.connector.cursor_front_buffer.get() + 1) % 2; + let buffer = (self.connector.cursor_front_buffer.get() + 1) % self.cursor_buffers.len(); self.cursor_buffers[buffer].render_fb() } @@ -2090,7 +2092,7 @@ impl MetalBackend { true } - fn create_scanout_buffers( + fn create_scanout_buffers( &self, dev: &Rc, format: &Format, @@ -2099,10 +2101,14 @@ impl MetalBackend { height: i32, ctx: &MetalRenderContext, cursor: bool, - ) -> Result<[RenderBuffer; 2], MetalError> { + ) -> Result<[RenderBuffer; N], MetalError> { let create = || self.create_scanout_buffer(dev, format, plane_modifiers, width, height, ctx, cursor); - Ok([create()?, create()?]) + let mut array = ArrayVec::<_, N>::new(); + for _ in 0..N { + array.push(create()?); + } + Ok(array.into_inner().unwrap()) } fn create_scanout_buffer( @@ -2279,7 +2285,7 @@ impl MetalBackend { connector: &Rc, changes: &mut Change, ctx: &MetalRenderContext, - old_buffers: &mut Vec>, + old_buffers: &mut Vec>, ) -> Result<(), MetalError> { let dd = connector.display.borrow_mut(); let crtc = match connector.crtc.get() {