73 lines
1.8 KiB
Rust
73 lines
1.8 KiB
Rust
#![deny(rust_2018_idioms)]
|
|
#![deny(unused_must_use)]
|
|
|
|
pub mod input;
|
|
pub mod presentationcore;
|
|
mod renderbackend;
|
|
pub mod traits;
|
|
pub mod vri;
|
|
pub mod wsi;
|
|
pub mod xri;
|
|
|
|
pub mod prelude;
|
|
|
|
use anyhow::Result;
|
|
|
|
use traits::RenderCore;
|
|
use ui::prelude::*;
|
|
use vulkan_rs::prelude::*;
|
|
|
|
use crate::prelude::*;
|
|
|
|
use std::sync::{Arc, Mutex};
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
pub struct RenderCoreCreateInfo {
|
|
pub usage: VkImageUsageFlagBits,
|
|
pub format: VkFormat,
|
|
pub vsync: bool,
|
|
}
|
|
|
|
pub fn create_render_core<SCENE, F>(
|
|
presentation_core: &PresentationCore,
|
|
device: &Arc<Device>,
|
|
queue: &Arc<Mutex<Queue>>,
|
|
create_info: RenderCoreCreateInfo,
|
|
create_scene: F,
|
|
) -> Result<(Box<dyn RenderCore>, TargetMode<()>)>
|
|
where
|
|
SCENE: TScene + 'static,
|
|
F: FnOnce(
|
|
&Arc<Device>,
|
|
&Arc<Mutex<Queue>>,
|
|
(f32, f32),
|
|
&TargetMode<Vec<Arc<Image>>>,
|
|
) -> Result<SCENE>,
|
|
{
|
|
match presentation_core.backend() {
|
|
PresentationBackend::Window(wsi) => {
|
|
let (render_core, target_mode) =
|
|
wsi::vulkanwindowrendercore::VulkanWindowRenderCore::new(
|
|
wsi.clone(),
|
|
device,
|
|
queue,
|
|
create_info,
|
|
create_scene,
|
|
)?;
|
|
|
|
Ok((Box::new(render_core), target_mode))
|
|
}
|
|
PresentationBackend::OpenXR(xri) => {
|
|
let (render_core, target_mode) =
|
|
xri::openxrrendercore::OpenXRRenderCore::new(xri, device, queue, create_info)?;
|
|
|
|
Ok((Box::new(render_core), target_mode))
|
|
}
|
|
PresentationBackend::OpenVR(vri) => {
|
|
let (render_core, target_mode) =
|
|
vri::openvrrendercore::OpenVRRenderCore::new(vri, device, queue, create_info)?;
|
|
|
|
Ok((Box::new(render_core), target_mode))
|
|
}
|
|
}
|
|
}
|