Implement live updating swap interval value for vulkan

This commit is contained in:
Benau 2022-04-02 14:17:27 +08:00
parent 3994ce5666
commit a98a470ea8
2 changed files with 16 additions and 0 deletions

View File

@ -320,6 +320,14 @@ namespace GE
{ return m_pre_rotation_matrix; }
virtual void pauseRendering();
virtual void unpauseRendering();
void updateSwapInterval(int value)
{
if (m_params.SwapInterval == value)
return;
m_params.SwapInterval = value;
destroySwapChainRelated(false/*handle_surface*/);
createSwapChainRelated(false/*handle_surface*/);
}
private:
struct SwapChainSupportDetails
{

View File

@ -20,6 +20,7 @@
#include "COpenGLExtensionHandler.h"
#include "guiengine/engine.hpp"
#include "ge_main.hpp"
#include "glad/gl.h"
#include "ge_vulkan_driver.hpp"
#include "MoltenVK.h"
@ -330,6 +331,13 @@ extern "C" void update_swap_interval(int swap_interval)
if (swap_interval > 1)
swap_interval = 1;
GE::GEVulkanDriver* gevk = GE::getVKDriver();
if (gevk)
{
gevk->updateSwapInterval(swap_interval);
return;
}
// Try adaptive vsync first if support
if (swap_interval > 0)
{