bedrock/resources/
swapchain_image.rs1use crate::*;
2
3#[derive(VkHandle, VkObject)]
5#[VkObject(type = VkImage::OBJECT_TYPE)]
6pub struct SwapchainImage<Swapchain>(pub(crate) VkImage, pub(crate) Swapchain, pub(crate) VkExtent3D);
7unsafe impl<Swapchain: Sync> Sync for SwapchainImage<Swapchain> {}
8unsafe impl<Swapchain: Send> Send for SwapchainImage<Swapchain> {}
9impl<Swapchain: DeviceChildHandle> DeviceChildHandle for SwapchainImage<Swapchain> {
10 #[inline(always)]
11 fn device_handle(&self) -> VkDevice {
12 self.1.device_handle()
13 }
14}
15impl<Swapchain: DeviceChild> DeviceChild for SwapchainImage<Swapchain> {
16 type ConcreteDevice = Swapchain::ConcreteDevice;
17
18 #[inline(always)]
19 fn device(&self) -> &Self::ConcreteDevice {
20 self.1.device()
21 }
22}
23impl<Swapchain: crate::Swapchain> Image for SwapchainImage<Swapchain> {
24 #[inline(always)]
25 fn format(&self) -> VkFormat {
26 self.1.format()
27 }
28
29 #[inline(always)]
30 fn size(&self) -> &VkExtent3D {
31 &self.2
32 }
33
34 #[inline(always)]
35 fn dimension(&self) -> VkImageViewType {
36 VK_IMAGE_VIEW_TYPE_2D
37 }
38}
39impl<Swapchain: Clone> SwapchainImage<&'_ Swapchain> {
40 #[inline(always)]
42 pub fn clone_parent(self) -> SwapchainImage<Swapchain> {
43 let r = SwapchainImage(self.0, self.1.clone(), self.2.clone());
44 std::mem::forget(self);
46 r
47 }
48}
49impl<Swapchain> SwapchainImage<Swapchain> {
50 pub const fn unmanage(self) -> (VkImage, Swapchain, VkExtent3D) {
52 let image = unsafe { core::ptr::read(&self.0) };
53 let swapchain = unsafe { core::ptr::read(&self.1) };
54 let extent = unsafe { core::ptr::read(&self.2) };
55 core::mem::forget(self);
56
57 (image, swapchain, extent)
58 }
59}