mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-31 14:52:11 +01:00
[dxgi] Use DXGI back buffer count for the Vulkan swap chain
This commit is contained in:
parent
45f61cbae5
commit
b7d8be25f1
@ -25,6 +25,7 @@ namespace dxvk {
|
|||||||
m_options.preferredSurfaceFormat = { VK_FORMAT_UNDEFINED, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR };
|
m_options.preferredSurfaceFormat = { VK_FORMAT_UNDEFINED, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR };
|
||||||
m_options.preferredPresentMode = VK_PRESENT_MODE_FIFO_KHR;
|
m_options.preferredPresentMode = VK_PRESENT_MODE_FIFO_KHR;
|
||||||
m_options.preferredBufferSize = { 0u, 0u };
|
m_options.preferredBufferSize = { 0u, 0u };
|
||||||
|
m_options.preferredBufferCount = 0;
|
||||||
|
|
||||||
// Samplers for presentation. We'll create one with point sampling that will
|
// Samplers for presentation. We'll create one with point sampling that will
|
||||||
// be used when the back buffer resolution matches the output resolution, and
|
// be used when the back buffer resolution matches the output resolution, and
|
||||||
@ -293,7 +294,7 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxgiVkPresenter::RecreateSwapchain(DXGI_FORMAT Format, BOOL Vsync, VkExtent2D WindowSize) {
|
void DxgiVkPresenter::RecreateSwapchain(DXGI_FORMAT Format, BOOL Vsync, VkExtent2D WindowSize, UINT BufferCount) {
|
||||||
if (m_surface == nullptr)
|
if (m_surface == nullptr)
|
||||||
m_surface = CreateSurface();
|
m_surface = CreateSurface();
|
||||||
|
|
||||||
@ -301,6 +302,7 @@ namespace dxvk {
|
|||||||
options.preferredSurfaceFormat = PickSurfaceFormat(Format);
|
options.preferredSurfaceFormat = PickSurfaceFormat(Format);
|
||||||
options.preferredPresentMode = PickPresentMode(Vsync);
|
options.preferredPresentMode = PickPresentMode(Vsync);
|
||||||
options.preferredBufferSize = WindowSize;
|
options.preferredBufferSize = WindowSize;
|
||||||
|
options.preferredBufferCount = BufferCount;
|
||||||
|
|
||||||
const bool doRecreate =
|
const bool doRecreate =
|
||||||
options.preferredSurfaceFormat.format != m_options.preferredSurfaceFormat.format
|
options.preferredSurfaceFormat.format != m_options.preferredSurfaceFormat.format
|
||||||
|
@ -105,11 +105,13 @@ namespace dxvk {
|
|||||||
* \param [in] Format New surface format
|
* \param [in] Format New surface format
|
||||||
* \param [in] Vsync Enable vertical sync
|
* \param [in] Vsync Enable vertical sync
|
||||||
* \param [in] WindowSize Window size
|
* \param [in] WindowSize Window size
|
||||||
|
* \param [in] BufferCount Swap image count
|
||||||
*/
|
*/
|
||||||
void RecreateSwapchain(
|
void RecreateSwapchain(
|
||||||
DXGI_FORMAT Format,
|
DXGI_FORMAT Format,
|
||||||
BOOL Vsync,
|
BOOL Vsync,
|
||||||
VkExtent2D WindowSize);
|
VkExtent2D WindowSize,
|
||||||
|
UINT BufferCount);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Sets gamma curve
|
* \brief Sets gamma curve
|
||||||
|
@ -272,6 +272,10 @@ namespace dxvk {
|
|||||||
std::lock_guard<std::mutex> lockWin(m_lockWindow);
|
std::lock_guard<std::mutex> lockWin(m_lockWindow);
|
||||||
std::lock_guard<std::mutex> lockBuf(m_lockBuffer);
|
std::lock_guard<std::mutex> lockBuf(m_lockBuffer);
|
||||||
|
|
||||||
|
// Retrieve the number of back buffers. If this option
|
||||||
|
// was defined by the user, it overrides app settings.
|
||||||
|
uint32_t bufferCount = m_desc.BufferCount;
|
||||||
|
|
||||||
// Higher values are not allowed according to the Microsoft documentation:
|
// Higher values are not allowed according to the Microsoft documentation:
|
||||||
//
|
//
|
||||||
// "1 through 4 - Synchronize presentation after the nth vertical blank."
|
// "1 through 4 - Synchronize presentation after the nth vertical blank."
|
||||||
@ -298,7 +302,7 @@ namespace dxvk {
|
|||||||
// up vertical synchronization properly, but also apply
|
// up vertical synchronization properly, but also apply
|
||||||
// changes that were made to the window size even if the
|
// changes that were made to the window size even if the
|
||||||
// Vulkan swap chain itself remains valid.
|
// Vulkan swap chain itself remains valid.
|
||||||
m_presenter->RecreateSwapchain(m_desc.Format, SyncInterval != 0, GetWindowSize());
|
m_presenter->RecreateSwapchain(m_desc.Format, SyncInterval != 0, GetWindowSize(), bufferCount);
|
||||||
m_presenter->PresentImage(SyncInterval, m_device->GetFrameSyncEvent());
|
m_presenter->PresentImage(SyncInterval, m_device->GetFrameSyncEvent());
|
||||||
return S_OK;
|
return S_OK;
|
||||||
} catch (const DxvkError& err) {
|
} catch (const DxvkError& err) {
|
||||||
|
@ -87,12 +87,15 @@ namespace dxvk {
|
|||||||
|
|
||||||
uint32_t DxvkSurface::pickImageCount(
|
uint32_t DxvkSurface::pickImageCount(
|
||||||
const VkSurfaceCapabilitiesKHR& caps,
|
const VkSurfaceCapabilitiesKHR& caps,
|
||||||
VkPresentModeKHR mode) const {
|
VkPresentModeKHR mode,
|
||||||
|
uint32_t preferred) const {
|
||||||
uint32_t count = caps.minImageCount;
|
uint32_t count = caps.minImageCount;
|
||||||
|
|
||||||
if (mode == VK_PRESENT_MODE_MAILBOX_KHR
|
if (mode != VK_PRESENT_MODE_IMMEDIATE_KHR)
|
||||||
|| mode == VK_PRESENT_MODE_FIFO_KHR)
|
count = caps.minImageCount + 1;
|
||||||
count += 1;
|
|
||||||
|
if (count < preferred)
|
||||||
|
count = preferred;
|
||||||
|
|
||||||
if (count > caps.maxImageCount && caps.maxImageCount != 0)
|
if (count > caps.maxImageCount && caps.maxImageCount != 0)
|
||||||
count = caps.maxImageCount;
|
count = caps.maxImageCount;
|
||||||
|
@ -65,11 +65,13 @@ namespace dxvk {
|
|||||||
*
|
*
|
||||||
* \param [in] caps Surface capabilities
|
* \param [in] caps Surface capabilities
|
||||||
* \param [in] mode The present mode
|
* \param [in] mode The present mode
|
||||||
|
* \param [in] preferred Preferred image count
|
||||||
* \returns Suitable image count
|
* \returns Suitable image count
|
||||||
*/
|
*/
|
||||||
uint32_t pickImageCount(
|
uint32_t pickImageCount(
|
||||||
const VkSurfaceCapabilitiesKHR& caps,
|
const VkSurfaceCapabilitiesKHR& caps,
|
||||||
VkPresentModeKHR mode) const;
|
VkPresentModeKHR mode,
|
||||||
|
uint32_t preferred) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Picks a suitable image size for a swap chain
|
* \brief Picks a suitable image size for a swap chain
|
||||||
|
@ -117,7 +117,7 @@ namespace dxvk {
|
|||||||
swapInfo.pNext = nullptr;
|
swapInfo.pNext = nullptr;
|
||||||
swapInfo.flags = 0;
|
swapInfo.flags = 0;
|
||||||
swapInfo.surface = m_surface->handle();
|
swapInfo.surface = m_surface->handle();
|
||||||
swapInfo.minImageCount = m_surface->pickImageCount(caps, mode);
|
swapInfo.minImageCount = m_surface->pickImageCount(caps, mode, m_properties.preferredBufferCount);
|
||||||
swapInfo.imageFormat = fmt.format;
|
swapInfo.imageFormat = fmt.format;
|
||||||
swapInfo.imageColorSpace = fmt.colorSpace;
|
swapInfo.imageColorSpace = fmt.colorSpace;
|
||||||
swapInfo.imageExtent = m_surface->pickImageExtent(caps, m_properties.preferredBufferSize);
|
swapInfo.imageExtent = m_surface->pickImageExtent(caps, m_properties.preferredBufferSize);
|
||||||
|
@ -28,6 +28,7 @@ namespace dxvk {
|
|||||||
VkSurfaceFormatKHR preferredSurfaceFormat;
|
VkSurfaceFormatKHR preferredSurfaceFormat;
|
||||||
VkPresentModeKHR preferredPresentMode;
|
VkPresentModeKHR preferredPresentMode;
|
||||||
VkExtent2D preferredBufferSize;
|
VkExtent2D preferredBufferSize;
|
||||||
|
uint32_t preferredBufferCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user