2023-01-12 09:10:09 +00:00
|
|
|
use self::rendering::Rendering;
|
|
|
|
|
2023-01-12 12:52:44 +00:00
|
|
|
mod pipeline;
|
2023-01-12 09:10:09 +00:00
|
|
|
mod rendering;
|
|
|
|
|
|
|
|
use anyhow::Result;
|
2023-01-12 12:52:44 +00:00
|
|
|
use std::sync::{Arc, Mutex};
|
2023-01-12 09:10:09 +00:00
|
|
|
use vulkan_rs::prelude::*;
|
|
|
|
|
|
|
|
#[derive(Default)]
|
|
|
|
pub struct Overlay {
|
|
|
|
instance: Option<Arc<Instance>>,
|
|
|
|
device: Option<Arc<Device>>,
|
2023-01-12 12:52:44 +00:00
|
|
|
queues: Vec<Arc<Mutex<Queue>>>,
|
|
|
|
renderings: Vec<Rendering>,
|
2023-01-12 09:10:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Overlay {
|
|
|
|
pub const fn new() -> Self {
|
|
|
|
Self {
|
|
|
|
instance: None,
|
|
|
|
device: None,
|
2023-01-12 12:52:44 +00:00
|
|
|
queues: Vec::new(),
|
|
|
|
renderings: Vec::new(),
|
2023-01-12 09:10:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn set_instance(&mut self, instance: Arc<Instance>) {
|
|
|
|
self.instance = Some(instance);
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn instance(&self) -> Arc<Instance> {
|
|
|
|
self.instance.as_ref().unwrap().clone()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn set_device(&mut self, device: Arc<Device>) {
|
|
|
|
self.device = Some(device);
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn device(&self) -> Arc<Device> {
|
|
|
|
self.device.as_ref().unwrap().clone()
|
|
|
|
}
|
|
|
|
|
2023-01-12 12:52:44 +00:00
|
|
|
pub fn add_queue(&mut self, queue: Arc<Mutex<Queue>>) {
|
|
|
|
self.queues.push(queue);
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn queue(&self, queue: VkQueue) -> Arc<Mutex<Queue>> {
|
|
|
|
match self
|
|
|
|
.queues
|
|
|
|
.iter()
|
|
|
|
.find(|q| q.lock().unwrap().vk_handle() == queue)
|
|
|
|
{
|
|
|
|
Some(q) => q.clone(),
|
|
|
|
None => panic!(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn swapchain(&self, swapchain: VkSwapchainKHR) -> &Arc<Swapchain> {
|
|
|
|
match self
|
|
|
|
.renderings
|
|
|
|
.iter()
|
|
|
|
.find(|r| r.swapchain().vk_handle() == swapchain)
|
|
|
|
{
|
|
|
|
Some(s) => s.swapchain(),
|
|
|
|
None => panic!(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn add_rendering(&mut self, swapchain: Arc<Swapchain>) -> Result<()> {
|
|
|
|
// self.renderings
|
|
|
|
// .push(Rendering::new(self.device(), self.queue(), swapchain)?);
|
2023-01-12 09:10:09 +00:00
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2023-01-12 12:52:44 +00:00
|
|
|
pub fn render(&mut self, queue: VkQueue) -> Result<VkSubmitInfo> {
|
|
|
|
// for rendering in self.renderings {
|
|
|
|
// rendering.render()
|
|
|
|
// }
|
|
|
|
|
|
|
|
todo!()
|
2023-01-12 09:10:09 +00:00
|
|
|
}
|
|
|
|
}
|