[Impeller] Fix swapchain recreation for non-polling cases. (flutter/engine#45740)
Earlier, there was no recovery from vk::Result::eSuboptimalKHR. This made the playground be stuck with a swapchain image size of 1x1 with suboptimal error code on acquisition indefinitely. Towards fixing the playgrounds. There are still some validation errors.
This commit is contained in:
@@ -69,13 +69,14 @@ bool SurfaceContextVK::SetWindowSurface(vk::UniqueSurfaceKHR surface) {
|
||||
std::unique_ptr<Surface> SurfaceContextVK::AcquireNextSurface() {
|
||||
TRACE_EVENT0("impeller", __FUNCTION__);
|
||||
auto surface = swapchain_ ? swapchain_->AcquireNextDrawable() : nullptr;
|
||||
auto pipeline_library = parent_->GetPipelineLibrary();
|
||||
if (surface && pipeline_library) {
|
||||
if (!surface) {
|
||||
return nullptr;
|
||||
}
|
||||
if (auto pipeline_library = parent_->GetPipelineLibrary()) {
|
||||
impeller::PipelineLibraryVK::Cast(*pipeline_library)
|
||||
.DidAcquireSurfaceFrame();
|
||||
}
|
||||
auto allocator = parent_->GetResourceAllocator();
|
||||
if (allocator) {
|
||||
if (auto allocator = parent_->GetResourceAllocator()) {
|
||||
allocator->DidAcquireSurfaceFrame();
|
||||
}
|
||||
return surface;
|
||||
|
||||
@@ -375,15 +375,20 @@ SwapchainImplVK::AcquireResult SwapchainImplVK::AcquireNextDrawable() {
|
||||
nullptr // fence
|
||||
);
|
||||
|
||||
if (acq_result == vk::Result::eErrorOutOfDateKHR) {
|
||||
return AcquireResult{true /* out of date */};
|
||||
}
|
||||
|
||||
if (acq_result != vk::Result::eSuccess &&
|
||||
acq_result != vk::Result::eSuboptimalKHR) {
|
||||
VALIDATION_LOG << "Could not acquire next swapchain image: "
|
||||
<< vk::to_string(acq_result);
|
||||
return {};
|
||||
switch (acq_result) {
|
||||
case vk::Result::eSuccess:
|
||||
// Keep going.
|
||||
break;
|
||||
case vk::Result::eSuboptimalKHR:
|
||||
case vk::Result::eErrorOutOfDateKHR:
|
||||
// A recoverable error. Just say we are out of date.
|
||||
return AcquireResult{true /* out of date */};
|
||||
break;
|
||||
default:
|
||||
// An unrecoverable error.
|
||||
VALIDATION_LOG << "Could not acquire next swapchain image: "
|
||||
<< vk::to_string(acq_result);
|
||||
return AcquireResult{false /* out of date */};
|
||||
}
|
||||
|
||||
if (index >= images_.size()) {
|
||||
|
||||
Reference in New Issue
Block a user