Add refresh rate to window/mode info

This commit is contained in:
Connor McLaughlin 2021-02-13 21:24:58 +10:00
parent 935c73fb6c
commit b811b78c09
2 changed files with 8 additions and 3 deletions

View File

@ -10,6 +10,7 @@
#include "util.h"
#include <algorithm>
#include <array>
#include <cmath>
Log_SetChannel(Vulkan::SwapChain);
#if defined(VK_USE_PLATFORM_XLIB_KHR)
@ -131,11 +132,14 @@ static VkSurfaceKHR CreateDisplaySurface(VkInstance instance, VkPhysicalDevice p
const VkDisplayModePropertiesKHR* matched_mode = nullptr;
for (const VkDisplayModePropertiesKHR& mode : modes)
{
Log_DevPrintf(" Mode %ux%u @ %u", mode.parameters.visibleRegion.width, mode.parameters.visibleRegion.height,
mode.parameters.refreshRate);
const float refresh_rate = static_cast<float>(mode.parameters.refreshRate) * 1000.0f;
Log_DevPrintf(" Mode %ux%u @ %f", mode.parameters.visibleRegion.width, mode.parameters.visibleRegion.height,
refresh_rate);
if (!matched_mode &&
((wi.surface_width == 0 && wi.surface_height == 0) ||
(mode.parameters.visibleRegion.width == wi.surface_width && mode.parameters.visibleRegion.height)))
(mode.parameters.visibleRegion.width == wi.surface_width && mode.parameters.visibleRegion.height &&
(wi.surface_refresh_rate == 0.0f || std::abs(refresh_rate - wi.surface_refresh_rate) < 0.1f))))
{
matched_mode = &mode;
}

View File

@ -30,6 +30,7 @@ struct WindowInfo
void* window_handle = nullptr;
u32 surface_width = 0;
u32 surface_height = 0;
float surface_refresh_rate = 0.0f;
float surface_scale = 1.0f;
SurfaceFormat surface_format = SurfaceFormat::RGB8;