Commit c13c3c37bdb6eda5d45b63d1ae1c9942e75510d4

Vanfanel 2021-03-27T22:50:18

[KMSDRM] For Vulkan, use a mode with the same exact size as the window, if possible, or create a new one.

diff --git a/src/video/kmsdrm/SDL_kmsdrmvulkan.c b/src/video/kmsdrm/SDL_kmsdrmvulkan.c
index 130a142..c7c3f5b 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvulkan.c
+++ b/src/video/kmsdrm/SDL_kmsdrmvulkan.c
@@ -367,14 +367,15 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS,
     planes_props = SDL_malloc(sizeof(VkDisplayPlanePropertiesKHR) * plane_count);
     vkGetPhysicalDeviceDisplayPlanePropertiesKHR(gpu, &plane_count, planes_props);
 
-    /* Get a video mode equal or smaller than the window size. REMEMBER:
-       We have to get a small enough videomode for the window size,
+    /* 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,
        because videomode determines how big the scanout region is and we can't
        scanout a region bigger than the window (we would be reading past the
        buffer, and Vulkan would give us a confusing VK_ERROR_SURFACE_LOST_KHR). */
     for (i = 0; i < mode_count; i++) {
-        if (modes_props[i].parameters.visibleRegion.width <= window->w &&
-            modes_props[i].parameters.visibleRegion.height <= window->h)
+        if (modes_props[i].parameters.visibleRegion.width == window->w &&
+            modes_props[i].parameters.visibleRegion.height == window->h)
         {
             display_mode_props = modes_props[i];
             mode_found = SDL_TRUE;