1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-02 01:24:11 +01:00

[dxgi] Don't use FIFO present mode if IMMEDIATE is not available

Might fix potential performance issues on Nvidia when VSYNC is disabled.
Based on RPCS3/rpcs3@25ec3789fe
This commit is contained in:
Philip Rebohle 2018-08-26 23:39:53 +02:00
parent 08a9963734
commit 5f42950650
3 changed files with 19 additions and 12 deletions

View File

@ -293,13 +293,13 @@ namespace dxvk {
}
void DxgiVkPresenter::RecreateSwapchain(DXGI_FORMAT Format, VkPresentModeKHR PresentMode, VkExtent2D WindowSize) {
void DxgiVkPresenter::RecreateSwapchain(DXGI_FORMAT Format, BOOL Vsync, VkExtent2D WindowSize) {
if (m_surface == nullptr)
m_surface = CreateSurface();
DxvkSwapchainProperties options;
options.preferredSurfaceFormat = PickSurfaceFormat(Format);
options.preferredPresentMode = PickPresentMode(PresentMode);
options.preferredPresentMode = PickPresentMode(Vsync);
options.preferredBufferSize = WindowSize;
const bool doRecreate =
@ -360,8 +360,19 @@ namespace dxvk {
}
VkPresentModeKHR DxgiVkPresenter::PickPresentMode(VkPresentModeKHR Preferred) const {
return m_surface->pickPresentMode(1, &Preferred);
VkPresentModeKHR DxgiVkPresenter::PickPresentMode(BOOL Vsync) const {
std::array<VkPresentModeKHR, 4> modes;
size_t n = 0;
if (Vsync) {
modes[n++] = VK_PRESENT_MODE_FIFO_KHR;
} else {
modes[n++] = VK_PRESENT_MODE_IMMEDIATE_KHR;
modes[n++] = VK_PRESENT_MODE_MAILBOX_KHR;
modes[n++] = VK_PRESENT_MODE_FIFO_RELAXED_KHR;
}
return m_surface->pickPresentMode(n, modes.data());
}

View File

@ -103,12 +103,12 @@ namespace dxvk {
* if any of the properties have changed. If no
* properties have changed, this is a no-op.
* \param [in] Format New surface format
* \param [in] PresentMode Present mode
* \param [in] Vsync Enable vertical sync
* \param [in] WindowSize Window size
*/
void RecreateSwapchain(
DXGI_FORMAT Format,
VkPresentModeKHR PresentMode,
BOOL Vsync,
VkExtent2D WindowSize);
/**
@ -164,7 +164,7 @@ namespace dxvk {
VkSurfaceFormatKHR PickSurfaceFormat(DXGI_FORMAT Fmt) const;
VkPresentModeKHR PickPresentMode(VkPresentModeKHR Preferred) const;
VkPresentModeKHR PickPresentMode(BOOL Vsync) const;
Rc<DxvkSurface> CreateSurface();

View File

@ -298,11 +298,7 @@ namespace dxvk {
// up vertical synchronization properly, but also apply
// changes that were made to the window size even if the
// Vulkan swap chain itself remains valid.
VkPresentModeKHR presentMode = SyncInterval == 0
? VK_PRESENT_MODE_IMMEDIATE_KHR
: VK_PRESENT_MODE_FIFO_KHR;
m_presenter->RecreateSwapchain(m_desc.Format, presentMode, GetWindowSize());
m_presenter->RecreateSwapchain(m_desc.Format, SyncInterval != 0, GetWindowSize());
m_presenter->PresentImage(SyncInterval, m_device->GetFrameSyncEvent());
return S_OK;
} catch (const DxvkError& err) {