mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-07-16 22:11:07 +00:00
[Video/KMSDRM]: Prefer largest compatible refresh rate by default.
This commit is contained in:
committed by
Sam Lantinga
parent
758dab45af
commit
52ec5120a0
@@ -156,6 +156,19 @@ char const * const *KMSDRM_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this,
|
||||
return extensionsForKMSDRM;
|
||||
}
|
||||
|
||||
static int SDLCALL display_mode_comparator(const void *a_opaque, const void *b_opaque)
|
||||
{
|
||||
const VkDisplayModePropertiesKHR *a = a_opaque;
|
||||
const VkDisplayModePropertiesKHR *b = b_opaque;
|
||||
|
||||
if (a->parameters.refreshRate > b->parameters.refreshRate)
|
||||
return -1;
|
||||
else if (a->parameters.refreshRate < b->parameters.refreshRate)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
// First thing to know is that we don't call vkCreateInstance() here.
|
||||
// Instead, programs using SDL and Vulkan create their Vulkan instance
|
||||
@@ -342,6 +355,9 @@ bool KMSDRM_Vulkan_CreateSurface(SDL_VideoDevice *_this,
|
||||
display,
|
||||
&mode_count, mode_props);
|
||||
|
||||
/* Sort the modes so that larger refresh rates come first. */
|
||||
SDL_qsort(mode_props, mode_count, sizeof(*mode_props), display_mode_comparator);
|
||||
|
||||
/* Get a video mode equal to the window size among the predefined ones,
|
||||
if possible.
|
||||
REMEMBER: We have to get a small enough videomode for the window size,
|
||||
|
||||
Reference in New Issue
Block a user