diff --git a/ash/src/extensions/khr/mod.rs b/ash/src/extensions/khr/mod.rs index cd15e02e..437e45f2 100644 --- a/ash/src/extensions/khr/mod.rs +++ b/ash/src/extensions/khr/mod.rs @@ -40,6 +40,7 @@ pub mod surface; pub mod swapchain; pub mod synchronization2; pub mod timeline_semaphore; +pub mod video_queue; pub mod wayland_surface; pub mod win32_surface; pub mod xcb_surface; diff --git a/ash/src/extensions/khr/video_queue.rs b/ash/src/extensions/khr/video_queue.rs new file mode 100644 index 00000000..a3be16c6 --- /dev/null +++ b/ash/src/extensions/khr/video_queue.rs @@ -0,0 +1,182 @@ +//! + +use crate::prelude::*; +use crate::vk; +use crate::RawPtr as _; +use core::mem; + +impl crate::khr::video_queue::Device { + #[inline] + /// + pub unsafe fn bind_video_session_memory( + &self, + video_session: vk::VideoSessionKHR, + bind_session_memory_infos: &[vk::BindVideoSessionMemoryInfoKHR<'_>], + ) -> VkResult<()> { + (self.fp.bind_video_session_memory_khr)( + self.handle, + video_session, + bind_session_memory_infos.len() as u32, + bind_session_memory_infos.as_ptr(), + ) + .result() + } + + #[inline] + /// + pub unsafe fn cmd_begin_video_coding( + &self, + command_buffer: vk::CommandBuffer, + begin_info: &vk::VideoBeginCodingInfoKHR<'_>, + ) { + (self.fp.cmd_begin_video_coding_khr)(command_buffer, begin_info); + } + + #[inline] + /// + pub unsafe fn cmd_control_video_coding( + &self, + command_buffer: vk::CommandBuffer, + coding_control_info: &vk::VideoCodingControlInfoKHR<'_>, + ) { + (self.fp.cmd_control_video_coding_khr)(command_buffer, coding_control_info); + } + + #[inline] + /// + pub unsafe fn cmd_end_video_coding( + &self, + command_buffer: vk::CommandBuffer, + end_coding_info: &vk::VideoEndCodingInfoKHR<'_>, + ) { + (self.fp.cmd_end_video_coding_khr)(command_buffer, end_coding_info); + } + + #[inline] + /// + pub unsafe fn create_video_session( + &self, + create_info: &vk::VideoSessionCreateInfoKHR<'_>, + allocation_callbacks: Option<&vk::AllocationCallbacks<'_>>, + ) -> VkResult { + let mut video_session = mem::zeroed(); + (self.fp.create_video_session_khr)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut video_session, + ) + .result_with_success(video_session) + } + + #[inline] + /// + pub unsafe fn create_video_session_parameters( + &self, + create_info: &vk::VideoSessionParametersCreateInfoKHR<'_>, + allocation_callbacks: Option<&vk::AllocationCallbacks<'_>>, + ) -> VkResult { + let mut video_session_parameters = mem::zeroed(); + (self.fp.create_video_session_parameters_khr)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut video_session_parameters, + ) + .result_with_success(video_session_parameters) + } + + #[inline] + /// + pub unsafe fn destroy_video_session( + &self, + video_session: vk::VideoSessionKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks<'_>>, + ) { + (self.fp.destroy_video_session_khr)( + self.handle, + video_session, + allocation_callbacks.as_raw_ptr(), + ); + } + + #[inline] + /// + pub unsafe fn destroy_video_session_parameters( + &self, + video_session_parameters: vk::VideoSessionParametersKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks<'_>>, + ) { + (self.fp.destroy_video_session_parameters_khr)( + self.handle, + video_session_parameters, + allocation_callbacks.as_raw_ptr(), + ); + } + + #[inline] + /// + pub unsafe fn get_video_session_memory_requirements( + &self, + video_session: vk::VideoSessionKHR, + ) -> VkResult>> { + read_into_defaulted_vector(|count, data| { + (self.fp.get_video_session_memory_requirements_khr)( + self.handle, + video_session, + count, + data, + ) + }) + } + + #[inline] + /// + pub unsafe fn update_video_session_parameters( + &self, + video_session_parameters: vk::VideoSessionParametersKHR, + update_info: &vk::VideoSessionParametersUpdateInfoKHR<'_>, + ) -> VkResult<()> { + (self.fp.update_video_session_parameters_khr)( + self.handle, + video_session_parameters, + update_info, + ) + .result() + } +} + +impl crate::khr::video_queue::Instance { + #[inline] + /// + pub unsafe fn get_physical_device_video_capabilities( + &self, + physical_device: vk::PhysicalDevice, + video_profile: &vk::VideoProfileInfoKHR<'_>, + capabilities: &mut vk::VideoCapabilitiesKHR<'_>, + ) -> VkResult<()> { + (self.fp.get_physical_device_video_capabilities_khr)( + physical_device, + video_profile, + capabilities, + ) + .result() + } + + #[inline] + /// + pub unsafe fn get_physical_device_video_format_properties( + &self, + physical_device: vk::PhysicalDevice, + video_format_info: &vk::PhysicalDeviceVideoFormatInfoKHR<'_>, + ) -> VkResult>> { + read_into_defaulted_vector(|count, data| { + (self.fp.get_physical_device_video_format_properties_khr)( + physical_device, + video_format_info, + count, + data, + ) + }) + } +}