1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-31 14:52:11 +01:00

[dxgi] Support SyncInterval values > 1

Required for Eve Online and the Unity Blacksmith demo.
This commit is contained in:
Philip Rebohle 2018-05-28 21:06:35 +02:00
parent f68bf1a187
commit e615fc19a9
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 81 additions and 67 deletions

View File

@ -143,7 +143,7 @@ namespace dxvk {
}
void DxgiVkPresenter::PresentImage() {
void DxgiVkPresenter::PresentImage(UINT SyncInterval) {
if (m_hud != nullptr) {
m_hud->render({
m_options.preferredBufferSize.width,
@ -151,20 +151,26 @@ namespace dxvk {
});
}
// Check whether the back buffer size is the same
// as the window size, in which case we should use
// VK_FILTER_NEAREST to avoid blurry output
const bool fitSize =
m_backBuffer->info().extent.width == m_options.preferredBufferSize.width
&& m_backBuffer->info().extent.height == m_options.preferredBufferSize.height;
for (uint32_t i = 0; i < SyncInterval || i < 1; i++) {
m_context->beginRecording(
m_device->createCommandList());
// Resolve back buffer if it is multisampled. We
// only have to do it only for the first frame.
if (m_backBufferResolve != nullptr && i == 0) {
VkImageSubresourceLayers resolveSubresources;
resolveSubresources.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
resolveSubresources.mipLevel = 0;
resolveSubresources.baseArrayLayer = 0;
resolveSubresources.layerCount = 1;
if (m_backBufferResolve != nullptr) {
m_context->resolveImage(
m_backBufferResolve, resolveSubresources,
m_backBuffer, resolveSubresources,
@ -223,6 +229,7 @@ namespace dxvk {
m_swapchain->present(
swapSemas.presentSync);
}
}
void DxgiVkPresenter::UpdateBackBuffer(const Rc<DxvkImage>& Image) {

View File

@ -82,8 +82,9 @@ namespace dxvk {
/**
* \brief Renders back buffer to the screen
* \param [in] SyncInterval Vsync interval
*/
void PresentImage();
void PresentImage(UINT SyncInterval);
/**
* \brief Sets new back buffer

View File

@ -286,6 +286,12 @@ namespace dxvk {
if (Flags & DXGI_PRESENT_TEST)
return S_OK;
// Higher values are not allowed according to the Microsoft documentation:
//
// "1 through 4 - Synchronize presentation after the nth vertical blank."
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb174576(v=vs.85).aspx
SyncInterval = std::min<UINT>(SyncInterval, 4);
try {
// If in fullscreen mode, apply any updated gamma curve
// if it has been changed since the last present call.
@ -311,7 +317,7 @@ namespace dxvk {
: VK_PRESENT_MODE_FIFO_KHR;
m_presenter->RecreateSwapchain(m_desc.Format, presentMode, GetWindowSize());
m_presenter->PresentImage();
m_presenter->PresentImage(SyncInterval);
return S_OK;
} catch (const DxvkError& err) {
Logger::err(err.message());