Skip to content

Commit

Permalink
get_surface_capabilities2: allow p_next to be set externally
Browse files Browse the repository at this point in the history
  • Loading branch information
asnordstrand committed Dec 28, 2021
1 parent 9a5a338 commit 7fac872
Showing 1 changed file with 36 additions and 11 deletions.
47 changes: 36 additions & 11 deletions ash/src/extensions/khr/get_surface_capabilities2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,48 @@ impl GetSurfaceCapabilities2 {
.result_with_success(surface_capabilities)
}

/// Retrieve the number of elements to pass to [`Self::get_physical_device_surface_formats2()`]
pub unsafe fn get_physical_device_surface_formats2_len(
&self,
physical_device: vk::PhysicalDevice,
surface_info: &vk::PhysicalDeviceSurfaceInfo2KHR,
) -> VkResult<usize> {
let mut count = 0;
let err_code = self.fp.get_physical_device_surface_formats2_khr(
physical_device,
surface_info,
&mut count,
std::ptr::null_mut(),
);
err_code.result_with_success(count as usize)
}

#[doc = "https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceSurfaceFormats2KHR.html"]
///
/// Call [`Self::get_physical_device_surface_formats2_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.
pub unsafe fn get_physical_device_surface_formats2(
&self,
physical_device: vk::PhysicalDevice,
surface_info: &vk::PhysicalDeviceSurfaceInfo2KHR,
) -> VkResult<Vec<vk::SurfaceFormat2KHR>> {
read_into_uninitialized_vector(|count, data| {
self.fp.get_physical_device_surface_formats2_khr(
physical_device,
surface_info,
count,
data
)
})
out: &mut [vk::SurfaceFormat2KHR],
) -> VkResult<()> {
let mut count = out.len() as u32;
let err_code = self.fp.get_physical_device_surface_formats2_khr(
physical_device,
surface_info,
&mut count,
out.as_mut_ptr(),
);
assert_eq!(count, out.len() as u32);
err_code.result()
}

pub fn name() -> &'static CStr { vk::KhrGetSurfaceCapabilities2Fn::name() }
pub fn name() -> &'static CStr {
vk::KhrGetSurfaceCapabilities2Fn::name()
}

pub fn fp(&self) -> &vk::KhrGetSurfaceCapabilities2Fn { &self.fp }
pub fn fp(&self) -> &vk::KhrGetSurfaceCapabilities2Fn {
&self.fp
}
}

0 comments on commit 7fac872

Please sign in to comment.