Skip to content

Commit

Permalink
extensions/khr: add VK_KHR_video_queue
Browse files Browse the repository at this point in the history
  • Loading branch information
colinmarc committed Nov 30, 2024
1 parent 078b7d3 commit ca9e4de
Show file tree
Hide file tree
Showing 2 changed files with 183 additions and 0 deletions.
1 change: 1 addition & 0 deletions ash/src/extensions/khr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
182 changes: 182 additions & 0 deletions ash/src/extensions/khr/video_queue.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_video_queue.html>
use crate::prelude::*;
use crate::vk;
use crate::RawPtr as _;
use core::mem;

impl crate::khr::video_queue::Device {
#[inline]
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkBindVideoSessionMemoryKHR.html>
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]
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdBeginVideoCodingKHR.html>
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]
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdControlVideoCodingKHR.html>
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]
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdEndVideoCodingKHR.html>
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]
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCreateVideoSessionKHR.html>
pub unsafe fn create_video_session(
&self,
create_info: &vk::VideoSessionCreateInfoKHR<'_>,
allocation_callbacks: Option<&vk::AllocationCallbacks<'_>>,
) -> VkResult<vk::VideoSessionKHR> {
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]
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCreateVideoSessionParametersKHR.html>
pub unsafe fn create_video_session_parameters(
&self,
create_info: &vk::VideoSessionParametersCreateInfoKHR<'_>,
allocation_callbacks: Option<&vk::AllocationCallbacks<'_>>,
) -> VkResult<vk::VideoSessionParametersKHR> {
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]
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkDestroyVideoSessionKHR.html>
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]
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkDestroyVideoSessionParametersKHR.html>
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]
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetVideoSessionMemoryRequirementsKHR.html>
pub unsafe fn get_video_session_memory_requirements(
&self,
video_session: vk::VideoSessionKHR,
) -> VkResult<Vec<vk::VideoSessionMemoryRequirementsKHR<'_>>> {
read_into_defaulted_vector(|count, data| {
(self.fp.get_video_session_memory_requirements_khr)(
self.handle,
video_session,
count,
data,
)
})
}

#[inline]
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkUpdateVideoSessionParametersKHR.html>
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]
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceVideoCapabilitiesKHR.html>
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]
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceVideoFormatPropertiesKHR.html>
pub unsafe fn get_physical_device_video_format_properties(
&self,
physical_device: vk::PhysicalDevice,
video_format_info: &vk::PhysicalDeviceVideoFormatInfoKHR<'_>,
) -> VkResult<Vec<vk::VideoFormatPropertiesKHR<'_>>> {
read_into_defaulted_vector(|count, data| {
(self.fp.get_physical_device_video_format_properties_khr)(
physical_device,
video_format_info,
count,
data,
)
})
}
}

0 comments on commit ca9e4de

Please sign in to comment.