Handle swapchain recreation (#1830)
Some checks are pending
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / reuse (push) Waiting to run
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions

This commit is contained in:
Quang Ngô 2024-12-23 21:21:48 +07:00 committed by GitHub
parent 94f861588d
commit 400da1aa8d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 5 deletions

View file

@ -634,9 +634,11 @@ void Presenter::Present(Frame* frame) {
swapchain.Recreate(window.GetWidth(), window.GetHeight());
}
ImGui::Core::NewFrame();
if (!swapchain.AcquireNextImage()) {
swapchain.Recreate(window.GetWidth(), window.GetHeight());
}
swapchain.AcquireNextImage();
ImGui::Core::NewFrame();
const vk::Image swapchain_image = swapchain.Image();
@ -731,7 +733,9 @@ void Presenter::Present(Frame* frame) {
// Present to swapchain.
std::scoped_lock submit_lock{Scheduler::submit_mutex};
swapchain.Present();
if (!swapchain.Present()) {
swapchain.Recreate(window.GetWidth(), window.GetHeight());
}
// Free the frame for reuse
std::scoped_lock fl{free_mutex};

View file

@ -112,7 +112,7 @@ bool Swapchain::AcquireNextImage() {
return !needs_recreation;
}
void Swapchain::Present() {
bool Swapchain::Present() {
const vk::PresentInfoKHR present_info = {
.waitSemaphoreCount = 1,
@ -131,6 +131,8 @@ void Swapchain::Present() {
}
frame_index = (frame_index + 1) % image_count;
return !needs_recreation;
}
void Swapchain::FindPresentFormat() {

View file

@ -32,7 +32,7 @@ public:
bool AcquireNextImage();
/// Presents the current image and move to the next one
void Present();
bool Present();
vk::SurfaceKHR GetSurface() const {
return surface;