Skip to content

Commit

Permalink
Add wrapper for gbm_device_get_format_modifier_plane_count
Browse files Browse the repository at this point in the history
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...
  • Loading branch information
ids1024 committed Feb 5, 2024
1 parent 18eb2b7 commit 67bb0e8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,22 @@ impl<T: AsFd> Device<T> {
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<u32, ()> {
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<U: 'static>(
&self,
Expand Down

0 comments on commit 67bb0e8

Please sign in to comment.