From 98e5070d81b59586458a0b8eac18e9ed008d1dc1 Mon Sep 17 00:00:00 2001 From: chyyran Date: Fri, 13 Jan 2023 04:13:16 -0500 Subject: [PATCH] vk: make frames in flight configurable --- librashader-runtime-vk/src/filter_chain.rs | 7 ++++++- librashader-runtime-vk/src/options.rs | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/librashader-runtime-vk/src/filter_chain.rs b/librashader-runtime-vk/src/filter_chain.rs index d78d246..67328c5 100644 --- a/librashader-runtime-vk/src/filter_chain.rs +++ b/librashader-runtime-vk/src/filter_chain.rs @@ -201,8 +201,13 @@ impl FilterChain { let (passes, semantics) = FilterChain::load_preset(preset.shaders, &preset.textures)?; let device = vulkan.try_into()?; + let mut frames_in_flight = options.map(|o| o.frames_in_flight).unwrap_or(0); + if frames_in_flight == 0 { + frames_in_flight = 3; + } + // initialize passes - let filters = Self::init_passes(&device, passes, &semantics, 3)?; + let filters = Self::init_passes(&device, passes, &semantics, frames_in_flight)?; let luts = FilterChain::load_luts(&device, &preset.textures)?; let samplers = SamplerSet::new(&device.device)?; diff --git a/librashader-runtime-vk/src/options.rs b/librashader-runtime-vk/src/options.rs index 2aa83b0..87f0733 100644 --- a/librashader-runtime-vk/src/options.rs +++ b/librashader-runtime-vk/src/options.rs @@ -14,6 +14,8 @@ pub struct FrameOptions { #[repr(C)] #[derive(Debug, Clone)] pub struct FilterChainOptions { + /// The number of frames in flight to keep. If zero, defaults to three. + pub frames_in_flight: u32, /// Whether or not to explicitly disable mipmap generation regardless of shader preset settings. pub force_no_mipmaps: bool, }