mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-15 07:29:17 +01:00
[vulkan] Add frame rate limiter to Vulkan presenter
This commit is contained in:
parent
a16c861358
commit
b537f19a3c
@ -89,6 +89,11 @@ namespace dxvk::vk {
|
|||||||
m_acquireStatus = m_vkd->vkAcquireNextImageKHR(m_vkd->device(),
|
m_acquireStatus = m_vkd->vkAcquireNextImageKHR(m_vkd->device(),
|
||||||
m_swapchain, std::numeric_limits<uint64_t>::max(),
|
m_swapchain, std::numeric_limits<uint64_t>::max(),
|
||||||
sync.acquire, VK_NULL_HANDLE, &m_imageIndex);
|
sync.acquire, VK_NULL_HANDLE, &m_imageIndex);
|
||||||
|
|
||||||
|
bool vsync = m_info.presentMode == VK_PRESENT_MODE_FIFO_KHR
|
||||||
|
|| m_info.presentMode == VK_PRESENT_MODE_FIFO_RELAXED_KHR;
|
||||||
|
|
||||||
|
m_fpsLimiter.delay(vsync);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,6 +243,16 @@ namespace dxvk::vk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Presenter::setFrameRateLimit(double frameRate) {
|
||||||
|
m_fpsLimiter.setTargetFrameRate(frameRate);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Presenter::setFrameRateLimiterRefreshRate(double refreshRate) {
|
||||||
|
m_fpsLimiter.setDisplayRefreshRate(refreshRate);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
VkResult Presenter::getSupportedFormats(std::vector<VkSurfaceFormatKHR>& formats, const PresenterDesc& desc) {
|
VkResult Presenter::getSupportedFormats(std::vector<VkSurfaceFormatKHR>& formats, const PresenterDesc& desc) {
|
||||||
uint32_t numFormats = 0;
|
uint32_t numFormats = 0;
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "../util/log/log.h"
|
#include "../util/log/log.h"
|
||||||
|
|
||||||
#include "../util/util_error.h"
|
#include "../util/util_error.h"
|
||||||
|
#include "../util/util_fps_limiter.h"
|
||||||
#include "../util/util_math.h"
|
#include "../util/util_math.h"
|
||||||
#include "../util/util_string.h"
|
#include "../util/util_string.h"
|
||||||
|
|
||||||
@ -152,6 +153,24 @@ namespace dxvk::vk {
|
|||||||
VkResult recreateSwapChain(
|
VkResult recreateSwapChain(
|
||||||
const PresenterDesc& desc);
|
const PresenterDesc& desc);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Changes maximum frame rate
|
||||||
|
*
|
||||||
|
* \param [in] frameRate Target frame rate. Set
|
||||||
|
* to 0 in order to disable the limiter.
|
||||||
|
*/
|
||||||
|
void setFrameRateLimit(double frameRate);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Notifies frame rate limiter about the display refresh rate
|
||||||
|
*
|
||||||
|
* Used to dynamically disable the frame rate limiter in case
|
||||||
|
* vertical synchronization is used and the target frame rate
|
||||||
|
* roughly equals the display's refresh rate.
|
||||||
|
* \param [in] refresnRate Current refresh rate
|
||||||
|
*/
|
||||||
|
void setFrameRateLimiterRefreshRate(double refreshRate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Checks whether a Vulkan swap chain exists
|
* \brief Checks whether a Vulkan swap chain exists
|
||||||
*
|
*
|
||||||
@ -184,6 +203,8 @@ namespace dxvk::vk {
|
|||||||
|
|
||||||
VkResult m_acquireStatus = VK_NOT_READY;
|
VkResult m_acquireStatus = VK_NOT_READY;
|
||||||
|
|
||||||
|
FpsLimiter m_fpsLimiter;
|
||||||
|
|
||||||
VkResult getSupportedFormats(
|
VkResult getSupportedFormats(
|
||||||
std::vector<VkSurfaceFormatKHR>& formats,
|
std::vector<VkSurfaceFormatKHR>& formats,
|
||||||
const PresenterDesc& desc);
|
const PresenterDesc& desc);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user