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:
parent
f68bf1a187
commit
e615fc19a9
@ -143,7 +143,7 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxgiVkPresenter::PresentImage() {
|
void DxgiVkPresenter::PresentImage(UINT SyncInterval) {
|
||||||
if (m_hud != nullptr) {
|
if (m_hud != nullptr) {
|
||||||
m_hud->render({
|
m_hud->render({
|
||||||
m_options.preferredBufferSize.width,
|
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 =
|
const bool fitSize =
|
||||||
m_backBuffer->info().extent.width == m_options.preferredBufferSize.width
|
m_backBuffer->info().extent.width == m_options.preferredBufferSize.width
|
||||||
&& m_backBuffer->info().extent.height == m_options.preferredBufferSize.height;
|
&& m_backBuffer->info().extent.height == m_options.preferredBufferSize.height;
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < SyncInterval || i < 1; i++) {
|
||||||
m_context->beginRecording(
|
m_context->beginRecording(
|
||||||
m_device->createCommandList());
|
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;
|
VkImageSubresourceLayers resolveSubresources;
|
||||||
resolveSubresources.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
resolveSubresources.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||||
resolveSubresources.mipLevel = 0;
|
resolveSubresources.mipLevel = 0;
|
||||||
resolveSubresources.baseArrayLayer = 0;
|
resolveSubresources.baseArrayLayer = 0;
|
||||||
resolveSubresources.layerCount = 1;
|
resolveSubresources.layerCount = 1;
|
||||||
|
|
||||||
if (m_backBufferResolve != nullptr) {
|
|
||||||
m_context->resolveImage(
|
m_context->resolveImage(
|
||||||
m_backBufferResolve, resolveSubresources,
|
m_backBufferResolve, resolveSubresources,
|
||||||
m_backBuffer, resolveSubresources,
|
m_backBuffer, resolveSubresources,
|
||||||
@ -223,6 +229,7 @@ namespace dxvk {
|
|||||||
m_swapchain->present(
|
m_swapchain->present(
|
||||||
swapSemas.presentSync);
|
swapSemas.presentSync);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxgiVkPresenter::UpdateBackBuffer(const Rc<DxvkImage>& Image) {
|
void DxgiVkPresenter::UpdateBackBuffer(const Rc<DxvkImage>& Image) {
|
||||||
|
@ -82,8 +82,9 @@ namespace dxvk {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Renders back buffer to the screen
|
* \brief Renders back buffer to the screen
|
||||||
|
* \param [in] SyncInterval Vsync interval
|
||||||
*/
|
*/
|
||||||
void PresentImage();
|
void PresentImage(UINT SyncInterval);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Sets new back buffer
|
* \brief Sets new back buffer
|
||||||
|
@ -286,6 +286,12 @@ namespace dxvk {
|
|||||||
if (Flags & DXGI_PRESENT_TEST)
|
if (Flags & DXGI_PRESENT_TEST)
|
||||||
return S_OK;
|
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 {
|
try {
|
||||||
// If in fullscreen mode, apply any updated gamma curve
|
// If in fullscreen mode, apply any updated gamma curve
|
||||||
// if it has been changed since the last present call.
|
// if it has been changed since the last present call.
|
||||||
@ -311,7 +317,7 @@ namespace dxvk {
|
|||||||
: VK_PRESENT_MODE_FIFO_KHR;
|
: VK_PRESENT_MODE_FIFO_KHR;
|
||||||
|
|
||||||
m_presenter->RecreateSwapchain(m_desc.Format, presentMode, GetWindowSize());
|
m_presenter->RecreateSwapchain(m_desc.Format, presentMode, GetWindowSize());
|
||||||
m_presenter->PresentImage();
|
m_presenter->PresentImage(SyncInterval);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
} catch (const DxvkError& err) {
|
} catch (const DxvkError& err) {
|
||||||
Logger::err(err.message());
|
Logger::err(err.message());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user