From 0bcdea659a2f1df7861da3172da19688f56569e6 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 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/device.rs b/src/device.rs index 8fb4b52..8bbefef 100644 --- a/src/device.rs +++ b/src/device.rs @@ -103,6 +103,23 @@ 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,