vk: make choice of render pass format dependent on the shader
This commit is contained in:
parent
b7a44f25f3
commit
da2fb7adca
|
@ -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)
|
||||
|
|
|
@ -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<ShaderPassMeta>,
|
||||
semantics: &ShaderSemantics,
|
||||
frames_in_flight: u32,
|
||||
render_pass_format: vk::Format,
|
||||
use_render_pass: bool,
|
||||
) -> error::Result<Box<[FilterPass]>> {
|
||||
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,
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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 };
|
||||
|
||||
|
|
Loading…
Reference in a new issue