| 1 |
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_device_group.html> |
| 2 |
|
| 3 |
#[cfg(doc)] |
| 4 |
use crate::khr; |
| 5 |
use crate::prelude::*; |
| 6 |
use crate::vk; |
| 7 |
use alloc::vec::Vec; |
| 8 |
use core::mem; |
| 9 |
|
| 10 |
impl crate::khr::device_group::Device { |
| 11 |
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetDeviceGroupPeerMemoryFeaturesKHR.html> |
| 12 |
#[inline] |
| 13 |
pub unsafe fn get_device_group_peer_memory_features( |
| 14 |
&self, |
| 15 |
heap_index: u32, |
| 16 |
local_device_index: u32, |
| 17 |
remote_device_index: u32, |
| 18 |
) -> vk::PeerMemoryFeatureFlags { |
| 19 |
let mut peer_memory_features = mem::MaybeUninit::uninit(); |
| 20 |
(self.fp.get_device_group_peer_memory_features_khr)( |
| 21 |
self.handle, |
| 22 |
heap_index, |
| 23 |
local_device_index, |
| 24 |
remote_device_index, |
| 25 |
peer_memory_features.as_mut_ptr(), |
| 26 |
); |
| 27 |
peer_memory_features.assume_init() |
| 28 |
} |
| 29 |
|
| 30 |
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdSetDeviceMaskKHR.html> |
| 31 |
#[inline] |
| 32 |
pub unsafe fn cmd_set_device_mask(&self, command_buffer: vk::CommandBuffer, device_mask: u32) { |
| 33 |
(self.fp.cmd_set_device_mask_khr)(command_buffer, device_mask) |
| 34 |
} |
| 35 |
|
| 36 |
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdDispatchBaseKHR.html> |
| 37 |
#[inline] |
| 38 |
pub unsafe fn cmd_dispatch_base( |
| 39 |
&self, |
| 40 |
command_buffer: vk::CommandBuffer, |
| 41 |
base_group: (u32, u32, u32), |
| 42 |
group_count: (u32, u32, u32), |
| 43 |
) { |
| 44 |
(self.fp.cmd_dispatch_base_khr)( |
| 45 |
command_buffer, |
| 46 |
base_group.0, |
| 47 |
base_group.1, |
| 48 |
base_group.2, |
| 49 |
group_count.0, |
| 50 |
group_count.1, |
| 51 |
group_count.2, |
| 52 |
) |
| 53 |
} |
| 54 |
|
| 55 |
/// Requires [`VK_KHR_surface`] to be enabled. |
| 56 |
/// |
| 57 |
/// Also available as [`khr::swapchain::Device::get_device_group_present_capabilities()`] since [Vulkan 1.1]. |
| 58 |
/// |
| 59 |
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetDeviceGroupPresentCapabilitiesKHR.html> |
| 60 |
/// |
| 61 |
/// [Vulkan 1.1]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_VERSION_1_1.html |
| 62 |
/// [`VK_KHR_surface`]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_surface.html |
| 63 |
#[inline] |
| 64 |
pub unsafe fn get_device_group_present_capabilities( |
| 65 |
&self, |
| 66 |
device_group_present_capabilities: &mut vk::DeviceGroupPresentCapabilitiesKHR<'_>, |
| 67 |
) -> VkResult<()> { |
| 68 |
(self.fp.get_device_group_present_capabilities_khr)( |
| 69 |
self.handle, |
| 70 |
device_group_present_capabilities, |
| 71 |
) |
| 72 |
.result() |
| 73 |
} |
| 74 |
|
| 75 |
/// Requires [`VK_KHR_surface`] to be enabled. |
| 76 |
/// |
| 77 |
/// Also available as [`khr::swapchain::Device::get_device_group_surface_present_modes()`] since [Vulkan 1.1]. |
| 78 |
/// |
| 79 |
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetDeviceGroupSurfacePresentModesKHR.html> |
| 80 |
/// |
| 81 |
/// [Vulkan 1.1]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_VERSION_1_1.html |
| 82 |
/// [`VK_KHR_surface`]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_surface.html |
| 83 |
#[inline] |
| 84 |
pub unsafe fn get_device_group_surface_present_modes( |
| 85 |
&self, |
| 86 |
surface: vk::SurfaceKHR, |
| 87 |
) -> VkResult<vk::DeviceGroupPresentModeFlagsKHR> { |
| 88 |
let mut modes = mem::MaybeUninit::uninit(); |
| 89 |
(self.fp.get_device_group_surface_present_modes_khr)( |
| 90 |
self.handle, |
| 91 |
surface, |
| 92 |
modes.as_mut_ptr(), |
| 93 |
) |
| 94 |
.assume_init_on_success(modes) |
| 95 |
} |
| 96 |
|
| 97 |
/// On success, returns the next image's index and whether the swapchain is suboptimal for the surface. |
| 98 |
/// |
| 99 |
/// Requires [`VK_KHR_swapchain`] to be enabled. |
| 100 |
/// |
| 101 |
/// Also available as [`khr::swapchain::Device::acquire_next_image2()`] since [Vulkan 1.1]. |
| 102 |
/// |
| 103 |
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkAcquireNextImage2KHR.html> |
| 104 |
/// |
| 105 |
/// [Vulkan 1.1]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_VERSION_1_1.html |
| 106 |
/// [`VK_KHR_swapchain`]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_swapchain.html |
| 107 |
#[inline] |
| 108 |
pub unsafe fn acquire_next_image2( |
| 109 |
&self, |
| 110 |
acquire_info: &vk::AcquireNextImageInfoKHR<'_>, |
| 111 |
) -> VkResult<(u32, bool)> { |
| 112 |
let mut index = mem::MaybeUninit::uninit(); |
| 113 |
let err_code = |
| 114 |
(self.fp.acquire_next_image2_khr)(self.handle, acquire_info, index.as_mut_ptr()); |
| 115 |
match err_code { |
| 116 |
vk::Result::SUCCESS => Ok((index.assume_init(), false)), |
| 117 |
vk::Result::SUBOPTIMAL_KHR => Ok((index.assume_init(), true)), |
| 118 |
_ => Err(err_code), |
| 119 |
} |
| 120 |
} |
| 121 |
} |
| 122 |
|
| 123 |
impl crate::khr::device_group::Instance { |
| 124 |
/// Requires [`VK_KHR_surface`] to be enabled. |
| 125 |
/// |
| 126 |
/// Also available as [`khr::swapchain::Instance::get_physical_device_present_rectangles()`] since [Vulkan 1.1]. |
| 127 |
/// |
| 128 |
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDevicePresentRectanglesKHR.html> |
| 129 |
/// |
| 130 |
/// [Vulkan 1.1]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_VERSION_1_1.html |
| 131 |
/// [`VK_KHR_surface`]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_surface.html |
| 132 |
#[inline] |
| 133 |
pub unsafe fn get_physical_device_present_rectangles( |
| 134 |
&self, |
| 135 |
physical_device: vk::PhysicalDevice, |
| 136 |
surface: vk::SurfaceKHR, |
| 137 |
) -> VkResult<Vec<vk::Rect2D>> { |
| 138 |
read_into_uninitialized_vector(|count, data| { |
| 139 |
(self.fp.get_physical_device_present_rectangles_khr)( |
| 140 |
physical_device, |
| 141 |
surface, |
| 142 |
count, |
| 143 |
data, |
| 144 |
) |
| 145 |
}) |
| 146 |
} |
| 147 |
} |