Skip to content

Commit

Permalink
fix build on windows
Browse files Browse the repository at this point in the history
(windows is not yet supported at runtime regardless)
  • Loading branch information
SludgePhD committed May 28, 2024
1 parent a8178da commit dd16b90
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fev"
version = "0.2.0"
version = "0.2.1"
edition = "2021"
license = "0BSD"
description = "High-level VA-API bindings"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Ferrovanadium: VA-API bindings for Rust
# VA-API bindings for Rust

This library provides high-level wrappers around **VA-API** (*libva*), the
Video Acceleration API used by Linux, Android, and BSD systems.
Expand Down
2 changes: 1 addition & 1 deletion src/dlopen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//!
//! Types used by the bindings are defined throughout the library.
#![allow(bad_style)]
#![allow(bad_style, non_camel_case_types)]

use std::{
os::raw::{c_char, c_float, c_int, c_short, c_uchar, c_uint, c_ulong, c_ushort, c_void},
Expand Down
37 changes: 33 additions & 4 deletions src/surface.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! [`Surface`]s and surface attributes.
#[cfg_attr(docsrs, doc(cfg(target_os = "linux")))]
#[cfg(target_os = "linux")]
pub mod drm;

use core::fmt;
Expand Down Expand Up @@ -62,7 +64,14 @@ bitflags! {
}
}

/// A [`Surface`] attribute.
/// A [`Surface`] attribute can be used to request a specific property or configuration during
/// [`Surface`] creation.
///
/// It can be created [`From`] a [`SurfaceAttribEnum`], or queried from a [`Config`] via
/// [`Config::query_surface_attributes`].
///
/// [`Config`]: crate::config::Config
/// [`Config::query_surface_attributes`]: crate::config::Config::query_surface_attributes
#[derive(Clone, Copy)]
#[repr(C)]
pub struct SurfaceAttrib {
Expand Down Expand Up @@ -318,18 +327,26 @@ bitflags! {
}

/// A graphics surface or texture.
///
/// A [`Surface`] acts as either the input of an encoding operation, or the output of a decoding
/// operation. It can also be used as either the source or target of a VPP operation.
#[derive(Debug)]
pub struct Surface {
d: Arc<DisplayOwner>,
id: VASurfaceID,
}

impl Surface {
/// Creates a [`Surface`] with the given [`RTFormat`].
pub fn new(display: &Display, width: u32, height: u32, format: RTFormat) -> Result<Self> {
log::trace!("creating {width}x{height} surface with {format:?}");
Self::with_attribs(display, width, height, format, &mut [])
}

/// Creates a [`Surface`] with the given [`PixelFormat`].
///
/// This will try to derive a matching [`RTFormat`] automatically via
/// [`PixelFormat::to_rtformat`].
pub fn with_pixel_format(
display: &Display,
width: u32,
Expand All @@ -353,6 +370,8 @@ impl Surface {
)
}

/// Creates a [`Surface`] with the given [`RTFormat`] and a list of [`SurfaceAttrib`]utes to
/// apply.
pub fn with_attribs(
display: &Display,
width: u32,
Expand Down Expand Up @@ -402,6 +421,10 @@ impl Surface {
Ok(())
}

/// Returns the current [`SurfaceStatus`] of this [`Surface`].
///
/// The [`SurfaceStatus`] indicates whether and how the [`Surface`] is currently being used by a
/// VA-API operation.
pub fn status(&self) -> Result<SurfaceStatus> {
let mut status = SurfaceStatus(0);
unsafe {
Expand All @@ -417,9 +440,9 @@ impl Surface {

/// Copies all pixels from `self` to the given [`Image`].
///
/// This calls `vaGetImage`, which may be expensive on some drivers (eg.
/// Intel). If possible, [`SurfaceWithImage`] should be used, so that
/// `vaDeriveImage` is used instead if the driver supports it.
/// This calls `vaGetImage`, which may be expensive on some drivers (eg. Intel). If possible,
/// [`SurfaceWithImage`] should be used, so that `vaDeriveImage` is used instead if the driver
/// supports it.
pub fn copy_to_image(&mut self, image: &mut Image) -> Result<()> {
self.sync()?;

Expand Down Expand Up @@ -519,6 +542,11 @@ impl Surface {
///
/// **Note**: The underlying function, `vaGetSurfaceBufferWl`, is not implemented on Mesa/AMD,
/// so this will always return an error there.
///
/// (also note that the `wl_buffer` type in the documentation is deliberately private; cast it
/// to the desired type to use it)
#[cfg(target_os = "linux")]
#[cfg_attr(docsrs, doc(cfg(target_os = "linux")))]
pub fn wayland_buffer(&self) -> Result<*mut wl_buffer> {
unsafe {
let mut wlbufferptr = MaybeUninit::uninit();
Expand Down Expand Up @@ -636,6 +664,7 @@ impl DerefMut for SurfaceWithImage {
}
}

/// Enumeration of supported [`SurfaceAttrib`]utes.
#[derive(Debug)]
#[non_exhaustive]
pub enum SurfaceAttribEnum {
Expand Down

0 comments on commit dd16b90

Please sign in to comment.