extensions/khr: Add VK_KHR_device_group_creation (#630)

This commit is contained in:
Marijn Suijten 2022-06-05 12:32:26 +02:00 committed by GitHub
parent c6f8da0515
commit 85fa5425d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 65 additions and 0 deletions

View file

@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added `VK_EXT_sample_locations` device extension (#616) - Added `VK_EXT_sample_locations` device extension (#616)
- Update Vulkan-Headers to 1.3.211 (#605, #608) - Update Vulkan-Headers to 1.3.211 (#605, #608)
- Added `VK_EXT_image_drm_format_modifier` device extension (#603) - Added `VK_EXT_image_drm_format_modifier` device extension (#603)
- Added `VK_KHR_device_group_creation` instance extension (#630)
### Removed ### Removed

View file

@ -0,0 +1,62 @@
use crate::prelude::*;
use crate::vk;
use crate::{Entry, Instance};
use std::ffi::CStr;
use std::mem;
use std::ptr;
#[derive(Clone)]
pub struct DeviceGroupCreation {
handle: vk::Instance,
fp: vk::KhrDeviceGroupCreationFn,
}
impl DeviceGroupCreation {
pub fn new(entry: Entry, instance: &Instance) -> Self {
let handle = instance.handle();
let fp = vk::KhrDeviceGroupCreationFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr()))
});
Self { handle, fp }
}
/// Retrieve the number of elements to pass to [`enumerate_physical_device_groups()`][Self::enumerate_physical_device_groups()]
#[inline]
pub unsafe fn enumerate_physical_device_groups_len(&self) -> VkResult<usize> {
let mut group_count = 0;
(self.fp.enumerate_physical_device_groups_khr)(
self.handle,
&mut group_count,
ptr::null_mut(),
)
.result_with_success(group_count as usize)
}
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkEnumeratePhysicalDeviceGroupsKHR.html>
///
/// Call [`enumerate_physical_device_groups_len()`][Self::enumerate_physical_device_groups_len()] to query the number of elements to pass to `out`.
/// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer.
#[inline]
pub unsafe fn enumerate_physical_device_groups(
&self,
out: &mut [vk::PhysicalDeviceGroupProperties],
) -> VkResult<()> {
let mut count = out.len() as u32;
(self.fp.enumerate_physical_device_groups_khr)(self.handle, &mut count, out.as_mut_ptr())
.result()?;
assert_eq!(count as usize, out.len());
Ok(())
}
pub const fn name() -> &'static CStr {
vk::KhrDeviceGroupCreationFn::name()
}
pub fn fp(&self) -> &vk::KhrDeviceGroupCreationFn {
&self.fp
}
pub fn device(&self) -> vk::Instance {
self.handle
}
}

View file

@ -4,6 +4,7 @@ pub use self::buffer_device_address::BufferDeviceAddress;
pub use self::copy_commands2::CopyCommands2; pub use self::copy_commands2::CopyCommands2;
pub use self::create_render_pass2::CreateRenderPass2; pub use self::create_render_pass2::CreateRenderPass2;
pub use self::deferred_host_operations::DeferredHostOperations; pub use self::deferred_host_operations::DeferredHostOperations;
pub use self::device_group_creation::DeviceGroupCreation;
pub use self::display::Display; pub use self::display::Display;
pub use self::display_swapchain::DisplaySwapchain; pub use self::display_swapchain::DisplaySwapchain;
pub use self::draw_indirect_count::DrawIndirectCount; pub use self::draw_indirect_count::DrawIndirectCount;
@ -39,6 +40,7 @@ mod buffer_device_address;
mod copy_commands2; mod copy_commands2;
mod create_render_pass2; mod create_render_pass2;
mod deferred_host_operations; mod deferred_host_operations;
mod device_group_creation;
mod display; mod display;
mod display_swapchain; mod display_swapchain;
mod draw_indirect_count; mod draw_indirect_count;