Vulkan: Fix vsync behavior when throttler is temp disabled

This commit is contained in:
Stenzek
2016-10-02 22:09:19 +10:00
parent b193282830
commit 5e29508b8f
4 changed files with 32 additions and 17 deletions

View File

@ -19,18 +19,19 @@ class ObjectCache;
class SwapChain
{
public:
SwapChain(void* native_handle, VkSurfaceKHR surface);
SwapChain(void* native_handle, VkSurfaceKHR surface, bool vsync);
~SwapChain();
// Creates a vulkan-renderable surface for the specified window handle.
static VkSurfaceKHR CreateVulkanSurface(VkInstance instance, void* hwnd);
// Create a new swap chain from a pre-existing surface.
static std::unique_ptr<SwapChain> Create(void* native_handle, VkSurfaceKHR surface);
static std::unique_ptr<SwapChain> Create(void* native_handle, VkSurfaceKHR surface, bool vsync);
void* GetNativeHandle() const { return m_native_handle; }
VkSurfaceKHR GetSurface() const { return m_surface; }
VkSurfaceFormatKHR GetSurfaceFormat() const { return m_surface_format; }
bool IsVSyncEnabled() const { return m_vsync_enabled; }
VkSwapchainKHR GetSwapChain() const { return m_swap_chain; }
VkRenderPass GetRenderPass() const { return m_render_pass; }
u32 GetWidth() const { return m_width; }
@ -54,6 +55,9 @@ public:
bool RecreateSurface(void* native_handle);
bool ResizeSwapChain();
// Change vsync enabled state. This may fail as it causes a swapchain recreation.
bool SetVSync(bool enabled);
private:
bool SelectSurfaceFormat();
bool SelectPresentMode();
@ -76,10 +80,11 @@ private:
VkFramebuffer framebuffer;
};
void* m_native_handle = nullptr;
void* m_native_handle;
VkSurfaceKHR m_surface = VK_NULL_HANDLE;
VkSurfaceFormatKHR m_surface_format = {};
VkPresentModeKHR m_present_mode = VK_PRESENT_MODE_RANGE_SIZE_KHR;
bool m_vsync_enabled;
VkSwapchainKHR m_swap_chain = VK_NULL_HANDLE;
std::vector<SwapChainImage> m_swap_chain_images;