|
|
|
@ -100,7 +100,7 @@ PresentWindow::PresentWindow(Frontend::EmuWindow& emu_window_, const Instance& i
|
|
|
|
|
Scheduler& scheduler_)
|
|
|
|
|
: emu_window{emu_window_}, instance{instance_}, scheduler{scheduler_},
|
|
|
|
|
surface{CreateSurface(instance.GetInstance(), emu_window)},
|
|
|
|
|
swapchain{instance, emu_window.GetFramebufferLayout().width,
|
|
|
|
|
next_surface{surface}, swapchain{instance, emu_window.GetFramebufferLayout().width,
|
|
|
|
|
emu_window.GetFramebufferLayout().height, surface},
|
|
|
|
|
graphics_queue{instance.GetGraphicsQueue()}, present_renderpass{CreateRenderpass()},
|
|
|
|
|
vsync_enabled{Settings::values.use_vsync_new.GetValue()},
|
|
|
|
@ -328,32 +328,26 @@ void PresentWindow::PresentThread(std::stop_token token) {
|
|
|
|
|
void PresentWindow::NotifySurfaceChanged() {
|
|
|
|
|
#ifdef ANDROID
|
|
|
|
|
std::scoped_lock lock{recreate_surface_mutex};
|
|
|
|
|
next_surface = CreateSurface(instance.GetInstance(), emu_window);
|
|
|
|
|
recreate_surface_cv.notify_one();
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PresentWindow::CopyToSwapchain(Frame* frame) {
|
|
|
|
|
const auto recreate_swapchain = [&] {
|
|
|
|
|
#ifdef ANDROID
|
|
|
|
|
{
|
|
|
|
|
std::unique_lock lock{recreate_surface_mutex};
|
|
|
|
|
recreate_surface_cv.wait(lock, [this]() { return surface != next_surface; });
|
|
|
|
|
surface = next_surface;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
std::scoped_lock submit_lock{scheduler.submit_mutex};
|
|
|
|
|
graphics_queue.waitIdle();
|
|
|
|
|
swapchain.Create(frame->width, frame->height, surface);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#ifdef ANDROID
|
|
|
|
|
std::unique_lock lock{recreate_surface_mutex};
|
|
|
|
|
|
|
|
|
|
recreate_surface_cv.wait_for(lock, std::chrono::milliseconds(400), [&]() {
|
|
|
|
|
return last_render_surface == emu_window.GetWindowInfo().render_surface;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// If the frontend recreated the surface, recreate the renderer surface and swapchain.
|
|
|
|
|
void* const render_surface = emu_window.GetWindowInfo().render_surface;
|
|
|
|
|
if (last_render_surface != render_surface) {
|
|
|
|
|
last_render_surface = render_surface;
|
|
|
|
|
surface = CreateSurface(instance.GetInstance(), emu_window);
|
|
|
|
|
recreate_swapchain();
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
#ifndef ANDROID
|
|
|
|
|
const bool use_vsync = Settings::values.use_vsync_new.GetValue();
|
|
|
|
|
const bool size_changed =
|
|
|
|
|
swapchain.GetWidth() != frame->width || swapchain.GetHeight() != frame->height;
|
|
|
|
|