Run cargo fmt
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 0s

This commit is contained in:
Florian RICHER 2024-11-16 22:45:22 +01:00
parent bc94b68c0c
commit e9ce480f96
Signed by: florian.richer
GPG key ID: C73D37CBED7BFC77
10 changed files with 175 additions and 136 deletions

View file

@ -1,6 +1,6 @@
use std::sync::Arc;
use crate::vulkan::{VkDevice, VkInstance, VkPhysicalDevice, VkSurface, VkSwapchain, LOG_TARGET};
use ash::vk;
use std::sync::Arc;
pub struct VkRenderContext {
instance: Arc<VkInstance>,
@ -8,7 +8,6 @@ pub struct VkRenderContext {
device: Arc<VkDevice>,
swapchain: Arc<VkSwapchain>,
// present_queue: vk::Queue,
//
// pool: vk::CommandPool,
@ -25,32 +24,34 @@ pub struct VkRenderContext {
impl VkRenderContext {
pub fn init(window: &crate::display::Window) -> anyhow::Result<Self> {
let required_extensions = window
.required_extensions()?;
let required_extensions = window.required_extensions()?;
let instance = Arc::new(VkInstance::new(&required_extensions));
let surface = Arc::new(VkSurface::new(
&window,
instance.clone()
)?);
let surface = Arc::new(VkSurface::new(&window, instance.clone())?);
let mut physical_devices = instance.get_physical_devices();
physical_devices.sort_by(|a, b| b.priority().cmp(&a.priority()));
let (physical_device, queue_family_index, properties) = VkPhysicalDevice::pick_physical_device_and_queue_by(
&physical_devices,
Some(vk::QueueFlags::GRAPHICS),
Some(&surface),
).ok_or_else(|| anyhow::anyhow!("Unable to find physical device"))?;
let (physical_device, queue_family_index, properties) =
VkPhysicalDevice::pick_physical_device_and_queue_by(
&physical_devices,
Some(vk::QueueFlags::GRAPHICS),
Some(&surface),
)
.ok_or_else(|| anyhow::anyhow!("Unable to find physical device"))?;
log::debug!(target: LOG_TARGET, "Selected queue {properties:#?} for physical device {:?}", physical_device.properties.device_name_as_c_str());
let device = Arc::new(VkDevice::new_graphics_device(instance.clone(), &physical_device, queue_family_index)?);
let device = Arc::new(VkDevice::new_graphics_device(
instance.clone(),
&physical_device,
queue_family_index,
)?);
let swapchain = Arc::new(VkSwapchain::new(
&window,
surface.clone(),
device.clone(),
&physical_device
&physical_device,
)?);
// let present_queue = device.get_device_queue(0);
@ -97,7 +98,6 @@ impl VkRenderContext {
device,
swapchain,
// present_queue,
//
// pool,