Parameter to force V-Sync at swap chain creation
This commit is contained in:
parent
5f2a7fc537
commit
8b08d01157
1 changed files with 16 additions and 10 deletions
|
|
@ -235,7 +235,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the swap chain and get images with given width and height
|
// Create the swap chain and get images with given width and height
|
||||||
void create(VkCommandBuffer cmdBuffer, uint32_t *width, uint32_t *height)
|
void create(VkCommandBuffer cmdBuffer, uint32_t *width, uint32_t *height, VkBool32 vsync = VK_FALSE)
|
||||||
{
|
{
|
||||||
VkResult err;
|
VkResult err;
|
||||||
VkSwapchainKHR oldSwapchain = swapChain;
|
VkSwapchainKHR oldSwapchain = swapChain;
|
||||||
|
|
@ -273,8 +273,14 @@ public:
|
||||||
*height = surfCaps.currentExtent.height;
|
*height = surfCaps.currentExtent.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prefer mailbox mode if present, it's the lowest latency non-tearing present mode
|
|
||||||
|
// Select a present mode for the swapchain
|
||||||
|
// The VK_PRESENT_MODE_FIFO_KHR mode must always be present as per spec
|
||||||
|
// This mode waits for the vertical blank ("v-sync")
|
||||||
VkPresentModeKHR swapchainPresentMode = VK_PRESENT_MODE_FIFO_KHR;
|
VkPresentModeKHR swapchainPresentMode = VK_PRESENT_MODE_FIFO_KHR;
|
||||||
|
|
||||||
|
// If v-sync is not requested, try to find a mailbox mode if present
|
||||||
|
// It's the lowest latency non-tearing present mode available
|
||||||
for (size_t i = 0; i < presentModeCount; i++)
|
for (size_t i = 0; i < presentModeCount; i++)
|
||||||
{
|
{
|
||||||
if (presentModes[i] == VK_PRESENT_MODE_MAILBOX_KHR)
|
if (presentModes[i] == VK_PRESENT_MODE_MAILBOX_KHR)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue