vk_texture_runtime: Use the highest-priority representation of a surface

Starting from the provided index, search for the first non-null handle.
This commit is contained in:
Wunkolo 2023-11-20 12:27:58 -08:00
parent 8f791c0863
commit a2aee70b86
2 changed files with 10 additions and 11 deletions

View File

@ -387,7 +387,7 @@ void TextureRuntime::ClearTextureWithRenderpass(Surface& surface,
.aspect = surface.Aspect(),
.pipeline_flags = surface.PipelineStageFlags(),
.src_access = surface.AccessFlags(),
.src_image = surface.GetSampleCount() > 1 ? surface.Image(3) : surface.Image(),
.src_image = surface.Image(),
};
scheduler.Record([params, is_color, clear, render_pass,
@ -467,8 +467,8 @@ bool TextureRuntime::CopyTextures(Surface& source, Surface& dest,
.pipeline_flags = source.PipelineStageFlags() | dest.PipelineStageFlags(),
.src_access = source.AccessFlags(),
.dst_access = dest.AccessFlags(),
.src_image = (source.GetSampleCount() > 1) ? source.Image(3) : source.Image(),
.dst_image = (dest.GetSampleCount() > 1) ? dest.Image(3) : dest.Image(),
.src_image = source.Image(),
.dst_image = dest.Image(),
};
scheduler.Record([params, copy](vk::CommandBuffer cmdbuf) {
@ -572,8 +572,8 @@ bool TextureRuntime::BlitTextures(Surface& source, Surface& dest,
.pipeline_flags = source.PipelineStageFlags() | dest.PipelineStageFlags(),
.src_access = source.AccessFlags(),
.dst_access = dest.AccessFlags(),
.src_image = source.Image(),
.dst_image = dest.Image(),
.src_image = source.Image(1),
.dst_image = dest.Image(1),
};
scheduler.Record([params, blit](vk::CommandBuffer cmdbuf) {
@ -1175,11 +1175,10 @@ vk::PipelineStageFlags Surface::PipelineStageFlags() const noexcept {
}
vk::Image Surface::Image(u32 index) const noexcept {
const vk::Image image = handles[index].image;
if (!image) {
return handles[0].image;
}
return image;
const auto it = std::find_if(handles.crend() - index - 1, handles.crend(),
[](const Handle& handle) -> bool { return handle.image; });
return it->image;
}
vk::ImageView Surface::CopyImageView() noexcept {

View File

@ -123,7 +123,7 @@ public:
}
/// Returns the image at index, otherwise the base image
vk::Image Image(u32 index = 1) const noexcept;
vk::Image Image(u32 index = 3) const noexcept;
/// Returns the image view at index, otherwise the base view
vk::ImageView ImageView(u32 index = 1) const noexcept;