Fix frame pacing issues (#3032)

This commit is contained in:
Adrian Cojocaru
2024-11-26 18:53:41 +02:00
committed by GitHub
parent e394fcd4a4
commit 1a38075a1c
8 changed files with 32 additions and 12 deletions

View File

@@ -1100,6 +1100,10 @@ void GLFWView::run() {
}
render();
#ifndef __APPLE__
runLoop.updateTime();
#endif
};
// Cap frame rate to 60hz if benchmark mode is disabled

View File

@@ -13,8 +13,9 @@
class GLFWVulkanRenderableResource final : public mbgl::vulkan::SurfaceRenderableResource {
public:
explicit GLFWVulkanRenderableResource(GLFWVulkanBackend& backend_)
: SurfaceRenderableResource(backend_) {}
explicit GLFWVulkanRenderableResource(GLFWVulkanBackend& backend_, bool capFrameRate)
: SurfaceRenderableResource(backend_,
capFrameRate ? vk::PresentModeKHR::eFifo : vk::PresentModeKHR::eImmediate) {}
std::vector<const char*> getDeviceExtensions() override { return {VK_KHR_SWAPCHAIN_EXTENSION_NAME}; }
@@ -34,7 +35,7 @@ public:
void bind() override {}
};
GLFWVulkanBackend::GLFWVulkanBackend(GLFWwindow* window_, const bool)
GLFWVulkanBackend::GLFWVulkanBackend(GLFWwindow* window_, const bool capFrameRate)
: mbgl::vulkan::RendererBackend(mbgl::gfx::ContextMode::Unique),
mbgl::vulkan::Renderable(
[window_] {
@@ -43,7 +44,7 @@ GLFWVulkanBackend::GLFWVulkanBackend(GLFWwindow* window_, const bool)
glfwGetFramebufferSize(window_, &fbWidth, &fbHeight);
return mbgl::Size{static_cast<uint32_t>(fbWidth), static_cast<uint32_t>(fbHeight)};
}(),
std::make_unique<GLFWVulkanRenderableResource>(*this)),
std::make_unique<GLFWVulkanRenderableResource>(*this, capFrameRate)),
window(window_) {
init();
}