use ash::vk;
#[cfg(feature = "fsr2")]
use fsr2_sys::FfxFsr2InitializationFlagBits;
use crate::core::queue::QueueType;
use crate::WindowInterface;
#[derive(Debug)]
pub struct QueueRequest {
pub dedicated: bool,
pub queue_type: QueueType,
}
#[derive(Default, Debug)]
pub struct GPURequirements {
pub dedicated: bool,
pub min_video_memory: usize,
pub min_dedicated_video_memory: usize,
pub queues: Vec<QueueRequest>,
pub features: vk::PhysicalDeviceFeatures,
pub features_1_1: vk::PhysicalDeviceVulkan11Features,
pub features_1_2: vk::PhysicalDeviceVulkan12Features,
pub features_1_3: vk::PhysicalDeviceVulkan13Features,
pub device_extensions: Vec<String>,
}
#[cfg(feature = "fsr2")]
#[derive(Debug)]
pub struct Fsr2Settings {
pub display_size: (u32, u32),
pub max_render_size: Option<(u32, u32)>,
pub flags: FfxFsr2InitializationFlagBits,
}
#[cfg(feature = "fsr2")]
impl Default for Fsr2Settings {
fn default() -> Self {
Self {
display_size: (0, 0),
max_render_size: None,
flags: FfxFsr2InitializationFlagBits::from_bits_retain(0),
}
}
}
#[derive(Debug)]
pub struct AppSettings<'a, Window: WindowInterface> {
pub name: String,
pub version: (u32, u32, u32),
pub enable_validation: bool,
pub window: Option<&'a Window>,
pub surface_format: Option<vk::SurfaceFormatKHR>,
pub present_mode: Option<vk::PresentModeKHR>,
pub gpu_requirements: GPURequirements,
pub scratch_buffer_size: u64,
pub raytracing: bool,
#[cfg(feature = "fsr2")]
pub fsr2_settings: Fsr2Settings,
}
impl<'a, Window: WindowInterface> Default for AppSettings<'a, Window> {
fn default() -> Self {
AppSettings {
name: String::from(""),
version: (0, 0, 0),
enable_validation: false,
window: None,
surface_format: None,
present_mode: None,
gpu_requirements: GPURequirements::default(),
scratch_buffer_size: 1,
raytracing: false,
#[cfg(feature = "fsr2")]
fsr2_settings: Fsr2Settings::default(),
}
}
}
pub struct AppBuilder<'a, Window: WindowInterface> {
inner: AppSettings<'a, Window>,
}
impl<'a, Window: WindowInterface> Default for AppBuilder<'a, Window> {
fn default() -> Self {
Self {
inner: AppSettings::default(),
}
}
}
impl<'a, Window: WindowInterface> AppBuilder<'a, Window> {
pub fn new() -> Self {
AppBuilder {
inner: AppSettings::default(),
}
}
pub fn name(mut self, name: impl Into<String>) -> Self {
self.inner.name = name.into();
self
}
pub fn version(mut self, ver: impl Into<(u32, u32, u32)>) -> Self {
self.inner.version = ver.into();
self
}
pub fn validation(mut self, val: bool) -> Self {
self.inner.enable_validation = val;
self
}
pub fn window(mut self, window: &'a Window) -> Self {
self.inner.window = Some(window);
self
}
pub fn surface_format(mut self, format: vk::SurfaceFormatKHR) -> Self {
self.inner.surface_format = Some(format);
self
}
pub fn present_mode(mut self, mode: vk::PresentModeKHR) -> Self {
self.inner.present_mode = Some(mode);
self
}
pub fn gpu(mut self, gpu: GPURequirements) -> Self {
self.inner.gpu_requirements = gpu;
self
}
pub fn scratch_size(mut self, size: impl Into<u64>) -> Self {
let size = size.into();
self.inner.scratch_buffer_size = size;
self
}
pub fn raytracing(mut self, enabled: bool) -> Self {
self.inner.raytracing = enabled;
self
}
#[cfg(feature = "fsr2")]
pub fn fsr2_display_size(mut self, width: u32, height: u32) -> Self {
self.inner.fsr2_settings.display_size = (width, height);
self
}
#[cfg(feature = "fsr2")]
pub fn fsr2_max_render_size(mut self, width: u32, height: u32) -> Self {
self.inner.fsr2_settings.max_render_size = Some((width, height));
self
}
#[cfg(feature = "fsr2")]
pub fn fsr2_flags(mut self, flags: FfxFsr2InitializationFlagBits) -> Self {
self.inner.fsr2_settings.flags = flags;
self
}
pub fn build(self) -> AppSettings<'a, Window> {
self.inner
}
}