mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2025-04-16 04:44:06 +00:00
vulkan: Implement BufferPoolConfig
extensions
This commit is contained in:
parent
56fde2d869
commit
765aebd395
3 changed files with 189 additions and 3 deletions
|
@ -23,7 +23,6 @@ external_libraries = [
|
|||
generate = [
|
||||
# Classes
|
||||
"GstVulkan.VulkanBufferMemoryAllocator",
|
||||
"GstVulkan.VulkanBufferPool",
|
||||
"GstVulkan.VulkanCommandPool",
|
||||
"GstVulkan.VulkanDescriptorCache",
|
||||
"GstVulkan.VulkanDescriptorPool",
|
||||
|
@ -32,7 +31,6 @@ generate = [
|
|||
"GstVulkan.VulkanFenceCache",
|
||||
"GstVulkan.VulkanFullScreenQuad",
|
||||
"GstVulkan.VulkanHandlePool",
|
||||
"GstVulkan.VulkanImageBufferPool",
|
||||
"GstVulkan.VulkanImageMemoryAllocator",
|
||||
"GstVulkan.VulkanInstance",
|
||||
"GstVulkan.VulkanMemoryAllocator",
|
||||
|
@ -169,3 +167,19 @@ manual_traits = ["VulkanSwapperExtManual"]
|
|||
# Function returns optional values in arguments
|
||||
# (Caller should specify what it wishes to retrieve)
|
||||
manual = true
|
||||
|
||||
[[object]]
|
||||
name = "GstVulkan.VulkanBufferPool"
|
||||
status = "generate"
|
||||
[[object.function]]
|
||||
pattern = "config_.*"
|
||||
# Implemented as extension on gst::BufferPoolConfigRef
|
||||
manual = true
|
||||
|
||||
[[object]]
|
||||
name = "GstVulkan.VulkanImageBufferPool"
|
||||
status = "generate"
|
||||
[[object.function]]
|
||||
pattern = "config_.*"
|
||||
# Implemented as extension on gst::BufferPoolConfigRef
|
||||
manual = true
|
||||
|
|
167
gstreamer-vulkan/src/buffer_pool_config.rs
Normal file
167
gstreamer-vulkan/src/buffer_pool_config.rs
Normal file
|
@ -0,0 +1,167 @@
|
|||
#[cfg(feature = "v1_24")]
|
||||
use glib::translate::*;
|
||||
use gst::BufferPoolConfigRef;
|
||||
|
||||
#[cfg(feature = "v1_24")]
|
||||
use crate::ffi;
|
||||
|
||||
/// Configuration for [`super::VulkanBufferPool`]
|
||||
pub trait VulkanBufferPoolConfig {
|
||||
#[cfg(feature = "v1_24")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
|
||||
#[doc(alias = "gst_vulkan_buffer_pool_config_set_allocation_params")]
|
||||
#[doc(alias = "config_set_allocation_params")]
|
||||
fn set_allocation_params(
|
||||
&mut self,
|
||||
usage: vulkan::BufferUsageFlags,
|
||||
mem_properties: vulkan::MemoryPropertyFlags,
|
||||
);
|
||||
}
|
||||
|
||||
impl VulkanBufferPoolConfig for BufferPoolConfigRef {
|
||||
#[cfg(feature = "v1_24")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
|
||||
#[doc(alias = "gst_vulkan_buffer_pool_config_set_allocation_params")]
|
||||
#[doc(alias = "config_set_allocation_params")]
|
||||
fn set_allocation_params(
|
||||
&mut self,
|
||||
usage: vulkan::BufferUsageFlags,
|
||||
mem_properties: vulkan::MemoryPropertyFlags,
|
||||
) {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
ffi::gst_vulkan_buffer_pool_config_set_allocation_params(
|
||||
self.as_mut_ptr(),
|
||||
usage,
|
||||
mem_properties,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Configuration for [`super::VulkanImageBufferPool`]
|
||||
pub trait VulkanImageBufferPoolConfig {
|
||||
#[cfg(feature = "v1_26")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
|
||||
#[doc(alias = "gst_vulkan_image_buffer_pool_config_get_allocation_params")]
|
||||
#[doc(alias = "config_get_allocation_params")]
|
||||
fn get_allocation_params(
|
||||
&self,
|
||||
) -> (
|
||||
vulkan::ImageUsageFlags,
|
||||
vulkan::MemoryPropertyFlags,
|
||||
vulkan::ImageLayout,
|
||||
u64,
|
||||
);
|
||||
|
||||
#[cfg(feature = "v1_24")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
|
||||
#[doc(alias = "gst_vulkan_image_buffer_pool_config_set_allocation_params")]
|
||||
#[doc(alias = "config_set_allocation_params")]
|
||||
fn set_allocation_params(
|
||||
&mut self,
|
||||
usage: vulkan::ImageUsageFlags,
|
||||
mem_properties: vulkan::MemoryPropertyFlags,
|
||||
initial_layout: vulkan::ImageLayout,
|
||||
initial_access: u64,
|
||||
);
|
||||
#[cfg(feature = "v1_24")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
|
||||
#[doc(alias = "gst_vulkan_image_buffer_pool_config_set_decode_caps")]
|
||||
#[doc(alias = "config_set_decode_caps")]
|
||||
fn set_decode_caps(&mut self, caps: &gst::Caps);
|
||||
|
||||
#[cfg(feature = "v1_26")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
|
||||
#[doc(alias = "gst_vulkan_image_buffer_pool_config_set_encode_caps")]
|
||||
#[doc(alias = "config_set_encode_caps")]
|
||||
fn set_encode_caps(&mut self, caps: &gst::Caps);
|
||||
}
|
||||
|
||||
impl VulkanImageBufferPoolConfig for BufferPoolConfigRef {
|
||||
#[cfg(feature = "v1_26")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
|
||||
#[doc(alias = "gst_vulkan_image_buffer_pool_config_get_allocation_params")]
|
||||
#[doc(alias = "config_get_allocation_params")]
|
||||
fn get_allocation_params(
|
||||
&self,
|
||||
) -> (
|
||||
vulkan::ImageUsageFlags,
|
||||
vulkan::MemoryPropertyFlags,
|
||||
vulkan::ImageLayout,
|
||||
u64,
|
||||
) {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
let mut usage = std::mem::MaybeUninit::uninit();
|
||||
let mut mem_props = std::mem::MaybeUninit::uninit();
|
||||
let mut initial_layout = std::mem::MaybeUninit::uninit();
|
||||
let mut initial_access = std::mem::MaybeUninit::uninit();
|
||||
ffi::gst_vulkan_image_buffer_pool_config_get_allocation_params(
|
||||
// TODO: Mut ptr?
|
||||
self.as_mut_ptr(),
|
||||
usage.as_mut_ptr(),
|
||||
mem_props.as_mut_ptr(),
|
||||
initial_layout.as_mut_ptr(),
|
||||
initial_access.as_mut_ptr(),
|
||||
);
|
||||
(
|
||||
usage.assume_init(),
|
||||
mem_props.assume_init(),
|
||||
initial_layout.assume_init(),
|
||||
initial_access.assume_init(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "v1_24")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
|
||||
#[doc(alias = "gst_vulkan_image_buffer_pool_config_set_allocation_params")]
|
||||
#[doc(alias = "config_set_allocation_params")]
|
||||
fn set_allocation_params(
|
||||
&mut self,
|
||||
usage: vulkan::ImageUsageFlags,
|
||||
mem_properties: vulkan::MemoryPropertyFlags,
|
||||
initial_layout: vulkan::ImageLayout,
|
||||
initial_access: u64,
|
||||
) {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
ffi::gst_vulkan_image_buffer_pool_config_set_allocation_params(
|
||||
self.as_mut_ptr(),
|
||||
usage,
|
||||
mem_properties,
|
||||
initial_layout,
|
||||
initial_access,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "v1_24")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
|
||||
#[doc(alias = "gst_vulkan_image_buffer_pool_config_set_decode_caps")]
|
||||
#[doc(alias = "config_set_decode_caps")]
|
||||
fn set_decode_caps(&mut self, caps: &gst::Caps) {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
ffi::gst_vulkan_image_buffer_pool_config_set_decode_caps(
|
||||
self.as_mut_ptr(),
|
||||
caps.to_glib_none().0,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "v1_26")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
|
||||
#[doc(alias = "gst_vulkan_image_buffer_pool_config_set_encode_caps")]
|
||||
#[doc(alias = "config_set_encode_caps")]
|
||||
fn set_encode_caps(&mut self, caps: &gst::Caps) {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
ffi::gst_vulkan_image_buffer_pool_config_set_encode_caps(
|
||||
self.as_mut_ptr(),
|
||||
caps.to_glib_none().0,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -32,6 +32,8 @@ macro_rules! skip_assert_initialized {
|
|||
mod auto;
|
||||
pub use crate::auto::*;
|
||||
|
||||
mod buffer_pool_config;
|
||||
pub use crate::buffer_pool_config::*;
|
||||
mod caps_features;
|
||||
pub use crate::caps_features::*;
|
||||
mod context;
|
||||
|
@ -63,7 +65,10 @@ pub mod prelude {
|
|||
pub use gst_video::prelude::*;
|
||||
|
||||
pub use crate::{
|
||||
auto::traits::*, context::ContextVulkanExt, vulkan_swapper::VulkanSwapperExtManual,
|
||||
auto::traits::*,
|
||||
buffer_pool_config::{VulkanBufferPoolConfig, VulkanImageBufferPoolConfig},
|
||||
context::ContextVulkanExt,
|
||||
vulkan_swapper::VulkanSwapperExtManual,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue