log: Remove vulkan target
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 0s
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 0s
This commit is contained in:
parent
fc4a856048
commit
891835c4af
8 changed files with 52 additions and 50 deletions
|
@ -1,6 +1,6 @@
|
|||
use crate::display::Window;
|
||||
use crate::vulkan::vk_surface::SwapchainSupportDetails;
|
||||
use crate::vulkan::{VkDevice, VkPhysicalDevice, VkSurface, LOG_TARGET};
|
||||
use crate::vulkan::{VkDevice, VkPhysicalDevice, VkSurface};
|
||||
use ash::prelude::VkResult;
|
||||
use ash::vk;
|
||||
use std::sync::Arc;
|
||||
|
@ -28,7 +28,7 @@ impl VkSwapchain {
|
|||
device: Arc<VkDevice>,
|
||||
physical_device: &VkPhysicalDevice,
|
||||
) -> anyhow::Result<Self> {
|
||||
log::debug!(target: LOG_TARGET, "Creating swapchain");
|
||||
log::debug!("Creating swapchain");
|
||||
|
||||
let window_size = window
|
||||
.physical_size::<u32>()
|
||||
|
@ -39,15 +39,15 @@ impl VkSwapchain {
|
|||
})
|
||||
})
|
||||
.ok_or_else(|| anyhow::anyhow!("Failed to get swapchain extent"))?;
|
||||
log::debug!(target: LOG_TARGET, "Window size ({}x{})", window_size.width, window_size.height);
|
||||
log::debug!("Window size ({}x{})", window_size.width, window_size.height);
|
||||
|
||||
let swapchain_support_details =
|
||||
surface.get_physical_device_swapchain_support_details(physical_device)?;
|
||||
let SwapchainSupportDetails(surface_formats, surface_capabilities, present_modes) =
|
||||
&swapchain_support_details;
|
||||
log::debug!(target: LOG_TARGET, "Supported surface formats by physical device: {surface_formats:#?}");
|
||||
log::debug!(target: LOG_TARGET, "Surface capabilities: {surface_capabilities:#?}");
|
||||
log::debug!(target: LOG_TARGET, "Present modes: {present_modes:#?}");
|
||||
log::debug!("Supported surface formats by physical device: {surface_formats:#?}");
|
||||
log::debug!("Surface capabilities: {surface_capabilities:#?}");
|
||||
log::debug!("Present modes: {present_modes:#?}");
|
||||
|
||||
let surface_format = Self::choose_surface_format(surface_formats)
|
||||
.ok_or_else(|| anyhow::anyhow!("No available surface formats"))?;
|
||||
|
@ -102,12 +102,12 @@ impl VkSwapchain {
|
|||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
if log::log_enabled!(target: LOG_TARGET, log::Level::Debug) {
|
||||
if log::log_enabled!(log::Level::Debug) {
|
||||
let label = match self.swapchain {
|
||||
None => "Swapchain created",
|
||||
Some(_) => "Swapchain updated",
|
||||
};
|
||||
log::debug!(target: LOG_TARGET, "{label} ({swapchain:?}) : {swapchain_create_info:#?}");
|
||||
log::debug!("{label} ({swapchain:?}) : {swapchain_create_info:#?}");
|
||||
}
|
||||
|
||||
self.swapchain = Some(swapchain);
|
||||
|
@ -118,7 +118,7 @@ impl VkSwapchain {
|
|||
}
|
||||
|
||||
pub(super) fn update_resolution(&mut self, width: u32, height: u32) -> VkResult<()> {
|
||||
log::debug!(target: LOG_TARGET, "New resolution requested ({width}x{height})");
|
||||
log::debug!("New resolution requested ({width}x{height})");
|
||||
|
||||
let chosen_extent = Self::choose_swapchain_extent(
|
||||
vk::Extent2D { width, height },
|
||||
|
@ -128,11 +128,15 @@ impl VkSwapchain {
|
|||
|| chosen_extent.height != self.surface_resolution.height
|
||||
{
|
||||
self.surface_resolution = chosen_extent;
|
||||
log::debug!(target: LOG_TARGET, "New resolution applied ({}x{})", chosen_extent.width, chosen_extent.height);
|
||||
log::debug!(
|
||||
"New resolution applied ({}x{})",
|
||||
chosen_extent.width,
|
||||
chosen_extent.height
|
||||
);
|
||||
|
||||
self.create_swapchain()?;
|
||||
} else {
|
||||
log::debug!(target: LOG_TARGET, "New resolution skipped ({width}x{height}) : Same resolution");
|
||||
log::debug!("New resolution skipped ({width}x{height}) : Same resolution");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -171,16 +175,12 @@ impl VkSwapchain {
|
|||
}
|
||||
|
||||
fn choose_surface_format(
|
||||
surface_formats: &Vec<vk::SurfaceFormatKHR>
|
||||
surface_formats: &Vec<vk::SurfaceFormatKHR>,
|
||||
) -> Option<vk::SurfaceFormatKHR> {
|
||||
surface_formats
|
||||
.first()
|
||||
.and_then(|f| Some(*f))
|
||||
surface_formats.first().and_then(|f| Some(*f))
|
||||
}
|
||||
|
||||
fn choose_desired_image_count(
|
||||
surface_capabilities: &vk::SurfaceCapabilitiesKHR
|
||||
) -> u32 {
|
||||
fn choose_desired_image_count(surface_capabilities: &vk::SurfaceCapabilitiesKHR) -> u32 {
|
||||
let mut desired_image_count = surface_capabilities.min_image_count + 1;
|
||||
if surface_capabilities.max_image_count > 0
|
||||
&& desired_image_count > surface_capabilities.max_image_count
|
||||
|
@ -191,7 +191,7 @@ impl VkSwapchain {
|
|||
}
|
||||
|
||||
fn choose_pre_transform(
|
||||
surface_capabilities: &vk::SurfaceCapabilitiesKHR
|
||||
surface_capabilities: &vk::SurfaceCapabilitiesKHR,
|
||||
) -> vk::SurfaceTransformFlagsKHR {
|
||||
if surface_capabilities
|
||||
.supported_transforms
|
||||
|
@ -202,10 +202,8 @@ impl VkSwapchain {
|
|||
surface_capabilities.current_transform
|
||||
}
|
||||
}
|
||||
|
||||
fn choose_present_mode(
|
||||
present_modes: &Vec<vk::PresentModeKHR>
|
||||
) -> vk::PresentModeKHR {
|
||||
|
||||
fn choose_present_mode(present_modes: &Vec<vk::PresentModeKHR>) -> vk::PresentModeKHR {
|
||||
present_modes
|
||||
.iter()
|
||||
.cloned()
|
||||
|
@ -223,7 +221,7 @@ impl Drop for VkSwapchain {
|
|||
.destroy_swapchain(swapchain, None);
|
||||
}
|
||||
self.swapchain = None;
|
||||
log::debug!(target: LOG_TARGET, "Swapchain destroyed ({swapchain:?})");
|
||||
log::debug!("Swapchain destroyed ({swapchain:?})");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue