[Commits] SDL: SDL - add SDL_WINDOW_VULKAN and make Android_CreateWindow o...

libsdl.org revision control commits-owner at libsdl.org
Tue May 16 14:23:34 PDT 2017


details:   https://hg.libsdl.org/SDL/rev/40ff26e5a853
changeset: 11006:40ff26e5a853
user:      Sam Lantinga <slouken at libsdl.org>
date:      Tue May 16 06:30:39 2017 -0700
description:
SDL - add SDL_WINDOW_VULKAN and make Android_CreateWindow only create an EGLSurface when SDL_WINDOW_VULKAN is not present.  This makes it so the ANativeWindow* can be used with vkCreateAndroidSurfaceKHR, otherwise it will fail because having both an EGLSurface and VkSurfaceKHR attached to a window is not allowed according to the Vulkan spec:

"In particular, only one VkSurfaceKHR can exist at a time for a given window. Similarly, a native window cannot be used by both a VkSurfaceKHR and EGLSurface simultaneously"

CR: SamL

diffstat:

 include/SDL_video.h                   |   3 ++-
 src/video/SDL_video.c                 |   2 +-
 src/video/android/SDL_androidwindow.c |  16 ++++++++++------
 3 files changed, 13 insertions(+), 8 deletions(-)

diffs (52 lines):

diff -r 5f5bd41b1fc6 -r 40ff26e5a853 include/SDL_video.h
--- a/include/SDL_video.h	Sat May 13 23:01:04 2017 +0200
+++ b/include/SDL_video.h	Tue May 16 06:30:39 2017 -0700
@@ -116,7 +116,8 @@
     SDL_WINDOW_SKIP_TASKBAR  = 0x00010000,      /**< window should not be added to the taskbar */
     SDL_WINDOW_UTILITY       = 0x00020000,      /**< window should be treated as a utility window */
     SDL_WINDOW_TOOLTIP       = 0x00040000,      /**< window should be treated as a tooltip */
-    SDL_WINDOW_POPUP_MENU    = 0x00080000       /**< window should be treated as a popup menu */
+    SDL_WINDOW_POPUP_MENU    = 0x00080000,      /**< window should be treated as a popup menu */
+    SDL_WINDOW_VULKAN        = 0x00100000       /**< window usable for Vulkan surface */
 } SDL_WindowFlags;
 
 /**
diff -r 5f5bd41b1fc6 -r 40ff26e5a853 src/video/SDL_video.c
--- a/src/video/SDL_video.c	Sat May 13 23:01:04 2017 +0200
+++ b/src/video/SDL_video.c	Tue May 16 06:30:39 2017 -0700
@@ -1321,7 +1321,7 @@
 }
 
 #define CREATE_FLAGS \
-    (SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_ALWAYS_ON_TOP | SDL_WINDOW_SKIP_TASKBAR | SDL_WINDOW_POPUP_MENU | SDL_WINDOW_UTILITY | SDL_WINDOW_TOOLTIP)
+    (SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_ALWAYS_ON_TOP | SDL_WINDOW_SKIP_TASKBAR | SDL_WINDOW_POPUP_MENU | SDL_WINDOW_UTILITY | SDL_WINDOW_TOOLTIP | SDL_WINDOW_VULKAN )
 
 static void
 SDL_FinishWindowCreation(SDL_Window *window, Uint32 flags)
diff -r 5f5bd41b1fc6 -r 40ff26e5a853 src/video/android/SDL_androidwindow.c
--- a/src/video/android/SDL_androidwindow.c	Sat May 13 23:01:04 2017 +0200
+++ b/src/video/android/SDL_androidwindow.c	Tue May 16 06:30:39 2017 -0700
@@ -69,13 +69,17 @@
         SDL_free(data);
         return SDL_SetError("Could not fetch native window");
     }
-    
-    data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) data->native_window);
 
-    if (data->egl_surface == EGL_NO_SURFACE) {
-        ANativeWindow_release(data->native_window);
-        SDL_free(data);
-        return SDL_SetError("Could not create GLES window surface");
+    /* Do not create EGLSurface for Vulkan window since it will then make the window
+       incompatible with vkCreateAndroidSurfaceKHR */
+    if ((window->flags & SDL_WINDOW_VULKAN) == 0) {
+        data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) data->native_window);
+
+        if (data->egl_surface == EGL_NO_SURFACE) {
+            ANativeWindow_release(data->native_window);
+            SDL_free(data);
+            return SDL_SetError("Could not create GLES window surface");
+        }
     }
 
     window->driverdata = data;


More information about the commits mailing list