Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions impeller/renderer/backend/vulkan/swapchain_impl_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ struct FrameSynchronizer {
vk::UniqueFence acquire;
vk::UniqueSemaphore render_ready;
vk::UniqueSemaphore present_ready;
std::shared_ptr<CommandBuffer> final_cmd_buffer;
bool is_valid = false;

explicit FrameSynchronizer(const vk::Device& device) {
Expand Down Expand Up @@ -382,18 +383,18 @@ bool SwapchainImplVK::Present(const std::shared_ptr<SwapchainImageVK>& image,
//----------------------------------------------------------------------------
/// Transition the image to color-attachment-optimal.
///
{
auto cmd_buffer = context.CreateCommandBuffer();
if (!cmd_buffer) {
return false;
}

auto vk_cmd_buffer =
CommandBufferVK::Cast(*cmd_buffer).GetEncoder()->GetCommandBuffer();
sync->final_cmd_buffer = context.CreateCommandBuffer();
if (!sync->final_cmd_buffer) {
return false;
}

auto vk_final_cmd_buffer = CommandBufferVK::Cast(*sync->final_cmd_buffer)
.GetEncoder()
->GetCommandBuffer();
{
LayoutTransition transition;
transition.new_layout = vk::ImageLayout::ePresentSrcKHR;
transition.cmd_buffer = vk_cmd_buffer;
transition.cmd_buffer = vk_final_cmd_buffer;
transition.src_access = vk::AccessFlagBits::eColorAttachmentWrite;
transition.src_stage = vk::PipelineStageFlagBits::eColorAttachmentOutput;
transition.dst_access = {};
Expand All @@ -403,7 +404,7 @@ bool SwapchainImplVK::Present(const std::shared_ptr<SwapchainImageVK>& image,
return false;
}

if (!cmd_buffer->SubmitCommands()) {
if (vk_final_cmd_buffer.end() != vk::Result::eSuccess) {
return false;
}
}
Expand All @@ -418,6 +419,7 @@ bool SwapchainImplVK::Present(const std::shared_ptr<SwapchainImageVK>& image,
submit_info.setWaitDstStageMask(wait_stage);
submit_info.setWaitSemaphores(*sync->render_ready);
submit_info.setSignalSemaphores(*sync->present_ready);
submit_info.setCommandBuffers(vk_final_cmd_buffer);
auto result =
context.GetGraphicsQueue()->Submit(submit_info, *sync->acquire);
if (result != vk::Result::eSuccess) {
Expand Down