vulkan

How to limit the frame rate in Vulkan


I know that the present mode of the swap chain can be used to sync the frame rate to the refresh rate of the screen (with VK_PRESENT_MODE_FIFO_KHR for example).

But is there a way of limiting the frame rate to a fraction of the monitor refresh rate? (eg. I want my application to run at 30 FPS instead of 60.)

In other words, is there a way of emulating what wglSwapIntervalEXT(2) does for OpenGL?


Solution

  • Vulkan is a low-level API. It tries to give you the tools you need to build the functionality you want.

    As such, when you present an image, the API assumes that you want the image presented as soon as possible (within the restrictions of the swapchain). If you want to delay presentation, then you delay presentation. That is, you don't present the image until it's near the time to present a new image, based on your own CPU timings.