mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2025-04-16 04:44:06 +00:00
vulkan: Manually implement CommandBuffer, DescriptorSet and ImageView
These are all GStreamer miniobjects.
This commit is contained in:
parent
8c2c2edb70
commit
56fde2d869
5 changed files with 201 additions and 3 deletions
|
@ -61,14 +61,12 @@ generate = [
|
|||
# "GstVulkan.VulkanBufferMemoryAllocatorClass",
|
||||
# "GstVulkan.VulkanBufferPoolClass",
|
||||
# "GstVulkan.VulkanBufferPoolPrivate",
|
||||
"GstVulkan.VulkanCommandBuffer",
|
||||
# "GstVulkan.VulkanCommandPoolClass",
|
||||
# "GstVulkan.VulkanCommandPoolPrivate",
|
||||
# "GstVulkan.VulkanDescriptorCacheClass",
|
||||
# "GstVulkan.VulkanDescriptorCachePrivate",
|
||||
# "GstVulkan.VulkanDescriptorPoolClass",
|
||||
# "GstVulkan.VulkanDescriptorPoolPrivate",
|
||||
"GstVulkan.VulkanDescriptorSet",
|
||||
# "GstVulkan.VulkanDeviceClass",
|
||||
# "GstVulkan.VulkanDevicePrivate",
|
||||
# "GstVulkan.VulkanDisplayClass",
|
||||
|
@ -85,7 +83,6 @@ generate = [
|
|||
# "GstVulkan.VulkanImageBufferPoolClass",
|
||||
# "GstVulkan.VulkanImageBufferPoolPrivate",
|
||||
# "GstVulkan.VulkanImageMemoryAllocatorClass",
|
||||
"GstVulkan.VulkanImageView",
|
||||
# "GstVulkan.VulkanInstanceClass",
|
||||
# "GstVulkan.VulkanInstancePrivate",
|
||||
# "GstVulkan.VulkanMemoryAllocatorClass",
|
||||
|
@ -129,7 +126,10 @@ manual = [
|
|||
"GstVideo.VideoInfo",
|
||||
"GstVideo.VideoRectangle",
|
||||
"GstVulkan.VulkanBufferMemory",
|
||||
"GstVulkan.VulkanCommandBuffer",
|
||||
"GstVulkan.VulkanDescriptorSet",
|
||||
"GstVulkan.VulkanImageMemory",
|
||||
"GstVulkan.VulkanImageView",
|
||||
"GstVulkan.VulkanMemory",
|
||||
]
|
||||
|
||||
|
|
|
@ -38,10 +38,16 @@ mod context;
|
|||
pub use crate::context::*;
|
||||
mod vulkan_buffer_memory;
|
||||
pub use crate::vulkan_buffer_memory::*;
|
||||
mod vulkan_command_buffer;
|
||||
pub use crate::vulkan_command_buffer::*;
|
||||
mod vulkan_descriptor_set;
|
||||
pub use crate::vulkan_descriptor_set::*;
|
||||
mod vulkan_handle;
|
||||
pub use crate::vulkan_handle::*;
|
||||
mod vulkan_image_memory;
|
||||
pub use crate::vulkan_image_memory::*;
|
||||
mod vulkan_image_view;
|
||||
pub use crate::vulkan_image_view::*;
|
||||
mod vulkan_memory;
|
||||
pub use crate::vulkan_memory::*;
|
||||
mod vulkan_swapper;
|
||||
|
|
53
gstreamer-vulkan/src/vulkan_command_buffer.rs
Normal file
53
gstreamer-vulkan/src/vulkan_command_buffer.rs
Normal file
|
@ -0,0 +1,53 @@
|
|||
// Take a look at the license at the top of the repository in the LICENSE file.
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use glib::translate::*;
|
||||
|
||||
use crate::ffi;
|
||||
|
||||
gst::mini_object_wrapper!(
|
||||
VulkanCommandBuffer,
|
||||
VulkanCommandBufferRef,
|
||||
ffi::GstVulkanCommandBuffer,
|
||||
|| ffi::gst_vulkan_command_buffer_get_type()
|
||||
);
|
||||
|
||||
impl fmt::Debug for VulkanCommandBuffer {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
VulkanCommandBufferRef::fmt(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for VulkanCommandBufferRef {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("VulkanCommandBuffer")
|
||||
.field("inner", &self.0)
|
||||
.finish()
|
||||
|
||||
// .finish_non_exhaustive()
|
||||
}
|
||||
}
|
||||
|
||||
impl VulkanCommandBuffer {
|
||||
#[doc(alias = "gst_vulkan_command_buffer_new_wrapped")]
|
||||
pub fn new_wrapped(
|
||||
cmd: vulkan::CommandBuffer,
|
||||
level: vulkan::CommandBufferLevel,
|
||||
) -> VulkanCommandBuffer {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe { from_glib_full(ffi::gst_vulkan_command_buffer_new_wrapped(cmd, level)) }
|
||||
}
|
||||
}
|
||||
|
||||
impl VulkanCommandBufferRef {
|
||||
pub fn cmd(&self) -> vulkan::CommandBuffer {
|
||||
self.0.cmd
|
||||
}
|
||||
|
||||
// TODO: pool getter
|
||||
|
||||
pub fn level(&self) -> vulkan::CommandBufferLevel {
|
||||
self.0.level
|
||||
}
|
||||
}
|
74
gstreamer-vulkan/src/vulkan_descriptor_set.rs
Normal file
74
gstreamer-vulkan/src/vulkan_descriptor_set.rs
Normal file
|
@ -0,0 +1,74 @@
|
|||
// Take a look at the license at the top of the repository in the LICENSE file.
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use glib::{prelude::*, translate::*};
|
||||
|
||||
use crate::{ffi, VulkanDescriptorCache, VulkanDescriptorPool, VulkanHandle};
|
||||
|
||||
gst::mini_object_wrapper!(
|
||||
VulkanDescriptorSet,
|
||||
VulkanDescriptorSetRef,
|
||||
ffi::GstVulkanDescriptorSet,
|
||||
|| ffi::gst_vulkan_descriptor_set_get_type()
|
||||
);
|
||||
|
||||
impl fmt::Debug for VulkanDescriptorSet {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
VulkanDescriptorSetRef::fmt(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for VulkanDescriptorSetRef {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("VulkanDescriptorSet")
|
||||
.field("set", &self.set())
|
||||
.field("set", &self.set())
|
||||
.field("pool", &unsafe { self.pool() })
|
||||
.field("cache", &unsafe { self.cache() })
|
||||
.field("layouts", &unsafe { self.layouts() })
|
||||
.finish_non_exhaustive()
|
||||
}
|
||||
}
|
||||
|
||||
impl VulkanDescriptorSet {
|
||||
#[doc(alias = "gst_vulkan_descriptor_set_new_wrapped")]
|
||||
pub fn new_wrapped(
|
||||
pool: &impl IsA<VulkanDescriptorPool>,
|
||||
set: vulkan::DescriptorSet,
|
||||
layouts: &[&VulkanHandle],
|
||||
) -> VulkanDescriptorSet {
|
||||
skip_assert_initialized!();
|
||||
let n_layouts = layouts.len() as _;
|
||||
unsafe {
|
||||
from_glib_full(ffi::gst_vulkan_descriptor_set_new_wrapped(
|
||||
pool.as_ref().to_glib_none().0,
|
||||
set,
|
||||
n_layouts,
|
||||
layouts.to_glib_none().0,
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl VulkanDescriptorSetRef {
|
||||
pub fn set(&self) -> vulkan::DescriptorSet {
|
||||
self.0.set
|
||||
}
|
||||
|
||||
pub unsafe fn pool(&self) -> VulkanDescriptorPool {
|
||||
// from_glib_borrow(self.0.pool)
|
||||
from_glib_none(self.0.pool)
|
||||
}
|
||||
|
||||
pub unsafe fn cache(&self) -> VulkanDescriptorCache {
|
||||
// from_glib_borrow(self.0.cache)
|
||||
from_glib_none(self.0.cache)
|
||||
}
|
||||
|
||||
pub unsafe fn layouts(&self) -> &[*mut ffi::GstVulkanHandle] {
|
||||
let layouts = std::slice::from_raw_parts(self.0.layouts, self.0.n_layouts as usize);
|
||||
// from_glib_none(layouts)
|
||||
layouts
|
||||
}
|
||||
}
|
65
gstreamer-vulkan/src/vulkan_image_view.rs
Normal file
65
gstreamer-vulkan/src/vulkan_image_view.rs
Normal file
|
@ -0,0 +1,65 @@
|
|||
// Take a look at the license at the top of the repository in the LICENSE file.
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use glib::translate::*;
|
||||
|
||||
use crate::{ffi, VulkanDevice, VulkanImageMemory};
|
||||
|
||||
gst::mini_object_wrapper!(
|
||||
VulkanImageView,
|
||||
VulkanImageViewRef,
|
||||
ffi::GstVulkanImageView,
|
||||
|| ffi::gst_vulkan_image_view_get_type()
|
||||
);
|
||||
|
||||
impl fmt::Debug for VulkanImageView {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
VulkanImageViewRef::fmt(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for VulkanImageViewRef {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("VulkanImageView")
|
||||
.field("device", &unsafe { self.device() })
|
||||
.field("image", &unsafe { self.image() })
|
||||
.field("view", &self.view())
|
||||
.field("create_info", &self.create_info())
|
||||
.finish_non_exhaustive()
|
||||
}
|
||||
}
|
||||
|
||||
impl VulkanImageView {
|
||||
#[doc(alias = "gst_vulkan_image_view_new")]
|
||||
// TODO: Mut?
|
||||
pub fn new(image: &mut VulkanImageMemory, create_info: &vulkan::ImageViewCreateInfo) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
from_glib_full(ffi::gst_vulkan_image_view_new(
|
||||
image.to_glib_none_mut().0,
|
||||
create_info,
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl VulkanImageViewRef {
|
||||
pub unsafe fn device(&self) -> VulkanDevice {
|
||||
// from_glib_borrow(self.0.device)
|
||||
from_glib_none(self.0.device)
|
||||
}
|
||||
|
||||
pub unsafe fn image(&self) -> VulkanImageMemory {
|
||||
// from_glib_borrow(self.0.image)
|
||||
from_glib_none(self.0.image)
|
||||
}
|
||||
|
||||
pub fn view(&self) -> vulkan::ImageView {
|
||||
self.0.view
|
||||
}
|
||||
|
||||
pub fn create_info(&self) -> &vulkan::ImageViewCreateInfo {
|
||||
&self.0.create_info
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue