From 67bb0e8d26a6c2a9dfbebbda575153c3ae8cc637 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Mon, 5 Feb 2024 13:32:20 -0800 Subject: [PATCH] Add wrapper for `gbm_device_get_format_modifier_plane_count` I'm not sure what to do about the error type here. `gbm_dri_get_format_modifier_plane_count` does potentially return -1, but doesn't set `errno`. Error handling generally looks like it could use some fixes in both gbm.rs and in Mesa... --- src/device.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/device.rs b/src/device.rs index 8fb4b52..2825ab0 100644 --- a/src/device.rs +++ b/src/device.rs @@ -103,6 +103,22 @@ impl Device { unsafe { ffi::gbm_device_is_format_supported(*self.ffi, format as u32, usage.bits()) != 0 } } + /// Get the required number of planes for a given format and modifier + pub fn format_modifier_plane_count( + &self, + format: Format, + modifier: Modifier, + ) -> Result { + unsafe { + ffi::gbm_device_get_format_modifier_plane_count( + *self.ffi, + format as u32, + modifier.into(), + ) + .try_into().map_err(|_| ()) + } + } + /// Allocate a new surface object pub fn create_surface( &self,