use crate::vulkan::{VkPhysicalDevice, LOG_TARGET}; use ash::prelude::VkResult; use ash::vk; pub struct VkSurface { surface_loader: ash::khr::surface::Instance, surface: vk::SurfaceKHR, } impl VkSurface { pub fn new( surface_loader: ash::khr::surface::Instance, surface: vk::SurfaceKHR, ) -> Self { Self { surface_loader, surface, } } pub fn physical_device_queue_supported(&self, physical_device: &VkPhysicalDevice, queue_index: u32) -> VkResult { unsafe { self.surface_loader.get_physical_device_surface_support( physical_device.handle, queue_index, self.surface, ) } } pub fn get_physical_device_surface_formats(&self, physical_device: &VkPhysicalDevice) -> VkResult> { unsafe { self.surface_loader.get_physical_device_surface_formats( physical_device.handle, self.surface, ) } } pub fn get_physical_device_surface_capabilities(&self, physical_device: &VkPhysicalDevice) -> VkResult { unsafe { self.surface_loader.get_physical_device_surface_capabilities( physical_device.handle, self.surface, ) } } pub fn get_physical_device_surface_present_modes(&self, physical_device: &VkPhysicalDevice) -> VkResult> { unsafe { self.surface_loader.get_physical_device_surface_present_modes( physical_device.handle, self.surface, ) } } } impl Drop for VkSurface { fn drop(&mut self) { unsafe { self.surface_loader.destroy_surface(self.surface, None); } log::debug!(target: LOG_TARGET, "Surface destroyed"); } }