Skip to content

Commit

Permalink
extensions/khr: Reorder Swapchain functions to match KhrSwapchainFn
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Jun 5, 2022
1 parent 85fa542 commit 0f298ee
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions ash/src/extensions/khr/swapchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@ impl Swapchain {
Self { handle, fp }
}

/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateSwapchainKHR.html>
pub unsafe fn create_swapchain(
&self,
create_info: &vk::SwapchainCreateInfoKHR,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SwapchainKHR> {
let mut swapchain = mem::zeroed();
(self.fp.create_swapchain_khr)(
self.handle,
create_info,
allocation_callbacks.as_raw_ptr(),
&mut swapchain,
)
.result_with_success(swapchain)
}

/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkDestroySwapchainKHR.html>
pub unsafe fn destroy_swapchain(
&self,
Expand All @@ -29,6 +45,16 @@ impl Swapchain {
(self.fp.destroy_swapchain_khr)(self.handle, swapchain, allocation_callbacks.as_raw_ptr());
}

/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetSwapchainImagesKHR.html>
pub unsafe fn get_swapchain_images(
&self,
swapchain: vk::SwapchainKHR,
) -> VkResult<Vec<vk::Image>> {
read_into_uninitialized_vector(|count, data| {
(self.fp.get_swapchain_images_khr)(self.handle, swapchain, count, data)
})
}

/// On success, returns the next image's index and whether the swapchain is suboptimal for the surface.
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkAcquireNextImageKHR.html>
pub unsafe fn acquire_next_image(
Expand All @@ -54,22 +80,6 @@ impl Swapchain {
}
}

/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateSwapchainKHR.html>
pub unsafe fn create_swapchain(
&self,
create_info: &vk::SwapchainCreateInfoKHR,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SwapchainKHR> {
let mut swapchain = mem::zeroed();
(self.fp.create_swapchain_khr)(
self.handle,
create_info,
allocation_callbacks.as_raw_ptr(),
&mut swapchain,
)
.result_with_success(swapchain)
}

/// On success, returns whether the swapchain is suboptimal for the surface.
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkQueuePresentKHR.html>
pub unsafe fn queue_present(
Expand All @@ -85,16 +95,6 @@ impl Swapchain {
}
}

/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetSwapchainImagesKHR.html>
pub unsafe fn get_swapchain_images(
&self,
swapchain: vk::SwapchainKHR,
) -> VkResult<Vec<vk::Image>> {
read_into_uninitialized_vector(|count, data| {
(self.fp.get_swapchain_images_khr)(self.handle, swapchain, count, data)
})
}

pub const fn name() -> &'static CStr {
vk::KhrSwapchainFn::name()
}
Expand Down

0 comments on commit 0f298ee

Please sign in to comment.