Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle swapchain recreation #1830

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
10 changes: 7 additions & 3 deletions src/video_core/renderer_vulkan/vk_presenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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};
Expand Down
4 changes: 3 additions & 1 deletion src/video_core/renderer_vulkan/vk_swapchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ bool Swapchain::AcquireNextImage() {
return !needs_recreation;
}

void Swapchain::Present() {
bool Swapchain::Present() {

const vk::PresentInfoKHR present_info = {
.waitSemaphoreCount = 1,
Expand All @@ -131,6 +131,8 @@ void Swapchain::Present() {
}

frame_index = (frame_index + 1) % image_count;

return !needs_recreation;
}

void Swapchain::FindPresentFormat() {
Expand Down
2 changes: 1 addition & 1 deletion src/video_core/renderer_vulkan/vk_swapchain.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Swapchain {
bool AcquireNextImage();

/// Presents the current image and move to the next one
void Present();
bool Present();

vk::SurfaceKHR GetSurface() const {
return surface;
Expand Down
Loading