diff --git a/include/librashader.h b/include/librashader.h index d034d1f..5becfe3 100644 --- a/include/librashader.h +++ b/include/librashader.h @@ -248,11 +248,9 @@ typedef struct filter_chain_vk_opt_t { uint32_t frames_in_flight; /// Whether or not to explicitly disable mipmap generation regardless of shader preset settings. bool force_no_mipmaps; - /// The format to use for the render pass. If this is `VK_FORMAT_UNDEFINED`, dynamic rendering - /// will be used instead of a render pass. If this is set to some format, the render passes - /// will be created with such format. It is recommended if possible to use dynamic rendering, + /// Use explicit render pass objects It is recommended if possible to use dynamic rendering, /// because render-pass mode will create new framebuffers per pass. - VkFormat render_pass_format; + bool use_render_pass; } filter_chain_vk_opt_t; #if defined(LIBRA_RUNTIME_VULKAN) diff --git a/librashader-runtime-vk/src/filter_chain.rs b/librashader-runtime-vk/src/filter_chain.rs index 49ec109..1de7f0d 100644 --- a/librashader-runtime-vk/src/filter_chain.rs +++ b/librashader-runtime-vk/src/filter_chain.rs @@ -238,8 +238,8 @@ impl FilterChainVulkan { &semantics, frames_in_flight, options - .map(|o| o.render_pass_format) - .unwrap_or(vk::Format::UNDEFINED), + .map(|o| o.use_render_pass) + .unwrap_or(false), )?; let luts = FilterChainVulkan::load_luts(&device, &preset.textures)?; @@ -306,7 +306,7 @@ impl FilterChainVulkan { passes: Vec, semantics: &ShaderSemantics, frames_in_flight: u32, - render_pass_format: vk::Format, + use_render_pass: bool, ) -> error::Result> { let mut filters = Vec::new(); let frames_in_flight = std::cmp::max(1, frames_in_flight); @@ -349,6 +349,16 @@ impl FilterChainVulkan { uniform_bindings.insert(UniformBinding::TextureSize(*semantics), param.offset); } + let render_pass_format = if !use_render_pass { + vk::Format::UNDEFINED + } else if let Some(format) = config.get_format_override() { + format.into() + } else if source.format != ImageFormat::Unknown { + source.format.into() + } else { + ImageFormat::R8G8B8A8Unorm.into() + }; + let graphics_pipeline = VulkanGraphicsPipeline::new( &vulkan.device, &vulkan.pipeline_cache, diff --git a/librashader-runtime-vk/src/lib.rs b/librashader-runtime-vk/src/lib.rs index bdd9b2f..fbd5861 100644 --- a/librashader-runtime-vk/src/lib.rs +++ b/librashader-runtime-vk/src/lib.rs @@ -52,7 +52,7 @@ mod tests { Some(&FilterChainOptionsVulkan { frames_in_flight: 3, force_no_mipmaps: false, - render_pass_format: vk::Format::R8G8B8A8_UNORM, + use_render_pass: true, }), ) .unwrap(); diff --git a/librashader-runtime-vk/src/options.rs b/librashader-runtime-vk/src/options.rs index 4711412..5765931 100644 --- a/librashader-runtime-vk/src/options.rs +++ b/librashader-runtime-vk/src/options.rs @@ -20,9 +20,7 @@ pub struct FilterChainOptionsVulkan { pub frames_in_flight: u32, /// Whether or not to explicitly disable mipmap generation regardless of shader preset settings. pub force_no_mipmaps: bool, - /// The format to use for the render pass. If this is `VK_FORMAT_UNDEFINED`, dynamic rendering - /// will be used instead of a render pass. If this is set to some format, the render passes - /// will be created with such format. It is recommended if possible to use dynamic rendering, + /// Use explicit render pass objects It is recommended if possible to use dynamic rendering, /// because render-pass mode will create new framebuffers per pass. - pub render_pass_format: vk::Format, + pub use_render_pass: bool, } diff --git a/librashader-runtime-vk/src/texture.rs b/librashader-runtime-vk/src/texture.rs index cd7c33a..f6b79d8 100644 --- a/librashader-runtime-vk/src/texture.rs +++ b/librashader-runtime-vk/src/texture.rs @@ -142,6 +142,7 @@ impl OwnedImage { if self.image.size != size || (mipmap && self.max_miplevels == 1) || (!mipmap && self.max_miplevels != 1) + || vk::Format::from(format) != self.image.format { let max_levels = if mipmap { u32::MAX } else { 1 };