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

View File

@ -123,7 +123,7 @@ public:
} }
/// Returns the image at index, otherwise the base image /// 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 /// Returns the image view at index, otherwise the base view
vk::ImageView ImageView(u32 index = 1) const noexcept; vk::ImageView ImageView(u32 index = 1) const noexcept;