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;
|
uint32_t frames_in_flight;
|
||||||
/// Whether or not to explicitly disable mipmap generation regardless of shader preset settings.
|
/// Whether or not to explicitly disable mipmap generation regardless of shader preset settings.
|
||||||
bool force_no_mipmaps;
|
bool force_no_mipmaps;
|
||||||
/// The format to use for the render pass. If this is `VK_FORMAT_UNDEFINED`, dynamic rendering
|
/// Use explicit render pass objects It is recommended if possible to use 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,
|
|
||||||
/// because render-pass mode will create new framebuffers per pass.
|
/// because render-pass mode will create new framebuffers per pass.
|
||||||
VkFormat render_pass_format;
|
bool use_render_pass;
|
||||||
} filter_chain_vk_opt_t;
|
} filter_chain_vk_opt_t;
|
||||||
|
|
||||||
#if defined(LIBRA_RUNTIME_VULKAN)
|
#if defined(LIBRA_RUNTIME_VULKAN)
|
||||||
|
|
|
@ -238,8 +238,8 @@ impl FilterChainVulkan {
|
||||||
&semantics,
|
&semantics,
|
||||||
frames_in_flight,
|
frames_in_flight,
|
||||||
options
|
options
|
||||||
.map(|o| o.render_pass_format)
|
.map(|o| o.use_render_pass)
|
||||||
.unwrap_or(vk::Format::UNDEFINED),
|
.unwrap_or(false),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let luts = FilterChainVulkan::load_luts(&device, &preset.textures)?;
|
let luts = FilterChainVulkan::load_luts(&device, &preset.textures)?;
|
||||||
|
@ -306,7 +306,7 @@ impl FilterChainVulkan {
|
||||||
passes: Vec<ShaderPassMeta>,
|
passes: Vec<ShaderPassMeta>,
|
||||||
semantics: &ShaderSemantics,
|
semantics: &ShaderSemantics,
|
||||||
frames_in_flight: u32,
|
frames_in_flight: u32,
|
||||||
render_pass_format: vk::Format,
|
use_render_pass: bool,
|
||||||
) -> error::Result<Box<[FilterPass]>> {
|
) -> error::Result<Box<[FilterPass]>> {
|
||||||
let mut filters = Vec::new();
|
let mut filters = Vec::new();
|
||||||
let frames_in_flight = std::cmp::max(1, frames_in_flight);
|
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);
|
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(
|
let graphics_pipeline = VulkanGraphicsPipeline::new(
|
||||||
&vulkan.device,
|
&vulkan.device,
|
||||||
&vulkan.pipeline_cache,
|
&vulkan.pipeline_cache,
|
||||||
|
|
|
@ -52,7 +52,7 @@ mod tests {
|
||||||
Some(&FilterChainOptionsVulkan {
|
Some(&FilterChainOptionsVulkan {
|
||||||
frames_in_flight: 3,
|
frames_in_flight: 3,
|
||||||
force_no_mipmaps: false,
|
force_no_mipmaps: false,
|
||||||
render_pass_format: vk::Format::R8G8B8A8_UNORM,
|
use_render_pass: true,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
@ -20,9 +20,7 @@ pub struct FilterChainOptionsVulkan {
|
||||||
pub frames_in_flight: u32,
|
pub frames_in_flight: u32,
|
||||||
/// Whether or not to explicitly disable mipmap generation regardless of shader preset settings.
|
/// Whether or not to explicitly disable mipmap generation regardless of shader preset settings.
|
||||||
pub force_no_mipmaps: bool,
|
pub force_no_mipmaps: bool,
|
||||||
/// The format to use for the render pass. If this is `VK_FORMAT_UNDEFINED`, dynamic rendering
|
/// Use explicit render pass objects It is recommended if possible to use 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,
|
|
||||||
/// because render-pass mode will create new framebuffers per pass.
|
/// 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
|
if self.image.size != size
|
||||||
|| (mipmap && self.max_miplevels == 1)
|
|| (mipmap && self.max_miplevels == 1)
|
||||||
|| (!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 };
|
let max_levels = if mipmap { u32::MAX } else { 1 };
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue