|
| 1 | +//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_video_queue.html> |
| 2 | +
|
| 3 | +use crate::prelude::*; |
| 4 | +use crate::vk; |
| 5 | +use crate::RawPtr; |
| 6 | +use core::mem; |
| 7 | +use core::ptr; |
| 8 | + |
| 9 | +impl crate::khr::video_queue::Device { |
| 10 | + /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkBindVideoSessionMemoryKHR.html> |
| 11 | + #[inline] |
| 12 | + #[doc(alias = "vkBindVideoSessionMemoryKHR")] |
| 13 | + pub unsafe fn bind_video_session_memory( |
| 14 | + &self, |
| 15 | + video_session: vk::VideoSessionKHR, |
| 16 | + bind_session_memory_infos: &[vk::BindVideoSessionMemoryInfoKHR<'_>], |
| 17 | + ) -> VkResult<()> { |
| 18 | + (self.fp.bind_video_session_memory_khr)( |
| 19 | + self.handle, |
| 20 | + video_session, |
| 21 | + bind_session_memory_infos.len() as u32, |
| 22 | + bind_session_memory_infos.as_ptr(), |
| 23 | + ) |
| 24 | + .result() |
| 25 | + } |
| 26 | + |
| 27 | + /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdBeginVideoCodingKHR.html> |
| 28 | + #[inline] |
| 29 | + #[doc(alias = "vkCmdBeginVideoCodingKHR")] |
| 30 | + pub unsafe fn cmd_begin_video_coding( |
| 31 | + &self, |
| 32 | + command_buffer: vk::CommandBuffer, |
| 33 | + begin_info: &vk::VideoBeginCodingInfoKHR<'_>, |
| 34 | + ) { |
| 35 | + (self.fp.cmd_begin_video_coding_khr)(command_buffer, begin_info) |
| 36 | + } |
| 37 | + |
| 38 | + /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdControlVideoCodingKHR.html> |
| 39 | + #[inline] |
| 40 | + #[doc(alias = "vkCmdControlVideoCodingKHR")] |
| 41 | + pub unsafe fn cmd_control_video_coding( |
| 42 | + &self, |
| 43 | + command_buffer: vk::CommandBuffer, |
| 44 | + coding_control_info: &vk::VideoCodingControlInfoKHR<'_>, |
| 45 | + ) { |
| 46 | + (self.fp.cmd_control_video_coding_khr)(command_buffer, coding_control_info) |
| 47 | + } |
| 48 | + |
| 49 | + /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdEndVideoCodingKHR.html> |
| 50 | + #[inline] |
| 51 | + #[doc(alias = "vkCmdEndVideoCodingKHR")] |
| 52 | + pub unsafe fn cmd_end_video_coding( |
| 53 | + &self, |
| 54 | + command_buffer: vk::CommandBuffer, |
| 55 | + end_coding_info: &vk::VideoEndCodingInfoKHR<'_>, |
| 56 | + ) { |
| 57 | + (self.fp.cmd_end_video_coding_khr)(command_buffer, end_coding_info) |
| 58 | + } |
| 59 | + |
| 60 | + /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCreateVideoSessionKHR.html> |
| 61 | + #[inline] |
| 62 | + #[doc(alias = "vkCreateVideoSessionKHR")] |
| 63 | + pub unsafe fn create_video_session( |
| 64 | + &self, |
| 65 | + create_info: &vk::VideoSessionCreateInfoKHR<'_>, |
| 66 | + allocation_callbacks: Option<&vk::AllocationCallbacks<'_>>, |
| 67 | + ) -> VkResult<vk::VideoSessionKHR> { |
| 68 | + let mut video_session = mem::MaybeUninit::uninit(); |
| 69 | + (self.fp.create_video_session_khr)( |
| 70 | + self.handle, |
| 71 | + create_info, |
| 72 | + allocation_callbacks.as_raw_ptr(), |
| 73 | + video_session.as_mut_ptr(), |
| 74 | + ) |
| 75 | + .assume_init_on_success(video_session) |
| 76 | + } |
| 77 | + |
| 78 | + /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCreateVideoSessionParametersKHR.html> |
| 79 | + #[inline] |
| 80 | + #[doc(alias = "vkCreateVideoSessionParametersKHR")] |
| 81 | + pub unsafe fn create_video_session_parameters( |
| 82 | + &self, |
| 83 | + create_info: &vk::VideoSessionParametersCreateInfoKHR<'_>, |
| 84 | + allocation_callbacks: Option<&vk::AllocationCallbacks<'_>>, |
| 85 | + ) -> VkResult<vk::VideoSessionParametersKHR> { |
| 86 | + let mut video_session_parameters = mem::MaybeUninit::uninit(); |
| 87 | + (self.fp.create_video_session_parameters_khr)( |
| 88 | + self.handle, |
| 89 | + create_info, |
| 90 | + allocation_callbacks.as_raw_ptr(), |
| 91 | + video_session_parameters.as_mut_ptr(), |
| 92 | + ) |
| 93 | + .assume_init_on_success(video_session_parameters) |
| 94 | + } |
| 95 | + |
| 96 | + /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkDestroyVideoSessionKHR.html> |
| 97 | + #[inline] |
| 98 | + #[doc(alias = "vkDestroyVideoSessionKHR")] |
| 99 | + pub unsafe fn destroy_video_session( |
| 100 | + &self, |
| 101 | + video_session: vk::VideoSessionKHR, |
| 102 | + allocation_callbacks: Option<&vk::AllocationCallbacks<'_>>, |
| 103 | + ) { |
| 104 | + (self.fp.destroy_video_session_khr)( |
| 105 | + self.handle, |
| 106 | + video_session, |
| 107 | + allocation_callbacks.as_raw_ptr(), |
| 108 | + ) |
| 109 | + } |
| 110 | + |
| 111 | + /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkDestroyVideoSessionParametersKHR.html> |
| 112 | + #[inline] |
| 113 | + #[doc(alias = "vkDestroyVideoSessionParametersKHR")] |
| 114 | + pub unsafe fn destroy_video_session_parameters( |
| 115 | + &self, |
| 116 | + video_session_parameters: vk::VideoSessionParametersKHR, |
| 117 | + allocation_callbacks: Option<&vk::AllocationCallbacks<'_>>, |
| 118 | + ) { |
| 119 | + (self.fp.destroy_video_session_parameters_khr)( |
| 120 | + self.handle, |
| 121 | + video_session_parameters, |
| 122 | + allocation_callbacks.as_raw_ptr(), |
| 123 | + ) |
| 124 | + } |
| 125 | + |
| 126 | + /// Retrieve the number of elements to pass to [`get_video_session_memory_requirements()`][Self::get_video_session_memory_requirements], |
| 127 | + #[inline] |
| 128 | + pub unsafe fn get_video_session_memory_requirements_len( |
| 129 | + &self, |
| 130 | + video_session: vk::VideoSessionKHR, |
| 131 | + ) -> VkResult<usize> { |
| 132 | + let mut count = mem::MaybeUninit::uninit(); |
| 133 | + (self.fp.get_video_session_memory_requirements_khr)( |
| 134 | + self.handle, |
| 135 | + video_session, |
| 136 | + count.as_mut_ptr(), |
| 137 | + ptr::null_mut(), |
| 138 | + ) |
| 139 | + .assume_init_on_success(count) |
| 140 | + .map(|c| c as usize) |
| 141 | + } |
| 142 | + |
| 143 | + /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetVideoSessionMemoryRequirementsKHR.html> |
| 144 | + /// |
| 145 | + /// Call [`get_video_session_memory_requirements_len()`][Self::get_video_session_memory_requirements_len] to query the number of elements to pass to `out.` |
| 146 | + /// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer. |
| 147 | + #[inline] |
| 148 | + #[doc(alias = "vkGetVideoSessionMemoryRequirementsKHR")] |
| 149 | + pub unsafe fn get_video_session_memory_requirements( |
| 150 | + &self, |
| 151 | + video_session: vk::VideoSessionKHR, |
| 152 | + out: &mut [vk::VideoSessionMemoryRequirementsKHR<'_>], |
| 153 | + ) -> VkResult<()> { |
| 154 | + let mut count = out.len() as u32; |
| 155 | + (self.fp.get_video_session_memory_requirements_khr)( |
| 156 | + self.handle, |
| 157 | + video_session, |
| 158 | + &mut count, |
| 159 | + out.as_mut_ptr(), |
| 160 | + ) |
| 161 | + .result()?; |
| 162 | + |
| 163 | + assert_eq!(count as usize, out.len()); |
| 164 | + Ok(()) |
| 165 | + } |
| 166 | + |
| 167 | + /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkUpdateVideoSessionParametersKHR.html> |
| 168 | + #[inline] |
| 169 | + #[doc(alias = "vkUpdateVideoSessionParametersKHR")] |
| 170 | + pub unsafe fn update_video_session_parameters( |
| 171 | + &self, |
| 172 | + video_session_parameters: vk::VideoSessionParametersKHR, |
| 173 | + update_info: &vk::VideoSessionParametersUpdateInfoKHR<'_>, |
| 174 | + ) -> VkResult<()> { |
| 175 | + (self.fp.update_video_session_parameters_khr)( |
| 176 | + self.handle, |
| 177 | + video_session_parameters, |
| 178 | + update_info, |
| 179 | + ) |
| 180 | + .result() |
| 181 | + } |
| 182 | +} |
| 183 | + |
| 184 | +impl crate::khr::video_queue::Instance { |
| 185 | + /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceVideoCapabilitiesKHR.html> |
| 186 | + #[inline] |
| 187 | + #[doc(alias = "vkGetPhysicalDeviceVideoCapabilitiesKHR")] |
| 188 | + pub unsafe fn get_physical_device_video_capabilities( |
| 189 | + &self, |
| 190 | + physical_device: vk::PhysicalDevice, |
| 191 | + video_profile: &vk::VideoProfileInfoKHR<'_>, |
| 192 | + capabilities: &mut vk::VideoCapabilitiesKHR<'_>, |
| 193 | + ) -> VkResult<()> { |
| 194 | + (self.fp.get_physical_device_video_capabilities_khr)( |
| 195 | + physical_device, |
| 196 | + video_profile, |
| 197 | + capabilities, |
| 198 | + ) |
| 199 | + .result() |
| 200 | + } |
| 201 | + |
| 202 | + /// Retrieve the number of elements to pass to [`get_physical_device_video_format_properties()`][Self::get_physical_device_video_format_properties], |
| 203 | + #[inline] |
| 204 | + pub unsafe fn get_physical_device_video_format_properties_len( |
| 205 | + &self, |
| 206 | + physical_device: vk::PhysicalDevice, |
| 207 | + video_format_info: &vk::PhysicalDeviceVideoFormatInfoKHR<'_>, |
| 208 | + ) -> VkResult<usize> { |
| 209 | + let mut count = mem::MaybeUninit::uninit(); |
| 210 | + (self.fp.get_physical_device_video_format_properties_khr)( |
| 211 | + physical_device, |
| 212 | + video_format_info, |
| 213 | + count.as_mut_ptr(), |
| 214 | + ptr::null_mut(), |
| 215 | + ) |
| 216 | + .assume_init_on_success(count) |
| 217 | + .map(|c| c as usize) |
| 218 | + } |
| 219 | + |
| 220 | + /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceVideoFormatPropertiesKHR.html> |
| 221 | + /// |
| 222 | + /// Call [`get_physical_device_video_format_properties_len()`][Self::get_physical_device_video_format_properties_len] to query the number of elements to pass to `out.` |
| 223 | + /// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer. |
| 224 | + #[inline] |
| 225 | + #[doc(alias = "vkGetPhysicalDeviceVideoFormatPropertiesKHR")] |
| 226 | + pub unsafe fn get_physical_device_video_format_properties( |
| 227 | + &self, |
| 228 | + physical_device: vk::PhysicalDevice, |
| 229 | + video_format_info: &vk::PhysicalDeviceVideoFormatInfoKHR<'_>, |
| 230 | + out: &mut [vk::VideoFormatPropertiesKHR<'_>], |
| 231 | + ) -> VkResult<()> { |
| 232 | + let mut format_count = out.len() as u32; |
| 233 | + (self.fp.get_physical_device_video_format_properties_khr)( |
| 234 | + physical_device, |
| 235 | + video_format_info, |
| 236 | + &mut format_count, |
| 237 | + out.as_mut_ptr(), |
| 238 | + ) |
| 239 | + .result()?; |
| 240 | + |
| 241 | + assert_eq!(format_count as usize, out.len()); |
| 242 | + Ok(()) |
| 243 | + } |
| 244 | +} |
0 commit comments